repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
listlengths
20
707
docstring
stringlengths
3
17.3k
docstring_tokens
listlengths
3
222
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
idx
int64
0
252k
openwisp/netdiff
netdiff/parsers/cnml.py
CnmlParser.parse
def parse(self, data): """ Converts a CNML structure to a NetworkX Graph object which is then returned. """ graph = self._init_graph() # loop over links and create networkx graph # Add only working nodes with working links for link in data.get_inner_links(...
python
def parse(self, data): """ Converts a CNML structure to a NetworkX Graph object which is then returned. """ graph = self._init_graph() # loop over links and create networkx graph # Add only working nodes with working links for link in data.get_inner_links(...
[ "def", "parse", "(", "self", ",", "data", ")", ":", "graph", "=", "self", ".", "_init_graph", "(", ")", "# loop over links and create networkx graph", "# Add only working nodes with working links", "for", "link", "in", "data", ".", "get_inner_links", "(", ")", ":", ...
Converts a CNML structure to a NetworkX Graph object which is then returned.
[ "Converts", "a", "CNML", "structure", "to", "a", "NetworkX", "Graph", "object", "which", "is", "then", "returned", "." ]
f7fda2ed78ad815b8c56eae27dfd193172fb23f5
https://github.com/openwisp/netdiff/blob/f7fda2ed78ad815b8c56eae27dfd193172fb23f5/netdiff/parsers/cnml.py#L34-L50
train
61,500
openwisp/netdiff
netdiff/parsers/olsr.py
OlsrParser.parse
def parse(self, data): """ Converts a dict representing an OLSR 0.6.x topology to a NetworkX Graph object, which is then returned. Additionally checks for "config" data in order to determine version and revision. """ graph = self._init_graph() if 'topology' not in...
python
def parse(self, data): """ Converts a dict representing an OLSR 0.6.x topology to a NetworkX Graph object, which is then returned. Additionally checks for "config" data in order to determine version and revision. """ graph = self._init_graph() if 'topology' not in...
[ "def", "parse", "(", "self", ",", "data", ")", ":", "graph", "=", "self", ".", "_init_graph", "(", ")", "if", "'topology'", "not", "in", "data", ":", "raise", "ParserError", "(", "'Parse error, \"topology\" key not found'", ")", "elif", "'mid'", "not", "in",...
Converts a dict representing an OLSR 0.6.x topology to a NetworkX Graph object, which is then returned. Additionally checks for "config" data in order to determine version and revision.
[ "Converts", "a", "dict", "representing", "an", "OLSR", "0", ".", "6", ".", "x", "topology", "to", "a", "NetworkX", "Graph", "object", "which", "is", "then", "returned", ".", "Additionally", "checks", "for", "config", "data", "in", "order", "to", "determine...
f7fda2ed78ad815b8c56eae27dfd193172fb23f5
https://github.com/openwisp/netdiff/blob/f7fda2ed78ad815b8c56eae27dfd193172fb23f5/netdiff/parsers/olsr.py#L20-L71
train
61,501
openwisp/netdiff
netdiff/parsers/olsr.py
OlsrParser._txtinfo_to_jsoninfo
def _txtinfo_to_jsoninfo(self, data): """ converts olsr 1 txtinfo format to jsoninfo """ # replace INFINITE with inf, which is convertible to float data = data.replace('INFINITE', 'inf') # find interesting section lines = data.split('\n') # process links ...
python
def _txtinfo_to_jsoninfo(self, data): """ converts olsr 1 txtinfo format to jsoninfo """ # replace INFINITE with inf, which is convertible to float data = data.replace('INFINITE', 'inf') # find interesting section lines = data.split('\n') # process links ...
[ "def", "_txtinfo_to_jsoninfo", "(", "self", ",", "data", ")", ":", "# replace INFINITE with inf, which is convertible to float", "data", "=", "data", ".", "replace", "(", "'INFINITE'", ",", "'inf'", ")", "# find interesting section", "lines", "=", "data", ".", "split"...
converts olsr 1 txtinfo format to jsoninfo
[ "converts", "olsr", "1", "txtinfo", "format", "to", "jsoninfo" ]
f7fda2ed78ad815b8c56eae27dfd193172fb23f5
https://github.com/openwisp/netdiff/blob/f7fda2ed78ad815b8c56eae27dfd193172fb23f5/netdiff/parsers/olsr.py#L73-L122
train
61,502
pyupio/changelogs
changelogs/changelogs.py
check_for_launchpad
def check_for_launchpad(old_vendor, name, urls): """Check if the project is hosted on launchpad. :param name: str, name of the project :param urls: set, urls to check. :return: the name of the project on launchpad, or an empty string. """ if old_vendor != "pypi": # XXX This might work f...
python
def check_for_launchpad(old_vendor, name, urls): """Check if the project is hosted on launchpad. :param name: str, name of the project :param urls: set, urls to check. :return: the name of the project on launchpad, or an empty string. """ if old_vendor != "pypi": # XXX This might work f...
[ "def", "check_for_launchpad", "(", "old_vendor", ",", "name", ",", "urls", ")", ":", "if", "old_vendor", "!=", "\"pypi\"", ":", "# XXX This might work for other starting vendors", "# XXX but I didn't check. For now only allow", "# XXX pypi -> launchpad.", "return", "''", "for...
Check if the project is hosted on launchpad. :param name: str, name of the project :param urls: set, urls to check. :return: the name of the project on launchpad, or an empty string.
[ "Check", "if", "the", "project", "is", "hosted", "on", "launchpad", "." ]
0cdb929ac4546c766cd7eef9ae4eb4baaa08f452
https://github.com/pyupio/changelogs/blob/0cdb929ac4546c766cd7eef9ae4eb4baaa08f452/changelogs/changelogs.py#L110-L129
train
61,503
pyupio/changelogs
changelogs/changelogs.py
check_switch_vendor
def check_switch_vendor(old_vendor, name, urls, _depth=0): """Check if the project should switch vendors. E.g project pushed on pypi, but changelog on launchpad. :param name: str, name of the project :param urls: set, urls to check. :return: tuple, (str(new vendor name), str(new project name)) ...
python
def check_switch_vendor(old_vendor, name, urls, _depth=0): """Check if the project should switch vendors. E.g project pushed on pypi, but changelog on launchpad. :param name: str, name of the project :param urls: set, urls to check. :return: tuple, (str(new vendor name), str(new project name)) ...
[ "def", "check_switch_vendor", "(", "old_vendor", ",", "name", ",", "urls", ",", "_depth", "=", "0", ")", ":", "if", "_depth", ">", "3", ":", "# Protect against recursive things vendors here.", "return", "\"\"", "new_name", "=", "check_for_launchpad", "(", "old_ven...
Check if the project should switch vendors. E.g project pushed on pypi, but changelog on launchpad. :param name: str, name of the project :param urls: set, urls to check. :return: tuple, (str(new vendor name), str(new project name))
[ "Check", "if", "the", "project", "should", "switch", "vendors", ".", "E", ".", "g", "project", "pushed", "on", "pypi", "but", "changelog", "on", "launchpad", "." ]
0cdb929ac4546c766cd7eef9ae4eb4baaa08f452
https://github.com/pyupio/changelogs/blob/0cdb929ac4546c766cd7eef9ae4eb4baaa08f452/changelogs/changelogs.py#L132-L146
train
61,504
klen/python-scss
scss/function.py
check_pil
def check_pil(func): """ PIL module checking decorator. """ def __wrapper(*args, **kwargs): root = kwargs.get('root') if not Image: if root and root.get_opt('warn'): warn("Images manipulation require PIL") return 'none' return func(*args, **kwa...
python
def check_pil(func): """ PIL module checking decorator. """ def __wrapper(*args, **kwargs): root = kwargs.get('root') if not Image: if root and root.get_opt('warn'): warn("Images manipulation require PIL") return 'none' return func(*args, **kwa...
[ "def", "check_pil", "(", "func", ")", ":", "def", "__wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "root", "=", "kwargs", ".", "get", "(", "'root'", ")", "if", "not", "Image", ":", "if", "root", "and", "root", ".", "get_opt", "("...
PIL module checking decorator.
[ "PIL", "module", "checking", "decorator", "." ]
34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec
https://github.com/klen/python-scss/blob/34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec/scss/function.py#L54-L64
train
61,505
klen/python-scss
scss/function.py
_mix
def _mix(color1, color2, weight=0.5, **kwargs): """ Mixes two colors together. """ weight = float(weight) c1 = color1.value c2 = color2.value p = 0.0 if weight < 0 else 1.0 if weight > 1 else weight w = p * 2 - 1 a = c1[3] - c2[3] w1 = ((w if (w * a == -1) else (w + a) / (1 + w * a)...
python
def _mix(color1, color2, weight=0.5, **kwargs): """ Mixes two colors together. """ weight = float(weight) c1 = color1.value c2 = color2.value p = 0.0 if weight < 0 else 1.0 if weight > 1 else weight w = p * 2 - 1 a = c1[3] - c2[3] w1 = ((w if (w * a == -1) else (w + a) / (1 + w * a)...
[ "def", "_mix", "(", "color1", ",", "color2", ",", "weight", "=", "0.5", ",", "*", "*", "kwargs", ")", ":", "weight", "=", "float", "(", "weight", ")", "c1", "=", "color1", ".", "value", "c2", "=", "color2", ".", "value", "p", "=", "0.0", "if", ...
Mixes two colors together.
[ "Mixes", "two", "colors", "together", "." ]
34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec
https://github.com/klen/python-scss/blob/34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec/scss/function.py#L100-L114
train
61,506
klen/python-scss
scss/function.py
_hsla
def _hsla(h, s, l, a, **kwargs): """ HSL with alpha channel color value. """ res = colorsys.hls_to_rgb(float(h), float(l), float(s)) return ColorValue([x * 255.0 for x in res] + [float(a)])
python
def _hsla(h, s, l, a, **kwargs): """ HSL with alpha channel color value. """ res = colorsys.hls_to_rgb(float(h), float(l), float(s)) return ColorValue([x * 255.0 for x in res] + [float(a)])
[ "def", "_hsla", "(", "h", ",", "s", ",", "l", ",", "a", ",", "*", "*", "kwargs", ")", ":", "res", "=", "colorsys", ".", "hls_to_rgb", "(", "float", "(", "h", ")", ",", "float", "(", "l", ")", ",", "float", "(", "s", ")", ")", "return", "Col...
HSL with alpha channel color value.
[ "HSL", "with", "alpha", "channel", "color", "value", "." ]
34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec
https://github.com/klen/python-scss/blob/34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec/scss/function.py#L126-L130
train
61,507
klen/python-scss
scss/function.py
_hue
def _hue(color, **kwargs): """ Get hue value of HSL color. """ h = colorsys.rgb_to_hls(*[x / 255.0 for x in color.value[:3]])[0] return NumberValue(h * 360.0)
python
def _hue(color, **kwargs): """ Get hue value of HSL color. """ h = colorsys.rgb_to_hls(*[x / 255.0 for x in color.value[:3]])[0] return NumberValue(h * 360.0)
[ "def", "_hue", "(", "color", ",", "*", "*", "kwargs", ")", ":", "h", "=", "colorsys", ".", "rgb_to_hls", "(", "*", "[", "x", "/", "255.0", "for", "x", "in", "color", ".", "value", "[", ":", "3", "]", "]", ")", "[", "0", "]", "return", "Number...
Get hue value of HSL color.
[ "Get", "hue", "value", "of", "HSL", "color", "." ]
34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec
https://github.com/klen/python-scss/blob/34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec/scss/function.py#L133-L137
train
61,508
klen/python-scss
scss/function.py
_lightness
def _lightness(color, **kwargs): """ Get lightness value of HSL color. """ l = colorsys.rgb_to_hls(*[x / 255.0 for x in color.value[:3]])[1] return NumberValue((l * 100, '%'))
python
def _lightness(color, **kwargs): """ Get lightness value of HSL color. """ l = colorsys.rgb_to_hls(*[x / 255.0 for x in color.value[:3]])[1] return NumberValue((l * 100, '%'))
[ "def", "_lightness", "(", "color", ",", "*", "*", "kwargs", ")", ":", "l", "=", "colorsys", ".", "rgb_to_hls", "(", "*", "[", "x", "/", "255.0", "for", "x", "in", "color", ".", "value", "[", ":", "3", "]", "]", ")", "[", "1", "]", "return", "...
Get lightness value of HSL color.
[ "Get", "lightness", "value", "of", "HSL", "color", "." ]
34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec
https://github.com/klen/python-scss/blob/34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec/scss/function.py#L140-L144
train
61,509
klen/python-scss
scss/function.py
_saturation
def _saturation(color, **kwargs): """ Get saturation value of HSL color. """ s = colorsys.rgb_to_hls(*[x / 255.0 for x in color.value[:3]])[2] return NumberValue((s * 100, '%'))
python
def _saturation(color, **kwargs): """ Get saturation value of HSL color. """ s = colorsys.rgb_to_hls(*[x / 255.0 for x in color.value[:3]])[2] return NumberValue((s * 100, '%'))
[ "def", "_saturation", "(", "color", ",", "*", "*", "kwargs", ")", ":", "s", "=", "colorsys", ".", "rgb_to_hls", "(", "*", "[", "x", "/", "255.0", "for", "x", "in", "color", ".", "value", "[", ":", "3", "]", "]", ")", "[", "2", "]", "return", ...
Get saturation value of HSL color.
[ "Get", "saturation", "value", "of", "HSL", "color", "." ]
34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec
https://github.com/klen/python-scss/blob/34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec/scss/function.py#L147-L151
train
61,510
klen/python-scss
scss/parser.py
load
def load(path, cache=None, precache=False): """ Parse from file. """ parser = Stylesheet(cache) return parser.load(path, precache=precache)
python
def load(path, cache=None, precache=False): """ Parse from file. """ parser = Stylesheet(cache) return parser.load(path, precache=precache)
[ "def", "load", "(", "path", ",", "cache", "=", "None", ",", "precache", "=", "False", ")", ":", "parser", "=", "Stylesheet", "(", "cache", ")", "return", "parser", ".", "load", "(", "path", ",", "precache", "=", "precache", ")" ]
Parse from file.
[ "Parse", "from", "file", "." ]
34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec
https://github.com/klen/python-scss/blob/34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec/scss/parser.py#L392-L396
train
61,511
klen/python-scss
scss/parser.py
Ruleset.parse
def parse(self, target): """ Parse nested rulesets and save it in cache. """ if isinstance(target, ContentNode): if target.name: self.parent = target self.name.parse(self) self.name += target.name target.ruleset....
python
def parse(self, target): """ Parse nested rulesets and save it in cache. """ if isinstance(target, ContentNode): if target.name: self.parent = target self.name.parse(self) self.name += target.name target.ruleset....
[ "def", "parse", "(", "self", ",", "target", ")", ":", "if", "isinstance", "(", "target", ",", "ContentNode", ")", ":", "if", "target", ".", "name", ":", "self", ".", "parent", "=", "target", "self", ".", "name", ".", "parse", "(", "self", ")", "sel...
Parse nested rulesets and save it in cache.
[ "Parse", "nested", "rulesets", "and", "save", "it", "in", "cache", "." ]
34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec
https://github.com/klen/python-scss/blob/34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec/scss/parser.py#L63-L74
train
61,512
klen/python-scss
scss/parser.py
Declaration.parse
def parse(self, target): """ Parse nested declaration. """ if not isinstance(target, Node): parent = ContentNode(None, None, []) parent.parse(target) target = parent super(Declaration, self).parse(target) self.name = str(self.data[0]) ...
python
def parse(self, target): """ Parse nested declaration. """ if not isinstance(target, Node): parent = ContentNode(None, None, []) parent.parse(target) target = parent super(Declaration, self).parse(target) self.name = str(self.data[0]) ...
[ "def", "parse", "(", "self", ",", "target", ")", ":", "if", "not", "isinstance", "(", "target", ",", "Node", ")", ":", "parent", "=", "ContentNode", "(", "None", ",", "None", ",", "[", "]", ")", "parent", ".", "parse", "(", "target", ")", "target",...
Parse nested declaration.
[ "Parse", "nested", "declaration", "." ]
34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec
https://github.com/klen/python-scss/blob/34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec/scss/parser.py#L88-L107
train
61,513
klen/python-scss
scss/parser.py
VarDefinition.parse
def parse(self, target): """ Update root and parent context. """ super(VarDefinition, self).parse(target) if isinstance(self.parent, ParseNode): self.parent.ctx.update({self.name: self.expression.value}) self.root.set_var(self)
python
def parse(self, target): """ Update root and parent context. """ super(VarDefinition, self).parse(target) if isinstance(self.parent, ParseNode): self.parent.ctx.update({self.name: self.expression.value}) self.root.set_var(self)
[ "def", "parse", "(", "self", ",", "target", ")", ":", "super", "(", "VarDefinition", ",", "self", ")", ".", "parse", "(", "target", ")", "if", "isinstance", "(", "self", ".", "parent", ",", "ParseNode", ")", ":", "self", ".", "parent", ".", "ctx", ...
Update root and parent context.
[ "Update", "root", "and", "parent", "context", "." ]
34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec
https://github.com/klen/python-scss/blob/34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec/scss/parser.py#L188-L194
train
61,514
klen/python-scss
scss/parser.py
Stylesheet.set_var
def set_var(self, vardef): """ Set variable to global stylesheet context. """ if not(vardef.default and self.cache['ctx'].get(vardef.name)): self.cache['ctx'][vardef.name] = vardef.expression.value
python
def set_var(self, vardef): """ Set variable to global stylesheet context. """ if not(vardef.default and self.cache['ctx'].get(vardef.name)): self.cache['ctx'][vardef.name] = vardef.expression.value
[ "def", "set_var", "(", "self", ",", "vardef", ")", ":", "if", "not", "(", "vardef", ".", "default", "and", "self", ".", "cache", "[", "'ctx'", "]", ".", "get", "(", "vardef", ".", "name", ")", ")", ":", "self", ".", "cache", "[", "'ctx'", "]", ...
Set variable to global stylesheet context.
[ "Set", "variable", "to", "global", "stylesheet", "context", "." ]
34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec
https://github.com/klen/python-scss/blob/34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec/scss/parser.py#L292-L296
train
61,515
klen/python-scss
scss/parser.py
Stylesheet.set_opt
def set_opt(self, name, value): """ Set option. """ self.cache['opts'][name] = value if name == 'compress': self.cache['delims'] = self.def_delims if not value else ( '', '', '')
python
def set_opt(self, name, value): """ Set option. """ self.cache['opts'][name] = value if name == 'compress': self.cache['delims'] = self.def_delims if not value else ( '', '', '')
[ "def", "set_opt", "(", "self", ",", "name", ",", "value", ")", ":", "self", ".", "cache", "[", "'opts'", "]", "[", "name", "]", "=", "value", "if", "name", "==", "'compress'", ":", "self", ".", "cache", "[", "'delims'", "]", "=", "self", ".", "de...
Set option.
[ "Set", "option", "." ]
34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec
https://github.com/klen/python-scss/blob/34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec/scss/parser.py#L298-L307
train
61,516
klen/python-scss
scss/parser.py
Stylesheet.update
def update(self, cache): """ Update self cache from other. """ self.cache['delims'] = cache.get('delims') self.cache['opts'].update(cache.get('opts')) self.cache['rset'].update(cache.get('rset')) self.cache['mix'].update(cache.get('mix')) map(self.set_var, cache['...
python
def update(self, cache): """ Update self cache from other. """ self.cache['delims'] = cache.get('delims') self.cache['opts'].update(cache.get('opts')) self.cache['rset'].update(cache.get('rset')) self.cache['mix'].update(cache.get('mix')) map(self.set_var, cache['...
[ "def", "update", "(", "self", ",", "cache", ")", ":", "self", ".", "cache", "[", "'delims'", "]", "=", "cache", ".", "get", "(", "'delims'", ")", "self", ".", "cache", "[", "'opts'", "]", ".", "update", "(", "cache", ".", "get", "(", "'opts'", ")...
Update self cache from other.
[ "Update", "self", "cache", "from", "other", "." ]
34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec
https://github.com/klen/python-scss/blob/34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec/scss/parser.py#L314-L321
train
61,517
klen/python-scss
scss/parser.py
Stylesheet.scan
def scan(src): """ Scan scss from string and return nodes. """ assert isinstance(src, (unicode_, bytes_)) try: nodes = STYLESHEET.parseString(src, parseAll=True) return nodes except ParseBaseException: err = sys.exc_info()[1] print(...
python
def scan(src): """ Scan scss from string and return nodes. """ assert isinstance(src, (unicode_, bytes_)) try: nodes = STYLESHEET.parseString(src, parseAll=True) return nodes except ParseBaseException: err = sys.exc_info()[1] print(...
[ "def", "scan", "(", "src", ")", ":", "assert", "isinstance", "(", "src", ",", "(", "unicode_", ",", "bytes_", ")", ")", "try", ":", "nodes", "=", "STYLESHEET", ".", "parseString", "(", "src", ",", "parseAll", "=", "True", ")", "return", "nodes", "exc...
Scan scss from string and return nodes.
[ "Scan", "scss", "from", "string", "and", "return", "nodes", "." ]
34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec
https://github.com/klen/python-scss/blob/34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec/scss/parser.py#L324-L336
train
61,518
klen/python-scss
scss/parser.py
Stylesheet.loads
def loads(self, src): """ Compile css from scss string. """ assert isinstance(src, (unicode_, bytes_)) nodes = self.scan(src.strip()) self.parse(nodes) return ''.join(map(str, nodes))
python
def loads(self, src): """ Compile css from scss string. """ assert isinstance(src, (unicode_, bytes_)) nodes = self.scan(src.strip()) self.parse(nodes) return ''.join(map(str, nodes))
[ "def", "loads", "(", "self", ",", "src", ")", ":", "assert", "isinstance", "(", "src", ",", "(", "unicode_", ",", "bytes_", ")", ")", "nodes", "=", "self", ".", "scan", "(", "src", ".", "strip", "(", ")", ")", "self", ".", "parse", "(", "nodes", ...
Compile css from scss string.
[ "Compile", "css", "from", "scss", "string", "." ]
34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec
https://github.com/klen/python-scss/blob/34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec/scss/parser.py#L343-L349
train
61,519
klen/python-scss
scss/parser.py
Stylesheet.load
def load(self, f, precache=None): """ Compile scss from file. File is string path of file object. """ precache = precache or self.get_opt('cache') or False nodes = None if isinstance(f, file_): path = os.path.abspath(f.name) else: path...
python
def load(self, f, precache=None): """ Compile scss from file. File is string path of file object. """ precache = precache or self.get_opt('cache') or False nodes = None if isinstance(f, file_): path = os.path.abspath(f.name) else: path...
[ "def", "load", "(", "self", ",", "f", ",", "precache", "=", "None", ")", ":", "precache", "=", "precache", "or", "self", ".", "get_opt", "(", "'cache'", ")", "or", "False", "nodes", "=", "None", "if", "isinstance", "(", "f", ",", "file_", ")", ":",...
Compile scss from file. File is string path of file object.
[ "Compile", "scss", "from", "file", ".", "File", "is", "string", "path", "of", "file", "object", "." ]
34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec
https://github.com/klen/python-scss/blob/34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec/scss/parser.py#L351-L382
train
61,520
openego/ego.io
egoio/tools/config.py
load_config
def load_config(filename, filepath=''): """ Loads config file Parameters ---------- filename: str Filename of config file (incl. file extension filepath: str Absolute path to directory of desired config file """ FILE = path.join(filepath, filename) try: cfg...
python
def load_config(filename, filepath=''): """ Loads config file Parameters ---------- filename: str Filename of config file (incl. file extension filepath: str Absolute path to directory of desired config file """ FILE = path.join(filepath, filename) try: cfg...
[ "def", "load_config", "(", "filename", ",", "filepath", "=", "''", ")", ":", "FILE", "=", "path", ".", "join", "(", "filepath", ",", "filename", ")", "try", ":", "cfg", ".", "read", "(", "FILE", ")", "global", "_loaded", "_loaded", "=", "True", "exce...
Loads config file Parameters ---------- filename: str Filename of config file (incl. file extension filepath: str Absolute path to directory of desired config file
[ "Loads", "config", "file" ]
35c472914ee62eff37ddb8e69be3d83276cf2d42
https://github.com/openego/ego.io/blob/35c472914ee62eff37ddb8e69be3d83276cf2d42/egoio/tools/config.py#L37-L56
train
61,521
NeelShah18/emot
emot/core.py
emoji
def emoji(string): '''emot.emoji is use to detect emoji from text >>> text = "I love python 👨 :-)" >>> emot.emoji(text) >>> {'value': ['👨'], 'mean': [':man:'], 'location': [[14, 14]], 'flag': True} ''' __entities = {} __value = [] __mean = [] __location = [] flag =...
python
def emoji(string): '''emot.emoji is use to detect emoji from text >>> text = "I love python 👨 :-)" >>> emot.emoji(text) >>> {'value': ['👨'], 'mean': [':man:'], 'location': [[14, 14]], 'flag': True} ''' __entities = {} __value = [] __mean = [] __location = [] flag =...
[ "def", "emoji", "(", "string", ")", ":", "__entities", "=", "{", "}", "__value", "=", "[", "]", "__mean", "=", "[", "]", "__location", "=", "[", "]", "flag", "=", "True", "try", ":", "pro_string", "=", "str", "(", "string", ")", "for", "pos", ","...
emot.emoji is use to detect emoji from text >>> text = "I love python 👨 :-)" >>> emot.emoji(text) >>> {'value': ['👨'], 'mean': [':man:'], 'location': [[14, 14]], 'flag': True}
[ "emot", ".", "emoji", "is", "use", "to", "detect", "emoji", "from", "text" ]
e0db2c7ebc033f232652f20c5466d27bfebe02bd
https://github.com/NeelShah18/emot/blob/e0db2c7ebc033f232652f20c5466d27bfebe02bd/emot/core.py#L17-L55
train
61,522
NeelShah18/emot
emot/core.py
emoticons
def emoticons(string): '''emot.emoticons is use to detect emoticons from text >>> text = "I love python 👨 :-)" >>> emot.emoticons(text) >>> {'value': [':-)'], 'location': [[16, 19]], 'mean': ['Happy face smiley'], 'flag': True} ''' __entities = [] flag = True try: p...
python
def emoticons(string): '''emot.emoticons is use to detect emoticons from text >>> text = "I love python 👨 :-)" >>> emot.emoticons(text) >>> {'value': [':-)'], 'location': [[16, 19]], 'mean': ['Happy face smiley'], 'flag': True} ''' __entities = [] flag = True try: p...
[ "def", "emoticons", "(", "string", ")", ":", "__entities", "=", "[", "]", "flag", "=", "True", "try", ":", "pattern", "=", "u'('", "+", "u'|'", ".", "join", "(", "k", "for", "k", "in", "emo_unicode", ".", "EMOTICONS", ")", "+", "u')'", "__entities", ...
emot.emoticons is use to detect emoticons from text >>> text = "I love python 👨 :-)" >>> emot.emoticons(text) >>> {'value': [':-)'], 'location': [[16, 19]], 'mean': ['Happy face smiley'], 'flag': True}
[ "emot", ".", "emoticons", "is", "use", "to", "detect", "emoticons", "from", "text" ]
e0db2c7ebc033f232652f20c5466d27bfebe02bd
https://github.com/NeelShah18/emot/blob/e0db2c7ebc033f232652f20c5466d27bfebe02bd/emot/core.py#L57-L93
train
61,523
insynchq/flask-googlelogin
flask_googlelogin.py
GoogleLogin.init_app
def init_app(self, app, add_context_processor=True): """ Initialize with app configuration """ # Check if login manager has been initialized if not hasattr(app, 'login_manager'): self.login_manager.init_app( app, add_context_processor=...
python
def init_app(self, app, add_context_processor=True): """ Initialize with app configuration """ # Check if login manager has been initialized if not hasattr(app, 'login_manager'): self.login_manager.init_app( app, add_context_processor=...
[ "def", "init_app", "(", "self", ",", "app", ",", "add_context_processor", "=", "True", ")", ":", "# Check if login manager has been initialized", "if", "not", "hasattr", "(", "app", ",", "'login_manager'", ")", ":", "self", ".", "login_manager", ".", "init_app", ...
Initialize with app configuration
[ "Initialize", "with", "app", "configuration" ]
67346d232414fdba7283f516cb7540d41134d175
https://github.com/insynchq/flask-googlelogin/blob/67346d232414fdba7283f516cb7540d41134d175/flask_googlelogin.py#L39-L55
train
61,524
insynchq/flask-googlelogin
flask_googlelogin.py
GoogleLogin.login_url
def login_url(self, params=None, **kwargs): """ Return login url with params encoded in state Available Google auth server params: response_type: code, token prompt: none, select_account, consent approval_prompt: force, auto access_type: online, offline s...
python
def login_url(self, params=None, **kwargs): """ Return login url with params encoded in state Available Google auth server params: response_type: code, token prompt: none, select_account, consent approval_prompt: force, auto access_type: online, offline s...
[ "def", "login_url", "(", "self", ",", "params", "=", "None", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "setdefault", "(", "'response_type'", ",", "'code'", ")", "kwargs", ".", "setdefault", "(", "'access_type'", ",", "'online'", ")", "if", "'prom...
Return login url with params encoded in state Available Google auth server params: response_type: code, token prompt: none, select_account, consent approval_prompt: force, auto access_type: online, offline scopes: string (separated with commas) or list redirect_u...
[ "Return", "login", "url", "with", "params", "encoded", "in", "state" ]
67346d232414fdba7283f516cb7540d41134d175
https://github.com/insynchq/flask-googlelogin/blob/67346d232414fdba7283f516cb7540d41134d175/flask_googlelogin.py#L88-L119
train
61,525
insynchq/flask-googlelogin
flask_googlelogin.py
GoogleLogin.unauthorized_callback
def unauthorized_callback(self): """ Redirect to login url with next param set as request.url """ return redirect(self.login_url(params=dict(next=request.url)))
python
def unauthorized_callback(self): """ Redirect to login url with next param set as request.url """ return redirect(self.login_url(params=dict(next=request.url)))
[ "def", "unauthorized_callback", "(", "self", ")", ":", "return", "redirect", "(", "self", ".", "login_url", "(", "params", "=", "dict", "(", "next", "=", "request", ".", "url", ")", ")", ")" ]
Redirect to login url with next param set as request.url
[ "Redirect", "to", "login", "url", "with", "next", "param", "set", "as", "request", ".", "url" ]
67346d232414fdba7283f516cb7540d41134d175
https://github.com/insynchq/flask-googlelogin/blob/67346d232414fdba7283f516cb7540d41134d175/flask_googlelogin.py#L121-L125
train
61,526
insynchq/flask-googlelogin
flask_googlelogin.py
GoogleLogin.get_access_token
def get_access_token(self, refresh_token): """ Use a refresh token to obtain a new access token """ token = requests.post(GOOGLE_OAUTH2_TOKEN_URL, data=dict( refresh_token=refresh_token, grant_type='refresh_token', client_id=self.client_id, ...
python
def get_access_token(self, refresh_token): """ Use a refresh token to obtain a new access token """ token = requests.post(GOOGLE_OAUTH2_TOKEN_URL, data=dict( refresh_token=refresh_token, grant_type='refresh_token', client_id=self.client_id, ...
[ "def", "get_access_token", "(", "self", ",", "refresh_token", ")", ":", "token", "=", "requests", ".", "post", "(", "GOOGLE_OAUTH2_TOKEN_URL", ",", "data", "=", "dict", "(", "refresh_token", "=", "refresh_token", ",", "grant_type", "=", "'refresh_token'", ",", ...
Use a refresh token to obtain a new access token
[ "Use", "a", "refresh", "token", "to", "obtain", "a", "new", "access", "token" ]
67346d232414fdba7283f516cb7540d41134d175
https://github.com/insynchq/flask-googlelogin/blob/67346d232414fdba7283f516cb7540d41134d175/flask_googlelogin.py#L151-L166
train
61,527
insynchq/flask-googlelogin
flask_googlelogin.py
GoogleLogin.oauth2callback
def oauth2callback(self, view_func): """ Decorator for OAuth2 callback. Calls `GoogleLogin.login` then passes results to `view_func`. """ @wraps(view_func) def decorated(*args, **kwargs): params = {} # Check sig if 'state' in request....
python
def oauth2callback(self, view_func): """ Decorator for OAuth2 callback. Calls `GoogleLogin.login` then passes results to `view_func`. """ @wraps(view_func) def decorated(*args, **kwargs): params = {} # Check sig if 'state' in request....
[ "def", "oauth2callback", "(", "self", ",", "view_func", ")", ":", "@", "wraps", "(", "view_func", ")", "def", "decorated", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "params", "=", "{", "}", "# Check sig", "if", "'state'", "in", "request", ...
Decorator for OAuth2 callback. Calls `GoogleLogin.login` then passes results to `view_func`.
[ "Decorator", "for", "OAuth2", "callback", ".", "Calls", "GoogleLogin", ".", "login", "then", "passes", "results", "to", "view_func", "." ]
67346d232414fdba7283f516cb7540d41134d175
https://github.com/insynchq/flask-googlelogin/blob/67346d232414fdba7283f516cb7540d41134d175/flask_googlelogin.py#L168-L214
train
61,528
klen/python-scss
scss/tool.py
complete
def complete(text, state): """ Auto complete scss constructions in interactive mode. """ for cmd in COMMANDS: if cmd.startswith(text): if not state: return cmd else: state -= 1
python
def complete(text, state): """ Auto complete scss constructions in interactive mode. """ for cmd in COMMANDS: if cmd.startswith(text): if not state: return cmd else: state -= 1
[ "def", "complete", "(", "text", ",", "state", ")", ":", "for", "cmd", "in", "COMMANDS", ":", "if", "cmd", ".", "startswith", "(", "text", ")", ":", "if", "not", "state", ":", "return", "cmd", "else", ":", "state", "-=", "1" ]
Auto complete scss constructions in interactive mode.
[ "Auto", "complete", "scss", "constructions", "in", "interactive", "mode", "." ]
34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec
https://github.com/klen/python-scss/blob/34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec/scss/tool.py#L16-L23
train
61,529
ulule/django-linguist
linguist/fields/__init__.py
Linguist.validate_args
def validate_args(self): """ Validates arguments. """ from ..mixins import ModelMixin for arg in ("instance", "decider", "identifier", "fields", "default_language"): if getattr(self, arg) is None: raise AttributeError("%s must not be None" % arg) ...
python
def validate_args(self): """ Validates arguments. """ from ..mixins import ModelMixin for arg in ("instance", "decider", "identifier", "fields", "default_language"): if getattr(self, arg) is None: raise AttributeError("%s must not be None" % arg) ...
[ "def", "validate_args", "(", "self", ")", ":", "from", ".", ".", "mixins", "import", "ModelMixin", "for", "arg", "in", "(", "\"instance\"", ",", "\"decider\"", ",", "\"identifier\"", ",", "\"fields\"", ",", "\"default_language\"", ")", ":", "if", "getattr", ...
Validates arguments.
[ "Validates", "arguments", "." ]
d2b95a6ab921039d56d5eeb352badfe5be9e8f77
https://github.com/ulule/django-linguist/blob/d2b95a6ab921039d56d5eeb352badfe5be9e8f77/linguist/fields/__init__.py#L40-L56
train
61,530
ulule/django-linguist
linguist/fields/__init__.py
Linguist.active_language
def active_language(self): """ Returns active language. """ # Current instance language (if user uses activate_language() method) if self._language is not None: return self._language # Current site language (translation.get_language()) current = utils...
python
def active_language(self): """ Returns active language. """ # Current instance language (if user uses activate_language() method) if self._language is not None: return self._language # Current site language (translation.get_language()) current = utils...
[ "def", "active_language", "(", "self", ")", ":", "# Current instance language (if user uses activate_language() method)", "if", "self", ".", "_language", "is", "not", "None", ":", "return", "self", ".", "_language", "# Current site language (translation.get_language())", "cur...
Returns active language.
[ "Returns", "active", "language", "." ]
d2b95a6ab921039d56d5eeb352badfe5be9e8f77
https://github.com/ulule/django-linguist/blob/d2b95a6ab921039d56d5eeb352badfe5be9e8f77/linguist/fields/__init__.py#L59-L73
train
61,531
ulule/django-linguist
linguist/fields/__init__.py
Linguist.translation_instances
def translation_instances(self): """ Returns translation instances. """ return [ instance for k, v in six.iteritems(self.instance._linguist_translations) for instance in v.values() ]
python
def translation_instances(self): """ Returns translation instances. """ return [ instance for k, v in six.iteritems(self.instance._linguist_translations) for instance in v.values() ]
[ "def", "translation_instances", "(", "self", ")", ":", "return", "[", "instance", "for", "k", ",", "v", "in", "six", ".", "iteritems", "(", "self", ".", "instance", ".", "_linguist_translations", ")", "for", "instance", "in", "v", ".", "values", "(", ")"...
Returns translation instances.
[ "Returns", "translation", "instances", "." ]
d2b95a6ab921039d56d5eeb352badfe5be9e8f77
https://github.com/ulule/django-linguist/blob/d2b95a6ab921039d56d5eeb352badfe5be9e8f77/linguist/fields/__init__.py#L128-L136
train
61,532
ulule/django-linguist
linguist/fields/__init__.py
Linguist.get_cache
def get_cache( self, instance, translation=None, language=None, field_name=None, field_value=None, ): """ Returns translation from cache. """ is_new = bool(instance.pk is None) try: cached_obj = instance._linguist_t...
python
def get_cache( self, instance, translation=None, language=None, field_name=None, field_value=None, ): """ Returns translation from cache. """ is_new = bool(instance.pk is None) try: cached_obj = instance._linguist_t...
[ "def", "get_cache", "(", "self", ",", "instance", ",", "translation", "=", "None", ",", "language", "=", "None", ",", "field_name", "=", "None", ",", "field_value", "=", "None", ",", ")", ":", "is_new", "=", "bool", "(", "instance", ".", "pk", "is", ...
Returns translation from cache.
[ "Returns", "translation", "from", "cache", "." ]
d2b95a6ab921039d56d5eeb352badfe5be9e8f77
https://github.com/ulule/django-linguist/blob/d2b95a6ab921039d56d5eeb352badfe5be9e8f77/linguist/fields/__init__.py#L145-L196
train
61,533
ulule/django-linguist
linguist/fields/__init__.py
Linguist.set_cache
def set_cache( self, instance=None, translation=None, language=None, field_name=None, field_value=None, ): """ Add a new translation into the cache. """ if instance is not None and translation is not None: cached_obj = Cache...
python
def set_cache( self, instance=None, translation=None, language=None, field_name=None, field_value=None, ): """ Add a new translation into the cache. """ if instance is not None and translation is not None: cached_obj = Cache...
[ "def", "set_cache", "(", "self", ",", "instance", "=", "None", ",", "translation", "=", "None", ",", "language", "=", "None", ",", "field_name", "=", "None", ",", "field_value", "=", "None", ",", ")", ":", "if", "instance", "is", "not", "None", "and", ...
Add a new translation into the cache.
[ "Add", "a", "new", "translation", "into", "the", "cache", "." ]
d2b95a6ab921039d56d5eeb352badfe5be9e8f77
https://github.com/ulule/django-linguist/blob/d2b95a6ab921039d56d5eeb352badfe5be9e8f77/linguist/fields/__init__.py#L198-L234
train
61,534
ulule/django-linguist
linguist/mixins.py
QuerySetMixin._filter_or_exclude
def _filter_or_exclude(self, negate, *args, **kwargs): """ Overrides default behavior to handle linguist fields. """ from .models import Translation new_args = self.get_cleaned_args(args) new_kwargs = self.get_cleaned_kwargs(kwargs) translation_args = self.get_t...
python
def _filter_or_exclude(self, negate, *args, **kwargs): """ Overrides default behavior to handle linguist fields. """ from .models import Translation new_args = self.get_cleaned_args(args) new_kwargs = self.get_cleaned_kwargs(kwargs) translation_args = self.get_t...
[ "def", "_filter_or_exclude", "(", "self", ",", "negate", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "from", ".", "models", "import", "Translation", "new_args", "=", "self", ".", "get_cleaned_args", "(", "args", ")", "new_kwargs", "=", "self", "...
Overrides default behavior to handle linguist fields.
[ "Overrides", "default", "behavior", "to", "handle", "linguist", "fields", "." ]
d2b95a6ab921039d56d5eeb352badfe5be9e8f77
https://github.com/ulule/django-linguist/blob/d2b95a6ab921039d56d5eeb352badfe5be9e8f77/linguist/mixins.py#L55-L91
train
61,535
ulule/django-linguist
linguist/mixins.py
QuerySetMixin.has_linguist_kwargs
def has_linguist_kwargs(self, kwargs): """ Parses the given kwargs and returns True if they contain linguist lookups. """ for k in kwargs: if self.is_linguist_lookup(k): return True return False
python
def has_linguist_kwargs(self, kwargs): """ Parses the given kwargs and returns True if they contain linguist lookups. """ for k in kwargs: if self.is_linguist_lookup(k): return True return False
[ "def", "has_linguist_kwargs", "(", "self", ",", "kwargs", ")", ":", "for", "k", "in", "kwargs", ":", "if", "self", ".", "is_linguist_lookup", "(", "k", ")", ":", "return", "True", "return", "False" ]
Parses the given kwargs and returns True if they contain linguist lookups.
[ "Parses", "the", "given", "kwargs", "and", "returns", "True", "if", "they", "contain", "linguist", "lookups", "." ]
d2b95a6ab921039d56d5eeb352badfe5be9e8f77
https://github.com/ulule/django-linguist/blob/d2b95a6ab921039d56d5eeb352badfe5be9e8f77/linguist/mixins.py#L144-L152
train
61,536
ulule/django-linguist
linguist/mixins.py
QuerySetMixin.has_linguist_args
def has_linguist_args(self, args): """ Parses the given args and returns True if they contain linguist lookups. """ linguist_args = [] for arg in args: condition = self._get_linguist_condition(arg) if condition: linguist_args.append...
python
def has_linguist_args(self, args): """ Parses the given args and returns True if they contain linguist lookups. """ linguist_args = [] for arg in args: condition = self._get_linguist_condition(arg) if condition: linguist_args.append...
[ "def", "has_linguist_args", "(", "self", ",", "args", ")", ":", "linguist_args", "=", "[", "]", "for", "arg", "in", "args", ":", "condition", "=", "self", ".", "_get_linguist_condition", "(", "arg", ")", "if", "condition", ":", "linguist_args", ".", "appen...
Parses the given args and returns True if they contain linguist lookups.
[ "Parses", "the", "given", "args", "and", "returns", "True", "if", "they", "contain", "linguist", "lookups", "." ]
d2b95a6ab921039d56d5eeb352badfe5be9e8f77
https://github.com/ulule/django-linguist/blob/d2b95a6ab921039d56d5eeb352badfe5be9e8f77/linguist/mixins.py#L154-L164
train
61,537
ulule/django-linguist
linguist/mixins.py
QuerySetMixin.get_translation_args
def get_translation_args(self, args): """ Returns linguist args from model args. """ translation_args = [] for arg in args: condition = self._get_linguist_condition(arg, transform=True) if condition: translation_args.append(condition) ...
python
def get_translation_args(self, args): """ Returns linguist args from model args. """ translation_args = [] for arg in args: condition = self._get_linguist_condition(arg, transform=True) if condition: translation_args.append(condition) ...
[ "def", "get_translation_args", "(", "self", ",", "args", ")", ":", "translation_args", "=", "[", "]", "for", "arg", "in", "args", ":", "condition", "=", "self", ".", "_get_linguist_condition", "(", "arg", ",", "transform", "=", "True", ")", "if", "conditio...
Returns linguist args from model args.
[ "Returns", "linguist", "args", "from", "model", "args", "." ]
d2b95a6ab921039d56d5eeb352badfe5be9e8f77
https://github.com/ulule/django-linguist/blob/d2b95a6ab921039d56d5eeb352badfe5be9e8f77/linguist/mixins.py#L166-L175
train
61,538
ulule/django-linguist
linguist/mixins.py
QuerySetMixin.is_linguist_lookup
def is_linguist_lookup(self, lookup): """ Returns true if the given lookup is a valid linguist lookup. """ field = utils.get_field_name_from_lookup(lookup) # To keep default behavior with "FieldError: Cannot resolve keyword". if ( field not in self.concrete_f...
python
def is_linguist_lookup(self, lookup): """ Returns true if the given lookup is a valid linguist lookup. """ field = utils.get_field_name_from_lookup(lookup) # To keep default behavior with "FieldError: Cannot resolve keyword". if ( field not in self.concrete_f...
[ "def", "is_linguist_lookup", "(", "self", ",", "lookup", ")", ":", "field", "=", "utils", ".", "get_field_name_from_lookup", "(", "lookup", ")", "# To keep default behavior with \"FieldError: Cannot resolve keyword\".", "if", "(", "field", "not", "in", "self", ".", "c...
Returns true if the given lookup is a valid linguist lookup.
[ "Returns", "true", "if", "the", "given", "lookup", "is", "a", "valid", "linguist", "lookup", "." ]
d2b95a6ab921039d56d5eeb352badfe5be9e8f77
https://github.com/ulule/django-linguist/blob/d2b95a6ab921039d56d5eeb352badfe5be9e8f77/linguist/mixins.py#L196-L209
train
61,539
ulule/django-linguist
linguist/mixins.py
QuerySetMixin._get_linguist_condition
def _get_linguist_condition(self, condition, reverse=False, transform=False): """ Parses Q tree and returns linguist lookups or model lookups if reverse is True. """ # We deal with a node if isinstance(condition, Q): children = [] for child in cond...
python
def _get_linguist_condition(self, condition, reverse=False, transform=False): """ Parses Q tree and returns linguist lookups or model lookups if reverse is True. """ # We deal with a node if isinstance(condition, Q): children = [] for child in cond...
[ "def", "_get_linguist_condition", "(", "self", ",", "condition", ",", "reverse", "=", "False", ",", "transform", "=", "False", ")", ":", "# We deal with a node", "if", "isinstance", "(", "condition", ",", "Q", ")", ":", "children", "=", "[", "]", "for", "c...
Parses Q tree and returns linguist lookups or model lookups if reverse is True.
[ "Parses", "Q", "tree", "and", "returns", "linguist", "lookups", "or", "model", "lookups", "if", "reverse", "is", "True", "." ]
d2b95a6ab921039d56d5eeb352badfe5be9e8f77
https://github.com/ulule/django-linguist/blob/d2b95a6ab921039d56d5eeb352badfe5be9e8f77/linguist/mixins.py#L211-L246
train
61,540
ulule/django-linguist
linguist/mixins.py
QuerySetMixin.get_cleaned_args
def get_cleaned_args(self, args): """ Returns positional arguments for related model query. """ if not args: return args cleaned_args = [] for arg in args: condition = self._get_linguist_condition(arg, True) if condition: ...
python
def get_cleaned_args(self, args): """ Returns positional arguments for related model query. """ if not args: return args cleaned_args = [] for arg in args: condition = self._get_linguist_condition(arg, True) if condition: ...
[ "def", "get_cleaned_args", "(", "self", ",", "args", ")", ":", "if", "not", "args", ":", "return", "args", "cleaned_args", "=", "[", "]", "for", "arg", "in", "args", ":", "condition", "=", "self", ".", "_get_linguist_condition", "(", "arg", ",", "True", ...
Returns positional arguments for related model query.
[ "Returns", "positional", "arguments", "for", "related", "model", "query", "." ]
d2b95a6ab921039d56d5eeb352badfe5be9e8f77
https://github.com/ulule/django-linguist/blob/d2b95a6ab921039d56d5eeb352badfe5be9e8f77/linguist/mixins.py#L248-L261
train
61,541
ulule/django-linguist
linguist/mixins.py
QuerySetMixin.get_cleaned_kwargs
def get_cleaned_kwargs(self, kwargs): """ Returns concrete field lookups. """ cleaned_kwargs = kwargs.copy() if kwargs is not None: for k in kwargs: if self.is_linguist_lookup(k): del cleaned_kwargs[k] return cleaned_kwarg...
python
def get_cleaned_kwargs(self, kwargs): """ Returns concrete field lookups. """ cleaned_kwargs = kwargs.copy() if kwargs is not None: for k in kwargs: if self.is_linguist_lookup(k): del cleaned_kwargs[k] return cleaned_kwarg...
[ "def", "get_cleaned_kwargs", "(", "self", ",", "kwargs", ")", ":", "cleaned_kwargs", "=", "kwargs", ".", "copy", "(", ")", "if", "kwargs", "is", "not", "None", ":", "for", "k", "in", "kwargs", ":", "if", "self", ".", "is_linguist_lookup", "(", "k", ")"...
Returns concrete field lookups.
[ "Returns", "concrete", "field", "lookups", "." ]
d2b95a6ab921039d56d5eeb352badfe5be9e8f77
https://github.com/ulule/django-linguist/blob/d2b95a6ab921039d56d5eeb352badfe5be9e8f77/linguist/mixins.py#L263-L274
train
61,542
ulule/django-linguist
linguist/mixins.py
QuerySetMixin.with_translations
def with_translations(self, **kwargs): """ Prefetches translations. Takes three optional keyword arguments: * ``field_names``: ``field_name`` values for SELECT IN * ``languages``: ``language`` values for SELECT IN * ``chunks_length``: fetches IDs by chunk """ ...
python
def with_translations(self, **kwargs): """ Prefetches translations. Takes three optional keyword arguments: * ``field_names``: ``field_name`` values for SELECT IN * ``languages``: ``language`` values for SELECT IN * ``chunks_length``: fetches IDs by chunk """ ...
[ "def", "with_translations", "(", "self", ",", "*", "*", "kwargs", ")", ":", "force", "=", "kwargs", ".", "pop", "(", "\"force\"", ",", "False", ")", "if", "self", ".", "_prefetch_translations_done", "and", "force", "is", "False", ":", "return", "self", "...
Prefetches translations. Takes three optional keyword arguments: * ``field_names``: ``field_name`` values for SELECT IN * ``languages``: ``language`` values for SELECT IN * ``chunks_length``: fetches IDs by chunk
[ "Prefetches", "translations", "." ]
d2b95a6ab921039d56d5eeb352badfe5be9e8f77
https://github.com/ulule/django-linguist/blob/d2b95a6ab921039d56d5eeb352badfe5be9e8f77/linguist/mixins.py#L276-L297
train
61,543
ulule/django-linguist
linguist/mixins.py
ModelMixin.available_languages
def available_languages(self): """ Returns available languages. """ from .models import Translation return ( Translation.objects.filter( identifier=self.linguist_identifier, object_id=self.pk ) .values_list("language", flat=Tru...
python
def available_languages(self): """ Returns available languages. """ from .models import Translation return ( Translation.objects.filter( identifier=self.linguist_identifier, object_id=self.pk ) .values_list("language", flat=Tru...
[ "def", "available_languages", "(", "self", ")", ":", "from", ".", "models", "import", "Translation", "return", "(", "Translation", ".", "objects", ".", "filter", "(", "identifier", "=", "self", ".", "linguist_identifier", ",", "object_id", "=", "self", ".", ...
Returns available languages.
[ "Returns", "available", "languages", "." ]
d2b95a6ab921039d56d5eeb352badfe5be9e8f77
https://github.com/ulule/django-linguist/blob/d2b95a6ab921039d56d5eeb352badfe5be9e8f77/linguist/mixins.py#L381-L394
train
61,544
ulule/django-linguist
linguist/mixins.py
ModelMixin.delete_translations
def delete_translations(self, language=None): """ Deletes related translations. """ from .models import Translation return Translation.objects.delete_translations(obj=self, language=language)
python
def delete_translations(self, language=None): """ Deletes related translations. """ from .models import Translation return Translation.objects.delete_translations(obj=self, language=language)
[ "def", "delete_translations", "(", "self", ",", "language", "=", "None", ")", ":", "from", ".", "models", "import", "Translation", "return", "Translation", ".", "objects", ".", "delete_translations", "(", "obj", "=", "self", ",", "language", "=", "language", ...
Deletes related translations.
[ "Deletes", "related", "translations", "." ]
d2b95a6ab921039d56d5eeb352badfe5be9e8f77
https://github.com/ulule/django-linguist/blob/d2b95a6ab921039d56d5eeb352badfe5be9e8f77/linguist/mixins.py#L420-L426
train
61,545
ulule/django-linguist
linguist/mixins.py
ModelMixin.override_language
def override_language(self, language): """ Context manager to override the instance language. """ previous_language = self._linguist.language self._linguist.language = language yield self._linguist.language = previous_language
python
def override_language(self, language): """ Context manager to override the instance language. """ previous_language = self._linguist.language self._linguist.language = language yield self._linguist.language = previous_language
[ "def", "override_language", "(", "self", ",", "language", ")", ":", "previous_language", "=", "self", ".", "_linguist", ".", "language", "self", ".", "_linguist", ".", "language", "=", "language", "yield", "self", ".", "_linguist", ".", "language", "=", "pre...
Context manager to override the instance language.
[ "Context", "manager", "to", "override", "the", "instance", "language", "." ]
d2b95a6ab921039d56d5eeb352badfe5be9e8f77
https://github.com/ulule/django-linguist/blob/d2b95a6ab921039d56d5eeb352badfe5be9e8f77/linguist/mixins.py#L435-L442
train
61,546
ulule/django-linguist
linguist/metaclasses.py
validate_meta
def validate_meta(meta): """ Validates Linguist Meta attribute. """ if not isinstance(meta, (dict,)): raise TypeError('Model Meta "linguist" must be a dict') required_keys = ("identifier", "fields") for key in required_keys: if key not in meta: raise KeyError('Model...
python
def validate_meta(meta): """ Validates Linguist Meta attribute. """ if not isinstance(meta, (dict,)): raise TypeError('Model Meta "linguist" must be a dict') required_keys = ("identifier", "fields") for key in required_keys: if key not in meta: raise KeyError('Model...
[ "def", "validate_meta", "(", "meta", ")", ":", "if", "not", "isinstance", "(", "meta", ",", "(", "dict", ",", ")", ")", ":", "raise", "TypeError", "(", "'Model Meta \"linguist\" must be a dict'", ")", "required_keys", "=", "(", "\"identifier\"", ",", "\"fields...
Validates Linguist Meta attribute.
[ "Validates", "Linguist", "Meta", "attribute", "." ]
d2b95a6ab921039d56d5eeb352badfe5be9e8f77
https://github.com/ulule/django-linguist/blob/d2b95a6ab921039d56d5eeb352badfe5be9e8f77/linguist/metaclasses.py#L22-L38
train
61,547
ulule/django-linguist
linguist/metaclasses.py
default_value_setter
def default_value_setter(field): """ When setting to the name of the field itself, the value in the current language will be set. """ def default_value_func_setter(self, value): localized_field = utils.build_localized_field_name( field, self._linguist.active_language ) ...
python
def default_value_setter(field): """ When setting to the name of the field itself, the value in the current language will be set. """ def default_value_func_setter(self, value): localized_field = utils.build_localized_field_name( field, self._linguist.active_language ) ...
[ "def", "default_value_setter", "(", "field", ")", ":", "def", "default_value_func_setter", "(", "self", ",", "value", ")", ":", "localized_field", "=", "utils", ".", "build_localized_field_name", "(", "field", ",", "self", ".", "_linguist", ".", "active_language",...
When setting to the name of the field itself, the value in the current language will be set.
[ "When", "setting", "to", "the", "name", "of", "the", "field", "itself", "the", "value", "in", "the", "current", "language", "will", "be", "set", "." ]
d2b95a6ab921039d56d5eeb352badfe5be9e8f77
https://github.com/ulule/django-linguist/blob/d2b95a6ab921039d56d5eeb352badfe5be9e8f77/linguist/metaclasses.py#L62-L75
train
61,548
ulule/django-linguist
linguist/metaclasses.py
field_factory
def field_factory(base_class): """ Takes a field base class and wrap it with ``TranslationField`` class. """ from .fields import TranslationField class TranslationFieldField(TranslationField, base_class): pass TranslationFieldField.__name__ = "Translation%s" % base_class.__name__ ...
python
def field_factory(base_class): """ Takes a field base class and wrap it with ``TranslationField`` class. """ from .fields import TranslationField class TranslationFieldField(TranslationField, base_class): pass TranslationFieldField.__name__ = "Translation%s" % base_class.__name__ ...
[ "def", "field_factory", "(", "base_class", ")", ":", "from", ".", "fields", "import", "TranslationField", "class", "TranslationFieldField", "(", "TranslationField", ",", "base_class", ")", ":", "pass", "TranslationFieldField", ".", "__name__", "=", "\"Translation%s\""...
Takes a field base class and wrap it with ``TranslationField`` class.
[ "Takes", "a", "field", "base", "class", "and", "wrap", "it", "with", "TranslationField", "class", "." ]
d2b95a6ab921039d56d5eeb352badfe5be9e8f77
https://github.com/ulule/django-linguist/blob/d2b95a6ab921039d56d5eeb352badfe5be9e8f77/linguist/metaclasses.py#L88-L99
train
61,549
ulule/django-linguist
linguist/metaclasses.py
create_translation_field
def create_translation_field(translated_field, language): """ Takes the original field, a given language, a decider model and return a Field class for model. """ cls_name = translated_field.__class__.__name__ if not isinstance(translated_field, tuple(SUPPORTED_FIELDS.keys())): raise Imp...
python
def create_translation_field(translated_field, language): """ Takes the original field, a given language, a decider model and return a Field class for model. """ cls_name = translated_field.__class__.__name__ if not isinstance(translated_field, tuple(SUPPORTED_FIELDS.keys())): raise Imp...
[ "def", "create_translation_field", "(", "translated_field", ",", "language", ")", ":", "cls_name", "=", "translated_field", ".", "__class__", ".", "__name__", "if", "not", "isinstance", "(", "translated_field", ",", "tuple", "(", "SUPPORTED_FIELDS", ".", "keys", "...
Takes the original field, a given language, a decider model and return a Field class for model.
[ "Takes", "the", "original", "field", "a", "given", "language", "a", "decider", "model", "and", "return", "a", "Field", "class", "for", "model", "." ]
d2b95a6ab921039d56d5eeb352badfe5be9e8f77
https://github.com/ulule/django-linguist/blob/d2b95a6ab921039d56d5eeb352badfe5be9e8f77/linguist/metaclasses.py#L102-L117
train
61,550
afg984/pyardrone
pyardrone/abc.py
BaseClient.connect
def connect(self): ''' Connect to the drone. :raises RuntimeError: if the drone is connected or closed already. ''' if self.connected: raise RuntimeError( '{} is connected already'.format(self.__class__.__name__)) if self.closed: r...
python
def connect(self): ''' Connect to the drone. :raises RuntimeError: if the drone is connected or closed already. ''' if self.connected: raise RuntimeError( '{} is connected already'.format(self.__class__.__name__)) if self.closed: r...
[ "def", "connect", "(", "self", ")", ":", "if", "self", ".", "connected", ":", "raise", "RuntimeError", "(", "'{} is connected already'", ".", "format", "(", "self", ".", "__class__", ".", "__name__", ")", ")", "if", "self", ".", "closed", ":", "raise", "...
Connect to the drone. :raises RuntimeError: if the drone is connected or closed already.
[ "Connect", "to", "the", "drone", "." ]
2c39263d5fdea91070c20f0ae9c9f355a9b5fe17
https://github.com/afg984/pyardrone/blob/2c39263d5fdea91070c20f0ae9c9f355a9b5fe17/pyardrone/abc.py#L9-L22
train
61,551
afg984/pyardrone
pyardrone/abc.py
BaseClient.close
def close(self): ''' Exit all threads and disconnect the drone. This method has no effect if the drone is closed already or not connected yet. ''' if not self.connected: return if self.closed: return self.closed = True self...
python
def close(self): ''' Exit all threads and disconnect the drone. This method has no effect if the drone is closed already or not connected yet. ''' if not self.connected: return if self.closed: return self.closed = True self...
[ "def", "close", "(", "self", ")", ":", "if", "not", "self", ".", "connected", ":", "return", "if", "self", ".", "closed", ":", "return", "self", ".", "closed", "=", "True", "self", ".", "_close", "(", ")" ]
Exit all threads and disconnect the drone. This method has no effect if the drone is closed already or not connected yet.
[ "Exit", "all", "threads", "and", "disconnect", "the", "drone", "." ]
2c39263d5fdea91070c20f0ae9c9f355a9b5fe17
https://github.com/afg984/pyardrone/blob/2c39263d5fdea91070c20f0ae9c9f355a9b5fe17/pyardrone/abc.py#L24-L36
train
61,552
afg984/pyardrone
pyardrone/at/parameters.py
Int32._set_flags
def _set_flags(self, **flags): ''' Set the flags of this argument. Example: ``int_param._set_flags(a=1, b=2, c=4, d=8)`` ''' self._flags = enum.IntEnum('_flags', flags) self.__dict__.update(self._flags.__members__) self._patch_flag_doc()
python
def _set_flags(self, **flags): ''' Set the flags of this argument. Example: ``int_param._set_flags(a=1, b=2, c=4, d=8)`` ''' self._flags = enum.IntEnum('_flags', flags) self.__dict__.update(self._flags.__members__) self._patch_flag_doc()
[ "def", "_set_flags", "(", "self", ",", "*", "*", "flags", ")", ":", "self", ".", "_flags", "=", "enum", ".", "IntEnum", "(", "'_flags'", ",", "flags", ")", "self", ".", "__dict__", ".", "update", "(", "self", ".", "_flags", ".", "__members__", ")", ...
Set the flags of this argument. Example: ``int_param._set_flags(a=1, b=2, c=4, d=8)``
[ "Set", "the", "flags", "of", "this", "argument", "." ]
2c39263d5fdea91070c20f0ae9c9f355a9b5fe17
https://github.com/afg984/pyardrone/blob/2c39263d5fdea91070c20f0ae9c9f355a9b5fe17/pyardrone/at/parameters.py#L86-L94
train
61,553
ulule/django-linguist
linguist/signals.py
delete_translations
def delete_translations(sender, instance, **kwargs): """ Deletes related instance's translations when instance is deleted. """ if issubclass(sender, (ModelMixin,)): instance._linguist.decider.objects.filter( identifier=instance.linguist_identifier, object_id=instance.pk ).del...
python
def delete_translations(sender, instance, **kwargs): """ Deletes related instance's translations when instance is deleted. """ if issubclass(sender, (ModelMixin,)): instance._linguist.decider.objects.filter( identifier=instance.linguist_identifier, object_id=instance.pk ).del...
[ "def", "delete_translations", "(", "sender", ",", "instance", ",", "*", "*", "kwargs", ")", ":", "if", "issubclass", "(", "sender", ",", "(", "ModelMixin", ",", ")", ")", ":", "instance", ".", "_linguist", ".", "decider", ".", "objects", ".", "filter", ...
Deletes related instance's translations when instance is deleted.
[ "Deletes", "related", "instance", "s", "translations", "when", "instance", "is", "deleted", "." ]
d2b95a6ab921039d56d5eeb352badfe5be9e8f77
https://github.com/ulule/django-linguist/blob/d2b95a6ab921039d56d5eeb352badfe5be9e8f77/linguist/signals.py#L9-L16
train
61,554
mbr/asciitree
asciitree/__init__.py
draw_tree
def draw_tree(node, child_iter=lambda n: n.children, text_str=str): """Support asciitree 0.2 API. This function solely exist to not break old code (using asciitree 0.2). Its use is deprecated.""" return LeftAligned(traverse=Traversal(get_text=text_str, ...
python
def draw_tree(node, child_iter=lambda n: n.children, text_str=str): """Support asciitree 0.2 API. This function solely exist to not break old code (using asciitree 0.2). Its use is deprecated.""" return LeftAligned(traverse=Traversal(get_text=text_str, ...
[ "def", "draw_tree", "(", "node", ",", "child_iter", "=", "lambda", "n", ":", "n", ".", "children", ",", "text_str", "=", "str", ")", ":", "return", "LeftAligned", "(", "traverse", "=", "Traversal", "(", "get_text", "=", "text_str", ",", "get_children", "...
Support asciitree 0.2 API. This function solely exist to not break old code (using asciitree 0.2). Its use is deprecated.
[ "Support", "asciitree", "0", ".", "2", "API", "." ]
29712fb66fd997b4345ac4f4436c8dc6401924de
https://github.com/mbr/asciitree/blob/29712fb66fd997b4345ac4f4436c8dc6401924de/asciitree/__init__.py#L74-L83
train
61,555
ulule/django-linguist
linguist/utils.py
get_language
def get_language(): """ Returns an active language code that is guaranteed to be in settings.SUPPORTED_LANGUAGES. """ lang = _get_language() if not lang: return get_fallback_language() langs = [l[0] for l in settings.SUPPORTED_LANGUAGES] if lang not in langs and "-" in lang: ...
python
def get_language(): """ Returns an active language code that is guaranteed to be in settings.SUPPORTED_LANGUAGES. """ lang = _get_language() if not lang: return get_fallback_language() langs = [l[0] for l in settings.SUPPORTED_LANGUAGES] if lang not in langs and "-" in lang: ...
[ "def", "get_language", "(", ")", ":", "lang", "=", "_get_language", "(", ")", "if", "not", "lang", ":", "return", "get_fallback_language", "(", ")", "langs", "=", "[", "l", "[", "0", "]", "for", "l", "in", "settings", ".", "SUPPORTED_LANGUAGES", "]", "...
Returns an active language code that is guaranteed to be in settings.SUPPORTED_LANGUAGES.
[ "Returns", "an", "active", "language", "code", "that", "is", "guaranteed", "to", "be", "in", "settings", ".", "SUPPORTED_LANGUAGES", "." ]
d2b95a6ab921039d56d5eeb352badfe5be9e8f77
https://github.com/ulule/django-linguist/blob/d2b95a6ab921039d56d5eeb352badfe5be9e8f77/linguist/utils.py#L30-L47
train
61,556
ulule/django-linguist
linguist/utils.py
activate_language
def activate_language(instances, language): """ Activates the given language for the given instances. """ language = ( language if language in get_supported_languages() else get_fallback_language() ) for instance in instances: instance.activate_language(language)
python
def activate_language(instances, language): """ Activates the given language for the given instances. """ language = ( language if language in get_supported_languages() else get_fallback_language() ) for instance in instances: instance.activate_language(language)
[ "def", "activate_language", "(", "instances", ",", "language", ")", ":", "language", "=", "(", "language", "if", "language", "in", "get_supported_languages", "(", ")", "else", "get_fallback_language", "(", ")", ")", "for", "instance", "in", "instances", ":", "...
Activates the given language for the given instances.
[ "Activates", "the", "given", "language", "for", "the", "given", "instances", "." ]
d2b95a6ab921039d56d5eeb352badfe5be9e8f77
https://github.com/ulule/django-linguist/blob/d2b95a6ab921039d56d5eeb352badfe5be9e8f77/linguist/utils.py#L85-L93
train
61,557
ulule/django-linguist
linguist/utils.py
load_class
def load_class(class_path, setting_name=None): """ Loads a class given a class_path. The setting value may be a string or a tuple. The setting_name parameter is only there for pretty error output, and therefore is optional. """ if not isinstance(class_path, six.string_types): try: ...
python
def load_class(class_path, setting_name=None): """ Loads a class given a class_path. The setting value may be a string or a tuple. The setting_name parameter is only there for pretty error output, and therefore is optional. """ if not isinstance(class_path, six.string_types): try: ...
[ "def", "load_class", "(", "class_path", ",", "setting_name", "=", "None", ")", ":", "if", "not", "isinstance", "(", "class_path", ",", "six", ".", "string_types", ")", ":", "try", ":", "class_path", ",", "app_label", "=", "class_path", "except", ":", "if",...
Loads a class given a class_path. The setting value may be a string or a tuple. The setting_name parameter is only there for pretty error output, and therefore is optional.
[ "Loads", "a", "class", "given", "a", "class_path", ".", "The", "setting", "value", "may", "be", "a", "string", "or", "a", "tuple", ".", "The", "setting_name", "parameter", "is", "only", "there", "for", "pretty", "error", "output", "and", "therefore", "is",...
d2b95a6ab921039d56d5eeb352badfe5be9e8f77
https://github.com/ulule/django-linguist/blob/d2b95a6ab921039d56d5eeb352badfe5be9e8f77/linguist/utils.py#L124-L182
train
61,558
ulule/django-linguist
linguist/utils.py
get_translation_lookup
def get_translation_lookup(identifier, field, value): """ Mapper that takes a language field, its value and returns the related lookup for Translation model. """ # Split by transformers parts = field.split("__") # Store transformers transformers = parts[1:] if len(parts) > 1 else None ...
python
def get_translation_lookup(identifier, field, value): """ Mapper that takes a language field, its value and returns the related lookup for Translation model. """ # Split by transformers parts = field.split("__") # Store transformers transformers = parts[1:] if len(parts) > 1 else None ...
[ "def", "get_translation_lookup", "(", "identifier", ",", "field", ",", "value", ")", ":", "# Split by transformers", "parts", "=", "field", ".", "split", "(", "\"__\"", ")", "# Store transformers", "transformers", "=", "parts", "[", "1", ":", "]", "if", "len",...
Mapper that takes a language field, its value and returns the related lookup for Translation model.
[ "Mapper", "that", "takes", "a", "language", "field", "its", "value", "and", "returns", "the", "related", "lookup", "for", "Translation", "model", "." ]
d2b95a6ab921039d56d5eeb352badfe5be9e8f77
https://github.com/ulule/django-linguist/blob/d2b95a6ab921039d56d5eeb352badfe5be9e8f77/linguist/utils.py#L215-L253
train
61,559
ulule/django-linguist
linguist/utils.py
get_grouped_translations
def get_grouped_translations(instances, **kwargs): """ Takes instances and returns grouped translations ready to be set in cache. """ grouped_translations = collections.defaultdict(list) if not instances: return grouped_translations if not isinstance(instances, collections.Iterable...
python
def get_grouped_translations(instances, **kwargs): """ Takes instances and returns grouped translations ready to be set in cache. """ grouped_translations = collections.defaultdict(list) if not instances: return grouped_translations if not isinstance(instances, collections.Iterable...
[ "def", "get_grouped_translations", "(", "instances", ",", "*", "*", "kwargs", ")", ":", "grouped_translations", "=", "collections", ".", "defaultdict", "(", "list", ")", "if", "not", "instances", ":", "return", "grouped_translations", "if", "not", "isinstance", ...
Takes instances and returns grouped translations ready to be set in cache.
[ "Takes", "instances", "and", "returns", "grouped", "translations", "ready", "to", "be", "set", "in", "cache", "." ]
d2b95a6ab921039d56d5eeb352badfe5be9e8f77
https://github.com/ulule/django-linguist/blob/d2b95a6ab921039d56d5eeb352badfe5be9e8f77/linguist/utils.py#L263-L324
train
61,560
afg984/pyardrone
pyardrone/utils/__init__.py
get_free_udp_port
def get_free_udp_port(): ''' Get a free UDP port. Note this is vlunerable to race conditions. ''' import socket sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.bind(('localhost', 0)) addr = sock.getsockname() sock.close() return addr[1]
python
def get_free_udp_port(): ''' Get a free UDP port. Note this is vlunerable to race conditions. ''' import socket sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.bind(('localhost', 0)) addr = sock.getsockname() sock.close() return addr[1]
[ "def", "get_free_udp_port", "(", ")", ":", "import", "socket", "sock", "=", "socket", ".", "socket", "(", "socket", ".", "AF_INET", ",", "socket", ".", "SOCK_STREAM", ")", "sock", ".", "bind", "(", "(", "'localhost'", ",", "0", ")", ")", "addr", "=", ...
Get a free UDP port. Note this is vlunerable to race conditions.
[ "Get", "a", "free", "UDP", "port", "." ]
2c39263d5fdea91070c20f0ae9c9f355a9b5fe17
https://github.com/afg984/pyardrone/blob/2c39263d5fdea91070c20f0ae9c9f355a9b5fe17/pyardrone/utils/__init__.py#L60-L71
train
61,561
ulule/django-linguist
linguist/admin.py
TranslatableModelAdminMixin.get_available_languages
def get_available_languages(self, obj): """ Returns available languages for current object. """ return obj.available_languages if obj is not None else self.model.objects.none()
python
def get_available_languages(self, obj): """ Returns available languages for current object. """ return obj.available_languages if obj is not None else self.model.objects.none()
[ "def", "get_available_languages", "(", "self", ",", "obj", ")", ":", "return", "obj", ".", "available_languages", "if", "obj", "is", "not", "None", "else", "self", ".", "model", ".", "objects", ".", "none", "(", ")" ]
Returns available languages for current object.
[ "Returns", "available", "languages", "for", "current", "object", "." ]
d2b95a6ab921039d56d5eeb352badfe5be9e8f77
https://github.com/ulule/django-linguist/blob/d2b95a6ab921039d56d5eeb352badfe5be9e8f77/linguist/admin.py#L43-L47
train
61,562
ulule/django-linguist
linguist/admin.py
TranslatableModelAdminMixin.languages_column
def languages_column(self, obj): """ Adds languages columns. """ languages = self.get_available_languages(obj) return '<span class="available-languages">{0}</span>'.format( " ".join(languages) )
python
def languages_column(self, obj): """ Adds languages columns. """ languages = self.get_available_languages(obj) return '<span class="available-languages">{0}</span>'.format( " ".join(languages) )
[ "def", "languages_column", "(", "self", ",", "obj", ")", ":", "languages", "=", "self", ".", "get_available_languages", "(", "obj", ")", "return", "'<span class=\"available-languages\">{0}</span>'", ".", "format", "(", "\" \"", ".", "join", "(", "languages", ")", ...
Adds languages columns.
[ "Adds", "languages", "columns", "." ]
d2b95a6ab921039d56d5eeb352badfe5be9e8f77
https://github.com/ulule/django-linguist/blob/d2b95a6ab921039d56d5eeb352badfe5be9e8f77/linguist/admin.py#L49-L56
train
61,563
ulule/django-linguist
linguist/helpers.py
prefetch_translations
def prefetch_translations(instances, **kwargs): """ Prefetches translations for the given instances. Can be useful for a list of instances. """ from .mixins import ModelMixin if not isinstance(instances, collections.Iterable): instances = [instances] populate_missing = kwargs.get("...
python
def prefetch_translations(instances, **kwargs): """ Prefetches translations for the given instances. Can be useful for a list of instances. """ from .mixins import ModelMixin if not isinstance(instances, collections.Iterable): instances = [instances] populate_missing = kwargs.get("...
[ "def", "prefetch_translations", "(", "instances", ",", "*", "*", "kwargs", ")", ":", "from", ".", "mixins", "import", "ModelMixin", "if", "not", "isinstance", "(", "instances", ",", "collections", ".", "Iterable", ")", ":", "instances", "=", "[", "instances"...
Prefetches translations for the given instances. Can be useful for a list of instances.
[ "Prefetches", "translations", "for", "the", "given", "instances", ".", "Can", "be", "useful", "for", "a", "list", "of", "instances", "." ]
d2b95a6ab921039d56d5eeb352badfe5be9e8f77
https://github.com/ulule/django-linguist/blob/d2b95a6ab921039d56d5eeb352badfe5be9e8f77/linguist/helpers.py#L8-L34
train
61,564
ulule/django-linguist
linguist/models/base.py
TranslationQuerySet.get_translations
def get_translations(self, obj, language=None): """ Shorcut method to retrieve translations for a given object. """ lookup = {"identifier": obj.linguist_identifier, "object_id": obj.pk} if language is not None: lookup["language"] = language return self.get_q...
python
def get_translations(self, obj, language=None): """ Shorcut method to retrieve translations for a given object. """ lookup = {"identifier": obj.linguist_identifier, "object_id": obj.pk} if language is not None: lookup["language"] = language return self.get_q...
[ "def", "get_translations", "(", "self", ",", "obj", ",", "language", "=", "None", ")", ":", "lookup", "=", "{", "\"identifier\"", ":", "obj", ".", "linguist_identifier", ",", "\"object_id\"", ":", "obj", ".", "pk", "}", "if", "language", "is", "not", "No...
Shorcut method to retrieve translations for a given object.
[ "Shorcut", "method", "to", "retrieve", "translations", "for", "a", "given", "object", "." ]
d2b95a6ab921039d56d5eeb352badfe5be9e8f77
https://github.com/ulule/django-linguist/blob/d2b95a6ab921039d56d5eeb352badfe5be9e8f77/linguist/models/base.py#L11-L20
train
61,565
afg984/pyardrone
pyardrone/__init__.py
HelperMixin.takeoff
def takeoff(self): ''' Sends the takeoff command. ''' self.send(at.REF(at.REF.input.start))
python
def takeoff(self): ''' Sends the takeoff command. ''' self.send(at.REF(at.REF.input.start))
[ "def", "takeoff", "(", "self", ")", ":", "self", ".", "send", "(", "at", ".", "REF", "(", "at", ".", "REF", ".", "input", ".", "start", ")", ")" ]
Sends the takeoff command.
[ "Sends", "the", "takeoff", "command", "." ]
2c39263d5fdea91070c20f0ae9c9f355a9b5fe17
https://github.com/afg984/pyardrone/blob/2c39263d5fdea91070c20f0ae9c9f355a9b5fe17/pyardrone/__init__.py#L101-L105
train
61,566
afg984/pyardrone
pyardrone/__init__.py
HelperMixin.emergency
def emergency(self): ''' Sends the emergency command. ''' self.send(at.REF(at.REF.input.select))
python
def emergency(self): ''' Sends the emergency command. ''' self.send(at.REF(at.REF.input.select))
[ "def", "emergency", "(", "self", ")", ":", "self", ".", "send", "(", "at", ".", "REF", "(", "at", ".", "REF", ".", "input", ".", "select", ")", ")" ]
Sends the emergency command.
[ "Sends", "the", "emergency", "command", "." ]
2c39263d5fdea91070c20f0ae9c9f355a9b5fe17
https://github.com/afg984/pyardrone/blob/2c39263d5fdea91070c20f0ae9c9f355a9b5fe17/pyardrone/__init__.py#L113-L117
train
61,567
afg984/pyardrone
pyardrone/__init__.py
HelperMixin.move
def move( self, *, forward=0, backward=0, left=0, right=0, up=0, down=0, cw=0, ccw=0): ''' Moves the drone. To move the drone forward at 0.8x speed: >>> drone.move(forward=0.8) To move the drone right at 0.5x speed an...
python
def move( self, *, forward=0, backward=0, left=0, right=0, up=0, down=0, cw=0, ccw=0): ''' Moves the drone. To move the drone forward at 0.8x speed: >>> drone.move(forward=0.8) To move the drone right at 0.5x speed an...
[ "def", "move", "(", "self", ",", "*", ",", "forward", "=", "0", ",", "backward", "=", "0", ",", "left", "=", "0", ",", "right", "=", "0", ",", "up", "=", "0", ",", "down", "=", "0", ",", "cw", "=", "0", ",", "ccw", "=", "0", ")", ":", "...
Moves the drone. To move the drone forward at 0.8x speed: >>> drone.move(forward=0.8) To move the drone right at 0.5x speed and upward at full speed: >>> drone.move(right=0.5, up=1) To rotate clockwise at 0.7x speed: >>> drone.move(cw=0.7) :param forward: ...
[ "Moves", "the", "drone", "." ]
2c39263d5fdea91070c20f0ae9c9f355a9b5fe17
https://github.com/afg984/pyardrone/blob/2c39263d5fdea91070c20f0ae9c9f355a9b5fe17/pyardrone/__init__.py#L126-L161
train
61,568
jbittel/base32-crockford
base32_crockford.py
encode
def encode(number, checksum=False, split=0): """Encode an integer into a symbol string. A ValueError is raised on invalid input. If checksum is set to True, a check symbol will be calculated and appended to the string. If split is specified, the string will be divided into clusters of that si...
python
def encode(number, checksum=False, split=0): """Encode an integer into a symbol string. A ValueError is raised on invalid input. If checksum is set to True, a check symbol will be calculated and appended to the string. If split is specified, the string will be divided into clusters of that si...
[ "def", "encode", "(", "number", ",", "checksum", "=", "False", ",", "split", "=", "0", ")", ":", "number", "=", "int", "(", "number", ")", "if", "number", "<", "0", ":", "raise", "ValueError", "(", "\"number '%d' is not a positive integer\"", "%", "number"...
Encode an integer into a symbol string. A ValueError is raised on invalid input. If checksum is set to True, a check symbol will be calculated and appended to the string. If split is specified, the string will be divided into clusters of that size separated by hyphens. The encoded string is ...
[ "Encode", "an", "integer", "into", "a", "symbol", "string", "." ]
1ffb6021485b666ea6a562abd0a1ea6f7021188f
https://github.com/jbittel/base32-crockford/blob/1ffb6021485b666ea6a562abd0a1ea6f7021188f/base32_crockford.py#L59-L100
train
61,569
jbittel/base32-crockford
base32_crockford.py
decode
def decode(symbol_string, checksum=False, strict=False): """Decode an encoded symbol string. If checksum is set to True, the string is assumed to have a trailing check symbol which will be validated. If the checksum validation fails, a ValueError is raised. If strict is set to True, a ValueError i...
python
def decode(symbol_string, checksum=False, strict=False): """Decode an encoded symbol string. If checksum is set to True, the string is assumed to have a trailing check symbol which will be validated. If the checksum validation fails, a ValueError is raised. If strict is set to True, a ValueError i...
[ "def", "decode", "(", "symbol_string", ",", "checksum", "=", "False", ",", "strict", "=", "False", ")", ":", "symbol_string", "=", "normalize", "(", "symbol_string", ",", "strict", "=", "strict", ")", "if", "checksum", ":", "symbol_string", ",", "check_symbo...
Decode an encoded symbol string. If checksum is set to True, the string is assumed to have a trailing check symbol which will be validated. If the checksum validation fails, a ValueError is raised. If strict is set to True, a ValueError is raised if the normalization step requires changes to the s...
[ "Decode", "an", "encoded", "symbol", "string", "." ]
1ffb6021485b666ea6a562abd0a1ea6f7021188f
https://github.com/jbittel/base32-crockford/blob/1ffb6021485b666ea6a562abd0a1ea6f7021188f/base32_crockford.py#L103-L130
train
61,570
jbittel/base32-crockford
base32_crockford.py
normalize
def normalize(symbol_string, strict=False): """Normalize an encoded symbol string. Normalization provides error correction and prepares the string for decoding. These transformations are applied: 1. Hyphens are removed 2. 'I', 'i', 'L' or 'l' are converted to '1' 3. 'O' or 'o' are con...
python
def normalize(symbol_string, strict=False): """Normalize an encoded symbol string. Normalization provides error correction and prepares the string for decoding. These transformations are applied: 1. Hyphens are removed 2. 'I', 'i', 'L' or 'l' are converted to '1' 3. 'O' or 'o' are con...
[ "def", "normalize", "(", "symbol_string", ",", "strict", "=", "False", ")", ":", "if", "isinstance", "(", "symbol_string", ",", "string_types", ")", ":", "if", "not", "PY3", ":", "try", ":", "symbol_string", "=", "symbol_string", ".", "encode", "(", "'asci...
Normalize an encoded symbol string. Normalization provides error correction and prepares the string for decoding. These transformations are applied: 1. Hyphens are removed 2. 'I', 'i', 'L' or 'l' are converted to '1' 3. 'O' or 'o' are converted to '0' 4. All characters are converte...
[ "Normalize", "an", "encoded", "symbol", "string", "." ]
1ffb6021485b666ea6a562abd0a1ea6f7021188f
https://github.com/jbittel/base32-crockford/blob/1ffb6021485b666ea6a562abd0a1ea6f7021188f/base32_crockford.py#L133-L172
train
61,571
has2k1/scikit-misc
setup.py
setup_requires
def setup_requires(): """ Return required packages Plus any version tests and warnings """ from pkg_resources import parse_version required = ['cython>=0.24.0'] numpy_requirement = 'numpy>=1.7.1' try: import numpy except Exception: required.append(numpy_requirement)...
python
def setup_requires(): """ Return required packages Plus any version tests and warnings """ from pkg_resources import parse_version required = ['cython>=0.24.0'] numpy_requirement = 'numpy>=1.7.1' try: import numpy except Exception: required.append(numpy_requirement)...
[ "def", "setup_requires", "(", ")", ":", "from", "pkg_resources", "import", "parse_version", "required", "=", "[", "'cython>=0.24.0'", "]", "numpy_requirement", "=", "'numpy>=1.7.1'", "try", ":", "import", "numpy", "except", "Exception", ":", "required", ".", "appe...
Return required packages Plus any version tests and warnings
[ "Return", "required", "packages" ]
1d599761e11f84233e59602330e22823efeee226
https://github.com/has2k1/scikit-misc/blob/1d599761e11f84233e59602330e22823efeee226/setup.py#L102-L120
train
61,572
clokep/django-render-block
render_block/django.py
_build_block_context
def _build_block_context(template, context): """Populate the block context with BlockNodes from parent templates.""" # Ensure there's a BlockContext before rendering. This allows blocks in # ExtendsNodes to be found by sub-templates (allowing {{ block.super }} and # overriding sub-blocks to work). ...
python
def _build_block_context(template, context): """Populate the block context with BlockNodes from parent templates.""" # Ensure there's a BlockContext before rendering. This allows blocks in # ExtendsNodes to be found by sub-templates (allowing {{ block.super }} and # overriding sub-blocks to work). ...
[ "def", "_build_block_context", "(", "template", ",", "context", ")", ":", "# Ensure there's a BlockContext before rendering. This allows blocks in", "# ExtendsNodes to be found by sub-templates (allowing {{ block.super }} and", "# overriding sub-blocks to work).", "if", "BLOCK_CONTEXT_KEY", ...
Populate the block context with BlockNodes from parent templates.
[ "Populate", "the", "block", "context", "with", "BlockNodes", "from", "parent", "templates", "." ]
0c530c1bff76916afdbb6d409d55cd259ffe1962
https://github.com/clokep/django-render-block/blob/0c530c1bff76916afdbb6d409d55cd259ffe1962/render_block/django.py#L40-L65
train
61,573
clokep/django-render-block
render_block/django.py
_render_template_block_nodelist
def _render_template_block_nodelist(nodelist, block_name, context): """Recursively iterate over a node to find the wanted block.""" # Attempt to find the wanted block in the current template. for node in nodelist: # If the wanted block was found, return it. if isinstance(node, BlockNode): ...
python
def _render_template_block_nodelist(nodelist, block_name, context): """Recursively iterate over a node to find the wanted block.""" # Attempt to find the wanted block in the current template. for node in nodelist: # If the wanted block was found, return it. if isinstance(node, BlockNode): ...
[ "def", "_render_template_block_nodelist", "(", "nodelist", ",", "block_name", ",", "context", ")", ":", "# Attempt to find the wanted block in the current template.", "for", "node", "in", "nodelist", ":", "# If the wanted block was found, return it.", "if", "isinstance", "(", ...
Recursively iterate over a node to find the wanted block.
[ "Recursively", "iterate", "over", "a", "node", "to", "find", "the", "wanted", "block", "." ]
0c530c1bff76916afdbb6d409d55cd259ffe1962
https://github.com/clokep/django-render-block/blob/0c530c1bff76916afdbb6d409d55cd259ffe1962/render_block/django.py#L73-L102
train
61,574
clokep/django-render-block
render_block/base.py
render_block_to_string
def render_block_to_string(template_name, block_name, context=None): """ Loads the given template_name and renders the given block with the given dictionary as context. Returns a string. template_name The name of the template to load and render. If it's a list of template na...
python
def render_block_to_string(template_name, block_name, context=None): """ Loads the given template_name and renders the given block with the given dictionary as context. Returns a string. template_name The name of the template to load and render. If it's a list of template na...
[ "def", "render_block_to_string", "(", "template_name", ",", "block_name", ",", "context", "=", "None", ")", ":", "# Like render_to_string, template_name can be a string or a list/tuple.", "if", "isinstance", "(", "template_name", ",", "(", "tuple", ",", "list", ")", ")"...
Loads the given template_name and renders the given block with the given dictionary as context. Returns a string. template_name The name of the template to load and render. If it's a list of template names, Django uses select_template() instead of get_template() to find ...
[ "Loads", "the", "given", "template_name", "and", "renders", "the", "given", "block", "with", "the", "given", "dictionary", "as", "context", ".", "Returns", "a", "string", "." ]
0c530c1bff76916afdbb6d409d55cd259ffe1962
https://github.com/clokep/django-render-block/blob/0c530c1bff76916afdbb6d409d55cd259ffe1962/render_block/base.py#L17-L47
train
61,575
merll/docker-map
dockermap/map/config/host_volume.py
get_host_path
def get_host_path(root, path, instance=None): """ Generates the host path for a container volume. If the given path is a dictionary, uses the entry of the instance name. :param root: Root path to prepend, if ``path`` does not already describe an absolute path. :type root: unicode | str | AbstractLa...
python
def get_host_path(root, path, instance=None): """ Generates the host path for a container volume. If the given path is a dictionary, uses the entry of the instance name. :param root: Root path to prepend, if ``path`` does not already describe an absolute path. :type root: unicode | str | AbstractLa...
[ "def", "get_host_path", "(", "root", ",", "path", ",", "instance", "=", "None", ")", ":", "r_val", "=", "resolve_value", "(", "path", ")", "if", "isinstance", "(", "r_val", ",", "dict", ")", ":", "r_instance", "=", "instance", "or", "'default'", "r_path"...
Generates the host path for a container volume. If the given path is a dictionary, uses the entry of the instance name. :param root: Root path to prepend, if ``path`` does not already describe an absolute path. :type root: unicode | str | AbstractLazyObject :param path: Path string or dictionary of per...
[ "Generates", "the", "host", "path", "for", "a", "container", "volume", ".", "If", "the", "given", "path", "is", "a", "dictionary", "uses", "the", "entry", "of", "the", "instance", "name", "." ]
e14fe86a6ff5c33d121eb2f9157e9359cb80dd02
https://github.com/merll/docker-map/blob/e14fe86a6ff5c33d121eb2f9157e9359cb80dd02/dockermap/map/config/host_volume.py#L11-L36
train
61,576
merll/docker-map
dockermap/map/runner/__init__.py
AbstractRunner.run_actions
def run_actions(self, actions): """ Runs the given lists of attached actions and instance actions on the client. :param actions: Actions to apply. :type actions: list[dockermap.map.action.ItemAction] :return: Where the result is not ``None``, returns the output from the client. ...
python
def run_actions(self, actions): """ Runs the given lists of attached actions and instance actions on the client. :param actions: Actions to apply. :type actions: list[dockermap.map.action.ItemAction] :return: Where the result is not ``None``, returns the output from the client. ...
[ "def", "run_actions", "(", "self", ",", "actions", ")", ":", "policy", "=", "self", ".", "_policy", "for", "action", "in", "actions", ":", "config_id", "=", "action", ".", "config_id", "config_type", "=", "config_id", ".", "config_type", "client_config", "="...
Runs the given lists of attached actions and instance actions on the client. :param actions: Actions to apply. :type actions: list[dockermap.map.action.ItemAction] :return: Where the result is not ``None``, returns the output from the client. Note that this is a generator and needs to...
[ "Runs", "the", "given", "lists", "of", "attached", "actions", "and", "instance", "actions", "on", "the", "client", "." ]
e14fe86a6ff5c33d121eb2f9157e9359cb80dd02
https://github.com/merll/docker-map/blob/e14fe86a6ff5c33d121eb2f9157e9359cb80dd02/dockermap/map/runner/__init__.py#L39-L89
train
61,577
merll/docker-map
dockermap/map/config/client.py
ClientConfiguration.from_client
def from_client(cls, client): """ Constructs a configuration object from an existing client instance. If the client has already been created with a configuration object, returns that instance. :param client: Client object to derive the configuration from. :type client: docker.cl...
python
def from_client(cls, client): """ Constructs a configuration object from an existing client instance. If the client has already been created with a configuration object, returns that instance. :param client: Client object to derive the configuration from. :type client: docker.cl...
[ "def", "from_client", "(", "cls", ",", "client", ")", ":", "if", "hasattr", "(", "client", ",", "'client_configuration'", ")", ":", "return", "client", ".", "client_configuration", "kwargs", "=", "{", "'client'", ":", "client", "}", "for", "attr", "in", "c...
Constructs a configuration object from an existing client instance. If the client has already been created with a configuration object, returns that instance. :param client: Client object to derive the configuration from. :type client: docker.client.Client :return: ClientConfiguration
[ "Constructs", "a", "configuration", "object", "from", "an", "existing", "client", "instance", ".", "If", "the", "client", "has", "already", "been", "created", "with", "a", "configuration", "object", "returns", "that", "instance", "." ]
e14fe86a6ff5c33d121eb2f9157e9359cb80dd02
https://github.com/merll/docker-map/blob/e14fe86a6ff5c33d121eb2f9157e9359cb80dd02/dockermap/map/config/client.py#L58-L75
train
61,578
merll/docker-map
dockermap/map/config/client.py
ClientConfiguration.get_init_kwargs
def get_init_kwargs(self): """ Generates keyword arguments for creating a new Docker client instance. :return: Keyword arguments as defined through this configuration. :rtype: dict """ init_kwargs = {} for k in self.init_kwargs: if k in self.core_prop...
python
def get_init_kwargs(self): """ Generates keyword arguments for creating a new Docker client instance. :return: Keyword arguments as defined through this configuration. :rtype: dict """ init_kwargs = {} for k in self.init_kwargs: if k in self.core_prop...
[ "def", "get_init_kwargs", "(", "self", ")", ":", "init_kwargs", "=", "{", "}", "for", "k", "in", "self", ".", "init_kwargs", ":", "if", "k", "in", "self", ".", "core_property_set", ":", "init_kwargs", "[", "k", "]", "=", "getattr", "(", "self", ",", ...
Generates keyword arguments for creating a new Docker client instance. :return: Keyword arguments as defined through this configuration. :rtype: dict
[ "Generates", "keyword", "arguments", "for", "creating", "a", "new", "Docker", "client", "instance", "." ]
e14fe86a6ff5c33d121eb2f9157e9359cb80dd02
https://github.com/merll/docker-map/blob/e14fe86a6ff5c33d121eb2f9157e9359cb80dd02/dockermap/map/config/client.py#L89-L102
train
61,579
merll/docker-map
dockermap/map/config/client.py
ClientConfiguration.get_client
def get_client(self): """ Retrieves or creates a client instance from this configuration object. If instantiated from this configuration, the resulting object is also cached in the property ``client`` and a reference to this configuration is stored on the client object. :return:...
python
def get_client(self): """ Retrieves or creates a client instance from this configuration object. If instantiated from this configuration, the resulting object is also cached in the property ``client`` and a reference to this configuration is stored on the client object. :return:...
[ "def", "get_client", "(", "self", ")", ":", "client", "=", "self", ".", "_client", "if", "not", "client", ":", "self", ".", "_client", "=", "client", "=", "self", ".", "client_constructor", "(", "*", "*", "self", ".", "get_init_kwargs", "(", ")", ")", ...
Retrieves or creates a client instance from this configuration object. If instantiated from this configuration, the resulting object is also cached in the property ``client`` and a reference to this configuration is stored on the client object. :return: Client object instance. :rtype: d...
[ "Retrieves", "or", "creates", "a", "client", "instance", "from", "this", "configuration", "object", ".", "If", "instantiated", "from", "this", "configuration", "the", "resulting", "object", "is", "also", "cached", "in", "the", "property", "client", "and", "a", ...
e14fe86a6ff5c33d121eb2f9157e9359cb80dd02
https://github.com/merll/docker-map/blob/e14fe86a6ff5c33d121eb2f9157e9359cb80dd02/dockermap/map/config/client.py#L104-L121
train
61,580
merll/docker-map
dockermap/map/runner/cmd.py
ExecMixin.exec_commands
def exec_commands(self, action, c_name, run_cmds, **kwargs): """ Runs a single command inside a container. :param action: Action configuration. :type action: dockermap.map.runner.ActionConfig :param c_name: Container name. :type c_name: unicode | str :param run_c...
python
def exec_commands(self, action, c_name, run_cmds, **kwargs): """ Runs a single command inside a container. :param action: Action configuration. :type action: dockermap.map.runner.ActionConfig :param c_name: Container name. :type c_name: unicode | str :param run_c...
[ "def", "exec_commands", "(", "self", ",", "action", ",", "c_name", ",", "run_cmds", ",", "*", "*", "kwargs", ")", ":", "client", "=", "action", ".", "client", "exec_results", "=", "[", "]", "for", "run_cmd", "in", "run_cmds", ":", "cmd", "=", "run_cmd"...
Runs a single command inside a container. :param action: Action configuration. :type action: dockermap.map.runner.ActionConfig :param c_name: Container name. :type c_name: unicode | str :param run_cmds: Commands to run. :type run_cmds: list[dockermap.map.input.ExecComman...
[ "Runs", "a", "single", "command", "inside", "a", "container", "." ]
e14fe86a6ff5c33d121eb2f9157e9359cb80dd02
https://github.com/merll/docker-map/blob/e14fe86a6ff5c33d121eb2f9157e9359cb80dd02/dockermap/map/runner/cmd.py#L21-L53
train
61,581
merll/docker-map
dockermap/map/runner/cmd.py
ExecMixin.exec_container_commands
def exec_container_commands(self, action, c_name, **kwargs): """ Runs all configured commands of a container configuration inside the container instance. :param action: Action configuration. :type action: dockermap.map.runner.ActionConfig :param c_name: Container name. :...
python
def exec_container_commands(self, action, c_name, **kwargs): """ Runs all configured commands of a container configuration inside the container instance. :param action: Action configuration. :type action: dockermap.map.runner.ActionConfig :param c_name: Container name. :...
[ "def", "exec_container_commands", "(", "self", ",", "action", ",", "c_name", ",", "*", "*", "kwargs", ")", ":", "config_cmds", "=", "action", ".", "config", ".", "exec_commands", "if", "not", "config_cmds", ":", "return", "None", "return", "self", ".", "ex...
Runs all configured commands of a container configuration inside the container instance. :param action: Action configuration. :type action: dockermap.map.runner.ActionConfig :param c_name: Container name. :type c_name: unicode | str :return: List of exec command return values (e...
[ "Runs", "all", "configured", "commands", "of", "a", "container", "configuration", "inside", "the", "container", "instance", "." ]
e14fe86a6ff5c33d121eb2f9157e9359cb80dd02
https://github.com/merll/docker-map/blob/e14fe86a6ff5c33d121eb2f9157e9359cb80dd02/dockermap/map/runner/cmd.py#L55-L70
train
61,582
merll/docker-map
dockermap/build/dockerfile.py
prepare_path
def prepare_path(path, replace_space, replace_sep, expandvars, expanduser): """ Performs `os.path` replacement operations on a path string. :param path: Path string :type path: unicode | str :param replace_space: Mask spaces with backslash. :param replace_sep: Replace potentially different path...
python
def prepare_path(path, replace_space, replace_sep, expandvars, expanduser): """ Performs `os.path` replacement operations on a path string. :param path: Path string :type path: unicode | str :param replace_space: Mask spaces with backslash. :param replace_sep: Replace potentially different path...
[ "def", "prepare_path", "(", "path", ",", "replace_space", ",", "replace_sep", ",", "expandvars", ",", "expanduser", ")", ":", "r_path", "=", "path", "if", "expandvars", ":", "r_path", "=", "os", ".", "path", ".", "expandvars", "(", "r_path", ")", "if", "...
Performs `os.path` replacement operations on a path string. :param path: Path string :type path: unicode | str :param replace_space: Mask spaces with backslash. :param replace_sep: Replace potentially different path separators with POSIX path notation (use :const:`posixpath.sep`). :type replace_sep...
[ "Performs", "os", ".", "path", "replacement", "operations", "on", "a", "path", "string", "." ]
e14fe86a6ff5c33d121eb2f9157e9359cb80dd02
https://github.com/merll/docker-map/blob/e14fe86a6ff5c33d121eb2f9157e9359cb80dd02/dockermap/build/dockerfile.py#L16-L41
train
61,583
merll/docker-map
dockermap/build/dockerfile.py
format_command
def format_command(cmd, shell=False): """ Converts a command line to the notation as used in a Dockerfile ``CMD`` and ``ENTRYPOINT`` command. In shell notation, this returns a simple string, whereas by default it returns a JSON-list format with the command and arguments. :param cmd: Command line as...
python
def format_command(cmd, shell=False): """ Converts a command line to the notation as used in a Dockerfile ``CMD`` and ``ENTRYPOINT`` command. In shell notation, this returns a simple string, whereas by default it returns a JSON-list format with the command and arguments. :param cmd: Command line as...
[ "def", "format_command", "(", "cmd", ",", "shell", "=", "False", ")", ":", "def", "_split_cmd", "(", ")", ":", "line", "=", "None", "for", "part", "in", "cmd", ".", "split", "(", "' '", ")", ":", "line", "=", "part", "if", "line", "is", "None", "...
Converts a command line to the notation as used in a Dockerfile ``CMD`` and ``ENTRYPOINT`` command. In shell notation, this returns a simple string, whereas by default it returns a JSON-list format with the command and arguments. :param cmd: Command line as a string or tuple. :type cmd: unicode | str |...
[ "Converts", "a", "command", "line", "to", "the", "notation", "as", "used", "in", "a", "Dockerfile", "CMD", "and", "ENTRYPOINT", "command", ".", "In", "shell", "notation", "this", "returns", "a", "simple", "string", "whereas", "by", "default", "it", "returns"...
e14fe86a6ff5c33d121eb2f9157e9359cb80dd02
https://github.com/merll/docker-map/blob/e14fe86a6ff5c33d121eb2f9157e9359cb80dd02/dockermap/build/dockerfile.py#L44-L80
train
61,584
merll/docker-map
dockermap/build/dockerfile.py
format_expose
def format_expose(expose): """ Converts a port number or multiple port numbers, as used in the Dockerfile ``EXPOSE`` command, to a tuple. :param: Port numbers, can be as integer, string, or a list/tuple of those. :type expose: int | unicode | str | list | tuple :return: A tuple, to be separated by ...
python
def format_expose(expose): """ Converts a port number or multiple port numbers, as used in the Dockerfile ``EXPOSE`` command, to a tuple. :param: Port numbers, can be as integer, string, or a list/tuple of those. :type expose: int | unicode | str | list | tuple :return: A tuple, to be separated by ...
[ "def", "format_expose", "(", "expose", ")", ":", "if", "isinstance", "(", "expose", ",", "six", ".", "string_types", ")", ":", "return", "expose", ",", "elif", "isinstance", "(", "expose", ",", "collections", ".", "Iterable", ")", ":", "return", "map", "...
Converts a port number or multiple port numbers, as used in the Dockerfile ``EXPOSE`` command, to a tuple. :param: Port numbers, can be as integer, string, or a list/tuple of those. :type expose: int | unicode | str | list | tuple :return: A tuple, to be separated by spaces before inserting in a Dockerfile...
[ "Converts", "a", "port", "number", "or", "multiple", "port", "numbers", "as", "used", "in", "the", "Dockerfile", "EXPOSE", "command", "to", "a", "tuple", "." ]
e14fe86a6ff5c33d121eb2f9157e9359cb80dd02
https://github.com/merll/docker-map/blob/e14fe86a6ff5c33d121eb2f9157e9359cb80dd02/dockermap/build/dockerfile.py#L83-L96
train
61,585
merll/docker-map
dockermap/build/dockerfile.py
DockerFile.add_file
def add_file(self, src_path, dst_path=None, ctx_path=None, replace_space=True, expandvars=False, expanduser=False, remove_final=False): """ Adds a file to the Docker build. An ``ADD`` command is inserted, and the path is stored for later packaging of the context tarball. ...
python
def add_file(self, src_path, dst_path=None, ctx_path=None, replace_space=True, expandvars=False, expanduser=False, remove_final=False): """ Adds a file to the Docker build. An ``ADD`` command is inserted, and the path is stored for later packaging of the context tarball. ...
[ "def", "add_file", "(", "self", ",", "src_path", ",", "dst_path", "=", "None", ",", "ctx_path", "=", "None", ",", "replace_space", "=", "True", ",", "expandvars", "=", "False", ",", "expanduser", "=", "False", ",", "remove_final", "=", "False", ")", ":",...
Adds a file to the Docker build. An ``ADD`` command is inserted, and the path is stored for later packaging of the context tarball. :param src_path: Path to the file or directory. :type src_path: unicode | str :param dst_path: Destination path during the Docker build. By default uses th...
[ "Adds", "a", "file", "to", "the", "Docker", "build", ".", "An", "ADD", "command", "is", "inserted", "and", "the", "path", "is", "stored", "for", "later", "packaging", "of", "the", "context", "tarball", "." ]
e14fe86a6ff5c33d121eb2f9157e9359cb80dd02
https://github.com/merll/docker-map/blob/e14fe86a6ff5c33d121eb2f9157e9359cb80dd02/dockermap/build/dockerfile.py#L202-L249
train
61,586
merll/docker-map
dockermap/build/dockerfile.py
DockerFile.write
def write(self, input_str): """ Adds content to the Dockerfile. :param input_str: Content. :type input_str: unicode | str """ self.check_not_finalized() if isinstance(input_str, six.binary_type): self.fileobj.write(input_str) else: ...
python
def write(self, input_str): """ Adds content to the Dockerfile. :param input_str: Content. :type input_str: unicode | str """ self.check_not_finalized() if isinstance(input_str, six.binary_type): self.fileobj.write(input_str) else: ...
[ "def", "write", "(", "self", ",", "input_str", ")", ":", "self", ".", "check_not_finalized", "(", ")", "if", "isinstance", "(", "input_str", ",", "six", ".", "binary_type", ")", ":", "self", ".", "fileobj", ".", "write", "(", "input_str", ")", "else", ...
Adds content to the Dockerfile. :param input_str: Content. :type input_str: unicode | str
[ "Adds", "content", "to", "the", "Dockerfile", "." ]
e14fe86a6ff5c33d121eb2f9157e9359cb80dd02
https://github.com/merll/docker-map/blob/e14fe86a6ff5c33d121eb2f9157e9359cb80dd02/dockermap/build/dockerfile.py#L307-L318
train
61,587
merll/docker-map
dockermap/map/policy/dep.py
ContainerDependencyMergeMixin.merge_dependency
def merge_dependency(self, item, resolve_parent, parents): """ Merge dependencies of current configuration with further dependencies; in this instance, it means that in case of container configuration first parent dependencies are checked, and then immediate dependencies of the current c...
python
def merge_dependency(self, item, resolve_parent, parents): """ Merge dependencies of current configuration with further dependencies; in this instance, it means that in case of container configuration first parent dependencies are checked, and then immediate dependencies of the current c...
[ "def", "merge_dependency", "(", "self", ",", "item", ",", "resolve_parent", ",", "parents", ")", ":", "dep", "=", "[", "]", "for", "parent_key", "in", "parents", ":", "if", "item", "==", "parent_key", ":", "raise", "CircularDependency", "(", "item", ",", ...
Merge dependencies of current configuration with further dependencies; in this instance, it means that in case of container configuration first parent dependencies are checked, and then immediate dependencies of the current configuration should be added to the list, but without duplicating any entries. ...
[ "Merge", "dependencies", "of", "current", "configuration", "with", "further", "dependencies", ";", "in", "this", "instance", "it", "means", "that", "in", "case", "of", "container", "configuration", "first", "parent", "dependencies", "are", "checked", "and", "then"...
e14fe86a6ff5c33d121eb2f9157e9359cb80dd02
https://github.com/merll/docker-map/blob/e14fe86a6ff5c33d121eb2f9157e9359cb80dd02/dockermap/map/policy/dep.py#L14-L39
train
61,588
merll/docker-map
dockermap/map/yaml.py
load_map
def load_map(stream, name=None, check_integrity=True, check_duplicates=True): """ Loads a ContainerMap configuration from a YAML document stream. :param stream: YAML stream. :type stream: file :param name: Name of the ContainerMap. If not provided, will be attempted to read from a ``name`` attribut...
python
def load_map(stream, name=None, check_integrity=True, check_duplicates=True): """ Loads a ContainerMap configuration from a YAML document stream. :param stream: YAML stream. :type stream: file :param name: Name of the ContainerMap. If not provided, will be attempted to read from a ``name`` attribut...
[ "def", "load_map", "(", "stream", ",", "name", "=", "None", ",", "check_integrity", "=", "True", ",", "check_duplicates", "=", "True", ")", ":", "map_dict", "=", "yaml", ".", "safe_load", "(", "stream", ")", "if", "isinstance", "(", "map_dict", ",", "dic...
Loads a ContainerMap configuration from a YAML document stream. :param stream: YAML stream. :type stream: file :param name: Name of the ContainerMap. If not provided, will be attempted to read from a ``name`` attribute on the document root level. :type name: unicode | str :param check_integri...
[ "Loads", "a", "ContainerMap", "configuration", "from", "a", "YAML", "document", "stream", "." ]
e14fe86a6ff5c33d121eb2f9157e9359cb80dd02
https://github.com/merll/docker-map/blob/e14fe86a6ff5c33d121eb2f9157e9359cb80dd02/dockermap/map/yaml.py#L56-L78
train
61,589
merll/docker-map
dockermap/map/yaml.py
load_clients
def load_clients(stream, configuration_class=ClientConfiguration): """ Loads client configurations from a YAML document stream. :param stream: YAML stream. :type stream: file :param configuration_class: Class of the configuration object to create. :type configuration_class: class :return: A...
python
def load_clients(stream, configuration_class=ClientConfiguration): """ Loads client configurations from a YAML document stream. :param stream: YAML stream. :type stream: file :param configuration_class: Class of the configuration object to create. :type configuration_class: class :return: A...
[ "def", "load_clients", "(", "stream", ",", "configuration_class", "=", "ClientConfiguration", ")", ":", "client_dict", "=", "yaml", ".", "safe_load", "(", "stream", ")", "if", "isinstance", "(", "client_dict", ",", "dict", ")", ":", "return", "{", "client_name...
Loads client configurations from a YAML document stream. :param stream: YAML stream. :type stream: file :param configuration_class: Class of the configuration object to create. :type configuration_class: class :return: A dictionary of client configuration objects. :rtype: dict[unicode | str, do...
[ "Loads", "client", "configurations", "from", "a", "YAML", "document", "stream", "." ]
e14fe86a6ff5c33d121eb2f9157e9359cb80dd02
https://github.com/merll/docker-map/blob/e14fe86a6ff5c33d121eb2f9157e9359cb80dd02/dockermap/map/yaml.py#L81-L96
train
61,590
merll/docker-map
dockermap/map/yaml.py
load_map_file
def load_map_file(filename, name=None, check_integrity=True): """ Loads a ContainerMap configuration from a YAML file. :param filename: YAML file name. :type filename: unicode | str :param name: Name of the ContainerMap. If ``None`` will attempt to find a ``name`` element on the root level of ...
python
def load_map_file(filename, name=None, check_integrity=True): """ Loads a ContainerMap configuration from a YAML file. :param filename: YAML file name. :type filename: unicode | str :param name: Name of the ContainerMap. If ``None`` will attempt to find a ``name`` element on the root level of ...
[ "def", "load_map_file", "(", "filename", ",", "name", "=", "None", ",", "check_integrity", "=", "True", ")", ":", "if", "name", "==", "''", ":", "base_name", "=", "os", ".", "path", ".", "basename", "(", "filename", ")", "map_name", ",", "__", ",", "...
Loads a ContainerMap configuration from a YAML file. :param filename: YAML file name. :type filename: unicode | str :param name: Name of the ContainerMap. If ``None`` will attempt to find a ``name`` element on the root level of the document; an empty string names the map according to the file, withou...
[ "Loads", "a", "ContainerMap", "configuration", "from", "a", "YAML", "file", "." ]
e14fe86a6ff5c33d121eb2f9157e9359cb80dd02
https://github.com/merll/docker-map/blob/e14fe86a6ff5c33d121eb2f9157e9359cb80dd02/dockermap/map/yaml.py#L99-L119
train
61,591
merll/docker-map
dockermap/map/yaml.py
load_clients_file
def load_clients_file(filename, configuration_class=ClientConfiguration): """ Loads client configurations from a YAML file. :param filename: YAML file name. :type filename: unicode | str :param configuration_class: Class of the configuration object to create. :type configuration_class: class ...
python
def load_clients_file(filename, configuration_class=ClientConfiguration): """ Loads client configurations from a YAML file. :param filename: YAML file name. :type filename: unicode | str :param configuration_class: Class of the configuration object to create. :type configuration_class: class ...
[ "def", "load_clients_file", "(", "filename", ",", "configuration_class", "=", "ClientConfiguration", ")", ":", "with", "open", "(", "filename", ",", "'r'", ")", "as", "f", ":", "return", "load_clients", "(", "f", ",", "configuration_class", "=", "configuration_c...
Loads client configurations from a YAML file. :param filename: YAML file name. :type filename: unicode | str :param configuration_class: Class of the configuration object to create. :type configuration_class: class :return: A dictionary of client configuration objects. :rtype: dict[unicode | st...
[ "Loads", "client", "configurations", "from", "a", "YAML", "file", "." ]
e14fe86a6ff5c33d121eb2f9157e9359cb80dd02
https://github.com/merll/docker-map/blob/e14fe86a6ff5c33d121eb2f9157e9359cb80dd02/dockermap/map/yaml.py#L122-L134
train
61,592
merll/docker-map
dockermap/map/client.py
MappingDockerClient.get_state_generator
def get_state_generator(self, action_name, policy, kwargs): """ Returns the state generator to be used for the given action. :param action_name: Action identifier name. :type action_name: unicode | str :param policy: An instance of the current policy class. :type policy:...
python
def get_state_generator(self, action_name, policy, kwargs): """ Returns the state generator to be used for the given action. :param action_name: Action identifier name. :type action_name: unicode | str :param policy: An instance of the current policy class. :type policy:...
[ "def", "get_state_generator", "(", "self", ",", "action_name", ",", "policy", ",", "kwargs", ")", ":", "state_generator_cls", "=", "self", ".", "generators", "[", "action_name", "]", "[", "0", "]", "state_generator", "=", "state_generator_cls", "(", "policy", ...
Returns the state generator to be used for the given action. :param action_name: Action identifier name. :type action_name: unicode | str :param policy: An instance of the current policy class. :type policy: dockermap.map.policy.base.BasePolicy :param kwargs: Keyword arguments. ...
[ "Returns", "the", "state", "generator", "to", "be", "used", "for", "the", "given", "action", "." ]
e14fe86a6ff5c33d121eb2f9157e9359cb80dd02
https://github.com/merll/docker-map/blob/e14fe86a6ff5c33d121eb2f9157e9359cb80dd02/dockermap/map/client.py#L112-L127
train
61,593
merll/docker-map
dockermap/map/client.py
MappingDockerClient.get_action_generator
def get_action_generator(self, action_name, policy, kwargs): """ Returns the action generator to be used for the given action. :param action_name: Action identifier name. :type action_name: unicode | str :param policy: An instance of the current policy class. :type polic...
python
def get_action_generator(self, action_name, policy, kwargs): """ Returns the action generator to be used for the given action. :param action_name: Action identifier name. :type action_name: unicode | str :param policy: An instance of the current policy class. :type polic...
[ "def", "get_action_generator", "(", "self", ",", "action_name", ",", "policy", ",", "kwargs", ")", ":", "action_generator_cls", "=", "self", ".", "generators", "[", "action_name", "]", "[", "1", "]", "action_generator", "=", "action_generator_cls", "(", "policy"...
Returns the action generator to be used for the given action. :param action_name: Action identifier name. :type action_name: unicode | str :param policy: An instance of the current policy class. :type policy: dockermap.map.policy.base.BasePolicy :param kwargs: Keyword arguments....
[ "Returns", "the", "action", "generator", "to", "be", "used", "for", "the", "given", "action", "." ]
e14fe86a6ff5c33d121eb2f9157e9359cb80dd02
https://github.com/merll/docker-map/blob/e14fe86a6ff5c33d121eb2f9157e9359cb80dd02/dockermap/map/client.py#L129-L144
train
61,594
merll/docker-map
dockermap/map/client.py
MappingDockerClient.get_states
def get_states(self, action_name, config_name, instances=None, map_name=None, **kwargs): """ Returns a generator of states in relation to the indicated action. :param action_name: Action name. :type action_name: unicode | str :param config_name: Name(s) of container configuratio...
python
def get_states(self, action_name, config_name, instances=None, map_name=None, **kwargs): """ Returns a generator of states in relation to the indicated action. :param action_name: Action name. :type action_name: unicode | str :param config_name: Name(s) of container configuratio...
[ "def", "get_states", "(", "self", ",", "action_name", ",", "config_name", ",", "instances", "=", "None", ",", "map_name", "=", "None", ",", "*", "*", "kwargs", ")", ":", "policy", "=", "self", ".", "get_policy", "(", ")", "_set_forced_update_ids", "(", "...
Returns a generator of states in relation to the indicated action. :param action_name: Action name. :type action_name: unicode | str :param config_name: Name(s) of container configuration(s) or MapConfigId tuple(s). :type config_name: unicode | str | collections.Iterable[unicode | str] ...
[ "Returns", "a", "generator", "of", "states", "in", "relation", "to", "the", "indicated", "action", "." ]
e14fe86a6ff5c33d121eb2f9157e9359cb80dd02
https://github.com/merll/docker-map/blob/e14fe86a6ff5c33d121eb2f9157e9359cb80dd02/dockermap/map/client.py#L159-L181
train
61,595
merll/docker-map
dockermap/map/client.py
MappingDockerClient.get_actions
def get_actions(self, action_name, config_name, instances=None, map_name=None, **kwargs): """ Returns the entire set of actions performed for the indicated action name. :param action_name: Action name. :type action_name: unicode | str :param config_name: Name(s) of container con...
python
def get_actions(self, action_name, config_name, instances=None, map_name=None, **kwargs): """ Returns the entire set of actions performed for the indicated action name. :param action_name: Action name. :type action_name: unicode | str :param config_name: Name(s) of container con...
[ "def", "get_actions", "(", "self", ",", "action_name", ",", "config_name", ",", "instances", "=", "None", ",", "map_name", "=", "None", ",", "*", "*", "kwargs", ")", ":", "policy", "=", "self", ".", "get_policy", "(", ")", "action_generator", "=", "self"...
Returns the entire set of actions performed for the indicated action name. :param action_name: Action name. :type action_name: unicode | str :param config_name: Name(s) of container configuration(s) or MapConfigId tuple(s). :type config_name: unicode | str | collections.Iterable[unicode...
[ "Returns", "the", "entire", "set", "of", "actions", "performed", "for", "the", "indicated", "action", "name", "." ]
e14fe86a6ff5c33d121eb2f9157e9359cb80dd02
https://github.com/merll/docker-map/blob/e14fe86a6ff5c33d121eb2f9157e9359cb80dd02/dockermap/map/client.py#L183-L207
train
61,596
merll/docker-map
dockermap/map/client.py
MappingDockerClient.create
def create(self, container, instances=None, map_name=None, **kwargs): """ Creates container instances for a container configuration. :param container: Container name. :type container: unicode | str :param instances: Instance name to create. If not specified, will create all inst...
python
def create(self, container, instances=None, map_name=None, **kwargs): """ Creates container instances for a container configuration. :param container: Container name. :type container: unicode | str :param instances: Instance name to create. If not specified, will create all inst...
[ "def", "create", "(", "self", ",", "container", ",", "instances", "=", "None", ",", "map_name", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "run_actions", "(", "'create'", ",", "container", ",", "instances", "=", "instances", ...
Creates container instances for a container configuration. :param container: Container name. :type container: unicode | str :param instances: Instance name to create. If not specified, will create all instances as specified in the configuration (or just one default instance). :...
[ "Creates", "container", "instances", "for", "a", "container", "configuration", "." ]
e14fe86a6ff5c33d121eb2f9157e9359cb80dd02
https://github.com/merll/docker-map/blob/e14fe86a6ff5c33d121eb2f9157e9359cb80dd02/dockermap/map/client.py#L240-L256
train
61,597
merll/docker-map
dockermap/map/client.py
MappingDockerClient.start
def start(self, container, instances=None, map_name=None, **kwargs): """ Starts instances for a container configuration. :param container: Container name. :type container: unicode | str :param instances: Instance names to start. If not specified, will start all instances as spec...
python
def start(self, container, instances=None, map_name=None, **kwargs): """ Starts instances for a container configuration. :param container: Container name. :type container: unicode | str :param instances: Instance names to start. If not specified, will start all instances as spec...
[ "def", "start", "(", "self", ",", "container", ",", "instances", "=", "None", ",", "map_name", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "run_actions", "(", "'start'", ",", "container", ",", "instances", "=", "instances", "...
Starts instances for a container configuration. :param container: Container name. :type container: unicode | str :param instances: Instance names to start. If not specified, will start all instances as specified in the configuration (or just one default instance). :param map_na...
[ "Starts", "instances", "for", "a", "container", "configuration", "." ]
e14fe86a6ff5c33d121eb2f9157e9359cb80dd02
https://github.com/merll/docker-map/blob/e14fe86a6ff5c33d121eb2f9157e9359cb80dd02/dockermap/map/client.py#L258-L274
train
61,598
merll/docker-map
dockermap/map/client.py
MappingDockerClient.restart
def restart(self, container, instances=None, map_name=None, **kwargs): """ Restarts instances for a container configuration. :param container: Container name. :type container: unicode | str :param instances: Instance names to stop. If not specified, will restart all instances as...
python
def restart(self, container, instances=None, map_name=None, **kwargs): """ Restarts instances for a container configuration. :param container: Container name. :type container: unicode | str :param instances: Instance names to stop. If not specified, will restart all instances as...
[ "def", "restart", "(", "self", ",", "container", ",", "instances", "=", "None", ",", "map_name", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "run_actions", "(", "'restart'", ",", "container", ",", "instances", "=", "instances",...
Restarts instances for a container configuration. :param container: Container name. :type container: unicode | str :param instances: Instance names to stop. If not specified, will restart all instances as specified in the configuration (or just one default instance). :type inst...
[ "Restarts", "instances", "for", "a", "container", "configuration", "." ]
e14fe86a6ff5c33d121eb2f9157e9359cb80dd02
https://github.com/merll/docker-map/blob/e14fe86a6ff5c33d121eb2f9157e9359cb80dd02/dockermap/map/client.py#L276-L292
train
61,599