text stringlengths 0 828 |
|---|
self.view.keypress(size, ""home"")" |
573,"def save_file(self): |
""""""Write the file out to disk."""""" |
l = [] |
walk = self.walker |
for edit in walk.lines: |
# collect the text already stored in edit widgets |
if edit.original_text.expandtabs() == edit.edit_text: |
l.append(edit.original_text) |
else: |
l.append(re_tab(edit.edit_text)) |
# then the rest |
while walk.file is not None: |
l.append(walk.read_next_line()) |
# write back to disk |
outfile = open(self.save_name, ""w"") |
l_iter = iter(l) |
line = next(l_iter) |
prefix = """" |
while True: |
try: |
outfile.write(prefix + line) |
prefix = ""\n"" |
line = next(l_iter) |
except StopIteration: |
if line != ""\n"": |
outfile.write(""\n"") |
break" |
574,"def _media(self): |
"""""" |
Returns a forms.Media instance with the basic editor media and media |
from all registered extensions. |
"""""" |
css = ['markymark/css/markdown-editor.css'] |
iconlibrary_css = getattr( |
settings, |
'MARKYMARK_FONTAWESOME_CSS', |
'markymark/fontawesome/fontawesome.min.css' |
) |
if iconlibrary_css: |
css.append(iconlibrary_css) |
media = forms.Media( |
css={'all': css}, |
js=('markymark/js/markdown-editor.js',) |
) |
# Use official extension loading to initialize all extensions |
# and hook in extension-defined media files. |
renderer = initialize_renderer() |
for extension in renderer.registeredExtensions: |
if hasattr(extension, 'media'): |
media += extension.media |
return media" |
575,"def rel(path, parent=None, par=False): |
"""""" |
Takes *path* and computes the relative path from *parent*. If *parent* is |
omitted, the current working directory is used. |
If *par* is #True, a relative path is always created when possible. |
Otherwise, a relative path is only returned if *path* lives inside the |
*parent* directory. |
"""""" |
try: |
res = os.path.relpath(path, parent) |
except ValueError: |
# Raised eg. on Windows for differing drive letters. |
if not par: |
return abs(path) |
raise |
else: |
if not par and not issub(res): |
return abs(path) |
return res" |
576,"def issub(path): |
"""""" |
Returns #True if *path* is a relative path that does not point outside |
of its parent directory or is equal to its parent directory (thus, this |
function will also return False for a path like `./`). |
"""""" |
if isabs(path): |
return False |
if path.startswith(curdir + sep) or path.startswith(pardir + sep) or \ |
path == curdir or path == pardir: |
return False |
return True" |
577,"def glob(patterns, parent=None, excludes=None, include_dotfiles=False, |
ignore_false_excludes=False): |
"""""" |
Wrapper for #glob2.glob() that accepts an arbitrary number of |
patterns and matches them. The paths are normalized with #norm(). |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.