repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
klingtnet/sblgntparser | sblgntparser/model.py | Text.find | def find(self, sought, view='lemma'):
'''
Returns a word instance for the hit if the "sought" word is found in the text.
Per default the "lemma" view of the words is compared.
You can specify the desired view with the optional "view" option.
'''
hits = []
for sent... | python | def find(self, sought, view='lemma'):
'''
Returns a word instance for the hit if the "sought" word is found in the text.
Per default the "lemma" view of the words is compared.
You can specify the desired view with the optional "view" option.
'''
hits = []
for sent... | [
"def",
"find",
"(",
"self",
",",
"sought",
",",
"view",
"=",
"'lemma'",
")",
":",
"hits",
"=",
"[",
"]",
"for",
"sentence",
"in",
"self",
".",
"_sentences",
":",
"hits",
"+=",
"sentence",
".",
"find",
"(",
"sought",
",",
"view",
")",
"return",
"hit... | Returns a word instance for the hit if the "sought" word is found in the text.
Per default the "lemma" view of the words is compared.
You can specify the desired view with the optional "view" option. | [
"Returns",
"a",
"word",
"instance",
"for",
"the",
"hit",
"if",
"the",
"sought",
"word",
"is",
"found",
"in",
"the",
"text",
".",
"Per",
"default",
"the",
"lemma",
"view",
"of",
"the",
"words",
"is",
"compared",
".",
"You",
"can",
"specify",
"the",
"des... | train | https://github.com/klingtnet/sblgntparser/blob/535931a833203e5d9065072ec988c575b493d67f/sblgntparser/model.py#L28-L37 |
klingtnet/sblgntparser | sblgntparser/model.py | Sentence.find | def find(self, sought, view='lemma'):
'''
Returns a word instance for the hit if the "sought" word is found in the sentence.
Per default the "lemma" view of the words is compared.
You can specify the desired view with the optional "view" option.
'''
for word in self.wordl... | python | def find(self, sought, view='lemma'):
'''
Returns a word instance for the hit if the "sought" word is found in the sentence.
Per default the "lemma" view of the words is compared.
You can specify the desired view with the optional "view" option.
'''
for word in self.wordl... | [
"def",
"find",
"(",
"self",
",",
"sought",
",",
"view",
"=",
"'lemma'",
")",
":",
"for",
"word",
"in",
"self",
".",
"wordlist",
":",
"if",
"sought",
"==",
"word",
".",
"views",
"[",
"view",
"]",
":",
"yield",
"word"
] | Returns a word instance for the hit if the "sought" word is found in the sentence.
Per default the "lemma" view of the words is compared.
You can specify the desired view with the optional "view" option. | [
"Returns",
"a",
"word",
"instance",
"for",
"the",
"hit",
"if",
"the",
"sought",
"word",
"is",
"found",
"in",
"the",
"sentence",
".",
"Per",
"default",
"the",
"lemma",
"view",
"of",
"the",
"words",
"is",
"compared",
".",
"You",
"can",
"specify",
"the",
... | train | https://github.com/klingtnet/sblgntparser/blob/535931a833203e5d9065072ec988c575b493d67f/sblgntparser/model.py#L63-L71 |
klingtnet/sblgntparser | sblgntparser/model.py | Sentence.word | def word(self, position):
'''
Returns the word instance at the given position in the sentence, None if not found.
'''
if 0 <= position < len(self.wordlist):
return self.wordlist[position]
else:
log.warn('position "{}" is not in sentence of length "{}"!'.fo... | python | def word(self, position):
'''
Returns the word instance at the given position in the sentence, None if not found.
'''
if 0 <= position < len(self.wordlist):
return self.wordlist[position]
else:
log.warn('position "{}" is not in sentence of length "{}"!'.fo... | [
"def",
"word",
"(",
"self",
",",
"position",
")",
":",
"if",
"0",
"<=",
"position",
"<",
"len",
"(",
"self",
".",
"wordlist",
")",
":",
"return",
"self",
".",
"wordlist",
"[",
"position",
"]",
"else",
":",
"log",
".",
"warn",
"(",
"'position \"{}\" i... | Returns the word instance at the given position in the sentence, None if not found. | [
"Returns",
"the",
"word",
"instance",
"at",
"the",
"given",
"position",
"in",
"the",
"sentence",
"None",
"if",
"not",
"found",
"."
] | train | https://github.com/klingtnet/sblgntparser/blob/535931a833203e5d9065072ec988c575b493d67f/sblgntparser/model.py#L79-L87 |
klingtnet/sblgntparser | sblgntparser/model.py | Word.subsentence | def subsentence(self):
'''
Returns the subsentence that contains this word, otherwise the whole sentence.
TODO
'''
subsentence = []
for word in self.sentence()[:self._position:-1]:
# left search
pass
for word in self.sentence()[:self._posit... | python | def subsentence(self):
'''
Returns the subsentence that contains this word, otherwise the whole sentence.
TODO
'''
subsentence = []
for word in self.sentence()[:self._position:-1]:
# left search
pass
for word in self.sentence()[:self._posit... | [
"def",
"subsentence",
"(",
"self",
")",
":",
"subsentence",
"=",
"[",
"]",
"for",
"word",
"in",
"self",
".",
"sentence",
"(",
")",
"[",
":",
"self",
".",
"_position",
":",
"-",
"1",
"]",
":",
"# left search",
"pass",
"for",
"word",
"in",
"self",
".... | Returns the subsentence that contains this word, otherwise the whole sentence.
TODO | [
"Returns",
"the",
"subsentence",
"that",
"contains",
"this",
"word",
"otherwise",
"the",
"whole",
"sentence",
".",
"TODO"
] | train | https://github.com/klingtnet/sblgntparser/blob/535931a833203e5d9065072ec988c575b493d67f/sblgntparser/model.py#L120-L131 |
klingtnet/sblgntparser | sblgntparser/model.py | Word.neighbors | def neighbors(self):
'''
Returns the left and right neighbors as Word instance.
If the word is the first one in the sentence only the right neighbor is returned and vice versa.
'''
if len(self._sentence) == 1:
return {
'left': None,
'ri... | python | def neighbors(self):
'''
Returns the left and right neighbors as Word instance.
If the word is the first one in the sentence only the right neighbor is returned and vice versa.
'''
if len(self._sentence) == 1:
return {
'left': None,
'ri... | [
"def",
"neighbors",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"_sentence",
")",
"==",
"1",
":",
"return",
"{",
"'left'",
":",
"None",
",",
"'right'",
":",
"None",
"}",
"else",
":",
"p",
"=",
"self",
".",
"_position",
"if",
"-",
"1",
... | Returns the left and right neighbors as Word instance.
If the word is the first one in the sentence only the right neighbor is returned and vice versa. | [
"Returns",
"the",
"left",
"and",
"right",
"neighbors",
"as",
"Word",
"instance",
".",
"If",
"the",
"word",
"is",
"the",
"first",
"one",
"in",
"the",
"sentence",
"only",
"the",
"right",
"neighbor",
"is",
"returned",
"and",
"vice",
"versa",
"."
] | train | https://github.com/klingtnet/sblgntparser/blob/535931a833203e5d9065072ec988c575b493d67f/sblgntparser/model.py#L139-L168 |
breuleux/hrepr | hrepr/__init__.py | HRepr.hrepr_with_resources | def hrepr_with_resources(self, obj, **cfg):
"""
This is equivalent to __call__, but performs the additional step of
putting the set of resources required to properly display the object
in the _resources property of the return value.
"""
res = self(obj, **cfg)
res.... | python | def hrepr_with_resources(self, obj, **cfg):
"""
This is equivalent to __call__, but performs the additional step of
putting the set of resources required to properly display the object
in the _resources property of the return value.
"""
res = self(obj, **cfg)
res.... | [
"def",
"hrepr_with_resources",
"(",
"self",
",",
"obj",
",",
"*",
"*",
"cfg",
")",
":",
"res",
"=",
"self",
"(",
"obj",
",",
"*",
"*",
"cfg",
")",
"res",
".",
"resources",
"=",
"self",
".",
"resources",
"return",
"res"
] | This is equivalent to __call__, but performs the additional step of
putting the set of resources required to properly display the object
in the _resources property of the return value. | [
"This",
"is",
"equivalent",
"to",
"__call__",
"but",
"performs",
"the",
"additional",
"step",
"of",
"putting",
"the",
"set",
"of",
"resources",
"required",
"to",
"properly",
"display",
"the",
"object",
"in",
"the",
"_resources",
"property",
"of",
"the",
"retur... | train | https://github.com/breuleux/hrepr/blob/a411395d31ac7c8c071d174e63a093751aa5997b/hrepr/__init__.py#L146-L154 |
breuleux/hrepr | hrepr/__init__.py | HRepr.acquire_resources | def acquire_resources(self, source):
"""
Store the resources returned by ``source()``. If ``source`` has
been acquired before, it will not be called a second time.
Args:
source (callable): A function that returns a resource or a
list of resources.
Re... | python | def acquire_resources(self, source):
"""
Store the resources returned by ``source()``. If ``source`` has
been acquired before, it will not be called a second time.
Args:
source (callable): A function that returns a resource or a
list of resources.
Re... | [
"def",
"acquire_resources",
"(",
"self",
",",
"source",
")",
":",
"if",
"source",
"not",
"in",
"self",
".",
"consulted",
":",
"self",
".",
"consulted",
".",
"add",
"(",
"source",
")",
"if",
"isinstance",
"(",
"source",
",",
"Tag",
")",
":",
"res",
"=... | Store the resources returned by ``source()``. If ``source`` has
been acquired before, it will not be called a second time.
Args:
source (callable): A function that returns a resource or a
list of resources.
Returns:
None | [
"Store",
"the",
"resources",
"returned",
"by",
"source",
"()",
".",
"If",
"source",
"has",
"been",
"acquired",
"before",
"it",
"will",
"not",
"be",
"called",
"a",
"second",
"time",
"."
] | train | https://github.com/breuleux/hrepr/blob/a411395d31ac7c8c071d174e63a093751aa5997b/hrepr/__init__.py#L166-L190 |
breuleux/hrepr | hrepr/__init__.py | HRepr.stdrepr | def stdrepr(self, obj, *, cls=None, tag='span'):
"""
Standard representation for objects, used when there is no
handler for its type in type_handlers on the HRepr object,
and no __hrepr__ method on obj. For an object of class 'klass',
the result is:
``<span class="hrepr-... | python | def stdrepr(self, obj, *, cls=None, tag='span'):
"""
Standard representation for objects, used when there is no
handler for its type in type_handlers on the HRepr object,
and no __hrepr__ method on obj. For an object of class 'klass',
the result is:
``<span class="hrepr-... | [
"def",
"stdrepr",
"(",
"self",
",",
"obj",
",",
"*",
",",
"cls",
"=",
"None",
",",
"tag",
"=",
"'span'",
")",
":",
"if",
"cls",
"is",
"None",
":",
"cls",
"=",
"f'hrepr-{obj.__class__.__name__}'",
"return",
"getattr",
"(",
"self",
".",
"H",
",",
"tag"... | Standard representation for objects, used when there is no
handler for its type in type_handlers on the HRepr object,
and no __hrepr__ method on obj. For an object of class 'klass',
the result is:
``<span class="hrepr-klass">{escape(str(obj))}</span>``
Where ``{escape(str(obj))... | [
"Standard",
"representation",
"for",
"objects",
"used",
"when",
"there",
"is",
"no",
"handler",
"for",
"its",
"type",
"in",
"type_handlers",
"on",
"the",
"HRepr",
"object",
"and",
"no",
"__hrepr__",
"method",
"on",
"obj",
".",
"For",
"an",
"object",
"of",
... | train | https://github.com/breuleux/hrepr/blob/a411395d31ac7c8c071d174e63a093751aa5997b/hrepr/__init__.py#L213-L234 |
breuleux/hrepr | hrepr/__init__.py | HRepr.stdrepr_short | def stdrepr_short(self, obj, *, cls=None, tag='span'):
"""
Standard short representation for objects, used for objects at
a depth that exceeds ``hrepr_object.config.max_depth``. That
representation is just the object's type between ``<>``s, e.g.
``<MyClass>``.
This behav... | python | def stdrepr_short(self, obj, *, cls=None, tag='span'):
"""
Standard short representation for objects, used for objects at
a depth that exceeds ``hrepr_object.config.max_depth``. That
representation is just the object's type between ``<>``s, e.g.
``<MyClass>``.
This behav... | [
"def",
"stdrepr_short",
"(",
"self",
",",
"obj",
",",
"*",
",",
"cls",
"=",
"None",
",",
"tag",
"=",
"'span'",
")",
":",
"cls_name",
"=",
"obj",
".",
"__class__",
".",
"__name__",
"if",
"cls",
"is",
"None",
":",
"cls",
"=",
"f'hrepr-short-{cls_name}'",... | Standard short representation for objects, used for objects at
a depth that exceeds ``hrepr_object.config.max_depth``. That
representation is just the object's type between ``<>``s, e.g.
``<MyClass>``.
This behavior can be overriden with a ``__hrepr_short__`` method
on the objec... | [
"Standard",
"short",
"representation",
"for",
"objects",
"used",
"for",
"objects",
"at",
"a",
"depth",
"that",
"exceeds",
"hrepr_object",
".",
"config",
".",
"max_depth",
".",
"That",
"representation",
"is",
"just",
"the",
"object",
"s",
"type",
"between",
"<"... | train | https://github.com/breuleux/hrepr/blob/a411395d31ac7c8c071d174e63a093751aa5997b/hrepr/__init__.py#L236-L256 |
breuleux/hrepr | hrepr/__init__.py | HRepr.stdrepr_iterable | def stdrepr_iterable(self, obj, *,
cls=None, before=None, after=None):
"""
Helper function to represent iterables. StdHRepr calls this on
lists, tuples, sets and frozensets, but NOT on iterables in general.
This method may be called to produce custom representati... | python | def stdrepr_iterable(self, obj, *,
cls=None, before=None, after=None):
"""
Helper function to represent iterables. StdHRepr calls this on
lists, tuples, sets and frozensets, but NOT on iterables in general.
This method may be called to produce custom representati... | [
"def",
"stdrepr_iterable",
"(",
"self",
",",
"obj",
",",
"*",
",",
"cls",
"=",
"None",
",",
"before",
"=",
"None",
",",
"after",
"=",
"None",
")",
":",
"if",
"cls",
"is",
"None",
":",
"cls",
"=",
"f'hrepr-{obj.__class__.__name__}'",
"children",
"=",
"[... | Helper function to represent iterables. StdHRepr calls this on
lists, tuples, sets and frozensets, but NOT on iterables in general.
This method may be called to produce custom representations.
Arguments:
obj (iterable): The iterable to represent.
cls (optional): The clas... | [
"Helper",
"function",
"to",
"represent",
"iterables",
".",
"StdHRepr",
"calls",
"this",
"on",
"lists",
"tuples",
"sets",
"and",
"frozensets",
"but",
"NOT",
"on",
"iterables",
"in",
"general",
".",
"This",
"method",
"may",
"be",
"called",
"to",
"produce",
"cu... | train | https://github.com/breuleux/hrepr/blob/a411395d31ac7c8c071d174e63a093751aa5997b/hrepr/__init__.py#L258-L275 |
breuleux/hrepr | hrepr/__init__.py | HRepr.stdrepr_object | def stdrepr_object(self, title, elements, *, cls=None,
short=False, quote_string_keys=False,
delimiter=None):
"""
Helper function to represent objects.
Arguments:
title: A title string displayed above the box containing
t... | python | def stdrepr_object(self, title, elements, *, cls=None,
short=False, quote_string_keys=False,
delimiter=None):
"""
Helper function to represent objects.
Arguments:
title: A title string displayed above the box containing
t... | [
"def",
"stdrepr_object",
"(",
"self",
",",
"title",
",",
"elements",
",",
"*",
",",
"cls",
"=",
"None",
",",
"short",
"=",
"False",
",",
"quote_string_keys",
"=",
"False",
",",
"delimiter",
"=",
"None",
")",
":",
"H",
"=",
"self",
".",
"H",
"if",
"... | Helper function to represent objects.
Arguments:
title: A title string displayed above the box containing
the elements, or a pair of two strings that will be
displayed left and right (e.g. a pair of brackets).
elements: A list of (key, value) pairs, which... | [
"Helper",
"function",
"to",
"represent",
"objects",
"."
] | train | https://github.com/breuleux/hrepr/blob/a411395d31ac7c8c071d174e63a093751aa5997b/hrepr/__init__.py#L277-L340 |
breuleux/hrepr | hrepr/__init__.py | HRepr.titled_box | def titled_box(self, titles, contents, tdir='h', cdir='h'):
"""
Helper function to build a box containing a list of elements,
with a title above and/or below, or left and/or right of the
box. (e.g. a class name on top, or brackets on both sides.)
The elements given must already ... | python | def titled_box(self, titles, contents, tdir='h', cdir='h'):
"""
Helper function to build a box containing a list of elements,
with a title above and/or below, or left and/or right of the
box. (e.g. a class name on top, or brackets on both sides.)
The elements given must already ... | [
"def",
"titled_box",
"(",
"self",
",",
"titles",
",",
"contents",
",",
"tdir",
"=",
"'h'",
",",
"cdir",
"=",
"'h'",
")",
":",
"H",
"=",
"self",
".",
"H",
"def",
"wrapt",
"(",
"x",
")",
":",
"return",
"H",
".",
"div",
"[",
"'hrepr-title'",
"]",
... | Helper function to build a box containing a list of elements,
with a title above and/or below, or left and/or right of the
box. (e.g. a class name on top, or brackets on both sides.)
The elements given must already have been transformed into
Tag instances.
Arguments:
... | [
"Helper",
"function",
"to",
"build",
"a",
"box",
"containing",
"a",
"list",
"of",
"elements",
"with",
"a",
"title",
"above",
"and",
"/",
"or",
"below",
"or",
"left",
"and",
"/",
"or",
"right",
"of",
"the",
"box",
".",
"(",
"e",
".",
"g",
".",
"a",
... | train | https://github.com/breuleux/hrepr/blob/a411395d31ac7c8c071d174e63a093751aa5997b/hrepr/__init__.py#L342-L383 |
qzmfranklin/easyshell | easycompleter/fs.py | find_matches | def find_matches(text):
r"""Find matching files for text.
For this completer to function in Unix systems, the readline module must not
treat \ and / as delimiters.
"""
path = os.path.expanduser(text)
if os.path.isdir(path) and not path.endswith('/'):
return [ text + '/' ]
pattern =... | python | def find_matches(text):
r"""Find matching files for text.
For this completer to function in Unix systems, the readline module must not
treat \ and / as delimiters.
"""
path = os.path.expanduser(text)
if os.path.isdir(path) and not path.endswith('/'):
return [ text + '/' ]
pattern =... | [
"def",
"find_matches",
"(",
"text",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"text",
")",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"path",
")",
"and",
"not",
"path",
".",
"endswith",
"(",
"'/'",
")",
":",
"return",
"["... | r"""Find matching files for text.
For this completer to function in Unix systems, the readline module must not
treat \ and / as delimiters. | [
"r",
"Find",
"matching",
"files",
"for",
"text",
"."
] | train | https://github.com/qzmfranklin/easyshell/blob/00c2e90e7767d32e7e127fc8c6875845aa308295/easycompleter/fs.py#L4-L27 |
FujiMakoto/IPS-Vagrant | ips_vagrant/commands/mysql/__init__.py | cli | def cli(ctx, dname, site):
"""
Launches a MySQL CLI session for the database of the specified IPS installation.
"""
assert isinstance(ctx, Context)
log = logging.getLogger('ipsv.mysql')
dname = domain_parse(dname).hostname
domain = Session.query(Domain).filter(Domain.name == dname).first()
... | python | def cli(ctx, dname, site):
"""
Launches a MySQL CLI session for the database of the specified IPS installation.
"""
assert isinstance(ctx, Context)
log = logging.getLogger('ipsv.mysql')
dname = domain_parse(dname).hostname
domain = Session.query(Domain).filter(Domain.name == dname).first()
... | [
"def",
"cli",
"(",
"ctx",
",",
"dname",
",",
"site",
")",
":",
"assert",
"isinstance",
"(",
"ctx",
",",
"Context",
")",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"'ipsv.mysql'",
")",
"dname",
"=",
"domain_parse",
"(",
"dname",
")",
".",
"hostname",... | Launches a MySQL CLI session for the database of the specified IPS installation. | [
"Launches",
"a",
"MySQL",
"CLI",
"session",
"for",
"the",
"database",
"of",
"the",
"specified",
"IPS",
"installation",
"."
] | train | https://github.com/FujiMakoto/IPS-Vagrant/blob/7b1d6d095034dd8befb026d9315ecc6494d52269/ips_vagrant/commands/mysql/__init__.py#L14-L49 |
ramrod-project/database-brain | schema/brain/telemetry/reads.py | target_query | def target_query(plugin, port, location):
"""
prepared ReQL for target
"""
return ((r.row[PLUGIN_NAME_KEY] == plugin) &
(r.row[PORT_FIELD] == port) &
(r.row[LOCATION_FIELD] == location)) | python | def target_query(plugin, port, location):
"""
prepared ReQL for target
"""
return ((r.row[PLUGIN_NAME_KEY] == plugin) &
(r.row[PORT_FIELD] == port) &
(r.row[LOCATION_FIELD] == location)) | [
"def",
"target_query",
"(",
"plugin",
",",
"port",
",",
"location",
")",
":",
"return",
"(",
"(",
"r",
".",
"row",
"[",
"PLUGIN_NAME_KEY",
"]",
"==",
"plugin",
")",
"&",
"(",
"r",
".",
"row",
"[",
"PORT_FIELD",
"]",
"==",
"port",
")",
"&",
"(",
"... | prepared ReQL for target | [
"prepared",
"ReQL",
"for",
"target"
] | train | https://github.com/ramrod-project/database-brain/blob/b024cb44f34cabb9d80af38271ddb65c25767083/schema/brain/telemetry/reads.py#L10-L16 |
eallik/spinoff | spinoff/util/python.py | enums | def enums(*names):
"""Returns a set of `EnumValue` objects with specified names and optionally orders.
Values in an enumeration must have unique names and be either all ordered or all unordered.
"""
if len(names) != len(list(set(names))):
raise TypeError("Names in an enumeration must be unique... | python | def enums(*names):
"""Returns a set of `EnumValue` objects with specified names and optionally orders.
Values in an enumeration must have unique names and be either all ordered or all unordered.
"""
if len(names) != len(list(set(names))):
raise TypeError("Names in an enumeration must be unique... | [
"def",
"enums",
"(",
"*",
"names",
")",
":",
"if",
"len",
"(",
"names",
")",
"!=",
"len",
"(",
"list",
"(",
"set",
"(",
"names",
")",
")",
")",
":",
"raise",
"TypeError",
"(",
"\"Names in an enumeration must be unique\"",
")",
"item_types",
"=",
"set",
... | Returns a set of `EnumValue` objects with specified names and optionally orders.
Values in an enumeration must have unique names and be either all ordered or all unordered. | [
"Returns",
"a",
"set",
"of",
"EnumValue",
"objects",
"with",
"specified",
"names",
"and",
"optionally",
"orders",
"."
] | train | https://github.com/eallik/spinoff/blob/06b00d6b86c7422c9cb8f9a4b2915906e92b7d52/spinoff/util/python.py#L45-L61 |
eallik/spinoff | spinoff/util/python.py | deferred_cleanup | def deferred_cleanup(fn):
"""Go defer style cleanups--in reality, just a convenience wrapper over try-finally"""
@functools.wraps(fn)
def ret(*args, **kwargs):
defers = []
try:
ret = fn(lambda *args: defers.extend(args), *args, **kwargs)
finally:
for defer in ... | python | def deferred_cleanup(fn):
"""Go defer style cleanups--in reality, just a convenience wrapper over try-finally"""
@functools.wraps(fn)
def ret(*args, **kwargs):
defers = []
try:
ret = fn(lambda *args: defers.extend(args), *args, **kwargs)
finally:
for defer in ... | [
"def",
"deferred_cleanup",
"(",
"fn",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"fn",
")",
"def",
"ret",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"defers",
"=",
"[",
"]",
"try",
":",
"ret",
"=",
"fn",
"(",
"lambda",
"*",
"args"... | Go defer style cleanups--in reality, just a convenience wrapper over try-finally | [
"Go",
"defer",
"style",
"cleanups",
"--",
"in",
"reality",
"just",
"a",
"convenience",
"wrapper",
"over",
"try",
"-",
"finally"
] | train | https://github.com/eallik/spinoff/blob/06b00d6b86c7422c9cb8f9a4b2915906e92b7d52/spinoff/util/python.py#L100-L111 |
looplab/skal | skal/core.py | command | def command(func_or_args=None):
"""Decorator to tell Skal that the method/function is a command.
"""
def decorator(f):
f.__args__ = args
return f
if type(func_or_args) == type(decorator):
args = {}
return decorator(func_or_args)
args = func_or_args
return decorat... | python | def command(func_or_args=None):
"""Decorator to tell Skal that the method/function is a command.
"""
def decorator(f):
f.__args__ = args
return f
if type(func_or_args) == type(decorator):
args = {}
return decorator(func_or_args)
args = func_or_args
return decorat... | [
"def",
"command",
"(",
"func_or_args",
"=",
"None",
")",
":",
"def",
"decorator",
"(",
"f",
")",
":",
"f",
".",
"__args__",
"=",
"args",
"return",
"f",
"if",
"type",
"(",
"func_or_args",
")",
"==",
"type",
"(",
"decorator",
")",
":",
"args",
"=",
"... | Decorator to tell Skal that the method/function is a command. | [
"Decorator",
"to",
"tell",
"Skal",
"that",
"the",
"method",
"/",
"function",
"is",
"a",
"command",
"."
] | train | https://github.com/looplab/skal/blob/af2ce460d9addd07ad2459125511308cfa7cdb44/skal/core.py#L126-L137 |
looplab/skal | skal/core.py | SkalApp.run | def run(self, args=None):
"""Applicatin starting point.
This will run the associated method/function/module or print a help
list if it's an unknown keyword or the syntax is incorrect.
Keyword arguments:
args -- Custom application arguments (default sys.argv)
"""
... | python | def run(self, args=None):
"""Applicatin starting point.
This will run the associated method/function/module or print a help
list if it's an unknown keyword or the syntax is incorrect.
Keyword arguments:
args -- Custom application arguments (default sys.argv)
"""
... | [
"def",
"run",
"(",
"self",
",",
"args",
"=",
"None",
")",
":",
"# TODO: Add tests to how command line arguments are passed in",
"raw_args",
"=",
"self",
".",
"__parser",
".",
"parse_args",
"(",
"args",
"=",
"args",
")",
"args",
"=",
"vars",
"(",
"raw_args",
")... | Applicatin starting point.
This will run the associated method/function/module or print a help
list if it's an unknown keyword or the syntax is incorrect.
Keyword arguments:
args -- Custom application arguments (default sys.argv) | [
"Applicatin",
"starting",
"point",
"."
] | train | https://github.com/looplab/skal/blob/af2ce460d9addd07ad2459125511308cfa7cdb44/skal/core.py#L108-L123 |
fordhurley/s3url | s3url/time.py | to_seconds | def to_seconds(string):
"""
Converts a human readable time string into seconds.
Accepts:
- 's': seconds
- 'm': minutes
- 'h': hours
- 'd': days
Examples:
>>> to_seconds('1m30s')
90
>>> to_seconds('5m')
300
>>> to_seconds('1h')
3600
>>> to_seconds('1h30m')
... | python | def to_seconds(string):
"""
Converts a human readable time string into seconds.
Accepts:
- 's': seconds
- 'm': minutes
- 'h': hours
- 'd': days
Examples:
>>> to_seconds('1m30s')
90
>>> to_seconds('5m')
300
>>> to_seconds('1h')
3600
>>> to_seconds('1h30m')
... | [
"def",
"to_seconds",
"(",
"string",
")",
":",
"units",
"=",
"{",
"'s'",
":",
"1",
",",
"'m'",
":",
"60",
",",
"'h'",
":",
"60",
"*",
"60",
",",
"'d'",
":",
"60",
"*",
"60",
"*",
"24",
"}",
"match",
"=",
"re",
".",
"search",
"(",
"r'(?:(?P<d>\... | Converts a human readable time string into seconds.
Accepts:
- 's': seconds
- 'm': minutes
- 'h': hours
- 'd': days
Examples:
>>> to_seconds('1m30s')
90
>>> to_seconds('5m')
300
>>> to_seconds('1h')
3600
>>> to_seconds('1h30m')
5400
>>> to_seconds('3d')
... | [
"Converts",
"a",
"human",
"readable",
"time",
"string",
"into",
"seconds",
"."
] | train | https://github.com/fordhurley/s3url/blob/a9e932308ee1bc70a4626ff0a28575cd6927ea33/s3url/time.py#L11-L55 |
KelSolaar/Oncilla | oncilla/slice_reStructuredText.py | slice_reStructuredText | def slice_reStructuredText(input, output):
"""
Slices given reStructuredText file.
:param input: ReStructuredText file to slice.
:type input: unicode
:param output: Directory to output sliced reStructuredText files.
:type output: unicode
:return: Definition success.
:rtype: bool
"""... | python | def slice_reStructuredText(input, output):
"""
Slices given reStructuredText file.
:param input: ReStructuredText file to slice.
:type input: unicode
:param output: Directory to output sliced reStructuredText files.
:type output: unicode
:return: Definition success.
:rtype: bool
"""... | [
"def",
"slice_reStructuredText",
"(",
"input",
",",
"output",
")",
":",
"LOGGER",
".",
"info",
"(",
"\"{0} | Slicing '{1}' file!\"",
".",
"format",
"(",
"slice_reStructuredText",
".",
"__name__",
",",
"input",
")",
")",
"file",
"=",
"File",
"(",
"input",
")",
... | Slices given reStructuredText file.
:param input: ReStructuredText file to slice.
:type input: unicode
:param output: Directory to output sliced reStructuredText files.
:type output: unicode
:return: Definition success.
:rtype: bool | [
"Slices",
"given",
"reStructuredText",
"file",
"."
] | train | https://github.com/KelSolaar/Oncilla/blob/2b4db3704cf2c22a09a207681cb041fff555a994/oncilla/slice_reStructuredText.py#L61-L118 |
FujiMakoto/IPS-Vagrant | ips_vagrant/commands/enable/__init__.py | cli | def cli(ctx, dname, site):
"""
Enable the <site> under the specified <domain>
"""
assert isinstance(ctx, Context)
dname = domain_parse(dname).hostname
domain = Session.query(Domain).filter(Domain.name == dname).first()
if not domain:
click.secho('No such domain: {dn}'.format(dn=dnam... | python | def cli(ctx, dname, site):
"""
Enable the <site> under the specified <domain>
"""
assert isinstance(ctx, Context)
dname = domain_parse(dname).hostname
domain = Session.query(Domain).filter(Domain.name == dname).first()
if not domain:
click.secho('No such domain: {dn}'.format(dn=dnam... | [
"def",
"cli",
"(",
"ctx",
",",
"dname",
",",
"site",
")",
":",
"assert",
"isinstance",
"(",
"ctx",
",",
"Context",
")",
"dname",
"=",
"domain_parse",
"(",
"dname",
")",
".",
"hostname",
"domain",
"=",
"Session",
".",
"query",
"(",
"Domain",
")",
".",... | Enable the <site> under the specified <domain> | [
"Enable",
"the",
"<site",
">",
"under",
"the",
"specified",
"<domain",
">"
] | train | https://github.com/FujiMakoto/IPS-Vagrant/blob/7b1d6d095034dd8befb026d9315ecc6494d52269/ips_vagrant/commands/enable/__init__.py#L14-L40 |
miquelo/resort | packages/resort/component/vagrant.py | VagrantObject.read | def read(self, cmd_args):
"""
Execute Vagrant read command.
:param list cmd_args:
Command argument list.
"""
args = [
"vagrant",
"--machine-readable"
]
args.extend(cmd_args)
proc = subprocess.Popen(args, stdout=subprocess.PIPE)
for line in proc.stdout.readlines():
if len(line) ==... | python | def read(self, cmd_args):
"""
Execute Vagrant read command.
:param list cmd_args:
Command argument list.
"""
args = [
"vagrant",
"--machine-readable"
]
args.extend(cmd_args)
proc = subprocess.Popen(args, stdout=subprocess.PIPE)
for line in proc.stdout.readlines():
if len(line) ==... | [
"def",
"read",
"(",
"self",
",",
"cmd_args",
")",
":",
"args",
"=",
"[",
"\"vagrant\"",
",",
"\"--machine-readable\"",
"]",
"args",
".",
"extend",
"(",
"cmd_args",
")",
"proc",
"=",
"subprocess",
".",
"Popen",
"(",
"args",
",",
"stdout",
"=",
"subprocess... | Execute Vagrant read command.
:param list cmd_args:
Command argument list. | [
"Execute",
"Vagrant",
"read",
"command",
".",
":",
"param",
"list",
"cmd_args",
":",
"Command",
"argument",
"list",
"."
] | train | https://github.com/miquelo/resort/blob/097a25d3257c91a75c194fd44c2797ab356f85dd/packages/resort/component/vagrant.py#L32-L51 |
miquelo/resort | packages/resort/component/vagrant.py | VagrantObject.write | def write(self, cmd_args):
"""
Execute Vagrant write command.
:param list cmd_args:
Command argument list.
"""
args = [
"vagrant"
]
args.extend(cmd_args)
subprocess.call(args) | python | def write(self, cmd_args):
"""
Execute Vagrant write command.
:param list cmd_args:
Command argument list.
"""
args = [
"vagrant"
]
args.extend(cmd_args)
subprocess.call(args) | [
"def",
"write",
"(",
"self",
",",
"cmd_args",
")",
":",
"args",
"=",
"[",
"\"vagrant\"",
"]",
"args",
".",
"extend",
"(",
"cmd_args",
")",
"subprocess",
".",
"call",
"(",
"args",
")"
] | Execute Vagrant write command.
:param list cmd_args:
Command argument list. | [
"Execute",
"Vagrant",
"write",
"command",
".",
":",
"param",
"list",
"cmd_args",
":",
"Command",
"argument",
"list",
"."
] | train | https://github.com/miquelo/resort/blob/097a25d3257c91a75c194fd44c2797ab356f85dd/packages/resort/component/vagrant.py#L53-L66 |
miquelo/resort | packages/resort/component/vagrant.py | BoxFile.available | def available(self, context):
"""
Box is available for the calling user.
:param resort.engine.execution.Context context:
Current execution context.
"""
if self.__available is None:
avail = False
name = context.resolve(self.__name)
for box in self.__box_list():
if box["name"] == name ... | python | def available(self, context):
"""
Box is available for the calling user.
:param resort.engine.execution.Context context:
Current execution context.
"""
if self.__available is None:
avail = False
name = context.resolve(self.__name)
for box in self.__box_list():
if box["name"] == name ... | [
"def",
"available",
"(",
"self",
",",
"context",
")",
":",
"if",
"self",
".",
"__available",
"is",
"None",
":",
"avail",
"=",
"False",
"name",
"=",
"context",
".",
"resolve",
"(",
"self",
".",
"__name",
")",
"for",
"box",
"in",
"self",
".",
"__box_li... | Box is available for the calling user.
:param resort.engine.execution.Context context:
Current execution context. | [
"Box",
"is",
"available",
"for",
"the",
"calling",
"user",
".",
":",
"param",
"resort",
".",
"engine",
".",
"execution",
".",
"Context",
"context",
":",
"Current",
"execution",
"context",
"."
] | train | https://github.com/miquelo/resort/blob/097a25d3257c91a75c194fd44c2797ab356f85dd/packages/resort/component/vagrant.py#L114-L131 |
miquelo/resort | packages/resort/component/vagrant.py | BoxFile.insert | def insert(self, context):
"""
Add Vagrant box to the calling user.
:param resort.engine.execution.Context context:
Current execution context.
"""
self.write([
"box",
"add",
"--name", context.resolve(self.__name),
self.__path(context)
]) | python | def insert(self, context):
"""
Add Vagrant box to the calling user.
:param resort.engine.execution.Context context:
Current execution context.
"""
self.write([
"box",
"add",
"--name", context.resolve(self.__name),
self.__path(context)
]) | [
"def",
"insert",
"(",
"self",
",",
"context",
")",
":",
"self",
".",
"write",
"(",
"[",
"\"box\"",
",",
"\"add\"",
",",
"\"--name\"",
",",
"context",
".",
"resolve",
"(",
"self",
".",
"__name",
")",
",",
"self",
".",
"__path",
"(",
"context",
")",
... | Add Vagrant box to the calling user.
:param resort.engine.execution.Context context:
Current execution context. | [
"Add",
"Vagrant",
"box",
"to",
"the",
"calling",
"user",
".",
":",
"param",
"resort",
".",
"engine",
".",
"execution",
".",
"Context",
"context",
":",
"Current",
"execution",
"context",
"."
] | train | https://github.com/miquelo/resort/blob/097a25d3257c91a75c194fd44c2797ab356f85dd/packages/resort/component/vagrant.py#L133-L147 |
miquelo/resort | packages/resort/component/vagrant.py | Instance.read | def read(self, context, cmd_args):
"""
Execute Vagrant read command on instance placed into configuration
directory.
:param resort.engine.execution.Context context:
Current execution context.
:param list cmd_args:
Command argument list.
"""
try:
current_dir = os.getcwd()
os.chdir(c... | python | def read(self, context, cmd_args):
"""
Execute Vagrant read command on instance placed into configuration
directory.
:param resort.engine.execution.Context context:
Current execution context.
:param list cmd_args:
Command argument list.
"""
try:
current_dir = os.getcwd()
os.chdir(c... | [
"def",
"read",
"(",
"self",
",",
"context",
",",
"cmd_args",
")",
":",
"try",
":",
"current_dir",
"=",
"os",
".",
"getcwd",
"(",
")",
"os",
".",
"chdir",
"(",
"context",
".",
"resolve",
"(",
"self",
".",
"__config_dir",
")",
")",
"args",
"=",
"[",
... | Execute Vagrant read command on instance placed into configuration
directory.
:param resort.engine.execution.Context context:
Current execution context.
:param list cmd_args:
Command argument list. | [
"Execute",
"Vagrant",
"read",
"command",
"on",
"instance",
"placed",
"into",
"configuration",
"directory",
".",
":",
"param",
"resort",
".",
"engine",
".",
"execution",
".",
"Context",
"context",
":",
"Current",
"execution",
"context",
".",
":",
"param",
"list... | train | https://github.com/miquelo/resort/blob/097a25d3257c91a75c194fd44c2797ab356f85dd/packages/resort/component/vagrant.py#L180-L200 |
miquelo/resort | packages/resort/component/vagrant.py | Instance.state | def state(self, context):
"""
Get instance state.
:param resort.engine.execution.Context context:
Current execution context.
:rtype:
str
:return:
Instance state name.
"""
state = None
for line in self.read(context, [
"status",
context.resolve(self.__name)
]):
if line[2]... | python | def state(self, context):
"""
Get instance state.
:param resort.engine.execution.Context context:
Current execution context.
:rtype:
str
:return:
Instance state name.
"""
state = None
for line in self.read(context, [
"status",
context.resolve(self.__name)
]):
if line[2]... | [
"def",
"state",
"(",
"self",
",",
"context",
")",
":",
"state",
"=",
"None",
"for",
"line",
"in",
"self",
".",
"read",
"(",
"context",
",",
"[",
"\"status\"",
",",
"context",
".",
"resolve",
"(",
"self",
".",
"__name",
")",
"]",
")",
":",
"if",
"... | Get instance state.
:param resort.engine.execution.Context context:
Current execution context.
:rtype:
str
:return:
Instance state name. | [
"Get",
"instance",
"state",
".",
":",
"param",
"resort",
".",
"engine",
".",
"execution",
".",
"Context",
"context",
":",
"Current",
"execution",
"context",
".",
":",
"rtype",
":",
"str",
":",
"return",
":",
"Instance",
"state",
"name",
"."
] | train | https://github.com/miquelo/resort/blob/097a25d3257c91a75c194fd44c2797ab356f85dd/packages/resort/component/vagrant.py#L224-L244 |
miquelo/resort | packages/resort/component/vagrant.py | InstanceCreated.available | def available(self, context):
"""
Check availability.
:param resort.engine.execution.Context context:
Current execution context.
:rtype:
bool
:return:
Availability value.
"""
if self.__available is None:
state = self.__inst.state(context)
self.__available = state is not None and ... | python | def available(self, context):
"""
Check availability.
:param resort.engine.execution.Context context:
Current execution context.
:rtype:
bool
:return:
Availability value.
"""
if self.__available is None:
state = self.__inst.state(context)
self.__available = state is not None and ... | [
"def",
"available",
"(",
"self",
",",
"context",
")",
":",
"if",
"self",
".",
"__available",
"is",
"None",
":",
"state",
"=",
"self",
".",
"__inst",
".",
"state",
"(",
"context",
")",
"self",
".",
"__available",
"=",
"state",
"is",
"not",
"None",
"an... | Check availability.
:param resort.engine.execution.Context context:
Current execution context.
:rtype:
bool
:return:
Availability value. | [
"Check",
"availability",
".",
":",
"param",
"resort",
".",
"engine",
".",
"execution",
".",
"Context",
"context",
":",
"Current",
"execution",
"context",
".",
":",
"rtype",
":",
"bool",
":",
"return",
":",
"Availability",
"value",
"."
] | train | https://github.com/miquelo/resort/blob/097a25d3257c91a75c194fd44c2797ab356f85dd/packages/resort/component/vagrant.py#L282-L297 |
FujiMakoto/IPS-Vagrant | ips_vagrant/scrapers/licenses.py | Licenses.get | def get(self):
"""
Fetch all licenses associated with our account
@rtype: list of LicenseMeta
"""
response = requests.get(self.URL, cookies=self.cookiejar)
self.log.debug('Response code: %s', response.status_code)
if response.status_code != 200:
raise ... | python | def get(self):
"""
Fetch all licenses associated with our account
@rtype: list of LicenseMeta
"""
response = requests.get(self.URL, cookies=self.cookiejar)
self.log.debug('Response code: %s', response.status_code)
if response.status_code != 200:
raise ... | [
"def",
"get",
"(",
"self",
")",
":",
"response",
"=",
"requests",
".",
"get",
"(",
"self",
".",
"URL",
",",
"cookies",
"=",
"self",
".",
"cookiejar",
")",
"self",
".",
"log",
".",
"debug",
"(",
"'Response code: %s'",
",",
"response",
".",
"status_code"... | Fetch all licenses associated with our account
@rtype: list of LicenseMeta | [
"Fetch",
"all",
"licenses",
"associated",
"with",
"our",
"account"
] | train | https://github.com/FujiMakoto/IPS-Vagrant/blob/7b1d6d095034dd8befb026d9315ecc6494d52269/ips_vagrant/scrapers/licenses.py#L22-L50 |
PinLin/KCOJ_api | KCOJ_api/api.py | KCOJ.courses | def courses(self) -> list:
"""
取得課程列表
"""
try:
# 取得資料
response = self.__session.get(
self.__url + '/Login', timeout=0.5, verify=False)
soup = BeautifulSoup(response.text, 'html.parser')
# 取出課程名稱
result = []
... | python | def courses(self) -> list:
"""
取得課程列表
"""
try:
# 取得資料
response = self.__session.get(
self.__url + '/Login', timeout=0.5, verify=False)
soup = BeautifulSoup(response.text, 'html.parser')
# 取出課程名稱
result = []
... | [
"def",
"courses",
"(",
"self",
")",
"->",
"list",
":",
"try",
":",
"# 取得資料",
"response",
"=",
"self",
".",
"__session",
".",
"get",
"(",
"self",
".",
"__url",
"+",
"'/Login'",
",",
"timeout",
"=",
"0.5",
",",
"verify",
"=",
"False",
")",
"soup",
"=... | 取得課程列表 | [
"取得課程列表"
] | train | https://github.com/PinLin/KCOJ_api/blob/64f6ef0f9e64dc1efd692cbe6d5738ee7cfb78ec/KCOJ_api/api.py#L13-L30 |
PinLin/KCOJ_api | KCOJ_api/api.py | KCOJ.active | def active(self) -> bool:
"""
檢查登入狀態
"""
try:
# 取得資料
response = self.__session.get(
self.__url + '/TopMenu', timeout=0.5, verify=False)
soup = BeautifulSoup(response.text, 'html.parser')
# 回傳是否為登入成功才看得到的網頁
return... | python | def active(self) -> bool:
"""
檢查登入狀態
"""
try:
# 取得資料
response = self.__session.get(
self.__url + '/TopMenu', timeout=0.5, verify=False)
soup = BeautifulSoup(response.text, 'html.parser')
# 回傳是否為登入成功才看得到的網頁
return... | [
"def",
"active",
"(",
"self",
")",
"->",
"bool",
":",
"try",
":",
"# 取得資料",
"response",
"=",
"self",
".",
"__session",
".",
"get",
"(",
"self",
".",
"__url",
"+",
"'/TopMenu'",
",",
"timeout",
"=",
"0.5",
",",
"verify",
"=",
"False",
")",
"soup",
"... | 檢查登入狀態 | [
"檢查登入狀態"
] | train | https://github.com/PinLin/KCOJ_api/blob/64f6ef0f9e64dc1efd692cbe6d5738ee7cfb78ec/KCOJ_api/api.py#L33-L46 |
PinLin/KCOJ_api | KCOJ_api/api.py | KCOJ.login | def login(self, username: str, password: str, course: int) -> requests.Response:
"""
登入課程
"""
try:
# 操作所需資訊
payload = {
'name': username,
'passwd': password,
'rdoCourse': course
}
# 回傳嘗試登入的回應
... | python | def login(self, username: str, password: str, course: int) -> requests.Response:
"""
登入課程
"""
try:
# 操作所需資訊
payload = {
'name': username,
'passwd': password,
'rdoCourse': course
}
# 回傳嘗試登入的回應
... | [
"def",
"login",
"(",
"self",
",",
"username",
":",
"str",
",",
"password",
":",
"str",
",",
"course",
":",
"int",
")",
"->",
"requests",
".",
"Response",
":",
"try",
":",
"# 操作所需資訊",
"payload",
"=",
"{",
"'name'",
":",
"username",
",",
"'passwd'",
":... | 登入課程 | [
"登入課程"
] | train | https://github.com/PinLin/KCOJ_api/blob/64f6ef0f9e64dc1efd692cbe6d5738ee7cfb78ec/KCOJ_api/api.py#L48-L64 |
PinLin/KCOJ_api | KCOJ_api/api.py | KCOJ.get_question | def get_question(self, number: str=None) -> dict:
"""
取得課程中的所有題目資訊
"""
try:
# 取得資料
response = self.__session.get(
self.__url + '/HomeworkBoard', timeout=0.5, verify=False)
soup = BeautifulSoup(response.text, 'html.parser')
#... | python | def get_question(self, number: str=None) -> dict:
"""
取得課程中的所有題目資訊
"""
try:
# 取得資料
response = self.__session.get(
self.__url + '/HomeworkBoard', timeout=0.5, verify=False)
soup = BeautifulSoup(response.text, 'html.parser')
#... | [
"def",
"get_question",
"(",
"self",
",",
"number",
":",
"str",
"=",
"None",
")",
"->",
"dict",
":",
"try",
":",
"# 取得資料",
"response",
"=",
"self",
".",
"__session",
".",
"get",
"(",
"self",
".",
"__url",
"+",
"'/HomeworkBoard'",
",",
"timeout",
"=",
... | 取得課程中的所有題目資訊 | [
"取得課程中的所有題目資訊"
] | train | https://github.com/PinLin/KCOJ_api/blob/64f6ef0f9e64dc1efd692cbe6d5738ee7cfb78ec/KCOJ_api/api.py#L66-L107 |
PinLin/KCOJ_api | KCOJ_api/api.py | KCOJ.get_question_content | def get_question_content(self, number: str) -> str:
"""
取得課程中特定題目內容
"""
try:
# 操作所需資訊
params = {
'hwId': number
}
# 取得資料
response = self.__session.get(
self.__url + '/showHomework', params=params,... | python | def get_question_content(self, number: str) -> str:
"""
取得課程中特定題目內容
"""
try:
# 操作所需資訊
params = {
'hwId': number
}
# 取得資料
response = self.__session.get(
self.__url + '/showHomework', params=params,... | [
"def",
"get_question_content",
"(",
"self",
",",
"number",
":",
"str",
")",
"->",
"str",
":",
"try",
":",
"# 操作所需資訊",
"params",
"=",
"{",
"'hwId'",
":",
"number",
"}",
"# 取得資料",
"response",
"=",
"self",
".",
"__session",
".",
"get",
"(",
"self",
".",
... | 取得課程中特定題目內容 | [
"取得課程中特定題目內容"
] | train | https://github.com/PinLin/KCOJ_api/blob/64f6ef0f9e64dc1efd692cbe6d5738ee7cfb78ec/KCOJ_api/api.py#L109-L131 |
PinLin/KCOJ_api | KCOJ_api/api.py | KCOJ.get_question_passers | def get_question_passers(self, number: str) -> list:
"""
取得課程中特定題目通過者列表
"""
try:
# 操作所需資訊
params = {
'HW_ID': number
}
# 取得資料
response = self.__session.get(
self.__url + '/success.jsp', params=par... | python | def get_question_passers(self, number: str) -> list:
"""
取得課程中特定題目通過者列表
"""
try:
# 操作所需資訊
params = {
'HW_ID': number
}
# 取得資料
response = self.__session.get(
self.__url + '/success.jsp', params=par... | [
"def",
"get_question_passers",
"(",
"self",
",",
"number",
":",
"str",
")",
"->",
"list",
":",
"try",
":",
"# 操作所需資訊",
"params",
"=",
"{",
"'HW_ID'",
":",
"number",
"}",
"# 取得資料",
"response",
"=",
"self",
".",
"__session",
".",
"get",
"(",
"self",
".",... | 取得課程中特定題目通過者列表 | [
"取得課程中特定題目通過者列表"
] | train | https://github.com/PinLin/KCOJ_api/blob/64f6ef0f9e64dc1efd692cbe6d5738ee7cfb78ec/KCOJ_api/api.py#L133-L158 |
PinLin/KCOJ_api | KCOJ_api/api.py | KCOJ.get_question_results | def get_question_results(self, number: str, username: str) -> dict:
"""
取得課程中特定題目指定用戶之測試結果
"""
try:
# 操作所需資訊
params = {
'questionID': number,
'studentID': username
}
# 取得資料
response = self.__sessi... | python | def get_question_results(self, number: str, username: str) -> dict:
"""
取得課程中特定題目指定用戶之測試結果
"""
try:
# 操作所需資訊
params = {
'questionID': number,
'studentID': username
}
# 取得資料
response = self.__sessi... | [
"def",
"get_question_results",
"(",
"self",
",",
"number",
":",
"str",
",",
"username",
":",
"str",
")",
"->",
"dict",
":",
"try",
":",
"# 操作所需資訊",
"params",
"=",
"{",
"'questionID'",
":",
"number",
",",
"'studentID'",
":",
"username",
"}",
"# 取得資料",
"re... | 取得課程中特定題目指定用戶之測試結果 | [
"取得課程中特定題目指定用戶之測試結果"
] | train | https://github.com/PinLin/KCOJ_api/blob/64f6ef0f9e64dc1efd692cbe6d5738ee7cfb78ec/KCOJ_api/api.py#L160-L188 |
PinLin/KCOJ_api | KCOJ_api/api.py | KCOJ.update_password | def update_password(self, password: str) -> bool:
"""
修改登入密碼
"""
try:
# 操作所需資訊
payload = {
'pass': password,
'submit': 'sumit'
}
# 修改密碼
response = self.__session.post(
self.__url +... | python | def update_password(self, password: str) -> bool:
"""
修改登入密碼
"""
try:
# 操作所需資訊
payload = {
'pass': password,
'submit': 'sumit'
}
# 修改密碼
response = self.__session.post(
self.__url +... | [
"def",
"update_password",
"(",
"self",
",",
"password",
":",
"str",
")",
"->",
"bool",
":",
"try",
":",
"# 操作所需資訊",
"payload",
"=",
"{",
"'pass'",
":",
"password",
",",
"'submit'",
":",
"'sumit'",
"}",
"# 修改密碼",
"response",
"=",
"self",
".",
"__session",... | 修改登入密碼 | [
"修改登入密碼"
] | train | https://github.com/PinLin/KCOJ_api/blob/64f6ef0f9e64dc1efd692cbe6d5738ee7cfb78ec/KCOJ_api/api.py#L190-L208 |
PinLin/KCOJ_api | KCOJ_api/api.py | KCOJ.post_question_answer | def post_question_answer(self, number: str, description: str, file_path: str) -> bool:
"""
上傳特定題目的作業
"""
try:
# 操作所需資訊
params = {
'hwId': number
}
data = {
'FileDesc': description
}
fi... | python | def post_question_answer(self, number: str, description: str, file_path: str) -> bool:
"""
上傳特定題目的作業
"""
try:
# 操作所需資訊
params = {
'hwId': number
}
data = {
'FileDesc': description
}
fi... | [
"def",
"post_question_answer",
"(",
"self",
",",
"number",
":",
"str",
",",
"description",
":",
"str",
",",
"file_path",
":",
"str",
")",
"->",
"bool",
":",
"try",
":",
"# 操作所需資訊",
"params",
"=",
"{",
"'hwId'",
":",
"number",
"}",
"data",
"=",
"{",
"... | 上傳特定題目的作業 | [
"上傳特定題目的作業"
] | train | https://github.com/PinLin/KCOJ_api/blob/64f6ef0f9e64dc1efd692cbe6d5738ee7cfb78ec/KCOJ_api/api.py#L210-L235 |
PinLin/KCOJ_api | KCOJ_api/api.py | KCOJ.delete_question_answer | def delete_question_answer(self, number: str) -> bool:
"""
刪除特定題目的作業
"""
try:
# 操作所需資訊
params = {
'title': number
}
# 刪除作業
response = self.__session.get(
self.__url + '/delHw', params=params, time... | python | def delete_question_answer(self, number: str) -> bool:
"""
刪除特定題目的作業
"""
try:
# 操作所需資訊
params = {
'title': number
}
# 刪除作業
response = self.__session.get(
self.__url + '/delHw', params=params, time... | [
"def",
"delete_question_answer",
"(",
"self",
",",
"number",
":",
"str",
")",
"->",
"bool",
":",
"try",
":",
"# 操作所需資訊",
"params",
"=",
"{",
"'title'",
":",
"number",
"}",
"# 刪除作業",
"response",
"=",
"self",
".",
"__session",
".",
"get",
"(",
"self",
".... | 刪除特定題目的作業 | [
"刪除特定題目的作業"
] | train | https://github.com/PinLin/KCOJ_api/blob/64f6ef0f9e64dc1efd692cbe6d5738ee7cfb78ec/KCOJ_api/api.py#L237-L254 |
PinLin/KCOJ_api | KCOJ_api/api.py | KCOJ.get_notice | def get_notice(self) -> dict:
"""
取得公布欄訊息列表
"""
try:
# 取得資料
response = self.__session.get(
self.__url + '/MessageBoard', timeout=0.5, verify=False)
soup = BeautifulSoup(response.text, 'html.parser')
# 整理公布欄訊息列表
n... | python | def get_notice(self) -> dict:
"""
取得公布欄訊息列表
"""
try:
# 取得資料
response = self.__session.get(
self.__url + '/MessageBoard', timeout=0.5, verify=False)
soup = BeautifulSoup(response.text, 'html.parser')
# 整理公布欄訊息列表
n... | [
"def",
"get_notice",
"(",
"self",
")",
"->",
"dict",
":",
"try",
":",
"# 取得資料",
"response",
"=",
"self",
".",
"__session",
".",
"get",
"(",
"self",
".",
"__url",
"+",
"'/MessageBoard'",
",",
"timeout",
"=",
"0.5",
",",
"verify",
"=",
"False",
")",
"s... | 取得公布欄訊息列表 | [
"取得公布欄訊息列表"
] | train | https://github.com/PinLin/KCOJ_api/blob/64f6ef0f9e64dc1efd692cbe6d5738ee7cfb78ec/KCOJ_api/api.py#L256-L277 |
PinLin/KCOJ_api | KCOJ_api/api.py | KCOJ.get_notice_content | def get_notice_content(self, time: str) -> str:
"""
取得公布欄特定訊息內容
"""
try:
# 取得資料
response = self.__session.get(
self.__url + '/showArticle?time=' + time, timeout=0.5, verify=False)
soup = BeautifulSoup(response.text, 'html.parser')
... | python | def get_notice_content(self, time: str) -> str:
"""
取得公布欄特定訊息內容
"""
try:
# 取得資料
response = self.__session.get(
self.__url + '/showArticle?time=' + time, timeout=0.5, verify=False)
soup = BeautifulSoup(response.text, 'html.parser')
... | [
"def",
"get_notice_content",
"(",
"self",
",",
"time",
":",
"str",
")",
"->",
"str",
":",
"try",
":",
"# 取得資料",
"response",
"=",
"self",
".",
"__session",
".",
"get",
"(",
"self",
".",
"__url",
"+",
"'/showArticle?time='",
"+",
"time",
",",
"timeout",
... | 取得公布欄特定訊息內容 | [
"取得公布欄特定訊息內容"
] | train | https://github.com/PinLin/KCOJ_api/blob/64f6ef0f9e64dc1efd692cbe6d5738ee7cfb78ec/KCOJ_api/api.py#L279-L292 |
PinLin/KCOJ_api | KCOJ_api/api.py | KCOJ.get_notices | def get_notices(self):
"""
[deprecated] 建議使用方法 `get_notice()` 及 `get_notice_content()`
"""
result = []
# 取得公布欄訊息列表
for date, title in self.get_notice().items():
content = self.get_notice_content(date)
result.append([date, title, content])
#... | python | def get_notices(self):
"""
[deprecated] 建議使用方法 `get_notice()` 及 `get_notice_content()`
"""
result = []
# 取得公布欄訊息列表
for date, title in self.get_notice().items():
content = self.get_notice_content(date)
result.append([date, title, content])
#... | [
"def",
"get_notices",
"(",
"self",
")",
":",
"result",
"=",
"[",
"]",
"# 取得公布欄訊息列表",
"for",
"date",
",",
"title",
"in",
"self",
".",
"get_notice",
"(",
")",
".",
"items",
"(",
")",
":",
"content",
"=",
"self",
".",
"get_notice_content",
"(",
"date",
... | [deprecated] 建議使用方法 `get_notice()` 及 `get_notice_content()` | [
"[",
"deprecated",
"]",
"建議使用方法",
"get_notice",
"()",
"及",
"get_notice_content",
"()"
] | train | https://github.com/PinLin/KCOJ_api/blob/64f6ef0f9e64dc1efd692cbe6d5738ee7cfb78ec/KCOJ_api/api.py#L294-L304 |
PinLin/KCOJ_api | KCOJ_api/api.py | KCOJ.list_questions | def list_questions(self):
"""
[deprecated] 建議使用方法 `get_question()`
"""
# 取得新 API 的結果
data = self.get_question()
# 實作相容的結構
result = {}
for number in data:
# 繳交期限
deadline = data[number]['deadline']
# 是否已經過期限
e... | python | def list_questions(self):
"""
[deprecated] 建議使用方法 `get_question()`
"""
# 取得新 API 的結果
data = self.get_question()
# 實作相容的結構
result = {}
for number in data:
# 繳交期限
deadline = data[number]['deadline']
# 是否已經過期限
e... | [
"def",
"list_questions",
"(",
"self",
")",
":",
"# 取得新 API 的結果",
"data",
"=",
"self",
".",
"get_question",
"(",
")",
"# 實作相容的結構",
"result",
"=",
"{",
"}",
"for",
"number",
"in",
"data",
":",
"# 繳交期限",
"deadline",
"=",
"data",
"[",
"number",
"]",
"[",
"... | [deprecated] 建議使用方法 `get_question()` | [
"[",
"deprecated",
"]",
"建議使用方法",
"get_question",
"()"
] | train | https://github.com/PinLin/KCOJ_api/blob/64f6ef0f9e64dc1efd692cbe6d5738ee7cfb78ec/KCOJ_api/api.py#L320-L340 |
PinLin/KCOJ_api | KCOJ_api/api.py | KCOJ.list_results | def list_results(self, number, username):
"""
[deprecated] 建議使用方法 `get_question_results()`
"""
# 取得新 API 的結果
data = self.get_question_results(number, username)
# 實作相容的結構
result = []
for number in data:
# 儲存題目資訊
result += [(number, d... | python | def list_results(self, number, username):
"""
[deprecated] 建議使用方法 `get_question_results()`
"""
# 取得新 API 的結果
data = self.get_question_results(number, username)
# 實作相容的結構
result = []
for number in data:
# 儲存題目資訊
result += [(number, d... | [
"def",
"list_results",
"(",
"self",
",",
"number",
",",
"username",
")",
":",
"# 取得新 API 的結果",
"data",
"=",
"self",
".",
"get_question_results",
"(",
"number",
",",
"username",
")",
"# 實作相容的結構",
"result",
"=",
"[",
"]",
"for",
"number",
"in",
"data",
":",
... | [deprecated] 建議使用方法 `get_question_results()` | [
"[",
"deprecated",
"]",
"建議使用方法",
"get_question_results",
"()"
] | train | https://github.com/PinLin/KCOJ_api/blob/64f6ef0f9e64dc1efd692cbe6d5738ee7cfb78ec/KCOJ_api/api.py#L356-L368 |
uw-it-aca/uw-restclients-sdbmyuw | uw_sdbmyuw/__init__.py | get_app_status | def get_app_status(system_key):
"""
Get Undergraduate application status
@return ApplicationStatus object
@InvalidSystemKey if system_key is not valid
"""
if invalid_system_key(system_key):
raise InvalidSystemKey(
"Invalid system key in get_app_status({})".format(system_key))... | python | def get_app_status(system_key):
"""
Get Undergraduate application status
@return ApplicationStatus object
@InvalidSystemKey if system_key is not valid
"""
if invalid_system_key(system_key):
raise InvalidSystemKey(
"Invalid system key in get_app_status({})".format(system_key))... | [
"def",
"get_app_status",
"(",
"system_key",
")",
":",
"if",
"invalid_system_key",
"(",
"system_key",
")",
":",
"raise",
"InvalidSystemKey",
"(",
"\"Invalid system key in get_app_status({})\"",
".",
"format",
"(",
"system_key",
")",
")",
"url",
"=",
"get_appstatus_url"... | Get Undergraduate application status
@return ApplicationStatus object
@InvalidSystemKey if system_key is not valid | [
"Get",
"Undergraduate",
"application",
"status"
] | train | https://github.com/uw-it-aca/uw-restclients-sdbmyuw/blob/b54317f8bcff1fd226a91e085fd6fe59757db07c/uw_sdbmyuw/__init__.py#L17-L40 |
fedora-infra/fmn.lib | fmn/lib/hinting.py | hint | def hint(invertible=True, callable=None, **hints):
""" A decorator that can optionally hang datanommer hints on a rule. """
def wrapper(fn):
# Hang hints on fn.
fn.hints = hints
fn.hinting_invertible = invertible
fn.hinting_callable = callable
return fn
return wrapp... | python | def hint(invertible=True, callable=None, **hints):
""" A decorator that can optionally hang datanommer hints on a rule. """
def wrapper(fn):
# Hang hints on fn.
fn.hints = hints
fn.hinting_invertible = invertible
fn.hinting_callable = callable
return fn
return wrapp... | [
"def",
"hint",
"(",
"invertible",
"=",
"True",
",",
"callable",
"=",
"None",
",",
"*",
"*",
"hints",
")",
":",
"def",
"wrapper",
"(",
"fn",
")",
":",
"# Hang hints on fn.",
"fn",
".",
"hints",
"=",
"hints",
"fn",
".",
"hinting_invertible",
"=",
"invert... | A decorator that can optionally hang datanommer hints on a rule. | [
"A",
"decorator",
"that",
"can",
"optionally",
"hang",
"datanommer",
"hints",
"on",
"a",
"rule",
"."
] | train | https://github.com/fedora-infra/fmn.lib/blob/3120725556153d07c1809530f0fadcf250439110/fmn/lib/hinting.py#L25-L35 |
fedora-infra/fmn.lib | fmn/lib/hinting.py | gather_hinting | def gather_hinting(config, rules, valid_paths):
""" Construct hint arguments for datanommer from a list of rules. """
hinting = collections.defaultdict(list)
for rule in rules:
root, name = rule.code_path.split(':', 1)
info = valid_paths[root][name]
if info['hints-callable']:
... | python | def gather_hinting(config, rules, valid_paths):
""" Construct hint arguments for datanommer from a list of rules. """
hinting = collections.defaultdict(list)
for rule in rules:
root, name = rule.code_path.split(':', 1)
info = valid_paths[root][name]
if info['hints-callable']:
... | [
"def",
"gather_hinting",
"(",
"config",
",",
"rules",
",",
"valid_paths",
")",
":",
"hinting",
"=",
"collections",
".",
"defaultdict",
"(",
"list",
")",
"for",
"rule",
"in",
"rules",
":",
"root",
",",
"name",
"=",
"rule",
".",
"code_path",
".",
"split",
... | Construct hint arguments for datanommer from a list of rules. | [
"Construct",
"hint",
"arguments",
"for",
"datanommer",
"from",
"a",
"list",
"of",
"rules",
"."
] | train | https://github.com/fedora-infra/fmn.lib/blob/3120725556153d07c1809530f0fadcf250439110/fmn/lib/hinting.py#L43-L81 |
rich-pixley/rain | rain/main.py | _parse_args | def _parse_args():
"""
Parses the command line arguments.
:return: Namespace with arguments.
:rtype: Namespace
"""
parser = argparse.ArgumentParser(description='rain - a new sort of automated builder.')
parser.add_argument('action', help='what shall we do?', default='build', nargs='?',... | python | def _parse_args():
"""
Parses the command line arguments.
:return: Namespace with arguments.
:rtype: Namespace
"""
parser = argparse.ArgumentParser(description='rain - a new sort of automated builder.')
parser.add_argument('action', help='what shall we do?', default='build', nargs='?',... | [
"def",
"_parse_args",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"'rain - a new sort of automated builder.'",
")",
"parser",
".",
"add_argument",
"(",
"'action'",
",",
"help",
"=",
"'what shall we do?'",
",",
"default",... | Parses the command line arguments.
:return: Namespace with arguments.
:rtype: Namespace | [
"Parses",
"the",
"command",
"line",
"arguments",
"."
] | train | https://github.com/rich-pixley/rain/blob/ed95aafc73002fbf0466be9a5eaa1e6ed3990a6d/rain/main.py#L200-L225 |
roedesh/django-xfeed | xfeed/templatetags/xfeed_tags.py | generate_feed_list | def generate_feed_list(feed, amount=None, list_class=None, li_class=None, list_type='ul'):
"""Generates a HTML list with items from a feed
:param feed: The feed to generate the list from.
:type feed: Feed
:param amount: The amount of items to show.
:type amount: int
:param ul_class: The <ul> or... | python | def generate_feed_list(feed, amount=None, list_class=None, li_class=None, list_type='ul'):
"""Generates a HTML list with items from a feed
:param feed: The feed to generate the list from.
:type feed: Feed
:param amount: The amount of items to show.
:type amount: int
:param ul_class: The <ul> or... | [
"def",
"generate_feed_list",
"(",
"feed",
",",
"amount",
"=",
"None",
",",
"list_class",
"=",
"None",
",",
"li_class",
"=",
"None",
",",
"list_type",
"=",
"'ul'",
")",
":",
"if",
"feed",
".",
"feed_type",
"==",
"'twitter'",
":",
"ret",
"=",
"[",
"'<%s ... | Generates a HTML list with items from a feed
:param feed: The feed to generate the list from.
:type feed: Feed
:param amount: The amount of items to show.
:type amount: int
:param ul_class: The <ul> or <ol> class to use.
:type ul_class: str
:param li_class: The <li> class to use.
:type ... | [
"Generates",
"a",
"HTML",
"list",
"with",
"items",
"from",
"a",
"feed"
] | train | https://github.com/roedesh/django-xfeed/blob/e4f1e4a6e476c06ea461e4c4c12e98230a61bdfc/xfeed/templatetags/xfeed_tags.py#L6-L47 |
ouroboroscoding/reconsider | Reconsider/__init__.py | clone | def clone(source, destination, dbs = None, verbose = False):
"""Clone
Clone is used to clone one or many DBs/Tables from one host to another
Args:
source (dict): Data specifying the source instance
A dictionary with the following possible elements: host, port, user,
password, timeout, ssl (see rethinkdb py... | python | def clone(source, destination, dbs = None, verbose = False):
"""Clone
Clone is used to clone one or many DBs/Tables from one host to another
Args:
source (dict): Data specifying the source instance
A dictionary with the following possible elements: host, port, user,
password, timeout, ssl (see rethinkdb py... | [
"def",
"clone",
"(",
"source",
",",
"destination",
",",
"dbs",
"=",
"None",
",",
"verbose",
"=",
"False",
")",
":",
"# If the source is not a valid dict",
"if",
"not",
"isinstance",
"(",
"source",
",",
"dict",
")",
":",
"raise",
"ValueError",
"(",
"'source m... | Clone
Clone is used to clone one or many DBs/Tables from one host to another
Args:
source (dict): Data specifying the source instance
A dictionary with the following possible elements: host, port, user,
password, timeout, ssl (see rethinkdb python api)
destination (dict): Date specifying the destination ... | [
"Clone"
] | train | https://github.com/ouroboroscoding/reconsider/blob/155061d72e757665f9d3fee5a8a9d6f31f6872ed/Reconsider/__init__.py#L29-L220 |
dstufft/storages | storages/core.py | chunks | def chunks(f, chunk_size=None):
"""
Read the file and yield chucks of ``chunk_size`` bytes.
"""
if not chunk_size:
chunk_size = 64 * 2 ** 10
if hasattr(f, "seek"):
f.seek(0)
while True:
data = f.read(chunk_size)
if not data:
break
yield data | python | def chunks(f, chunk_size=None):
"""
Read the file and yield chucks of ``chunk_size`` bytes.
"""
if not chunk_size:
chunk_size = 64 * 2 ** 10
if hasattr(f, "seek"):
f.seek(0)
while True:
data = f.read(chunk_size)
if not data:
break
yield data | [
"def",
"chunks",
"(",
"f",
",",
"chunk_size",
"=",
"None",
")",
":",
"if",
"not",
"chunk_size",
":",
"chunk_size",
"=",
"64",
"*",
"2",
"**",
"10",
"if",
"hasattr",
"(",
"f",
",",
"\"seek\"",
")",
":",
"f",
".",
"seek",
"(",
"0",
")",
"while",
... | Read the file and yield chucks of ``chunk_size`` bytes. | [
"Read",
"the",
"file",
"and",
"yield",
"chucks",
"of",
"chunk_size",
"bytes",
"."
] | train | https://github.com/dstufft/storages/blob/0d893afc1db32cd83eaf8e2ad4ed51b37933d5f0/storages/core.py#L20-L34 |
dstufft/storages | storages/core.py | Storage.save | def save(self, name, content):
"""
Saves new content to the file specified by name. The content should be a
proper File object, ready to be read from the beginning.
"""
# Get the proper name for the file, as it will actually be saved.
if name is None:
name = c... | python | def save(self, name, content):
"""
Saves new content to the file specified by name. The content should be a
proper File object, ready to be read from the beginning.
"""
# Get the proper name for the file, as it will actually be saved.
if name is None:
name = c... | [
"def",
"save",
"(",
"self",
",",
"name",
",",
"content",
")",
":",
"# Get the proper name for the file, as it will actually be saved.",
"if",
"name",
"is",
"None",
":",
"name",
"=",
"content",
".",
"name",
"name",
"=",
"self",
".",
"get_available_name",
"(",
"na... | Saves new content to the file specified by name. The content should be a
proper File object, ready to be read from the beginning. | [
"Saves",
"new",
"content",
"to",
"the",
"file",
"specified",
"by",
"name",
".",
"The",
"content",
"should",
"be",
"a",
"proper",
"File",
"object",
"ready",
"to",
"be",
"read",
"from",
"the",
"beginning",
"."
] | train | https://github.com/dstufft/storages/blob/0d893afc1db32cd83eaf8e2ad4ed51b37933d5f0/storages/core.py#L55-L68 |
dstufft/storages | storages/core.py | Storage.get_available_name | def get_available_name(self, name):
"""
Returns a filename that's free on the target storage system, and
available for new content to be written to.
"""
dir_name, file_name = os.path.split(name)
file_root, file_ext = os.path.splitext(file_name)
# If the filename a... | python | def get_available_name(self, name):
"""
Returns a filename that's free on the target storage system, and
available for new content to be written to.
"""
dir_name, file_name = os.path.split(name)
file_root, file_ext = os.path.splitext(file_name)
# If the filename a... | [
"def",
"get_available_name",
"(",
"self",
",",
"name",
")",
":",
"dir_name",
",",
"file_name",
"=",
"os",
".",
"path",
".",
"split",
"(",
"name",
")",
"file_root",
",",
"file_ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"file_name",
")",
"# If t... | Returns a filename that's free on the target storage system, and
available for new content to be written to. | [
"Returns",
"a",
"filename",
"that",
"s",
"free",
"on",
"the",
"target",
"storage",
"system",
"and",
"available",
"for",
"new",
"content",
"to",
"be",
"written",
"to",
"."
] | train | https://github.com/dstufft/storages/blob/0d893afc1db32cd83eaf8e2ad4ed51b37933d5f0/storages/core.py#L79-L94 |
anti1869/sunhead | src/sunhead/cli/banners.py | print_banner | def print_banner(filename: str, template: str = DEFAULT_BANNER_TEMPLATE) -> None:
"""
Print text file to output.
:param filename: Which file to print.
:param template: Format string which specified banner arrangement.
:return: Does not return anything
"""
if not os.path.isfile(filename):
... | python | def print_banner(filename: str, template: str = DEFAULT_BANNER_TEMPLATE) -> None:
"""
Print text file to output.
:param filename: Which file to print.
:param template: Format string which specified banner arrangement.
:return: Does not return anything
"""
if not os.path.isfile(filename):
... | [
"def",
"print_banner",
"(",
"filename",
":",
"str",
",",
"template",
":",
"str",
"=",
"DEFAULT_BANNER_TEMPLATE",
")",
"->",
"None",
":",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"filename",
")",
":",
"logger",
".",
"warning",
"(",
"\"Can't fin... | Print text file to output.
:param filename: Which file to print.
:param template: Format string which specified banner arrangement.
:return: Does not return anything | [
"Print",
"text",
"file",
"to",
"output",
"."
] | train | https://github.com/anti1869/sunhead/blob/5117ec797a38eb82d955241d20547d125efe80f3/src/sunhead/cli/banners.py#L15-L31 |
capslockwizard/drsip-common | drsip_common/__init__.py | get_best_fit_rot_mat | def get_best_fit_rot_mat(from_coord, to_coord):
"""
Compute best-fit rotation matrix.
The best-fit rotation matrix rotates from_coord such that the RMSD
between the 2 sets of coordinates are minimized after the rotation.
Parameters
----------
from_coord, to_coord : np.array
... | python | def get_best_fit_rot_mat(from_coord, to_coord):
"""
Compute best-fit rotation matrix.
The best-fit rotation matrix rotates from_coord such that the RMSD
between the 2 sets of coordinates are minimized after the rotation.
Parameters
----------
from_coord, to_coord : np.array
... | [
"def",
"get_best_fit_rot_mat",
"(",
"from_coord",
",",
"to_coord",
")",
":",
"superimpose_inst",
".",
"set",
"(",
"to_coord",
".",
"astype",
"(",
"'float64'",
")",
",",
"from_coord",
".",
"astype",
"(",
"'float64'",
")",
")",
"superimpose_inst",
".",
"run",
... | Compute best-fit rotation matrix.
The best-fit rotation matrix rotates from_coord such that the RMSD
between the 2 sets of coordinates are minimized after the rotation.
Parameters
----------
from_coord, to_coord : np.array
Nx3 coordinate arrays, where N is the number of atoms. The
... | [
"Compute",
"best",
"-",
"fit",
"rotation",
"matrix",
".",
"The",
"best",
"-",
"fit",
"rotation",
"matrix",
"rotates",
"from_coord",
"such",
"that",
"the",
"RMSD",
"between",
"the",
"2",
"sets",
"of",
"coordinates",
"are",
"minimized",
"after",
"the",
"rotati... | train | https://github.com/capslockwizard/drsip-common/blob/ca70ebc5128fd3be75786223860b1935324083a1/drsip_common/__init__.py#L22-L45 |
dossier/dossier.fc | python/dossier/fc/dump.py | repr_feature | def repr_feature(feature, max_keys=100, indent=8, lexigraphic=False):
'''
generate a pretty-printed string for a feature
Currently implemented:
* StringCounter
@max_keys: truncate long counters
@indent: indent multi-line displays by this many spaces
@lexigraphic: instead of sorting cou... | python | def repr_feature(feature, max_keys=100, indent=8, lexigraphic=False):
'''
generate a pretty-printed string for a feature
Currently implemented:
* StringCounter
@max_keys: truncate long counters
@indent: indent multi-line displays by this many spaces
@lexigraphic: instead of sorting cou... | [
"def",
"repr_feature",
"(",
"feature",
",",
"max_keys",
"=",
"100",
",",
"indent",
"=",
"8",
",",
"lexigraphic",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"feature",
",",
"(",
"str",
",",
"bytes",
")",
")",
":",
"try",
":",
"ustr",
"=",
"fea... | generate a pretty-printed string for a feature
Currently implemented:
* StringCounter
@max_keys: truncate long counters
@indent: indent multi-line displays by this many spaces
@lexigraphic: instead of sorting counters by count (default), sort
keys lexigraphically | [
"generate",
"a",
"pretty",
"-",
"printed",
"string",
"for",
"a",
"feature"
] | train | https://github.com/dossier/dossier.fc/blob/3e969d0cb2592fc06afc1c849d2b22283450b5e2/python/dossier/fc/dump.py#L18-L47 |
dossier/dossier.fc | python/dossier/fc/dump.py | detailed_view | def detailed_view(fc, features_to_show=None, max_keys=100, lexigraphic=False,
display_only=True):
'''
returns a pretty-printed string describing a
:class:`dossier.fc.FeatureCollection`.
@features_to_show: list of features to include, defaults to None
meaning include all.
@lex... | python | def detailed_view(fc, features_to_show=None, max_keys=100, lexigraphic=False,
display_only=True):
'''
returns a pretty-printed string describing a
:class:`dossier.fc.FeatureCollection`.
@features_to_show: list of features to include, defaults to None
meaning include all.
@lex... | [
"def",
"detailed_view",
"(",
"fc",
",",
"features_to_show",
"=",
"None",
",",
"max_keys",
"=",
"100",
",",
"lexigraphic",
"=",
"False",
",",
"display_only",
"=",
"True",
")",
":",
"if",
"'#NAME'",
"in",
"fc",
":",
"top_lines",
"=",
"[",
"'NAME: %s'",
"%"... | returns a pretty-printed string describing a
:class:`dossier.fc.FeatureCollection`.
@features_to_show: list of features to include, defaults to None
meaning include all.
@lexigraphic: passed to repr_feature
@display_only: if DISPLAY_PREFIX versions of features are present, only show those. (defau... | [
"returns",
"a",
"pretty",
"-",
"printed",
"string",
"describing",
"a",
":",
"class",
":",
"dossier",
".",
"fc",
".",
"FeatureCollection",
"."
] | train | https://github.com/dossier/dossier.fc/blob/3e969d0cb2592fc06afc1c849d2b22283450b5e2/python/dossier/fc/dump.py#L75-L119 |
dossier/dossier.fc | python/dossier/fc/dump.py | only_specific_multisets | def only_specific_multisets(ent, multisets_to_show):
'''
returns a pretty-printed string for specific features in a FeatureCollection
'''
out_str = []
for mset_name in multisets_to_show:
for key, count in ent[mset_name].items():
out_str.append( '%s - %d: %s' % (mset_name, count, ... | python | def only_specific_multisets(ent, multisets_to_show):
'''
returns a pretty-printed string for specific features in a FeatureCollection
'''
out_str = []
for mset_name in multisets_to_show:
for key, count in ent[mset_name].items():
out_str.append( '%s - %d: %s' % (mset_name, count, ... | [
"def",
"only_specific_multisets",
"(",
"ent",
",",
"multisets_to_show",
")",
":",
"out_str",
"=",
"[",
"]",
"for",
"mset_name",
"in",
"multisets_to_show",
":",
"for",
"key",
",",
"count",
"in",
"ent",
"[",
"mset_name",
"]",
".",
"items",
"(",
")",
":",
"... | returns a pretty-printed string for specific features in a FeatureCollection | [
"returns",
"a",
"pretty",
"-",
"printed",
"string",
"for",
"specific",
"features",
"in",
"a",
"FeatureCollection"
] | train | https://github.com/dossier/dossier.fc/blob/3e969d0cb2592fc06afc1c849d2b22283450b5e2/python/dossier/fc/dump.py#L132-L140 |
lambdalisue/tolerance | src/tolerance/decorators.py | tolerate | def tolerate(substitute=None, exceptions=None,
switch=DEFAULT_TOLERATE_SWITCH):
"""
A function decorator which makes a function fail silently
To disable fail silently in a decorated function, specify
``fail_silently=False``.
To disable fail silenlty in decorated functions globally, spe... | python | def tolerate(substitute=None, exceptions=None,
switch=DEFAULT_TOLERATE_SWITCH):
"""
A function decorator which makes a function fail silently
To disable fail silently in a decorated function, specify
``fail_silently=False``.
To disable fail silenlty in decorated functions globally, spe... | [
"def",
"tolerate",
"(",
"substitute",
"=",
"None",
",",
"exceptions",
"=",
"None",
",",
"switch",
"=",
"DEFAULT_TOLERATE_SWITCH",
")",
":",
"def",
"decorator",
"(",
"fn",
")",
":",
"@",
"wraps",
"(",
"fn",
")",
"def",
"inner",
"(",
"*",
"args",
",",
... | A function decorator which makes a function fail silently
To disable fail silently in a decorated function, specify
``fail_silently=False``.
To disable fail silenlty in decorated functions globally, specify
``tolerate.disabled``.
Parameters
----------
fn : function
A function which... | [
"A",
"function",
"decorator",
"which",
"makes",
"a",
"function",
"fail",
"silently"
] | train | https://github.com/lambdalisue/tolerance/blob/e332622d78b1f8066098cc768af4ed12ccb4153d/src/tolerance/decorators.py#L15-L201 |
soasme/rio-client | rio_client/transports/requests.py | RequestsTransport.emit | def emit(self, action, payload):
"""Emit action with payload via `requests.post`."""
url = self.get_emit_api(action)
headers = {
'User-Agent': 'rio/%s' % VERSION,
'X-Rio-Protocol': '1',
}
args = dict(
url=url,
json=payload,
... | python | def emit(self, action, payload):
"""Emit action with payload via `requests.post`."""
url = self.get_emit_api(action)
headers = {
'User-Agent': 'rio/%s' % VERSION,
'X-Rio-Protocol': '1',
}
args = dict(
url=url,
json=payload,
... | [
"def",
"emit",
"(",
"self",
",",
"action",
",",
"payload",
")",
":",
"url",
"=",
"self",
".",
"get_emit_api",
"(",
"action",
")",
"headers",
"=",
"{",
"'User-Agent'",
":",
"'rio/%s'",
"%",
"VERSION",
",",
"'X-Rio-Protocol'",
":",
"'1'",
",",
"}",
"args... | Emit action with payload via `requests.post`. | [
"Emit",
"action",
"with",
"payload",
"via",
"requests",
".",
"post",
"."
] | train | https://github.com/soasme/rio-client/blob/c6d684c6f9deea5b43f2b05bcaf40714c48b5619/rio_client/transports/requests.py#L25-L50 |
tsileo/globster | lazy_regex.py | LazyRegex._compile_and_collapse | def _compile_and_collapse(self):
"""Actually compile the requested regex"""
self._real_regex = self._real_re_compile(*self._regex_args,
**self._regex_kwargs)
for attr in self._regex_attributes_to_copy:
setattr(self, attr, getattr(self.... | python | def _compile_and_collapse(self):
"""Actually compile the requested regex"""
self._real_regex = self._real_re_compile(*self._regex_args,
**self._regex_kwargs)
for attr in self._regex_attributes_to_copy:
setattr(self, attr, getattr(self.... | [
"def",
"_compile_and_collapse",
"(",
"self",
")",
":",
"self",
".",
"_real_regex",
"=",
"self",
".",
"_real_re_compile",
"(",
"*",
"self",
".",
"_regex_args",
",",
"*",
"*",
"self",
".",
"_regex_kwargs",
")",
"for",
"attr",
"in",
"self",
".",
"_regex_attri... | Actually compile the requested regex | [
"Actually",
"compile",
"the",
"requested",
"regex"
] | train | https://github.com/tsileo/globster/blob/9628bce60207b150d39b409cddc3fadb34e70841/lazy_regex.py#L60-L65 |
tsileo/globster | lazy_regex.py | LazyRegex._real_re_compile | def _real_re_compile(self, *args, **kwargs):
"""Thunk over to the original re.compile"""
try:
return _real_re_compile(*args, **kwargs)
except re.error as e:
# raise InvalidPattern instead of re.error as this gives a
# cleaner message to the user.
r... | python | def _real_re_compile(self, *args, **kwargs):
"""Thunk over to the original re.compile"""
try:
return _real_re_compile(*args, **kwargs)
except re.error as e:
# raise InvalidPattern instead of re.error as this gives a
# cleaner message to the user.
r... | [
"def",
"_real_re_compile",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"return",
"_real_re_compile",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"except",
"re",
".",
"error",
"as",
"e",
":",
"# raise InvalidPattern... | Thunk over to the original re.compile | [
"Thunk",
"over",
"to",
"the",
"original",
"re",
".",
"compile"
] | train | https://github.com/tsileo/globster/blob/9628bce60207b150d39b409cddc3fadb34e70841/lazy_regex.py#L67-L74 |
ScienceLogic/amiuploader | amiimporter/AWSUtilities.py | parse_image_json | def parse_image_json(text):
"""
parses response output of AWS describe commands and returns the first (and only) item in array
:param text: describe output
:return: image json
"""
image_details = json.loads(text)
if image_details.get('Images') is not None:
try:
image_deta... | python | def parse_image_json(text):
"""
parses response output of AWS describe commands and returns the first (and only) item in array
:param text: describe output
:return: image json
"""
image_details = json.loads(text)
if image_details.get('Images') is not None:
try:
image_deta... | [
"def",
"parse_image_json",
"(",
"text",
")",
":",
"image_details",
"=",
"json",
".",
"loads",
"(",
"text",
")",
"if",
"image_details",
".",
"get",
"(",
"'Images'",
")",
"is",
"not",
"None",
":",
"try",
":",
"image_details",
"=",
"image_details",
".",
"ge... | parses response output of AWS describe commands and returns the first (and only) item in array
:param text: describe output
:return: image json | [
"parses",
"response",
"output",
"of",
"AWS",
"describe",
"commands",
"and",
"returns",
"the",
"first",
"(",
"and",
"only",
")",
"item",
"in",
"array",
":",
"param",
"text",
":",
"describe",
"output",
":",
"return",
":",
"image",
"json"
] | train | https://github.com/ScienceLogic/amiuploader/blob/c36c247b2226107b38571cbc6119118b1fe07182/amiimporter/AWSUtilities.py#L12-L24 |
ScienceLogic/amiuploader | amiimporter/AWSUtilities.py | AWSUtils.validate_regions | def validate_regions(self):
"""
Validate the user specified regions are valid
:return:
"""
for region in self.aws_regions:
if region not in aws_regions:
print "Error: Specified region: {} is not a valid aws_region".format(region)
print ... | python | def validate_regions(self):
"""
Validate the user specified regions are valid
:return:
"""
for region in self.aws_regions:
if region not in aws_regions:
print "Error: Specified region: {} is not a valid aws_region".format(region)
print ... | [
"def",
"validate_regions",
"(",
"self",
")",
":",
"for",
"region",
"in",
"self",
".",
"aws_regions",
":",
"if",
"region",
"not",
"in",
"aws_regions",
":",
"print",
"\"Error: Specified region: {} is not a valid aws_region\"",
".",
"format",
"(",
"region",
")",
"pri... | Validate the user specified regions are valid
:return: | [
"Validate",
"the",
"user",
"specified",
"regions",
"are",
"valid",
":",
"return",
":"
] | train | https://github.com/ScienceLogic/amiuploader/blob/c36c247b2226107b38571cbc6119118b1fe07182/amiimporter/AWSUtilities.py#L54-L62 |
ScienceLogic/amiuploader | amiimporter/AWSUtilities.py | AWSUtils.validate_ec2_action | def validate_ec2_action(self):
"""
Attempt to validate that the provided user has permissions to import an AMI
:return:
"""
import_cmd = 'aws ec2 import-image --dry-run --profile {} --region {}'\
.format(self.aws_project, self.aws_regions[0])
print "Attempting... | python | def validate_ec2_action(self):
"""
Attempt to validate that the provided user has permissions to import an AMI
:return:
"""
import_cmd = 'aws ec2 import-image --dry-run --profile {} --region {}'\
.format(self.aws_project, self.aws_regions[0])
print "Attempting... | [
"def",
"validate_ec2_action",
"(",
"self",
")",
":",
"import_cmd",
"=",
"'aws ec2 import-image --dry-run --profile {} --region {}'",
".",
"format",
"(",
"self",
".",
"aws_project",
",",
"self",
".",
"aws_regions",
"[",
"0",
"]",
")",
"print",
"\"Attempting ec2 import ... | Attempt to validate that the provided user has permissions to import an AMI
:return: | [
"Attempt",
"to",
"validate",
"that",
"the",
"provided",
"user",
"has",
"permissions",
"to",
"import",
"an",
"AMI",
":",
"return",
":"
] | train | https://github.com/ScienceLogic/amiuploader/blob/c36c247b2226107b38571cbc6119118b1fe07182/amiimporter/AWSUtilities.py#L64-L81 |
ScienceLogic/amiuploader | amiimporter/AWSUtilities.py | AWSUtils.validate_bucket | def validate_bucket(self):
"""
Do a quick check to see if the s3 bucket is valid
:return:
"""
s3_check_cmd = "aws s3 ls s3://{} --profile '{}' --region '{}'".format(self.bucket_name, self.aws_project,
... | python | def validate_bucket(self):
"""
Do a quick check to see if the s3 bucket is valid
:return:
"""
s3_check_cmd = "aws s3 ls s3://{} --profile '{}' --region '{}'".format(self.bucket_name, self.aws_project,
... | [
"def",
"validate_bucket",
"(",
"self",
")",
":",
"s3_check_cmd",
"=",
"\"aws s3 ls s3://{} --profile '{}' --region '{}'\"",
".",
"format",
"(",
"self",
".",
"bucket_name",
",",
"self",
".",
"aws_project",
",",
"self",
".",
"aws_regions",
"[",
"0",
"]",
")",
"pri... | Do a quick check to see if the s3 bucket is valid
:return: | [
"Do",
"a",
"quick",
"check",
"to",
"see",
"if",
"the",
"s3",
"bucket",
"is",
"valid",
":",
"return",
":"
] | train | https://github.com/ScienceLogic/amiuploader/blob/c36c247b2226107b38571cbc6119118b1fe07182/amiimporter/AWSUtilities.py#L83-L97 |
ScienceLogic/amiuploader | amiimporter/AWSUtilities.py | AWSUtils.get_image_id_by_name | def get_image_id_by_name(self, ami_name, region='us-east-1'):
"""
Locate an AMI image id by name in a particular region
:param ami_name: ami name you need the id for
:param region: the region the image exists in
:return: id of the image
"""
image_details = None
... | python | def get_image_id_by_name(self, ami_name, region='us-east-1'):
"""
Locate an AMI image id by name in a particular region
:param ami_name: ami name you need the id for
:param region: the region the image exists in
:return: id of the image
"""
image_details = None
... | [
"def",
"get_image_id_by_name",
"(",
"self",
",",
"ami_name",
",",
"region",
"=",
"'us-east-1'",
")",
":",
"image_details",
"=",
"None",
"detail_query_attempts",
"=",
"0",
"while",
"image_details",
"is",
"None",
":",
"describe_cmd",
"=",
"\"aws ec2 describe-images --... | Locate an AMI image id by name in a particular region
:param ami_name: ami name you need the id for
:param region: the region the image exists in
:return: id of the image | [
"Locate",
"an",
"AMI",
"image",
"id",
"by",
"name",
"in",
"a",
"particular",
"region",
":",
"param",
"ami_name",
":",
"ami",
"name",
"you",
"need",
"the",
"id",
"for",
":",
"param",
"region",
":",
"the",
"region",
"the",
"image",
"exists",
"in",
":",
... | train | https://github.com/ScienceLogic/amiuploader/blob/c36c247b2226107b38571cbc6119118b1fe07182/amiimporter/AWSUtilities.py#L99-L127 |
ScienceLogic/amiuploader | amiimporter/AWSUtilities.py | AWSUtils.copy_ami_to_new_name | def copy_ami_to_new_name(self, ami_id, new_name, source_region='us-east-1'):
"""
Copies an AMI from the default region and name to the desired name and region
:param ami_id: ami id to copy
:param new_name: name of the new ami to create
:param source_region: the source region of t... | python | def copy_ami_to_new_name(self, ami_id, new_name, source_region='us-east-1'):
"""
Copies an AMI from the default region and name to the desired name and region
:param ami_id: ami id to copy
:param new_name: name of the new ami to create
:param source_region: the source region of t... | [
"def",
"copy_ami_to_new_name",
"(",
"self",
",",
"ami_id",
",",
"new_name",
",",
"source_region",
"=",
"'us-east-1'",
")",
":",
"new_image_ids",
"=",
"[",
"]",
"for",
"region",
"in",
"self",
".",
"aws_regions",
":",
"copy_img_cmd",
"=",
"\"aws ec2 copy-image --s... | Copies an AMI from the default region and name to the desired name and region
:param ami_id: ami id to copy
:param new_name: name of the new ami to create
:param source_region: the source region of the ami to copy | [
"Copies",
"an",
"AMI",
"from",
"the",
"default",
"region",
"and",
"name",
"to",
"the",
"desired",
"name",
"and",
"region",
":",
"param",
"ami_id",
":",
"ami",
"id",
"to",
"copy",
":",
"param",
"new_name",
":",
"name",
"of",
"the",
"new",
"ami",
"to",
... | train | https://github.com/ScienceLogic/amiuploader/blob/c36c247b2226107b38571cbc6119118b1fe07182/amiimporter/AWSUtilities.py#L129-L155 |
ScienceLogic/amiuploader | amiimporter/AWSUtilities.py | AWSUtils.deregister_image | def deregister_image(self, ami_id, region='us-east-1'):
"""
Deregister an AMI by id
:param ami_id:
:param region: region to deregister from
:return:
"""
deregister_cmd = "aws ec2 --profile {} --region {} deregister-image --image-id {}"\
.format(self.aw... | python | def deregister_image(self, ami_id, region='us-east-1'):
"""
Deregister an AMI by id
:param ami_id:
:param region: region to deregister from
:return:
"""
deregister_cmd = "aws ec2 --profile {} --region {} deregister-image --image-id {}"\
.format(self.aw... | [
"def",
"deregister_image",
"(",
"self",
",",
"ami_id",
",",
"region",
"=",
"'us-east-1'",
")",
":",
"deregister_cmd",
"=",
"\"aws ec2 --profile {} --region {} deregister-image --image-id {}\"",
".",
"format",
"(",
"self",
".",
"aws_project",
",",
"region",
",",
"ami_i... | Deregister an AMI by id
:param ami_id:
:param region: region to deregister from
:return: | [
"Deregister",
"an",
"AMI",
"by",
"id",
":",
"param",
"ami_id",
":",
":",
"param",
"region",
":",
"region",
"to",
"deregister",
"from",
":",
"return",
":"
] | train | https://github.com/ScienceLogic/amiuploader/blob/c36c247b2226107b38571cbc6119118b1fe07182/amiimporter/AWSUtilities.py#L157-L170 |
ScienceLogic/amiuploader | amiimporter/AWSUtilities.py | AWSUtils.wait_for_copy_available | def wait_for_copy_available(self, image_id, region):
"""
Wait for the newly copied ami to become available
:param image_id: image id to monitor
:param region: region to monitor copy
"""
waiting = True
describe_image_cmd = "aws ec2 --profile {} --region {} --outpu... | python | def wait_for_copy_available(self, image_id, region):
"""
Wait for the newly copied ami to become available
:param image_id: image id to monitor
:param region: region to monitor copy
"""
waiting = True
describe_image_cmd = "aws ec2 --profile {} --region {} --outpu... | [
"def",
"wait_for_copy_available",
"(",
"self",
",",
"image_id",
",",
"region",
")",
":",
"waiting",
"=",
"True",
"describe_image_cmd",
"=",
"\"aws ec2 --profile {} --region {} --output json describe-images --image-id {}\"",
".",
"format",
"(",
"self",
".",
"aws_project",
... | Wait for the newly copied ami to become available
:param image_id: image id to monitor
:param region: region to monitor copy | [
"Wait",
"for",
"the",
"newly",
"copied",
"ami",
"to",
"become",
"available",
":",
"param",
"image_id",
":",
"image",
"id",
"to",
"monitor",
":",
"param",
"region",
":",
"region",
"to",
"monitor",
"copy"
] | train | https://github.com/ScienceLogic/amiuploader/blob/c36c247b2226107b38571cbc6119118b1fe07182/amiimporter/AWSUtilities.py#L172-L196 |
ScienceLogic/amiuploader | amiimporter/AWSUtilities.py | AWSUtils.rename_image | def rename_image(self, ami_name, new_ami_name, source_region='us-east-1'):
"""
Method which renames an ami by copying to a new ami with a new name (only way this is possible in AWS)
:param ami_name:
:param new_ami_name:
:return:
"""
print "Re-naming/moving AMI to ... | python | def rename_image(self, ami_name, new_ami_name, source_region='us-east-1'):
"""
Method which renames an ami by copying to a new ami with a new name (only way this is possible in AWS)
:param ami_name:
:param new_ami_name:
:return:
"""
print "Re-naming/moving AMI to ... | [
"def",
"rename_image",
"(",
"self",
",",
"ami_name",
",",
"new_ami_name",
",",
"source_region",
"=",
"'us-east-1'",
")",
":",
"print",
"\"Re-naming/moving AMI to desired name and region\"",
"image_id",
"=",
"self",
".",
"get_image_id_by_name",
"(",
"ami_name",
",",
"s... | Method which renames an ami by copying to a new ami with a new name (only way this is possible in AWS)
:param ami_name:
:param new_ami_name:
:return: | [
"Method",
"which",
"renames",
"an",
"ami",
"by",
"copying",
"to",
"a",
"new",
"ami",
"with",
"a",
"new",
"name",
"(",
"only",
"way",
"this",
"is",
"possible",
"in",
"AWS",
")",
":",
"param",
"ami_name",
":",
":",
"param",
"new_ami_name",
":",
":",
"r... | train | https://github.com/ScienceLogic/amiuploader/blob/c36c247b2226107b38571cbc6119118b1fe07182/amiimporter/AWSUtilities.py#L198-L208 |
ScienceLogic/amiuploader | amiimporter/AWSUtilities.py | AWSUtils.create_config_file | def create_config_file(self, vmdk_location, description):
"""
Create the aws import config file
:param vmdk_location: location of downloaded VMDK
:param description: description to use for config_file creation
:return: config file descriptor, config file full path
"""
... | python | def create_config_file(self, vmdk_location, description):
"""
Create the aws import config file
:param vmdk_location: location of downloaded VMDK
:param description: description to use for config_file creation
:return: config file descriptor, config file full path
"""
... | [
"def",
"create_config_file",
"(",
"self",
",",
"vmdk_location",
",",
"description",
")",
":",
"description",
"=",
"description",
"format",
"=",
"\"vmdk\"",
"user_bucket",
"=",
"{",
"\"S3Bucket\"",
":",
"self",
".",
"bucket_name",
",",
"\"S3Key\"",
":",
"vmdk_loc... | Create the aws import config file
:param vmdk_location: location of downloaded VMDK
:param description: description to use for config_file creation
:return: config file descriptor, config file full path | [
"Create",
"the",
"aws",
"import",
"config",
"file",
":",
"param",
"vmdk_location",
":",
"location",
"of",
"downloaded",
"VMDK",
":",
"param",
"description",
":",
"description",
"to",
"use",
"for",
"config_file",
"creation",
":",
"return",
":",
"config",
"file"... | train | https://github.com/ScienceLogic/amiuploader/blob/c36c247b2226107b38571cbc6119118b1fe07182/amiimporter/AWSUtilities.py#L210-L231 |
ScienceLogic/amiuploader | amiimporter/AWSUtilities.py | AWSUtils.run_ec2_import | def run_ec2_import(self, config_file_location, description, region='us-east-1'):
"""
Runs the command to import an uploaded vmdk to aws ec2
:param config_file_location: config file of import param location
:param description: description to attach to the import task
:return: the ... | python | def run_ec2_import(self, config_file_location, description, region='us-east-1'):
"""
Runs the command to import an uploaded vmdk to aws ec2
:param config_file_location: config file of import param location
:param description: description to attach to the import task
:return: the ... | [
"def",
"run_ec2_import",
"(",
"self",
",",
"config_file_location",
",",
"description",
",",
"region",
"=",
"'us-east-1'",
")",
":",
"import_cmd",
"=",
"\"aws ec2 import-image --description '{}' --profile '{}' --region '{}' --output 'json'\"",
"\" --disk-containers file://{}\"",
"... | Runs the command to import an uploaded vmdk to aws ec2
:param config_file_location: config file of import param location
:param description: description to attach to the import task
:return: the import task id for the given ami | [
"Runs",
"the",
"command",
"to",
"import",
"an",
"uploaded",
"vmdk",
"to",
"aws",
"ec2",
":",
"param",
"config_file_location",
":",
"config",
"file",
"of",
"import",
"param",
"location",
":",
"param",
"description",
":",
"description",
"to",
"attach",
"to",
"... | train | https://github.com/ScienceLogic/amiuploader/blob/c36c247b2226107b38571cbc6119118b1fe07182/amiimporter/AWSUtilities.py#L233-L253 |
ScienceLogic/amiuploader | amiimporter/AWSUtilities.py | AWSUtils.upload_to_s3 | def upload_to_s3(self, region='us-east-1'):
"""
Uploads the vmdk file to aws s3
:param file_location: location of vmdk
:return:
"""
s3_import_cmd = "aws s3 cp {} s3://{} --profile '{}' --region {}".format(self.upload_file, self.bucket_name,
... | python | def upload_to_s3(self, region='us-east-1'):
"""
Uploads the vmdk file to aws s3
:param file_location: location of vmdk
:return:
"""
s3_import_cmd = "aws s3 cp {} s3://{} --profile '{}' --region {}".format(self.upload_file, self.bucket_name,
... | [
"def",
"upload_to_s3",
"(",
"self",
",",
"region",
"=",
"'us-east-1'",
")",
":",
"s3_import_cmd",
"=",
"\"aws s3 cp {} s3://{} --profile '{}' --region {}\"",
".",
"format",
"(",
"self",
".",
"upload_file",
",",
"self",
".",
"bucket_name",
",",
"self",
".",
"aws_pr... | Uploads the vmdk file to aws s3
:param file_location: location of vmdk
:return: | [
"Uploads",
"the",
"vmdk",
"file",
"to",
"aws",
"s3",
":",
"param",
"file_location",
":",
"location",
"of",
"vmdk",
":",
"return",
":"
] | train | https://github.com/ScienceLogic/amiuploader/blob/c36c247b2226107b38571cbc6119118b1fe07182/amiimporter/AWSUtilities.py#L255-L275 |
ScienceLogic/amiuploader | amiimporter/AWSUtilities.py | AWSUtils.wait_for_import_to_complete | def wait_for_import_to_complete(self, import_id, region='us-east-1'):
"""
Monitors the status of aws import, waiting for it to complete, or error out
:param import_id: id of import task to monitor
"""
task_running = True
while task_running:
import_status_cmd =... | python | def wait_for_import_to_complete(self, import_id, region='us-east-1'):
"""
Monitors the status of aws import, waiting for it to complete, or error out
:param import_id: id of import task to monitor
"""
task_running = True
while task_running:
import_status_cmd =... | [
"def",
"wait_for_import_to_complete",
"(",
"self",
",",
"import_id",
",",
"region",
"=",
"'us-east-1'",
")",
":",
"task_running",
"=",
"True",
"while",
"task_running",
":",
"import_status_cmd",
"=",
"\"aws ec2 --profile {} --region '{}' --output 'json' describe-import-image-... | Monitors the status of aws import, waiting for it to complete, or error out
:param import_id: id of import task to monitor | [
"Monitors",
"the",
"status",
"of",
"aws",
"import",
"waiting",
"for",
"it",
"to",
"complete",
"or",
"error",
"out",
":",
"param",
"import_id",
":",
"id",
"of",
"import",
"task",
"to",
"monitor"
] | train | https://github.com/ScienceLogic/amiuploader/blob/c36c247b2226107b38571cbc6119118b1fe07182/amiimporter/AWSUtilities.py#L277-L288 |
ScienceLogic/amiuploader | amiimporter/AWSUtilities.py | AWSUtils.check_task_status_and_id | def check_task_status_and_id(task_json):
"""
Read status of import json and parse
:param task_json: status json to parse
:return: (stillRunning, imageId)
"""
if task_json.get('ImportImageTasks') is not None:
task = task_json['ImportImageTasks'][0]
else... | python | def check_task_status_and_id(task_json):
"""
Read status of import json and parse
:param task_json: status json to parse
:return: (stillRunning, imageId)
"""
if task_json.get('ImportImageTasks') is not None:
task = task_json['ImportImageTasks'][0]
else... | [
"def",
"check_task_status_and_id",
"(",
"task_json",
")",
":",
"if",
"task_json",
".",
"get",
"(",
"'ImportImageTasks'",
")",
"is",
"not",
"None",
":",
"task",
"=",
"task_json",
"[",
"'ImportImageTasks'",
"]",
"[",
"0",
"]",
"else",
":",
"task",
"=",
"task... | Read status of import json and parse
:param task_json: status json to parse
:return: (stillRunning, imageId) | [
"Read",
"status",
"of",
"import",
"json",
"and",
"parse",
":",
"param",
"task_json",
":",
"status",
"json",
"to",
"parse",
":",
"return",
":",
"(",
"stillRunning",
"imageId",
")"
] | train | https://github.com/ScienceLogic/amiuploader/blob/c36c247b2226107b38571cbc6119118b1fe07182/amiimporter/AWSUtilities.py#L291-L317 |
ScienceLogic/amiuploader | amiimporter/AWSUtilities.py | AWSUtils.import_vmdk | def import_vmdk(self):
"""
All actions necessary to import vmdk (calls s3 upload, and import to aws ec2)
:param vmdk_location: location of vmdk to import. Can be provided as a string, or the result output of fabric
execution
:return:
"""
# Set the inital upload to... | python | def import_vmdk(self):
"""
All actions necessary to import vmdk (calls s3 upload, and import to aws ec2)
:param vmdk_location: location of vmdk to import. Can be provided as a string, or the result output of fabric
execution
:return:
"""
# Set the inital upload to... | [
"def",
"import_vmdk",
"(",
"self",
")",
":",
"# Set the inital upload to be the first region in the list",
"first_upload_region",
"=",
"self",
".",
"aws_regions",
"[",
"0",
"]",
"print",
"\"Initial AMI will be created in: {}\"",
".",
"format",
"(",
"first_upload_region",
")... | All actions necessary to import vmdk (calls s3 upload, and import to aws ec2)
:param vmdk_location: location of vmdk to import. Can be provided as a string, or the result output of fabric
execution
:return: | [
"All",
"actions",
"necessary",
"to",
"import",
"vmdk",
"(",
"calls",
"s3",
"upload",
"and",
"import",
"to",
"aws",
"ec2",
")",
":",
"param",
"vmdk_location",
":",
"location",
"of",
"vmdk",
"to",
"import",
".",
"Can",
"be",
"provided",
"as",
"a",
"string"... | train | https://github.com/ScienceLogic/amiuploader/blob/c36c247b2226107b38571cbc6119118b1fe07182/amiimporter/AWSUtilities.py#L319-L337 |
jfjlaros/memoise | memoise/memoise.py | _get_params | def _get_params(func, *args, **kwargs):
"""Turn an argument list into a dictionary.
:arg function func: A function.
:arg list *args: Positional arguments of `func`.
:arg dict **kwargs: Keyword arguments of `func`.
:returns dict: Dictionary representation of `args` and `kwargs`.
"""
params ... | python | def _get_params(func, *args, **kwargs):
"""Turn an argument list into a dictionary.
:arg function func: A function.
:arg list *args: Positional arguments of `func`.
:arg dict **kwargs: Keyword arguments of `func`.
:returns dict: Dictionary representation of `args` and `kwargs`.
"""
params ... | [
"def",
"_get_params",
"(",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"params",
"=",
"dict",
"(",
"zip",
"(",
"func",
".",
"func_code",
".",
"co_varnames",
"[",
":",
"len",
"(",
"args",
")",
"]",
",",
"args",
")",
")",
"if",
"... | Turn an argument list into a dictionary.
:arg function func: A function.
:arg list *args: Positional arguments of `func`.
:arg dict **kwargs: Keyword arguments of `func`.
:returns dict: Dictionary representation of `args` and `kwargs`. | [
"Turn",
"an",
"argument",
"list",
"into",
"a",
"dictionary",
"."
] | train | https://github.com/jfjlaros/memoise/blob/65c834c2a778a39742827b0627e4792637096fec/memoise/memoise.py#L6-L22 |
tomekwojcik/flask-htauth | flask_htauth/extension.py | authenticated | def authenticated(viewfunc):
"""Decorate **viewfunc** with this decorator to require HTTP auth on the
view."""
@wraps(viewfunc)
def wrapper(*args, **kwargs):
ctx = stack.top
if ctx and hasattr(ctx, 'htauth'):
auth_header = request.headers.get('Authorization', None)
... | python | def authenticated(viewfunc):
"""Decorate **viewfunc** with this decorator to require HTTP auth on the
view."""
@wraps(viewfunc)
def wrapper(*args, **kwargs):
ctx = stack.top
if ctx and hasattr(ctx, 'htauth'):
auth_header = request.headers.get('Authorization', None)
... | [
"def",
"authenticated",
"(",
"viewfunc",
")",
":",
"@",
"wraps",
"(",
"viewfunc",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"ctx",
"=",
"stack",
".",
"top",
"if",
"ctx",
"and",
"hasattr",
"(",
"ctx",
",",
"'htauth'... | Decorate **viewfunc** with this decorator to require HTTP auth on the
view. | [
"Decorate",
"**",
"viewfunc",
"**",
"with",
"this",
"decorator",
"to",
"require",
"HTTP",
"auth",
"on",
"the",
"view",
"."
] | train | https://github.com/tomekwojcik/flask-htauth/blob/bb89bee3fa7d88de3147ae338048624e01de710b/flask_htauth/extension.py#L81-L109 |
refinery29/chassis | chassis/services/dependency_injection/__init__.py | _check_type | def _check_type(name, obj, expected_type):
""" Raise a TypeError if object is not of expected type """
if not isinstance(obj, expected_type):
raise TypeError(
'"%s" must be an a %s' % (name, expected_type.__name__)
) | python | def _check_type(name, obj, expected_type):
""" Raise a TypeError if object is not of expected type """
if not isinstance(obj, expected_type):
raise TypeError(
'"%s" must be an a %s' % (name, expected_type.__name__)
) | [
"def",
"_check_type",
"(",
"name",
",",
"obj",
",",
"expected_type",
")",
":",
"if",
"not",
"isinstance",
"(",
"obj",
",",
"expected_type",
")",
":",
"raise",
"TypeError",
"(",
"'\"%s\" must be an a %s'",
"%",
"(",
"name",
",",
"expected_type",
".",
"__name_... | Raise a TypeError if object is not of expected type | [
"Raise",
"a",
"TypeError",
"if",
"object",
"is",
"not",
"of",
"expected",
"type"
] | train | https://github.com/refinery29/chassis/blob/1238d5214cbb8f3e1fe7c0dc2fa72f45bf085192/chassis/services/dependency_injection/__init__.py#L27-L32 |
refinery29/chassis | chassis/services/dependency_injection/__init__.py | _import_module | def _import_module(module_name):
"""
Imports the module dynamically
_import_module('foo.bar') calls:
__import__('foo.bar',
globals(),
locals(),
['bar', ],
0)
"""
fromlist = []
dot_pos... | python | def _import_module(module_name):
"""
Imports the module dynamically
_import_module('foo.bar') calls:
__import__('foo.bar',
globals(),
locals(),
['bar', ],
0)
"""
fromlist = []
dot_pos... | [
"def",
"_import_module",
"(",
"module_name",
")",
":",
"fromlist",
"=",
"[",
"]",
"dot_position",
"=",
"module_name",
".",
"rfind",
"(",
"'.'",
")",
"if",
"dot_position",
">",
"-",
"1",
":",
"fromlist",
".",
"append",
"(",
"module_name",
"[",
"dot_position... | Imports the module dynamically
_import_module('foo.bar') calls:
__import__('foo.bar',
globals(),
locals(),
['bar', ],
0) | [
"Imports",
"the",
"module",
"dynamically"
] | train | https://github.com/refinery29/chassis/blob/1238d5214cbb8f3e1fe7c0dc2fa72f45bf085192/chassis/services/dependency_injection/__init__.py#L35-L56 |
refinery29/chassis | chassis/services/dependency_injection/__init__.py | _verify_create_args | def _verify_create_args(module_name, class_name, static):
""" Verifies a subset of the arguments to create() """
# Verify module name is provided
if module_name is None:
raise InvalidServiceConfiguration(
'Service configurations must define a module'
)
# Non-static services ... | python | def _verify_create_args(module_name, class_name, static):
""" Verifies a subset of the arguments to create() """
# Verify module name is provided
if module_name is None:
raise InvalidServiceConfiguration(
'Service configurations must define a module'
)
# Non-static services ... | [
"def",
"_verify_create_args",
"(",
"module_name",
",",
"class_name",
",",
"static",
")",
":",
"# Verify module name is provided",
"if",
"module_name",
"is",
"None",
":",
"raise",
"InvalidServiceConfiguration",
"(",
"'Service configurations must define a module'",
")",
"# No... | Verifies a subset of the arguments to create() | [
"Verifies",
"a",
"subset",
"of",
"the",
"arguments",
"to",
"create",
"()"
] | train | https://github.com/refinery29/chassis/blob/1238d5214cbb8f3e1fe7c0dc2fa72f45bf085192/chassis/services/dependency_injection/__init__.py#L59-L71 |
refinery29/chassis | chassis/services/dependency_injection/__init__.py | ServiceFactory.create | def create(self, module_name, class_name,
args=None, kwargs=None, factory_method=None,
factory_args=None, factory_kwargs=None, static=False,
calls=None):
""" Initializes an instance of the service """
if args is None:
args = []
if kwargs i... | python | def create(self, module_name, class_name,
args=None, kwargs=None, factory_method=None,
factory_args=None, factory_kwargs=None, static=False,
calls=None):
""" Initializes an instance of the service """
if args is None:
args = []
if kwargs i... | [
"def",
"create",
"(",
"self",
",",
"module_name",
",",
"class_name",
",",
"args",
"=",
"None",
",",
"kwargs",
"=",
"None",
",",
"factory_method",
"=",
"None",
",",
"factory_args",
"=",
"None",
",",
"factory_kwargs",
"=",
"None",
",",
"static",
"=",
"Fals... | Initializes an instance of the service | [
"Initializes",
"an",
"instance",
"of",
"the",
"service"
] | train | https://github.com/refinery29/chassis/blob/1238d5214cbb8f3e1fe7c0dc2fa72f45bf085192/chassis/services/dependency_injection/__init__.py#L86-L122 |
refinery29/chassis | chassis/services/dependency_injection/__init__.py | ServiceFactory.create_from_dict | def create_from_dict(self, dictionary):
""" Initializes an instance from a dictionary blueprint """
# Defaults
args = []
kwargs = {}
factory_method = None
factory_args = []
factory_kwargs = {}
static = False
calls = None
# Check dictionary... | python | def create_from_dict(self, dictionary):
""" Initializes an instance from a dictionary blueprint """
# Defaults
args = []
kwargs = {}
factory_method = None
factory_args = []
factory_kwargs = {}
static = False
calls = None
# Check dictionary... | [
"def",
"create_from_dict",
"(",
"self",
",",
"dictionary",
")",
":",
"# Defaults",
"args",
"=",
"[",
"]",
"kwargs",
"=",
"{",
"}",
"factory_method",
"=",
"None",
"factory_args",
"=",
"[",
"]",
"factory_kwargs",
"=",
"{",
"}",
"static",
"=",
"False",
"cal... | Initializes an instance from a dictionary blueprint | [
"Initializes",
"an",
"instance",
"from",
"a",
"dictionary",
"blueprint"
] | train | https://github.com/refinery29/chassis/blob/1238d5214cbb8f3e1fe7c0dc2fa72f45bf085192/chassis/services/dependency_injection/__init__.py#L124-L167 |
refinery29/chassis | chassis/services/dependency_injection/__init__.py | ServiceFactory.get_instantiated_service | def get_instantiated_service(self, name):
""" Get instantiated service by name """
if name not in self.instantiated_services:
raise UninstantiatedServiceException
return self.instantiated_services[name] | python | def get_instantiated_service(self, name):
""" Get instantiated service by name """
if name not in self.instantiated_services:
raise UninstantiatedServiceException
return self.instantiated_services[name] | [
"def",
"get_instantiated_service",
"(",
"self",
",",
"name",
")",
":",
"if",
"name",
"not",
"in",
"self",
".",
"instantiated_services",
":",
"raise",
"UninstantiatedServiceException",
"return",
"self",
".",
"instantiated_services",
"[",
"name",
"]"
] | Get instantiated service by name | [
"Get",
"instantiated",
"service",
"by",
"name"
] | train | https://github.com/refinery29/chassis/blob/1238d5214cbb8f3e1fe7c0dc2fa72f45bf085192/chassis/services/dependency_injection/__init__.py#L177-L181 |
refinery29/chassis | chassis/services/dependency_injection/__init__.py | ServiceFactory._replace_service_arg | def _replace_service_arg(self, name, index, args):
""" Replace index in list with service """
args[index] = self.get_instantiated_service(name) | python | def _replace_service_arg(self, name, index, args):
""" Replace index in list with service """
args[index] = self.get_instantiated_service(name) | [
"def",
"_replace_service_arg",
"(",
"self",
",",
"name",
",",
"index",
",",
"args",
")",
":",
"args",
"[",
"index",
"]",
"=",
"self",
".",
"get_instantiated_service",
"(",
"name",
")"
] | Replace index in list with service | [
"Replace",
"index",
"in",
"list",
"with",
"service"
] | train | https://github.com/refinery29/chassis/blob/1238d5214cbb8f3e1fe7c0dc2fa72f45bf085192/chassis/services/dependency_injection/__init__.py#L183-L185 |
refinery29/chassis | chassis/services/dependency_injection/__init__.py | ServiceFactory._replace_scalars_in_args | def _replace_scalars_in_args(self, args):
""" Replace scalars in arguments list """
_check_type('args', args, list)
new_args = []
for arg in args:
if isinstance(arg, list):
to_append = self._replace_scalars_in_args(arg)
elif isinstance(arg, dict):
... | python | def _replace_scalars_in_args(self, args):
""" Replace scalars in arguments list """
_check_type('args', args, list)
new_args = []
for arg in args:
if isinstance(arg, list):
to_append = self._replace_scalars_in_args(arg)
elif isinstance(arg, dict):
... | [
"def",
"_replace_scalars_in_args",
"(",
"self",
",",
"args",
")",
":",
"_check_type",
"(",
"'args'",
",",
"args",
",",
"list",
")",
"new_args",
"=",
"[",
"]",
"for",
"arg",
"in",
"args",
":",
"if",
"isinstance",
"(",
"arg",
",",
"list",
")",
":",
"to... | Replace scalars in arguments list | [
"Replace",
"scalars",
"in",
"arguments",
"list"
] | train | https://github.com/refinery29/chassis/blob/1238d5214cbb8f3e1fe7c0dc2fa72f45bf085192/chassis/services/dependency_injection/__init__.py#L191-L205 |
refinery29/chassis | chassis/services/dependency_injection/__init__.py | ServiceFactory._replace_scalars_in_kwargs | def _replace_scalars_in_kwargs(self, kwargs):
""" Replace scalars in keyed arguments dictionary """
_check_type('kwargs', kwargs, dict)
new_kwargs = {}
for (name, value) in iteritems(kwargs):
if isinstance(value, list):
new_kwargs[name] = self._replace_scalar... | python | def _replace_scalars_in_kwargs(self, kwargs):
""" Replace scalars in keyed arguments dictionary """
_check_type('kwargs', kwargs, dict)
new_kwargs = {}
for (name, value) in iteritems(kwargs):
if isinstance(value, list):
new_kwargs[name] = self._replace_scalar... | [
"def",
"_replace_scalars_in_kwargs",
"(",
"self",
",",
"kwargs",
")",
":",
"_check_type",
"(",
"'kwargs'",
",",
"kwargs",
",",
"dict",
")",
"new_kwargs",
"=",
"{",
"}",
"for",
"(",
"name",
",",
"value",
")",
"in",
"iteritems",
"(",
"kwargs",
")",
":",
... | Replace scalars in keyed arguments dictionary | [
"Replace",
"scalars",
"in",
"keyed",
"arguments",
"dictionary"
] | train | https://github.com/refinery29/chassis/blob/1238d5214cbb8f3e1fe7c0dc2fa72f45bf085192/chassis/services/dependency_injection/__init__.py#L207-L221 |
refinery29/chassis | chassis/services/dependency_injection/__init__.py | ServiceFactory._replace_services_in_args | def _replace_services_in_args(self, args):
""" Replace service references in arguments list """
_check_type('args', args, list)
new_args = []
for arg in args:
if isinstance(arg, list):
new_args.append(self._replace_services_in_args(arg))
elif isin... | python | def _replace_services_in_args(self, args):
""" Replace service references in arguments list """
_check_type('args', args, list)
new_args = []
for arg in args:
if isinstance(arg, list):
new_args.append(self._replace_services_in_args(arg))
elif isin... | [
"def",
"_replace_services_in_args",
"(",
"self",
",",
"args",
")",
":",
"_check_type",
"(",
"'args'",
",",
"args",
",",
"list",
")",
"new_args",
"=",
"[",
"]",
"for",
"arg",
"in",
"args",
":",
"if",
"isinstance",
"(",
"arg",
",",
"list",
")",
":",
"n... | Replace service references in arguments list | [
"Replace",
"service",
"references",
"in",
"arguments",
"list"
] | train | https://github.com/refinery29/chassis/blob/1238d5214cbb8f3e1fe7c0dc2fa72f45bf085192/chassis/services/dependency_injection/__init__.py#L223-L237 |
refinery29/chassis | chassis/services/dependency_injection/__init__.py | ServiceFactory._replace_services_in_kwargs | def _replace_services_in_kwargs(self, kwargs):
""" Replace service references in keyed arguments dictionary """
_check_type('kwargs', kwargs, dict)
new_kwargs = {}
for (name, value) in iteritems(kwargs):
if isinstance(value, list):
new_kwargs[name] = self._re... | python | def _replace_services_in_kwargs(self, kwargs):
""" Replace service references in keyed arguments dictionary """
_check_type('kwargs', kwargs, dict)
new_kwargs = {}
for (name, value) in iteritems(kwargs):
if isinstance(value, list):
new_kwargs[name] = self._re... | [
"def",
"_replace_services_in_kwargs",
"(",
"self",
",",
"kwargs",
")",
":",
"_check_type",
"(",
"'kwargs'",
",",
"kwargs",
",",
"dict",
")",
"new_kwargs",
"=",
"{",
"}",
"for",
"(",
"name",
",",
"value",
")",
"in",
"iteritems",
"(",
"kwargs",
")",
":",
... | Replace service references in keyed arguments dictionary | [
"Replace",
"service",
"references",
"in",
"keyed",
"arguments",
"dictionary"
] | train | https://github.com/refinery29/chassis/blob/1238d5214cbb8f3e1fe7c0dc2fa72f45bf085192/chassis/services/dependency_injection/__init__.py#L239-L253 |
refinery29/chassis | chassis/services/dependency_injection/__init__.py | ServiceFactory.get_scalar_value | def get_scalar_value(self, name):
""" Get scalar value by name """
if name not in self.scalars:
raise InvalidServiceConfiguration(
'Invalid Service Argument Scalar "%s" (not found)' % name
)
new_value = self.scalars.get(name)
return new_value | python | def get_scalar_value(self, name):
""" Get scalar value by name """
if name not in self.scalars:
raise InvalidServiceConfiguration(
'Invalid Service Argument Scalar "%s" (not found)' % name
)
new_value = self.scalars.get(name)
return new_value | [
"def",
"get_scalar_value",
"(",
"self",
",",
"name",
")",
":",
"if",
"name",
"not",
"in",
"self",
".",
"scalars",
":",
"raise",
"InvalidServiceConfiguration",
"(",
"'Invalid Service Argument Scalar \"%s\" (not found)'",
"%",
"name",
")",
"new_value",
"=",
"self",
... | Get scalar value by name | [
"Get",
"scalar",
"value",
"by",
"name"
] | train | https://github.com/refinery29/chassis/blob/1238d5214cbb8f3e1fe7c0dc2fa72f45bf085192/chassis/services/dependency_injection/__init__.py#L255-L262 |
refinery29/chassis | chassis/services/dependency_injection/__init__.py | ServiceFactory._replace_scalar | def _replace_scalar(self, scalar):
""" Replace scalar name with scalar value """
if not is_arg_scalar(scalar):
return scalar
name = scalar[1:]
return self.get_scalar_value(name) | python | def _replace_scalar(self, scalar):
""" Replace scalar name with scalar value """
if not is_arg_scalar(scalar):
return scalar
name = scalar[1:]
return self.get_scalar_value(name) | [
"def",
"_replace_scalar",
"(",
"self",
",",
"scalar",
")",
":",
"if",
"not",
"is_arg_scalar",
"(",
"scalar",
")",
":",
"return",
"scalar",
"name",
"=",
"scalar",
"[",
"1",
":",
"]",
"return",
"self",
".",
"get_scalar_value",
"(",
"name",
")"
] | Replace scalar name with scalar value | [
"Replace",
"scalar",
"name",
"with",
"scalar",
"value"
] | train | https://github.com/refinery29/chassis/blob/1238d5214cbb8f3e1fe7c0dc2fa72f45bf085192/chassis/services/dependency_injection/__init__.py#L264-L269 |
refinery29/chassis | chassis/services/dependency_injection/__init__.py | ServiceFactory._instantiate | def _instantiate(self, module, class_name,
args=None, kwargs=None, static=None):
""" Instantiates a class if provided """
if args is None:
args = []
if kwargs is None:
kwargs = {}
if static is None:
static = False
_check_t... | python | def _instantiate(self, module, class_name,
args=None, kwargs=None, static=None):
""" Instantiates a class if provided """
if args is None:
args = []
if kwargs is None:
kwargs = {}
if static is None:
static = False
_check_t... | [
"def",
"_instantiate",
"(",
"self",
",",
"module",
",",
"class_name",
",",
"args",
"=",
"None",
",",
"kwargs",
"=",
"None",
",",
"static",
"=",
"None",
")",
":",
"if",
"args",
"is",
"None",
":",
"args",
"=",
"[",
"]",
"if",
"kwargs",
"is",
"None",
... | Instantiates a class if provided | [
"Instantiates",
"a",
"class",
"if",
"provided"
] | train | https://github.com/refinery29/chassis/blob/1238d5214cbb8f3e1fe7c0dc2fa72f45bf085192/chassis/services/dependency_injection/__init__.py#L277-L307 |
refinery29/chassis | chassis/services/dependency_injection/__init__.py | ServiceFactory._handle_factory_method | def _handle_factory_method(self, service_obj, method_name,
args=None, kwargs=None):
"""" Returns an object returned from a factory method """
if args is None:
args = []
if kwargs is None:
kwargs = {}
_check_type('args', args, list)
... | python | def _handle_factory_method(self, service_obj, method_name,
args=None, kwargs=None):
"""" Returns an object returned from a factory method """
if args is None:
args = []
if kwargs is None:
kwargs = {}
_check_type('args', args, list)
... | [
"def",
"_handle_factory_method",
"(",
"self",
",",
"service_obj",
",",
"method_name",
",",
"args",
"=",
"None",
",",
"kwargs",
"=",
"None",
")",
":",
"if",
"args",
"is",
"None",
":",
"args",
"=",
"[",
"]",
"if",
"kwargs",
"is",
"None",
":",
"kwargs",
... | Returns an object returned from a factory method | [
"Returns",
"an",
"object",
"returned",
"from",
"a",
"factory",
"method"
] | train | https://github.com/refinery29/chassis/blob/1238d5214cbb8f3e1fe7c0dc2fa72f45bf085192/chassis/services/dependency_injection/__init__.py#L309-L324 |
refinery29/chassis | chassis/services/dependency_injection/__init__.py | ServiceFactory._handle_calls | def _handle_calls(self, service_obj, calls):
""" Performs method calls on service object """
for call in calls:
method = call.get('method')
args = call.get('args', [])
kwargs = call.get('kwargs', {})
_check_type('args', args, list)
_check_typ... | python | def _handle_calls(self, service_obj, calls):
""" Performs method calls on service object """
for call in calls:
method = call.get('method')
args = call.get('args', [])
kwargs = call.get('kwargs', {})
_check_type('args', args, list)
_check_typ... | [
"def",
"_handle_calls",
"(",
"self",
",",
"service_obj",
",",
"calls",
")",
":",
"for",
"call",
"in",
"calls",
":",
"method",
"=",
"call",
".",
"get",
"(",
"'method'",
")",
"args",
"=",
"call",
".",
"get",
"(",
"'args'",
",",
"[",
"]",
")",
"kwargs... | Performs method calls on service object | [
"Performs",
"method",
"calls",
"on",
"service",
"object"
] | train | https://github.com/refinery29/chassis/blob/1238d5214cbb8f3e1fe7c0dc2fa72f45bf085192/chassis/services/dependency_injection/__init__.py#L326-L344 |
breuleux/hrepr | hrepr/h.py | Tag._repr_html_ | def _repr_html_(self):
"""
Jupyter Notebook hook to print this element as HTML.
"""
nbreset = f'<style>{css_nbreset}</style>'
resources = ''.join(map(str, self.resources))
return f'<div>{nbreset}{resources}<div class="hrepr">{self}</div></div>' | python | def _repr_html_(self):
"""
Jupyter Notebook hook to print this element as HTML.
"""
nbreset = f'<style>{css_nbreset}</style>'
resources = ''.join(map(str, self.resources))
return f'<div>{nbreset}{resources}<div class="hrepr">{self}</div></div>' | [
"def",
"_repr_html_",
"(",
"self",
")",
":",
"nbreset",
"=",
"f'<style>{css_nbreset}</style>'",
"resources",
"=",
"''",
".",
"join",
"(",
"map",
"(",
"str",
",",
"self",
".",
"resources",
")",
")",
"return",
"f'<div>{nbreset}{resources}<div class=\"hrepr\">{self}</d... | Jupyter Notebook hook to print this element as HTML. | [
"Jupyter",
"Notebook",
"hook",
"to",
"print",
"this",
"element",
"as",
"HTML",
"."
] | train | https://github.com/breuleux/hrepr/blob/a411395d31ac7c8c071d174e63a093751aa5997b/hrepr/h.py#L143-L149 |
breuleux/hrepr | hrepr/h.py | Tag.as_page | def as_page(self):
"""
Wrap this Tag as a self-contained webpage. Create a page with
the following structure:
.. code-block:: html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type"
content="text/htm... | python | def as_page(self):
"""
Wrap this Tag as a self-contained webpage. Create a page with
the following structure:
.. code-block:: html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type"
content="text/htm... | [
"def",
"as_page",
"(",
"self",
")",
":",
"H",
"=",
"HTML",
"(",
")",
"utf8",
"=",
"H",
".",
"meta",
"(",
"{",
"'http-equiv'",
":",
"'Content-type'",
"}",
",",
"content",
"=",
"\"text/html\"",
",",
"charset",
"=",
"\"UTF-8\"",
")",
"return",
"H",
".",... | Wrap this Tag as a self-contained webpage. Create a page with
the following structure:
.. code-block:: html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type"
content="text/html"
charset="UTF-8... | [
"Wrap",
"this",
"Tag",
"as",
"a",
"self",
"-",
"contained",
"webpage",
".",
"Create",
"a",
"page",
"with",
"the",
"following",
"structure",
":"
] | train | https://github.com/breuleux/hrepr/blob/a411395d31ac7c8c071d174e63a093751aa5997b/hrepr/h.py#L151-L177 |
rackerlabs/rackspace-python-neutronclient | neutronclient/neutron/client.py | make_client | def make_client(instance):
"""Returns an neutron client."""
neutron_client = utils.get_client_class(
API_NAME,
instance._api_version[API_NAME],
API_VERSIONS,
)
instance.initialize()
url = instance._url
url = url.rstrip("/")
client = neutron_client(username=instance._u... | python | def make_client(instance):
"""Returns an neutron client."""
neutron_client = utils.get_client_class(
API_NAME,
instance._api_version[API_NAME],
API_VERSIONS,
)
instance.initialize()
url = instance._url
url = url.rstrip("/")
client = neutron_client(username=instance._u... | [
"def",
"make_client",
"(",
"instance",
")",
":",
"neutron_client",
"=",
"utils",
".",
"get_client_class",
"(",
"API_NAME",
",",
"instance",
".",
"_api_version",
"[",
"API_NAME",
"]",
",",
"API_VERSIONS",
",",
")",
"instance",
".",
"initialize",
"(",
")",
"ur... | Returns an neutron client. | [
"Returns",
"an",
"neutron",
"client",
"."
] | train | https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/neutron/client.py#L27-L52 |
rackerlabs/rackspace-python-neutronclient | neutronclient/neutron/client.py | Client | def Client(api_version, *args, **kwargs):
"""Return an neutron client.
@param api_version: only 2.0 is supported now
"""
neutron_client = utils.get_client_class(
API_NAME,
api_version,
API_VERSIONS,
)
return neutron_client(*args, **kwargs) | python | def Client(api_version, *args, **kwargs):
"""Return an neutron client.
@param api_version: only 2.0 is supported now
"""
neutron_client = utils.get_client_class(
API_NAME,
api_version,
API_VERSIONS,
)
return neutron_client(*args, **kwargs) | [
"def",
"Client",
"(",
"api_version",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"neutron_client",
"=",
"utils",
".",
"get_client_class",
"(",
"API_NAME",
",",
"api_version",
",",
"API_VERSIONS",
",",
")",
"return",
"neutron_client",
"(",
"*",
"ar... | Return an neutron client.
@param api_version: only 2.0 is supported now | [
"Return",
"an",
"neutron",
"client",
"."
] | train | https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/neutron/client.py#L55-L65 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.