repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
lewisjared/credkeep | credkeep/util.py | enc_to_clear_filename | def enc_to_clear_filename(fname):
"""
Converts the filename of an encrypted file to cleartext
:param fname:
:return: filename of clear secret file if found, else None
"""
if not fname.lower().endswith('.json'):
raise CredkeepException('Invalid filetype')
if not fname.lower().endswi... | python | def enc_to_clear_filename(fname):
"""
Converts the filename of an encrypted file to cleartext
:param fname:
:return: filename of clear secret file if found, else None
"""
if not fname.lower().endswith('.json'):
raise CredkeepException('Invalid filetype')
if not fname.lower().endswi... | [
"def",
"enc_to_clear_filename",
"(",
"fname",
")",
":",
"if",
"not",
"fname",
".",
"lower",
"(",
")",
".",
"endswith",
"(",
"'.json'",
")",
":",
"raise",
"CredkeepException",
"(",
"'Invalid filetype'",
")",
"if",
"not",
"fname",
".",
"lower",
"(",
")",
"... | Converts the filename of an encrypted file to cleartext
:param fname:
:return: filename of clear secret file if found, else None | [
"Converts",
"the",
"filename",
"of",
"an",
"encrypted",
"file",
"to",
"cleartext"
] | train | https://github.com/lewisjared/credkeep/blob/63638ced094992552a28109b91839bcbbbe9230a/credkeep/util.py#L30-L46 |
kevinsprong23/aperture | aperture/heatmaps.py | calc_2d_hist | def calc_2d_hist(x, y, step=None, min_pt=None, max_pt=None):
"""
given two vectors x and y, calculate a 2-d histogram matrix
x = data list
y = data list
step = either a scalar dx/dy, or a tuple (dx,dy)
min = tuple for lower left of bounding box (minx, miny)
max = tuple for upper right of bou... | python | def calc_2d_hist(x, y, step=None, min_pt=None, max_pt=None):
"""
given two vectors x and y, calculate a 2-d histogram matrix
x = data list
y = data list
step = either a scalar dx/dy, or a tuple (dx,dy)
min = tuple for lower left of bounding box (minx, miny)
max = tuple for upper right of bou... | [
"def",
"calc_2d_hist",
"(",
"x",
",",
"y",
",",
"step",
"=",
"None",
",",
"min_pt",
"=",
"None",
",",
"max_pt",
"=",
"None",
")",
":",
"# rough data boundary ",
"minx",
"=",
"min",
"(",
"x",
")",
"maxx",
"=",
"max",
"(",
"x",
")",
"miny",
"=",
... | given two vectors x and y, calculate a 2-d histogram matrix
x = data list
y = data list
step = either a scalar dx/dy, or a tuple (dx,dy)
min = tuple for lower left of bounding box (minx, miny)
max = tuple for upper right of bounding box
returns: a tuple (x_vec, y_vec, hist_matrix) | [
"given",
"two",
"vectors",
"x",
"and",
"y",
"calculate",
"a",
"2",
"-",
"d",
"histogram",
"matrix",
"x",
"=",
"data",
"list",
"y",
"=",
"data",
"list",
"step",
"=",
"either",
"a",
"scalar",
"dx",
"/",
"dy",
"or",
"a",
"tuple",
"(",
"dx",
"dy",
")... | train | https://github.com/kevinsprong23/aperture/blob/d0420fef3b25d8afc0e5ddcfb6fe5f0ff42b9799/aperture/heatmaps.py#L10-L85 |
kevinsprong23/aperture | aperture/heatmaps.py | init_heatmap | def init_heatmap(x_vec, y_vec, hist_matrix, fig, colormap='Blues',
alpha=1, grid=False, colorbar=True,
vmax='auto', vmin='auto', crop=True):
"""
convenience function to initialize a standard colormap in a figure
"""
plt.figure(fig.number)
ax = fig.gca()
# set v... | python | def init_heatmap(x_vec, y_vec, hist_matrix, fig, colormap='Blues',
alpha=1, grid=False, colorbar=True,
vmax='auto', vmin='auto', crop=True):
"""
convenience function to initialize a standard colormap in a figure
"""
plt.figure(fig.number)
ax = fig.gca()
# set v... | [
"def",
"init_heatmap",
"(",
"x_vec",
",",
"y_vec",
",",
"hist_matrix",
",",
"fig",
",",
"colormap",
"=",
"'Blues'",
",",
"alpha",
"=",
"1",
",",
"grid",
"=",
"False",
",",
"colorbar",
"=",
"True",
",",
"vmax",
"=",
"'auto'",
",",
"vmin",
"=",
"'auto'... | convenience function to initialize a standard colormap in a figure | [
"convenience",
"function",
"to",
"initialize",
"a",
"standard",
"colormap",
"in",
"a",
"figure"
] | train | https://github.com/kevinsprong23/aperture/blob/d0420fef3b25d8afc0e5ddcfb6fe5f0ff42b9799/aperture/heatmaps.py#L88-L120 |
kevinsprong23/aperture | aperture/heatmaps.py | heatmap | def heatmap(x, y, step=None, min_pt=None, max_pt=None,
colormap='Blues', alpha=1, grid=False,
colorbar=True, scale='lin',
vmax='auto', vmin='auto', crop=True):
"""
function to take vectors x and y and hist them
"""
(x_vec, y_vec, hist_matrix) = calc_2d_... | python | def heatmap(x, y, step=None, min_pt=None, max_pt=None,
colormap='Blues', alpha=1, grid=False,
colorbar=True, scale='lin',
vmax='auto', vmin='auto', crop=True):
"""
function to take vectors x and y and hist them
"""
(x_vec, y_vec, hist_matrix) = calc_2d_... | [
"def",
"heatmap",
"(",
"x",
",",
"y",
",",
"step",
"=",
"None",
",",
"min_pt",
"=",
"None",
",",
"max_pt",
"=",
"None",
",",
"colormap",
"=",
"'Blues'",
",",
"alpha",
"=",
"1",
",",
"grid",
"=",
"False",
",",
"colorbar",
"=",
"True",
",",
"scale"... | function to take vectors x and y and hist them | [
"function",
"to",
"take",
"vectors",
"x",
"and",
"y",
"and",
"hist",
"them"
] | train | https://github.com/kevinsprong23/aperture/blob/d0420fef3b25d8afc0e5ddcfb6fe5f0ff42b9799/aperture/heatmaps.py#L123-L144 |
jalanb/pysyte | pysyte/paths.py | ext_language | def ext_language(ext, exts=None):
"""Language of the extension in those extensions
If exts is supplied, then restrict recognition to those exts only
If exts is not supplied, then use all known extensions
>>> ext_language('.py') == 'python'
True
"""
languages = {
'.py': 'python',
... | python | def ext_language(ext, exts=None):
"""Language of the extension in those extensions
If exts is supplied, then restrict recognition to those exts only
If exts is not supplied, then use all known extensions
>>> ext_language('.py') == 'python'
True
"""
languages = {
'.py': 'python',
... | [
"def",
"ext_language",
"(",
"ext",
",",
"exts",
"=",
"None",
")",
":",
"languages",
"=",
"{",
"'.py'",
":",
"'python'",
",",
"'.py2'",
":",
"'python2'",
",",
"'.py3'",
":",
"'python3'",
",",
"'.sh'",
":",
"'bash'",
",",
"'.bash'",
":",
"'bash'",
",",
... | Language of the extension in those extensions
If exts is supplied, then restrict recognition to those exts only
If exts is not supplied, then use all known extensions
>>> ext_language('.py') == 'python'
True | [
"Language",
"of",
"the",
"extension",
"in",
"those",
"extensions"
] | train | https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/paths.py#L273-L293 |
jalanb/pysyte | pysyte/paths.py | find_language | def find_language(script, exts=None):
"""Determine the script's language extension
>>> this_script = __file__.rstrip('c')
>>> find_language(makepath(this_script)) == 'python'
True
If exts are given they restrict which extensions are allowed
>>> find_language(makepath(this_script), ('.sh', '.t... | python | def find_language(script, exts=None):
"""Determine the script's language extension
>>> this_script = __file__.rstrip('c')
>>> find_language(makepath(this_script)) == 'python'
True
If exts are given they restrict which extensions are allowed
>>> find_language(makepath(this_script), ('.sh', '.t... | [
"def",
"find_language",
"(",
"script",
",",
"exts",
"=",
"None",
")",
":",
"if",
"not",
"script",
".",
"isfile",
"(",
")",
":",
"return",
"None",
"if",
"script",
".",
"ext",
":",
"return",
"ext_language",
"(",
"script",
".",
"ext",
",",
"exts",
")",
... | Determine the script's language extension
>>> this_script = __file__.rstrip('c')
>>> find_language(makepath(this_script)) == 'python'
True
If exts are given they restrict which extensions are allowed
>>> find_language(makepath(this_script), ('.sh', '.txt')) is None
True
If there is no ex... | [
"Determine",
"the",
"script",
"s",
"language",
"extension"
] | train | https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/paths.py#L296-L320 |
jalanb/pysyte | pysyte/paths.py | makepath | def makepath(s, as_file=False):
"""Make a path from a string
Expand out any variables, home squiggles, and normalise it
See also http://stackoverflow.com/questions/26403972
"""
if s is None:
return None
result = FilePath(s) if (os.path.isfile(s) or as_file) else DirectPath(s)
return... | python | def makepath(s, as_file=False):
"""Make a path from a string
Expand out any variables, home squiggles, and normalise it
See also http://stackoverflow.com/questions/26403972
"""
if s is None:
return None
result = FilePath(s) if (os.path.isfile(s) or as_file) else DirectPath(s)
return... | [
"def",
"makepath",
"(",
"s",
",",
"as_file",
"=",
"False",
")",
":",
"if",
"s",
"is",
"None",
":",
"return",
"None",
"result",
"=",
"FilePath",
"(",
"s",
")",
"if",
"(",
"os",
".",
"path",
".",
"isfile",
"(",
"s",
")",
"or",
"as_file",
")",
"el... | Make a path from a string
Expand out any variables, home squiggles, and normalise it
See also http://stackoverflow.com/questions/26403972 | [
"Make",
"a",
"path",
"from",
"a",
"string"
] | train | https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/paths.py#L608-L617 |
jalanb/pysyte | pysyte/paths.py | cd | def cd(path_to): # pylint: disable=invalid-name
"""cd to the given path
If the path is a file, then cd to its parent directory
Remember current directory before the cd
so that we can cd back there with cd('-')
"""
if path_to == '-':
if not cd.previous:
raise PathError(... | python | def cd(path_to): # pylint: disable=invalid-name
"""cd to the given path
If the path is a file, then cd to its parent directory
Remember current directory before the cd
so that we can cd back there with cd('-')
"""
if path_to == '-':
if not cd.previous:
raise PathError(... | [
"def",
"cd",
"(",
"path_to",
")",
":",
"# pylint: disable=invalid-name",
"if",
"path_to",
"==",
"'-'",
":",
"if",
"not",
"cd",
".",
"previous",
":",
"raise",
"PathError",
"(",
"'No previous directory to return to'",
")",
"return",
"cd",
"(",
"cd",
".",
"previo... | cd to the given path
If the path is a file, then cd to its parent directory
Remember current directory before the cd
so that we can cd back there with cd('-') | [
"cd",
"to",
"the",
"given",
"path"
] | train | https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/paths.py#L622-L651 |
jalanb/pysyte | pysyte/paths.py | make_needed | def make_needed(pattern, path_to_directory, wanted):
"""Make a method to check if an item matches the pattern, and is wanted
If wanted is None just check the pattern
"""
if wanted:
def needed(name):
return fnmatch(name, pattern) and wanted(
os.path.join(path_to_direc... | python | def make_needed(pattern, path_to_directory, wanted):
"""Make a method to check if an item matches the pattern, and is wanted
If wanted is None just check the pattern
"""
if wanted:
def needed(name):
return fnmatch(name, pattern) and wanted(
os.path.join(path_to_direc... | [
"def",
"make_needed",
"(",
"pattern",
",",
"path_to_directory",
",",
"wanted",
")",
":",
"if",
"wanted",
":",
"def",
"needed",
"(",
"name",
")",
":",
"return",
"fnmatch",
"(",
"name",
",",
"pattern",
")",
"and",
"wanted",
"(",
"os",
".",
"path",
".",
... | Make a method to check if an item matches the pattern, and is wanted
If wanted is None just check the pattern | [
"Make",
"a",
"method",
"to",
"check",
"if",
"an",
"item",
"matches",
"the",
"pattern",
"and",
"is",
"wanted"
] | train | https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/paths.py#L763-L774 |
jalanb/pysyte | pysyte/paths.py | list_items | def list_items(path_to_directory, pattern, wanted):
"""All items in the given path which match the given glob and are wanted"""
if not path_to_directory:
return set()
needed = make_needed(pattern, path_to_directory, wanted)
return [os.path.join(path_to_directory, name)
for name in _n... | python | def list_items(path_to_directory, pattern, wanted):
"""All items in the given path which match the given glob and are wanted"""
if not path_to_directory:
return set()
needed = make_needed(pattern, path_to_directory, wanted)
return [os.path.join(path_to_directory, name)
for name in _n... | [
"def",
"list_items",
"(",
"path_to_directory",
",",
"pattern",
",",
"wanted",
")",
":",
"if",
"not",
"path_to_directory",
":",
"return",
"set",
"(",
")",
"needed",
"=",
"make_needed",
"(",
"pattern",
",",
"path_to_directory",
",",
"wanted",
")",
"return",
"[... | All items in the given path which match the given glob and are wanted | [
"All",
"items",
"in",
"the",
"given",
"path",
"which",
"match",
"the",
"given",
"glob",
"and",
"are",
"wanted"
] | train | https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/paths.py#L777-L784 |
jalanb/pysyte | pysyte/paths.py | contains_glob | def contains_glob(path_to_directory, pattern, wanted=None):
"""Whether the given path contains an item matching the given glob"""
if not path_to_directory:
return False
needed = make_needed(pattern, path_to_directory, wanted)
for name in _names_in_directory(path_to_directory):
if needed(... | python | def contains_glob(path_to_directory, pattern, wanted=None):
"""Whether the given path contains an item matching the given glob"""
if not path_to_directory:
return False
needed = make_needed(pattern, path_to_directory, wanted)
for name in _names_in_directory(path_to_directory):
if needed(... | [
"def",
"contains_glob",
"(",
"path_to_directory",
",",
"pattern",
",",
"wanted",
"=",
"None",
")",
":",
"if",
"not",
"path_to_directory",
":",
"return",
"False",
"needed",
"=",
"make_needed",
"(",
"pattern",
",",
"path_to_directory",
",",
"wanted",
")",
"for",... | Whether the given path contains an item matching the given glob | [
"Whether",
"the",
"given",
"path",
"contains",
"an",
"item",
"matching",
"the",
"given",
"glob"
] | train | https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/paths.py#L801-L809 |
jalanb/pysyte | pysyte/paths.py | tab_complete | def tab_complete(string):
"""Finish file names "left short" by tab-completion
For example, if an argument is "fred."
and no file called "fred." exists
but "fred.py" does exist
then return fred.py
"""
if is_option(string):
return string
if not missing_extension(string... | python | def tab_complete(string):
"""Finish file names "left short" by tab-completion
For example, if an argument is "fred."
and no file called "fred." exists
but "fred.py" does exist
then return fred.py
"""
if is_option(string):
return string
if not missing_extension(string... | [
"def",
"tab_complete",
"(",
"string",
")",
":",
"if",
"is_option",
"(",
"string",
")",
":",
"return",
"string",
"if",
"not",
"missing_extension",
"(",
"string",
")",
":",
"return",
"string",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"string",
")",
"... | Finish file names "left short" by tab-completion
For example, if an argument is "fred."
and no file called "fred." exists
but "fred.py" does exist
then return fred.py | [
"Finish",
"file",
"names",
"left",
"short",
"by",
"tab",
"-",
"completion"
] | train | https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/paths.py#L834-L852 |
jalanb/pysyte | pysyte/paths.py | pyc_to_py | def pyc_to_py(path_to_file):
"""Change some file extensions to those which are more likely to be text
>>> pyc_to_py('vim.pyc') == 'vim.py'
True
"""
stem, ext = os.path.splitext(path_to_file)
if ext == '.pyc':
return '%s.py' % stem
return path_to_file | python | def pyc_to_py(path_to_file):
"""Change some file extensions to those which are more likely to be text
>>> pyc_to_py('vim.pyc') == 'vim.py'
True
"""
stem, ext = os.path.splitext(path_to_file)
if ext == '.pyc':
return '%s.py' % stem
return path_to_file | [
"def",
"pyc_to_py",
"(",
"path_to_file",
")",
":",
"stem",
",",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"path_to_file",
")",
"if",
"ext",
"==",
"'.pyc'",
":",
"return",
"'%s.py'",
"%",
"stem",
"return",
"path_to_file"
] | Change some file extensions to those which are more likely to be text
>>> pyc_to_py('vim.pyc') == 'vim.py'
True | [
"Change",
"some",
"file",
"extensions",
"to",
"those",
"which",
"are",
"more",
"likely",
"to",
"be",
"text"
] | train | https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/paths.py#L855-L864 |
jalanb/pysyte | pysyte/paths.py | DotPath.as_existing_file | def as_existing_file(self, filepath):
"""Return the file class for existing files only"""
if os.path.isfile(filepath) and hasattr(self, '__file_class__'):
return self.__file_class__(filepath) # pylint: disable=no-member
return self.__class__(filepath) | python | def as_existing_file(self, filepath):
"""Return the file class for existing files only"""
if os.path.isfile(filepath) and hasattr(self, '__file_class__'):
return self.__file_class__(filepath) # pylint: disable=no-member
return self.__class__(filepath) | [
"def",
"as_existing_file",
"(",
"self",
",",
"filepath",
")",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"filepath",
")",
"and",
"hasattr",
"(",
"self",
",",
"'__file_class__'",
")",
":",
"return",
"self",
".",
"__file_class__",
"(",
"filepath",
"... | Return the file class for existing files only | [
"Return",
"the",
"file",
"class",
"for",
"existing",
"files",
"only"
] | train | https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/paths.py#L76-L80 |
jalanb/pysyte | pysyte/paths.py | DotPath.dirpaths | def dirpaths(self):
"""Split the dirname into individual directory names
An absolute path starts with an empty string, a relative path does not
>>> p = DotPath(u'/path/to/x.py')
>>> p.paths == p.dirpaths()
True
"""
parts = self.parts()
result = [DotPath(... | python | def dirpaths(self):
"""Split the dirname into individual directory names
An absolute path starts with an empty string, a relative path does not
>>> p = DotPath(u'/path/to/x.py')
>>> p.paths == p.dirpaths()
True
"""
parts = self.parts()
result = [DotPath(... | [
"def",
"dirpaths",
"(",
"self",
")",
":",
"parts",
"=",
"self",
".",
"parts",
"(",
")",
"result",
"=",
"[",
"DotPath",
"(",
"parts",
"[",
"0",
"]",
"or",
"'/'",
")",
"]",
"for",
"name",
"in",
"parts",
"[",
"1",
":",
"]",
":",
"result",
".",
"... | Split the dirname into individual directory names
An absolute path starts with an empty string, a relative path does not
>>> p = DotPath(u'/path/to/x.py')
>>> p.paths == p.dirpaths()
True | [
"Split",
"the",
"dirname",
"into",
"individual",
"directory",
"names"
] | train | https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/paths.py#L103-L116 |
jalanb/pysyte | pysyte/paths.py | DotPath.parts | def parts(self):
"""Split the path into parts like Pathlib
>>> expected = ['/', 'path', 'to', 'there']
>>> assert DotPath('/path/to/there').parts() == expected
"""
parts = self.split(os.path.sep)
parts[0] = parts[0] and parts[0] or '/'
return parts | python | def parts(self):
"""Split the path into parts like Pathlib
>>> expected = ['/', 'path', 'to', 'there']
>>> assert DotPath('/path/to/there').parts() == expected
"""
parts = self.split(os.path.sep)
parts[0] = parts[0] and parts[0] or '/'
return parts | [
"def",
"parts",
"(",
"self",
")",
":",
"parts",
"=",
"self",
".",
"split",
"(",
"os",
".",
"path",
".",
"sep",
")",
"parts",
"[",
"0",
"]",
"=",
"parts",
"[",
"0",
"]",
"and",
"parts",
"[",
"0",
"]",
"or",
"'/'",
"return",
"parts"
] | Split the path into parts like Pathlib
>>> expected = ['/', 'path', 'to', 'there']
>>> assert DotPath('/path/to/there').parts() == expected | [
"Split",
"the",
"path",
"into",
"parts",
"like",
"Pathlib"
] | train | https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/paths.py#L118-L126 |
jalanb/pysyte | pysyte/paths.py | DotPath.short_relative_path_to | def short_relative_path_to(self, destination):
"""The shorter of either the absolute path of the destination,
or the relative path to it
>>> print(DotPath('/home/guido/bin').short_relative_path_to(
... '/home/guido/build/python.tar'))
../build/python.tar
>>> prin... | python | def short_relative_path_to(self, destination):
"""The shorter of either the absolute path of the destination,
or the relative path to it
>>> print(DotPath('/home/guido/bin').short_relative_path_to(
... '/home/guido/build/python.tar'))
../build/python.tar
>>> prin... | [
"def",
"short_relative_path_to",
"(",
"self",
",",
"destination",
")",
":",
"relative",
"=",
"self",
".",
"relpathto",
"(",
"destination",
")",
"absolute",
"=",
"self",
".",
"__class__",
"(",
"destination",
")",
".",
"abspath",
"(",
")",
"if",
"len",
"(",
... | The shorter of either the absolute path of the destination,
or the relative path to it
>>> print(DotPath('/home/guido/bin').short_relative_path_to(
... '/home/guido/build/python.tar'))
../build/python.tar
>>> print(DotPath('/home/guido/bin').short_relative_path_to(
... | [
"The",
"shorter",
"of",
"either",
"the",
"absolute",
"path",
"of",
"the",
"destination",
"or",
"the",
"relative",
"path",
"to",
"it"
] | train | https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/paths.py#L165-L180 |
jalanb/pysyte | pysyte/paths.py | DotPath.walk_some_dirs | def walk_some_dirs(self, levels=-1, pattern=None):
""" D.walkdirs() -> iterator over subdirs, recursively.
With the optional 'pattern' argument, this yields only
directories whose names match the given pattern. For
example, mydir.walkdirs('*test') yields only directories
with n... | python | def walk_some_dirs(self, levels=-1, pattern=None):
""" D.walkdirs() -> iterator over subdirs, recursively.
With the optional 'pattern' argument, this yields only
directories whose names match the given pattern. For
example, mydir.walkdirs('*test') yields only directories
with n... | [
"def",
"walk_some_dirs",
"(",
"self",
",",
"levels",
"=",
"-",
"1",
",",
"pattern",
"=",
"None",
")",
":",
"if",
"not",
"levels",
":",
"yield",
"self",
"raise",
"StopIteration",
"levels",
"-=",
"1",
"for",
"child",
"in",
"self",
".",
"dirs",
"(",
")"... | D.walkdirs() -> iterator over subdirs, recursively.
With the optional 'pattern' argument, this yields only
directories whose names match the given pattern. For
example, mydir.walkdirs('*test') yields only directories
with names ending in 'test'. | [
"D",
".",
"walkdirs",
"()",
"-",
">",
"iterator",
"over",
"subdirs",
"recursively",
"."
] | train | https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/paths.py#L190-L207 |
jalanb/pysyte | pysyte/paths.py | FilePath.extend_by | def extend_by(self, extension):
"""The path to the file changed to use the given extension
>>> FilePath('/path/to/fred').extend_by('.txt')
<FilePath '/path/to/fred.txt'>
>>> FilePath('/path/to/fred.txt').extend_by('..tmp')
<FilePath '/path/to/fred.tmp'>
>>> FilePath('/pa... | python | def extend_by(self, extension):
"""The path to the file changed to use the given extension
>>> FilePath('/path/to/fred').extend_by('.txt')
<FilePath '/path/to/fred.txt'>
>>> FilePath('/path/to/fred.txt').extend_by('..tmp')
<FilePath '/path/to/fred.tmp'>
>>> FilePath('/pa... | [
"def",
"extend_by",
"(",
"self",
",",
"extension",
")",
":",
"copy",
"=",
"self",
"[",
":",
"]",
"filename",
",",
"_",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"copy",
")",
"return",
"self",
".",
"__class__",
"(",
"'%s.%s'",
"%",
"(",
"filenam... | The path to the file changed to use the given extension
>>> FilePath('/path/to/fred').extend_by('.txt')
<FilePath '/path/to/fred.txt'>
>>> FilePath('/path/to/fred.txt').extend_by('..tmp')
<FilePath '/path/to/fred.tmp'>
>>> FilePath('/path/to/fred.txt').extend_by('fred')
... | [
"The",
"path",
"to",
"the",
"file",
"changed",
"to",
"use",
"the",
"given",
"extension"
] | train | https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/paths.py#L390-L402 |
jalanb/pysyte | pysyte/paths.py | FilePath.shebang | def shebang(self):
"""The #! entry from the first line of the file
If no shebang is present, return an empty string
"""
try:
try:
first_line = self.lines()[0]
except (OSError, UnicodeDecodeError):
return ''
if first_li... | python | def shebang(self):
"""The #! entry from the first line of the file
If no shebang is present, return an empty string
"""
try:
try:
first_line = self.lines()[0]
except (OSError, UnicodeDecodeError):
return ''
if first_li... | [
"def",
"shebang",
"(",
"self",
")",
":",
"try",
":",
"try",
":",
"first_line",
"=",
"self",
".",
"lines",
"(",
")",
"[",
"0",
"]",
"except",
"(",
"OSError",
",",
"UnicodeDecodeError",
")",
":",
"return",
"''",
"if",
"first_line",
".",
"startswith",
"... | The #! entry from the first line of the file
If no shebang is present, return an empty string | [
"The",
"#!",
"entry",
"from",
"the",
"first",
"line",
"of",
"the",
"file"
] | train | https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/paths.py#L416-L433 |
jalanb/pysyte | pysyte/paths.py | FilePath.make_file_exist | def make_file_exist(self):
"""Make sure the parent directory exists, then touch the file"""
self.parent.make_directory_exist()
self.parent.touch_file(self.name)
return self | python | def make_file_exist(self):
"""Make sure the parent directory exists, then touch the file"""
self.parent.make_directory_exist()
self.parent.touch_file(self.name)
return self | [
"def",
"make_file_exist",
"(",
"self",
")",
":",
"self",
".",
"parent",
".",
"make_directory_exist",
"(",
")",
"self",
".",
"parent",
".",
"touch_file",
"(",
"self",
".",
"name",
")",
"return",
"self"
] | Make sure the parent directory exists, then touch the file | [
"Make",
"sure",
"the",
"parent",
"directory",
"exists",
"then",
"touch",
"the",
"file"
] | train | https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/paths.py#L438-L442 |
jalanb/pysyte | pysyte/paths.py | FilePath.language | def language(self):
"""The language of this file"""
try:
return self._language
except AttributeError:
self._language = find_language(self, getattr(self, 'exts', None))
return self._language | python | def language(self):
"""The language of this file"""
try:
return self._language
except AttributeError:
self._language = find_language(self, getattr(self, 'exts', None))
return self._language | [
"def",
"language",
"(",
"self",
")",
":",
"try",
":",
"return",
"self",
".",
"_language",
"except",
"AttributeError",
":",
"self",
".",
"_language",
"=",
"find_language",
"(",
"self",
",",
"getattr",
"(",
"self",
",",
"'exts'",
",",
"None",
")",
")",
"... | The language of this file | [
"The",
"language",
"of",
"this",
"file"
] | train | https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/paths.py#L445-L451 |
jalanb/pysyte | pysyte/paths.py | DirectPath.try_remove | def try_remove(self):
"""Try to remove the path
If it is a directory, try recursive removal of contents too
"""
if self.islink():
self.unlink()
elif self.isfile():
self.remove()
elif self.isdir():
self.empty_directory()
if ... | python | def try_remove(self):
"""Try to remove the path
If it is a directory, try recursive removal of contents too
"""
if self.islink():
self.unlink()
elif self.isfile():
self.remove()
elif self.isdir():
self.empty_directory()
if ... | [
"def",
"try_remove",
"(",
"self",
")",
":",
"if",
"self",
".",
"islink",
"(",
")",
":",
"self",
".",
"unlink",
"(",
")",
"elif",
"self",
".",
"isfile",
"(",
")",
":",
"self",
".",
"remove",
"(",
")",
"elif",
"self",
".",
"isdir",
"(",
")",
":",... | Try to remove the path
If it is a directory, try recursive removal of contents too | [
"Try",
"to",
"remove",
"the",
"path"
] | train | https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/paths.py#L483-L498 |
jalanb/pysyte | pysyte/paths.py | DirectPath.empty_directory | def empty_directory(self):
"""Remove all contents of a directory
Including any sub-directories and their contents"""
for child in self.walkfiles():
child.remove()
for child in reversed([d for d in self.walkdirs()]):
if child == self or not child.isdir():
... | python | def empty_directory(self):
"""Remove all contents of a directory
Including any sub-directories and their contents"""
for child in self.walkfiles():
child.remove()
for child in reversed([d for d in self.walkdirs()]):
if child == self or not child.isdir():
... | [
"def",
"empty_directory",
"(",
"self",
")",
":",
"for",
"child",
"in",
"self",
".",
"walkfiles",
"(",
")",
":",
"child",
".",
"remove",
"(",
")",
"for",
"child",
"in",
"reversed",
"(",
"[",
"d",
"for",
"d",
"in",
"self",
".",
"walkdirs",
"(",
")",
... | Remove all contents of a directory
Including any sub-directories and their contents | [
"Remove",
"all",
"contents",
"of",
"a",
"directory"
] | train | https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/paths.py#L500-L509 |
jalanb/pysyte | pysyte/paths.py | DirectPath.make_file_exist | def make_file_exist(self, filename=None):
"""Make the directory exist, then touch the file
If the filename is None, then use self.name as filename
"""
if filename is None:
path_to_file = FilePath(self)
path_to_file.make_file_exist()
return path_to_fil... | python | def make_file_exist(self, filename=None):
"""Make the directory exist, then touch the file
If the filename is None, then use self.name as filename
"""
if filename is None:
path_to_file = FilePath(self)
path_to_file.make_file_exist()
return path_to_fil... | [
"def",
"make_file_exist",
"(",
"self",
",",
"filename",
"=",
"None",
")",
":",
"if",
"filename",
"is",
"None",
":",
"path_to_file",
"=",
"FilePath",
"(",
"self",
")",
"path_to_file",
".",
"make_file_exist",
"(",
")",
"return",
"path_to_file",
"else",
":",
... | Make the directory exist, then touch the file
If the filename is None, then use self.name as filename | [
"Make",
"the",
"directory",
"exist",
"then",
"touch",
"the",
"file"
] | train | https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/paths.py#L542-L554 |
jalanb/pysyte | pysyte/paths.py | DirectPath.touch_file | def touch_file(self, filename):
"""Touch a file in the directory"""
path_to_file = self.__file_class__(os.path.join(self, filename))
path_to_file.touch()
return path_to_file | python | def touch_file(self, filename):
"""Touch a file in the directory"""
path_to_file = self.__file_class__(os.path.join(self, filename))
path_to_file.touch()
return path_to_file | [
"def",
"touch_file",
"(",
"self",
",",
"filename",
")",
":",
"path_to_file",
"=",
"self",
".",
"__file_class__",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
",",
"filename",
")",
")",
"path_to_file",
".",
"touch",
"(",
")",
"return",
"path_to_file"... | Touch a file in the directory | [
"Touch",
"a",
"file",
"in",
"the",
"directory"
] | train | https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/paths.py#L560-L564 |
jalanb/pysyte | pysyte/paths.py | DirectPath.existing_sub_paths | def existing_sub_paths(self, sub_paths):
"""Those in the given list of sub_paths which do exist"""
paths_to_subs = [self / _ for _ in sub_paths]
return [_ for _ in paths_to_subs if _.exists()] | python | def existing_sub_paths(self, sub_paths):
"""Those in the given list of sub_paths which do exist"""
paths_to_subs = [self / _ for _ in sub_paths]
return [_ for _ in paths_to_subs if _.exists()] | [
"def",
"existing_sub_paths",
"(",
"self",
",",
"sub_paths",
")",
":",
"paths_to_subs",
"=",
"[",
"self",
"/",
"_",
"for",
"_",
"in",
"sub_paths",
"]",
"return",
"[",
"_",
"for",
"_",
"in",
"paths_to_subs",
"if",
"_",
".",
"exists",
"(",
")",
"]"
] | Those in the given list of sub_paths which do exist | [
"Those",
"in",
"the",
"given",
"list",
"of",
"sub_paths",
"which",
"do",
"exist"
] | train | https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/paths.py#L566-L569 |
frigg/frigg-worker | frigg_worker/deployments.py | Deployment.create_pending_tasks | def create_pending_tasks(self):
"""
Creates pending task results in a dict on self.result with task string as key. It will also
create a list on self.tasks that is used to make sure the serialization of the results
creates a correctly ordered list.
"""
for task in self.se... | python | def create_pending_tasks(self):
"""
Creates pending task results in a dict on self.result with task string as key. It will also
create a list on self.tasks that is used to make sure the serialization of the results
creates a correctly ordered list.
"""
for task in self.se... | [
"def",
"create_pending_tasks",
"(",
"self",
")",
":",
"for",
"task",
"in",
"self",
".",
"settings",
".",
"tasks",
"[",
"'setup'",
"]",
":",
"self",
".",
"setup_tasks",
".",
"append",
"(",
"task",
")",
"self",
".",
"setup_results",
"[",
"task",
"]",
"="... | Creates pending task results in a dict on self.result with task string as key. It will also
create a list on self.tasks that is used to make sure the serialization of the results
creates a correctly ordered list. | [
"Creates",
"pending",
"task",
"results",
"in",
"a",
"dict",
"on",
"self",
".",
"result",
"with",
"task",
"string",
"as",
"key",
".",
"It",
"will",
"also",
"create",
"a",
"list",
"on",
"self",
".",
"tasks",
"that",
"is",
"used",
"to",
"make",
"sure",
... | train | https://github.com/frigg/frigg-worker/blob/8c215cd8f5a27ff9f5a4fedafe93d2ef0fbca86c/frigg_worker/deployments.py#L63-L84 |
frigg/frigg-worker | frigg_worker/deployments.py | Deployment.load_preset | def load_preset(self):
"""
Loads preset if it is specified in the .frigg.yml
"""
if 'preset' in self.settings.preview:
with open(os.path.join(os.path.dirname(__file__), 'presets.yaml')) as f:
presets = yaml.load(f.read())
if self.settings.preview[... | python | def load_preset(self):
"""
Loads preset if it is specified in the .frigg.yml
"""
if 'preset' in self.settings.preview:
with open(os.path.join(os.path.dirname(__file__), 'presets.yaml')) as f:
presets = yaml.load(f.read())
if self.settings.preview[... | [
"def",
"load_preset",
"(",
"self",
")",
":",
"if",
"'preset'",
"in",
"self",
".",
"settings",
".",
"preview",
":",
"with",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"'presets.yaml'... | Loads preset if it is specified in the .frigg.yml | [
"Loads",
"preset",
"if",
"it",
"is",
"specified",
"in",
"the",
".",
"frigg",
".",
"yml"
] | train | https://github.com/frigg/frigg-worker/blob/8c215cd8f5a27ff9f5a4fedafe93d2ef0fbca86c/frigg_worker/deployments.py#L86-L96 |
lukaszb/monolith | monolith/cli/base.py | ExecutionManager.get_parser | def get_parser(self):
"""
Returns :class:`monolith.cli.Parser` instance for this
*ExecutionManager*.
"""
parser = self.parser_cls(prog=self.prog_name, usage=self.get_usage(),
stream=self.stderr)
subparsers = parser.add_subparsers(
title='subcommand... | python | def get_parser(self):
"""
Returns :class:`monolith.cli.Parser` instance for this
*ExecutionManager*.
"""
parser = self.parser_cls(prog=self.prog_name, usage=self.get_usage(),
stream=self.stderr)
subparsers = parser.add_subparsers(
title='subcommand... | [
"def",
"get_parser",
"(",
"self",
")",
":",
"parser",
"=",
"self",
".",
"parser_cls",
"(",
"prog",
"=",
"self",
".",
"prog_name",
",",
"usage",
"=",
"self",
".",
"get_usage",
"(",
")",
",",
"stream",
"=",
"self",
".",
"stderr",
")",
"subparsers",
"="... | Returns :class:`monolith.cli.Parser` instance for this
*ExecutionManager*. | [
"Returns",
":",
"class",
":",
"monolith",
".",
"cli",
".",
"Parser",
"instance",
"for",
"this",
"*",
"ExecutionManager",
"*",
"."
] | train | https://github.com/lukaszb/monolith/blob/cd8ab0483829ed4be6439c4f787ea59d48ad35b8/monolith/cli/base.py#L67-L84 |
lukaszb/monolith | monolith/cli/base.py | ExecutionManager.register | def register(self, name, Command, force=False):
"""
Registers given ``Command`` (as given ``name``) at this
*ExecutionManager*'s registry.
:param name: name in the registry under which given ``Command``
should be stored.
:param Command: should be subclass of
... | python | def register(self, name, Command, force=False):
"""
Registers given ``Command`` (as given ``name``) at this
*ExecutionManager*'s registry.
:param name: name in the registry under which given ``Command``
should be stored.
:param Command: should be subclass of
... | [
"def",
"register",
"(",
"self",
",",
"name",
",",
"Command",
",",
"force",
"=",
"False",
")",
":",
"if",
"not",
"force",
"and",
"name",
"in",
"self",
".",
"registry",
":",
"raise",
"AlreadyRegistered",
"(",
"'Command %r is already registered'",
"%",
"name",
... | Registers given ``Command`` (as given ``name``) at this
*ExecutionManager*'s registry.
:param name: name in the registry under which given ``Command``
should be stored.
:param Command: should be subclass of
:class:``monolith.cli.base.BaseCommand``
:param force: Force... | [
"Registers",
"given",
"Command",
"(",
"as",
"given",
"name",
")",
"at",
"this",
"*",
"ExecutionManager",
"*",
"s",
"registry",
"."
] | train | https://github.com/lukaszb/monolith/blob/cd8ab0483829ed4be6439c4f787ea59d48ad35b8/monolith/cli/base.py#L86-L107 |
lukaszb/monolith | monolith/cli/base.py | ExecutionManager.get_commands | def get_commands(self):
"""
Returns commands stored in the registry (sorted by name).
"""
commands = OrderedDict()
for cmd in sorted(self.registry.keys()):
commands[cmd] = self.registry[cmd]
return commands | python | def get_commands(self):
"""
Returns commands stored in the registry (sorted by name).
"""
commands = OrderedDict()
for cmd in sorted(self.registry.keys()):
commands[cmd] = self.registry[cmd]
return commands | [
"def",
"get_commands",
"(",
"self",
")",
":",
"commands",
"=",
"OrderedDict",
"(",
")",
"for",
"cmd",
"in",
"sorted",
"(",
"self",
".",
"registry",
".",
"keys",
"(",
")",
")",
":",
"commands",
"[",
"cmd",
"]",
"=",
"self",
".",
"registry",
"[",
"cm... | Returns commands stored in the registry (sorted by name). | [
"Returns",
"commands",
"stored",
"in",
"the",
"registry",
"(",
"sorted",
"by",
"name",
")",
"."
] | train | https://github.com/lukaszb/monolith/blob/cd8ab0483829ed4be6439c4f787ea59d48ad35b8/monolith/cli/base.py#L109-L116 |
lukaszb/monolith | monolith/cli/base.py | ExecutionManager.call_command | def call_command(self, cmd, *argv):
"""
Runs a command.
:param cmd: command to run (key at the registry)
:param argv: arguments that would be passed to the command
"""
parser = self.get_parser()
args = [cmd] + list(argv)
namespace = parser.parse_args(args... | python | def call_command(self, cmd, *argv):
"""
Runs a command.
:param cmd: command to run (key at the registry)
:param argv: arguments that would be passed to the command
"""
parser = self.get_parser()
args = [cmd] + list(argv)
namespace = parser.parse_args(args... | [
"def",
"call_command",
"(",
"self",
",",
"cmd",
",",
"*",
"argv",
")",
":",
"parser",
"=",
"self",
".",
"get_parser",
"(",
")",
"args",
"=",
"[",
"cmd",
"]",
"+",
"list",
"(",
"argv",
")",
"namespace",
"=",
"parser",
".",
"parse_args",
"(",
"args",... | Runs a command.
:param cmd: command to run (key at the registry)
:param argv: arguments that would be passed to the command | [
"Runs",
"a",
"command",
"."
] | train | https://github.com/lukaszb/monolith/blob/cd8ab0483829ed4be6439c4f787ea59d48ad35b8/monolith/cli/base.py#L125-L135 |
lukaszb/monolith | monolith/cli/base.py | ExecutionManager.execute | def execute(self, argv=None):
"""
Executes command based on given arguments.
"""
if self.completion:
self.autocomplete()
parser = self.get_parser()
namespace = parser.parse_args(argv)
if hasattr(namespace, 'func'):
self.run_command(namespac... | python | def execute(self, argv=None):
"""
Executes command based on given arguments.
"""
if self.completion:
self.autocomplete()
parser = self.get_parser()
namespace = parser.parse_args(argv)
if hasattr(namespace, 'func'):
self.run_command(namespac... | [
"def",
"execute",
"(",
"self",
",",
"argv",
"=",
"None",
")",
":",
"if",
"self",
".",
"completion",
":",
"self",
".",
"autocomplete",
"(",
")",
"parser",
"=",
"self",
".",
"get_parser",
"(",
")",
"namespace",
"=",
"parser",
".",
"parse_args",
"(",
"a... | Executes command based on given arguments. | [
"Executes",
"command",
"based",
"on",
"given",
"arguments",
"."
] | train | https://github.com/lukaszb/monolith/blob/cd8ab0483829ed4be6439c4f787ea59d48ad35b8/monolith/cli/base.py#L137-L146 |
lukaszb/monolith | monolith/cli/base.py | ExecutionManager.autocomplete | def autocomplete(self):
"""
If *completion* is enabled, this method would write to ``self.stdout``
completion words separated with space.
"""
if self.completion_env_var_name not in os.environ:
return
cwords = os.environ['COMP_WORDS'].split()[1:]
cword ... | python | def autocomplete(self):
"""
If *completion* is enabled, this method would write to ``self.stdout``
completion words separated with space.
"""
if self.completion_env_var_name not in os.environ:
return
cwords = os.environ['COMP_WORDS'].split()[1:]
cword ... | [
"def",
"autocomplete",
"(",
"self",
")",
":",
"if",
"self",
".",
"completion_env_var_name",
"not",
"in",
"os",
".",
"environ",
":",
"return",
"cwords",
"=",
"os",
".",
"environ",
"[",
"'COMP_WORDS'",
"]",
".",
"split",
"(",
")",
"[",
"1",
":",
"]",
"... | If *completion* is enabled, this method would write to ``self.stdout``
completion words separated with space. | [
"If",
"*",
"completion",
"*",
"is",
"enabled",
"this",
"method",
"would",
"write",
"to",
"self",
".",
"stdout",
"completion",
"words",
"separated",
"with",
"space",
"."
] | train | https://github.com/lukaszb/monolith/blob/cd8ab0483829ed4be6439c4f787ea59d48ad35b8/monolith/cli/base.py#L155-L174 |
lukaszb/monolith | monolith/cli/base.py | SimpleExecutionManager.get_commands_to_register | def get_commands_to_register(self):
"""
Returns dictionary with commands given during construction. If value is
a string, it would be converted into proper class pointer.
"""
return dict((key, get_class(value)) for key, value in
self.simple_commands.items()) | python | def get_commands_to_register(self):
"""
Returns dictionary with commands given during construction. If value is
a string, it would be converted into proper class pointer.
"""
return dict((key, get_class(value)) for key, value in
self.simple_commands.items()) | [
"def",
"get_commands_to_register",
"(",
"self",
")",
":",
"return",
"dict",
"(",
"(",
"key",
",",
"get_class",
"(",
"value",
")",
")",
"for",
"key",
",",
"value",
"in",
"self",
".",
"simple_commands",
".",
"items",
"(",
")",
")"
] | Returns dictionary with commands given during construction. If value is
a string, it would be converted into proper class pointer. | [
"Returns",
"dictionary",
"with",
"commands",
"given",
"during",
"construction",
".",
"If",
"value",
"is",
"a",
"string",
"it",
"would",
"be",
"converted",
"into",
"proper",
"class",
"pointer",
"."
] | train | https://github.com/lukaszb/monolith/blob/cd8ab0483829ed4be6439c4f787ea59d48ad35b8/monolith/cli/base.py#L195-L201 |
lukaszb/monolith | monolith/cli/base.py | LabelCommand.handle | def handle(self, namespace):
"""
Handles given ``namespace`` by calling ``handle_label`` method
for each given *label*.
"""
for label in namespace.labels:
self.handle_label(label, namespace)
else:
self.handle_no_labels(namespace) | python | def handle(self, namespace):
"""
Handles given ``namespace`` by calling ``handle_label`` method
for each given *label*.
"""
for label in namespace.labels:
self.handle_label(label, namespace)
else:
self.handle_no_labels(namespace) | [
"def",
"handle",
"(",
"self",
",",
"namespace",
")",
":",
"for",
"label",
"in",
"namespace",
".",
"labels",
":",
"self",
".",
"handle_label",
"(",
"label",
",",
"namespace",
")",
"else",
":",
"self",
".",
"handle_no_labels",
"(",
"namespace",
")"
] | Handles given ``namespace`` by calling ``handle_label`` method
for each given *label*. | [
"Handles",
"given",
"namespace",
"by",
"calling",
"handle_label",
"method",
"for",
"each",
"given",
"*",
"label",
"*",
"."
] | train | https://github.com/lukaszb/monolith/blob/cd8ab0483829ed4be6439c4f787ea59d48ad35b8/monolith/cli/base.py#L280-L288 |
datakortet/dkfileutils | dkfileutils/which.py | get_path_directories | def get_path_directories():
"""Return a list of all the directories on the path.
"""
pth = os.environ['PATH']
if sys.platform == 'win32' and os.environ.get("BASH"):
# winbash has a bug..
if pth[1] == ';': # pragma: nocover
pth = pth.replace(';', ':', 1)
return [p.strip()... | python | def get_path_directories():
"""Return a list of all the directories on the path.
"""
pth = os.environ['PATH']
if sys.platform == 'win32' and os.environ.get("BASH"):
# winbash has a bug..
if pth[1] == ';': # pragma: nocover
pth = pth.replace(';', ':', 1)
return [p.strip()... | [
"def",
"get_path_directories",
"(",
")",
":",
"pth",
"=",
"os",
".",
"environ",
"[",
"'PATH'",
"]",
"if",
"sys",
".",
"platform",
"==",
"'win32'",
"and",
"os",
".",
"environ",
".",
"get",
"(",
"\"BASH\"",
")",
":",
"# winbash has a bug..",
"if",
"pth",
... | Return a list of all the directories on the path. | [
"Return",
"a",
"list",
"of",
"all",
"the",
"directories",
"on",
"the",
"path",
"."
] | train | https://github.com/datakortet/dkfileutils/blob/924098d6e2edf88ad9b3ffdec9c74530f80a7d77/dkfileutils/which.py#L18-L26 |
datakortet/dkfileutils | dkfileutils/which.py | _listdir | def _listdir(pth, extensions):
"""Non-raising listdir."""
try:
return [fname for fname in os.listdir(pth)
if os.path.splitext(fname)[1] in extensions]
except OSError: # pragma: nocover
pass | python | def _listdir(pth, extensions):
"""Non-raising listdir."""
try:
return [fname for fname in os.listdir(pth)
if os.path.splitext(fname)[1] in extensions]
except OSError: # pragma: nocover
pass | [
"def",
"_listdir",
"(",
"pth",
",",
"extensions",
")",
":",
"try",
":",
"return",
"[",
"fname",
"for",
"fname",
"in",
"os",
".",
"listdir",
"(",
"pth",
")",
"if",
"os",
".",
"path",
".",
"splitext",
"(",
"fname",
")",
"[",
"1",
"]",
"in",
"extens... | Non-raising listdir. | [
"Non",
"-",
"raising",
"listdir",
"."
] | train | https://github.com/datakortet/dkfileutils/blob/924098d6e2edf88ad9b3ffdec9c74530f80a7d77/dkfileutils/which.py#L35-L41 |
datakortet/dkfileutils | dkfileutils/which.py | which | def which(filename, interactive=False, verbose=False):
"""Yield all executable files on path that matches `filename`.
"""
exe = [e.lower() for e in os.environ.get('PATHEXT', '').split(';')]
if sys.platform != 'win32': # pragma: nocover
exe.append('')
name, ext = os.path.splitext(filename)
... | python | def which(filename, interactive=False, verbose=False):
"""Yield all executable files on path that matches `filename`.
"""
exe = [e.lower() for e in os.environ.get('PATHEXT', '').split(';')]
if sys.platform != 'win32': # pragma: nocover
exe.append('')
name, ext = os.path.splitext(filename)
... | [
"def",
"which",
"(",
"filename",
",",
"interactive",
"=",
"False",
",",
"verbose",
"=",
"False",
")",
":",
"exe",
"=",
"[",
"e",
".",
"lower",
"(",
")",
"for",
"e",
"in",
"os",
".",
"environ",
".",
"get",
"(",
"'PATHEXT'",
",",
"''",
")",
".",
... | Yield all executable files on path that matches `filename`. | [
"Yield",
"all",
"executable",
"files",
"on",
"path",
"that",
"matches",
"filename",
"."
] | train | https://github.com/datakortet/dkfileutils/blob/924098d6e2edf88ad9b3ffdec9c74530f80a7d77/dkfileutils/which.py#L48-L93 |
a-tal/kezmenu3 | kezmenu3/kezmenu_effects.py | KezMenuEffectAble.enableEffect | def enableEffect(self, name, **kwargs):
"""Enable an effect in the KezMenu."""
if name not in VALID_EFFECTS:
raise KeyError("KezMenu doesn't know an effect of type %s" % name)
self.__getattribute__(
'_effectinit_{}'.format(name.replace("-", "_"))
)(name, **kwargs) | python | def enableEffect(self, name, **kwargs):
"""Enable an effect in the KezMenu."""
if name not in VALID_EFFECTS:
raise KeyError("KezMenu doesn't know an effect of type %s" % name)
self.__getattribute__(
'_effectinit_{}'.format(name.replace("-", "_"))
)(name, **kwargs) | [
"def",
"enableEffect",
"(",
"self",
",",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"name",
"not",
"in",
"VALID_EFFECTS",
":",
"raise",
"KeyError",
"(",
"\"KezMenu doesn't know an effect of type %s\"",
"%",
"name",
")",
"self",
".",
"__getattribute__",
"... | Enable an effect in the KezMenu. | [
"Enable",
"an",
"effect",
"in",
"the",
"KezMenu",
"."
] | train | https://github.com/a-tal/kezmenu3/blob/3b06f9cb67fdc98a73928f877eea86692f832fa4/kezmenu3/kezmenu_effects.py#L20-L26 |
a-tal/kezmenu3 | kezmenu3/kezmenu_effects.py | KezMenuEffectAble.disableEffect | def disableEffect(self, name):
"""Disable an effect."""
try:
del self._effects[name]
self.__getattribute__(
'_effectdisable_%s' % name.replace("-", "_")
)()
except KeyError:
pass
except AttributeError:
pass | python | def disableEffect(self, name):
"""Disable an effect."""
try:
del self._effects[name]
self.__getattribute__(
'_effectdisable_%s' % name.replace("-", "_")
)()
except KeyError:
pass
except AttributeError:
pass | [
"def",
"disableEffect",
"(",
"self",
",",
"name",
")",
":",
"try",
":",
"del",
"self",
".",
"_effects",
"[",
"name",
"]",
"self",
".",
"__getattribute__",
"(",
"'_effectdisable_%s'",
"%",
"name",
".",
"replace",
"(",
"\"-\"",
",",
"\"_\"",
")",
")",
"(... | Disable an effect. | [
"Disable",
"an",
"effect",
"."
] | train | https://github.com/a-tal/kezmenu3/blob/3b06f9cb67fdc98a73928f877eea86692f832fa4/kezmenu3/kezmenu_effects.py#L28-L38 |
a-tal/kezmenu3 | kezmenu3/kezmenu_effects.py | KezMenuEffectAble._updateEffects | def _updateEffects(self, time_passed):
"""Update method for the effects handle"""
for name in self._effects:
update_func = getattr(
self,
'_effectupdate_{}'.format(name.replace("-", "_")),
)
update_func(time_passed) | python | def _updateEffects(self, time_passed):
"""Update method for the effects handle"""
for name in self._effects:
update_func = getattr(
self,
'_effectupdate_{}'.format(name.replace("-", "_")),
)
update_func(time_passed) | [
"def",
"_updateEffects",
"(",
"self",
",",
"time_passed",
")",
":",
"for",
"name",
"in",
"self",
".",
"_effects",
":",
"update_func",
"=",
"getattr",
"(",
"self",
",",
"'_effectupdate_{}'",
".",
"format",
"(",
"name",
".",
"replace",
"(",
"\"-\"",
",",
"... | Update method for the effects handle | [
"Update",
"method",
"for",
"the",
"effects",
"handle"
] | train | https://github.com/a-tal/kezmenu3/blob/3b06f9cb67fdc98a73928f877eea86692f832fa4/kezmenu3/kezmenu_effects.py#L40-L48 |
a-tal/kezmenu3 | kezmenu3/kezmenu_effects.py | KezMenuEffectAble._effectinit_enlarge_font_on_focus | def _effectinit_enlarge_font_on_focus(self, name, **kwargs):
"""Init the effect that enlarge the focused menu entry.
Keyword arguments can contain enlarge_time and enlarge_factor.
"""
self._effects[name] = kwargs
if "font" not in kwargs:
raise TypeError(
... | python | def _effectinit_enlarge_font_on_focus(self, name, **kwargs):
"""Init the effect that enlarge the focused menu entry.
Keyword arguments can contain enlarge_time and enlarge_factor.
"""
self._effects[name] = kwargs
if "font" not in kwargs:
raise TypeError(
... | [
"def",
"_effectinit_enlarge_font_on_focus",
"(",
"self",
",",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_effects",
"[",
"name",
"]",
"=",
"kwargs",
"if",
"\"font\"",
"not",
"in",
"kwargs",
":",
"raise",
"TypeError",
"(",
"\"enlarge_font_on_foc... | Init the effect that enlarge the focused menu entry.
Keyword arguments can contain enlarge_time and enlarge_factor. | [
"Init",
"the",
"effect",
"that",
"enlarge",
"the",
"focused",
"menu",
"entry",
".",
"Keyword",
"arguments",
"can",
"contain",
"enlarge_time",
"and",
"enlarge_factor",
"."
] | train | https://github.com/a-tal/kezmenu3/blob/3b06f9cb67fdc98a73928f877eea86692f832fa4/kezmenu3/kezmenu_effects.py#L50-L75 |
a-tal/kezmenu3 | kezmenu3/kezmenu_effects.py | KezMenuEffectAble._effectupdate_enlarge_font_on_focus | def _effectupdate_enlarge_font_on_focus(self, time_passed):
"""Gradually enlarge the font size of the focused line."""
data = self._effects['enlarge-font-on-focus']
fps = data['raise_font_ps']
final_size = data['size'] * data['enlarge_factor']
for i, option in enumerate(self.opt... | python | def _effectupdate_enlarge_font_on_focus(self, time_passed):
"""Gradually enlarge the font size of the focused line."""
data = self._effects['enlarge-font-on-focus']
fps = data['raise_font_ps']
final_size = data['size'] * data['enlarge_factor']
for i, option in enumerate(self.opt... | [
"def",
"_effectupdate_enlarge_font_on_focus",
"(",
"self",
",",
"time_passed",
")",
":",
"data",
"=",
"self",
".",
"_effects",
"[",
"'enlarge-font-on-focus'",
"]",
"fps",
"=",
"data",
"[",
"'raise_font_ps'",
"]",
"final_size",
"=",
"data",
"[",
"'size'",
"]",
... | Gradually enlarge the font size of the focused line. | [
"Gradually",
"enlarge",
"the",
"font",
"size",
"of",
"the",
"focused",
"line",
"."
] | train | https://github.com/a-tal/kezmenu3/blob/3b06f9cb67fdc98a73928f877eea86692f832fa4/kezmenu3/kezmenu_effects.py#L77-L100 |
a-tal/kezmenu3 | kezmenu3/kezmenu_effects.py | KezMenuEffectAble._effectinit_raise_line_padding_on_focus | def _effectinit_raise_line_padding_on_focus(self, name, **kwargs):
"""Init the effect for the empty space around the focused entry.
Keyword arguments can contain enlarge_time and padding.
"""
self._effects[name] = kwargs
if "enlarge_time" not in kwargs:
kwargs['enlar... | python | def _effectinit_raise_line_padding_on_focus(self, name, **kwargs):
"""Init the effect for the empty space around the focused entry.
Keyword arguments can contain enlarge_time and padding.
"""
self._effects[name] = kwargs
if "enlarge_time" not in kwargs:
kwargs['enlar... | [
"def",
"_effectinit_raise_line_padding_on_focus",
"(",
"self",
",",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_effects",
"[",
"name",
"]",
"=",
"kwargs",
"if",
"\"enlarge_time\"",
"not",
"in",
"kwargs",
":",
"kwargs",
"[",
"'enlarge_time'",
"]... | Init the effect for the empty space around the focused entry.
Keyword arguments can contain enlarge_time and padding. | [
"Init",
"the",
"effect",
"for",
"the",
"empty",
"space",
"around",
"the",
"focused",
"entry",
".",
"Keyword",
"arguments",
"can",
"contain",
"enlarge_time",
"and",
"padding",
"."
] | train | https://github.com/a-tal/kezmenu3/blob/3b06f9cb67fdc98a73928f877eea86692f832fa4/kezmenu3/kezmenu_effects.py#L107-L120 |
a-tal/kezmenu3 | kezmenu3/kezmenu_effects.py | KezMenuEffectAble._effectupdate_raise_line_padding_on_focus | def _effectupdate_raise_line_padding_on_focus(self, time_passed):
"""Gradually enlarge the padding of the focused line."""
data = self._effects['raise-line-padding-on-focus']
pps = data['padding_pps']
for i, option in enumerate(self.options):
if i == self.option:
... | python | def _effectupdate_raise_line_padding_on_focus(self, time_passed):
"""Gradually enlarge the padding of the focused line."""
data = self._effects['raise-line-padding-on-focus']
pps = data['padding_pps']
for i, option in enumerate(self.options):
if i == self.option:
... | [
"def",
"_effectupdate_raise_line_padding_on_focus",
"(",
"self",
",",
"time_passed",
")",
":",
"data",
"=",
"self",
".",
"_effects",
"[",
"'raise-line-padding-on-focus'",
"]",
"pps",
"=",
"data",
"[",
"'padding_pps'",
"]",
"for",
"i",
",",
"option",
"in",
"enume... | Gradually enlarge the padding of the focused line. | [
"Gradually",
"enlarge",
"the",
"padding",
"of",
"the",
"focused",
"line",
"."
] | train | https://github.com/a-tal/kezmenu3/blob/3b06f9cb67fdc98a73928f877eea86692f832fa4/kezmenu3/kezmenu_effects.py#L122-L138 |
a-tal/kezmenu3 | kezmenu3/kezmenu_effects.py | KezMenuEffectAble._effectinit_raise_col_padding_on_focus | def _effectinit_raise_col_padding_on_focus(self, name, **kwargs):
"""Init the column padding on focus effect.
Keyword arguments can contain enlarge_time and padding.
"""
self._effects[name] = kwargs
if "enlarge_time" not in kwargs:
kwargs['enlarge_time'] = 0.5
... | python | def _effectinit_raise_col_padding_on_focus(self, name, **kwargs):
"""Init the column padding on focus effect.
Keyword arguments can contain enlarge_time and padding.
"""
self._effects[name] = kwargs
if "enlarge_time" not in kwargs:
kwargs['enlarge_time'] = 0.5
... | [
"def",
"_effectinit_raise_col_padding_on_focus",
"(",
"self",
",",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_effects",
"[",
"name",
"]",
"=",
"kwargs",
"if",
"\"enlarge_time\"",
"not",
"in",
"kwargs",
":",
"kwargs",
"[",
"'enlarge_time'",
"]"... | Init the column padding on focus effect.
Keyword arguments can contain enlarge_time and padding. | [
"Init",
"the",
"column",
"padding",
"on",
"focus",
"effect",
".",
"Keyword",
"arguments",
"can",
"contain",
"enlarge_time",
"and",
"padding",
"."
] | train | https://github.com/a-tal/kezmenu3/blob/3b06f9cb67fdc98a73928f877eea86692f832fa4/kezmenu3/kezmenu_effects.py#L146-L159 |
crcresearch/py-utils | crc_nd/utils/django.py | make_choices_tuple | def make_choices_tuple(choices, get_display_name):
"""
Make a tuple for the choices parameter for a data model field.
:param choices: sequence of valid values for the model field
:param get_display_name: callable that returns the human-readable name for a choice
:return: A tuple of 2-tuples (choic... | python | def make_choices_tuple(choices, get_display_name):
"""
Make a tuple for the choices parameter for a data model field.
:param choices: sequence of valid values for the model field
:param get_display_name: callable that returns the human-readable name for a choice
:return: A tuple of 2-tuples (choic... | [
"def",
"make_choices_tuple",
"(",
"choices",
",",
"get_display_name",
")",
":",
"assert",
"callable",
"(",
"get_display_name",
")",
"return",
"tuple",
"(",
"(",
"x",
",",
"get_display_name",
"(",
"x",
")",
")",
"for",
"x",
"in",
"choices",
")"
] | Make a tuple for the choices parameter for a data model field.
:param choices: sequence of valid values for the model field
:param get_display_name: callable that returns the human-readable name for a choice
:return: A tuple of 2-tuples (choice, display_name) suitable for the choices parameter | [
"Make",
"a",
"tuple",
"for",
"the",
"choices",
"parameter",
"for",
"a",
"data",
"model",
"field",
"."
] | train | https://github.com/crcresearch/py-utils/blob/04caf0425a047baf900da726cf47c42413b0dd81/crc_nd/utils/django.py#L16-L26 |
gdoermann/voicebase | voicebase/api/media.py | clean_dict | def clean_dict(d, test=lambda v: v):
"""
Return only keys that meet the test
:param d: Dictionary
:param test: the test to run on the value (example override is: "lambda v: v is not None")
:return: Cleaned dictionary
"""
return {k: v for k, v in d.items() if test(v)} | python | def clean_dict(d, test=lambda v: v):
"""
Return only keys that meet the test
:param d: Dictionary
:param test: the test to run on the value (example override is: "lambda v: v is not None")
:return: Cleaned dictionary
"""
return {k: v for k, v in d.items() if test(v)} | [
"def",
"clean_dict",
"(",
"d",
",",
"test",
"=",
"lambda",
"v",
":",
"v",
")",
":",
"return",
"{",
"k",
":",
"v",
"for",
"k",
",",
"v",
"in",
"d",
".",
"items",
"(",
")",
"if",
"test",
"(",
"v",
")",
"}"
] | Return only keys that meet the test
:param d: Dictionary
:param test: the test to run on the value (example override is: "lambda v: v is not None")
:return: Cleaned dictionary | [
"Return",
"only",
"keys",
"that",
"meet",
"the",
"test",
":",
"param",
"d",
":",
"Dictionary",
":",
"param",
"test",
":",
"the",
"test",
"to",
"run",
"on",
"the",
"value",
"(",
"example",
"override",
"is",
":",
"lambda",
"v",
":",
"v",
"is",
"not",
... | train | https://github.com/gdoermann/voicebase/blob/53cb4735327898a7a284dea3a60ace0b3956a8ec/voicebase/api/media.py#L14-L21 |
gdoermann/voicebase | voicebase/api/media.py | VoicebaseMediaConfiguration.prediction_model_dict | def prediction_model_dict(self):
"""
Converts the list of prediction_models passed in into properly formatted dictionaries
:return: formatted prediction model dict
"""
models = {}
for model in self.predictions_models:
models[model.name] = model.keywords
... | python | def prediction_model_dict(self):
"""
Converts the list of prediction_models passed in into properly formatted dictionaries
:return: formatted prediction model dict
"""
models = {}
for model in self.predictions_models:
models[model.name] = model.keywords
... | [
"def",
"prediction_model_dict",
"(",
"self",
")",
":",
"models",
"=",
"{",
"}",
"for",
"model",
"in",
"self",
".",
"predictions_models",
":",
"models",
"[",
"model",
".",
"name",
"]",
"=",
"model",
".",
"keywords",
"return",
"models"
] | Converts the list of prediction_models passed in into properly formatted dictionaries
:return: formatted prediction model dict | [
"Converts",
"the",
"list",
"of",
"prediction_models",
"passed",
"in",
"into",
"properly",
"formatted",
"dictionaries",
":",
"return",
":",
"formatted",
"prediction",
"model",
"dict"
] | train | https://github.com/gdoermann/voicebase/blob/53cb4735327898a7a284dea3a60ace0b3956a8ec/voicebase/api/media.py#L153-L161 |
gdoermann/voicebase | voicebase/api/media.py | MediaEndpoint.list | def list(self, external_id=None):
"""
Retrieve from the media colection.
HTTP GET on /media
:param external_id: A unique identifier in an external system, set in metadata on POST.
:return: list(VoicebaseMedia)
"""
response = self._get('base')
return [Voice... | python | def list(self, external_id=None):
"""
Retrieve from the media colection.
HTTP GET on /media
:param external_id: A unique identifier in an external system, set in metadata on POST.
:return: list(VoicebaseMedia)
"""
response = self._get('base')
return [Voice... | [
"def",
"list",
"(",
"self",
",",
"external_id",
"=",
"None",
")",
":",
"response",
"=",
"self",
".",
"_get",
"(",
"'base'",
")",
"return",
"[",
"VoicebaseMedia",
"(",
"o",
",",
"self",
".",
"api",
")",
"for",
"o",
"in",
"response",
"[",
"'media'",
... | Retrieve from the media colection.
HTTP GET on /media
:param external_id: A unique identifier in an external system, set in metadata on POST.
:return: list(VoicebaseMedia) | [
"Retrieve",
"from",
"the",
"media",
"colection",
".",
"HTTP",
"GET",
"on",
"/",
"media",
":",
"param",
"external_id",
":",
"A",
"unique",
"identifier",
"in",
"an",
"external",
"system",
"set",
"in",
"metadata",
"on",
"POST",
".",
":",
"return",
":",
"lis... | train | https://github.com/gdoermann/voicebase/blob/53cb4735327898a7a284dea3a60ace0b3956a8ec/voicebase/api/media.py#L260-L268 |
gdoermann/voicebase | voicebase/api/media.py | MediaEndpoint.upload | def upload(self, filename, configuration=None, metadata=None, transcript=None):
"""
Upload new new media to the service as an attachment or from a url.
HTTP POST on /media
:param filename: Media file attached to the request.
:param configuration: VoicebaseMediaConfiguration
... | python | def upload(self, filename, configuration=None, metadata=None, transcript=None):
"""
Upload new new media to the service as an attachment or from a url.
HTTP POST on /media
:param filename: Media file attached to the request.
:param configuration: VoicebaseMediaConfiguration
... | [
"def",
"upload",
"(",
"self",
",",
"filename",
",",
"configuration",
"=",
"None",
",",
"metadata",
"=",
"None",
",",
"transcript",
"=",
"None",
")",
":",
"data",
"=",
"{",
"}",
"if",
"metadata",
":",
"data",
"[",
"'metadata'",
"]",
"=",
"str",
"(",
... | Upload new new media to the service as an attachment or from a url.
HTTP POST on /media
:param filename: Media file attached to the request.
:param configuration: VoicebaseMediaConfiguration
:param metadata: VoicebaseMediaMeta
:param transcript: attached transcript
:retur... | [
"Upload",
"new",
"new",
"media",
"to",
"the",
"service",
"as",
"an",
"attachment",
"or",
"from",
"a",
"url",
".",
"HTTP",
"POST",
"on",
"/",
"media",
":",
"param",
"filename",
":",
"Media",
"file",
"attached",
"to",
"the",
"request",
".",
":",
"param",... | train | https://github.com/gdoermann/voicebase/blob/53cb4735327898a7a284dea3a60ace0b3956a8ec/voicebase/api/media.py#L270-L300 |
gdoermann/voicebase | voicebase/api/media.py | MediaEndpoint.get | def get(self, media_id):
"""
Get this media item and associated analytics.
HTTP GET on /media/{mediaId}
:param media_id: Media ID
:return: VoicebaseMedia
"""
response = self._get('item', format_dict=dict(media_id=media_id))
return VoicebaseMedia(response, ... | python | def get(self, media_id):
"""
Get this media item and associated analytics.
HTTP GET on /media/{mediaId}
:param media_id: Media ID
:return: VoicebaseMedia
"""
response = self._get('item', format_dict=dict(media_id=media_id))
return VoicebaseMedia(response, ... | [
"def",
"get",
"(",
"self",
",",
"media_id",
")",
":",
"response",
"=",
"self",
".",
"_get",
"(",
"'item'",
",",
"format_dict",
"=",
"dict",
"(",
"media_id",
"=",
"media_id",
")",
")",
"return",
"VoicebaseMedia",
"(",
"response",
",",
"api",
"=",
"self"... | Get this media item and associated analytics.
HTTP GET on /media/{mediaId}
:param media_id: Media ID
:return: VoicebaseMedia | [
"Get",
"this",
"media",
"item",
"and",
"associated",
"analytics",
".",
"HTTP",
"GET",
"on",
"/",
"media",
"/",
"{",
"mediaId",
"}",
":",
"param",
"media_id",
":",
"Media",
"ID",
":",
"return",
":",
"VoicebaseMedia"
] | train | https://github.com/gdoermann/voicebase/blob/53cb4735327898a7a284dea3a60ace0b3956a8ec/voicebase/api/media.py#L302-L310 |
AndresMWeber/Nomenclate | nomenclate/core/renderers.py | RenderVar._get_variation_id | def _get_variation_id(value, capital=False):
""" Convert an integer value to a character. a-z then double aa-zz etc
Args:
value (int): integer index we're looking up
capital (bool): whether we convert to capitals or not
Returns (str): alphanumeric representation of the in... | python | def _get_variation_id(value, capital=False):
""" Convert an integer value to a character. a-z then double aa-zz etc
Args:
value (int): integer index we're looking up
capital (bool): whether we convert to capitals or not
Returns (str): alphanumeric representation of the in... | [
"def",
"_get_variation_id",
"(",
"value",
",",
"capital",
"=",
"False",
")",
":",
"# Reinforcing type just in case a valid string was entered",
"value",
"=",
"int",
"(",
"value",
")",
"base_power",
"=",
"base_start",
"=",
"base_end",
"=",
"0",
"while",
"value",
">... | Convert an integer value to a character. a-z then double aa-zz etc
Args:
value (int): integer index we're looking up
capital (bool): whether we convert to capitals or not
Returns (str): alphanumeric representation of the index | [
"Convert",
"an",
"integer",
"value",
"to",
"a",
"character",
".",
"a",
"-",
"z",
"then",
"double",
"aa",
"-",
"zz",
"etc",
"Args",
":",
"value",
"(",
"int",
")",
":",
"integer",
"index",
"we",
"re",
"looking",
"up",
"capital",
"(",
"bool",
")",
":"... | train | https://github.com/AndresMWeber/Nomenclate/blob/e6d6fc28beac042bad588e56fbe77531d2de6b6f/nomenclate/core/renderers.py#L156-L179 |
hobson/pug-dj | pug/dj/miner/templatetags/getattribute.py | getattribute | def getattribute(value, arg):
"""Gets an attribute of an object dynamically from a string name"""
if hasattr(value, str(arg)):
return getattr(value, arg)
elif hasattr(value, 'has_key') and value.has_key(arg):
return value[arg]
elif numeric_test.match(str(arg)) and len(value) > int(arg):... | python | def getattribute(value, arg):
"""Gets an attribute of an object dynamically from a string name"""
if hasattr(value, str(arg)):
return getattr(value, arg)
elif hasattr(value, 'has_key') and value.has_key(arg):
return value[arg]
elif numeric_test.match(str(arg)) and len(value) > int(arg):... | [
"def",
"getattribute",
"(",
"value",
",",
"arg",
")",
":",
"if",
"hasattr",
"(",
"value",
",",
"str",
"(",
"arg",
")",
")",
":",
"return",
"getattr",
"(",
"value",
",",
"arg",
")",
"elif",
"hasattr",
"(",
"value",
",",
"'has_key'",
")",
"and",
"val... | Gets an attribute of an object dynamically from a string name | [
"Gets",
"an",
"attribute",
"of",
"an",
"object",
"dynamically",
"from",
"a",
"string",
"name"
] | train | https://github.com/hobson/pug-dj/blob/55678b08755a55366ce18e7d3b8ea8fa4491ab04/pug/dj/miner/templatetags/getattribute.py#L24-L34 |
jaraco/jaraco.ui | jaraco/ui/editor.py | EditableFile.edit | def edit(self):
"""
Edit the file
"""
self.changed = False
with self:
editor = self.get_editor()
cmd = [editor, self.name]
try:
res = subprocess.call(cmd)
except Exception as e:
print("Error launching editor %(editor)s" % locals())
print(e)
return
if res != 0:
msg = '%(edito... | python | def edit(self):
"""
Edit the file
"""
self.changed = False
with self:
editor = self.get_editor()
cmd = [editor, self.name]
try:
res = subprocess.call(cmd)
except Exception as e:
print("Error launching editor %(editor)s" % locals())
print(e)
return
if res != 0:
msg = '%(edito... | [
"def",
"edit",
"(",
"self",
")",
":",
"self",
".",
"changed",
"=",
"False",
"with",
"self",
":",
"editor",
"=",
"self",
".",
"get_editor",
"(",
")",
"cmd",
"=",
"[",
"editor",
",",
"self",
".",
"name",
"]",
"try",
":",
"res",
"=",
"subprocess",
"... | Edit the file | [
"Edit",
"the",
"file"
] | train | https://github.com/jaraco/jaraco.ui/blob/10e844c03f3afb3d37bd5d727ba9334af2547fcf/jaraco/ui/editor.py#L63-L83 |
jaraco/jaraco.ui | jaraco/ui/editor.py | EditableFile._search_env | def _search_env(keys):
"""
Search the environment for the supplied keys, returning the first
one found or None if none was found.
"""
matches = (os.environ[key] for key in keys if key in os.environ)
return next(matches, None) | python | def _search_env(keys):
"""
Search the environment for the supplied keys, returning the first
one found or None if none was found.
"""
matches = (os.environ[key] for key in keys if key in os.environ)
return next(matches, None) | [
"def",
"_search_env",
"(",
"keys",
")",
":",
"matches",
"=",
"(",
"os",
".",
"environ",
"[",
"key",
"]",
"for",
"key",
"in",
"keys",
"if",
"key",
"in",
"os",
".",
"environ",
")",
"return",
"next",
"(",
"matches",
",",
"None",
")"
] | Search the environment for the supplied keys, returning the first
one found or None if none was found. | [
"Search",
"the",
"environment",
"for",
"the",
"supplied",
"keys",
"returning",
"the",
"first",
"one",
"found",
"or",
"None",
"if",
"none",
"was",
"found",
"."
] | train | https://github.com/jaraco/jaraco.ui/blob/10e844c03f3afb3d37bd5d727ba9334af2547fcf/jaraco/ui/editor.py#L86-L92 |
jaraco/jaraco.ui | jaraco/ui/editor.py | EditableFile.get_editor | def get_editor(self):
"""
Give preference to an XML_EDITOR or EDITOR defined in the
environment. Otherwise use a default editor based on platform.
"""
env_search = ['EDITOR']
if 'xml' in self.content_type:
env_search.insert(0, 'XML_EDITOR')
default_editor = self.platform_default_editors[sys.platform]
... | python | def get_editor(self):
"""
Give preference to an XML_EDITOR or EDITOR defined in the
environment. Otherwise use a default editor based on platform.
"""
env_search = ['EDITOR']
if 'xml' in self.content_type:
env_search.insert(0, 'XML_EDITOR')
default_editor = self.platform_default_editors[sys.platform]
... | [
"def",
"get_editor",
"(",
"self",
")",
":",
"env_search",
"=",
"[",
"'EDITOR'",
"]",
"if",
"'xml'",
"in",
"self",
".",
"content_type",
":",
"env_search",
".",
"insert",
"(",
"0",
",",
"'XML_EDITOR'",
")",
"default_editor",
"=",
"self",
".",
"platform_defau... | Give preference to an XML_EDITOR or EDITOR defined in the
environment. Otherwise use a default editor based on platform. | [
"Give",
"preference",
"to",
"an",
"XML_EDITOR",
"or",
"EDITOR",
"defined",
"in",
"the",
"environment",
".",
"Otherwise",
"use",
"a",
"default",
"editor",
"based",
"on",
"platform",
"."
] | train | https://github.com/jaraco/jaraco.ui/blob/10e844c03f3afb3d37bd5d727ba9334af2547fcf/jaraco/ui/editor.py#L94-L103 |
sbuss/pypercube | pypercube/event.py | Event.from_json | def from_json(cls, json_obj):
"""Build an Event from JSON.
:param json_obj: JSON data representing a Cube Event
:type json_obj: `String` or `json`
:throws: `InvalidEventError` when any of time field is not present
in json_obj.
"""
if isinstance(json_obj, str):
... | python | def from_json(cls, json_obj):
"""Build an Event from JSON.
:param json_obj: JSON data representing a Cube Event
:type json_obj: `String` or `json`
:throws: `InvalidEventError` when any of time field is not present
in json_obj.
"""
if isinstance(json_obj, str):
... | [
"def",
"from_json",
"(",
"cls",
",",
"json_obj",
")",
":",
"if",
"isinstance",
"(",
"json_obj",
",",
"str",
")",
":",
"json_obj",
"=",
"json",
".",
"loads",
"(",
"json_obj",
")",
"type",
"=",
"None",
"time",
"=",
"None",
"data",
"=",
"None",
"if",
... | Build an Event from JSON.
:param json_obj: JSON data representing a Cube Event
:type json_obj: `String` or `json`
:throws: `InvalidEventError` when any of time field is not present
in json_obj. | [
"Build",
"an",
"Event",
"from",
"JSON",
"."
] | train | https://github.com/sbuss/pypercube/blob/e9d2cca9c004b8bad6d1e0b68b080f887a186a22/pypercube/event.py#L31-L57 |
Perfectial/django-view-acl | view_acl/__init__.py | autodiscover | def autodiscover():
"""Autodiscover for urls.py"""
# Get permissions based on urlpatterns from urls.py
url_conf = getattr(settings, 'ROOT_URLCONF', ())
resolver = urlresolvers.get_resolver(url_conf)
urlpatterns = resolver.url_patterns
permissions = generate_permissions(urlpatterns)
# Refresh... | python | def autodiscover():
"""Autodiscover for urls.py"""
# Get permissions based on urlpatterns from urls.py
url_conf = getattr(settings, 'ROOT_URLCONF', ())
resolver = urlresolvers.get_resolver(url_conf)
urlpatterns = resolver.url_patterns
permissions = generate_permissions(urlpatterns)
# Refresh... | [
"def",
"autodiscover",
"(",
")",
":",
"# Get permissions based on urlpatterns from urls.py",
"url_conf",
"=",
"getattr",
"(",
"settings",
",",
"'ROOT_URLCONF'",
",",
"(",
")",
")",
"resolver",
"=",
"urlresolvers",
".",
"get_resolver",
"(",
"url_conf",
")",
"urlpatte... | Autodiscover for urls.py | [
"Autodiscover",
"for",
"urls",
".",
"py"
] | train | https://github.com/Perfectial/django-view-acl/blob/71f514f65761895bc64d5ca735997c5455c254fa/view_acl/__init__.py#L7-L15 |
Apitax/Apitax | apitax/api/controllers/drivers_controller.py | get_driver_blacklist | def get_driver_blacklist(driver): # noqa: E501
"""Retrieve the blacklist in the driver
Retrieve the blacklist in the driver # noqa: E501
:param driver: The driver to use for the request. ie. github
:type driver: str
:rtype: Response
"""
response = errorIfUnauthorized(role='admin')
i... | python | def get_driver_blacklist(driver): # noqa: E501
"""Retrieve the blacklist in the driver
Retrieve the blacklist in the driver # noqa: E501
:param driver: The driver to use for the request. ie. github
:type driver: str
:rtype: Response
"""
response = errorIfUnauthorized(role='admin')
i... | [
"def",
"get_driver_blacklist",
"(",
"driver",
")",
":",
"# noqa: E501",
"response",
"=",
"errorIfUnauthorized",
"(",
"role",
"=",
"'admin'",
")",
"if",
"response",
":",
"return",
"response",
"else",
":",
"response",
"=",
"ApitaxResponse",
"(",
")",
"driver",
"... | Retrieve the blacklist in the driver
Retrieve the blacklist in the driver # noqa: E501
:param driver: The driver to use for the request. ie. github
:type driver: str
:rtype: Response | [
"Retrieve",
"the",
"blacklist",
"in",
"the",
"driver"
] | train | https://github.com/Apitax/Apitax/blob/3883e45f17e01eba4edac9d1bba42f0e7a748682/apitax/api/controllers/drivers_controller.py#L16-L36 |
Apitax/Apitax | apitax/api/controllers/drivers_controller.py | get_driver_config | def get_driver_config(driver): # noqa: E501
"""Retrieve the config of a loaded driver
Retrieve the config of a loaded driver # noqa: E501
:param driver: The driver to use for the request. ie. github
:type driver: str
:rtype: Response
"""
response = errorIfUnauthorized(role='admin')
... | python | def get_driver_config(driver): # noqa: E501
"""Retrieve the config of a loaded driver
Retrieve the config of a loaded driver # noqa: E501
:param driver: The driver to use for the request. ie. github
:type driver: str
:rtype: Response
"""
response = errorIfUnauthorized(role='admin')
... | [
"def",
"get_driver_config",
"(",
"driver",
")",
":",
"# noqa: E501",
"response",
"=",
"errorIfUnauthorized",
"(",
"role",
"=",
"'admin'",
")",
"if",
"response",
":",
"return",
"response",
"else",
":",
"response",
"=",
"ApitaxResponse",
"(",
")",
"# TODO: This ne... | Retrieve the config of a loaded driver
Retrieve the config of a loaded driver # noqa: E501
:param driver: The driver to use for the request. ie. github
:type driver: str
:rtype: Response | [
"Retrieve",
"the",
"config",
"of",
"a",
"loaded",
"driver"
] | train | https://github.com/Apitax/Apitax/blob/3883e45f17e01eba4edac9d1bba42f0e7a748682/apitax/api/controllers/drivers_controller.py#L39-L58 |
Apitax/Apitax | apitax/api/controllers/drivers_controller.py | get_driver_list | def get_driver_list(): # noqa: E501
"""Retrieve the catalog of drivers
Retrieve the catalog of drivers # noqa: E501
:rtype: Response
"""
response = errorIfUnauthorized(role='admin')
if response:
return response
else:
response = ApitaxResponse()
response.body.add({'d... | python | def get_driver_list(): # noqa: E501
"""Retrieve the catalog of drivers
Retrieve the catalog of drivers # noqa: E501
:rtype: Response
"""
response = errorIfUnauthorized(role='admin')
if response:
return response
else:
response = ApitaxResponse()
response.body.add({'d... | [
"def",
"get_driver_list",
"(",
")",
":",
"# noqa: E501",
"response",
"=",
"errorIfUnauthorized",
"(",
"role",
"=",
"'admin'",
")",
"if",
"response",
":",
"return",
"response",
"else",
":",
"response",
"=",
"ApitaxResponse",
"(",
")",
"response",
".",
"body",
... | Retrieve the catalog of drivers
Retrieve the catalog of drivers # noqa: E501
:rtype: Response | [
"Retrieve",
"the",
"catalog",
"of",
"drivers"
] | train | https://github.com/Apitax/Apitax/blob/3883e45f17e01eba4edac9d1bba42f0e7a748682/apitax/api/controllers/drivers_controller.py#L61-L78 |
Apitax/Apitax | apitax/api/controllers/drivers_controller.py | get_driver_status | def get_driver_status(driver): # noqa: E501
"""Retrieve the status of a loaded driver
Retrieve the status of a loaded driver # noqa: E501
:param driver: The driver to use for the request. ie. github
:type driver: str
:rtype: Response
"""
response = errorIfUnauthorized(role='admin')
... | python | def get_driver_status(driver): # noqa: E501
"""Retrieve the status of a loaded driver
Retrieve the status of a loaded driver # noqa: E501
:param driver: The driver to use for the request. ie. github
:type driver: str
:rtype: Response
"""
response = errorIfUnauthorized(role='admin')
... | [
"def",
"get_driver_status",
"(",
"driver",
")",
":",
"# noqa: E501",
"response",
"=",
"errorIfUnauthorized",
"(",
"role",
"=",
"'admin'",
")",
"if",
"response",
":",
"return",
"response",
"else",
":",
"response",
"=",
"ApitaxResponse",
"(",
")",
"driver",
":",... | Retrieve the status of a loaded driver
Retrieve the status of a loaded driver # noqa: E501
:param driver: The driver to use for the request. ie. github
:type driver: str
:rtype: Response | [
"Retrieve",
"the",
"status",
"of",
"a",
"loaded",
"driver"
] | train | https://github.com/Apitax/Apitax/blob/3883e45f17e01eba4edac9d1bba42f0e7a748682/apitax/api/controllers/drivers_controller.py#L81-L113 |
Apitax/Apitax | apitax/api/controllers/drivers_controller.py | get_driver_whitelist | def get_driver_whitelist(driver): # noqa: E501
"""Retrieve the whitelist in the driver
Retrieve the whitelist in the driver # noqa: E501
:param driver: The driver to use for the request. ie. github
:type driver: str
:rtype: Response
"""
response = errorIfUnauthorized(role='admin')
i... | python | def get_driver_whitelist(driver): # noqa: E501
"""Retrieve the whitelist in the driver
Retrieve the whitelist in the driver # noqa: E501
:param driver: The driver to use for the request. ie. github
:type driver: str
:rtype: Response
"""
response = errorIfUnauthorized(role='admin')
i... | [
"def",
"get_driver_whitelist",
"(",
"driver",
")",
":",
"# noqa: E501",
"response",
"=",
"errorIfUnauthorized",
"(",
"role",
"=",
"'admin'",
")",
"if",
"response",
":",
"return",
"response",
"else",
":",
"response",
"=",
"ApitaxResponse",
"(",
")",
"driver",
"... | Retrieve the whitelist in the driver
Retrieve the whitelist in the driver # noqa: E501
:param driver: The driver to use for the request. ie. github
:type driver: str
:rtype: Response | [
"Retrieve",
"the",
"whitelist",
"in",
"the",
"driver"
] | train | https://github.com/Apitax/Apitax/blob/3883e45f17e01eba4edac9d1bba42f0e7a748682/apitax/api/controllers/drivers_controller.py#L116-L136 |
bitlabstudio/django-tagging-translated | tagging_translated/models.py | tag_post_save_handler | def tag_post_save_handler(sender, **kwargs):
"""
Makes sure that a translation is created when a tag is saved.
Also ensures that the original tag name gets updated when the english
translation is updated.
TODO: This will create two tags when a tag is saved through the admin
"""
instance =... | python | def tag_post_save_handler(sender, **kwargs):
"""
Makes sure that a translation is created when a tag is saved.
Also ensures that the original tag name gets updated when the english
translation is updated.
TODO: This will create two tags when a tag is saved through the admin
"""
instance =... | [
"def",
"tag_post_save_handler",
"(",
"sender",
",",
"*",
"*",
"kwargs",
")",
":",
"instance",
"=",
"kwargs",
".",
"get",
"(",
"'instance'",
")",
"try",
":",
"translation",
"=",
"instance",
".",
"tagtitle_set",
".",
"get",
"(",
"language",
"=",
"'en'",
")... | Makes sure that a translation is created when a tag is saved.
Also ensures that the original tag name gets updated when the english
translation is updated.
TODO: This will create two tags when a tag is saved through the admin | [
"Makes",
"sure",
"that",
"a",
"translation",
"is",
"created",
"when",
"a",
"tag",
"is",
"saved",
"."
] | train | https://github.com/bitlabstudio/django-tagging-translated/blob/8766d88077959efb07a97a116538e53b800b6019/tagging_translated/models.py#L23-L41 |
tmr232/rage | rage/rage.py | require_editable | def require_editable(f):
"""
Makes sure the registry key is editable before trying to edit it.
"""
def wrapper(self, *args, **kwargs):
if not self._edit:
raise RegistryKeyNotEditable("The key is not set as editable.")
return f(self, *args, **kwargs)
return wrapper | python | def require_editable(f):
"""
Makes sure the registry key is editable before trying to edit it.
"""
def wrapper(self, *args, **kwargs):
if not self._edit:
raise RegistryKeyNotEditable("The key is not set as editable.")
return f(self, *args, **kwargs)
return wrapper | [
"def",
"require_editable",
"(",
"f",
")",
":",
"def",
"wrapper",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"self",
".",
"_edit",
":",
"raise",
"RegistryKeyNotEditable",
"(",
"\"The key is not set as editable.\"",
")",
"... | Makes sure the registry key is editable before trying to edit it. | [
"Makes",
"sure",
"the",
"registry",
"key",
"is",
"editable",
"before",
"trying",
"to",
"edit",
"it",
"."
] | train | https://github.com/tmr232/rage/blob/0973a43a6956e8bacd14245509b26608f6649edb/rage/rage.py#L31-L41 |
Synerty/pytmpdir | pytmpdir/Directory.py | Directory.pathNames | def pathNames(self) -> [str]:
""" Path Names
@return: A list of path + name of each file, relative to the root
directory.
"""
return [f.pathName for f in list(self._files.values())] | python | def pathNames(self) -> [str]:
""" Path Names
@return: A list of path + name of each file, relative to the root
directory.
"""
return [f.pathName for f in list(self._files.values())] | [
"def",
"pathNames",
"(",
"self",
")",
"->",
"[",
"str",
"]",
":",
"return",
"[",
"f",
".",
"pathName",
"for",
"f",
"in",
"list",
"(",
"self",
".",
"_files",
".",
"values",
"(",
")",
")",
"]"
] | Path Names
@return: A list of path + name of each file, relative to the root
directory. | [
"Path",
"Names"
] | train | https://github.com/Synerty/pytmpdir/blob/8f21d7a0b28d4f5c3a0ed91f9660ac5310773605/pytmpdir/Directory.py#L141-L148 |
Synerty/pytmpdir | pytmpdir/Directory.py | Directory.paths | def paths(self) -> [str]:
""" Paths
@return: A list of the paths, effectively a list of relative
directory names.
"""
return set([f.path for f in list(self._files.values())]) | python | def paths(self) -> [str]:
""" Paths
@return: A list of the paths, effectively a list of relative
directory names.
"""
return set([f.path for f in list(self._files.values())]) | [
"def",
"paths",
"(",
"self",
")",
"->",
"[",
"str",
"]",
":",
"return",
"set",
"(",
"[",
"f",
".",
"path",
"for",
"f",
"in",
"list",
"(",
"self",
".",
"_files",
".",
"values",
"(",
")",
")",
"]",
")"
] | Paths
@return: A list of the paths, effectively a list of relative
directory names. | [
"Paths"
] | train | https://github.com/Synerty/pytmpdir/blob/8f21d7a0b28d4f5c3a0ed91f9660ac5310773605/pytmpdir/Directory.py#L151-L158 |
Synerty/pytmpdir | pytmpdir/Directory.py | Directory.getFile | def getFile(self, path: str = '', name: str = None,
pathName: str = None) -> 'File':
""" Get File
Get File name corresponding to a path name.
@param path: File path. Default as empty string.
@param name: File name to be used if passed.
@param pathName: Joined f... | python | def getFile(self, path: str = '', name: str = None,
pathName: str = None) -> 'File':
""" Get File
Get File name corresponding to a path name.
@param path: File path. Default as empty string.
@param name: File name to be used if passed.
@param pathName: Joined f... | [
"def",
"getFile",
"(",
"self",
",",
"path",
":",
"str",
"=",
"''",
",",
"name",
":",
"str",
"=",
"None",
",",
"pathName",
":",
"str",
"=",
"None",
")",
"->",
"'File'",
":",
"assert",
"(",
"name",
"or",
"pathName",
")",
"pathName",
"=",
"(",
"path... | Get File
Get File name corresponding to a path name.
@param path: File path. Default as empty string.
@param name: File name to be used if passed.
@param pathName: Joined file name and path to be used if passed.
@type path: String
@type name: String
@type pathN... | [
"Get",
"File"
] | train | https://github.com/Synerty/pytmpdir/blob/8f21d7a0b28d4f5c3a0ed91f9660ac5310773605/pytmpdir/Directory.py#L160-L177 |
Synerty/pytmpdir | pytmpdir/Directory.py | Directory.createFile | def createFile(self, path: str = '', name: str = None,
pathName: str = None) -> 'File':
""" Create File
Creates a new file and updates file dictionary.
@param path: File path. Defaults as empty string.
@param name: File name to be used if passed.
@param path... | python | def createFile(self, path: str = '', name: str = None,
pathName: str = None) -> 'File':
""" Create File
Creates a new file and updates file dictionary.
@param path: File path. Defaults as empty string.
@param name: File name to be used if passed.
@param path... | [
"def",
"createFile",
"(",
"self",
",",
"path",
":",
"str",
"=",
"''",
",",
"name",
":",
"str",
"=",
"None",
",",
"pathName",
":",
"str",
"=",
"None",
")",
"->",
"'File'",
":",
"file",
"=",
"File",
"(",
"self",
",",
"path",
"=",
"path",
",",
"na... | Create File
Creates a new file and updates file dictionary.
@param path: File path. Defaults as empty string.
@param name: File name to be used if passed.
@param pathName: Joined file name and path to be used if passed.
@type path: String
@type name: String
@ty... | [
"Create",
"File"
] | train | https://github.com/Synerty/pytmpdir/blob/8f21d7a0b28d4f5c3a0ed91f9660ac5310773605/pytmpdir/Directory.py#L179-L196 |
Synerty/pytmpdir | pytmpdir/Directory.py | Directory.createTempFile | def createTempFile(self, suffix=None, prefix=None, secure=True) -> 'File':
""" Create File
Creates a new file within the directory with a temporary file like name.
@return: Created file.
"""
if not secure:
raise NotImplementedError("We only support secure files at t... | python | def createTempFile(self, suffix=None, prefix=None, secure=True) -> 'File':
""" Create File
Creates a new file within the directory with a temporary file like name.
@return: Created file.
"""
if not secure:
raise NotImplementedError("We only support secure files at t... | [
"def",
"createTempFile",
"(",
"self",
",",
"suffix",
"=",
"None",
",",
"prefix",
"=",
"None",
",",
"secure",
"=",
"True",
")",
"->",
"'File'",
":",
"if",
"not",
"secure",
":",
"raise",
"NotImplementedError",
"(",
"\"We only support secure files at this point\"",... | Create File
Creates a new file within the directory with a temporary file like name.
@return: Created file. | [
"Create",
"File"
] | train | https://github.com/Synerty/pytmpdir/blob/8f21d7a0b28d4f5c3a0ed91f9660ac5310773605/pytmpdir/Directory.py#L198-L218 |
Synerty/pytmpdir | pytmpdir/Directory.py | Directory.createHiddenFolder | def createHiddenFolder(self) -> 'File':
""" Create Hidden Folder
Create a hidden folder. Raise exception if auto delete isn't True.
@return: Created folder.
"""
if not self._autoDelete:
raise Exception("Hidden folders can only be created within"
... | python | def createHiddenFolder(self) -> 'File':
""" Create Hidden Folder
Create a hidden folder. Raise exception if auto delete isn't True.
@return: Created folder.
"""
if not self._autoDelete:
raise Exception("Hidden folders can only be created within"
... | [
"def",
"createHiddenFolder",
"(",
"self",
")",
"->",
"'File'",
":",
"if",
"not",
"self",
".",
"_autoDelete",
":",
"raise",
"Exception",
"(",
"\"Hidden folders can only be created within\"",
"\" an autoDelete directory\"",
")",
"return",
"tempfile",
".",
"mkdtemp",
"("... | Create Hidden Folder
Create a hidden folder. Raise exception if auto delete isn't True.
@return: Created folder. | [
"Create",
"Hidden",
"Folder"
] | train | https://github.com/Synerty/pytmpdir/blob/8f21d7a0b28d4f5c3a0ed91f9660ac5310773605/pytmpdir/Directory.py#L220-L231 |
Synerty/pytmpdir | pytmpdir/Directory.py | Directory._listFilesWin | def _listFilesWin(self) -> ['File']:
""" List Files for Windows OS
Search and list the files and folder in the current directory for the
Windows file system.
@return: List of directory files and folders.
"""
output = []
for dirname, dirnames, filenames in os.wa... | python | def _listFilesWin(self) -> ['File']:
""" List Files for Windows OS
Search and list the files and folder in the current directory for the
Windows file system.
@return: List of directory files and folders.
"""
output = []
for dirname, dirnames, filenames in os.wa... | [
"def",
"_listFilesWin",
"(",
"self",
")",
"->",
"[",
"'File'",
"]",
":",
"output",
"=",
"[",
"]",
"for",
"dirname",
",",
"dirnames",
",",
"filenames",
"in",
"os",
".",
"walk",
"(",
"self",
".",
"_path",
")",
":",
"for",
"subdirname",
"in",
"dirnames"... | List Files for Windows OS
Search and list the files and folder in the current directory for the
Windows file system.
@return: List of directory files and folders. | [
"List",
"Files",
"for",
"Windows",
"OS"
] | train | https://github.com/Synerty/pytmpdir/blob/8f21d7a0b28d4f5c3a0ed91f9660ac5310773605/pytmpdir/Directory.py#L233-L248 |
Synerty/pytmpdir | pytmpdir/Directory.py | Directory._listFilesPosix | def _listFilesPosix(self) -> ['File']:
""" List Files for POSIX
Search and list the files and folder in the current directory for the
POSIX file system.
@return: List of directory files and folders.
"""
find = "find %s -type f" % self._path
output = check_outpu... | python | def _listFilesPosix(self) -> ['File']:
""" List Files for POSIX
Search and list the files and folder in the current directory for the
POSIX file system.
@return: List of directory files and folders.
"""
find = "find %s -type f" % self._path
output = check_outpu... | [
"def",
"_listFilesPosix",
"(",
"self",
")",
"->",
"[",
"'File'",
"]",
":",
"find",
"=",
"\"find %s -type f\"",
"%",
"self",
".",
"_path",
"output",
"=",
"check_output",
"(",
"args",
"=",
"find",
".",
"split",
"(",
")",
")",
".",
"strip",
"(",
")",
".... | List Files for POSIX
Search and list the files and folder in the current directory for the
POSIX file system.
@return: List of directory files and folders. | [
"List",
"Files",
"for",
"POSIX"
] | train | https://github.com/Synerty/pytmpdir/blob/8f21d7a0b28d4f5c3a0ed91f9660ac5310773605/pytmpdir/Directory.py#L250-L262 |
Synerty/pytmpdir | pytmpdir/Directory.py | Directory.scan | def scan(self) -> ['File']:
""" Scan
Scan the directory for files and folders and update the file dictionary.
@return: List of files
"""
self._files = {}
output = self._listFilesWin() if isWindows else self._listFilesPosix()
output = [line for line in output if... | python | def scan(self) -> ['File']:
""" Scan
Scan the directory for files and folders and update the file dictionary.
@return: List of files
"""
self._files = {}
output = self._listFilesWin() if isWindows else self._listFilesPosix()
output = [line for line in output if... | [
"def",
"scan",
"(",
"self",
")",
"->",
"[",
"'File'",
"]",
":",
"self",
".",
"_files",
"=",
"{",
"}",
"output",
"=",
"self",
".",
"_listFilesWin",
"(",
")",
"if",
"isWindows",
"else",
"self",
".",
"_listFilesPosix",
"(",
")",
"output",
"=",
"[",
"l... | Scan
Scan the directory for files and folders and update the file dictionary.
@return: List of files | [
"Scan"
] | train | https://github.com/Synerty/pytmpdir/blob/8f21d7a0b28d4f5c3a0ed91f9660ac5310773605/pytmpdir/Directory.py#L264-L283 |
Synerty/pytmpdir | pytmpdir/Directory.py | Directory.clone | def clone(self, autoDelete: bool = True) -> 'Directory':
""" Clone
Recursively copy a directory tree. Removes the destination
directory as the destination directory must not already exist.
@param autoDelete: Used to clean up files on completion. Default as
True.
@type... | python | def clone(self, autoDelete: bool = True) -> 'Directory':
""" Clone
Recursively copy a directory tree. Removes the destination
directory as the destination directory must not already exist.
@param autoDelete: Used to clean up files on completion. Default as
True.
@type... | [
"def",
"clone",
"(",
"self",
",",
"autoDelete",
":",
"bool",
"=",
"True",
")",
"->",
"'Directory'",
":",
"d",
"=",
"Directory",
"(",
"autoDelete",
"=",
"autoDelete",
")",
"os",
".",
"rmdir",
"(",
"d",
".",
"_path",
")",
"# shutil doesn't like it existing",... | Clone
Recursively copy a directory tree. Removes the destination
directory as the destination directory must not already exist.
@param autoDelete: Used to clean up files on completion. Default as
True.
@type autoDelete: Boolean
@return: The cloned directory. | [
"Clone"
] | train | https://github.com/Synerty/pytmpdir/blob/8f21d7a0b28d4f5c3a0ed91f9660ac5310773605/pytmpdir/Directory.py#L285-L301 |
Synerty/pytmpdir | pytmpdir/Directory.py | Directory._fileMoved | def _fileMoved(self, oldPathName: str, file: 'File'):
""" File Moved
Drop the old file name from the dictionary and add the new file name.
@param oldPathName: Previous dictionary path name.
@param file: File name.
@type oldPathName: String
@type file: File
"""
... | python | def _fileMoved(self, oldPathName: str, file: 'File'):
""" File Moved
Drop the old file name from the dictionary and add the new file name.
@param oldPathName: Previous dictionary path name.
@param file: File name.
@type oldPathName: String
@type file: File
"""
... | [
"def",
"_fileMoved",
"(",
"self",
",",
"oldPathName",
":",
"str",
",",
"file",
":",
"'File'",
")",
":",
"self",
".",
"_files",
".",
"pop",
"(",
"oldPathName",
")",
"self",
".",
"_files",
"[",
"file",
".",
"pathName",
"]",
"=",
"file"
] | File Moved
Drop the old file name from the dictionary and add the new file name.
@param oldPathName: Previous dictionary path name.
@param file: File name.
@type oldPathName: String
@type file: File | [
"File",
"Moved"
] | train | https://github.com/Synerty/pytmpdir/blob/8f21d7a0b28d4f5c3a0ed91f9660ac5310773605/pytmpdir/Directory.py#L314-L326 |
Synerty/pytmpdir | pytmpdir/Directory.py | File.path | def path(self, path: str):
""" Path Setter
Set path with passed in variable.
@param path: New path string.
@type path: String
"""
path = path if path else ''
self.pathName = os.path.join(path, self.name) | python | def path(self, path: str):
""" Path Setter
Set path with passed in variable.
@param path: New path string.
@type path: String
"""
path = path if path else ''
self.pathName = os.path.join(path, self.name) | [
"def",
"path",
"(",
"self",
",",
"path",
":",
"str",
")",
":",
"path",
"=",
"path",
"if",
"path",
"else",
"''",
"self",
".",
"pathName",
"=",
"os",
".",
"path",
".",
"join",
"(",
"path",
",",
"self",
".",
"name",
")"
] | Path Setter
Set path with passed in variable.
@param path: New path string.
@type path: String | [
"Path",
"Setter"
] | train | https://github.com/Synerty/pytmpdir/blob/8f21d7a0b28d4f5c3a0ed91f9660ac5310773605/pytmpdir/Directory.py#L472-L482 |
Synerty/pytmpdir | pytmpdir/Directory.py | File.name | def name(self, name: str):
""" Name Setter
Set name with passed in variable.
@param name: New name string.
@type name: String
"""
self.pathName = os.path.join(self.path, name) | python | def name(self, name: str):
""" Name Setter
Set name with passed in variable.
@param name: New name string.
@type name: String
"""
self.pathName = os.path.join(self.path, name) | [
"def",
"name",
"(",
"self",
",",
"name",
":",
"str",
")",
":",
"self",
".",
"pathName",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"path",
",",
"name",
")"
] | Name Setter
Set name with passed in variable.
@param name: New name string.
@type name: String | [
"Name",
"Setter"
] | train | https://github.com/Synerty/pytmpdir/blob/8f21d7a0b28d4f5c3a0ed91f9660ac5310773605/pytmpdir/Directory.py#L496-L505 |
Synerty/pytmpdir | pytmpdir/Directory.py | File.pathName | def pathName(self, pathName: str):
""" Path Name Setter
Set path name with passed in variable, create new directory and move
previous directory contents to new path name.
@param pathName: New path name string.
@type pathName: String
"""
if self.pathName == path... | python | def pathName(self, pathName: str):
""" Path Name Setter
Set path name with passed in variable, create new directory and move
previous directory contents to new path name.
@param pathName: New path name string.
@type pathName: String
"""
if self.pathName == path... | [
"def",
"pathName",
"(",
"self",
",",
"pathName",
":",
"str",
")",
":",
"if",
"self",
".",
"pathName",
"==",
"pathName",
":",
"return",
"pathName",
"=",
"self",
".",
"sanitise",
"(",
"pathName",
")",
"before",
"=",
"self",
".",
"realPath",
"after",
"=",... | Path Name Setter
Set path name with passed in variable, create new directory and move
previous directory contents to new path name.
@param pathName: New path name string.
@type pathName: String | [
"Path",
"Name",
"Setter"
] | train | https://github.com/Synerty/pytmpdir/blob/8f21d7a0b28d4f5c3a0ed91f9660ac5310773605/pytmpdir/Directory.py#L519-L547 |
Synerty/pytmpdir | pytmpdir/Directory.py | File.open | def open(self, append: bool = False, write: bool = False):
""" Open
Pass arguments and return open file.
@param append: Open for writing, appending to the end of the file if
it exists. Default as False.
@param write: Open for writing, truncating the file first. Default
... | python | def open(self, append: bool = False, write: bool = False):
""" Open
Pass arguments and return open file.
@param append: Open for writing, appending to the end of the file if
it exists. Default as False.
@param write: Open for writing, truncating the file first. Default
... | [
"def",
"open",
"(",
"self",
",",
"append",
":",
"bool",
"=",
"False",
",",
"write",
":",
"bool",
"=",
"False",
")",
":",
"flag",
"=",
"{",
"(",
"False",
",",
"False",
")",
":",
"'r'",
",",
"(",
"True",
",",
"False",
")",
":",
"'a'",
",",
"(",... | Open
Pass arguments and return open file.
@param append: Open for writing, appending to the end of the file if
it exists. Default as False.
@param write: Open for writing, truncating the file first. Default
as False.
@type append: Boolean
@type write: Boolean
... | [
"Open"
] | train | https://github.com/Synerty/pytmpdir/blob/8f21d7a0b28d4f5c3a0ed91f9660ac5310773605/pytmpdir/Directory.py#L549-L572 |
Synerty/pytmpdir | pytmpdir/Directory.py | File.namedTempFileReader | def namedTempFileReader(self) -> NamedTempFileReader:
""" Named Temporary File Reader
This provides an object compatible with NamedTemporaryFile, used for reading this
files contents. This will still delete after the object falls out of scope.
This solves the problem on windows where a... | python | def namedTempFileReader(self) -> NamedTempFileReader:
""" Named Temporary File Reader
This provides an object compatible with NamedTemporaryFile, used for reading this
files contents. This will still delete after the object falls out of scope.
This solves the problem on windows where a... | [
"def",
"namedTempFileReader",
"(",
"self",
")",
"->",
"NamedTempFileReader",
":",
"# Get the weak ref",
"directory",
"=",
"self",
".",
"_directory",
"(",
")",
"assert",
"isinstance",
"(",
"directory",
",",
"Directory",
")",
",",
"(",
"\"Expected Directory, receieved... | Named Temporary File Reader
This provides an object compatible with NamedTemporaryFile, used for reading this
files contents. This will still delete after the object falls out of scope.
This solves the problem on windows where a NamedTemporaryFile can not be read
while it's being writt... | [
"Named",
"Temporary",
"File",
"Reader"
] | train | https://github.com/Synerty/pytmpdir/blob/8f21d7a0b28d4f5c3a0ed91f9660ac5310773605/pytmpdir/Directory.py#L574-L590 |
Synerty/pytmpdir | pytmpdir/Directory.py | File.delete | def delete(self):
""" Delete
Deletes directory and drops the file name from dictionary. File on
file system removed on disk.
"""
directory = self._directory()
assert isinstance(directory, Directory)
realPath = self.realPath
assert (os.path.exists(realP... | python | def delete(self):
""" Delete
Deletes directory and drops the file name from dictionary. File on
file system removed on disk.
"""
directory = self._directory()
assert isinstance(directory, Directory)
realPath = self.realPath
assert (os.path.exists(realP... | [
"def",
"delete",
"(",
"self",
")",
":",
"directory",
"=",
"self",
".",
"_directory",
"(",
")",
"assert",
"isinstance",
"(",
"directory",
",",
"Directory",
")",
"realPath",
"=",
"self",
".",
"realPath",
"assert",
"(",
"os",
".",
"path",
".",
"exists",
"... | Delete
Deletes directory and drops the file name from dictionary. File on
file system removed on disk. | [
"Delete"
] | train | https://github.com/Synerty/pytmpdir/blob/8f21d7a0b28d4f5c3a0ed91f9660ac5310773605/pytmpdir/Directory.py#L592-L606 |
Synerty/pytmpdir | pytmpdir/Directory.py | File.remove | def remove(self):
""" Remove
Removes the file from the Directory object, file on file system
remains on disk.
"""
directory = self._directory()
assert isinstance(directory, Directory)
directory._fileDeleted(self) | python | def remove(self):
""" Remove
Removes the file from the Directory object, file on file system
remains on disk.
"""
directory = self._directory()
assert isinstance(directory, Directory)
directory._fileDeleted(self) | [
"def",
"remove",
"(",
"self",
")",
":",
"directory",
"=",
"self",
".",
"_directory",
"(",
")",
"assert",
"isinstance",
"(",
"directory",
",",
"Directory",
")",
"directory",
".",
"_fileDeleted",
"(",
"self",
")"
] | Remove
Removes the file from the Directory object, file on file system
remains on disk. | [
"Remove"
] | train | https://github.com/Synerty/pytmpdir/blob/8f21d7a0b28d4f5c3a0ed91f9660ac5310773605/pytmpdir/Directory.py#L608-L617 |
Synerty/pytmpdir | pytmpdir/Directory.py | File._realPath | def _realPath(self, newPathName: str = None) -> str:
""" Private Real Path
Get path name.
@param newPathName: variable for new path name if passed argument.
@type newPathName: String
@return: Path Name as string.
"""
directory = self._directory()
assert... | python | def _realPath(self, newPathName: str = None) -> str:
""" Private Real Path
Get path name.
@param newPathName: variable for new path name if passed argument.
@type newPathName: String
@return: Path Name as string.
"""
directory = self._directory()
assert... | [
"def",
"_realPath",
"(",
"self",
",",
"newPathName",
":",
"str",
"=",
"None",
")",
"->",
"str",
":",
"directory",
"=",
"self",
".",
"_directory",
"(",
")",
"assert",
"directory",
"return",
"os",
".",
"path",
".",
"join",
"(",
"directory",
".",
"path",
... | Private Real Path
Get path name.
@param newPathName: variable for new path name if passed argument.
@type newPathName: String
@return: Path Name as string. | [
"Private",
"Real",
"Path"
] | train | https://github.com/Synerty/pytmpdir/blob/8f21d7a0b28d4f5c3a0ed91f9660ac5310773605/pytmpdir/Directory.py#L664-L677 |
Synerty/pytmpdir | pytmpdir/Directory.py | File.sanitise | def sanitise(self, pathName: str) -> str:
""" Sanitise
Clean unwanted characters from the pathName string.
@param pathName: Path name variable.
@type pathName: String
@return: Path name as string.
"""
assert isinstance(pathName, str)
assert '..' not in ... | python | def sanitise(self, pathName: str) -> str:
""" Sanitise
Clean unwanted characters from the pathName string.
@param pathName: Path name variable.
@type pathName: String
@return: Path name as string.
"""
assert isinstance(pathName, str)
assert '..' not in ... | [
"def",
"sanitise",
"(",
"self",
",",
"pathName",
":",
"str",
")",
"->",
"str",
":",
"assert",
"isinstance",
"(",
"pathName",
",",
"str",
")",
"assert",
"'..'",
"not",
"in",
"pathName",
"assert",
"not",
"pathName",
".",
"endswith",
"(",
"os",
".",
"sep"... | Sanitise
Clean unwanted characters from the pathName string.
@param pathName: Path name variable.
@type pathName: String
@return: Path name as string. | [
"Sanitise"
] | train | https://github.com/Synerty/pytmpdir/blob/8f21d7a0b28d4f5c3a0ed91f9660ac5310773605/pytmpdir/Directory.py#L679-L696 |
JNRowe/jnrbase | setup.py | import_file | def import_file(package: str, fname: str) -> ModuleType:
"""Import file directly.
This is a hack to import files from packages without importing
<package>/__init__.py, its purpose is to allow import without requiring
all the dependencies at this point.
Args:
package: Package to import from... | python | def import_file(package: str, fname: str) -> ModuleType:
"""Import file directly.
This is a hack to import files from packages without importing
<package>/__init__.py, its purpose is to allow import without requiring
all the dependencies at this point.
Args:
package: Package to import from... | [
"def",
"import_file",
"(",
"package",
":",
"str",
",",
"fname",
":",
"str",
")",
"->",
"ModuleType",
":",
"mod_name",
"=",
"fname",
".",
"rstrip",
"(",
"'.py'",
")",
"spec",
"=",
"spec_from_file_location",
"(",
"mod_name",
",",
"'{}/{}'",
".",
"format",
... | Import file directly.
This is a hack to import files from packages without importing
<package>/__init__.py, its purpose is to allow import without requiring
all the dependencies at this point.
Args:
package: Package to import from
fname: File to import
Returns:
Imported mod... | [
"Import",
"file",
"directly",
"."
] | train | https://github.com/JNRowe/jnrbase/blob/ae505ef69a9feb739b5f4e62c5a8e6533104d3ea/setup.py#L42-L59 |
honzamach/pynspect | pynspect/lexer.py | PynspectFilterLexer.t_EXP_ALL | def t_EXP_ALL(self, tok): # pylint: disable=locally-disabled,invalid-name
r'(-|\+|\*|/|%|like|LIKE|=~|in|IN|~~|is|IS|eq|EQ|==|ne|NE|!=|<>|ge|GE|>=|gt|GT|>|le|LE|<=|lt|LT|<|or|OR|\|\||xor|XOR|\^\^|and|AND|&&|not|NOT|!|exists|EXISTS|\?)'
tok.type = self.reserved.get(tok.value)
tok.value = tok.typ... | python | def t_EXP_ALL(self, tok): # pylint: disable=locally-disabled,invalid-name
r'(-|\+|\*|/|%|like|LIKE|=~|in|IN|~~|is|IS|eq|EQ|==|ne|NE|!=|<>|ge|GE|>=|gt|GT|>|le|LE|<=|lt|LT|<|or|OR|\|\||xor|XOR|\^\^|and|AND|&&|not|NOT|!|exists|EXISTS|\?)'
tok.type = self.reserved.get(tok.value)
tok.value = tok.typ... | [
"def",
"t_EXP_ALL",
"(",
"self",
",",
"tok",
")",
":",
"# pylint: disable=locally-disabled,invalid-name",
"tok",
".",
"type",
"=",
"self",
".",
"reserved",
".",
"get",
"(",
"tok",
".",
"value",
")",
"tok",
".",
"value",
"=",
"tok",
".",
"type",
"return",
... | r'(-|\+|\*|/|%|like|LIKE|=~|in|IN|~~|is|IS|eq|EQ|==|ne|NE|!=|<>|ge|GE|>=|gt|GT|>|le|LE|<=|lt|LT|<|or|OR|\|\||xor|XOR|\^\^|and|AND|&&|not|NOT|!|exists|EXISTS|\?) | [
"r",
"(",
"-",
"|",
"\\",
"+",
"|",
"\\",
"*",
"|",
"/",
"|%|like|LIKE|",
"=",
"~|in|IN|~~|is|IS|eq|EQ|",
"==",
"|ne|NE|!",
"=",
"|<",
">",
"|ge|GE|",
">",
"=",
"|gt|GT|",
">",
"|le|LE|<",
"=",
"|lt|LT|<|or|OR|",
"\\",
"|",
"\\",
"||xor|XOR|",
"\\",
"^... | train | https://github.com/honzamach/pynspect/blob/0582dcc1f7aafe50e25a21c792ea1b3367ea5881/pynspect/lexer.py#L261-L265 |
honzamach/pynspect | pynspect/lexer.py | PynspectFilterLexer.t_FLOAT | def t_FLOAT(tok): # pylint: disable=locally-disabled,invalid-name
r'\d+\.\d+'
tok.value = (tok.type, float(tok.value))
return tok | python | def t_FLOAT(tok): # pylint: disable=locally-disabled,invalid-name
r'\d+\.\d+'
tok.value = (tok.type, float(tok.value))
return tok | [
"def",
"t_FLOAT",
"(",
"tok",
")",
":",
"# pylint: disable=locally-disabled,invalid-name",
"tok",
".",
"value",
"=",
"(",
"tok",
".",
"type",
",",
"float",
"(",
"tok",
".",
"value",
")",
")",
"return",
"tok"
] | r'\d+\.\d+ | [
"r",
"\\",
"d",
"+",
"\\",
".",
"\\",
"d",
"+"
] | train | https://github.com/honzamach/pynspect/blob/0582dcc1f7aafe50e25a21c792ea1b3367ea5881/pynspect/lexer.py#L292-L295 |
honzamach/pynspect | pynspect/lexer.py | PynspectFilterLexer.t_INTEGER | def t_INTEGER(tok): # pylint: disable=locally-disabled,invalid-name
r'\d+'
tok.value = (tok.type, int(tok.value))
return tok | python | def t_INTEGER(tok): # pylint: disable=locally-disabled,invalid-name
r'\d+'
tok.value = (tok.type, int(tok.value))
return tok | [
"def",
"t_INTEGER",
"(",
"tok",
")",
":",
"# pylint: disable=locally-disabled,invalid-name",
"tok",
".",
"value",
"=",
"(",
"tok",
".",
"type",
",",
"int",
"(",
"tok",
".",
"value",
")",
")",
"return",
"tok"
] | r'\d+ | [
"r",
"\\",
"d",
"+"
] | train | https://github.com/honzamach/pynspect/blob/0582dcc1f7aafe50e25a21c792ea1b3367ea5881/pynspect/lexer.py#L298-L301 |
honzamach/pynspect | pynspect/lexer.py | PynspectFilterLexer.t_CONSTANT | def t_CONSTANT(tok): # pylint: disable=locally-disabled,invalid-name
r'"([^"]+)"|\'([^\']+)\''
tok.value = (tok.type, re.sub('["\']', '', tok.value))
return tok | python | def t_CONSTANT(tok): # pylint: disable=locally-disabled,invalid-name
r'"([^"]+)"|\'([^\']+)\''
tok.value = (tok.type, re.sub('["\']', '', tok.value))
return tok | [
"def",
"t_CONSTANT",
"(",
"tok",
")",
":",
"# pylint: disable=locally-disabled,invalid-name",
"tok",
".",
"value",
"=",
"(",
"tok",
".",
"type",
",",
"re",
".",
"sub",
"(",
"'[\"\\']'",
",",
"''",
",",
"tok",
".",
"value",
")",
")",
"return",
"tok"
] | r'"([^"]+)"|\'([^\']+)\ | [
"r",
"(",
"[",
"^",
"]",
"+",
")",
"|",
"\\",
"(",
"[",
"^",
"\\",
"]",
"+",
")",
"\\"
] | train | https://github.com/honzamach/pynspect/blob/0582dcc1f7aafe50e25a21c792ea1b3367ea5881/pynspect/lexer.py#L316-L319 |
armenzg/buildapi_client | buildapi_client/buildapi_client.py | trigger_arbitrary_job | def trigger_arbitrary_job(repo_name, builder, revision, auth, files=None, dry_run=False,
extra_properties=None):
"""
Request buildapi to trigger a job for us.
We return the request or None if dry_run is True.
Raises BuildapiAuthError if credentials are invalid.
"""
as... | python | def trigger_arbitrary_job(repo_name, builder, revision, auth, files=None, dry_run=False,
extra_properties=None):
"""
Request buildapi to trigger a job for us.
We return the request or None if dry_run is True.
Raises BuildapiAuthError if credentials are invalid.
"""
as... | [
"def",
"trigger_arbitrary_job",
"(",
"repo_name",
",",
"builder",
",",
"revision",
",",
"auth",
",",
"files",
"=",
"None",
",",
"dry_run",
"=",
"False",
",",
"extra_properties",
"=",
"None",
")",
":",
"assert",
"len",
"(",
"revision",
")",
"==",
"40",
",... | Request buildapi to trigger a job for us.
We return the request or None if dry_run is True.
Raises BuildapiAuthError if credentials are invalid. | [
"Request",
"buildapi",
"to",
"trigger",
"a",
"job",
"for",
"us",
"."
] | train | https://github.com/armenzg/buildapi_client/blob/59af70ad54bf65e09e5eb02241c61b326153b761/buildapi_client/buildapi_client.py#L35-L75 |
armenzg/buildapi_client | buildapi_client/buildapi_client.py | make_retrigger_request | def make_retrigger_request(repo_name, request_id, auth, count=DEFAULT_COUNT_NUM,
priority=DEFAULT_PRIORITY, dry_run=True):
"""
Retrigger a request using buildapi self-serve. Returns a request.
Buildapi documentation:
POST /self-serve/{branch}/request
Rebuild `request_id`... | python | def make_retrigger_request(repo_name, request_id, auth, count=DEFAULT_COUNT_NUM,
priority=DEFAULT_PRIORITY, dry_run=True):
"""
Retrigger a request using buildapi self-serve. Returns a request.
Buildapi documentation:
POST /self-serve/{branch}/request
Rebuild `request_id`... | [
"def",
"make_retrigger_request",
"(",
"repo_name",
",",
"request_id",
",",
"auth",
",",
"count",
"=",
"DEFAULT_COUNT_NUM",
",",
"priority",
"=",
"DEFAULT_PRIORITY",
",",
"dry_run",
"=",
"True",
")",
":",
"url",
"=",
"'{}/{}/request'",
".",
"format",
"(",
"SELF... | Retrigger a request using buildapi self-serve. Returns a request.
Buildapi documentation:
POST /self-serve/{branch}/request
Rebuild `request_id`, which must be passed in as a POST parameter.
`priority` and `count` are also accepted as optional
parameters. `count` defaults to 1, and represents the ... | [
"Retrigger",
"a",
"request",
"using",
"buildapi",
"self",
"-",
"serve",
".",
"Returns",
"a",
"request",
"."
] | train | https://github.com/armenzg/buildapi_client/blob/59af70ad54bf65e09e5eb02241c61b326153b761/buildapi_client/buildapi_client.py#L78-L111 |
armenzg/buildapi_client | buildapi_client/buildapi_client.py | make_cancel_request | def make_cancel_request(repo_name, request_id, auth, dry_run=True):
"""
Cancel a request using buildapi self-serve. Returns a request.
Buildapi documentation:
DELETE /self-serve/{branch}/request/{request_id} Cancel the given request
"""
url = '{}/{}/request/{}'.format(SELF_SERVE, repo_name, req... | python | def make_cancel_request(repo_name, request_id, auth, dry_run=True):
"""
Cancel a request using buildapi self-serve. Returns a request.
Buildapi documentation:
DELETE /self-serve/{branch}/request/{request_id} Cancel the given request
"""
url = '{}/{}/request/{}'.format(SELF_SERVE, repo_name, req... | [
"def",
"make_cancel_request",
"(",
"repo_name",
",",
"request_id",
",",
"auth",
",",
"dry_run",
"=",
"True",
")",
":",
"url",
"=",
"'{}/{}/request/{}'",
".",
"format",
"(",
"SELF_SERVE",
",",
"repo_name",
",",
"request_id",
")",
"if",
"dry_run",
":",
"LOG",
... | Cancel a request using buildapi self-serve. Returns a request.
Buildapi documentation:
DELETE /self-serve/{branch}/request/{request_id} Cancel the given request | [
"Cancel",
"a",
"request",
"using",
"buildapi",
"self",
"-",
"serve",
".",
"Returns",
"a",
"request",
"."
] | train | https://github.com/armenzg/buildapi_client/blob/59af70ad54bf65e09e5eb02241c61b326153b761/buildapi_client/buildapi_client.py#L114-L131 |
armenzg/buildapi_client | buildapi_client/buildapi_client.py | query_jobs_schedule | def query_jobs_schedule(repo_name, revision, auth):
"""
Query Buildapi for jobs.
"""
url = "%s/%s/rev/%s?format=json" % (SELF_SERVE, repo_name, revision)
LOG.debug("About to fetch %s" % url)
req = requests.get(url, auth=auth, timeout=TCP_TIMEOUT)
# If the revision doesn't exist on buildapi,... | python | def query_jobs_schedule(repo_name, revision, auth):
"""
Query Buildapi for jobs.
"""
url = "%s/%s/rev/%s?format=json" % (SELF_SERVE, repo_name, revision)
LOG.debug("About to fetch %s" % url)
req = requests.get(url, auth=auth, timeout=TCP_TIMEOUT)
# If the revision doesn't exist on buildapi,... | [
"def",
"query_jobs_schedule",
"(",
"repo_name",
",",
"revision",
",",
"auth",
")",
":",
"url",
"=",
"\"%s/%s/rev/%s?format=json\"",
"%",
"(",
"SELF_SERVE",
",",
"repo_name",
",",
"revision",
")",
"LOG",
".",
"debug",
"(",
"\"About to fetch %s\"",
"%",
"url",
"... | Query Buildapi for jobs. | [
"Query",
"Buildapi",
"for",
"jobs",
"."
] | train | https://github.com/armenzg/buildapi_client/blob/59af70ad54bf65e09e5eb02241c61b326153b761/buildapi_client/buildapi_client.py#L220-L233 |
armenzg/buildapi_client | buildapi_client/buildapi_client.py | query_pending_jobs | def query_pending_jobs(auth, repo_name=None, return_raw=False):
"""Return pending jobs"""
url = '%s/pending?format=json' % HOST_ROOT
LOG.debug('About to fetch %s' % url)
req = requests.get(url, auth=auth, timeout=TCP_TIMEOUT)
# If the revision doesn't exist on buildapi, that means there are
# n... | python | def query_pending_jobs(auth, repo_name=None, return_raw=False):
"""Return pending jobs"""
url = '%s/pending?format=json' % HOST_ROOT
LOG.debug('About to fetch %s' % url)
req = requests.get(url, auth=auth, timeout=TCP_TIMEOUT)
# If the revision doesn't exist on buildapi, that means there are
# n... | [
"def",
"query_pending_jobs",
"(",
"auth",
",",
"repo_name",
"=",
"None",
",",
"return_raw",
"=",
"False",
")",
":",
"url",
"=",
"'%s/pending?format=json'",
"%",
"HOST_ROOT",
"LOG",
".",
"debug",
"(",
"'About to fetch %s'",
"%",
"url",
")",
"req",
"=",
"reque... | Return pending jobs | [
"Return",
"pending",
"jobs"
] | train | https://github.com/armenzg/buildapi_client/blob/59af70ad54bf65e09e5eb02241c61b326153b761/buildapi_client/buildapi_client.py#L241-L272 |
krukas/Trionyx | trionyx/layout.py | Component.set_object | def set_object(self, object):
"""
Set object for rendering component and set object to all components
:param object:
:return:
"""
if self.object is False:
self.object = object
# Pass object along to child components for rendering
for componen... | python | def set_object(self, object):
"""
Set object for rendering component and set object to all components
:param object:
:return:
"""
if self.object is False:
self.object = object
# Pass object along to child components for rendering
for componen... | [
"def",
"set_object",
"(",
"self",
",",
"object",
")",
":",
"if",
"self",
".",
"object",
"is",
"False",
":",
"self",
".",
"object",
"=",
"object",
"# Pass object along to child components for rendering",
"for",
"component",
"in",
"self",
".",
"components",
":",
... | Set object for rendering component and set object to all components
:param object:
:return: | [
"Set",
"object",
"for",
"rendering",
"component",
"and",
"set",
"object",
"to",
"all",
"components"
] | train | https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/layout.py#L118-L130 |
krukas/Trionyx | trionyx/layout.py | Component.render | def render(self, context, request=None):
"""Render component"""
context['component'] = self
return render_to_string(self.template_name, context, request) | python | def render(self, context, request=None):
"""Render component"""
context['component'] = self
return render_to_string(self.template_name, context, request) | [
"def",
"render",
"(",
"self",
",",
"context",
",",
"request",
"=",
"None",
")",
":",
"context",
"[",
"'component'",
"]",
"=",
"self",
"return",
"render_to_string",
"(",
"self",
".",
"template_name",
",",
"context",
",",
"request",
")"
] | Render component | [
"Render",
"component"
] | train | https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/layout.py#L132-L135 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.