partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | Cache._new_ass_hierarchy | Returns a completely new cache hierarchy for given assistant file.
Args:
file_ass: the assistant from filesystem hierarchy to create cache hierarchy for
(for format see what refresh_role accepts)
Returns:
the newly created cache hierarchy | devassistant/cache.py | def _new_ass_hierarchy(self, file_ass):
"""Returns a completely new cache hierarchy for given assistant file.
Args:
file_ass: the assistant from filesystem hierarchy to create cache hierarchy for
(for format see what refresh_role accepts)
Returns:
... | def _new_ass_hierarchy(self, file_ass):
"""Returns a completely new cache hierarchy for given assistant file.
Args:
file_ass: the assistant from filesystem hierarchy to create cache hierarchy for
(for format see what refresh_role accepts)
Returns:
... | [
"Returns",
"a",
"completely",
"new",
"cache",
"hierarchy",
"for",
"given",
"assistant",
"file",
"."
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/cache.py#L205-L224 | [
"def",
"_new_ass_hierarchy",
"(",
"self",
",",
"file_ass",
")",
":",
"ret_struct",
"=",
"{",
"'source'",
":",
"''",
",",
"'subhierarchy'",
":",
"{",
"}",
",",
"'attrs'",
":",
"{",
"}",
",",
"'snippets'",
":",
"{",
"}",
"}",
"ret_struct",
"[",
"'source'... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | Cache._get_snippet_ctime | Returns and remembers (during this DevAssistant invocation) last ctime of given
snippet.
Calling ctime costs lost of time and some snippets, like common_args, are used widely,
so we don't want to call ctime bazillion times on them during one invocation.
Args:
snip_name: nam... | devassistant/cache.py | def _get_snippet_ctime(self, snip_name):
"""Returns and remembers (during this DevAssistant invocation) last ctime of given
snippet.
Calling ctime costs lost of time and some snippets, like common_args, are used widely,
so we don't want to call ctime bazillion times on them during one i... | def _get_snippet_ctime(self, snip_name):
"""Returns and remembers (during this DevAssistant invocation) last ctime of given
snippet.
Calling ctime costs lost of time and some snippets, like common_args, are used widely,
so we don't want to call ctime bazillion times on them during one i... | [
"Returns",
"and",
"remembers",
"(",
"during",
"this",
"DevAssistant",
"invocation",
")",
"last",
"ctime",
"of",
"given",
"snippet",
"."
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/cache.py#L226-L241 | [
"def",
"_get_snippet_ctime",
"(",
"self",
",",
"snip_name",
")",
":",
"if",
"snip_name",
"not",
"in",
"self",
".",
"snip_ctimes",
":",
"snippet",
"=",
"yaml_snippet_loader",
".",
"YamlSnippetLoader",
".",
"get_snippet_by_name",
"(",
"snip_name",
")",
"self",
"."... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | expand_dependencies_section | Expands dependency section, e.g. substitues "use: foo" for its contents, but
doesn't evaluate conditions nor substitue variables. | devassistant/lang.py | def expand_dependencies_section(section, kwargs):
"""Expands dependency section, e.g. substitues "use: foo" for its contents, but
doesn't evaluate conditions nor substitue variables."""
deps = []
for dep in section:
for dep_type, dep_list in dep.items():
if dep_type in ['call', 'use... | def expand_dependencies_section(section, kwargs):
"""Expands dependency section, e.g. substitues "use: foo" for its contents, but
doesn't evaluate conditions nor substitue variables."""
deps = []
for dep in section:
for dep_type, dep_list in dep.items():
if dep_type in ['call', 'use... | [
"Expands",
"dependency",
"section",
"e",
".",
"g",
".",
"substitues",
"use",
":",
"foo",
"for",
"its",
"contents",
"but",
"doesn",
"t",
"evaluate",
"conditions",
"nor",
"substitue",
"variables",
"."
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/lang.py#L125-L139 | [
"def",
"expand_dependencies_section",
"(",
"section",
",",
"kwargs",
")",
":",
"deps",
"=",
"[",
"]",
"for",
"dep",
"in",
"section",
":",
"for",
"dep_type",
",",
"dep_list",
"in",
"dep",
".",
"items",
"(",
")",
":",
"if",
"dep_type",
"in",
"[",
"'call'... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | parse_for | Returns name of loop control variable(s), iteration type (in/word_in) and
expression to iterate on.
For example:
- given "for $i in $foo", returns (['i'], '$foo')
- given "for ${i} in $(ls $foo)", returns (['i'], '$(ls $foo)')
- given "for $k, $v in $foo", returns (['k', 'v'], '$foo') | devassistant/lang.py | def parse_for(control_line):
"""Returns name of loop control variable(s), iteration type (in/word_in) and
expression to iterate on.
For example:
- given "for $i in $foo", returns (['i'], '$foo')
- given "for ${i} in $(ls $foo)", returns (['i'], '$(ls $foo)')
- given "for $k, $v in $foo", return... | def parse_for(control_line):
"""Returns name of loop control variable(s), iteration type (in/word_in) and
expression to iterate on.
For example:
- given "for $i in $foo", returns (['i'], '$foo')
- given "for ${i} in $(ls $foo)", returns (['i'], '$(ls $foo)')
- given "for $k, $v in $foo", return... | [
"Returns",
"name",
"of",
"loop",
"control",
"variable",
"(",
"s",
")",
"iteration",
"type",
"(",
"in",
"/",
"word_in",
")",
"and",
"expression",
"to",
"iterate",
"on",
"."
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/lang.py#L260-L283 | [
"def",
"parse_for",
"(",
"control_line",
")",
":",
"error",
"=",
"'For loop call must be in form \\'for $var in expression\\', got: '",
"+",
"control_line",
"regex",
"=",
"re",
".",
"compile",
"(",
"r'for\\s+(\\${?\\S+}?)(?:\\s*,\\s+(\\${?\\S+}?))?\\s+(in|word_in)\\s+(\\S.+)'",
"... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | get_for_control_var_and_eval_expr | Returns tuple that consists of control variable name and iterable that is result
of evaluated expression of given for loop.
For example:
- given 'for $i in $(echo "foo bar")' it returns (['i'], ['foo', 'bar'])
- given 'for $i, $j in $foo' it returns (['i', 'j'], [('foo', 'bar')]) | devassistant/lang.py | def get_for_control_var_and_eval_expr(comm_type, kwargs):
"""Returns tuple that consists of control variable name and iterable that is result
of evaluated expression of given for loop.
For example:
- given 'for $i in $(echo "foo bar")' it returns (['i'], ['foo', 'bar'])
- given 'for $i, $j in $foo'... | def get_for_control_var_and_eval_expr(comm_type, kwargs):
"""Returns tuple that consists of control variable name and iterable that is result
of evaluated expression of given for loop.
For example:
- given 'for $i in $(echo "foo bar")' it returns (['i'], ['foo', 'bar'])
- given 'for $i, $j in $foo'... | [
"Returns",
"tuple",
"that",
"consists",
"of",
"control",
"variable",
"name",
"and",
"iterable",
"that",
"is",
"result",
"of",
"evaluated",
"expression",
"of",
"given",
"for",
"loop",
"."
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/lang.py#L286-L313 | [
"def",
"get_for_control_var_and_eval_expr",
"(",
"comm_type",
",",
"kwargs",
")",
":",
"# let possible exceptions bubble up",
"control_vars",
",",
"iter_type",
",",
"expression",
"=",
"parse_for",
"(",
"comm_type",
")",
"eval_expression",
"=",
"evaluate_expression",
"(",
... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | get_section_from_condition | Returns section that should be used from given if/else sections by evaluating given
condition.
Args:
if_section - section with if clause
else_section - section that *may* be else clause (just next section after if_section,
this method will check if it really is else); pos... | devassistant/lang.py | def get_section_from_condition(if_section, else_section, kwargs):
"""Returns section that should be used from given if/else sections by evaluating given
condition.
Args:
if_section - section with if clause
else_section - section that *may* be else clause (just next section after if_section,... | def get_section_from_condition(if_section, else_section, kwargs):
"""Returns section that should be used from given if/else sections by evaluating given
condition.
Args:
if_section - section with if clause
else_section - section that *may* be else clause (just next section after if_section,... | [
"Returns",
"section",
"that",
"should",
"be",
"used",
"from",
"given",
"if",
"/",
"else",
"sections",
"by",
"evaluating",
"given",
"condition",
"."
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/lang.py#L316-L338 | [
"def",
"get_section_from_condition",
"(",
"if_section",
",",
"else_section",
",",
"kwargs",
")",
":",
"# check if else section is really else",
"skip",
"=",
"True",
"if",
"else_section",
"is",
"not",
"None",
"and",
"else_section",
"[",
"0",
"]",
"==",
"'else'",
"e... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | get_catch_vars | Returns 2-tuple with names of catch control vars, e.g. for "catch $was_exc, $exc"
it returns ('was_exc', 'err').
Args:
catch: the whole catch line
Returns:
2-tuple with names of catch control variables
Raises:
exceptions.YamlSyntaxError if the catch line is malformed | devassistant/lang.py | def get_catch_vars(catch):
"""Returns 2-tuple with names of catch control vars, e.g. for "catch $was_exc, $exc"
it returns ('was_exc', 'err').
Args:
catch: the whole catch line
Returns:
2-tuple with names of catch control variables
Raises:
exceptions.YamlSyntaxError if the... | def get_catch_vars(catch):
"""Returns 2-tuple with names of catch control vars, e.g. for "catch $was_exc, $exc"
it returns ('was_exc', 'err').
Args:
catch: the whole catch line
Returns:
2-tuple with names of catch control variables
Raises:
exceptions.YamlSyntaxError if the... | [
"Returns",
"2",
"-",
"tuple",
"with",
"names",
"of",
"catch",
"control",
"vars",
"e",
".",
"g",
".",
"for",
"catch",
"$was_exc",
"$exc",
"it",
"returns",
"(",
"was_exc",
"err",
")",
"."
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/lang.py#L341-L359 | [
"def",
"get_catch_vars",
"(",
"catch",
")",
":",
"catch_re",
"=",
"re",
".",
"compile",
"(",
"r'catch\\s+(\\${?\\S+}?),\\s*(\\${?\\S+}?)'",
")",
"res",
"=",
"catch_re",
".",
"match",
"(",
"catch",
")",
"if",
"res",
"is",
"None",
":",
"err",
"=",
"'Catch must... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | assign_variable | Assigns given result (resp. logical result and result) to a variable
(resp. to two variables). log_res and res are already computed result
of an exec/input section. For example:
$foo~: $spam and $eggs
$log_res, $foo~: $spam and $eggs
$foo:
some: struct
$log_res, $foo:
some:
... | devassistant/lang.py | def assign_variable(variable, log_res, res, kwargs):
"""Assigns given result (resp. logical result and result) to a variable
(resp. to two variables). log_res and res are already computed result
of an exec/input section. For example:
$foo~: $spam and $eggs
$log_res, $foo~: $spam and $eggs
$foo... | def assign_variable(variable, log_res, res, kwargs):
"""Assigns given result (resp. logical result and result) to a variable
(resp. to two variables). log_res and res are already computed result
of an exec/input section. For example:
$foo~: $spam and $eggs
$log_res, $foo~: $spam and $eggs
$foo... | [
"Assigns",
"given",
"result",
"(",
"resp",
".",
"logical",
"result",
"and",
"result",
")",
"to",
"a",
"variable",
"(",
"resp",
".",
"to",
"two",
"variables",
")",
".",
"log_res",
"and",
"res",
"are",
"already",
"computed",
"result",
"of",
"an",
"exec",
... | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/lang.py#L362-L397 | [
"def",
"assign_variable",
"(",
"variable",
",",
"log_res",
",",
"res",
",",
"kwargs",
")",
":",
"if",
"variable",
".",
"endswith",
"(",
"'~'",
")",
":",
"variable",
"=",
"variable",
"[",
":",
"-",
"1",
"]",
"comma_count",
"=",
"variable",
".",
"count",... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | Interpreter.symbol | Adds symbol 'id' to symbol_table if it does not exist already,
if it does it merely updates its binding power and returns it's
symbol class | devassistant/lang.py | def symbol(self, id, bp=0):
"""
Adds symbol 'id' to symbol_table if it does not exist already,
if it does it merely updates its binding power and returns it's
symbol class
"""
try:
s = self.symbol_table[id]
except KeyError:
class s(self.sy... | def symbol(self, id, bp=0):
"""
Adds symbol 'id' to symbol_table if it does not exist already,
if it does it merely updates its binding power and returns it's
symbol class
"""
try:
s = self.symbol_table[id]
except KeyError:
class s(self.sy... | [
"Adds",
"symbol",
"id",
"to",
"symbol_table",
"if",
"it",
"does",
"not",
"exist",
"already",
"if",
"it",
"does",
"it",
"merely",
"updates",
"its",
"binding",
"power",
"and",
"returns",
"it",
"s",
"symbol",
"class"
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/lang.py#L451-L468 | [
"def",
"symbol",
"(",
"self",
",",
"id",
",",
"bp",
"=",
"0",
")",
":",
"try",
":",
"s",
"=",
"self",
".",
"symbol_table",
"[",
"id",
"]",
"except",
"KeyError",
":",
"class",
"s",
"(",
"self",
".",
"symbol_base",
")",
":",
"pass",
"s",
".",
"id... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | Interpreter.advance | Advance to next token, optionally check that current token is 'id' | devassistant/lang.py | def advance(self, id=None):
"""
Advance to next token, optionally check that current token is 'id'
"""
if id and self.token.id != id:
raise SyntaxError("Expected {0}".format(id))
self.token = self.next() | def advance(self, id=None):
"""
Advance to next token, optionally check that current token is 'id'
"""
if id and self.token.id != id:
raise SyntaxError("Expected {0}".format(id))
self.token = self.next() | [
"Advance",
"to",
"next",
"token",
"optionally",
"check",
"that",
"current",
"token",
"is",
"id"
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/lang.py#L470-L477 | [
"def",
"advance",
"(",
"self",
",",
"id",
"=",
"None",
")",
":",
"if",
"id",
"and",
"self",
".",
"token",
".",
"id",
"!=",
"id",
":",
"raise",
"SyntaxError",
"(",
"\"Expected {0}\"",
".",
"format",
"(",
"id",
")",
")",
"self",
".",
"token",
"=",
... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | Interpreter.method | A decorator - adds the decorated method to symbol 'symbol_name' | devassistant/lang.py | def method(self, symbol_name):
"""
A decorator - adds the decorated method to symbol 'symbol_name'
"""
s = self.symbol(symbol_name)
def bind(fn):
setattr(s, fn.__name__, fn)
return bind | def method(self, symbol_name):
"""
A decorator - adds the decorated method to symbol 'symbol_name'
"""
s = self.symbol(symbol_name)
def bind(fn):
setattr(s, fn.__name__, fn)
return bind | [
"A",
"decorator",
"-",
"adds",
"the",
"decorated",
"method",
"to",
"symbol",
"symbol_name"
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/lang.py#L479-L488 | [
"def",
"method",
"(",
"self",
",",
"symbol_name",
")",
":",
"s",
"=",
"self",
".",
"symbol",
"(",
"symbol_name",
")",
"def",
"bind",
"(",
"fn",
")",
":",
"setattr",
"(",
"s",
",",
"fn",
".",
"__name__",
",",
"fn",
")",
"return",
"bind"
] | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | Interpreter.parse | Evaluates 'expression' and returns it's value(s) | devassistant/lang.py | def parse(self, expression):
"""
Evaluates 'expression' and returns it's value(s)
"""
if isinstance(expression, (list, dict)):
return (True if expression else False, expression)
if sys.version_info[0] > 2:
self.next = self.tokenize(expression).__next__
... | def parse(self, expression):
"""
Evaluates 'expression' and returns it's value(s)
"""
if isinstance(expression, (list, dict)):
return (True if expression else False, expression)
if sys.version_info[0] > 2:
self.next = self.tokenize(expression).__next__
... | [
"Evaluates",
"expression",
"and",
"returns",
"it",
"s",
"value",
"(",
"s",
")"
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/lang.py#L534-L545 | [
"def",
"parse",
"(",
"self",
",",
"expression",
")",
":",
"if",
"isinstance",
"(",
"expression",
",",
"(",
"list",
",",
"dict",
")",
")",
":",
"return",
"(",
"True",
"if",
"expression",
"else",
"False",
",",
"expression",
")",
"if",
"sys",
".",
"vers... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | get_platforms_set | Returns set of all possible platforms | devassistant/dapi/platforms.py | def get_platforms_set():
'''Returns set of all possible platforms'''
# arch and mageia are not in Py2 _supported_dists, so we add them manually
# Ubuntu adds itself to the list on Ubuntu
platforms = set([x.lower() for x in platform._supported_dists])
platforms |= set(['darwin', 'arch', 'mageia', 'ub... | def get_platforms_set():
'''Returns set of all possible platforms'''
# arch and mageia are not in Py2 _supported_dists, so we add them manually
# Ubuntu adds itself to the list on Ubuntu
platforms = set([x.lower() for x in platform._supported_dists])
platforms |= set(['darwin', 'arch', 'mageia', 'ub... | [
"Returns",
"set",
"of",
"all",
"possible",
"platforms"
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/platforms.py#L4-L10 | [
"def",
"get_platforms_set",
"(",
")",
":",
"# arch and mageia are not in Py2 _supported_dists, so we add them manually",
"# Ubuntu adds itself to the list on Ubuntu",
"platforms",
"=",
"set",
"(",
"[",
"x",
".",
"lower",
"(",
")",
"for",
"x",
"in",
"platform",
".",
"_supp... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | find_file_in_load_dirs | If given relative path exists in one of DevAssistant load paths,
return its full path.
Args:
relpath: a relative path, e.g. "assitants/crt/test.yaml"
Returns:
absolute path of the file, e.g. "/home/x/.devassistant/assistanta/crt/test.yaml
or None if file is not found | devassistant/utils.py | def find_file_in_load_dirs(relpath):
"""If given relative path exists in one of DevAssistant load paths,
return its full path.
Args:
relpath: a relative path, e.g. "assitants/crt/test.yaml"
Returns:
absolute path of the file, e.g. "/home/x/.devassistant/assistanta/crt/test.yaml
... | def find_file_in_load_dirs(relpath):
"""If given relative path exists in one of DevAssistant load paths,
return its full path.
Args:
relpath: a relative path, e.g. "assitants/crt/test.yaml"
Returns:
absolute path of the file, e.g. "/home/x/.devassistant/assistanta/crt/test.yaml
... | [
"If",
"given",
"relative",
"path",
"exists",
"in",
"one",
"of",
"DevAssistant",
"load",
"paths",
"return",
"its",
"full",
"path",
"."
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/utils.py#L109-L126 | [
"def",
"find_file_in_load_dirs",
"(",
"relpath",
")",
":",
"if",
"relpath",
".",
"startswith",
"(",
"os",
".",
"path",
".",
"sep",
")",
":",
"relpath",
"=",
"relpath",
".",
"lstrip",
"(",
"os",
".",
"path",
".",
"sep",
")",
"for",
"ld",
"in",
"settin... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | run_exitfuncs | Function that behaves exactly like Python's atexit, but runs atexit functions
in the order in which they were registered, not reversed. | devassistant/utils.py | def run_exitfuncs():
"""Function that behaves exactly like Python's atexit, but runs atexit functions
in the order in which they were registered, not reversed.
"""
exc_info = None
for func, targs, kargs in _exithandlers:
try:
func(*targs, **kargs)
except SystemExit:
... | def run_exitfuncs():
"""Function that behaves exactly like Python's atexit, but runs atexit functions
in the order in which they were registered, not reversed.
"""
exc_info = None
for func, targs, kargs in _exithandlers:
try:
func(*targs, **kargs)
except SystemExit:
... | [
"Function",
"that",
"behaves",
"exactly",
"like",
"Python",
"s",
"atexit",
"but",
"runs",
"atexit",
"functions",
"in",
"the",
"order",
"in",
"which",
"they",
"were",
"registered",
"not",
"reversed",
"."
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/utils.py#L149-L163 | [
"def",
"run_exitfuncs",
"(",
")",
":",
"exc_info",
"=",
"None",
"for",
"func",
",",
"targs",
",",
"kargs",
"in",
"_exithandlers",
":",
"try",
":",
"func",
"(",
"*",
"targs",
",",
"*",
"*",
"kargs",
")",
"except",
"SystemExit",
":",
"exc_info",
"=",
"... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | strip_prefix | Strip the prefix from the string
If 'regex' is specified, prefix is understood as a regular expression. | devassistant/utils.py | def strip_prefix(string, prefix, regex=False):
"""Strip the prefix from the string
If 'regex' is specified, prefix is understood as a regular expression."""
if not isinstance(string, six.string_types) or not isinstance(prefix, six.string_types):
msg = 'Arguments to strip_prefix must be string types... | def strip_prefix(string, prefix, regex=False):
"""Strip the prefix from the string
If 'regex' is specified, prefix is understood as a regular expression."""
if not isinstance(string, six.string_types) or not isinstance(prefix, six.string_types):
msg = 'Arguments to strip_prefix must be string types... | [
"Strip",
"the",
"prefix",
"from",
"the",
"string"
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/utils.py#L190-L203 | [
"def",
"strip_prefix",
"(",
"string",
",",
"prefix",
",",
"regex",
"=",
"False",
")",
":",
"if",
"not",
"isinstance",
"(",
"string",
",",
"six",
".",
"string_types",
")",
"or",
"not",
"isinstance",
"(",
"prefix",
",",
"six",
".",
"string_types",
")",
"... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | strip_suffix | Strip the suffix from the string.
If 'regex' is specified, suffix is understood as a regular expression. | devassistant/utils.py | def strip_suffix(string, suffix, regex=False):
"""Strip the suffix from the string.
If 'regex' is specified, suffix is understood as a regular expression."""
if not isinstance(string, six.string_types) or not isinstance(suffix, six.string_types):
msg = 'Arguments to strip_suffix must be string type... | def strip_suffix(string, suffix, regex=False):
"""Strip the suffix from the string.
If 'regex' is specified, suffix is understood as a regular expression."""
if not isinstance(string, six.string_types) or not isinstance(suffix, six.string_types):
msg = 'Arguments to strip_suffix must be string type... | [
"Strip",
"the",
"suffix",
"from",
"the",
"string",
"."
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/utils.py#L206-L219 | [
"def",
"strip_suffix",
"(",
"string",
",",
"suffix",
",",
"regex",
"=",
"False",
")",
":",
"if",
"not",
"isinstance",
"(",
"string",
",",
"six",
".",
"string_types",
")",
"or",
"not",
"isinstance",
"(",
"suffix",
",",
"six",
".",
"string_types",
")",
"... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | _strip | Return complement of pattern in string | devassistant/utils.py | def _strip(string, pattern):
"""Return complement of pattern in string"""
m = re.compile(pattern).search(string)
if m:
return string[0:m.start()] + string[m.end():len(string)]
else:
return string | def _strip(string, pattern):
"""Return complement of pattern in string"""
m = re.compile(pattern).search(string)
if m:
return string[0:m.start()] + string[m.end():len(string)]
else:
return string | [
"Return",
"complement",
"of",
"pattern",
"in",
"string"
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/utils.py#L222-L229 | [
"def",
"_strip",
"(",
"string",
",",
"pattern",
")",
":",
"m",
"=",
"re",
".",
"compile",
"(",
"pattern",
")",
".",
"search",
"(",
"string",
")",
"if",
"m",
":",
"return",
"string",
"[",
"0",
":",
"m",
".",
"start",
"(",
")",
"]",
"+",
"string"... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | CliRunner.register_console_logging_handler | Registers console logging handler to given logger. | devassistant/cli/cli_runner.py | def register_console_logging_handler(cls, lgr, level=logging.INFO):
"""Registers console logging handler to given logger."""
console_handler = logger.DevassistantClHandler(sys.stdout)
if console_handler.stream.isatty():
console_handler.setFormatter(logger.DevassistantClColorFormatter... | def register_console_logging_handler(cls, lgr, level=logging.INFO):
"""Registers console logging handler to given logger."""
console_handler = logger.DevassistantClHandler(sys.stdout)
if console_handler.stream.isatty():
console_handler.setFormatter(logger.DevassistantClColorFormatter... | [
"Registers",
"console",
"logging",
"handler",
"to",
"given",
"logger",
"."
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/cli/cli_runner.py#L21-L30 | [
"def",
"register_console_logging_handler",
"(",
"cls",
",",
"lgr",
",",
"level",
"=",
"logging",
".",
"INFO",
")",
":",
"console_handler",
"=",
"logger",
".",
"DevassistantClHandler",
"(",
"sys",
".",
"stdout",
")",
"if",
"console_handler",
".",
"stream",
".",... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | CliRunner.run | Runs the whole cli:
1. Registers console logging handler
2. Creates argparser from all assistants and actions
3. Parses args and decides what to run
4. Runs a proper assistant or action | devassistant/cli/cli_runner.py | def run(cls):
"""Runs the whole cli:
1. Registers console logging handler
2. Creates argparser from all assistants and actions
3. Parses args and decides what to run
4. Runs a proper assistant or action
"""
sigint_handler.override()
# set settings.USE_CAC... | def run(cls):
"""Runs the whole cli:
1. Registers console logging handler
2. Creates argparser from all assistants and actions
3. Parses args and decides what to run
4. Runs a proper assistant or action
"""
sigint_handler.override()
# set settings.USE_CAC... | [
"Runs",
"the",
"whole",
"cli",
":"
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/cli/cli_runner.py#L37-L81 | [
"def",
"run",
"(",
"cls",
")",
":",
"sigint_handler",
".",
"override",
"(",
")",
"# set settings.USE_CACHE before constructing parser, since constructing",
"# parser requires loaded assistants",
"settings",
".",
"USE_CACHE",
"=",
"False",
"if",
"'--no-cache'",
"in",
"sys",
... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | CliRunner.inform_of_short_bin_name | Historically, we had "devassistant" binary, but we chose to go with
shorter "da". We still allow "devassistant", but we recommend using "da". | devassistant/cli/cli_runner.py | def inform_of_short_bin_name(cls, binary):
"""Historically, we had "devassistant" binary, but we chose to go with
shorter "da". We still allow "devassistant", but we recommend using "da".
"""
binary = os.path.splitext(os.path.basename(binary))[0]
if binary != 'da':
ms... | def inform_of_short_bin_name(cls, binary):
"""Historically, we had "devassistant" binary, but we chose to go with
shorter "da". We still allow "devassistant", but we recommend using "da".
"""
binary = os.path.splitext(os.path.basename(binary))[0]
if binary != 'da':
ms... | [
"Historically",
"we",
"had",
"devassistant",
"binary",
"but",
"we",
"chose",
"to",
"go",
"with",
"shorter",
"da",
".",
"We",
"still",
"allow",
"devassistant",
"but",
"we",
"recommend",
"using",
"da",
"."
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/cli/cli_runner.py#L84-L93 | [
"def",
"inform_of_short_bin_name",
"(",
"cls",
",",
"binary",
")",
":",
"binary",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"os",
".",
"path",
".",
"basename",
"(",
"binary",
")",
")",
"[",
"0",
"]",
"if",
"binary",
"!=",
"'da'",
":",
"msg",
"=... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | PathWindow.get_full_dir_name | Function returns a full dir name | devassistant/gui/path_window.py | def get_full_dir_name(self):
"""
Function returns a full dir name
"""
return os.path.join(self.dir_name.get_text(), self.entry_project_name.get_text()) | def get_full_dir_name(self):
"""
Function returns a full dir name
"""
return os.path.join(self.dir_name.get_text(), self.entry_project_name.get_text()) | [
"Function",
"returns",
"a",
"full",
"dir",
"name"
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/path_window.py#L65-L69 | [
"def",
"get_full_dir_name",
"(",
"self",
")",
":",
"return",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"dir_name",
".",
"get_text",
"(",
")",
",",
"self",
".",
"entry_project_name",
".",
"get_text",
"(",
")",
")"
] | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | PathWindow.next_window | Function opens the run Window who executes the
assistant project creation | devassistant/gui/path_window.py | def next_window(self, widget, data=None):
"""
Function opens the run Window who executes the
assistant project creation
"""
# check whether deps-only is selected
deps_only = ('deps_only' in self.args and self.args['deps_only']['checkbox'].get_active())
# preserve... | def next_window(self, widget, data=None):
"""
Function opens the run Window who executes the
assistant project creation
"""
# check whether deps-only is selected
deps_only = ('deps_only' in self.args and self.args['deps_only']['checkbox'].get_active())
# preserve... | [
"Function",
"opens",
"the",
"run",
"Window",
"who",
"executes",
"the",
"assistant",
"project",
"creation"
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/path_window.py#L71-L130 | [
"def",
"next_window",
"(",
"self",
",",
"widget",
",",
"data",
"=",
"None",
")",
":",
"# check whether deps-only is selected",
"deps_only",
"=",
"(",
"'deps_only'",
"in",
"self",
".",
"args",
"and",
"self",
".",
"args",
"[",
"'deps_only'",
"]",
"[",
"'checkb... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | PathWindow._build_flags | Function builds kwargs variable for run_window | devassistant/gui/path_window.py | def _build_flags(self):
"""
Function builds kwargs variable for run_window
"""
# Check if all entries for selected arguments are nonempty
for arg_dict in [x for x in self.args.values() if self.arg_is_selected(x)]:
if 'entry' in arg_dict and not arg_dict['entry'].get_t... | def _build_flags(self):
"""
Function builds kwargs variable for run_window
"""
# Check if all entries for selected arguments are nonempty
for arg_dict in [x for x in self.args.values() if self.arg_is_selected(x)]:
if 'entry' in arg_dict and not arg_dict['entry'].get_t... | [
"Function",
"builds",
"kwargs",
"variable",
"for",
"run_window"
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/path_window.py#L132-L161 | [
"def",
"_build_flags",
"(",
"self",
")",
":",
"# Check if all entries for selected arguments are nonempty",
"for",
"arg_dict",
"in",
"[",
"x",
"for",
"x",
"in",
"self",
".",
"args",
".",
"values",
"(",
")",
"if",
"self",
".",
"arg_is_selected",
"(",
"x",
")",
... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | PathWindow.open_window | Function opens the Options dialog | devassistant/gui/path_window.py | def open_window(self, data=None):
"""
Function opens the Options dialog
"""
self.args = dict()
if data is not None:
self.top_assistant = data.get('top_assistant', None)
self.current_main_assistant = data.get('current_main_assistant', None)
self... | def open_window(self, data=None):
"""
Function opens the Options dialog
"""
self.args = dict()
if data is not None:
self.top_assistant = data.get('top_assistant', None)
self.current_main_assistant = data.get('current_main_assistant', None)
self... | [
"Function",
"opens",
"the",
"Options",
"dialog"
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/path_window.py#L177-L236 | [
"def",
"open_window",
"(",
"self",
",",
"data",
"=",
"None",
")",
":",
"self",
".",
"args",
"=",
"dict",
"(",
")",
"if",
"data",
"is",
"not",
"None",
":",
"self",
".",
"top_assistant",
"=",
"data",
".",
"get",
"(",
"'top_assistant'",
",",
"None",
"... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | PathWindow._check_box_toggled | Function manipulates with entries and buttons. | devassistant/gui/path_window.py | def _check_box_toggled(self, widget, data=None):
"""
Function manipulates with entries and buttons.
"""
active = widget.get_active()
arg_name = data
if 'entry' in self.args[arg_name]:
self.args[arg_name]['entry'].set_sensitive(active)
if 'browse_btn' ... | def _check_box_toggled(self, widget, data=None):
"""
Function manipulates with entries and buttons.
"""
active = widget.get_active()
arg_name = data
if 'entry' in self.args[arg_name]:
self.args[arg_name]['entry'].set_sensitive(active)
if 'browse_btn' ... | [
"Function",
"manipulates",
"with",
"entries",
"and",
"buttons",
"."
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/path_window.py#L238-L250 | [
"def",
"_check_box_toggled",
"(",
"self",
",",
"widget",
",",
"data",
"=",
"None",
")",
":",
"active",
"=",
"widget",
".",
"get_active",
"(",
")",
"arg_name",
"=",
"data",
"if",
"'entry'",
"in",
"self",
".",
"args",
"[",
"arg_name",
"]",
":",
"self",
... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | PathWindow._deps_only_toggled | Function deactivate options in case of deps_only and opposite | devassistant/gui/path_window.py | def _deps_only_toggled(self, widget, data=None):
"""
Function deactivate options in case of deps_only and opposite
"""
active = widget.get_active()
self.dir_name.set_sensitive(not active)
self.entry_project_name.set_sensitive(not active)
self.dir_name_browse_btn.s... | def _deps_only_toggled(self, widget, data=None):
"""
Function deactivate options in case of deps_only and opposite
"""
active = widget.get_active()
self.dir_name.set_sensitive(not active)
self.entry_project_name.set_sensitive(not active)
self.dir_name_browse_btn.s... | [
"Function",
"deactivate",
"options",
"in",
"case",
"of",
"deps_only",
"and",
"opposite"
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/path_window.py#L252-L260 | [
"def",
"_deps_only_toggled",
"(",
"self",
",",
"widget",
",",
"data",
"=",
"None",
")",
":",
"active",
"=",
"widget",
".",
"get_active",
"(",
")",
"self",
".",
"dir_name",
".",
"set_sensitive",
"(",
"not",
"active",
")",
"self",
".",
"entry_project_name",
... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | PathWindow.prev_window | Function returns to Main Window | devassistant/gui/path_window.py | def prev_window(self, widget, data=None):
"""
Function returns to Main Window
"""
self.path_window.hide()
self.parent.open_window(widget, self.data) | def prev_window(self, widget, data=None):
"""
Function returns to Main Window
"""
self.path_window.hide()
self.parent.open_window(widget, self.data) | [
"Function",
"returns",
"to",
"Main",
"Window"
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/path_window.py#L262-L267 | [
"def",
"prev_window",
"(",
"self",
",",
"widget",
",",
"data",
"=",
"None",
")",
":",
"self",
".",
"path_window",
".",
"hide",
"(",
")",
"self",
".",
"parent",
".",
"open_window",
"(",
"widget",
",",
"self",
".",
"data",
")"
] | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | PathWindow.browse_path | Function opens the file chooser dialog for settings project dir | devassistant/gui/path_window.py | def browse_path(self, window):
"""
Function opens the file chooser dialog for settings project dir
"""
text = self.gui_helper.create_file_chooser_dialog("Choose project directory", self.path_window, name="Select")
if text is not None:
self.dir_name.set_text(text) | def browse_path(self, window):
"""
Function opens the file chooser dialog for settings project dir
"""
text = self.gui_helper.create_file_chooser_dialog("Choose project directory", self.path_window, name="Select")
if text is not None:
self.dir_name.set_text(text) | [
"Function",
"opens",
"the",
"file",
"chooser",
"dialog",
"for",
"settings",
"project",
"dir"
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/path_window.py#L275-L281 | [
"def",
"browse_path",
"(",
"self",
",",
"window",
")",
":",
"text",
"=",
"self",
".",
"gui_helper",
".",
"create_file_chooser_dialog",
"(",
"\"Choose project directory\"",
",",
"self",
".",
"path_window",
",",
"name",
"=",
"\"Select\"",
")",
"if",
"text",
"is"... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | PathWindow._add_table_row | Function adds options to a grid | devassistant/gui/path_window.py | def _add_table_row(self, arg, number, row):
"""
Function adds options to a grid
"""
self.args[arg.name] = dict()
self.args[arg.name]['arg'] = arg
check_box_title = arg.flags[number][2:].title()
self.args[arg.name]['label'] = check_box_title
align = self.gu... | def _add_table_row(self, arg, number, row):
"""
Function adds options to a grid
"""
self.args[arg.name] = dict()
self.args[arg.name]['arg'] = arg
check_box_title = arg.flags[number][2:].title()
self.args[arg.name]['label'] = check_box_title
align = self.gu... | [
"Function",
"adds",
"options",
"to",
"a",
"grid"
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/path_window.py#L283-L356 | [
"def",
"_add_table_row",
"(",
"self",
",",
"arg",
",",
"number",
",",
"row",
")",
":",
"self",
".",
"args",
"[",
"arg",
".",
"name",
"]",
"=",
"dict",
"(",
")",
"self",
".",
"args",
"[",
"arg",
".",
"name",
"]",
"[",
"'arg'",
"]",
"=",
"arg",
... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | PathWindow.browse_clicked | Function sets the directory to entry | devassistant/gui/path_window.py | def browse_clicked(self, widget, data=None):
"""
Function sets the directory to entry
"""
text = self.gui_helper.create_file_chooser_dialog("Please select directory", self.path_window)
if text is not None:
data.set_text(text) | def browse_clicked(self, widget, data=None):
"""
Function sets the directory to entry
"""
text = self.gui_helper.create_file_chooser_dialog("Please select directory", self.path_window)
if text is not None:
data.set_text(text) | [
"Function",
"sets",
"the",
"directory",
"to",
"entry"
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/path_window.py#L358-L364 | [
"def",
"browse_clicked",
"(",
"self",
",",
"widget",
",",
"data",
"=",
"None",
")",
":",
"text",
"=",
"self",
".",
"gui_helper",
".",
"create_file_chooser_dialog",
"(",
"\"Please select directory\"",
",",
"self",
".",
"path_window",
")",
"if",
"text",
"is",
... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | PathWindow.project_name_changed | Function controls whether run button is enabled | devassistant/gui/path_window.py | def project_name_changed(self, widget, data=None):
"""
Function controls whether run button is enabled
"""
if widget.get_text() != "":
self.run_btn.set_sensitive(True)
else:
self.run_btn.set_sensitive(False)
self.update_full_label() | def project_name_changed(self, widget, data=None):
"""
Function controls whether run button is enabled
"""
if widget.get_text() != "":
self.run_btn.set_sensitive(True)
else:
self.run_btn.set_sensitive(False)
self.update_full_label() | [
"Function",
"controls",
"whether",
"run",
"button",
"is",
"enabled"
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/path_window.py#L373-L381 | [
"def",
"project_name_changed",
"(",
"self",
",",
"widget",
",",
"data",
"=",
"None",
")",
":",
"if",
"widget",
".",
"get_text",
"(",
")",
"!=",
"\"\"",
":",
"self",
".",
"run_btn",
".",
"set_sensitive",
"(",
"True",
")",
"else",
":",
"self",
".",
"ru... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | PathWindow.dir_name_changed | Function is used for controlling
label Full Directory project name
and storing current project directory
in configuration manager | devassistant/gui/path_window.py | def dir_name_changed(self, widget, data=None):
"""
Function is used for controlling
label Full Directory project name
and storing current project directory
in configuration manager
"""
config_manager.set_config_value("da.project_dir", self.dir_name.get_text())
... | def dir_name_changed(self, widget, data=None):
"""
Function is used for controlling
label Full Directory project name
and storing current project directory
in configuration manager
"""
config_manager.set_config_value("da.project_dir", self.dir_name.get_text())
... | [
"Function",
"is",
"used",
"for",
"controlling",
"label",
"Full",
"Directory",
"project",
"name",
"and",
"storing",
"current",
"project",
"directory",
"in",
"configuration",
"manager"
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/path_window.py#L383-L391 | [
"def",
"dir_name_changed",
"(",
"self",
",",
"widget",
",",
"data",
"=",
"None",
")",
":",
"config_manager",
".",
"set_config_value",
"(",
"\"da.project_dir\"",
",",
"self",
".",
"dir_name",
".",
"get_text",
"(",
")",
")",
"self",
".",
"update_full_label",
"... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | YamlChecker.check | Checks whether loaded yaml is well-formed according to syntax defined for
version 0.9.0 and later.
Raises:
YamlError: (containing a meaningful message) when the loaded Yaml
is not well formed | devassistant/yaml_checker.py | def check(self):
"""Checks whether loaded yaml is well-formed according to syntax defined for
version 0.9.0 and later.
Raises:
YamlError: (containing a meaningful message) when the loaded Yaml
is not well formed
"""
if not isinstance(self.parsed_yaml,... | def check(self):
"""Checks whether loaded yaml is well-formed according to syntax defined for
version 0.9.0 and later.
Raises:
YamlError: (containing a meaningful message) when the loaded Yaml
is not well formed
"""
if not isinstance(self.parsed_yaml,... | [
"Checks",
"whether",
"loaded",
"yaml",
"is",
"well",
"-",
"formed",
"according",
"to",
"syntax",
"defined",
"for",
"version",
"0",
".",
"9",
".",
"0",
"and",
"later",
"."
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/yaml_checker.py#L34-L54 | [
"def",
"check",
"(",
"self",
")",
":",
"if",
"not",
"isinstance",
"(",
"self",
".",
"parsed_yaml",
",",
"dict",
")",
":",
"msg",
"=",
"'In {0}:\\n'",
".",
"format",
"(",
"self",
".",
"sourcefile",
")",
"msg",
"+=",
"'Assistants and snippets must be Yaml mapp... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | YamlChecker._check_args | Validate the argument section.
Args may be either a dict or a list (to allow multiple positional args). | devassistant/yaml_checker.py | def _check_args(self, source):
'''Validate the argument section.
Args may be either a dict or a list (to allow multiple positional args).
'''
path = [source]
args = self.parsed_yaml.get('args', {})
self._assert_struct_type(args, 'args', (dict, list), path)
path.a... | def _check_args(self, source):
'''Validate the argument section.
Args may be either a dict or a list (to allow multiple positional args).
'''
path = [source]
args = self.parsed_yaml.get('args', {})
self._assert_struct_type(args, 'args', (dict, list), path)
path.a... | [
"Validate",
"the",
"argument",
"section",
"."
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/yaml_checker.py#L80-L96 | [
"def",
"_check_args",
"(",
"self",
",",
"source",
")",
":",
"path",
"=",
"[",
"source",
"]",
"args",
"=",
"self",
".",
"parsed_yaml",
".",
"get",
"(",
"'args'",
",",
"{",
"}",
")",
"self",
".",
"_assert_struct_type",
"(",
"args",
",",
"'args'",
",",
... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | YamlChecker._assert_command_dict | Checks whether struct is a command dict (e.g. it's a dict and has 1 key-value pair. | devassistant/yaml_checker.py | def _assert_command_dict(self, struct, name, path=None, extra_info=None):
"""Checks whether struct is a command dict (e.g. it's a dict and has 1 key-value pair."""
self._assert_dict(struct, name, path, extra_info)
if len(struct) != 1:
err = [self._format_error_path(path + [name])]
... | def _assert_command_dict(self, struct, name, path=None, extra_info=None):
"""Checks whether struct is a command dict (e.g. it's a dict and has 1 key-value pair."""
self._assert_dict(struct, name, path, extra_info)
if len(struct) != 1:
err = [self._format_error_path(path + [name])]
... | [
"Checks",
"whether",
"struct",
"is",
"a",
"command",
"dict",
"(",
"e",
".",
"g",
".",
"it",
"s",
"a",
"dict",
"and",
"has",
"1",
"key",
"-",
"value",
"pair",
"."
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/yaml_checker.py#L221-L230 | [
"def",
"_assert_command_dict",
"(",
"self",
",",
"struct",
",",
"name",
",",
"path",
"=",
"None",
",",
"extra_info",
"=",
"None",
")",
":",
"self",
".",
"_assert_dict",
"(",
"struct",
",",
"name",
",",
"path",
",",
"extra_info",
")",
"if",
"len",
"(",
... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | YamlChecker._assert_struct_type | Asserts that given structure is of any of given types.
Args:
struct: structure to check
name: displayable name of the checked structure (e.g. "run_foo" for section run_foo)
types: list/tuple of types that are allowed for given struct
path: list with a source file... | devassistant/yaml_checker.py | def _assert_struct_type(self, struct, name, types, path=None, extra_info=None):
"""Asserts that given structure is of any of given types.
Args:
struct: structure to check
name: displayable name of the checked structure (e.g. "run_foo" for section run_foo)
types: list... | def _assert_struct_type(self, struct, name, types, path=None, extra_info=None):
"""Asserts that given structure is of any of given types.
Args:
struct: structure to check
name: displayable name of the checked structure (e.g. "run_foo" for section run_foo)
types: list... | [
"Asserts",
"that",
"given",
"structure",
"is",
"of",
"any",
"of",
"given",
"types",
"."
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/yaml_checker.py#L242-L273 | [
"def",
"_assert_struct_type",
"(",
"self",
",",
"struct",
",",
"name",
",",
"types",
",",
"path",
"=",
"None",
",",
"extra_info",
"=",
"None",
")",
":",
"wanted_yaml_typenames",
"=",
"set",
"(",
")",
"for",
"t",
"in",
"types",
":",
"wanted_yaml_typenames",... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | _split_license | Returns all individual licenses in the input | devassistant/dapi/licenses.py | def _split_license(license):
'''Returns all individual licenses in the input'''
return (x.strip() for x in (l for l in _regex.split(license) if l)) | def _split_license(license):
'''Returns all individual licenses in the input'''
return (x.strip() for x in (l for l in _regex.split(license) if l)) | [
"Returns",
"all",
"individual",
"licenses",
"in",
"the",
"input"
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/licenses.py#L47-L49 | [
"def",
"_split_license",
"(",
"license",
")",
":",
"return",
"(",
"x",
".",
"strip",
"(",
")",
"for",
"x",
"in",
"(",
"l",
"for",
"l",
"in",
"_regex",
".",
"split",
"(",
"license",
")",
"if",
"l",
")",
")"
] | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | match | Returns True if given license field is correct
Taken from rpmlint.
It's named match() to mimic a compiled regexp. | devassistant/dapi/licenses.py | def match(license):
'''Returns True if given license field is correct
Taken from rpmlint.
It's named match() to mimic a compiled regexp.'''
if license not in VALID_LICENSES:
for l1 in _split_license(license):
if l1 in VALID_LICENSES:
continue
for l2 in _s... | def match(license):
'''Returns True if given license field is correct
Taken from rpmlint.
It's named match() to mimic a compiled regexp.'''
if license not in VALID_LICENSES:
for l1 in _split_license(license):
if l1 in VALID_LICENSES:
continue
for l2 in _s... | [
"Returns",
"True",
"if",
"given",
"license",
"field",
"is",
"correct",
"Taken",
"from",
"rpmlint",
"."
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/licenses.py#L52-L65 | [
"def",
"match",
"(",
"license",
")",
":",
"if",
"license",
"not",
"in",
"VALID_LICENSES",
":",
"for",
"l1",
"in",
"_split_license",
"(",
"license",
")",
":",
"if",
"l1",
"in",
"VALID_LICENSES",
":",
"continue",
"for",
"l2",
"in",
"_split_license",
"(",
"... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | register_command_runner | Decorator that registers a command runner. Accepts either:
- CommandRunner directly or
- String prefix to register a command runner under (returning a decorator) | devassistant/command_runners.py | def register_command_runner(arg):
"""Decorator that registers a command runner. Accepts either:
- CommandRunner directly or
- String prefix to register a command runner under (returning a decorator)
"""
if isinstance(arg, str):
def inner(command_runner):
command_runners.setdefau... | def register_command_runner(arg):
"""Decorator that registers a command runner. Accepts either:
- CommandRunner directly or
- String prefix to register a command runner under (returning a decorator)
"""
if isinstance(arg, str):
def inner(command_runner):
command_runners.setdefau... | [
"Decorator",
"that",
"registers",
"a",
"command",
"runner",
".",
"Accepts",
"either",
":"
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/command_runners.py#L42-L61 | [
"def",
"register_command_runner",
"(",
"arg",
")",
":",
"if",
"isinstance",
"(",
"arg",
",",
"str",
")",
":",
"def",
"inner",
"(",
"command_runner",
")",
":",
"command_runners",
".",
"setdefault",
"(",
"arg",
",",
"[",
"]",
")",
"command_runners",
"[",
"... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | compare | Version comparing, returns 0 if are the same,
returns >0 if first is bigger, <0 if first is smaller,
excepts valid version | devassistant/dapi/dapver.py | def compare(ver1, ver2):
'''Version comparing, returns 0 if are the same,
returns >0 if first is bigger, <0 if first is smaller,
excepts valid version'''
if ver1 == ver2:
return 0
ver1 = _cut(ver1)
ver2 = _cut(ver2)
# magic multiplier
m = 1
# if the first one is shorter, repl... | def compare(ver1, ver2):
'''Version comparing, returns 0 if are the same,
returns >0 if first is bigger, <0 if first is smaller,
excepts valid version'''
if ver1 == ver2:
return 0
ver1 = _cut(ver1)
ver2 = _cut(ver2)
# magic multiplier
m = 1
# if the first one is shorter, repl... | [
"Version",
"comparing",
"returns",
"0",
"if",
"are",
"the",
"same",
"returns",
">",
"0",
"if",
"first",
"is",
"bigger",
"<0",
"if",
"first",
"is",
"smaller",
"excepts",
"valid",
"version"
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapver.py#L1-L26 | [
"def",
"compare",
"(",
"ver1",
",",
"ver2",
")",
":",
"if",
"ver1",
"==",
"ver2",
":",
"return",
"0",
"ver1",
"=",
"_cut",
"(",
"ver1",
")",
"ver2",
"=",
"_cut",
"(",
"ver2",
")",
"# magic multiplier",
"m",
"=",
"1",
"# if the first one is shorter, repla... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | _cut | Cuts the version to array, excepts valid version | devassistant/dapi/dapver.py | def _cut(ver):
'''Cuts the version to array, excepts valid version'''
ver = ver.split('.')
for i, part in enumerate(ver):
try:
ver[i] = int(part)
except:
if part[-len('dev'):] == 'dev':
ver[i] = int(part[:-len('dev')])
ver.append(-3)
... | def _cut(ver):
'''Cuts the version to array, excepts valid version'''
ver = ver.split('.')
for i, part in enumerate(ver):
try:
ver[i] = int(part)
except:
if part[-len('dev'):] == 'dev':
ver[i] = int(part[:-len('dev')])
ver.append(-3)
... | [
"Cuts",
"the",
"version",
"to",
"array",
"excepts",
"valid",
"version"
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapver.py#L29-L45 | [
"def",
"_cut",
"(",
"ver",
")",
":",
"ver",
"=",
"ver",
".",
"split",
"(",
"'.'",
")",
"for",
"i",
",",
"part",
"in",
"enumerate",
"(",
"ver",
")",
":",
"try",
":",
"ver",
"[",
"i",
"]",
"=",
"int",
"(",
"part",
")",
"except",
":",
"if",
"p... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | ArgparseGenerator.generate_argument_parser | Generates argument parser for given assistant tree and actions.
Args:
tree: assistant tree as returned by
devassistant.assistant_base.AssistantBase.get_subassistant_tree
actions: dict mapping actions (devassistant.actions.Action subclasses) to their
... | devassistant/cli/argparse_generator.py | def generate_argument_parser(cls, tree, actions={}):
"""Generates argument parser for given assistant tree and actions.
Args:
tree: assistant tree as returned by
devassistant.assistant_base.AssistantBase.get_subassistant_tree
actions: dict mapping actions (deva... | def generate_argument_parser(cls, tree, actions={}):
"""Generates argument parser for given assistant tree and actions.
Args:
tree: assistant tree as returned by
devassistant.assistant_base.AssistantBase.get_subassistant_tree
actions: dict mapping actions (deva... | [
"Generates",
"argument",
"parser",
"for",
"given",
"assistant",
"tree",
"and",
"actions",
"."
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/cli/argparse_generator.py#L15-L48 | [
"def",
"generate_argument_parser",
"(",
"cls",
",",
"tree",
",",
"actions",
"=",
"{",
"}",
")",
":",
"cur_as",
",",
"cur_subas",
"=",
"tree",
"parser",
"=",
"devassistant_argparse",
".",
"ArgumentParser",
"(",
"argument_default",
"=",
"argparse",
".",
"SUPPRES... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | ArgparseGenerator.add_subassistants_to | Adds assistant from given part of assistant tree and all its subassistants to
a given argument parser.
Args:
parser: instance of devassistant_argparse.ArgumentParser
assistant_tuple: part of assistant tree (see generate_argument_parser doc)
level: level of subassista... | devassistant/cli/argparse_generator.py | def add_subassistants_to(cls, parser, assistant_tuple, level, alias=None):
"""Adds assistant from given part of assistant tree and all its subassistants to
a given argument parser.
Args:
parser: instance of devassistant_argparse.ArgumentParser
assistant_tuple: part of as... | def add_subassistants_to(cls, parser, assistant_tuple, level, alias=None):
"""Adds assistant from given part of assistant tree and all its subassistants to
a given argument parser.
Args:
parser: instance of devassistant_argparse.ArgumentParser
assistant_tuple: part of as... | [
"Adds",
"assistant",
"from",
"given",
"part",
"of",
"assistant",
"tree",
"and",
"all",
"its",
"subassistants",
"to",
"a",
"given",
"argument",
"parser",
"."
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/cli/argparse_generator.py#L61-L88 | [
"def",
"add_subassistants_to",
"(",
"cls",
",",
"parser",
",",
"assistant_tuple",
",",
"level",
",",
"alias",
"=",
"None",
")",
":",
"name",
"=",
"alias",
"or",
"assistant_tuple",
"[",
"0",
"]",
".",
"name",
"p",
"=",
"parser",
".",
"add_parser",
"(",
... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | ArgparseGenerator.add_action_to | Adds given action to given parser
Args:
parser: instance of devassistant_argparse.ArgumentParser
action: devassistant.actions.Action subclass
subactions: dict with subactions - {SubA: {SubB: {}}, SubC: {}} | devassistant/cli/argparse_generator.py | def add_action_to(cls, parser, action, subactions, level):
"""Adds given action to given parser
Args:
parser: instance of devassistant_argparse.ArgumentParser
action: devassistant.actions.Action subclass
subactions: dict with subactions - {SubA: {SubB: {}}, SubC: {}}... | def add_action_to(cls, parser, action, subactions, level):
"""Adds given action to given parser
Args:
parser: instance of devassistant_argparse.ArgumentParser
action: devassistant.actions.Action subclass
subactions: dict with subactions - {SubA: {SubB: {}}, SubC: {}}... | [
"Adds",
"given",
"action",
"to",
"given",
"parser"
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/cli/argparse_generator.py#L91-L111 | [
"def",
"add_action_to",
"(",
"cls",
",",
"parser",
",",
"action",
",",
"subactions",
",",
"level",
")",
":",
"p",
"=",
"parser",
".",
"add_parser",
"(",
"action",
".",
"name",
",",
"description",
"=",
"action",
".",
"description",
",",
"argument_default",
... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | format_entry | Format a log entry according to its level and context | devassistant/gui/run_window.py | def format_entry(record, show_level=False, colorize=False):
"""
Format a log entry according to its level and context
"""
if show_level:
log_str = u'{}: {}'.format(record.levelname, record.getMessage())
else:
log_str = record.getMessage()
if colorize and record.levelname in LOG_... | def format_entry(record, show_level=False, colorize=False):
"""
Format a log entry according to its level and context
"""
if show_level:
log_str = u'{}: {}'.format(record.levelname, record.getMessage())
else:
log_str = record.getMessage()
if colorize and record.levelname in LOG_... | [
"Format",
"a",
"log",
"entry",
"according",
"to",
"its",
"level",
"and",
"context"
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/run_window.py#L28-L40 | [
"def",
"format_entry",
"(",
"record",
",",
"show_level",
"=",
"False",
",",
"colorize",
"=",
"False",
")",
":",
"if",
"show_level",
":",
"log_str",
"=",
"u'{}: {}'",
".",
"format",
"(",
"record",
".",
"levelname",
",",
"record",
".",
"getMessage",
"(",
"... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | switch_cursor | Functions switches the cursor to cursor type | devassistant/gui/run_window.py | def switch_cursor(cursor_type, parent_window):
"""
Functions switches the cursor to cursor type
"""
watch = Gdk.Cursor(cursor_type)
window = parent_window.get_root_window()
window.set_cursor(watch) | def switch_cursor(cursor_type, parent_window):
"""
Functions switches the cursor to cursor type
"""
watch = Gdk.Cursor(cursor_type)
window = parent_window.get_root_window()
window.set_cursor(watch) | [
"Functions",
"switches",
"the",
"cursor",
"to",
"cursor",
"type"
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/run_window.py#L42-L48 | [
"def",
"switch_cursor",
"(",
"cursor_type",
",",
"parent_window",
")",
":",
"watch",
"=",
"Gdk",
".",
"Cursor",
"(",
"cursor_type",
")",
"window",
"=",
"parent_window",
".",
"get_root_window",
"(",
")",
"window",
".",
"set_cursor",
"(",
"watch",
")"
] | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | RunLoggingHandler.emit | Function inserts log messages to list_view | devassistant/gui/run_window.py | def emit(self, record):
"""
Function inserts log messages to list_view
"""
msg = record.getMessage()
list_store = self.list_view.get_model()
Gdk.threads_enter()
if msg:
# Underline URLs in the record message
msg = replace_markup_chars(recor... | def emit(self, record):
"""
Function inserts log messages to list_view
"""
msg = record.getMessage()
list_store = self.list_view.get_model()
Gdk.threads_enter()
if msg:
# Underline URLs in the record message
msg = replace_markup_chars(recor... | [
"Function",
"inserts",
"log",
"messages",
"to",
"list_view"
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/run_window.py#L62-L93 | [
"def",
"emit",
"(",
"self",
",",
"record",
")",
":",
"msg",
"=",
"record",
".",
"getMessage",
"(",
")",
"list_store",
"=",
"self",
".",
"list_view",
".",
"get_model",
"(",
")",
"Gdk",
".",
"threads_enter",
"(",
")",
"if",
"msg",
":",
"# Underline URLs ... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | RunWindow.open_window | Function opens the run window | devassistant/gui/run_window.py | def open_window(self, widget, data=None):
"""
Function opens the run window
"""
if data is not None:
self.kwargs = data.get('kwargs', None)
self.top_assistant = data.get('top_assistant', None)
self.current_main_assistant = data.get('current_main_assist... | def open_window(self, widget, data=None):
"""
Function opens the run window
"""
if data is not None:
self.kwargs = data.get('kwargs', None)
self.top_assistant = data.get('top_assistant', None)
self.current_main_assistant = data.get('current_main_assist... | [
"Function",
"opens",
"the",
"run",
"window"
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/run_window.py#L144-L175 | [
"def",
"open_window",
"(",
"self",
",",
"widget",
",",
"data",
"=",
"None",
")",
":",
"if",
"data",
"is",
"not",
"None",
":",
"self",
".",
"kwargs",
"=",
"data",
".",
"get",
"(",
"'kwargs'",
",",
"None",
")",
"self",
".",
"top_assistant",
"=",
"dat... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | RunWindow.remove_link_button | Function removes link button from Run Window | devassistant/gui/run_window.py | def remove_link_button(self):
"""
Function removes link button from Run Window
"""
if self.link is not None:
self.info_box.remove(self.link)
self.link.destroy()
self.link = None | def remove_link_button(self):
"""
Function removes link button from Run Window
"""
if self.link is not None:
self.info_box.remove(self.link)
self.link.destroy()
self.link = None | [
"Function",
"removes",
"link",
"button",
"from",
"Run",
"Window"
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/run_window.py#L183-L190 | [
"def",
"remove_link_button",
"(",
"self",
")",
":",
"if",
"self",
".",
"link",
"is",
"not",
"None",
":",
"self",
".",
"info_box",
".",
"remove",
"(",
"self",
".",
"link",
")",
"self",
".",
"link",
".",
"destroy",
"(",
")",
"self",
".",
"link",
"=",... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | RunWindow.delete_event | Event cancels the project creation | devassistant/gui/run_window.py | def delete_event(self, widget, event, data=None):
"""
Event cancels the project creation
"""
if not self.close_win:
if self.thread.isAlive():
dlg = self.gui_helper.create_message_dialog("Do you want to cancel project creation?",
... | def delete_event(self, widget, event, data=None):
"""
Event cancels the project creation
"""
if not self.close_win:
if self.thread.isAlive():
dlg = self.gui_helper.create_message_dialog("Do you want to cancel project creation?",
... | [
"Event",
"cancels",
"the",
"project",
"creation"
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/run_window.py#L192-L212 | [
"def",
"delete_event",
"(",
"self",
",",
"widget",
",",
"event",
",",
"data",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"close_win",
":",
"if",
"self",
".",
"thread",
".",
"isAlive",
"(",
")",
":",
"dlg",
"=",
"self",
".",
"gui_helper",
".",... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | RunWindow.list_view_changed | Function shows last rows. | devassistant/gui/run_window.py | def list_view_changed(self, widget, event, data=None):
"""
Function shows last rows.
"""
adj = self.scrolled_window.get_vadjustment()
adj.set_value(adj.get_upper() - adj.get_page_size()) | def list_view_changed(self, widget, event, data=None):
"""
Function shows last rows.
"""
adj = self.scrolled_window.get_vadjustment()
adj.set_value(adj.get_upper() - adj.get_page_size()) | [
"Function",
"shows",
"last",
"rows",
"."
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/run_window.py#L214-L219 | [
"def",
"list_view_changed",
"(",
"self",
",",
"widget",
",",
"event",
",",
"data",
"=",
"None",
")",
":",
"adj",
"=",
"self",
".",
"scrolled_window",
".",
"get_vadjustment",
"(",
")",
"adj",
".",
"set_value",
"(",
"adj",
".",
"get_upper",
"(",
")",
"-"... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | RunWindow.disable_buttons | Function disables buttons | devassistant/gui/run_window.py | def disable_buttons(self):
"""
Function disables buttons
"""
self.main_btn.set_sensitive(False)
self.back_btn.hide()
self.info_label.set_label('<span color="#FFA500">In progress...</span>')
self.disable_close_window()
if self.link is not None:
... | def disable_buttons(self):
"""
Function disables buttons
"""
self.main_btn.set_sensitive(False)
self.back_btn.hide()
self.info_label.set_label('<span color="#FFA500">In progress...</span>')
self.disable_close_window()
if self.link is not None:
... | [
"Function",
"disables",
"buttons"
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/run_window.py#L233-L242 | [
"def",
"disable_buttons",
"(",
"self",
")",
":",
"self",
".",
"main_btn",
".",
"set_sensitive",
"(",
"False",
")",
"self",
".",
"back_btn",
".",
"hide",
"(",
")",
"self",
".",
"info_label",
".",
"set_label",
"(",
"'<span color=\"#FFA500\">In progress...</span>'"... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | RunWindow.allow_buttons | Function allows buttons | devassistant/gui/run_window.py | def allow_buttons(self, message="", link=True, back=True):
"""
Function allows buttons
"""
self.info_label.set_label(message)
self.allow_close_window()
if link and self.link is not None:
self.link.set_sensitive(True)
self.link.show_all()
if... | def allow_buttons(self, message="", link=True, back=True):
"""
Function allows buttons
"""
self.info_label.set_label(message)
self.allow_close_window()
if link and self.link is not None:
self.link.set_sensitive(True)
self.link.show_all()
if... | [
"Function",
"allows",
"buttons"
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/run_window.py#L244-L255 | [
"def",
"allow_buttons",
"(",
"self",
",",
"message",
"=",
"\"\"",
",",
"link",
"=",
"True",
",",
"back",
"=",
"True",
")",
":",
"self",
".",
"info_label",
".",
"set_label",
"(",
"message",
")",
"self",
".",
"allow_close_window",
"(",
")",
"if",
"link",... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | RunWindow.dev_assistant_start | Thread executes devassistant API. | devassistant/gui/run_window.py | def dev_assistant_start(self):
"""
Thread executes devassistant API.
"""
#logger_gui.info("Thread run")
path = self.top_assistant.get_selected_subassistant_path(**self.kwargs)
kwargs_decoded = dict()
for k, v in self.kwargs.items():
kwargs_decoded[k] =... | def dev_assistant_start(self):
"""
Thread executes devassistant API.
"""
#logger_gui.info("Thread run")
path = self.top_assistant.get_selected_subassistant_path(**self.kwargs)
kwargs_decoded = dict()
for k, v in self.kwargs.items():
kwargs_decoded[k] =... | [
"Thread",
"executes",
"devassistant",
"API",
"."
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/run_window.py#L257-L298 | [
"def",
"dev_assistant_start",
"(",
"self",
")",
":",
"#logger_gui.info(\"Thread run\")",
"path",
"=",
"self",
".",
"top_assistant",
".",
"get_selected_subassistant_path",
"(",
"*",
"*",
"self",
".",
"kwargs",
")",
"kwargs_decoded",
"=",
"dict",
"(",
")",
"for",
... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | RunWindow.debug_btn_clicked | Event in case that debug button is pressed. | devassistant/gui/run_window.py | def debug_btn_clicked(self, widget, data=None):
"""
Event in case that debug button is pressed.
"""
self.store.clear()
self.thread = threading.Thread(target=self.logs_update)
self.thread.start() | def debug_btn_clicked(self, widget, data=None):
"""
Event in case that debug button is pressed.
"""
self.store.clear()
self.thread = threading.Thread(target=self.logs_update)
self.thread.start() | [
"Event",
"in",
"case",
"that",
"debug",
"button",
"is",
"pressed",
"."
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/run_window.py#L300-L306 | [
"def",
"debug_btn_clicked",
"(",
"self",
",",
"widget",
",",
"data",
"=",
"None",
")",
":",
"self",
".",
"store",
".",
"clear",
"(",
")",
"self",
".",
"thread",
"=",
"threading",
".",
"Thread",
"(",
"target",
"=",
"self",
".",
"logs_update",
")",
"se... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | RunWindow.logs_update | Function updates logs. | devassistant/gui/run_window.py | def logs_update(self):
"""
Function updates logs.
"""
Gdk.threads_enter()
if not self.debugging:
self.debugging = True
self.debug_btn.set_label('Info logs')
else:
self.debugging = False
self.debug_btn.set_label('Debug logs')... | def logs_update(self):
"""
Function updates logs.
"""
Gdk.threads_enter()
if not self.debugging:
self.debugging = True
self.debug_btn.set_label('Info logs')
else:
self.debugging = False
self.debug_btn.set_label('Debug logs')... | [
"Function",
"updates",
"logs",
"."
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/run_window.py#L308-L327 | [
"def",
"logs_update",
"(",
"self",
")",
":",
"Gdk",
".",
"threads_enter",
"(",
")",
"if",
"not",
"self",
".",
"debugging",
":",
"self",
".",
"debugging",
"=",
"True",
"self",
".",
"debug_btn",
".",
"set_label",
"(",
"'Info logs'",
")",
"else",
":",
"se... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | RunWindow.clipboard_btn_clicked | Function copies logs to clipboard. | devassistant/gui/run_window.py | def clipboard_btn_clicked(self, widget, data=None):
"""
Function copies logs to clipboard.
"""
_clipboard_text = []
for record in self.debug_logs['logs']:
if self.debugging:
_clipboard_text.append(format_entry(record, show_level=True))
else... | def clipboard_btn_clicked(self, widget, data=None):
"""
Function copies logs to clipboard.
"""
_clipboard_text = []
for record in self.debug_logs['logs']:
if self.debugging:
_clipboard_text.append(format_entry(record, show_level=True))
else... | [
"Function",
"copies",
"logs",
"to",
"clipboard",
"."
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/run_window.py#L330-L345 | [
"def",
"clipboard_btn_clicked",
"(",
"self",
",",
"widget",
",",
"data",
"=",
"None",
")",
":",
"_clipboard_text",
"=",
"[",
"]",
"for",
"record",
"in",
"self",
".",
"debug_logs",
"[",
"'logs'",
"]",
":",
"if",
"self",
".",
"debugging",
":",
"_clipboard_... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | RunWindow.back_btn_clicked | Event for back button.
This occurs in case of devassistant fail. | devassistant/gui/run_window.py | def back_btn_clicked(self, widget, data=None):
"""
Event for back button.
This occurs in case of devassistant fail.
"""
self.remove_link_button()
self.run_window.hide()
self.parent.path_window.path_window.show() | def back_btn_clicked(self, widget, data=None):
"""
Event for back button.
This occurs in case of devassistant fail.
"""
self.remove_link_button()
self.run_window.hide()
self.parent.path_window.path_window.show() | [
"Event",
"for",
"back",
"button",
".",
"This",
"occurs",
"in",
"case",
"of",
"devassistant",
"fail",
"."
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/run_window.py#L347-L354 | [
"def",
"back_btn_clicked",
"(",
"self",
",",
"widget",
",",
"data",
"=",
"None",
")",
":",
"self",
".",
"remove_link_button",
"(",
")",
"self",
".",
"run_window",
".",
"hide",
"(",
")",
"self",
".",
"parent",
".",
"path_window",
".",
"path_window",
".",
... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | RunWindow.main_btn_clicked | Button switches to Dev Assistant GUI main window | devassistant/gui/run_window.py | def main_btn_clicked(self, widget, data=None):
"""
Button switches to Dev Assistant GUI main window
"""
self.remove_link_button()
data = dict()
data['debugging'] = self.debugging
self.run_window.hide()
self.parent.open_window(widget, data) | def main_btn_clicked(self, widget, data=None):
"""
Button switches to Dev Assistant GUI main window
"""
self.remove_link_button()
data = dict()
data['debugging'] = self.debugging
self.run_window.hide()
self.parent.open_window(widget, data) | [
"Button",
"switches",
"to",
"Dev",
"Assistant",
"GUI",
"main",
"window"
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/run_window.py#L356-L364 | [
"def",
"main_btn_clicked",
"(",
"self",
",",
"widget",
",",
"data",
"=",
"None",
")",
":",
"self",
".",
"remove_link_button",
"(",
")",
"data",
"=",
"dict",
"(",
")",
"data",
"[",
"'debugging'",
"]",
"=",
"self",
".",
"debugging",
"self",
".",
"run_win... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | RunWindow.list_view_row_clicked | Function opens the firefox window with relevant link | devassistant/gui/run_window.py | def list_view_row_clicked(self, list_view, path, view_column):
"""
Function opens the firefox window with relevant link
"""
model = list_view.get_model()
text = model[path][0]
match = URL_FINDER.search(text)
if match is not None:
url = match.group(1)
... | def list_view_row_clicked(self, list_view, path, view_column):
"""
Function opens the firefox window with relevant link
"""
model = list_view.get_model()
text = model[path][0]
match = URL_FINDER.search(text)
if match is not None:
url = match.group(1)
... | [
"Function",
"opens",
"the",
"firefox",
"window",
"with",
"relevant",
"link"
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/run_window.py#L366-L377 | [
"def",
"list_view_row_clicked",
"(",
"self",
",",
"list_view",
",",
"path",
",",
"view_column",
")",
":",
"model",
"=",
"list_view",
".",
"get_model",
"(",
")",
"text",
"=",
"model",
"[",
"path",
"]",
"[",
"0",
"]",
"match",
"=",
"URL_FINDER",
".",
"se... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | GitHubAuth._github_create_twofactor_authorization | Create an authorization for a GitHub user using two-factor
authentication. Unlike its non-two-factor counterpart, this method
does not traverse the available authentications as they are not
visible until the user logs in.
Please note: cls._user's attributes are not accessibl... | devassistant/remote_auth.py | def _github_create_twofactor_authorization(cls, ui):
"""Create an authorization for a GitHub user using two-factor
authentication. Unlike its non-two-factor counterpart, this method
does not traverse the available authentications as they are not
visible until the user logs in.
... | def _github_create_twofactor_authorization(cls, ui):
"""Create an authorization for a GitHub user using two-factor
authentication. Unlike its non-two-factor counterpart, this method
does not traverse the available authentications as they are not
visible until the user logs in.
... | [
"Create",
"an",
"authorization",
"for",
"a",
"GitHub",
"user",
"using",
"two",
"-",
"factor",
"authentication",
".",
"Unlike",
"its",
"non",
"-",
"two",
"-",
"factor",
"counterpart",
"this",
"method",
"does",
"not",
"traverse",
"the",
"available",
"authenticat... | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/remote_auth.py#L105-L127 | [
"def",
"_github_create_twofactor_authorization",
"(",
"cls",
",",
"ui",
")",
":",
"try",
":",
"try",
":",
"# This is necessary to trigger sending a 2FA key to the user",
"auth",
"=",
"cls",
".",
"_user",
".",
"create_authorization",
"(",
")",
"except",
"cls",
".",
"... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | GitHubAuth._github_create_simple_authorization | Create a GitHub authorization for the given user in case they don't
already have one. | devassistant/remote_auth.py | def _github_create_simple_authorization(cls):
"""Create a GitHub authorization for the given user in case they don't
already have one.
"""
try:
auth = None
for a in cls._user.get_authorizations():
if a.note == 'DevAssistant':
... | def _github_create_simple_authorization(cls):
"""Create a GitHub authorization for the given user in case they don't
already have one.
"""
try:
auth = None
for a in cls._user.get_authorizations():
if a.note == 'DevAssistant':
... | [
"Create",
"a",
"GitHub",
"authorization",
"for",
"the",
"given",
"user",
"in",
"case",
"they",
"don",
"t",
"already",
"have",
"one",
"."
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/remote_auth.py#L131-L146 | [
"def",
"_github_create_simple_authorization",
"(",
"cls",
")",
":",
"try",
":",
"auth",
"=",
"None",
"for",
"a",
"in",
"cls",
".",
"_user",
".",
"get_authorizations",
"(",
")",
":",
"if",
"a",
".",
"note",
"==",
"'DevAssistant'",
":",
"auth",
"=",
"a",
... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | GitHubAuth._github_store_authorization | Store an authorization token for the given GitHub user in the git
global config file. | devassistant/remote_auth.py | def _github_store_authorization(cls, user, auth):
"""Store an authorization token for the given GitHub user in the git
global config file.
"""
ClHelper.run_command("git config --global github.token.{login} {token}".format(
login=user.login, token=auth.token), log_secret=Tr... | def _github_store_authorization(cls, user, auth):
"""Store an authorization token for the given GitHub user in the git
global config file.
"""
ClHelper.run_command("git config --global github.token.{login} {token}".format(
login=user.login, token=auth.token), log_secret=Tr... | [
"Store",
"an",
"authorization",
"token",
"for",
"the",
"given",
"GitHub",
"user",
"in",
"the",
"git",
"global",
"config",
"file",
"."
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/remote_auth.py#L149-L156 | [
"def",
"_github_store_authorization",
"(",
"cls",
",",
"user",
",",
"auth",
")",
":",
"ClHelper",
".",
"run_command",
"(",
"\"git config --global github.token.{login} {token}\"",
".",
"format",
"(",
"login",
"=",
"user",
".",
"login",
",",
"token",
"=",
"auth",
... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | GitHubAuth._start_ssh_agent | Starts ssh-agent and returns the environment variables related to it | devassistant/remote_auth.py | def _start_ssh_agent(cls):
"""Starts ssh-agent and returns the environment variables related to it"""
env = dict()
stdout = ClHelper.run_command('ssh-agent -s')
lines = stdout.split('\n')
for line in lines:
if not line or line.startswith('echo '):
cont... | def _start_ssh_agent(cls):
"""Starts ssh-agent and returns the environment variables related to it"""
env = dict()
stdout = ClHelper.run_command('ssh-agent -s')
lines = stdout.split('\n')
for line in lines:
if not line or line.startswith('echo '):
cont... | [
"Starts",
"ssh",
"-",
"agent",
"and",
"returns",
"the",
"environment",
"variables",
"related",
"to",
"it"
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/remote_auth.py#L159-L171 | [
"def",
"_start_ssh_agent",
"(",
"cls",
")",
":",
"env",
"=",
"dict",
"(",
")",
"stdout",
"=",
"ClHelper",
".",
"run_command",
"(",
"'ssh-agent -s'",
")",
"lines",
"=",
"stdout",
".",
"split",
"(",
"'\\n'",
")",
"for",
"line",
"in",
"lines",
":",
"if",
... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | GitHubAuth._github_create_ssh_key | Creates a local ssh key, if it doesn't exist already, and uploads it to Github. | devassistant/remote_auth.py | def _github_create_ssh_key(cls):
"""Creates a local ssh key, if it doesn't exist already, and uploads it to Github."""
try:
login = cls._user.login
pkey_path = '{home}/.ssh/{keyname}'.format(
home=os.path.expanduser('~'),
keyname=settings.GITHUB_SS... | def _github_create_ssh_key(cls):
"""Creates a local ssh key, if it doesn't exist already, and uploads it to Github."""
try:
login = cls._user.login
pkey_path = '{home}/.ssh/{keyname}'.format(
home=os.path.expanduser('~'),
keyname=settings.GITHUB_SS... | [
"Creates",
"a",
"local",
"ssh",
"key",
"if",
"it",
"doesn",
"t",
"exist",
"already",
"and",
"uploads",
"it",
"to",
"Github",
"."
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/remote_auth.py#L174-L196 | [
"def",
"_github_create_ssh_key",
"(",
"cls",
")",
":",
"try",
":",
"login",
"=",
"cls",
".",
"_user",
".",
"login",
"pkey_path",
"=",
"'{home}/.ssh/{keyname}'",
".",
"format",
"(",
"home",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"'~'",
")",
",",
... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | GitHubAuth._github_ssh_key_exists | Returns True if any key on Github matches a local key, else False. | devassistant/remote_auth.py | def _github_ssh_key_exists(cls):
"""Returns True if any key on Github matches a local key, else False."""
remote_keys = map(lambda k: k._key, cls._user.get_keys())
found = False
pubkey_files = glob.glob(os.path.expanduser('~/.ssh/*.pub'))
for rk in remote_keys:
for pk... | def _github_ssh_key_exists(cls):
"""Returns True if any key on Github matches a local key, else False."""
remote_keys = map(lambda k: k._key, cls._user.get_keys())
found = False
pubkey_files = glob.glob(os.path.expanduser('~/.ssh/*.pub'))
for rk in remote_keys:
for pk... | [
"Returns",
"True",
"if",
"any",
"key",
"on",
"Github",
"matches",
"a",
"local",
"key",
"else",
"False",
"."
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/remote_auth.py#L208-L222 | [
"def",
"_github_ssh_key_exists",
"(",
"cls",
")",
":",
"remote_keys",
"=",
"map",
"(",
"lambda",
"k",
":",
"k",
".",
"_key",
",",
"cls",
".",
"_user",
".",
"get_keys",
"(",
")",
")",
"found",
"=",
"False",
"pubkey_files",
"=",
"glob",
".",
"glob",
"(... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | GitHubAuth.github_authenticated | Does user authentication, creates SSH keys if needed and injects "_user" attribute
into class/object bound to the decorated function.
Don't call any other methods of this class manually, this should be everything you need. | devassistant/remote_auth.py | def github_authenticated(cls, func):
"""Does user authentication, creates SSH keys if needed and injects "_user" attribute
into class/object bound to the decorated function.
Don't call any other methods of this class manually, this should be everything you need.
"""
def inner(fun... | def github_authenticated(cls, func):
"""Does user authentication, creates SSH keys if needed and injects "_user" attribute
into class/object bound to the decorated function.
Don't call any other methods of this class manually, this should be everything you need.
"""
def inner(fun... | [
"Does",
"user",
"authentication",
"creates",
"SSH",
"keys",
"if",
"needed",
"and",
"injects",
"_user",
"attribute",
"into",
"class",
"/",
"object",
"bound",
"to",
"the",
"decorated",
"function",
".",
"Don",
"t",
"call",
"any",
"other",
"methods",
"of",
"this... | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/remote_auth.py#L241-L265 | [
"def",
"github_authenticated",
"(",
"cls",
",",
"func",
")",
":",
"def",
"inner",
"(",
"func_cls",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"cls",
".",
"_gh_module",
":",
"logger",
".",
"warning",
"(",
"'PyGithub not installed, s... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | YamlAssistantLoader.get_assistants | Returns list of assistants that are subassistants of given superassistants
(I love this docstring).
Args:
roles: list of names of roles, defaults to all roles
Returns:
list of YamlAssistant instances with specified roles | devassistant/yaml_assistant_loader.py | def get_assistants(cls, superassistants):
"""Returns list of assistants that are subassistants of given superassistants
(I love this docstring).
Args:
roles: list of names of roles, defaults to all roles
Returns:
list of YamlAssistant instances with specified rol... | def get_assistants(cls, superassistants):
"""Returns list of assistants that are subassistants of given superassistants
(I love this docstring).
Args:
roles: list of names of roles, defaults to all roles
Returns:
list of YamlAssistant instances with specified rol... | [
"Returns",
"list",
"of",
"assistants",
"that",
"are",
"subassistants",
"of",
"given",
"superassistants",
"(",
"I",
"love",
"this",
"docstring",
")",
"."
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/yaml_assistant_loader.py#L16-L30 | [
"def",
"get_assistants",
"(",
"cls",
",",
"superassistants",
")",
":",
"_assistants",
"=",
"cls",
".",
"load_all_assistants",
"(",
"superassistants",
")",
"result",
"=",
"[",
"]",
"for",
"supa",
"in",
"superassistants",
":",
"result",
".",
"extend",
"(",
"_a... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | YamlAssistantLoader.load_all_assistants | Fills self._assistants with loaded YamlAssistant instances of requested roles.
Tries to use cache (updated/created if needed). If cache is unusable, it
falls back to loading all assistants.
Args:
roles: list of required assistant roles | devassistant/yaml_assistant_loader.py | def load_all_assistants(cls, superassistants):
"""Fills self._assistants with loaded YamlAssistant instances of requested roles.
Tries to use cache (updated/created if needed). If cache is unusable, it
falls back to loading all assistants.
Args:
roles: list of required assi... | def load_all_assistants(cls, superassistants):
"""Fills self._assistants with loaded YamlAssistant instances of requested roles.
Tries to use cache (updated/created if needed). If cache is unusable, it
falls back to loading all assistants.
Args:
roles: list of required assi... | [
"Fills",
"self",
".",
"_assistants",
"with",
"loaded",
"YamlAssistant",
"instances",
"of",
"requested",
"roles",
"."
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/yaml_assistant_loader.py#L33-L67 | [
"def",
"load_all_assistants",
"(",
"cls",
",",
"superassistants",
")",
":",
"# mapping of assistant roles to lists of top-level assistant instances",
"_assistants",
"=",
"{",
"}",
"# {'crt': CreatorAssistant, ...}",
"superas_dict",
"=",
"dict",
"(",
"map",
"(",
"lambda",
"a... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | YamlAssistantLoader.get_assistants_from_cache_hierarchy | Accepts cache_hierarch as described in devassistant.cache and returns
instances of YamlAssistant (only with cached attributes) for loaded files
Args:
cache_hierarchy: structure as described in devassistant.cache
role: role of all assistants in this hierarchy (we could find
... | devassistant/yaml_assistant_loader.py | def get_assistants_from_cache_hierarchy(cls, cache_hierarchy, superassistant,
role=settings.DEFAULT_ASSISTANT_ROLE):
"""Accepts cache_hierarch as described in devassistant.cache and returns
instances of YamlAssistant (only with cached attributes) for loaded fi... | def get_assistants_from_cache_hierarchy(cls, cache_hierarchy, superassistant,
role=settings.DEFAULT_ASSISTANT_ROLE):
"""Accepts cache_hierarch as described in devassistant.cache and returns
instances of YamlAssistant (only with cached attributes) for loaded fi... | [
"Accepts",
"cache_hierarch",
"as",
"described",
"in",
"devassistant",
".",
"cache",
"and",
"returns",
"instances",
"of",
"YamlAssistant",
"(",
"only",
"with",
"cached",
"attributes",
")",
"for",
"loaded",
"files"
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/yaml_assistant_loader.py#L70-L97 | [
"def",
"get_assistants_from_cache_hierarchy",
"(",
"cls",
",",
"cache_hierarchy",
",",
"superassistant",
",",
"role",
"=",
"settings",
".",
"DEFAULT_ASSISTANT_ROLE",
")",
":",
"result",
"=",
"[",
"]",
"for",
"name",
",",
"attrs",
"in",
"cache_hierarchy",
".",
"i... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | YamlAssistantLoader.get_assistants_from_file_hierarchy | Accepts file_hierarch as returned by cls.get_assistant_file_hierarchy and returns
instances of YamlAssistant for loaded files
Args:
file_hierarchy: structure as described in cls.get_assistants_file_hierarchy
role: role of all assistants in this hierarchy (we could find
... | devassistant/yaml_assistant_loader.py | def get_assistants_from_file_hierarchy(cls, file_hierarchy, superassistant,
role=settings.DEFAULT_ASSISTANT_ROLE):
"""Accepts file_hierarch as returned by cls.get_assistant_file_hierarchy and returns
instances of YamlAssistant for loaded files
Args:
... | def get_assistants_from_file_hierarchy(cls, file_hierarchy, superassistant,
role=settings.DEFAULT_ASSISTANT_ROLE):
"""Accepts file_hierarch as returned by cls.get_assistant_file_hierarchy and returns
instances of YamlAssistant for loaded files
Args:
... | [
"Accepts",
"file_hierarch",
"as",
"returned",
"by",
"cls",
".",
"get_assistant_file_hierarchy",
"and",
"returns",
"instances",
"of",
"YamlAssistant",
"for",
"loaded",
"files"
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/yaml_assistant_loader.py#L100-L134 | [
"def",
"get_assistants_from_file_hierarchy",
"(",
"cls",
",",
"file_hierarchy",
",",
"superassistant",
",",
"role",
"=",
"settings",
".",
"DEFAULT_ASSISTANT_ROLE",
")",
":",
"result",
"=",
"[",
"]",
"warn_msg",
"=",
"'Failed to load assistant {source}, skipping subassista... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | YamlAssistantLoader.get_assistants_file_hierarchy | Returns assistants file hierarchy structure (see below) representing assistant
hierarchy in given directories.
It works like this:
1. It goes through all *.yaml files in all given directories and adds them into
hierarchy (if there are two files with same name in more directories, the... | devassistant/yaml_assistant_loader.py | def get_assistants_file_hierarchy(cls, dirs):
"""Returns assistants file hierarchy structure (see below) representing assistant
hierarchy in given directories.
It works like this:
1. It goes through all *.yaml files in all given directories and adds them into
hierarchy (if th... | def get_assistants_file_hierarchy(cls, dirs):
"""Returns assistants file hierarchy structure (see below) representing assistant
hierarchy in given directories.
It works like this:
1. It goes through all *.yaml files in all given directories and adds them into
hierarchy (if th... | [
"Returns",
"assistants",
"file",
"hierarchy",
"structure",
"(",
"see",
"below",
")",
"representing",
"assistant",
"hierarchy",
"in",
"given",
"directories",
"."
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/yaml_assistant_loader.py#L137-L170 | [
"def",
"get_assistants_file_hierarchy",
"(",
"cls",
",",
"dirs",
")",
":",
"result",
"=",
"{",
"}",
"for",
"d",
"in",
"filter",
"(",
"lambda",
"d",
":",
"os",
".",
"path",
".",
"exists",
"(",
"d",
")",
",",
"dirs",
")",
":",
"for",
"f",
"in",
"fi... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | YamlAssistantLoader.assistant_from_yaml | Constructs instance of YamlAssistant loaded from given structure y, loaded
from source file source.
Args:
source: path to assistant source file
y: loaded yaml structure
superassistant: superassistant of this assistant
Returns:
YamlAssistant instan... | devassistant/yaml_assistant_loader.py | def assistant_from_yaml(cls, source, y, superassistant, fully_loaded=True,
role=settings.DEFAULT_ASSISTANT_ROLE):
"""Constructs instance of YamlAssistant loaded from given structure y, loaded
from source file source.
Args:
source: path to assistant source... | def assistant_from_yaml(cls, source, y, superassistant, fully_loaded=True,
role=settings.DEFAULT_ASSISTANT_ROLE):
"""Constructs instance of YamlAssistant loaded from given structure y, loaded
from source file source.
Args:
source: path to assistant source... | [
"Constructs",
"instance",
"of",
"YamlAssistant",
"loaded",
"from",
"given",
"structure",
"y",
"loaded",
"from",
"source",
"file",
"source",
"."
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/yaml_assistant_loader.py#L173-L195 | [
"def",
"assistant_from_yaml",
"(",
"cls",
",",
"source",
",",
"y",
",",
"superassistant",
",",
"fully_loaded",
"=",
"True",
",",
"role",
"=",
"settings",
".",
"DEFAULT_ASSISTANT_ROLE",
")",
":",
"# In pre-0.9.0, we required assistant to be a mapping of {name: assistant_at... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | YamlSnippetLoader.get_snippet_by_name | name is in dotted format, e.g. topsnippet.something.wantedsnippet | devassistant/yaml_snippet_loader.py | def get_snippet_by_name(cls, name):
"""name is in dotted format, e.g. topsnippet.something.wantedsnippet"""
name_with_dir_separators = name.replace('.', os.path.sep)
loaded = yaml_loader.YamlLoader.load_yaml_by_relpath(cls.snippets_dirs,
... | def get_snippet_by_name(cls, name):
"""name is in dotted format, e.g. topsnippet.something.wantedsnippet"""
name_with_dir_separators = name.replace('.', os.path.sep)
loaded = yaml_loader.YamlLoader.load_yaml_by_relpath(cls.snippets_dirs,
... | [
"name",
"is",
"in",
"dotted",
"format",
"e",
".",
"g",
".",
"topsnippet",
".",
"something",
".",
"wantedsnippet"
] | devassistant/devassistant | python | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/yaml_snippet_loader.py#L23-L32 | [
"def",
"get_snippet_by_name",
"(",
"cls",
",",
"name",
")",
":",
"name_with_dir_separators",
"=",
"name",
".",
"replace",
"(",
"'.'",
",",
"os",
".",
"path",
".",
"sep",
")",
"loaded",
"=",
"yaml_loader",
".",
"YamlLoader",
".",
"load_yaml_by_relpath",
"(",
... | 2dbfeaa666a64127263664d18969c55d19ecc83e |
train | conforms | `5.6.1 Schema Validation Requirement <http://shex.io/shex-semantics/#validation-requirement>`_
A graph G is said to conform with a schema S with a ShapeMap m when:
Every, SemAct in the startActs of S has a successful evaluation of semActsSatisfied.
Every node n in m conforms to its associated shapeExp... | pyshex/shape_expressions_language/p5_6_schema_requirements.py | def conforms(cntxt: Context, n: Node, S: ShExJ.Shape) -> bool:
""" `5.6.1 Schema Validation Requirement <http://shex.io/shex-semantics/#validation-requirement>`_
A graph G is said to conform with a schema S with a ShapeMap m when:
Every, SemAct in the startActs of S has a successful evaluation of semA... | def conforms(cntxt: Context, n: Node, S: ShExJ.Shape) -> bool:
""" `5.6.1 Schema Validation Requirement <http://shex.io/shex-semantics/#validation-requirement>`_
A graph G is said to conform with a schema S with a ShapeMap m when:
Every, SemAct in the startActs of S has a successful evaluation of semA... | [
"5",
".",
"6",
".",
"1",
"Schema",
"Validation",
"Requirement",
"<http",
":",
"//",
"shex",
".",
"io",
"/",
"shex",
"-",
"semantics",
"/",
"#validation",
"-",
"requirement",
">",
"_",
"A",
"graph",
"G",
"is",
"said",
"to",
"conform",
"with",
"a",
"sc... | hsolbrig/PyShEx | python | https://github.com/hsolbrig/PyShEx/blob/9d659cc36e808afd66d4a6d60e8ea21cb12eb744/pyshex/shape_expressions_language/p5_6_schema_requirements.py#L14-L29 | [
"def",
"conforms",
"(",
"cntxt",
":",
"Context",
",",
"n",
":",
"Node",
",",
"S",
":",
"ShExJ",
".",
"Shape",
")",
"->",
"bool",
":",
"# return semActsSatisfied(cntxt.schema.startActs, cntxt) and \\",
"# all(reference_of(cntxt.schema, sa.shapeLabel) is not None and",
... | 9d659cc36e808afd66d4a6d60e8ea21cb12eb744 |
train | Chart.set_legend | legend needs to be a list, tuple or None | pygooglechart.py | def set_legend(self, legend):
"""legend needs to be a list, tuple or None"""
assert(isinstance(legend, list) or isinstance(legend, tuple) or
legend is None)
if legend:
self.legend = [quote(a) for a in legend]
else:
self.legend = None | def set_legend(self, legend):
"""legend needs to be a list, tuple or None"""
assert(isinstance(legend, list) or isinstance(legend, tuple) or
legend is None)
if legend:
self.legend = [quote(a) for a in legend]
else:
self.legend = None | [
"legend",
"needs",
"to",
"be",
"a",
"list",
"tuple",
"or",
"None"
] | gak/pygooglechart | python | https://github.com/gak/pygooglechart/blob/25234bb63127a7e5e057c0b98ab841f3f1d93b21/pygooglechart.py#L434-L441 | [
"def",
"set_legend",
"(",
"self",
",",
"legend",
")",
":",
"assert",
"(",
"isinstance",
"(",
"legend",
",",
"list",
")",
"or",
"isinstance",
"(",
"legend",
",",
"tuple",
")",
"or",
"legend",
"is",
"None",
")",
"if",
"legend",
":",
"self",
".",
"legen... | 25234bb63127a7e5e057c0b98ab841f3f1d93b21 |
train | Chart.set_legend_position | Sets legend position. Default is 'r'.
b - At the bottom of the chart, legend entries in a horizontal row.
bv - At the bottom of the chart, legend entries in a vertical column.
t - At the top of the chart, legend entries in a horizontal row.
tv - At the top of the chart, legend entries i... | pygooglechart.py | def set_legend_position(self, legend_position):
"""Sets legend position. Default is 'r'.
b - At the bottom of the chart, legend entries in a horizontal row.
bv - At the bottom of the chart, legend entries in a vertical column.
t - At the top of the chart, legend entries in a horizontal ... | def set_legend_position(self, legend_position):
"""Sets legend position. Default is 'r'.
b - At the bottom of the chart, legend entries in a horizontal row.
bv - At the bottom of the chart, legend entries in a vertical column.
t - At the top of the chart, legend entries in a horizontal ... | [
"Sets",
"legend",
"position",
".",
"Default",
"is",
"r",
"."
] | gak/pygooglechart | python | https://github.com/gak/pygooglechart/blob/25234bb63127a7e5e057c0b98ab841f3f1d93b21/pygooglechart.py#L443-L456 | [
"def",
"set_legend_position",
"(",
"self",
",",
"legend_position",
")",
":",
"if",
"legend_position",
":",
"self",
".",
"legend_position",
"=",
"quote",
"(",
"legend_position",
")",
"else",
":",
"self",
".",
"legend_position",
"=",
"None"
] | 25234bb63127a7e5e057c0b98ab841f3f1d93b21 |
train | Chart.data_class_detection | Determines the appropriate data encoding type to give satisfactory
resolution (http://code.google.com/apis/chart/#chart_data). | pygooglechart.py | def data_class_detection(self, data):
"""Determines the appropriate data encoding type to give satisfactory
resolution (http://code.google.com/apis/chart/#chart_data).
"""
assert(isinstance(data, list) or isinstance(data, tuple))
if not isinstance(self, (LineChart, BarChart, Scat... | def data_class_detection(self, data):
"""Determines the appropriate data encoding type to give satisfactory
resolution (http://code.google.com/apis/chart/#chart_data).
"""
assert(isinstance(data, list) or isinstance(data, tuple))
if not isinstance(self, (LineChart, BarChart, Scat... | [
"Determines",
"the",
"appropriate",
"data",
"encoding",
"type",
"to",
"give",
"satisfactory",
"resolution",
"(",
"http",
":",
"//",
"code",
".",
"google",
".",
"com",
"/",
"apis",
"/",
"chart",
"/",
"#chart_data",
")",
"."
] | gak/pygooglechart | python | https://github.com/gak/pygooglechart/blob/25234bb63127a7e5e057c0b98ab841f3f1d93b21/pygooglechart.py#L527-L544 | [
"def",
"data_class_detection",
"(",
"self",
",",
"data",
")",
":",
"assert",
"(",
"isinstance",
"(",
"data",
",",
"list",
")",
"or",
"isinstance",
"(",
"data",
",",
"tuple",
")",
")",
"if",
"not",
"isinstance",
"(",
"self",
",",
"(",
"LineChart",
",",
... | 25234bb63127a7e5e057c0b98ab841f3f1d93b21 |
train | Chart.data_x_range | Return a 2-tuple giving the minimum and maximum x-axis
data range. | pygooglechart.py | def data_x_range(self):
"""Return a 2-tuple giving the minimum and maximum x-axis
data range.
"""
try:
lower = min([min(self._filter_none(s))
for type, s in self.annotated_data()
if type == 'x'])
upper = max([max(s... | def data_x_range(self):
"""Return a 2-tuple giving the minimum and maximum x-axis
data range.
"""
try:
lower = min([min(self._filter_none(s))
for type, s in self.annotated_data()
if type == 'x'])
upper = max([max(s... | [
"Return",
"a",
"2",
"-",
"tuple",
"giving",
"the",
"minimum",
"and",
"maximum",
"x",
"-",
"axis",
"data",
"range",
"."
] | gak/pygooglechart | python | https://github.com/gak/pygooglechart/blob/25234bb63127a7e5e057c0b98ab841f3f1d93b21/pygooglechart.py#L549-L562 | [
"def",
"data_x_range",
"(",
"self",
")",
":",
"try",
":",
"lower",
"=",
"min",
"(",
"[",
"min",
"(",
"self",
".",
"_filter_none",
"(",
"s",
")",
")",
"for",
"type",
",",
"s",
"in",
"self",
".",
"annotated_data",
"(",
")",
"if",
"type",
"==",
"'x'... | 25234bb63127a7e5e057c0b98ab841f3f1d93b21 |
train | Chart.scaled_data | Scale `self.data` as appropriate for the given data encoding
(data_class) and return it.
An optional `y_range` -- a 2-tuple (lower, upper) -- can be
given to specify the y-axis bounds. If not given, the range is
inferred from the data: (0, <max-value>) presuming no negative
valu... | pygooglechart.py | def scaled_data(self, data_class, x_range=None, y_range=None):
"""Scale `self.data` as appropriate for the given data encoding
(data_class) and return it.
An optional `y_range` -- a 2-tuple (lower, upper) -- can be
given to specify the y-axis bounds. If not given, the range is
i... | def scaled_data(self, data_class, x_range=None, y_range=None):
"""Scale `self.data` as appropriate for the given data encoding
(data_class) and return it.
An optional `y_range` -- a 2-tuple (lower, upper) -- can be
given to specify the y-axis bounds. If not given, the range is
i... | [
"Scale",
"self",
".",
"data",
"as",
"appropriate",
"for",
"the",
"given",
"data",
"encoding",
"(",
"data_class",
")",
"and",
"return",
"it",
"."
] | gak/pygooglechart | python | https://github.com/gak/pygooglechart/blob/25234bb63127a7e5e057c0b98ab841f3f1d93b21/pygooglechart.py#L579-L625 | [
"def",
"scaled_data",
"(",
"self",
",",
"data_class",
",",
"x_range",
"=",
"None",
",",
"y_range",
"=",
"None",
")",
":",
"self",
".",
"scaled_data_class",
"=",
"data_class",
"# Determine the x-axis range for scaling.",
"if",
"x_range",
"is",
"None",
":",
"x_ran... | 25234bb63127a7e5e057c0b98ab841f3f1d93b21 |
train | MapChart.set_codes | Set the country code map for the data.
Codes given in a list.
i.e. DE - Germany
AT - Austria
US - United States | pygooglechart.py | def set_codes(self, codes):
'''Set the country code map for the data.
Codes given in a list.
i.e. DE - Germany
AT - Austria
US - United States
'''
codemap = ''
for cc in codes:
cc = cc.upper()
if cc in self.__cc... | def set_codes(self, codes):
'''Set the country code map for the data.
Codes given in a list.
i.e. DE - Germany
AT - Austria
US - United States
'''
codemap = ''
for cc in codes:
cc = cc.upper()
if cc in self.__cc... | [
"Set",
"the",
"country",
"code",
"map",
"for",
"the",
"data",
".",
"Codes",
"given",
"in",
"a",
"list",
"."
] | gak/pygooglechart | python | https://github.com/gak/pygooglechart/blob/25234bb63127a7e5e057c0b98ab841f3f1d93b21/pygooglechart.py#L1021-L1039 | [
"def",
"set_codes",
"(",
"self",
",",
"codes",
")",
":",
"codemap",
"=",
"''",
"for",
"cc",
"in",
"codes",
":",
"cc",
"=",
"cc",
".",
"upper",
"(",
")",
"if",
"cc",
"in",
"self",
".",
"__ccodes",
":",
"codemap",
"+=",
"cc",
"else",
":",
"raise",
... | 25234bb63127a7e5e057c0b98ab841f3f1d93b21 |
train | MapChart.set_geo_area | Sets the geo area for the map.
* africa
* asia
* europe
* middle_east
* south_america
* usa
* world | pygooglechart.py | def set_geo_area(self, area):
'''Sets the geo area for the map.
* africa
* asia
* europe
* middle_east
* south_america
* usa
* world
'''
if area in self.__areas:
self.geo_area = area
else:
raise Unk... | def set_geo_area(self, area):
'''Sets the geo area for the map.
* africa
* asia
* europe
* middle_east
* south_america
* usa
* world
'''
if area in self.__areas:
self.geo_area = area
else:
raise Unk... | [
"Sets",
"the",
"geo",
"area",
"for",
"the",
"map",
"."
] | gak/pygooglechart | python | https://github.com/gak/pygooglechart/blob/25234bb63127a7e5e057c0b98ab841f3f1d93b21/pygooglechart.py#L1041-L1056 | [
"def",
"set_geo_area",
"(",
"self",
",",
"area",
")",
":",
"if",
"area",
"in",
"self",
".",
"__areas",
":",
"self",
".",
"geo_area",
"=",
"area",
"else",
":",
"raise",
"UnknownChartType",
"(",
"'Unknown chart type for maps: %s'",
"%",
"area",
")"
] | 25234bb63127a7e5e057c0b98ab841f3f1d93b21 |
train | MapChart.add_data_dict | Sets the data and country codes via a dictionary.
i.e. {'DE': 50, 'GB': 30, 'AT': 70} | pygooglechart.py | def add_data_dict(self, datadict):
'''Sets the data and country codes via a dictionary.
i.e. {'DE': 50, 'GB': 30, 'AT': 70}
'''
self.set_codes(list(datadict.keys()))
self.add_data(list(datadict.values())) | def add_data_dict(self, datadict):
'''Sets the data and country codes via a dictionary.
i.e. {'DE': 50, 'GB': 30, 'AT': 70}
'''
self.set_codes(list(datadict.keys()))
self.add_data(list(datadict.values())) | [
"Sets",
"the",
"data",
"and",
"country",
"codes",
"via",
"a",
"dictionary",
"."
] | gak/pygooglechart | python | https://github.com/gak/pygooglechart/blob/25234bb63127a7e5e057c0b98ab841f3f1d93b21/pygooglechart.py#L1065-L1072 | [
"def",
"add_data_dict",
"(",
"self",
",",
"datadict",
")",
":",
"self",
".",
"set_codes",
"(",
"list",
"(",
"datadict",
".",
"keys",
"(",
")",
")",
")",
"self",
".",
"add_data",
"(",
"list",
"(",
"datadict",
".",
"values",
"(",
")",
")",
")"
] | 25234bb63127a7e5e057c0b98ab841f3f1d93b21 |
train | can_cast_to | 5.4.3 Datatype Constraints
Determine whether "a value of the lexical form of n can be cast to the target type v per
XPath Functions 3.1 section 19 Casting[xpath-functions]." | pyshex/utils/datatype_utils.py | def can_cast_to(v: Literal, dt: str) -> bool:
""" 5.4.3 Datatype Constraints
Determine whether "a value of the lexical form of n can be cast to the target type v per
XPath Functions 3.1 section 19 Casting[xpath-functions]."
"""
# TODO: rdflib doesn't appear to pay any attention to lengths (e.g. 257... | def can_cast_to(v: Literal, dt: str) -> bool:
""" 5.4.3 Datatype Constraints
Determine whether "a value of the lexical form of n can be cast to the target type v per
XPath Functions 3.1 section 19 Casting[xpath-functions]."
"""
# TODO: rdflib doesn't appear to pay any attention to lengths (e.g. 257... | [
"5",
".",
"4",
".",
"3",
"Datatype",
"Constraints"
] | hsolbrig/PyShEx | python | https://github.com/hsolbrig/PyShEx/blob/9d659cc36e808afd66d4a6d60e8ea21cb12eb744/pyshex/utils/datatype_utils.py#L12-L19 | [
"def",
"can_cast_to",
"(",
"v",
":",
"Literal",
",",
"dt",
":",
"str",
")",
"->",
"bool",
":",
"# TODO: rdflib doesn't appear to pay any attention to lengths (e.g. 257 is a valid XSD.byte)",
"return",
"v",
".",
"value",
"is",
"not",
"None",
"and",
"Literal",
"(",
"s... | 9d659cc36e808afd66d4a6d60e8ea21cb12eb744 |
train | total_digits | 5.4.5 XML Schema Numberic Facet Constraints
totaldigits and fractiondigits constraints on values not derived from xsd:decimal fail. | pyshex/utils/datatype_utils.py | def total_digits(n: Literal) -> Optional[int]:
""" 5.4.5 XML Schema Numberic Facet Constraints
totaldigits and fractiondigits constraints on values not derived from xsd:decimal fail.
"""
return len(str(abs(int(n.value)))) + fraction_digits(n) if is_numeric(n) and n.value is not None else None | def total_digits(n: Literal) -> Optional[int]:
""" 5.4.5 XML Schema Numberic Facet Constraints
totaldigits and fractiondigits constraints on values not derived from xsd:decimal fail.
"""
return len(str(abs(int(n.value)))) + fraction_digits(n) if is_numeric(n) and n.value is not None else None | [
"5",
".",
"4",
".",
"5",
"XML",
"Schema",
"Numberic",
"Facet",
"Constraints"
] | hsolbrig/PyShEx | python | https://github.com/hsolbrig/PyShEx/blob/9d659cc36e808afd66d4a6d60e8ea21cb12eb744/pyshex/utils/datatype_utils.py#L22-L27 | [
"def",
"total_digits",
"(",
"n",
":",
"Literal",
")",
"->",
"Optional",
"[",
"int",
"]",
":",
"return",
"len",
"(",
"str",
"(",
"abs",
"(",
"int",
"(",
"n",
".",
"value",
")",
")",
")",
")",
"+",
"fraction_digits",
"(",
"n",
")",
"if",
"is_numeri... | 9d659cc36e808afd66d4a6d60e8ea21cb12eb744 |
train | fraction_digits | 5.4.5 XML Schema Numeric Facet Constraints
for "fractiondigits" constraints, v is less than or equals the number of digits to the right of the decimal place
in the XML Schema canonical form[xmlschema-2] of the value of n, ignoring trailing zeros. | pyshex/utils/datatype_utils.py | def fraction_digits(n: Literal) -> Optional[int]:
""" 5.4.5 XML Schema Numeric Facet Constraints
for "fractiondigits" constraints, v is less than or equals the number of digits to the right of the decimal place
in the XML Schema canonical form[xmlschema-2] of the value of n, ignoring trailing zeros.
""... | def fraction_digits(n: Literal) -> Optional[int]:
""" 5.4.5 XML Schema Numeric Facet Constraints
for "fractiondigits" constraints, v is less than or equals the number of digits to the right of the decimal place
in the XML Schema canonical form[xmlschema-2] of the value of n, ignoring trailing zeros.
""... | [
"5",
".",
"4",
".",
"5",
"XML",
"Schema",
"Numeric",
"Facet",
"Constraints"
] | hsolbrig/PyShEx | python | https://github.com/hsolbrig/PyShEx/blob/9d659cc36e808afd66d4a6d60e8ea21cb12eb744/pyshex/utils/datatype_utils.py#L30-L40 | [
"def",
"fraction_digits",
"(",
"n",
":",
"Literal",
")",
"->",
"Optional",
"[",
"int",
"]",
":",
"# Note - the last expression below isolates the fractional portion, reverses it (e.g. 017320 --> 023710) and",
"# converts it to an integer and back to a string",
"return",
"None"... | 9d659cc36e808afd66d4a6d60e8ea21cb12eb744 |
train | _map_xpath_flags_to_re | Map `5.6.2 Flags <https://www.w3.org/TR/xpath-functions-31/#flags>`_ to python
:param expr: match pattern
:param xpath_flags: xpath flags
:returns: python flags / modified match pattern | pyshex/utils/datatype_utils.py | def _map_xpath_flags_to_re(expr: str, xpath_flags: str) -> Tuple[int, str]:
""" Map `5.6.2 Flags <https://www.w3.org/TR/xpath-functions-31/#flags>`_ to python
:param expr: match pattern
:param xpath_flags: xpath flags
:returns: python flags / modified match pattern
"""
python_flags: int = 0
... | def _map_xpath_flags_to_re(expr: str, xpath_flags: str) -> Tuple[int, str]:
""" Map `5.6.2 Flags <https://www.w3.org/TR/xpath-functions-31/#flags>`_ to python
:param expr: match pattern
:param xpath_flags: xpath flags
:returns: python flags / modified match pattern
"""
python_flags: int = 0
... | [
"Map",
"5",
".",
"6",
".",
"2",
"Flags",
"<https",
":",
"//",
"www",
".",
"w3",
".",
"org",
"/",
"TR",
"/",
"xpath",
"-",
"functions",
"-",
"31",
"/",
"#flags",
">",
"_",
"to",
"python"
] | hsolbrig/PyShEx | python | https://github.com/hsolbrig/PyShEx/blob/9d659cc36e808afd66d4a6d60e8ea21cb12eb744/pyshex/utils/datatype_utils.py#L61-L84 | [
"def",
"_map_xpath_flags_to_re",
"(",
"expr",
":",
"str",
",",
"xpath_flags",
":",
"str",
")",
"->",
"Tuple",
"[",
"int",
",",
"str",
"]",
":",
"python_flags",
":",
"int",
"=",
"0",
"modified_expr",
"=",
"expr",
"if",
"xpath_flags",
"is",
"None",
":",
... | 9d659cc36e808afd66d4a6d60e8ea21cb12eb744 |
train | map_object_literal | `PyShEx.jsg <https://github.com/hsolbrig/ShExJSG/ShExJSG/ShExJ.jsg>`_ does not add identifying
types to ObjectLiterals. This routine re-identifies the types | pyshex/utils/datatype_utils.py | def map_object_literal(v: Union[str, jsonasobj.JsonObj]) -> ShExJ.ObjectLiteral:
""" `PyShEx.jsg <https://github.com/hsolbrig/ShExJSG/ShExJSG/ShExJ.jsg>`_ does not add identifying
types to ObjectLiterals. This routine re-identifies the types
"""
# TODO: isinstance(v, JSGString) should work here, but it... | def map_object_literal(v: Union[str, jsonasobj.JsonObj]) -> ShExJ.ObjectLiteral:
""" `PyShEx.jsg <https://github.com/hsolbrig/ShExJSG/ShExJSG/ShExJ.jsg>`_ does not add identifying
types to ObjectLiterals. This routine re-identifies the types
"""
# TODO: isinstance(v, JSGString) should work here, but it... | [
"PyShEx",
".",
"jsg",
"<https",
":",
"//",
"github",
".",
"com",
"/",
"hsolbrig",
"/",
"ShExJSG",
"/",
"ShExJSG",
"/",
"ShExJ",
".",
"jsg",
">",
"_",
"does",
"not",
"add",
"identifying",
"types",
"to",
"ObjectLiterals",
".",
"This",
"routine",
"re",
"-... | hsolbrig/PyShEx | python | https://github.com/hsolbrig/PyShEx/blob/9d659cc36e808afd66d4a6d60e8ea21cb12eb744/pyshex/utils/datatype_utils.py#L95-L101 | [
"def",
"map_object_literal",
"(",
"v",
":",
"Union",
"[",
"str",
",",
"jsonasobj",
".",
"JsonObj",
"]",
")",
"->",
"ShExJ",
".",
"ObjectLiteral",
":",
"# TODO: isinstance(v, JSGString) should work here, but it doesn't with IRIREF(http://a.example/v1)",
"return",
"v",
"if"... | 9d659cc36e808afd66d4a6d60e8ea21cb12eb744 |
train | do_enable | Uncomment any lines that start with #import in the .pth file | vext/cmdline/__init__.py | def do_enable():
"""
Uncomment any lines that start with #import in the .pth file
"""
try:
_lines = []
with open(vext_pth, mode='r') as f:
for line in f.readlines():
if line.startswith('#') and line[1:].lstrip().startswith('import '):
_line... | def do_enable():
"""
Uncomment any lines that start with #import in the .pth file
"""
try:
_lines = []
with open(vext_pth, mode='r') as f:
for line in f.readlines():
if line.startswith('#') and line[1:].lstrip().startswith('import '):
_line... | [
"Uncomment",
"any",
"lines",
"that",
"start",
"with",
"#import",
"in",
"the",
".",
"pth",
"file"
] | stuaxo/vext | python | https://github.com/stuaxo/vext/blob/fa98a21ecfbbc1c3d1b84085d69ec42defdd2f69/vext/cmdline/__init__.py#L32-L63 | [
"def",
"do_enable",
"(",
")",
":",
"try",
":",
"_lines",
"=",
"[",
"]",
"with",
"open",
"(",
"vext_pth",
",",
"mode",
"=",
"'r'",
")",
"as",
"f",
":",
"for",
"line",
"in",
"f",
".",
"readlines",
"(",
")",
":",
"if",
"line",
".",
"startswith",
"... | fa98a21ecfbbc1c3d1b84085d69ec42defdd2f69 |
train | do_disable | Comment any lines that start with import in the .pth file | vext/cmdline/__init__.py | def do_disable():
"""
Comment any lines that start with import in the .pth file
"""
from vext import vext_pth
try:
_lines = []
with open(vext_pth, mode='r') as f:
for line in f.readlines():
if not line.startswith('#') and line.startswith('import '):
... | def do_disable():
"""
Comment any lines that start with import in the .pth file
"""
from vext import vext_pth
try:
_lines = []
with open(vext_pth, mode='r') as f:
for line in f.readlines():
if not line.startswith('#') and line.startswith('import '):
... | [
"Comment",
"any",
"lines",
"that",
"start",
"with",
"import",
"in",
"the",
".",
"pth",
"file"
] | stuaxo/vext | python | https://github.com/stuaxo/vext/blob/fa98a21ecfbbc1c3d1b84085d69ec42defdd2f69/vext/cmdline/__init__.py#L67-L99 | [
"def",
"do_disable",
"(",
")",
":",
"from",
"vext",
"import",
"vext_pth",
"try",
":",
"_lines",
"=",
"[",
"]",
"with",
"open",
"(",
"vext_pth",
",",
"mode",
"=",
"'r'",
")",
"as",
"f",
":",
"for",
"line",
"in",
"f",
".",
"readlines",
"(",
")",
":... | fa98a21ecfbbc1c3d1b84085d69ec42defdd2f69 |
train | do_check | Attempt to import everything in the 'test-imports' section of specified
vext_files
:param: list of vext filenames (without paths), '*' matches all.
:return: True if test_imports was successful from all files | vext/cmdline/__init__.py | def do_check(vext_files):
"""
Attempt to import everything in the 'test-imports' section of specified
vext_files
:param: list of vext filenames (without paths), '*' matches all.
:return: True if test_imports was successful from all files
"""
import vext
# not efficient ... but then ther... | def do_check(vext_files):
"""
Attempt to import everything in the 'test-imports' section of specified
vext_files
:param: list of vext filenames (without paths), '*' matches all.
:return: True if test_imports was successful from all files
"""
import vext
# not efficient ... but then ther... | [
"Attempt",
"to",
"import",
"everything",
"in",
"the",
"test",
"-",
"imports",
"section",
"of",
"specified",
"vext_files"
] | stuaxo/vext | python | https://github.com/stuaxo/vext/blob/fa98a21ecfbbc1c3d1b84085d69ec42defdd2f69/vext/cmdline/__init__.py#L116-L148 | [
"def",
"do_check",
"(",
"vext_files",
")",
":",
"import",
"vext",
"# not efficient ... but then there shouldn't be many of these",
"all_specs",
"=",
"set",
"(",
"vext",
".",
"gatekeeper",
".",
"spec_files_flat",
"(",
")",
")",
"if",
"vext_files",
"==",
"[",
"'*'",
... | fa98a21ecfbbc1c3d1b84085d69ec42defdd2f69 |
train | fix_path | Convert path pointing subdirectory of virtualenv site-packages
to system site-packages.
Destination directory must exist for this to work.
>>> fix_path('C:\\some-venv\\Lib\\site-packages\\gnome')
'C:\\Python27\\lib\\site-packages\\gnome' | vext/gatekeeper/__init__.py | def fix_path(p):
"""
Convert path pointing subdirectory of virtualenv site-packages
to system site-packages.
Destination directory must exist for this to work.
>>> fix_path('C:\\some-venv\\Lib\\site-packages\\gnome')
'C:\\Python27\\lib\\site-packages\\gnome'
"""
venv_lib = get_python_l... | def fix_path(p):
"""
Convert path pointing subdirectory of virtualenv site-packages
to system site-packages.
Destination directory must exist for this to work.
>>> fix_path('C:\\some-venv\\Lib\\site-packages\\gnome')
'C:\\Python27\\lib\\site-packages\\gnome'
"""
venv_lib = get_python_l... | [
"Convert",
"path",
"pointing",
"subdirectory",
"of",
"virtualenv",
"site",
"-",
"packages",
"to",
"system",
"site",
"-",
"packages",
"."
] | stuaxo/vext | python | https://github.com/stuaxo/vext/blob/fa98a21ecfbbc1c3d1b84085d69ec42defdd2f69/vext/gatekeeper/__init__.py#L56-L76 | [
"def",
"fix_path",
"(",
"p",
")",
":",
"venv_lib",
"=",
"get_python_lib",
"(",
")",
"if",
"p",
".",
"startswith",
"(",
"venv_lib",
")",
":",
"subdir",
"=",
"p",
"[",
"len",
"(",
"venv_lib",
")",
"+",
"1",
":",
"]",
"for",
"sitedir",
"in",
"getsyssi... | fa98a21ecfbbc1c3d1b84085d69ec42defdd2f69 |
train | fixup_paths | Fixup paths added in .pth file that point to the virtualenv
instead of the system site packages.
In depth: .PTH can execute arbitrary code, which might
manipulate the PATH or sys.path
:return: | vext/gatekeeper/__init__.py | def fixup_paths():
"""
Fixup paths added in .pth file that point to the virtualenv
instead of the system site packages.
In depth: .PTH can execute arbitrary code, which might
manipulate the PATH or sys.path
:return:
"""
original_paths = os.environ.get('PATH', "").split(os.path.pathsep... | def fixup_paths():
"""
Fixup paths added in .pth file that point to the virtualenv
instead of the system site packages.
In depth: .PTH can execute arbitrary code, which might
manipulate the PATH or sys.path
:return:
"""
original_paths = os.environ.get('PATH', "").split(os.path.pathsep... | [
"Fixup",
"paths",
"added",
"in",
".",
"pth",
"file",
"that",
"point",
"to",
"the",
"virtualenv",
"instead",
"of",
"the",
"system",
"site",
"packages",
"."
] | stuaxo/vext | python | https://github.com/stuaxo/vext/blob/fa98a21ecfbbc1c3d1b84085d69ec42defdd2f69/vext/gatekeeper/__init__.py#L80-L120 | [
"def",
"fixup_paths",
"(",
")",
":",
"original_paths",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"'PATH'",
",",
"\"\"",
")",
".",
"split",
"(",
"os",
".",
"path",
".",
"pathsep",
")",
"original_dirs",
"=",
"set",
"(",
"added_dirs",
")",
"yield",
"#... | fa98a21ecfbbc1c3d1b84085d69ec42defdd2f69 |
train | addpackage | Wrapper for site.addpackage
Try and work out which directories are added by
the .pth and add them to the known_dirs set
:param sys_sitedir: system site-packages directory
:param pthfile: path file to add
:param known_dirs: set of known directories | vext/gatekeeper/__init__.py | def addpackage(sys_sitedir, pthfile, known_dirs):
"""
Wrapper for site.addpackage
Try and work out which directories are added by
the .pth and add them to the known_dirs set
:param sys_sitedir: system site-packages directory
:param pthfile: path file to add
:param known_dirs: set of known ... | def addpackage(sys_sitedir, pthfile, known_dirs):
"""
Wrapper for site.addpackage
Try and work out which directories are added by
the .pth and add them to the known_dirs set
:param sys_sitedir: system site-packages directory
:param pthfile: path file to add
:param known_dirs: set of known ... | [
"Wrapper",
"for",
"site",
".",
"addpackage"
] | stuaxo/vext | python | https://github.com/stuaxo/vext/blob/fa98a21ecfbbc1c3d1b84085d69ec42defdd2f69/vext/gatekeeper/__init__.py#L123-L158 | [
"def",
"addpackage",
"(",
"sys_sitedir",
",",
"pthfile",
",",
"known_dirs",
")",
":",
"with",
"open",
"(",
"join",
"(",
"sys_sitedir",
",",
"pthfile",
")",
")",
"as",
"f",
":",
"for",
"n",
",",
"line",
"in",
"enumerate",
"(",
"f",
")",
":",
"if",
"... | fa98a21ecfbbc1c3d1b84085d69ec42defdd2f69 |
train | filename_to_module | convert a filename like html5lib-0.999.egg-info to html5lib | vext/gatekeeper/__init__.py | def filename_to_module(filename):
"""
convert a filename like html5lib-0.999.egg-info to html5lib
"""
find = re.compile(r"^[^.|-]*")
name = re.search(find, filename).group(0)
return name | def filename_to_module(filename):
"""
convert a filename like html5lib-0.999.egg-info to html5lib
"""
find = re.compile(r"^[^.|-]*")
name = re.search(find, filename).group(0)
return name | [
"convert",
"a",
"filename",
"like",
"html5lib",
"-",
"0",
".",
"999",
".",
"egg",
"-",
"info",
"to",
"html5lib"
] | stuaxo/vext | python | https://github.com/stuaxo/vext/blob/fa98a21ecfbbc1c3d1b84085d69ec42defdd2f69/vext/gatekeeper/__init__.py#L166-L172 | [
"def",
"filename_to_module",
"(",
"filename",
")",
":",
"find",
"=",
"re",
".",
"compile",
"(",
"r\"^[^.|-]*\"",
")",
"name",
"=",
"re",
".",
"search",
"(",
"find",
",",
"filename",
")",
".",
"group",
"(",
"0",
")",
"return",
"name"
] | fa98a21ecfbbc1c3d1b84085d69ec42defdd2f69 |
train | init_path | Add any new modules that are directories to the PATH | vext/gatekeeper/__init__.py | def init_path():
"""
Add any new modules that are directories to the PATH
"""
sitedirs = getsyssitepackages()
for sitedir in sitedirs:
env_path = os.environ['PATH'].split(os.pathsep)
for module in allowed_modules:
p = join(sitedir, module)
if isdir(p) and not ... | def init_path():
"""
Add any new modules that are directories to the PATH
"""
sitedirs = getsyssitepackages()
for sitedir in sitedirs:
env_path = os.environ['PATH'].split(os.pathsep)
for module in allowed_modules:
p = join(sitedir, module)
if isdir(p) and not ... | [
"Add",
"any",
"new",
"modules",
"that",
"are",
"directories",
"to",
"the",
"PATH"
] | stuaxo/vext | python | https://github.com/stuaxo/vext/blob/fa98a21ecfbbc1c3d1b84085d69ec42defdd2f69/vext/gatekeeper/__init__.py#L275-L285 | [
"def",
"init_path",
"(",
")",
":",
"sitedirs",
"=",
"getsyssitepackages",
"(",
")",
"for",
"sitedir",
"in",
"sitedirs",
":",
"env_path",
"=",
"os",
".",
"environ",
"[",
"'PATH'",
"]",
".",
"split",
"(",
"os",
".",
"pathsep",
")",
"for",
"module",
"in",... | fa98a21ecfbbc1c3d1b84085d69ec42defdd2f69 |
train | install_importer | If in a virtualenv then load spec files to decide which
modules can be imported from system site-packages and
install path hook. | vext/gatekeeper/__init__.py | def install_importer():
"""
If in a virtualenv then load spec files to decide which
modules can be imported from system site-packages and
install path hook.
"""
logging.debug('install_importer')
if not in_venv():
logging.debug('No virtualenv active py:[%s]', sys.executable)
r... | def install_importer():
"""
If in a virtualenv then load spec files to decide which
modules can be imported from system site-packages and
install path hook.
"""
logging.debug('install_importer')
if not in_venv():
logging.debug('No virtualenv active py:[%s]', sys.executable)
r... | [
"If",
"in",
"a",
"virtualenv",
"then",
"load",
"spec",
"files",
"to",
"decide",
"which",
"modules",
"can",
"be",
"imported",
"from",
"system",
"site",
"-",
"packages",
"and",
"install",
"path",
"hook",
"."
] | stuaxo/vext | python | https://github.com/stuaxo/vext/blob/fa98a21ecfbbc1c3d1b84085d69ec42defdd2f69/vext/gatekeeper/__init__.py#L377-L406 | [
"def",
"install_importer",
"(",
")",
":",
"logging",
".",
"debug",
"(",
"'install_importer'",
")",
"if",
"not",
"in_venv",
"(",
")",
":",
"logging",
".",
"debug",
"(",
"'No virtualenv active py:[%s]'",
",",
"sys",
".",
"executable",
")",
"return",
"False",
"... | fa98a21ecfbbc1c3d1b84085d69ec42defdd2f69 |
train | GateKeeperLoader.load_module | Only lets modules in allowed_modules be loaded, others
will get an ImportError | vext/gatekeeper/__init__.py | def load_module(self, name):
"""
Only lets modules in allowed_modules be loaded, others
will get an ImportError
"""
# Get the name relative to SITEDIR ..
filepath = self.module_info[1]
fullname = splitext( \
relpath(filepath, self.sitedir) \
... | def load_module(self, name):
"""
Only lets modules in allowed_modules be loaded, others
will get an ImportError
"""
# Get the name relative to SITEDIR ..
filepath = self.module_info[1]
fullname = splitext( \
relpath(filepath, self.sitedir) \
... | [
"Only",
"lets",
"modules",
"in",
"allowed_modules",
"be",
"loaded",
"others",
"will",
"get",
"an",
"ImportError"
] | stuaxo/vext | python | https://github.com/stuaxo/vext/blob/fa98a21ecfbbc1c3d1b84085d69ec42defdd2f69/vext/gatekeeper/__init__.py#L184-L215 | [
"def",
"load_module",
"(",
"self",
",",
"name",
")",
":",
"# Get the name relative to SITEDIR ..",
"filepath",
"=",
"self",
".",
"module_info",
"[",
"1",
"]",
"fullname",
"=",
"splitext",
"(",
"relpath",
"(",
"filepath",
",",
"self",
".",
"sitedir",
")",
")"... | fa98a21ecfbbc1c3d1b84085d69ec42defdd2f69 |
train | extra_paths | :return: extra paths | vext/helpers/sip.py | def extra_paths():
"""
:return: extra paths
"""
# TODO - this is only tested on Ubuntu for now
# there must be a better way of getting
# the sip directory.
dirs = {}
try:
@vext.env.run_in_syspy
def run(*args):
import sipconfig
config ... | def extra_paths():
"""
:return: extra paths
"""
# TODO - this is only tested on Ubuntu for now
# there must be a better way of getting
# the sip directory.
dirs = {}
try:
@vext.env.run_in_syspy
def run(*args):
import sipconfig
config ... | [
":",
"return",
":",
"extra",
"paths"
] | stuaxo/vext | python | https://github.com/stuaxo/vext/blob/fa98a21ecfbbc1c3d1b84085d69ec42defdd2f69/vext/helpers/sip.py#L10-L30 | [
"def",
"extra_paths",
"(",
")",
":",
"# TODO - this is only tested on Ubuntu for now",
"# there must be a better way of getting",
"# the sip directory.",
"dirs",
"=",
"{",
"}",
"try",
":",
"@",
"vext",
".",
"env",
".",
"run_in_syspy",
"def",
"run",
"(",
"*... | fa98a21ecfbbc1c3d1b84085d69ec42defdd2f69 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.