repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
cthoyt/onto2nx | src/onto2nx/ontospy/core/ontospy.py | Ontospy.getClass | def getClass(self, id=None, uri=None, match=None):
"""
get the saved-class with given ID or via other methods...
Note: it tries to guess what is being passed..
In [1]: g.getClass(uri='http://www.w3.org/2000/01/rdf-schema#Resource')
Out[1]: <Class *http://www.w3.org/2000/01/rdf-... | python | def getClass(self, id=None, uri=None, match=None):
"""
get the saved-class with given ID or via other methods...
Note: it tries to guess what is being passed..
In [1]: g.getClass(uri='http://www.w3.org/2000/01/rdf-schema#Resource')
Out[1]: <Class *http://www.w3.org/2000/01/rdf-... | [
"def",
"getClass",
"(",
"self",
",",
"id",
"=",
"None",
",",
"uri",
"=",
"None",
",",
"match",
"=",
"None",
")",
":",
"if",
"not",
"id",
"and",
"not",
"uri",
"and",
"not",
"match",
":",
"return",
"None",
"if",
"type",
"(",
"id",
")",
"==",
"typ... | get the saved-class with given ID or via other methods...
Note: it tries to guess what is being passed..
In [1]: g.getClass(uri='http://www.w3.org/2000/01/rdf-schema#Resource')
Out[1]: <Class *http://www.w3.org/2000/01/rdf-schema#Resource*>
In [2]: g.getClass(10)
Out[2]: <Clas... | [
"get",
"the",
"saved",
"-",
"class",
"with",
"given",
"ID",
"or",
"via",
"other",
"methods",
"..."
] | train | https://github.com/cthoyt/onto2nx/blob/94c86e5e187cca67534afe0260097177b66e02c8/src/onto2nx/ontospy/core/ontospy.py#L515-L563 |
cthoyt/onto2nx | src/onto2nx/ontospy/core/ontospy.py | Ontospy.getProperty | def getProperty(self, id=None, uri=None, match=None):
"""
get the saved-class with given ID or via other methods...
Note: analogous to getClass method
"""
if not id and not uri and not match:
return None
if type(id) == type("string"):
uri = id
... | python | def getProperty(self, id=None, uri=None, match=None):
"""
get the saved-class with given ID or via other methods...
Note: analogous to getClass method
"""
if not id and not uri and not match:
return None
if type(id) == type("string"):
uri = id
... | [
"def",
"getProperty",
"(",
"self",
",",
"id",
"=",
"None",
",",
"uri",
"=",
"None",
",",
"match",
"=",
"None",
")",
":",
"if",
"not",
"id",
"and",
"not",
"uri",
"and",
"not",
"match",
":",
"return",
"None",
"if",
"type",
"(",
"id",
")",
"==",
"... | get the saved-class with given ID or via other methods...
Note: analogous to getClass method | [
"get",
"the",
"saved",
"-",
"class",
"with",
"given",
"ID",
"or",
"via",
"other",
"methods",
"..."
] | train | https://github.com/cthoyt/onto2nx/blob/94c86e5e187cca67534afe0260097177b66e02c8/src/onto2nx/ontospy/core/ontospy.py#L566-L601 |
cthoyt/onto2nx | src/onto2nx/ontospy/core/ontospy.py | Ontospy.getSkosConcept | def getSkosConcept(self, id=None, uri=None, match=None):
"""
get the saved skos concept with given ID or via other methods...
Note: it tries to guess what is being passed as above
"""
if not id and not uri and not match:
return None
if type(id) == type("str... | python | def getSkosConcept(self, id=None, uri=None, match=None):
"""
get the saved skos concept with given ID or via other methods...
Note: it tries to guess what is being passed as above
"""
if not id and not uri and not match:
return None
if type(id) == type("str... | [
"def",
"getSkosConcept",
"(",
"self",
",",
"id",
"=",
"None",
",",
"uri",
"=",
"None",
",",
"match",
"=",
"None",
")",
":",
"if",
"not",
"id",
"and",
"not",
"uri",
"and",
"not",
"match",
":",
"return",
"None",
"if",
"type",
"(",
"id",
")",
"==",
... | get the saved skos concept with given ID or via other methods...
Note: it tries to guess what is being passed as above | [
"get",
"the",
"saved",
"skos",
"concept",
"with",
"given",
"ID",
"or",
"via",
"other",
"methods",
"..."
] | train | https://github.com/cthoyt/onto2nx/blob/94c86e5e187cca67534afe0260097177b66e02c8/src/onto2nx/ontospy/core/ontospy.py#L604-L639 |
cthoyt/onto2nx | src/onto2nx/ontospy/core/ontospy.py | Ontospy.getEntity | def getEntity(self, id=None, uri=None, match=None):
"""
get a generic entity with given ID or via other methods...
"""
if not id and not uri and not match:
return None
if type(id) == type("string"):
uri = id
id = None
if not uri.s... | python | def getEntity(self, id=None, uri=None, match=None):
"""
get a generic entity with given ID or via other methods...
"""
if not id and not uri and not match:
return None
if type(id) == type("string"):
uri = id
id = None
if not uri.s... | [
"def",
"getEntity",
"(",
"self",
",",
"id",
"=",
"None",
",",
"uri",
"=",
"None",
",",
"match",
"=",
"None",
")",
":",
"if",
"not",
"id",
"and",
"not",
"uri",
"and",
"not",
"match",
":",
"return",
"None",
"if",
"type",
"(",
"id",
")",
"==",
"ty... | get a generic entity with given ID or via other methods... | [
"get",
"a",
"generic",
"entity",
"with",
"given",
"ID",
"or",
"via",
"other",
"methods",
"..."
] | train | https://github.com/cthoyt/onto2nx/blob/94c86e5e187cca67534afe0260097177b66e02c8/src/onto2nx/ontospy/core/ontospy.py#L642-L686 |
cthoyt/onto2nx | src/onto2nx/ontospy/core/ontospy.py | Ontospy.getOntology | def getOntology(self, id=None, uri=None, match=None):
"""
get the saved-ontology with given ID or via other methods...
"""
if not id and not uri and not match:
return None
if type(id) == type("string"):
uri = id
id = None
if not u... | python | def getOntology(self, id=None, uri=None, match=None):
"""
get the saved-ontology with given ID or via other methods...
"""
if not id and not uri and not match:
return None
if type(id) == type("string"):
uri = id
id = None
if not u... | [
"def",
"getOntology",
"(",
"self",
",",
"id",
"=",
"None",
",",
"uri",
"=",
"None",
",",
"match",
"=",
"None",
")",
":",
"if",
"not",
"id",
"and",
"not",
"uri",
"and",
"not",
"match",
":",
"return",
"None",
"if",
"type",
"(",
"id",
")",
"==",
"... | get the saved-ontology with given ID or via other methods... | [
"get",
"the",
"saved",
"-",
"ontology",
"with",
"given",
"ID",
"or",
"via",
"other",
"methods",
"..."
] | train | https://github.com/cthoyt/onto2nx/blob/94c86e5e187cca67534afe0260097177b66e02c8/src/onto2nx/ontospy/core/ontospy.py#L690-L718 |
cthoyt/onto2nx | src/onto2nx/ontospy/core/ontospy.py | Ontospy.nextClass | def nextClass(self, classuri):
"""Returns the next class in the list of classes. If it's the last one, returns the first one."""
if classuri == self.classes[-1].uri:
return self.classes[0]
flag = False
for x in self.classes:
if flag == True:
return... | python | def nextClass(self, classuri):
"""Returns the next class in the list of classes. If it's the last one, returns the first one."""
if classuri == self.classes[-1].uri:
return self.classes[0]
flag = False
for x in self.classes:
if flag == True:
return... | [
"def",
"nextClass",
"(",
"self",
",",
"classuri",
")",
":",
"if",
"classuri",
"==",
"self",
".",
"classes",
"[",
"-",
"1",
"]",
".",
"uri",
":",
"return",
"self",
".",
"classes",
"[",
"0",
"]",
"flag",
"=",
"False",
"for",
"x",
"in",
"self",
".",... | Returns the next class in the list of classes. If it's the last one, returns the first one. | [
"Returns",
"the",
"next",
"class",
"in",
"the",
"list",
"of",
"classes",
".",
"If",
"it",
"s",
"the",
"last",
"one",
"returns",
"the",
"first",
"one",
"."
] | train | https://github.com/cthoyt/onto2nx/blob/94c86e5e187cca67534afe0260097177b66e02c8/src/onto2nx/ontospy/core/ontospy.py#L721-L731 |
cthoyt/onto2nx | src/onto2nx/ontospy/core/ontospy.py | Ontospy.nextProperty | def nextProperty(self, propuri):
"""Returns the next property in the list of properties. If it's the last one, returns the first one."""
if propuri == self.properties[-1].uri:
return self.properties[0]
flag = False
for x in self.properties:
if flag == True:
... | python | def nextProperty(self, propuri):
"""Returns the next property in the list of properties. If it's the last one, returns the first one."""
if propuri == self.properties[-1].uri:
return self.properties[0]
flag = False
for x in self.properties:
if flag == True:
... | [
"def",
"nextProperty",
"(",
"self",
",",
"propuri",
")",
":",
"if",
"propuri",
"==",
"self",
".",
"properties",
"[",
"-",
"1",
"]",
".",
"uri",
":",
"return",
"self",
".",
"properties",
"[",
"0",
"]",
"flag",
"=",
"False",
"for",
"x",
"in",
"self",... | Returns the next property in the list of properties. If it's the last one, returns the first one. | [
"Returns",
"the",
"next",
"property",
"in",
"the",
"list",
"of",
"properties",
".",
"If",
"it",
"s",
"the",
"last",
"one",
"returns",
"the",
"first",
"one",
"."
] | train | https://github.com/cthoyt/onto2nx/blob/94c86e5e187cca67534afe0260097177b66e02c8/src/onto2nx/ontospy/core/ontospy.py#L734-L744 |
cthoyt/onto2nx | src/onto2nx/ontospy/core/ontospy.py | Ontospy.nextConcept | def nextConcept(self, concepturi):
"""Returns the next skos concept in the list of concepts. If it's the last one, returns the first one."""
if concepturi == self.skosConcepts[-1].uri:
return self.skosConcepts[0]
flag = False
for x in self.skosConcepts:
if flag ==... | python | def nextConcept(self, concepturi):
"""Returns the next skos concept in the list of concepts. If it's the last one, returns the first one."""
if concepturi == self.skosConcepts[-1].uri:
return self.skosConcepts[0]
flag = False
for x in self.skosConcepts:
if flag ==... | [
"def",
"nextConcept",
"(",
"self",
",",
"concepturi",
")",
":",
"if",
"concepturi",
"==",
"self",
".",
"skosConcepts",
"[",
"-",
"1",
"]",
".",
"uri",
":",
"return",
"self",
".",
"skosConcepts",
"[",
"0",
"]",
"flag",
"=",
"False",
"for",
"x",
"in",
... | Returns the next skos concept in the list of concepts. If it's the last one, returns the first one. | [
"Returns",
"the",
"next",
"skos",
"concept",
"in",
"the",
"list",
"of",
"concepts",
".",
"If",
"it",
"s",
"the",
"last",
"one",
"returns",
"the",
"first",
"one",
"."
] | train | https://github.com/cthoyt/onto2nx/blob/94c86e5e187cca67534afe0260097177b66e02c8/src/onto2nx/ontospy/core/ontospy.py#L746-L756 |
cthoyt/onto2nx | src/onto2nx/ontospy/core/ontospy.py | Ontospy.printSkosTree | def printSkosTree(self, element = None, showids=False, labels=False, showtype=False):
"""
Print nicely into stdout the SKOS tree of an ontology
Note: indentation is made so that ids up to 3 digits fit in, plus a space.
[123]1--
[1]123--
[12]12--
"""
TYPE_... | python | def printSkosTree(self, element = None, showids=False, labels=False, showtype=False):
"""
Print nicely into stdout the SKOS tree of an ontology
Note: indentation is made so that ids up to 3 digits fit in, plus a space.
[123]1--
[1]123--
[12]12--
"""
TYPE_... | [
"def",
"printSkosTree",
"(",
"self",
",",
"element",
"=",
"None",
",",
"showids",
"=",
"False",
",",
"labels",
"=",
"False",
",",
"showtype",
"=",
"False",
")",
":",
"TYPE_MARGIN",
"=",
"13",
"# length for skos:concept",
"if",
"not",
"element",
":",
"# fir... | Print nicely into stdout the SKOS tree of an ontology
Note: indentation is made so that ids up to 3 digits fit in, plus a space.
[123]1--
[1]123--
[12]12-- | [
"Print",
"nicely",
"into",
"stdout",
"the",
"SKOS",
"tree",
"of",
"an",
"ontology"
] | train | https://github.com/cthoyt/onto2nx/blob/94c86e5e187cca67534afe0260097177b66e02c8/src/onto2nx/ontospy/core/ontospy.py#L797-L813 |
justquick/django-native-tags | native_tags/contrib/pygmentize.py | highlight | def highlight(code, lexer, **kwargs):
"""
Returns highlighted code ``div`` tag from ``HtmlFormatter``
Lexer is guessed by ``lexer`` name
arguments are passed into the formatter
Syntax::
{% highlight [source code] [lexer name] [formatter options] %}
Example::
{... | python | def highlight(code, lexer, **kwargs):
"""
Returns highlighted code ``div`` tag from ``HtmlFormatter``
Lexer is guessed by ``lexer`` name
arguments are passed into the formatter
Syntax::
{% highlight [source code] [lexer name] [formatter options] %}
Example::
{... | [
"def",
"highlight",
"(",
"code",
",",
"lexer",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"highlighter",
"is",
"None",
":",
"return",
"'<pre>%s</pre>'",
"%",
"code",
"return",
"highlighter",
"(",
"code",
"or",
"''",
",",
"get_lexer_by_name",
"(",
"lexer",
... | Returns highlighted code ``div`` tag from ``HtmlFormatter``
Lexer is guessed by ``lexer`` name
arguments are passed into the formatter
Syntax::
{% highlight [source code] [lexer name] [formatter options] %}
Example::
{% highlight 'print "Hello World"' python linenos=t... | [
"Returns",
"highlighted",
"code",
"div",
"tag",
"from",
"HtmlFormatter",
"Lexer",
"is",
"guessed",
"by",
"lexer",
"name",
"arguments",
"are",
"passed",
"into",
"the",
"formatter"
] | train | https://github.com/justquick/django-native-tags/blob/d40b976ee1cb13faeb04f0dedf02933d4274abf2/native_tags/contrib/pygmentize.py#L28-L44 |
justquick/django-native-tags | native_tags/contrib/pygmentize.py | highlight_block | def highlight_block(context, nodelist, lexer, **kwargs):
"""
Code is nodelist ``rendered`` in ``context``
Returns highlighted code ``div`` tag from ``HtmlFormatter``
Lexer is guessed by ``lexer`` name
arguments are passed into the formatter
Syntax::
{% highlight_block [lexer na... | python | def highlight_block(context, nodelist, lexer, **kwargs):
"""
Code is nodelist ``rendered`` in ``context``
Returns highlighted code ``div`` tag from ``HtmlFormatter``
Lexer is guessed by ``lexer`` name
arguments are passed into the formatter
Syntax::
{% highlight_block [lexer na... | [
"def",
"highlight_block",
"(",
"context",
",",
"nodelist",
",",
"lexer",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"highlighter",
"is",
"None",
":",
"return",
"'<pre>%s</pre>'",
"%",
"str",
"(",
"nodelist",
".",
"render",
"(",
"context",
")",
"or",
"''",
... | Code is nodelist ``rendered`` in ``context``
Returns highlighted code ``div`` tag from ``HtmlFormatter``
Lexer is guessed by ``lexer`` name
arguments are passed into the formatter
Syntax::
{% highlight_block [lexer name] [formatter options] %}
... source code ..
... | [
"Code",
"is",
"nodelist",
"rendered",
"in",
"context",
"Returns",
"highlighted",
"code",
"div",
"tag",
"from",
"HtmlFormatter",
"Lexer",
"is",
"guessed",
"by",
"lexer",
"name",
"arguments",
"are",
"passed",
"into",
"the",
"formatter"
] | train | https://github.com/justquick/django-native-tags/blob/d40b976ee1cb13faeb04f0dedf02933d4274abf2/native_tags/contrib/pygmentize.py#L47-L68 |
pytorn/torn | torn/plugins/log.py | warning | def warning(message, code='WARNING'):
"""Display Warning.
Method prints the warning message, message being given
as an input.
Arguments:
message {string} -- The message to be displayed.
"""
now = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
output = now + ' [' + torn.plugins.color... | python | def warning(message, code='WARNING'):
"""Display Warning.
Method prints the warning message, message being given
as an input.
Arguments:
message {string} -- The message to be displayed.
"""
now = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
output = now + ' [' + torn.plugins.color... | [
"def",
"warning",
"(",
"message",
",",
"code",
"=",
"'WARNING'",
")",
":",
"now",
"=",
"datetime",
".",
"now",
"(",
")",
".",
"strftime",
"(",
"'%Y-%m-%d %H:%M:%S'",
")",
"output",
"=",
"now",
"+",
"' ['",
"+",
"torn",
".",
"plugins",
".",
"colors",
... | Display Warning.
Method prints the warning message, message being given
as an input.
Arguments:
message {string} -- The message to be displayed. | [
"Display",
"Warning",
"."
] | train | https://github.com/pytorn/torn/blob/68ba077173a1d22236d570d933dd99a3e3f0040f/torn/plugins/log.py#L10-L24 |
pytorn/torn | torn/plugins/log.py | info | def info(message, code='INFO'):
"""Display Information.
Method prints the information message, message being given
as an input.
Arguments:
message {string} -- The message to be displayed.
"""
now = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
output = now + ' [' + torn.plugins.col... | python | def info(message, code='INFO'):
"""Display Information.
Method prints the information message, message being given
as an input.
Arguments:
message {string} -- The message to be displayed.
"""
now = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
output = now + ' [' + torn.plugins.col... | [
"def",
"info",
"(",
"message",
",",
"code",
"=",
"'INFO'",
")",
":",
"now",
"=",
"datetime",
".",
"now",
"(",
")",
".",
"strftime",
"(",
"'%Y-%m-%d %H:%M:%S'",
")",
"output",
"=",
"now",
"+",
"' ['",
"+",
"torn",
".",
"plugins",
".",
"colors",
".",
... | Display Information.
Method prints the information message, message being given
as an input.
Arguments:
message {string} -- The message to be displayed. | [
"Display",
"Information",
"."
] | train | https://github.com/pytorn/torn/blob/68ba077173a1d22236d570d933dd99a3e3f0040f/torn/plugins/log.py#L26-L40 |
pytorn/torn | torn/plugins/log.py | error | def error(message, code='ERROR'):
"""Display Error.
Method prints the error message, message being given
as an input.
Arguments:
message {string} -- The message to be displayed.
"""
now = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
output = now + ' [' + torn.plugins.colors.FAIL + ... | python | def error(message, code='ERROR'):
"""Display Error.
Method prints the error message, message being given
as an input.
Arguments:
message {string} -- The message to be displayed.
"""
now = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
output = now + ' [' + torn.plugins.colors.FAIL + ... | [
"def",
"error",
"(",
"message",
",",
"code",
"=",
"'ERROR'",
")",
":",
"now",
"=",
"datetime",
".",
"now",
"(",
")",
".",
"strftime",
"(",
"'%Y-%m-%d %H:%M:%S'",
")",
"output",
"=",
"now",
"+",
"' ['",
"+",
"torn",
".",
"plugins",
".",
"colors",
".",... | Display Error.
Method prints the error message, message being given
as an input.
Arguments:
message {string} -- The message to be displayed. | [
"Display",
"Error",
"."
] | train | https://github.com/pytorn/torn/blob/68ba077173a1d22236d570d933dd99a3e3f0040f/torn/plugins/log.py#L42-L55 |
pytorn/torn | torn/api/__init__.py | Controller.render | def render(self, template, **data):
"""Renders the template using Jinja2 with given data arguments.
"""
if(type(template) != str):
raise TypeError("String expected")
env = Environment(
loader=FileSystemLoader(os.getcwd() + '/View'),
autoescap... | python | def render(self, template, **data):
"""Renders the template using Jinja2 with given data arguments.
"""
if(type(template) != str):
raise TypeError("String expected")
env = Environment(
loader=FileSystemLoader(os.getcwd() + '/View'),
autoescap... | [
"def",
"render",
"(",
"self",
",",
"template",
",",
"*",
"*",
"data",
")",
":",
"if",
"(",
"type",
"(",
"template",
")",
"!=",
"str",
")",
":",
"raise",
"TypeError",
"(",
"\"String expected\"",
")",
"env",
"=",
"Environment",
"(",
"loader",
"=",
"Fil... | Renders the template using Jinja2 with given data arguments. | [
"Renders",
"the",
"template",
"using",
"Jinja2",
"with",
"given",
"data",
"arguments",
"."
] | train | https://github.com/pytorn/torn/blob/68ba077173a1d22236d570d933dd99a3e3f0040f/torn/api/__init__.py#L14-L27 |
SetBased/py-etlt | etlt/condition/OrCondition.py | AndCondition.match | def match(self, row):
"""
Returns True if the row matches one or more child conditions. Returns False otherwise.
:param dict row: The row.
:rtype: bool
"""
for condition in self._conditions:
if condition.match(row):
return True
retur... | python | def match(self, row):
"""
Returns True if the row matches one or more child conditions. Returns False otherwise.
:param dict row: The row.
:rtype: bool
"""
for condition in self._conditions:
if condition.match(row):
return True
retur... | [
"def",
"match",
"(",
"self",
",",
"row",
")",
":",
"for",
"condition",
"in",
"self",
".",
"_conditions",
":",
"if",
"condition",
".",
"match",
"(",
"row",
")",
":",
"return",
"True",
"return",
"False"
] | Returns True if the row matches one or more child conditions. Returns False otherwise.
:param dict row: The row.
:rtype: bool | [
"Returns",
"True",
"if",
"the",
"row",
"matches",
"one",
"or",
"more",
"child",
"conditions",
".",
"Returns",
"False",
"otherwise",
"."
] | train | https://github.com/SetBased/py-etlt/blob/1c5b8ea60293c14f54d7845a9fe5c595021f66f2/etlt/condition/OrCondition.py#L17-L29 |
pcdinh/greenclock | greenclock/__init__.py | wait_until | def wait_until(time_label):
'''
Calculates the number of seconds that the process needs to sleep
'''
if time_label == 'next_minute':
gevent.sleep(60 - int(time.time()) % 60)
elif time_label == 'next_hour':
gevent.sleep(3600 - int(time.time()) % 3600)
elif time_label == 'tomorrow... | python | def wait_until(time_label):
'''
Calculates the number of seconds that the process needs to sleep
'''
if time_label == 'next_minute':
gevent.sleep(60 - int(time.time()) % 60)
elif time_label == 'next_hour':
gevent.sleep(3600 - int(time.time()) % 3600)
elif time_label == 'tomorrow... | [
"def",
"wait_until",
"(",
"time_label",
")",
":",
"if",
"time_label",
"==",
"'next_minute'",
":",
"gevent",
".",
"sleep",
"(",
"60",
"-",
"int",
"(",
"time",
".",
"time",
"(",
")",
")",
"%",
"60",
")",
"elif",
"time_label",
"==",
"'next_hour'",
":",
... | Calculates the number of seconds that the process needs to sleep | [
"Calculates",
"the",
"number",
"of",
"seconds",
"that",
"the",
"process",
"needs",
"to",
"sleep"
] | train | https://github.com/pcdinh/greenclock/blob/52df4f5bdfae296e01d253ae7a177c7fc90ba6c5/greenclock/__init__.py#L109-L118 |
pcdinh/greenclock | greenclock/__init__.py | every_hour.next | def next(self):
'''
Never return StopIteration
'''
if self.started is False:
self.started = True
now_ = datetime.now()
if self.hour:
# Fixed hour in a day
# Next run will be the next day
scheduled = now_... | python | def next(self):
'''
Never return StopIteration
'''
if self.started is False:
self.started = True
now_ = datetime.now()
if self.hour:
# Fixed hour in a day
# Next run will be the next day
scheduled = now_... | [
"def",
"next",
"(",
"self",
")",
":",
"if",
"self",
".",
"started",
"is",
"False",
":",
"self",
".",
"started",
"=",
"True",
"now_",
"=",
"datetime",
".",
"now",
"(",
")",
"if",
"self",
".",
"hour",
":",
"# Fixed hour in a day",
"# Next run will be the n... | Never return StopIteration | [
"Never",
"return",
"StopIteration"
] | train | https://github.com/pcdinh/greenclock/blob/52df4f5bdfae296e01d253ae7a177c7fc90ba6c5/greenclock/__init__.py#L77-L107 |
pcdinh/greenclock | greenclock/__init__.py | Scheduler.schedule | def schedule(self, name, timer, func, *args, **kwargs):
'''
ts = Scheduler('my_task')
ts.schedule(every(seconds=10), handle_message, "Every 10 seconds")
ts.schedule(every(seconds=30), fetch_url, url="http://yahoo.com", section="stock_ticker")
ts.run_forever()
'''
... | python | def schedule(self, name, timer, func, *args, **kwargs):
'''
ts = Scheduler('my_task')
ts.schedule(every(seconds=10), handle_message, "Every 10 seconds")
ts.schedule(every(seconds=30), fetch_url, url="http://yahoo.com", section="stock_ticker")
ts.run_forever()
'''
... | [
"def",
"schedule",
"(",
"self",
",",
"name",
",",
"timer",
",",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"tasks",
".",
"append",
"(",
"Task",
"(",
"name",
",",
"func",
",",
"timer",
",",
"*",
"args",
",",
"*",
... | ts = Scheduler('my_task')
ts.schedule(every(seconds=10), handle_message, "Every 10 seconds")
ts.schedule(every(seconds=30), fetch_url, url="http://yahoo.com", section="stock_ticker")
ts.run_forever() | [
"ts",
"=",
"Scheduler",
"(",
"my_task",
")",
"ts",
".",
"schedule",
"(",
"every",
"(",
"seconds",
"=",
"10",
")",
"handle_message",
"Every",
"10",
"seconds",
")",
"ts",
".",
"schedule",
"(",
"every",
"(",
"seconds",
"=",
"30",
")",
"fetch_url",
"url",
... | train | https://github.com/pcdinh/greenclock/blob/52df4f5bdfae296e01d253ae7a177c7fc90ba6c5/greenclock/__init__.py#L142-L151 |
pcdinh/greenclock | greenclock/__init__.py | Scheduler.unschedule | def unschedule(self, task_name):
'''
Removes a task from scheduled jobs but it will not kill running tasks
'''
for greenlet in self.waiting[task_name]:
try:
gevent.kill(greenlet)
except BaseException:
pass | python | def unschedule(self, task_name):
'''
Removes a task from scheduled jobs but it will not kill running tasks
'''
for greenlet in self.waiting[task_name]:
try:
gevent.kill(greenlet)
except BaseException:
pass | [
"def",
"unschedule",
"(",
"self",
",",
"task_name",
")",
":",
"for",
"greenlet",
"in",
"self",
".",
"waiting",
"[",
"task_name",
"]",
":",
"try",
":",
"gevent",
".",
"kill",
"(",
"greenlet",
")",
"except",
"BaseException",
":",
"pass"
] | Removes a task from scheduled jobs but it will not kill running tasks | [
"Removes",
"a",
"task",
"from",
"scheduled",
"jobs",
"but",
"it",
"will",
"not",
"kill",
"running",
"tasks"
] | train | https://github.com/pcdinh/greenclock/blob/52df4f5bdfae296e01d253ae7a177c7fc90ba6c5/greenclock/__init__.py#L153-L161 |
pcdinh/greenclock | greenclock/__init__.py | Scheduler.stop_task | def stop_task(self, task_name):
'''
Stops a running or dead task
'''
for greenlet in self.active[task_name]:
try:
# Do not need to check if greenlet is dead, gevent does it already
gevent.kill(greenlet)
self.active[task_name] = ... | python | def stop_task(self, task_name):
'''
Stops a running or dead task
'''
for greenlet in self.active[task_name]:
try:
# Do not need to check if greenlet is dead, gevent does it already
gevent.kill(greenlet)
self.active[task_name] = ... | [
"def",
"stop_task",
"(",
"self",
",",
"task_name",
")",
":",
"for",
"greenlet",
"in",
"self",
".",
"active",
"[",
"task_name",
"]",
":",
"try",
":",
"# Do not need to check if greenlet is dead, gevent does it already",
"gevent",
".",
"kill",
"(",
"greenlet",
")",
... | Stops a running or dead task | [
"Stops",
"a",
"running",
"or",
"dead",
"task"
] | train | https://github.com/pcdinh/greenclock/blob/52df4f5bdfae296e01d253ae7a177c7fc90ba6c5/greenclock/__init__.py#L163-L173 |
pcdinh/greenclock | greenclock/__init__.py | Scheduler._remove_dead_greenlet | def _remove_dead_greenlet(self, task_name):
'''
Removes dead greenlet or done task from active list
'''
for greenlet in self.active[task_name]:
try:
# Allows active greenlet continue to run
if greenlet.dead:
self.active[task... | python | def _remove_dead_greenlet(self, task_name):
'''
Removes dead greenlet or done task from active list
'''
for greenlet in self.active[task_name]:
try:
# Allows active greenlet continue to run
if greenlet.dead:
self.active[task... | [
"def",
"_remove_dead_greenlet",
"(",
"self",
",",
"task_name",
")",
":",
"for",
"greenlet",
"in",
"self",
".",
"active",
"[",
"task_name",
"]",
":",
"try",
":",
"# Allows active greenlet continue to run",
"if",
"greenlet",
".",
"dead",
":",
"self",
".",
"activ... | Removes dead greenlet or done task from active list | [
"Removes",
"dead",
"greenlet",
"or",
"done",
"task",
"from",
"active",
"list"
] | train | https://github.com/pcdinh/greenclock/blob/52df4f5bdfae296e01d253ae7a177c7fc90ba6c5/greenclock/__init__.py#L175-L185 |
pcdinh/greenclock | greenclock/__init__.py | Scheduler.run | def run(self, task):
'''
Runs a task and re-schedule it
'''
self._remove_dead_greenlet(task.name)
if isinstance(task.timer, types.GeneratorType):
# Starts the task immediately
greenlet_ = gevent.spawn(task.action, *task.args, **task.kwargs)
sel... | python | def run(self, task):
'''
Runs a task and re-schedule it
'''
self._remove_dead_greenlet(task.name)
if isinstance(task.timer, types.GeneratorType):
# Starts the task immediately
greenlet_ = gevent.spawn(task.action, *task.args, **task.kwargs)
sel... | [
"def",
"run",
"(",
"self",
",",
"task",
")",
":",
"self",
".",
"_remove_dead_greenlet",
"(",
"task",
".",
"name",
")",
"if",
"isinstance",
"(",
"task",
".",
"timer",
",",
"types",
".",
"GeneratorType",
")",
":",
"# Starts the task immediately",
"greenlet_",
... | Runs a task and re-schedule it | [
"Runs",
"a",
"task",
"and",
"re",
"-",
"schedule",
"it"
] | train | https://github.com/pcdinh/greenclock/blob/52df4f5bdfae296e01d253ae7a177c7fc90ba6c5/greenclock/__init__.py#L187-L219 |
pcdinh/greenclock | greenclock/__init__.py | Scheduler.run_tasks | def run_tasks(self):
'''
Runs all assigned task in separate green threads. If the task should not be run, schedule it
'''
pool = Pool(len(self.tasks))
for task in self.tasks:
# Launch a green thread to schedule the task
# A task will be managed by 2 green ... | python | def run_tasks(self):
'''
Runs all assigned task in separate green threads. If the task should not be run, schedule it
'''
pool = Pool(len(self.tasks))
for task in self.tasks:
# Launch a green thread to schedule the task
# A task will be managed by 2 green ... | [
"def",
"run_tasks",
"(",
"self",
")",
":",
"pool",
"=",
"Pool",
"(",
"len",
"(",
"self",
".",
"tasks",
")",
")",
"for",
"task",
"in",
"self",
".",
"tasks",
":",
"# Launch a green thread to schedule the task",
"# A task will be managed by 2 green thread: execution th... | Runs all assigned task in separate green threads. If the task should not be run, schedule it | [
"Runs",
"all",
"assigned",
"task",
"in",
"separate",
"green",
"threads",
".",
"If",
"the",
"task",
"should",
"not",
"be",
"run",
"schedule",
"it"
] | train | https://github.com/pcdinh/greenclock/blob/52df4f5bdfae296e01d253ae7a177c7fc90ba6c5/greenclock/__init__.py#L221-L230 |
pcdinh/greenclock | greenclock/__init__.py | Scheduler.run_forever | def run_forever(self, start_at='once'):
"""
Starts the scheduling engine
@param start_at: 'once' -> start immediately
'next_minute' -> start at the first second of the next minutes
'next_hour' -> start 00:00 (min) next hour
... | python | def run_forever(self, start_at='once'):
"""
Starts the scheduling engine
@param start_at: 'once' -> start immediately
'next_minute' -> start at the first second of the next minutes
'next_hour' -> start 00:00 (min) next hour
... | [
"def",
"run_forever",
"(",
"self",
",",
"start_at",
"=",
"'once'",
")",
":",
"if",
"start_at",
"not",
"in",
"(",
"'once'",
",",
"'next_minute'",
",",
"'next_hour'",
",",
"'tomorrow'",
")",
":",
"raise",
"ValueError",
"(",
"\"start_at parameter must be one of the... | Starts the scheduling engine
@param start_at: 'once' -> start immediately
'next_minute' -> start at the first second of the next minutes
'next_hour' -> start 00:00 (min) next hour
'tomorrow' -> start at 0h tomorrow | [
"Starts",
"the",
"scheduling",
"engine"
] | train | https://github.com/pcdinh/greenclock/blob/52df4f5bdfae296e01d253ae7a177c7fc90ba6c5/greenclock/__init__.py#L232-L255 |
cthoyt/onto2nx | src/onto2nx/aba.py | aba_onto2nx | def aba_onto2nx(str_gr_id=10):
""" Downloads and parse the Allen Brain Atlas ontologies into a network object
More information about Allen Brain Atlas API can be found using following links:
http://help.brain-map.org/display/api/Atlas+Drawings+and+Ontologies#AtlasDrawingsandOntologies-StructuresAndOntologi... | python | def aba_onto2nx(str_gr_id=10):
""" Downloads and parse the Allen Brain Atlas ontologies into a network object
More information about Allen Brain Atlas API can be found using following links:
http://help.brain-map.org/display/api/Atlas+Drawings+and+Ontologies#AtlasDrawingsandOntologies-StructuresAndOntologi... | [
"def",
"aba_onto2nx",
"(",
"str_gr_id",
"=",
"10",
")",
":",
"netw",
"=",
"nx",
".",
"DiGraph",
"(",
")",
"# Downloading and parsing json structure graph",
"r",
"=",
"requests",
".",
"get",
"(",
"url",
"=",
"ABA_API_FORMAT",
".",
"format",
"(",
"str_gr_id",
... | Downloads and parse the Allen Brain Atlas ontologies into a network object
More information about Allen Brain Atlas API can be found using following links:
http://help.brain-map.org/display/api/Atlas+Drawings+and+Ontologies#AtlasDrawingsandOntologies-StructuresAndOntologies
http://help.brain-map.org/displa... | [
"Downloads",
"and",
"parse",
"the",
"Allen",
"Brain",
"Atlas",
"ontologies",
"into",
"a",
"network",
"object"
] | train | https://github.com/cthoyt/onto2nx/blob/94c86e5e187cca67534afe0260097177b66e02c8/src/onto2nx/aba.py#L15-L49 |
henzk/django-productline | django_productline/utils.py | create_or_append_to_zip | def create_or_append_to_zip(file_handle, zip_path, arc_name=None):
"""
Append file_handle to given zip_path with name arc_name if given, else file_handle. zip_path will be created.
:param file_handle: path to file or file-like object
:param zip_path: path to zip archive
:param arc_name: optional fil... | python | def create_or_append_to_zip(file_handle, zip_path, arc_name=None):
"""
Append file_handle to given zip_path with name arc_name if given, else file_handle. zip_path will be created.
:param file_handle: path to file or file-like object
:param zip_path: path to zip archive
:param arc_name: optional fil... | [
"def",
"create_or_append_to_zip",
"(",
"file_handle",
",",
"zip_path",
",",
"arc_name",
"=",
"None",
")",
":",
"with",
"zipfile",
".",
"ZipFile",
"(",
"zip_path",
",",
"'a'",
")",
"as",
"my_zip",
":",
"if",
"arc_name",
":",
"my_zip",
".",
"write",
"(",
"... | Append file_handle to given zip_path with name arc_name if given, else file_handle. zip_path will be created.
:param file_handle: path to file or file-like object
:param zip_path: path to zip archive
:param arc_name: optional filename in archive | [
"Append",
"file_handle",
"to",
"given",
"zip_path",
"with",
"name",
"arc_name",
"if",
"given",
"else",
"file_handle",
".",
"zip_path",
"will",
"be",
"created",
".",
":",
"param",
"file_handle",
":",
"path",
"to",
"file",
"or",
"file",
"-",
"like",
"object",
... | train | https://github.com/henzk/django-productline/blob/24ff156924c1a8c07b99cbb8a1de0a42b8d81f60/django_productline/utils.py#L8-L19 |
henzk/django-productline | django_productline/utils.py | zipdir | def zipdir(src_path, target_path, wrapdir=''):
"""
Zips the pat
:param path: the path to the directory
:param ziph: the zipfile handle
:param wrapdir: wrap all contents in an additional dir
:return:
"""
zipf = zipfile.ZipFile(target_path, 'w', zipfile.ZIP_DEFLATED)
for root, dirs, ... | python | def zipdir(src_path, target_path, wrapdir=''):
"""
Zips the pat
:param path: the path to the directory
:param ziph: the zipfile handle
:param wrapdir: wrap all contents in an additional dir
:return:
"""
zipf = zipfile.ZipFile(target_path, 'w', zipfile.ZIP_DEFLATED)
for root, dirs, ... | [
"def",
"zipdir",
"(",
"src_path",
",",
"target_path",
",",
"wrapdir",
"=",
"''",
")",
":",
"zipf",
"=",
"zipfile",
".",
"ZipFile",
"(",
"target_path",
",",
"'w'",
",",
"zipfile",
".",
"ZIP_DEFLATED",
")",
"for",
"root",
",",
"dirs",
",",
"files",
"in",... | Zips the pat
:param path: the path to the directory
:param ziph: the zipfile handle
:param wrapdir: wrap all contents in an additional dir
:return: | [
"Zips",
"the",
"pat",
":",
"param",
"path",
":",
"the",
"path",
"to",
"the",
"directory",
":",
"param",
"ziph",
":",
"the",
"zipfile",
"handle",
":",
"param",
"wrapdir",
":",
"wrap",
"all",
"contents",
"in",
"an",
"additional",
"dir",
":",
"return",
":... | train | https://github.com/henzk/django-productline/blob/24ff156924c1a8c07b99cbb8a1de0a42b8d81f60/django_productline/utils.py#L22-L41 |
henzk/django-productline | django_productline/utils.py | compare_version | def compare_version(version1, version2):
"""
Compares two versions.
"""
def normalize(v):
return [int(x) for x in re.sub(r'(\.0+)*$','', v).split(".")]
return (normalize(version1) > normalize(version2))-(normalize(version1) < normalize(version2)) | python | def compare_version(version1, version2):
"""
Compares two versions.
"""
def normalize(v):
return [int(x) for x in re.sub(r'(\.0+)*$','', v).split(".")]
return (normalize(version1) > normalize(version2))-(normalize(version1) < normalize(version2)) | [
"def",
"compare_version",
"(",
"version1",
",",
"version2",
")",
":",
"def",
"normalize",
"(",
"v",
")",
":",
"return",
"[",
"int",
"(",
"x",
")",
"for",
"x",
"in",
"re",
".",
"sub",
"(",
"r'(\\.0+)*$'",
",",
"''",
",",
"v",
")",
".",
"split",
"(... | Compares two versions. | [
"Compares",
"two",
"versions",
"."
] | train | https://github.com/henzk/django-productline/blob/24ff156924c1a8c07b99cbb8a1de0a42b8d81f60/django_productline/utils.py#L44-L50 |
seibert-media/Highton | highton/fields/field.py | Field.encode | def encode(self):
"""
Encodes the value of the field and put it in the element
also make the check for nil=true if there is one
:return: returns the encoded element
:rtype: xml.etree.ElementTree.Element
"""
element = ElementTree.Element(self.name)
element... | python | def encode(self):
"""
Encodes the value of the field and put it in the element
also make the check for nil=true if there is one
:return: returns the encoded element
:rtype: xml.etree.ElementTree.Element
"""
element = ElementTree.Element(self.name)
element... | [
"def",
"encode",
"(",
"self",
")",
":",
"element",
"=",
"ElementTree",
".",
"Element",
"(",
"self",
".",
"name",
")",
"element",
"=",
"self",
".",
"_set_nil",
"(",
"element",
",",
"lambda",
"value",
":",
"str",
"(",
"value",
")",
")",
"return",
"elem... | Encodes the value of the field and put it in the element
also make the check for nil=true if there is one
:return: returns the encoded element
:rtype: xml.etree.ElementTree.Element | [
"Encodes",
"the",
"value",
"of",
"the",
"field",
"and",
"put",
"it",
"in",
"the",
"element",
"also",
"make",
"the",
"check",
"for",
"nil",
"=",
"true",
"if",
"there",
"is",
"one"
] | train | https://github.com/seibert-media/Highton/blob/1519e4fb105f62882c2e7bc81065d994649558d8/highton/fields/field.py#L18-L28 |
seibert-media/Highton | highton/fields/field.py | Field._set_nil | def _set_nil(self, element, value_parser):
"""
Method to set an attribute of the element.
If the value of the field is None then set the nil='true' attribute in the element
:param element: the element which needs to be modified
:type element: xml.etree.ElementTree.Element
... | python | def _set_nil(self, element, value_parser):
"""
Method to set an attribute of the element.
If the value of the field is None then set the nil='true' attribute in the element
:param element: the element which needs to be modified
:type element: xml.etree.ElementTree.Element
... | [
"def",
"_set_nil",
"(",
"self",
",",
"element",
",",
"value_parser",
")",
":",
"if",
"self",
".",
"value",
":",
"element",
".",
"text",
"=",
"value_parser",
"(",
"self",
".",
"value",
")",
"else",
":",
"element",
".",
"attrib",
"[",
"'nil'",
"]",
"="... | Method to set an attribute of the element.
If the value of the field is None then set the nil='true' attribute in the element
:param element: the element which needs to be modified
:type element: xml.etree.ElementTree.Element
:param value_parser: the lambda function which changes will b... | [
"Method",
"to",
"set",
"an",
"attribute",
"of",
"the",
"element",
".",
"If",
"the",
"value",
"of",
"the",
"field",
"is",
"None",
"then",
"set",
"the",
"nil",
"=",
"true",
"attribute",
"in",
"the",
"element"
] | train | https://github.com/seibert-media/Highton/blob/1519e4fb105f62882c2e7bc81065d994649558d8/highton/fields/field.py#L41-L57 |
cgearhart/Resound | identify.py | main | def main(input_filename, format):
"""
Calculate the fingerprint hashses of the referenced audio file and save
to disk as a pickle file
"""
# open the file & convert to wav
song_data = AudioSegment.from_file(input_filename, format=format)
song_data = song_data.set_channels(1) # convert to m... | python | def main(input_filename, format):
"""
Calculate the fingerprint hashses of the referenced audio file and save
to disk as a pickle file
"""
# open the file & convert to wav
song_data = AudioSegment.from_file(input_filename, format=format)
song_data = song_data.set_channels(1) # convert to m... | [
"def",
"main",
"(",
"input_filename",
",",
"format",
")",
":",
"# open the file & convert to wav",
"song_data",
"=",
"AudioSegment",
".",
"from_file",
"(",
"input_filename",
",",
"format",
"=",
"format",
")",
"song_data",
"=",
"song_data",
".",
"set_channels",
"("... | Calculate the fingerprint hashses of the referenced audio file and save
to disk as a pickle file | [
"Calculate",
"the",
"fingerprint",
"hashses",
"of",
"the",
"referenced",
"audio",
"file",
"and",
"save",
"to",
"disk",
"as",
"a",
"pickle",
"file"
] | train | https://github.com/cgearhart/Resound/blob/83a15be0ce2dc13003574c6039f8a1ad87734bc2/identify.py#L38-L63 |
petebachant/Nortek-Python | nortek/files.py | DataFile.read_header | def read_header(self):
"""Hardware configuration A505
Head configuration A504
User configuration A500"""
with open(self.filepath, 'rb') as instrumentDataFile:
while True:
sync = instrumentDataFile.read(1)
if not sync:
break
... | python | def read_header(self):
"""Hardware configuration A505
Head configuration A504
User configuration A500"""
with open(self.filepath, 'rb') as instrumentDataFile:
while True:
sync = instrumentDataFile.read(1)
if not sync:
break
... | [
"def",
"read_header",
"(",
"self",
")",
":",
"with",
"open",
"(",
"self",
".",
"filepath",
",",
"'rb'",
")",
"as",
"instrumentDataFile",
":",
"while",
"True",
":",
"sync",
"=",
"instrumentDataFile",
".",
"read",
"(",
"1",
")",
"if",
"not",
"sync",
":",... | Hardware configuration A505
Head configuration A504
User configuration A500 | [
"Hardware",
"configuration",
"A505",
"Head",
"configuration",
"A504",
"User",
"configuration",
"A500"
] | train | https://github.com/petebachant/Nortek-Python/blob/6c979662cf62c11ad5899ccc5e53365c87e5be02/nortek/files.py#L32-L73 |
jkwill87/mapi | mapi/metadata.py | Metadata.format | def format(self, template=None):
""" Substitutes variables within template with that of fields'
"""
pattern = r"(?:<([^<]*?)\$(\w+)([^>]*?)>)"
s = sub(pattern, self._format_repl, template or self.template)
s = self._str_fix_whitespace(s)
return s | python | def format(self, template=None):
""" Substitutes variables within template with that of fields'
"""
pattern = r"(?:<([^<]*?)\$(\w+)([^>]*?)>)"
s = sub(pattern, self._format_repl, template or self.template)
s = self._str_fix_whitespace(s)
return s | [
"def",
"format",
"(",
"self",
",",
"template",
"=",
"None",
")",
":",
"pattern",
"=",
"r\"(?:<([^<]*?)\\$(\\w+)([^>]*?)>)\"",
"s",
"=",
"sub",
"(",
"pattern",
",",
"self",
".",
"_format_repl",
",",
"template",
"or",
"self",
".",
"template",
")",
"s",
"=",
... | Substitutes variables within template with that of fields' | [
"Substitutes",
"variables",
"within",
"template",
"with",
"that",
"of",
"fields"
] | train | https://github.com/jkwill87/mapi/blob/730bf57c12aecaf49e18c15bf2b35af7f554b3cc/mapi/metadata.py#L234-L240 |
klen/django-netauth | netauth/views.py | begin | def begin(request, provider):
"""
Display authentication form. This is also the first step
in registration. The actual login is in social_complete
function below.
"""
# store url to where user will be redirected
request.session['next_url'] = request.GET.get("next") or settings.LO... | python | def begin(request, provider):
"""
Display authentication form. This is also the first step
in registration. The actual login is in social_complete
function below.
"""
# store url to where user will be redirected
request.session['next_url'] = request.GET.get("next") or settings.LO... | [
"def",
"begin",
"(",
"request",
",",
"provider",
")",
":",
"# store url to where user will be redirected",
"request",
".",
"session",
"[",
"'next_url'",
"]",
"=",
"request",
".",
"GET",
".",
"get",
"(",
"\"next\"",
")",
"or",
"settings",
".",
"LOGIN_REDIRECT_URL... | Display authentication form. This is also the first step
in registration. The actual login is in social_complete
function below. | [
"Display",
"authentication",
"form",
".",
"This",
"is",
"also",
"the",
"first",
"step",
"in",
"registration",
".",
"The",
"actual",
"login",
"is",
"in",
"social_complete",
"function",
"below",
"."
] | train | https://github.com/klen/django-netauth/blob/228e4297fda98d5f9df35f86a01f87c6fb05ab1d/netauth/views.py#L16-L27 |
klen/django-netauth | netauth/views.py | complete | def complete(request, provider):
"""
After first step of net authentication, we must validate the response.
If everything is ok, we must do the following:
1. If user is already authenticated:
a. Try to login him again (strange variation but we must take it to account).
... | python | def complete(request, provider):
"""
After first step of net authentication, we must validate the response.
If everything is ok, we must do the following:
1. If user is already authenticated:
a. Try to login him again (strange variation but we must take it to account).
... | [
"def",
"complete",
"(",
"request",
",",
"provider",
")",
":",
"# merge data from POST and GET methods",
"data",
"=",
"request",
".",
"GET",
".",
"copy",
"(",
")",
"data",
".",
"update",
"(",
"request",
".",
"POST",
")",
"# In case of skipping begin step.",
"if",... | After first step of net authentication, we must validate the response.
If everything is ok, we must do the following:
1. If user is already authenticated:
a. Try to login him again (strange variation but we must take it to account).
b. Create new netID record in database.
... | [
"After",
"first",
"step",
"of",
"net",
"authentication",
"we",
"must",
"validate",
"the",
"response",
".",
"If",
"everything",
"is",
"ok",
"we",
"must",
"do",
"the",
"following",
":",
"1",
".",
"If",
"user",
"is",
"already",
"authenticated",
":",
"a",
".... | train | https://github.com/klen/django-netauth/blob/228e4297fda98d5f9df35f86a01f87c6fb05ab1d/netauth/views.py#L31-L70 |
klen/django-netauth | netauth/views.py | extra | def extra(request, provider):
"""
Handle registration of new user with extra data for profile
"""
identity = request.session.get('identity', None)
if not identity:
raise Http404
if request.method == "POST":
form = str_to_class(settings.EXTRA_FORM)(request.POST)
if fo... | python | def extra(request, provider):
"""
Handle registration of new user with extra data for profile
"""
identity = request.session.get('identity', None)
if not identity:
raise Http404
if request.method == "POST":
form = str_to_class(settings.EXTRA_FORM)(request.POST)
if fo... | [
"def",
"extra",
"(",
"request",
",",
"provider",
")",
":",
"identity",
"=",
"request",
".",
"session",
".",
"get",
"(",
"'identity'",
",",
"None",
")",
"if",
"not",
"identity",
":",
"raise",
"Http404",
"if",
"request",
".",
"method",
"==",
"\"POST\"",
... | Handle registration of new user with extra data for profile | [
"Handle",
"registration",
"of",
"new",
"user",
"with",
"extra",
"data",
"for",
"profile"
] | train | https://github.com/klen/django-netauth/blob/228e4297fda98d5f9df35f86a01f87c6fb05ab1d/netauth/views.py#L72-L97 |
rominf/module-wrapper | module_wrapper/__init__.py | getmembers | def getmembers(object, predicate=None):
"""Return all members of an object as (name, value) pairs sorted by name.
Optionally, only return members that satisfy a given predicate."""
if inspect.isclass(object):
mro = (object,) + inspect.getmro(object)
else:
mro = ()
results = []
pr... | python | def getmembers(object, predicate=None):
"""Return all members of an object as (name, value) pairs sorted by name.
Optionally, only return members that satisfy a given predicate."""
if inspect.isclass(object):
mro = (object,) + inspect.getmro(object)
else:
mro = ()
results = []
pr... | [
"def",
"getmembers",
"(",
"object",
",",
"predicate",
"=",
"None",
")",
":",
"if",
"inspect",
".",
"isclass",
"(",
"object",
")",
":",
"mro",
"=",
"(",
"object",
",",
")",
"+",
"inspect",
".",
"getmro",
"(",
"object",
")",
"else",
":",
"mro",
"=",
... | Return all members of an object as (name, value) pairs sorted by name.
Optionally, only return members that satisfy a given predicate. | [
"Return",
"all",
"members",
"of",
"an",
"object",
"as",
"(",
"name",
"value",
")",
"pairs",
"sorted",
"by",
"name",
".",
"Optionally",
"only",
"return",
"members",
"that",
"satisfy",
"a",
"given",
"predicate",
"."
] | train | https://github.com/rominf/module-wrapper/blob/2148f3ca0b04bade017594c99c52b7c3fca945bf/module_wrapper/__init__.py#L43-L87 |
rominf/module-wrapper | module_wrapper/__init__.py | _wrap | def _wrap(obj, wrapper=None, methods_to_add=(), name=None, skip=(), wrap_return_values=False, wrap_filenames=(),
filename=None, wrapped_name_func=None, wrapped=None):
"""
Wrap module, class, function or another variable recursively
:param Any obj: Object to wrap recursively
:param Optional[Ca... | python | def _wrap(obj, wrapper=None, methods_to_add=(), name=None, skip=(), wrap_return_values=False, wrap_filenames=(),
filename=None, wrapped_name_func=None, wrapped=None):
"""
Wrap module, class, function or another variable recursively
:param Any obj: Object to wrap recursively
:param Optional[Ca... | [
"def",
"_wrap",
"(",
"obj",
",",
"wrapper",
"=",
"None",
",",
"methods_to_add",
"=",
"(",
")",
",",
"name",
"=",
"None",
",",
"skip",
"=",
"(",
")",
",",
"wrap_return_values",
"=",
"False",
",",
"wrap_filenames",
"=",
"(",
")",
",",
"filename",
"=",
... | Wrap module, class, function or another variable recursively
:param Any obj: Object to wrap recursively
:param Optional[Callable] wrapper: Wrapper to wrap functions and methods in (accepts function as argument)
:param Collection[Callable] methods_to_add: Container of functions, which accept class as argume... | [
"Wrap",
"module",
"class",
"function",
"or",
"another",
"variable",
"recursively"
] | train | https://github.com/rominf/module-wrapper/blob/2148f3ca0b04bade017594c99c52b7c3fca945bf/module_wrapper/__init__.py#L90-L462 |
rominf/module-wrapper | module_wrapper/__init__.py | wrap | def wrap(obj, wrapper=None, methods_to_add=(), name=None, skip=(), wrap_return_values=False, clear_cache=True):
"""
Wrap module, class, function or another variable recursively
:param Any obj: Object to wrap recursively
:param Optional[Callable] wrapper: Wrapper to wrap functions and methods in (accept... | python | def wrap(obj, wrapper=None, methods_to_add=(), name=None, skip=(), wrap_return_values=False, clear_cache=True):
"""
Wrap module, class, function or another variable recursively
:param Any obj: Object to wrap recursively
:param Optional[Callable] wrapper: Wrapper to wrap functions and methods in (accept... | [
"def",
"wrap",
"(",
"obj",
",",
"wrapper",
"=",
"None",
",",
"methods_to_add",
"=",
"(",
")",
",",
"name",
"=",
"None",
",",
"skip",
"=",
"(",
")",
",",
"wrap_return_values",
"=",
"False",
",",
"clear_cache",
"=",
"True",
")",
":",
"result",
"=",
"... | Wrap module, class, function or another variable recursively
:param Any obj: Object to wrap recursively
:param Optional[Callable] wrapper: Wrapper to wrap functions and methods in (accepts function as argument)
:param Collection[Callable] methods_to_add: Container of functions, which accept class as argume... | [
"Wrap",
"module",
"class",
"function",
"or",
"another",
"variable",
"recursively"
] | train | https://github.com/rominf/module-wrapper/blob/2148f3ca0b04bade017594c99c52b7c3fca945bf/module_wrapper/__init__.py#L465-L490 |
erikdejonge/arguments | fallbackdocopt/__init__.py | docopt | def docopt(doc, argv=None, help=True, version=None, options_first=False):
"""Parse `argv` based on command-line interface described in `doc`.
`docopt` creates your command-line interface based on its
description that you pass as `doc`. Such description can contain
--options, <positional-argument>, comm... | python | def docopt(doc, argv=None, help=True, version=None, options_first=False):
"""Parse `argv` based on command-line interface described in `doc`.
`docopt` creates your command-line interface based on its
description that you pass as `doc`. Such description can contain
--options, <positional-argument>, comm... | [
"def",
"docopt",
"(",
"doc",
",",
"argv",
"=",
"None",
",",
"help",
"=",
"True",
",",
"version",
"=",
"None",
",",
"options_first",
"=",
"False",
")",
":",
"if",
"argv",
"is",
"None",
":",
"argv",
"=",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
"D... | Parse `argv` based on command-line interface described in `doc`.
`docopt` creates your command-line interface based on its
description that you pass as `doc`. Such description can contain
--options, <positional-argument>, commands, which could be
[optional], (required), (mutually | exclusive) or repeat... | [
"Parse",
"argv",
"based",
"on",
"command",
"-",
"line",
"interface",
"described",
"in",
"doc",
"."
] | train | https://github.com/erikdejonge/arguments/blob/fc222d3989d459343a81944cabb56854014335ed/fallbackdocopt/__init__.py#L494-L581 |
yatiml/yatiml | yatiml/helpers.py | Node.is_scalar | def is_scalar(self, typ: Type = _Any) -> bool:
"""Returns True iff this represents a scalar node.
If a type is given, checks that the ScalarNode represents this \
type. Type may be `str`, `int`, `float`, `bool`, or `None`.
If no type is given, any ScalarNode will return True.
"... | python | def is_scalar(self, typ: Type = _Any) -> bool:
"""Returns True iff this represents a scalar node.
If a type is given, checks that the ScalarNode represents this \
type. Type may be `str`, `int`, `float`, `bool`, or `None`.
If no type is given, any ScalarNode will return True.
"... | [
"def",
"is_scalar",
"(",
"self",
",",
"typ",
":",
"Type",
"=",
"_Any",
")",
"->",
"bool",
":",
"if",
"isinstance",
"(",
"self",
".",
"yaml_node",
",",
"yaml",
".",
"ScalarNode",
")",
":",
"if",
"typ",
"!=",
"_Any",
"and",
"typ",
"in",
"scalar_type_to... | Returns True iff this represents a scalar node.
If a type is given, checks that the ScalarNode represents this \
type. Type may be `str`, `int`, `float`, `bool`, or `None`.
If no type is given, any ScalarNode will return True. | [
"Returns",
"True",
"iff",
"this",
"represents",
"a",
"scalar",
"node",
"."
] | train | https://github.com/yatiml/yatiml/blob/4f55c058b72388350f0af3076ac3ea9bc1c142b0/yatiml/helpers.py#L50-L67 |
yatiml/yatiml | yatiml/helpers.py | Node.get_value | def get_value(self) -> ScalarType:
"""Returns the value of a Scalar node.
Use is_scalar(type) to check which type the node has.
"""
if self.yaml_node.tag == 'tag:yaml.org,2002:str':
return self.yaml_node.value
if self.yaml_node.tag == 'tag:yaml.org,2002:int':
... | python | def get_value(self) -> ScalarType:
"""Returns the value of a Scalar node.
Use is_scalar(type) to check which type the node has.
"""
if self.yaml_node.tag == 'tag:yaml.org,2002:str':
return self.yaml_node.value
if self.yaml_node.tag == 'tag:yaml.org,2002:int':
... | [
"def",
"get_value",
"(",
"self",
")",
"->",
"ScalarType",
":",
"if",
"self",
".",
"yaml_node",
".",
"tag",
"==",
"'tag:yaml.org,2002:str'",
":",
"return",
"self",
".",
"yaml_node",
".",
"value",
"if",
"self",
".",
"yaml_node",
".",
"tag",
"==",
"'tag:yaml.... | Returns the value of a Scalar node.
Use is_scalar(type) to check which type the node has. | [
"Returns",
"the",
"value",
"of",
"a",
"Scalar",
"node",
"."
] | train | https://github.com/yatiml/yatiml/blob/4f55c058b72388350f0af3076ac3ea9bc1c142b0/yatiml/helpers.py#L78-L94 |
yatiml/yatiml | yatiml/helpers.py | Node.set_value | def set_value(self, value: ScalarType) -> None:
"""Sets the value of the node to a scalar value.
After this, is_scalar(type(value)) will return true.
Args:
value: The value to set this node to, a str, int, float, \
bool, or None.
"""
if isinstanc... | python | def set_value(self, value: ScalarType) -> None:
"""Sets the value of the node to a scalar value.
After this, is_scalar(type(value)) will return true.
Args:
value: The value to set this node to, a str, int, float, \
bool, or None.
"""
if isinstanc... | [
"def",
"set_value",
"(",
"self",
",",
"value",
":",
"ScalarType",
")",
"->",
"None",
":",
"if",
"isinstance",
"(",
"value",
",",
"bool",
")",
":",
"value_str",
"=",
"'true'",
"if",
"value",
"else",
"'false'",
"else",
":",
"value_str",
"=",
"str",
"(",
... | Sets the value of the node to a scalar value.
After this, is_scalar(type(value)) will return true.
Args:
value: The value to set this node to, a str, int, float, \
bool, or None. | [
"Sets",
"the",
"value",
"of",
"the",
"node",
"to",
"a",
"scalar",
"value",
"."
] | train | https://github.com/yatiml/yatiml/blob/4f55c058b72388350f0af3076ac3ea9bc1c142b0/yatiml/helpers.py#L96-L118 |
yatiml/yatiml | yatiml/helpers.py | Node.make_mapping | def make_mapping(self) -> None:
"""Replaces the node with a new, empty mapping.
Note that this will work on the Node object that is passed to \
a yatiml_savorize() or yatiml_sweeten() function, but not on \
any of its attributes or items. If you need to set an attribute \
to a c... | python | def make_mapping(self) -> None:
"""Replaces the node with a new, empty mapping.
Note that this will work on the Node object that is passed to \
a yatiml_savorize() or yatiml_sweeten() function, but not on \
any of its attributes or items. If you need to set an attribute \
to a c... | [
"def",
"make_mapping",
"(",
"self",
")",
"->",
"None",
":",
"start_mark",
"=",
"StreamMark",
"(",
"'generated node'",
",",
"0",
",",
"0",
",",
"0",
")",
"end_mark",
"=",
"StreamMark",
"(",
"'generated node'",
",",
"0",
",",
"0",
",",
"0",
")",
"self",
... | Replaces the node with a new, empty mapping.
Note that this will work on the Node object that is passed to \
a yatiml_savorize() or yatiml_sweeten() function, but not on \
any of its attributes or items. If you need to set an attribute \
to a complex value, build a yaml.Node representin... | [
"Replaces",
"the",
"node",
"with",
"a",
"new",
"empty",
"mapping",
"."
] | train | https://github.com/yatiml/yatiml/blob/4f55c058b72388350f0af3076ac3ea9bc1c142b0/yatiml/helpers.py#L122-L134 |
yatiml/yatiml | yatiml/helpers.py | Node.has_attribute | def has_attribute(self, attribute: str) -> bool:
"""Whether the node has an attribute with the given name.
Use only if is_mapping() returns True.
Args:
attribute: The name of the attribute to check for.
Returns:
True iff the attribute is present.
"""
... | python | def has_attribute(self, attribute: str) -> bool:
"""Whether the node has an attribute with the given name.
Use only if is_mapping() returns True.
Args:
attribute: The name of the attribute to check for.
Returns:
True iff the attribute is present.
"""
... | [
"def",
"has_attribute",
"(",
"self",
",",
"attribute",
":",
"str",
")",
"->",
"bool",
":",
"return",
"any",
"(",
"[",
"key_node",
".",
"value",
"==",
"attribute",
"for",
"key_node",
",",
"_",
"in",
"self",
".",
"yaml_node",
".",
"value",
"]",
")"
] | Whether the node has an attribute with the given name.
Use only if is_mapping() returns True.
Args:
attribute: The name of the attribute to check for.
Returns:
True iff the attribute is present. | [
"Whether",
"the",
"node",
"has",
"an",
"attribute",
"with",
"the",
"given",
"name",
"."
] | train | https://github.com/yatiml/yatiml/blob/4f55c058b72388350f0af3076ac3ea9bc1c142b0/yatiml/helpers.py#L136-L149 |
yatiml/yatiml | yatiml/helpers.py | Node.has_attribute_type | def has_attribute_type(self, attribute: str, typ: Type) -> bool:
"""Whether the given attribute exists and has a compatible type.
Returns true iff the attribute exists and is an instance of \
the given type. Matching between types passed as typ and \
yaml node types is as follows:
... | python | def has_attribute_type(self, attribute: str, typ: Type) -> bool:
"""Whether the given attribute exists and has a compatible type.
Returns true iff the attribute exists and is an instance of \
the given type. Matching between types passed as typ and \
yaml node types is as follows:
... | [
"def",
"has_attribute_type",
"(",
"self",
",",
"attribute",
":",
"str",
",",
"typ",
":",
"Type",
")",
"->",
"bool",
":",
"if",
"not",
"self",
".",
"has_attribute",
"(",
"attribute",
")",
":",
"return",
"False",
"attr_node",
"=",
"self",
".",
"get_attribu... | Whether the given attribute exists and has a compatible type.
Returns true iff the attribute exists and is an instance of \
the given type. Matching between types passed as typ and \
yaml node types is as follows:
+---------+-------------------------------------------+
| typ ... | [
"Whether",
"the",
"given",
"attribute",
"exists",
"and",
"has",
"a",
"compatible",
"type",
"."
] | train | https://github.com/yatiml/yatiml/blob/4f55c058b72388350f0af3076ac3ea9bc1c142b0/yatiml/helpers.py#L151-L196 |
yatiml/yatiml | yatiml/helpers.py | Node.get_attribute | def get_attribute(self, attribute: str) -> 'Node':
"""Returns the node representing the given attribute's value.
Use only if is_mapping() returns true.
Args:
attribute: The name of the attribute to retrieve.
Raises:
KeyError: If the attribute does not exist.
... | python | def get_attribute(self, attribute: str) -> 'Node':
"""Returns the node representing the given attribute's value.
Use only if is_mapping() returns true.
Args:
attribute: The name of the attribute to retrieve.
Raises:
KeyError: If the attribute does not exist.
... | [
"def",
"get_attribute",
"(",
"self",
",",
"attribute",
":",
"str",
")",
"->",
"'Node'",
":",
"matches",
"=",
"[",
"value_node",
"for",
"key_node",
",",
"value_node",
"in",
"self",
".",
"yaml_node",
".",
"value",
"if",
"key_node",
".",
"value",
"==",
"att... | Returns the node representing the given attribute's value.
Use only if is_mapping() returns true.
Args:
attribute: The name of the attribute to retrieve.
Raises:
KeyError: If the attribute does not exist.
Returns:
A node representing the value. | [
"Returns",
"the",
"node",
"representing",
"the",
"given",
"attribute",
"s",
"value",
"."
] | train | https://github.com/yatiml/yatiml/blob/4f55c058b72388350f0af3076ac3ea9bc1c142b0/yatiml/helpers.py#L198-L220 |
yatiml/yatiml | yatiml/helpers.py | Node.set_attribute | def set_attribute(self, attribute: str,
value: Union[ScalarType, yaml.Node]) -> None:
"""Sets the attribute to the given value.
Use only if is_mapping() returns True.
If the attribute does not exist, this adds a new attribute, \
if it does, it will be overwritten.... | python | def set_attribute(self, attribute: str,
value: Union[ScalarType, yaml.Node]) -> None:
"""Sets the attribute to the given value.
Use only if is_mapping() returns True.
If the attribute does not exist, this adds a new attribute, \
if it does, it will be overwritten.... | [
"def",
"set_attribute",
"(",
"self",
",",
"attribute",
":",
"str",
",",
"value",
":",
"Union",
"[",
"ScalarType",
",",
"yaml",
".",
"Node",
"]",
")",
"->",
"None",
":",
"start_mark",
"=",
"StreamMark",
"(",
"'generated node'",
",",
"0",
",",
"0",
",",
... | Sets the attribute to the given value.
Use only if is_mapping() returns True.
If the attribute does not exist, this adds a new attribute, \
if it does, it will be overwritten.
If value is a str, int, float, bool or None, the attribute will \
be set to this value. If you want t... | [
"Sets",
"the",
"attribute",
"to",
"the",
"given",
"value",
"."
] | train | https://github.com/yatiml/yatiml/blob/4f55c058b72388350f0af3076ac3ea9bc1c142b0/yatiml/helpers.py#L222-L269 |
yatiml/yatiml | yatiml/helpers.py | Node.remove_attribute | def remove_attribute(self, attribute: str) -> None:
"""Remove an attribute from the node.
Use only if is_mapping() returns True.
Args:
attribute: The name of the attribute to remove.
"""
attr_index = self.__attr_index(attribute)
if attr_index is not None:
... | python | def remove_attribute(self, attribute: str) -> None:
"""Remove an attribute from the node.
Use only if is_mapping() returns True.
Args:
attribute: The name of the attribute to remove.
"""
attr_index = self.__attr_index(attribute)
if attr_index is not None:
... | [
"def",
"remove_attribute",
"(",
"self",
",",
"attribute",
":",
"str",
")",
"->",
"None",
":",
"attr_index",
"=",
"self",
".",
"__attr_index",
"(",
"attribute",
")",
"if",
"attr_index",
"is",
"not",
"None",
":",
"self",
".",
"yaml_node",
".",
"value",
"."... | Remove an attribute from the node.
Use only if is_mapping() returns True.
Args:
attribute: The name of the attribute to remove. | [
"Remove",
"an",
"attribute",
"from",
"the",
"node",
"."
] | train | https://github.com/yatiml/yatiml/blob/4f55c058b72388350f0af3076ac3ea9bc1c142b0/yatiml/helpers.py#L271-L281 |
yatiml/yatiml | yatiml/helpers.py | Node.rename_attribute | def rename_attribute(self, attribute: str, new_name: str) -> None:
"""Renames an attribute.
Use only if is_mapping() returns true.
If the attribute does not exist, this will do nothing.
Args:
attribute: The (old) name of the attribute to rename.
new_name: The n... | python | def rename_attribute(self, attribute: str, new_name: str) -> None:
"""Renames an attribute.
Use only if is_mapping() returns true.
If the attribute does not exist, this will do nothing.
Args:
attribute: The (old) name of the attribute to rename.
new_name: The n... | [
"def",
"rename_attribute",
"(",
"self",
",",
"attribute",
":",
"str",
",",
"new_name",
":",
"str",
")",
"->",
"None",
":",
"for",
"key_node",
",",
"_",
"in",
"self",
".",
"yaml_node",
".",
"value",
":",
"if",
"key_node",
".",
"value",
"==",
"attribute"... | Renames an attribute.
Use only if is_mapping() returns true.
If the attribute does not exist, this will do nothing.
Args:
attribute: The (old) name of the attribute to rename.
new_name: The new name to rename it to. | [
"Renames",
"an",
"attribute",
"."
] | train | https://github.com/yatiml/yatiml/blob/4f55c058b72388350f0af3076ac3ea9bc1c142b0/yatiml/helpers.py#L283-L297 |
yatiml/yatiml | yatiml/helpers.py | Node.unders_to_dashes_in_keys | def unders_to_dashes_in_keys(self) -> None:
"""Replaces underscores with dashes in key names.
For each attribute in a mapping, this replaces any underscores \
in its keys with dashes. Handy because Python does not \
accept dashes in identifiers, while some YAML-based formats use \
... | python | def unders_to_dashes_in_keys(self) -> None:
"""Replaces underscores with dashes in key names.
For each attribute in a mapping, this replaces any underscores \
in its keys with dashes. Handy because Python does not \
accept dashes in identifiers, while some YAML-based formats use \
... | [
"def",
"unders_to_dashes_in_keys",
"(",
"self",
")",
"->",
"None",
":",
"for",
"key_node",
",",
"_",
"in",
"self",
".",
"yaml_node",
".",
"value",
":",
"key_node",
".",
"value",
"=",
"key_node",
".",
"value",
".",
"replace",
"(",
"'_'",
",",
"'-'",
")"... | Replaces underscores with dashes in key names.
For each attribute in a mapping, this replaces any underscores \
in its keys with dashes. Handy because Python does not \
accept dashes in identifiers, while some YAML-based formats use \
dashes in their keys. | [
"Replaces",
"underscores",
"with",
"dashes",
"in",
"key",
"names",
"."
] | train | https://github.com/yatiml/yatiml/blob/4f55c058b72388350f0af3076ac3ea9bc1c142b0/yatiml/helpers.py#L299-L308 |
yatiml/yatiml | yatiml/helpers.py | Node.dashes_to_unders_in_keys | def dashes_to_unders_in_keys(self) -> None:
"""Replaces dashes with underscores in key names.
For each attribute in a mapping, this replaces any dashes in \
its keys with underscores. Handy because Python does not \
accept dashes in identifiers, while some YAML-based file \
form... | python | def dashes_to_unders_in_keys(self) -> None:
"""Replaces dashes with underscores in key names.
For each attribute in a mapping, this replaces any dashes in \
its keys with underscores. Handy because Python does not \
accept dashes in identifiers, while some YAML-based file \
form... | [
"def",
"dashes_to_unders_in_keys",
"(",
"self",
")",
"->",
"None",
":",
"for",
"key_node",
",",
"_",
"in",
"self",
".",
"yaml_node",
".",
"value",
":",
"key_node",
".",
"value",
"=",
"key_node",
".",
"value",
".",
"replace",
"(",
"'-'",
",",
"'_'",
")"... | Replaces dashes with underscores in key names.
For each attribute in a mapping, this replaces any dashes in \
its keys with underscores. Handy because Python does not \
accept dashes in identifiers, while some YAML-based file \
formats use dashes in their keys. | [
"Replaces",
"dashes",
"with",
"underscores",
"in",
"key",
"names",
"."
] | train | https://github.com/yatiml/yatiml/blob/4f55c058b72388350f0af3076ac3ea9bc1c142b0/yatiml/helpers.py#L310-L319 |
yatiml/yatiml | yatiml/helpers.py | Node.seq_attribute_to_map | def seq_attribute_to_map(self,
attribute: str,
key_attribute: str,
value_attribute: Optional[str] = None,
strict: Optional[bool] = True) -> None:
"""Converts a sequence attribute to a map.
... | python | def seq_attribute_to_map(self,
attribute: str,
key_attribute: str,
value_attribute: Optional[str] = None,
strict: Optional[bool] = True) -> None:
"""Converts a sequence attribute to a map.
... | [
"def",
"seq_attribute_to_map",
"(",
"self",
",",
"attribute",
":",
"str",
",",
"key_attribute",
":",
"str",
",",
"value_attribute",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"strict",
":",
"Optional",
"[",
"bool",
"]",
"=",
"True",
")",
"->",
... | Converts a sequence attribute to a map.
This function takes an attribute of this Node that is \
a sequence of mappings and turns it into a mapping of mappings. \
It assumes that each of the mappings in the original sequence \
has an attribute containing a unique value, which it will use... | [
"Converts",
"a",
"sequence",
"attribute",
"to",
"a",
"map",
"."
] | train | https://github.com/yatiml/yatiml/blob/4f55c058b72388350f0af3076ac3ea9bc1c142b0/yatiml/helpers.py#L321-L425 |
yatiml/yatiml | yatiml/helpers.py | Node.map_attribute_to_seq | def map_attribute_to_seq(self,
attribute: str,
key_attribute: str,
value_attribute: Optional[str] = None) -> None:
"""Converts a mapping attribute to a sequence.
This function takes an attribute of this Node whose va... | python | def map_attribute_to_seq(self,
attribute: str,
key_attribute: str,
value_attribute: Optional[str] = None) -> None:
"""Converts a mapping attribute to a sequence.
This function takes an attribute of this Node whose va... | [
"def",
"map_attribute_to_seq",
"(",
"self",
",",
"attribute",
":",
"str",
",",
"key_attribute",
":",
"str",
",",
"value_attribute",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
")",
"->",
"None",
":",
"if",
"not",
"self",
".",
"has_attribute",
"(",
"at... | Converts a mapping attribute to a sequence.
This function takes an attribute of this Node whose value \
is a mapping or a mapping of mappings and turns it into a \
sequence of mappings. Each entry in the original mapping is \
converted to an entry in the list. If only a key attribute is... | [
"Converts",
"a",
"mapping",
"attribute",
"to",
"a",
"sequence",
"."
] | train | https://github.com/yatiml/yatiml/blob/4f55c058b72388350f0af3076ac3ea9bc1c142b0/yatiml/helpers.py#L427-L525 |
yatiml/yatiml | yatiml/helpers.py | Node.__attr_index | def __attr_index(self, attribute: str) -> Optional[int]:
"""Finds an attribute's index in the yaml_node.value list."""
attr_index = None
for i, (key_node, _) in enumerate(self.yaml_node.value):
if key_node.value == attribute:
attr_index = i
break
... | python | def __attr_index(self, attribute: str) -> Optional[int]:
"""Finds an attribute's index in the yaml_node.value list."""
attr_index = None
for i, (key_node, _) in enumerate(self.yaml_node.value):
if key_node.value == attribute:
attr_index = i
break
... | [
"def",
"__attr_index",
"(",
"self",
",",
"attribute",
":",
"str",
")",
"->",
"Optional",
"[",
"int",
"]",
":",
"attr_index",
"=",
"None",
"for",
"i",
",",
"(",
"key_node",
",",
"_",
")",
"in",
"enumerate",
"(",
"self",
".",
"yaml_node",
".",
"value",... | Finds an attribute's index in the yaml_node.value list. | [
"Finds",
"an",
"attribute",
"s",
"index",
"in",
"the",
"yaml_node",
".",
"value",
"list",
"."
] | train | https://github.com/yatiml/yatiml/blob/4f55c058b72388350f0af3076ac3ea9bc1c142b0/yatiml/helpers.py#L538-L545 |
yatiml/yatiml | yatiml/helpers.py | UnknownNode.require_scalar | def require_scalar(self, *args: Type) -> None:
"""Require the node to be a scalar.
If additional arguments are passed, these are taken as a list \
of valid types; if the node matches one of these, then it is \
accepted.
Example:
# Match either an int or a string
... | python | def require_scalar(self, *args: Type) -> None:
"""Require the node to be a scalar.
If additional arguments are passed, these are taken as a list \
of valid types; if the node matches one of these, then it is \
accepted.
Example:
# Match either an int or a string
... | [
"def",
"require_scalar",
"(",
"self",
",",
"*",
"args",
":",
"Type",
")",
"->",
"None",
":",
"node",
"=",
"Node",
"(",
"self",
".",
"yaml_node",
")",
"if",
"len",
"(",
"args",
")",
"==",
"0",
":",
"if",
"not",
"node",
".",
"is_scalar",
"(",
")",
... | Require the node to be a scalar.
If additional arguments are passed, these are taken as a list \
of valid types; if the node matches one of these, then it is \
accepted.
Example:
# Match either an int or a string
node.require_scalar(int, str)
Arguments:... | [
"Require",
"the",
"node",
"to",
"be",
"a",
"scalar",
"."
] | train | https://github.com/yatiml/yatiml/blob/4f55c058b72388350f0af3076ac3ea9bc1c142b0/yatiml/helpers.py#L573-L598 |
yatiml/yatiml | yatiml/helpers.py | UnknownNode.require_mapping | def require_mapping(self) -> None:
"""Require the node to be a mapping."""
if not isinstance(self.yaml_node, yaml.MappingNode):
raise RecognitionError(('{}{}A mapping is required here').format(
self.yaml_node.start_mark, os.linesep)) | python | def require_mapping(self) -> None:
"""Require the node to be a mapping."""
if not isinstance(self.yaml_node, yaml.MappingNode):
raise RecognitionError(('{}{}A mapping is required here').format(
self.yaml_node.start_mark, os.linesep)) | [
"def",
"require_mapping",
"(",
"self",
")",
"->",
"None",
":",
"if",
"not",
"isinstance",
"(",
"self",
".",
"yaml_node",
",",
"yaml",
".",
"MappingNode",
")",
":",
"raise",
"RecognitionError",
"(",
"(",
"'{}{}A mapping is required here'",
")",
".",
"format",
... | Require the node to be a mapping. | [
"Require",
"the",
"node",
"to",
"be",
"a",
"mapping",
"."
] | train | https://github.com/yatiml/yatiml/blob/4f55c058b72388350f0af3076ac3ea9bc1c142b0/yatiml/helpers.py#L600-L604 |
yatiml/yatiml | yatiml/helpers.py | UnknownNode.require_sequence | def require_sequence(self) -> None:
"""Require the node to be a sequence."""
if not isinstance(self.yaml_node, yaml.SequenceNode):
raise RecognitionError(('{}{}A sequence is required here').format(
self.yaml_node.start_mark, os.linesep)) | python | def require_sequence(self) -> None:
"""Require the node to be a sequence."""
if not isinstance(self.yaml_node, yaml.SequenceNode):
raise RecognitionError(('{}{}A sequence is required here').format(
self.yaml_node.start_mark, os.linesep)) | [
"def",
"require_sequence",
"(",
"self",
")",
"->",
"None",
":",
"if",
"not",
"isinstance",
"(",
"self",
".",
"yaml_node",
",",
"yaml",
".",
"SequenceNode",
")",
":",
"raise",
"RecognitionError",
"(",
"(",
"'{}{}A sequence is required here'",
")",
".",
"format"... | Require the node to be a sequence. | [
"Require",
"the",
"node",
"to",
"be",
"a",
"sequence",
"."
] | train | https://github.com/yatiml/yatiml/blob/4f55c058b72388350f0af3076ac3ea9bc1c142b0/yatiml/helpers.py#L606-L610 |
yatiml/yatiml | yatiml/helpers.py | UnknownNode.require_attribute | def require_attribute(self, attribute: str, typ: Type = _Any) -> None:
"""Require an attribute on the node to exist.
If `typ` is given, the attribute must have this type.
Args:
attribute: The name of the attribute / mapping key.
typ: The type the attribute must have.
... | python | def require_attribute(self, attribute: str, typ: Type = _Any) -> None:
"""Require an attribute on the node to exist.
If `typ` is given, the attribute must have this type.
Args:
attribute: The name of the attribute / mapping key.
typ: The type the attribute must have.
... | [
"def",
"require_attribute",
"(",
"self",
",",
"attribute",
":",
"str",
",",
"typ",
":",
"Type",
"=",
"_Any",
")",
"->",
"None",
":",
"attr_nodes",
"=",
"[",
"value_node",
"for",
"key_node",
",",
"value_node",
"in",
"self",
".",
"yaml_node",
".",
"value",... | Require an attribute on the node to exist.
If `typ` is given, the attribute must have this type.
Args:
attribute: The name of the attribute / mapping key.
typ: The type the attribute must have. | [
"Require",
"an",
"attribute",
"on",
"the",
"node",
"to",
"exist",
"."
] | train | https://github.com/yatiml/yatiml/blob/4f55c058b72388350f0af3076ac3ea9bc1c142b0/yatiml/helpers.py#L612-L635 |
yatiml/yatiml | yatiml/helpers.py | UnknownNode.require_attribute_value | def require_attribute_value(
self, attribute: str,
value: Union[int, str, float, bool, None]) -> None:
"""Require an attribute on the node to have a particular value.
This requires the attribute to exist, and to have the given value \
and corresponding type. Handy for in... | python | def require_attribute_value(
self, attribute: str,
value: Union[int, str, float, bool, None]) -> None:
"""Require an attribute on the node to have a particular value.
This requires the attribute to exist, and to have the given value \
and corresponding type. Handy for in... | [
"def",
"require_attribute_value",
"(",
"self",
",",
"attribute",
":",
"str",
",",
"value",
":",
"Union",
"[",
"int",
",",
"str",
",",
"float",
",",
"bool",
",",
"None",
"]",
")",
"->",
"None",
":",
"found",
"=",
"False",
"for",
"key_node",
",",
"valu... | Require an attribute on the node to have a particular value.
This requires the attribute to exist, and to have the given value \
and corresponding type. Handy for in your yatiml_recognize() \
function.
Args:
attribute: The name of the attribute / mapping key.
va... | [
"Require",
"an",
"attribute",
"on",
"the",
"node",
"to",
"have",
"a",
"particular",
"value",
"."
] | train | https://github.com/yatiml/yatiml/blob/4f55c058b72388350f0af3076ac3ea9bc1c142b0/yatiml/helpers.py#L637-L677 |
ionelmc/python-cogen | cogen/core/proactors/epoll_impl.py | EpollProactor.run | def run(self, timeout = 0):
"""
Run a proactor loop and return new socket events. Timeout is a timedelta
object, 0 if active coros or None.
epoll timeout param is a integer number of miliseconds (seconds/1000).
"""
ptimeout = int(timeout.microseconds/1000+timeout.... | python | def run(self, timeout = 0):
"""
Run a proactor loop and return new socket events. Timeout is a timedelta
object, 0 if active coros or None.
epoll timeout param is a integer number of miliseconds (seconds/1000).
"""
ptimeout = int(timeout.microseconds/1000+timeout.... | [
"def",
"run",
"(",
"self",
",",
"timeout",
"=",
"0",
")",
":",
"ptimeout",
"=",
"int",
"(",
"timeout",
".",
"microseconds",
"/",
"1000",
"+",
"timeout",
".",
"seconds",
"*",
"1000",
"if",
"timeout",
"else",
"(",
"self",
".",
"m_resolution",
"if",
"ti... | Run a proactor loop and return new socket events. Timeout is a timedelta
object, 0 if active coros or None.
epoll timeout param is a integer number of miliseconds (seconds/1000). | [
"Run",
"a",
"proactor",
"loop",
"and",
"return",
"new",
"socket",
"events",
".",
"Timeout",
"is",
"a",
"timedelta",
"object",
"0",
"if",
"active",
"coros",
"or",
"None",
".",
"epoll",
"timeout",
"param",
"is",
"a",
"integer",
"number",
"of",
"miliseconds",... | train | https://github.com/ionelmc/python-cogen/blob/83b0edb88425eba6e5bfda9f1dcd34642517e2a8/cogen/core/proactors/epoll_impl.py#L49-L83 |
inveniosoftware/invenio-cache | invenio_cache/ext.py | _callback_factory | def _callback_factory(callback_imp):
"""Factory for creating a is authenticated callback."""
if callback_imp is None:
try:
pkg_resources.get_distribution('flask-login')
from flask_login import current_user
return lambda: current_user.is_authenticated
except pk... | python | def _callback_factory(callback_imp):
"""Factory for creating a is authenticated callback."""
if callback_imp is None:
try:
pkg_resources.get_distribution('flask-login')
from flask_login import current_user
return lambda: current_user.is_authenticated
except pk... | [
"def",
"_callback_factory",
"(",
"callback_imp",
")",
":",
"if",
"callback_imp",
"is",
"None",
":",
"try",
":",
"pkg_resources",
".",
"get_distribution",
"(",
"'flask-login'",
")",
"from",
"flask_login",
"import",
"current_user",
"return",
"lambda",
":",
"current_... | Factory for creating a is authenticated callback. | [
"Factory",
"for",
"creating",
"a",
"is",
"authenticated",
"callback",
"."
] | train | https://github.com/inveniosoftware/invenio-cache/blob/2f0e1c8f9b1cf2b2dfb338d82b77f6287a367a74/invenio_cache/ext.py#L44-L56 |
inveniosoftware/invenio-cache | invenio_cache/ext.py | InvenioCache.init_app | def init_app(self, app):
"""Flask application initialization."""
self.init_config(app)
self.cache = Cache(app)
self.is_authenticated_callback = _callback_factory(
app.config['CACHE_IS_AUTHENTICATED_CALLBACK'])
app.extensions['invenio-cache'] = self | python | def init_app(self, app):
"""Flask application initialization."""
self.init_config(app)
self.cache = Cache(app)
self.is_authenticated_callback = _callback_factory(
app.config['CACHE_IS_AUTHENTICATED_CALLBACK'])
app.extensions['invenio-cache'] = self | [
"def",
"init_app",
"(",
"self",
",",
"app",
")",
":",
"self",
".",
"init_config",
"(",
"app",
")",
"self",
".",
"cache",
"=",
"Cache",
"(",
"app",
")",
"self",
".",
"is_authenticated_callback",
"=",
"_callback_factory",
"(",
"app",
".",
"config",
"[",
... | Flask application initialization. | [
"Flask",
"application",
"initialization",
"."
] | train | https://github.com/inveniosoftware/invenio-cache/blob/2f0e1c8f9b1cf2b2dfb338d82b77f6287a367a74/invenio_cache/ext.py#L29-L35 |
ibm-watson-data-lab/ibmseti | ibmseti/features.py | difference | def difference(arr, n=1, axis=0, **kwargs):
'''
Assuming that `arr` is a 2D spectrogram returned by
ibmseti.dsp.raw_to_spectrogram(data), this function
uses the Numpy.diff function to calculate the nth
difference along either time or frequency.
If axis = 0 and n=1, then the first difference is taken
betw... | python | def difference(arr, n=1, axis=0, **kwargs):
'''
Assuming that `arr` is a 2D spectrogram returned by
ibmseti.dsp.raw_to_spectrogram(data), this function
uses the Numpy.diff function to calculate the nth
difference along either time or frequency.
If axis = 0 and n=1, then the first difference is taken
betw... | [
"def",
"difference",
"(",
"arr",
",",
"n",
"=",
"1",
",",
"axis",
"=",
"0",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"np",
".",
"diff",
"(",
"arr",
",",
"n",
"=",
"n",
",",
"axis",
"=",
"axis",
",",
"*",
"*",
"kwargs",
")"
] | Assuming that `arr` is a 2D spectrogram returned by
ibmseti.dsp.raw_to_spectrogram(data), this function
uses the Numpy.diff function to calculate the nth
difference along either time or frequency.
If axis = 0 and n=1, then the first difference is taken
between subsequent time samples
If axis = 1 and n=1, ... | [
"Assuming",
"that",
"arr",
"is",
"a",
"2D",
"spectrogram",
"returned",
"by",
"ibmseti",
".",
"dsp",
".",
"raw_to_spectrogram",
"(",
"data",
")",
"this",
"function",
"uses",
"the",
"Numpy",
".",
"diff",
"function",
"to",
"calculate",
"the",
"nth",
"difference... | train | https://github.com/ibm-watson-data-lab/ibmseti/blob/3361bc0adb4770dc7a554ed7cda292503892acee/ibmseti/features.py#L29-L60 |
ibm-watson-data-lab/ibmseti | ibmseti/features.py | projection | def projection(arr, axis=0, **kwargs):
'''
Assuming that `arr` is a 2D spectrogram returned by
ibmseti.dsp.raw_to_spectrogram(data), where each row
of the `arr` is a power spectrum at a particular time,
this function uses the numpy.sum function to project the
data onto the time or frequency axis into a 1D a... | python | def projection(arr, axis=0, **kwargs):
'''
Assuming that `arr` is a 2D spectrogram returned by
ibmseti.dsp.raw_to_spectrogram(data), where each row
of the `arr` is a power spectrum at a particular time,
this function uses the numpy.sum function to project the
data onto the time or frequency axis into a 1D a... | [
"def",
"projection",
"(",
"arr",
",",
"axis",
"=",
"0",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"np",
".",
"sum",
"(",
"arr",
",",
"axis",
"=",
"axis",
",",
"*",
"*",
"kwargs",
")"
] | Assuming that `arr` is a 2D spectrogram returned by
ibmseti.dsp.raw_to_spectrogram(data), where each row
of the `arr` is a power spectrum at a particular time,
this function uses the numpy.sum function to project the
data onto the time or frequency axis into a 1D array.
If axis = 0, then the projection is on... | [
"Assuming",
"that",
"arr",
"is",
"a",
"2D",
"spectrogram",
"returned",
"by",
"ibmseti",
".",
"dsp",
".",
"raw_to_spectrogram",
"(",
"data",
")",
"where",
"each",
"row",
"of",
"the",
"arr",
"is",
"a",
"power",
"spectrum",
"at",
"a",
"particular",
"time",
... | train | https://github.com/ibm-watson-data-lab/ibmseti/blob/3361bc0adb4770dc7a554ed7cda292503892acee/ibmseti/features.py#L63-L95 |
ibm-watson-data-lab/ibmseti | ibmseti/features.py | moment | def moment(arr, moment=1, axis=0, **kwargs):
'''
Uses the scipy.stats.moment to calculate the Nth central
moment about the mean.
If `arr` is a 2D spectrogram returned by
ibmseti.dsp.raw_to_spectrogram(data), where each row
of the `arr` is a power spectrum at a particular time,
this function, then the Nth... | python | def moment(arr, moment=1, axis=0, **kwargs):
'''
Uses the scipy.stats.moment to calculate the Nth central
moment about the mean.
If `arr` is a 2D spectrogram returned by
ibmseti.dsp.raw_to_spectrogram(data), where each row
of the `arr` is a power spectrum at a particular time,
this function, then the Nth... | [
"def",
"moment",
"(",
"arr",
",",
"moment",
"=",
"1",
",",
"axis",
"=",
"0",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"scipy",
".",
"stats",
".",
"moment",
"(",
"arr",
",",
"moment",
"=",
"moment",
",",
"axis",
"=",
"axis",
",",
"*",
"*",
... | Uses the scipy.stats.moment to calculate the Nth central
moment about the mean.
If `arr` is a 2D spectrogram returned by
ibmseti.dsp.raw_to_spectrogram(data), where each row
of the `arr` is a power spectrum at a particular time,
this function, then the Nth moment along each axis
will be computed.
If axi... | [
"Uses",
"the",
"scipy",
".",
"stats",
".",
"moment",
"to",
"calculate",
"the",
"Nth",
"central",
"moment",
"about",
"the",
"mean",
"."
] | train | https://github.com/ibm-watson-data-lab/ibmseti/blob/3361bc0adb4770dc7a554ed7cda292503892acee/ibmseti/features.py#L98-L135 |
ibm-watson-data-lab/ibmseti | ibmseti/features.py | first_order_gradient | def first_order_gradient(arr, axis=0):
'''
Returns the gradient of arr along a particular axis using
the first order forward-difference.
Additionally, the result is padded with 0 so that the
returned array is the same shape as in input array.
'''
grad_arr = difference(arr, n=1, axis=axis)
return np.inse... | python | def first_order_gradient(arr, axis=0):
'''
Returns the gradient of arr along a particular axis using
the first order forward-difference.
Additionally, the result is padded with 0 so that the
returned array is the same shape as in input array.
'''
grad_arr = difference(arr, n=1, axis=axis)
return np.inse... | [
"def",
"first_order_gradient",
"(",
"arr",
",",
"axis",
"=",
"0",
")",
":",
"grad_arr",
"=",
"difference",
"(",
"arr",
",",
"n",
"=",
"1",
",",
"axis",
"=",
"axis",
")",
"return",
"np",
".",
"insert",
"(",
"grad_arr",
",",
"grad_arr",
".",
"shape",
... | Returns the gradient of arr along a particular axis using
the first order forward-difference.
Additionally, the result is padded with 0 so that the
returned array is the same shape as in input array. | [
"Returns",
"the",
"gradient",
"of",
"arr",
"along",
"a",
"particular",
"axis",
"using",
"the",
"first",
"order",
"forward",
"-",
"difference",
".",
"Additionally",
"the",
"result",
"is",
"padded",
"with",
"0",
"so",
"that",
"the",
"returned",
"array",
"is",
... | train | https://github.com/ibm-watson-data-lab/ibmseti/blob/3361bc0adb4770dc7a554ed7cda292503892acee/ibmseti/features.py#L138-L146 |
ibm-watson-data-lab/ibmseti | ibmseti/features.py | total_variation | def total_variation(arr):
'''
If arr is a 2D array (N X M), assumes that arr is a spectrogram with time along axis=0.
Calculates the 1D total variation in time for each frequency and returns an array
of size M.
If arr is a 1D array, calculates total variation and returns a scalar.
Sum ( Abs(arr_i+1,j - ... | python | def total_variation(arr):
'''
If arr is a 2D array (N X M), assumes that arr is a spectrogram with time along axis=0.
Calculates the 1D total variation in time for each frequency and returns an array
of size M.
If arr is a 1D array, calculates total variation and returns a scalar.
Sum ( Abs(arr_i+1,j - ... | [
"def",
"total_variation",
"(",
"arr",
")",
":",
"return",
"np",
".",
"sum",
"(",
"np",
".",
"abs",
"(",
"np",
".",
"diff",
"(",
"arr",
",",
"axis",
"=",
"0",
")",
")",
",",
"axis",
"=",
"0",
")"
] | If arr is a 2D array (N X M), assumes that arr is a spectrogram with time along axis=0.
Calculates the 1D total variation in time for each frequency and returns an array
of size M.
If arr is a 1D array, calculates total variation and returns a scalar.
Sum ( Abs(arr_i+1,j - arr_ij) )
If arr is a 2D array,... | [
"If",
"arr",
"is",
"a",
"2D",
"array",
"(",
"N",
"X",
"M",
")",
"assumes",
"that",
"arr",
"is",
"a",
"spectrogram",
"with",
"time",
"along",
"axis",
"=",
"0",
"."
] | train | https://github.com/ibm-watson-data-lab/ibmseti/blob/3361bc0adb4770dc7a554ed7cda292503892acee/ibmseti/features.py#L149-L163 |
ibm-watson-data-lab/ibmseti | ibmseti/features.py | maximum_variation | def maximum_variation(arr):
'''
return np.max(arr, axis=0) - np.min(arr, axis=0)
If `arr` is a 1D array, a scalar is returned.
If `arr` is a 2D array (N x M), an array of length M is returned.
'''
return np.max(arr, axis=0) - np.min(arr, axis=0) | python | def maximum_variation(arr):
'''
return np.max(arr, axis=0) - np.min(arr, axis=0)
If `arr` is a 1D array, a scalar is returned.
If `arr` is a 2D array (N x M), an array of length M is returned.
'''
return np.max(arr, axis=0) - np.min(arr, axis=0) | [
"def",
"maximum_variation",
"(",
"arr",
")",
":",
"return",
"np",
".",
"max",
"(",
"arr",
",",
"axis",
"=",
"0",
")",
"-",
"np",
".",
"min",
"(",
"arr",
",",
"axis",
"=",
"0",
")"
] | return np.max(arr, axis=0) - np.min(arr, axis=0)
If `arr` is a 1D array, a scalar is returned.
If `arr` is a 2D array (N x M), an array of length M is returned. | [
"return",
"np",
".",
"max",
"(",
"arr",
"axis",
"=",
"0",
")",
"-",
"np",
".",
"min",
"(",
"arr",
"axis",
"=",
"0",
")"
] | train | https://github.com/ibm-watson-data-lab/ibmseti/blob/3361bc0adb4770dc7a554ed7cda292503892acee/ibmseti/features.py#L166-L174 |
ibm-watson-data-lab/ibmseti | ibmseti/features.py | entropy | def entropy(p, w):
'''
Computes the entropy for a discrete probability distribution function, as
represented by a histogram, `p`, with bin sizes `w`,
h_p = Sum -1 * p_i * ln(p_i / w_i)
Also computes the maximum allowed entropy for a histogram with bin sizes `w`.
h_max = ln( Sum w_i )
and returns bo... | python | def entropy(p, w):
'''
Computes the entropy for a discrete probability distribution function, as
represented by a histogram, `p`, with bin sizes `w`,
h_p = Sum -1 * p_i * ln(p_i / w_i)
Also computes the maximum allowed entropy for a histogram with bin sizes `w`.
h_max = ln( Sum w_i )
and returns bo... | [
"def",
"entropy",
"(",
"p",
",",
"w",
")",
":",
"if",
"w",
"is",
"None",
":",
"w",
"=",
"np",
".",
"ones",
"(",
"len",
"(",
"p",
")",
")",
"h_p",
"=",
"np",
".",
"sum",
"(",
"[",
"-",
"x",
"[",
"0",
"]",
"*",
"math",
".",
"log",
"(",
... | Computes the entropy for a discrete probability distribution function, as
represented by a histogram, `p`, with bin sizes `w`,
h_p = Sum -1 * p_i * ln(p_i / w_i)
Also computes the maximum allowed entropy for a histogram with bin sizes `w`.
h_max = ln( Sum w_i )
and returns both as a tuple (h_p , h_max ... | [
"Computes",
"the",
"entropy",
"for",
"a",
"discrete",
"probability",
"distribution",
"function",
"as",
"represented",
"by",
"a",
"histogram",
"p",
"with",
"bin",
"sizes",
"w"
] | train | https://github.com/ibm-watson-data-lab/ibmseti/blob/3361bc0adb4770dc7a554ed7cda292503892acee/ibmseti/features.py#L194-L323 |
henzk/django-productline | django_productline/features/staticfiles/urls.py | refine_get_urls | def refine_get_urls(original):
"""
serve static files (and media files also)
in production the webserver should serve requested
static files itself and never let requests to /static/*
and /media/* get to the django application.
"""
def get_urls():
from django.conf.urls import url
... | python | def refine_get_urls(original):
"""
serve static files (and media files also)
in production the webserver should serve requested
static files itself and never let requests to /static/*
and /media/* get to the django application.
"""
def get_urls():
from django.conf.urls import url
... | [
"def",
"refine_get_urls",
"(",
"original",
")",
":",
"def",
"get_urls",
"(",
")",
":",
"from",
"django",
".",
"conf",
".",
"urls",
"import",
"url",
"from",
"django",
".",
"conf",
"import",
"settings",
"from",
"django",
".",
"contrib",
".",
"staticfiles",
... | serve static files (and media files also)
in production the webserver should serve requested
static files itself and never let requests to /static/*
and /media/* get to the django application. | [
"serve",
"static",
"files",
"(",
"and",
"media",
"files",
"also",
")"
] | train | https://github.com/henzk/django-productline/blob/24ff156924c1a8c07b99cbb8a1de0a42b8d81f60/django_productline/features/staticfiles/urls.py#L4-L26 |
cthoyt/onto2nx | src/onto2nx/utils.py | download | def download(url):
"""Uses requests to download an URL, maybe from a file"""
session = requests.Session()
session.mount('file://', FileAdapter())
try:
res = session.get(url)
except requests.exceptions.ConnectionError as e:
raise e
res.raise_for_status()
return res | python | def download(url):
"""Uses requests to download an URL, maybe from a file"""
session = requests.Session()
session.mount('file://', FileAdapter())
try:
res = session.get(url)
except requests.exceptions.ConnectionError as e:
raise e
res.raise_for_status()
return res | [
"def",
"download",
"(",
"url",
")",
":",
"session",
"=",
"requests",
".",
"Session",
"(",
")",
"session",
".",
"mount",
"(",
"'file://'",
",",
"FileAdapter",
"(",
")",
")",
"try",
":",
"res",
"=",
"session",
".",
"get",
"(",
"url",
")",
"except",
"... | Uses requests to download an URL, maybe from a file | [
"Uses",
"requests",
"to",
"download",
"an",
"URL",
"maybe",
"from",
"a",
"file"
] | train | https://github.com/cthoyt/onto2nx/blob/94c86e5e187cca67534afe0260097177b66e02c8/src/onto2nx/utils.py#L11-L23 |
cthoyt/onto2nx | src/onto2nx/utils.py | get_uri_name | def get_uri_name(url):
"""Gets the file name from the end of the URL. Only useful for PyBEL's testing though since it looks specifically
if the file is from the weird owncloud resources distributed by Fraunhofer"""
url_parsed = urlparse(url)
url_parts = url_parsed.path.split('/')
log.info('url par... | python | def get_uri_name(url):
"""Gets the file name from the end of the URL. Only useful for PyBEL's testing though since it looks specifically
if the file is from the weird owncloud resources distributed by Fraunhofer"""
url_parsed = urlparse(url)
url_parts = url_parsed.path.split('/')
log.info('url par... | [
"def",
"get_uri_name",
"(",
"url",
")",
":",
"url_parsed",
"=",
"urlparse",
"(",
"url",
")",
"url_parts",
"=",
"url_parsed",
".",
"path",
".",
"split",
"(",
"'/'",
")",
"log",
".",
"info",
"(",
"'url parts: %s'",
",",
"url_parts",
")",
"return",
"url_par... | Gets the file name from the end of the URL. Only useful for PyBEL's testing though since it looks specifically
if the file is from the weird owncloud resources distributed by Fraunhofer | [
"Gets",
"the",
"file",
"name",
"from",
"the",
"end",
"of",
"the",
"URL",
".",
"Only",
"useful",
"for",
"PyBEL",
"s",
"testing",
"though",
"since",
"it",
"looks",
"specifically",
"if",
"the",
"file",
"is",
"from",
"the",
"weird",
"owncloud",
"resources",
... | train | https://github.com/cthoyt/onto2nx/blob/94c86e5e187cca67534afe0260097177b66e02c8/src/onto2nx/utils.py#L26-L35 |
exa-analytics/exa | exa/util/nbvars.py | numbafy | def numbafy(fn, args, compiler="jit", **nbkws):
"""
Compile a string, sympy expression or symengine expression using numba.
Not all functions are supported by Python's numerical package (numpy). For
difficult cases, valid Python code (as string) may be more suitable than
symbolic expressions coming... | python | def numbafy(fn, args, compiler="jit", **nbkws):
"""
Compile a string, sympy expression or symengine expression using numba.
Not all functions are supported by Python's numerical package (numpy). For
difficult cases, valid Python code (as string) may be more suitable than
symbolic expressions coming... | [
"def",
"numbafy",
"(",
"fn",
",",
"args",
",",
"compiler",
"=",
"\"jit\"",
",",
"*",
"*",
"nbkws",
")",
":",
"kwargs",
"=",
"{",
"}",
"# Numba kwargs to be updated by user",
"if",
"not",
"isinstance",
"(",
"args",
",",
"(",
"tuple",
",",
"list",
")",
"... | Compile a string, sympy expression or symengine expression using numba.
Not all functions are supported by Python's numerical package (numpy). For
difficult cases, valid Python code (as string) may be more suitable than
symbolic expressions coming from sympy, symengine, etc. When compiling
vectorized f... | [
"Compile",
"a",
"string",
"sympy",
"expression",
"or",
"symengine",
"expression",
"using",
"numba",
"."
] | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/util/nbvars.py#L39-L95 |
Maplecroft/Winston | winston/stats.py | summary | def summary(raster, geometry=None, all_touched=False, mean_only=False,
bounds=None, exclude_nodata_value=True):
"""Return ``ST_SummaryStats`` style stats for the given raster.
If ``geometry`` is provided, we mask the raster with the given geometry and
return the stats for the intersection. The ... | python | def summary(raster, geometry=None, all_touched=False, mean_only=False,
bounds=None, exclude_nodata_value=True):
"""Return ``ST_SummaryStats`` style stats for the given raster.
If ``geometry`` is provided, we mask the raster with the given geometry and
return the stats for the intersection. The ... | [
"def",
"summary",
"(",
"raster",
",",
"geometry",
"=",
"None",
",",
"all_touched",
"=",
"False",
",",
"mean_only",
"=",
"False",
",",
"bounds",
"=",
"None",
",",
"exclude_nodata_value",
"=",
"True",
")",
":",
"def",
"no_result",
"(",
"mean_only",
")",
":... | Return ``ST_SummaryStats`` style stats for the given raster.
If ``geometry`` is provided, we mask the raster with the given geometry and
return the stats for the intersection. The parameter can be a GeoJSON-like
object, a WKT string, or a Shapely geometry.
If ``all_touched`` is set, we include every p... | [
"Return",
"ST_SummaryStats",
"style",
"stats",
"for",
"the",
"given",
"raster",
"."
] | train | https://github.com/Maplecroft/Winston/blob/d70394c60d5b56d8b374b4db2240394dfd45cfa8/winston/stats.py#L24-L117 |
klen/django-netauth | netauth/utils.py | parse_template | def parse_template(template_path, **kwargs):
""" Load and render template.
First line of template should contain the subject of email.
Return tuple with subject and content.
"""
template = get_template(template_path)
context = Context(kwargs)
data = template.render(context).strip()
... | python | def parse_template(template_path, **kwargs):
""" Load and render template.
First line of template should contain the subject of email.
Return tuple with subject and content.
"""
template = get_template(template_path)
context = Context(kwargs)
data = template.render(context).strip()
... | [
"def",
"parse_template",
"(",
"template_path",
",",
"*",
"*",
"kwargs",
")",
":",
"template",
"=",
"get_template",
"(",
"template_path",
")",
"context",
"=",
"Context",
"(",
"kwargs",
")",
"data",
"=",
"template",
".",
"render",
"(",
"context",
")",
".",
... | Load and render template.
First line of template should contain the subject of email.
Return tuple with subject and content. | [
"Load",
"and",
"render",
"template",
".",
"First",
"line",
"of",
"template",
"should",
"contain",
"the",
"subject",
"of",
"email",
".",
"Return",
"tuple",
"with",
"subject",
"and",
"content",
"."
] | train | https://github.com/klen/django-netauth/blob/228e4297fda98d5f9df35f86a01f87c6fb05ab1d/netauth/utils.py#L12-L21 |
klen/django-netauth | netauth/utils.py | email_template | def email_template(rcpt, template_path, **kwargs):
""" Load, render and email template.
**kwargs may contain variables for template rendering.
"""
subject, content = parse_template(template_path, **kwargs)
count = send_mail(subject, content, settings.DEFAULT_FROM_EMAIL,
[r... | python | def email_template(rcpt, template_path, **kwargs):
""" Load, render and email template.
**kwargs may contain variables for template rendering.
"""
subject, content = parse_template(template_path, **kwargs)
count = send_mail(subject, content, settings.DEFAULT_FROM_EMAIL,
[r... | [
"def",
"email_template",
"(",
"rcpt",
",",
"template_path",
",",
"*",
"*",
"kwargs",
")",
":",
"subject",
",",
"content",
"=",
"parse_template",
"(",
"template_path",
",",
"*",
"*",
"kwargs",
")",
"count",
"=",
"send_mail",
"(",
"subject",
",",
"content",
... | Load, render and email template.
**kwargs may contain variables for template rendering. | [
"Load",
"render",
"and",
"email",
"template",
".",
"**",
"kwargs",
"may",
"contain",
"variables",
"for",
"template",
"rendering",
"."
] | train | https://github.com/klen/django-netauth/blob/228e4297fda98d5f9df35f86a01f87c6fb05ab1d/netauth/utils.py#L24-L32 |
klen/django-netauth | netauth/utils.py | get_instance_from_path | def get_instance_from_path(path, *args, **kwargs):
""" Return an instance of a class, given the dotted
Python import path (as a string) to the backend class.
If the backend cannot be located (e.g., because no such module
exists, or because the module does not contain a class of the
... | python | def get_instance_from_path(path, *args, **kwargs):
""" Return an instance of a class, given the dotted
Python import path (as a string) to the backend class.
If the backend cannot be located (e.g., because no such module
exists, or because the module does not contain a class of the
... | [
"def",
"get_instance_from_path",
"(",
"path",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"i",
"=",
"path",
".",
"rfind",
"(",
"'.'",
")",
"module",
",",
"attr",
"=",
"path",
"[",
":",
"i",
"]",
",",
"path",
"[",
"i",
"+",
"1",
":",
... | Return an instance of a class, given the dotted
Python import path (as a string) to the backend class.
If the backend cannot be located (e.g., because no such module
exists, or because the module does not contain a class of the
appropriate name), ``django.core.exceptions.ImproperlyConfi... | [
"Return",
"an",
"instance",
"of",
"a",
"class",
"given",
"the",
"dotted",
"Python",
"import",
"path",
"(",
"as",
"a",
"string",
")",
"to",
"the",
"backend",
"class",
"."
] | train | https://github.com/klen/django-netauth/blob/228e4297fda98d5f9df35f86a01f87c6fb05ab1d/netauth/utils.py#L46-L66 |
justquick/django-native-tags | native_tags/contrib/regex.py | substitute | def substitute(search, replace, text):
'Regex substitution function. Replaces regex ``search`` with ``replace`` in ``text``'
return re.sub(re.compile(str(search)), replace, text) | python | def substitute(search, replace, text):
'Regex substitution function. Replaces regex ``search`` with ``replace`` in ``text``'
return re.sub(re.compile(str(search)), replace, text) | [
"def",
"substitute",
"(",
"search",
",",
"replace",
",",
"text",
")",
":",
"return",
"re",
".",
"sub",
"(",
"re",
".",
"compile",
"(",
"str",
"(",
"search",
")",
")",
",",
"replace",
",",
"text",
")"
] | Regex substitution function. Replaces regex ``search`` with ``replace`` in ``text`` | [
"Regex",
"substitution",
"function",
".",
"Replaces",
"regex",
"search",
"with",
"replace",
"in",
"text"
] | train | https://github.com/justquick/django-native-tags/blob/d40b976ee1cb13faeb04f0dedf02933d4274abf2/native_tags/contrib/regex.py#L12-L14 |
justquick/django-native-tags | native_tags/contrib/regex.py | search | def search(pattern, text):
'Regex pattern search. Returns match if ``pattern`` is found in ``text``'
return re.compile(str(pattern)).search(str(text)) | python | def search(pattern, text):
'Regex pattern search. Returns match if ``pattern`` is found in ``text``'
return re.compile(str(pattern)).search(str(text)) | [
"def",
"search",
"(",
"pattern",
",",
"text",
")",
":",
"return",
"re",
".",
"compile",
"(",
"str",
"(",
"pattern",
")",
")",
".",
"search",
"(",
"str",
"(",
"text",
")",
")"
] | Regex pattern search. Returns match if ``pattern`` is found in ``text`` | [
"Regex",
"pattern",
"search",
".",
"Returns",
"match",
"if",
"pattern",
"is",
"found",
"in",
"text"
] | train | https://github.com/justquick/django-native-tags/blob/d40b976ee1cb13faeb04f0dedf02933d4274abf2/native_tags/contrib/regex.py#L18-L20 |
stevepeak/debris | debris/object.py | Object.get | def get(cls, route, args, kwargs):
"""
:cls (class) <Class> of the object requested
:route (dict) Debris route schema
:args (list) of argument provided for initializing
:kwargs (dict) of given data to construct the object
"""
# ---------
... | python | def get(cls, route, args, kwargs):
"""
:cls (class) <Class> of the object requested
:route (dict) Debris route schema
:args (list) of argument provided for initializing
:kwargs (dict) of given data to construct the object
"""
# ---------
... | [
"def",
"get",
"(",
"cls",
",",
"route",
",",
"args",
",",
"kwargs",
")",
":",
"# ---------",
"# Namespace",
"# ---------",
"if",
"None",
"in",
"args",
":",
"namespace",
"=",
"None",
"else",
":",
"namespace",
"=",
"call",
"(",
"route",
".",
"get",
"(",
... | :cls (class) <Class> of the object requested
:route (dict) Debris route schema
:args (list) of argument provided for initializing
:kwargs (dict) of given data to construct the object | [
":",
"cls",
"(",
"class",
")",
"<Class",
">",
"of",
"the",
"object",
"requested",
":",
"route",
"(",
"dict",
")",
"Debris",
"route",
"schema",
":",
"args",
"(",
"list",
")",
"of",
"argument",
"provided",
"for",
"initializing",
":",
"kwargs",
"(",
"dict... | train | https://github.com/stevepeak/debris/blob/62ffde573a880c022bd4876ec836b32953225eea/debris/object.py#L16-L112 |
stevepeak/debris | debris/object.py | Object.getmany | def getmany(cls, route, args, kwargs, _keys):
"""
1. build name space
2. look locally for copies
3. build group for batch
4. fetch the new ones
5. return found + new list
"""
# copy the list of keys
keys = [] + _keys
# build a list of retur... | python | def getmany(cls, route, args, kwargs, _keys):
"""
1. build name space
2. look locally for copies
3. build group for batch
4. fetch the new ones
5. return found + new list
"""
# copy the list of keys
keys = [] + _keys
# build a list of retur... | [
"def",
"getmany",
"(",
"cls",
",",
"route",
",",
"args",
",",
"kwargs",
",",
"_keys",
")",
":",
"# copy the list of keys",
"keys",
"=",
"[",
"]",
"+",
"_keys",
"# build a list of returning objects",
"returning",
"=",
"[",
"]",
"# dictionary of references",
"name... | 1. build name space
2. look locally for copies
3. build group for batch
4. fetch the new ones
5. return found + new list | [
"1",
".",
"build",
"name",
"space",
"2",
".",
"look",
"locally",
"for",
"copies",
"3",
".",
"build",
"group",
"for",
"batch",
"4",
".",
"fetch",
"the",
"new",
"ones",
"5",
".",
"return",
"found",
"+",
"new",
"list"
] | train | https://github.com/stevepeak/debris/blob/62ffde573a880c022bd4876ec836b32953225eea/debris/object.py#L114-L207 |
zetaops/pyoko | pyoko/listnode.py | ListNode._load_data | def _load_data(self, data, from_db=False):
"""
Stores the data at self._data, actual object creation done at _generate_instances()
Args:
data (list): List of dicts.
from_db (bool): Default False. Is this data coming from DB or not.
"""
self._data = data[:... | python | def _load_data(self, data, from_db=False):
"""
Stores the data at self._data, actual object creation done at _generate_instances()
Args:
data (list): List of dicts.
from_db (bool): Default False. Is this data coming from DB or not.
"""
self._data = data[:... | [
"def",
"_load_data",
"(",
"self",
",",
"data",
",",
"from_db",
"=",
"False",
")",
":",
"self",
".",
"_data",
"=",
"data",
"[",
":",
"]",
"self",
".",
"setattrs",
"(",
"values",
"=",
"[",
"]",
",",
"node_stack",
"=",
"[",
"]",
",",
"node_dict",
"=... | Stores the data at self._data, actual object creation done at _generate_instances()
Args:
data (list): List of dicts.
from_db (bool): Default False. Is this data coming from DB or not. | [
"Stores",
"the",
"data",
"at",
"self",
".",
"_data",
"actual",
"object",
"creation",
"done",
"at",
"_generate_instances",
"()"
] | train | https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/listnode.py#L82-L96 |
zetaops/pyoko | pyoko/listnode.py | ListNode._generate_instances | def _generate_instances(self):
"""
ListNode item generator. Will be used internally by __iter__ and __getitem__
Yields:
ListNode items (instances)
"""
for node in self.node_stack:
yield node
while self._data:
yield self._make_instance(... | python | def _generate_instances(self):
"""
ListNode item generator. Will be used internally by __iter__ and __getitem__
Yields:
ListNode items (instances)
"""
for node in self.node_stack:
yield node
while self._data:
yield self._make_instance(... | [
"def",
"_generate_instances",
"(",
"self",
")",
":",
"for",
"node",
"in",
"self",
".",
"node_stack",
":",
"yield",
"node",
"while",
"self",
".",
"_data",
":",
"yield",
"self",
".",
"_make_instance",
"(",
"self",
".",
"_data",
".",
"pop",
"(",
"0",
")",... | ListNode item generator. Will be used internally by __iter__ and __getitem__
Yields:
ListNode items (instances) | [
"ListNode",
"item",
"generator",
".",
"Will",
"be",
"used",
"internally",
"by",
"__iter__",
"and",
"__getitem__"
] | train | https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/listnode.py#L98-L108 |
zetaops/pyoko | pyoko/listnode.py | ListNode._make_instance | def _make_instance(self, node_data):
"""
Create a ListNode instance from node_data
Args:
node_data (dict): Data to create ListNode item.
Returns:
ListNode item.
"""
node_data['from_db'] = self._from_db
clone = self.__call__(**node_data)
... | python | def _make_instance(self, node_data):
"""
Create a ListNode instance from node_data
Args:
node_data (dict): Data to create ListNode item.
Returns:
ListNode item.
"""
node_data['from_db'] = self._from_db
clone = self.__call__(**node_data)
... | [
"def",
"_make_instance",
"(",
"self",
",",
"node_data",
")",
":",
"node_data",
"[",
"'from_db'",
"]",
"=",
"self",
".",
"_from_db",
"clone",
"=",
"self",
".",
"__call__",
"(",
"*",
"*",
"node_data",
")",
"clone",
".",
"setattrs",
"(",
"container",
"=",
... | Create a ListNode instance from node_data
Args:
node_data (dict): Data to create ListNode item.
Returns:
ListNode item. | [
"Create",
"a",
"ListNode",
"instance",
"from",
"node_data"
] | train | https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/listnode.py#L110-L130 |
zetaops/pyoko | pyoko/listnode.py | ListNode.clean_value | def clean_value(self):
"""
Populates json serialization ready data.
This is the method used to serialize and store the object data in to DB
Returns:
List of dicts.
"""
result = []
for mdl in self:
result.append(super(ListNode, mdl).clean_v... | python | def clean_value(self):
"""
Populates json serialization ready data.
This is the method used to serialize and store the object data in to DB
Returns:
List of dicts.
"""
result = []
for mdl in self:
result.append(super(ListNode, mdl).clean_v... | [
"def",
"clean_value",
"(",
"self",
")",
":",
"result",
"=",
"[",
"]",
"for",
"mdl",
"in",
"self",
":",
"result",
".",
"append",
"(",
"super",
"(",
"ListNode",
",",
"mdl",
")",
".",
"clean_value",
"(",
")",
")",
"return",
"result"
] | Populates json serialization ready data.
This is the method used to serialize and store the object data in to DB
Returns:
List of dicts. | [
"Populates",
"json",
"serialization",
"ready",
"data",
".",
"This",
"is",
"the",
"method",
"used",
"to",
"serialize",
"and",
"store",
"the",
"object",
"data",
"in",
"to",
"DB"
] | train | https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/listnode.py#L142-L153 |
zetaops/pyoko | pyoko/listnode.py | ListNode.remove | def remove(self):
"""
Removes an item from ListNode.
Raises:
TypeError: If it's called on container ListNode (intstead of ListNode's item)
Note:
Parent object should be explicitly saved.
"""
if not self._is_item:
raise TypeError("Shou... | python | def remove(self):
"""
Removes an item from ListNode.
Raises:
TypeError: If it's called on container ListNode (intstead of ListNode's item)
Note:
Parent object should be explicitly saved.
"""
if not self._is_item:
raise TypeError("Shou... | [
"def",
"remove",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_is_item",
":",
"raise",
"TypeError",
"(",
"\"Should be called on an item, not ListNode's itself.\"",
")",
"self",
".",
"container",
".",
"node_stack",
".",
"remove",
"(",
"self",
")"
] | Removes an item from ListNode.
Raises:
TypeError: If it's called on container ListNode (intstead of ListNode's item)
Note:
Parent object should be explicitly saved. | [
"Removes",
"an",
"item",
"from",
"ListNode",
"."
] | train | https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/listnode.py#L277-L289 |
cthoyt/onto2nx | src/onto2nx/ontospy/core/queryHelper.py | QueryHelper.entityTriples | def entityTriples(self, aURI):
""" Builds all triples for an entity
Note: if a triple object is a blank node (=a nested definition)
we try to extract all relevant data recursively (does not work with
sparql endpoins)
2015-10-18: updated
"""
aURI = aURI
qr... | python | def entityTriples(self, aURI):
""" Builds all triples for an entity
Note: if a triple object is a blank node (=a nested definition)
we try to extract all relevant data recursively (does not work with
sparql endpoins)
2015-10-18: updated
"""
aURI = aURI
qr... | [
"def",
"entityTriples",
"(",
"self",
",",
"aURI",
")",
":",
"aURI",
"=",
"aURI",
"qres",
"=",
"self",
".",
"rdfgraph",
".",
"query",
"(",
"\"\"\"CONSTRUCT {<%s> ?y ?z }\n WHERE {\n { <%s> ?y ?z }\n }\n \"\"\"",... | Builds all triples for an entity
Note: if a triple object is a blank node (=a nested definition)
we try to extract all relevant data recursively (does not work with
sparql endpoins)
2015-10-18: updated | [
"Builds",
"all",
"triples",
"for",
"an",
"entity",
"Note",
":",
"if",
"a",
"triple",
"object",
"is",
"a",
"blank",
"node",
"(",
"=",
"a",
"nested",
"definition",
")",
"we",
"try",
"to",
"extract",
"all",
"relevant",
"data",
"recursively",
"(",
"does",
... | train | https://github.com/cthoyt/onto2nx/blob/94c86e5e187cca67534afe0260097177b66e02c8/src/onto2nx/ontospy/core/queryHelper.py#L54-L87 |
cthoyt/onto2nx | src/onto2nx/ontospy/core/queryHelper.py | QueryHelper.getAllClasses | def getAllClasses(self, hide_base_schemas=True):
"""
by default, obscure all RDF/RDFS/OWL/XML stuff
2016-05-06: not obscured anymore
"""
query = """SELECT DISTINCT ?x ?c
WHERE {
{
{ ?x a owl:Class }
... | python | def getAllClasses(self, hide_base_schemas=True):
"""
by default, obscure all RDF/RDFS/OWL/XML stuff
2016-05-06: not obscured anymore
"""
query = """SELECT DISTINCT ?x ?c
WHERE {
{
{ ?x a owl:Class }
... | [
"def",
"getAllClasses",
"(",
"self",
",",
"hide_base_schemas",
"=",
"True",
")",
":",
"query",
"=",
"\"\"\"SELECT DISTINCT ?x ?c\n WHERE {\n {\n { ?x a owl:Class }\n union\n ... | by default, obscure all RDF/RDFS/OWL/XML stuff
2016-05-06: not obscured anymore | [
"by",
"default",
"obscure",
"all",
"RDF",
"/",
"RDFS",
"/",
"OWL",
"/",
"XML",
"stuff",
"2016",
"-",
"05",
"-",
"06",
":",
"not",
"obscured",
"anymore"
] | train | https://github.com/cthoyt/onto2nx/blob/94c86e5e187cca67534afe0260097177b66e02c8/src/onto2nx/ontospy/core/queryHelper.py#L108-L151 |
cthoyt/onto2nx | src/onto2nx/ontospy/core/queryHelper.py | QueryHelper.getClassDirectSubs | def getClassDirectSubs(self, aURI):
"""
2015-06-03: currenlty not used, inferred from above
"""
aURI = aURI
qres = self.rdfgraph.query(
"""SELECT DISTINCT ?x
WHERE {
{ ?x rdfs:subClassOf <%s> }
FILTER (!isBl... | python | def getClassDirectSubs(self, aURI):
"""
2015-06-03: currenlty not used, inferred from above
"""
aURI = aURI
qres = self.rdfgraph.query(
"""SELECT DISTINCT ?x
WHERE {
{ ?x rdfs:subClassOf <%s> }
FILTER (!isBl... | [
"def",
"getClassDirectSubs",
"(",
"self",
",",
"aURI",
")",
":",
"aURI",
"=",
"aURI",
"qres",
"=",
"self",
".",
"rdfgraph",
".",
"query",
"(",
"\"\"\"SELECT DISTINCT ?x\n WHERE {\n { ?x rdfs:subClassOf <%s> }\n FILTER (!is... | 2015-06-03: currenlty not used, inferred from above | [
"2015",
"-",
"06",
"-",
"03",
":",
"currenlty",
"not",
"used",
"inferred",
"from",
"above"
] | train | https://github.com/cthoyt/onto2nx/blob/94c86e5e187cca67534afe0260097177b66e02c8/src/onto2nx/ontospy/core/queryHelper.py#L237-L249 |
cthoyt/onto2nx | src/onto2nx/ontospy/core/queryHelper.py | QueryHelper.getClassAllSupers | def getClassAllSupers(self, aURI):
"""
note: requires SPARQL 1.1
2015-06-04: currenlty not used, inferred from above
"""
aURI = aURI
try:
qres = self.rdfgraph.query(
"""SELECT DISTINCT ?x
WHERE {
... | python | def getClassAllSupers(self, aURI):
"""
note: requires SPARQL 1.1
2015-06-04: currenlty not used, inferred from above
"""
aURI = aURI
try:
qres = self.rdfgraph.query(
"""SELECT DISTINCT ?x
WHERE {
... | [
"def",
"getClassAllSupers",
"(",
"self",
",",
"aURI",
")",
":",
"aURI",
"=",
"aURI",
"try",
":",
"qres",
"=",
"self",
".",
"rdfgraph",
".",
"query",
"(",
"\"\"\"SELECT DISTINCT ?x\n WHERE {\n { <%s> rdfs:subClassOf+ ?x }\n ... | note: requires SPARQL 1.1
2015-06-04: currenlty not used, inferred from above | [
"note",
":",
"requires",
"SPARQL",
"1",
".",
"1",
"2015",
"-",
"06",
"-",
"04",
":",
"currenlty",
"not",
"used",
"inferred",
"from",
"above"
] | train | https://github.com/cthoyt/onto2nx/blob/94c86e5e187cca67534afe0260097177b66e02c8/src/onto2nx/ontospy/core/queryHelper.py#L251-L268 |
cthoyt/onto2nx | src/onto2nx/ontospy/core/queryHelper.py | QueryHelper.getClassAllSubs | def getClassAllSubs(self, aURI):
"""
note: requires SPARQL 1.1
2015-06-04: currenlty not used, inferred from above
"""
aURI = aURI
try:
qres = self.rdfgraph.query(
"""SELECT DISTINCT ?x
WHERE {
{ ... | python | def getClassAllSubs(self, aURI):
"""
note: requires SPARQL 1.1
2015-06-04: currenlty not used, inferred from above
"""
aURI = aURI
try:
qres = self.rdfgraph.query(
"""SELECT DISTINCT ?x
WHERE {
{ ... | [
"def",
"getClassAllSubs",
"(",
"self",
",",
"aURI",
")",
":",
"aURI",
"=",
"aURI",
"try",
":",
"qres",
"=",
"self",
".",
"rdfgraph",
".",
"query",
"(",
"\"\"\"SELECT DISTINCT ?x\n WHERE {\n { ?x rdfs:subClassOf+ <%s> }\n ... | note: requires SPARQL 1.1
2015-06-04: currenlty not used, inferred from above | [
"note",
":",
"requires",
"SPARQL",
"1",
".",
"1",
"2015",
"-",
"06",
"-",
"04",
":",
"currenlty",
"not",
"used",
"inferred",
"from",
"above"
] | train | https://github.com/cthoyt/onto2nx/blob/94c86e5e187cca67534afe0260097177b66e02c8/src/onto2nx/ontospy/core/queryHelper.py#L271-L288 |
cthoyt/onto2nx | src/onto2nx/ontospy/core/queryHelper.py | QueryHelper.getPropAllSupers | def getPropAllSupers(self, aURI):
"""
note: requires SPARQL 1.1
2015-06-04: currenlty not used, inferred from above
"""
aURI = aURI
try:
qres = self.rdfgraph.query(
"""SELECT DISTINCT ?x
WHERE {
{... | python | def getPropAllSupers(self, aURI):
"""
note: requires SPARQL 1.1
2015-06-04: currenlty not used, inferred from above
"""
aURI = aURI
try:
qres = self.rdfgraph.query(
"""SELECT DISTINCT ?x
WHERE {
{... | [
"def",
"getPropAllSupers",
"(",
"self",
",",
"aURI",
")",
":",
"aURI",
"=",
"aURI",
"try",
":",
"qres",
"=",
"self",
".",
"rdfgraph",
".",
"query",
"(",
"\"\"\"SELECT DISTINCT ?x\n WHERE {\n { <%s> rdfs:subPropertyOf+ ?x }\n ... | note: requires SPARQL 1.1
2015-06-04: currenlty not used, inferred from above | [
"note",
":",
"requires",
"SPARQL",
"1",
".",
"1",
"2015",
"-",
"06",
"-",
"04",
":",
"currenlty",
"not",
"used",
"inferred",
"from",
"above"
] | train | https://github.com/cthoyt/onto2nx/blob/94c86e5e187cca67534afe0260097177b66e02c8/src/onto2nx/ontospy/core/queryHelper.py#L329-L346 |
cthoyt/onto2nx | src/onto2nx/ontospy/core/queryHelper.py | QueryHelper.getPropAllSubs | def getPropAllSubs(self, aURI):
"""
note: requires SPARQL 1.1
2015-06-04: currenlty not used, inferred from above
"""
aURI = aURI
try:
qres = self.rdfgraph.query(
"""SELECT DISTINCT ?x
WHERE {
{ ?... | python | def getPropAllSubs(self, aURI):
"""
note: requires SPARQL 1.1
2015-06-04: currenlty not used, inferred from above
"""
aURI = aURI
try:
qres = self.rdfgraph.query(
"""SELECT DISTINCT ?x
WHERE {
{ ?... | [
"def",
"getPropAllSubs",
"(",
"self",
",",
"aURI",
")",
":",
"aURI",
"=",
"aURI",
"try",
":",
"qres",
"=",
"self",
".",
"rdfgraph",
".",
"query",
"(",
"\"\"\"SELECT DISTINCT ?x\n WHERE {\n { ?x rdfs:subPropertyOf+ <%s> }\n ... | note: requires SPARQL 1.1
2015-06-04: currenlty not used, inferred from above | [
"note",
":",
"requires",
"SPARQL",
"1",
".",
"1",
"2015",
"-",
"06",
"-",
"04",
":",
"currenlty",
"not",
"used",
"inferred",
"from",
"above"
] | train | https://github.com/cthoyt/onto2nx/blob/94c86e5e187cca67534afe0260097177b66e02c8/src/onto2nx/ontospy/core/queryHelper.py#L349-L366 |
cthoyt/onto2nx | src/onto2nx/ontospy/core/queryHelper.py | QueryHelper.getSKOSDirectSubs | def getSKOSDirectSubs(self, aURI):
"""
2015-08-19: currenlty not used, inferred from above
"""
aURI = aURI
qres = self.rdfgraph.query(
"""SELECT DISTINCT ?x
WHERE {
{
{ ?x skos:broader <%s> }
... | python | def getSKOSDirectSubs(self, aURI):
"""
2015-08-19: currenlty not used, inferred from above
"""
aURI = aURI
qres = self.rdfgraph.query(
"""SELECT DISTINCT ?x
WHERE {
{
{ ?x skos:broader <%s> }
... | [
"def",
"getSKOSDirectSubs",
"(",
"self",
",",
"aURI",
")",
":",
"aURI",
"=",
"aURI",
"qres",
"=",
"self",
".",
"rdfgraph",
".",
"query",
"(",
"\"\"\"SELECT DISTINCT ?x\n WHERE {\n {\n { ?x skos:broader <%s> }\n... | 2015-08-19: currenlty not used, inferred from above | [
"2015",
"-",
"08",
"-",
"19",
":",
"currenlty",
"not",
"used",
"inferred",
"from",
"above"
] | train | https://github.com/cthoyt/onto2nx/blob/94c86e5e187cca67534afe0260097177b66e02c8/src/onto2nx/ontospy/core/queryHelper.py#L400-L416 |
seibert-media/Highton | highton/parsing/xml_encoder.py | XMLEncoder.encode | def encode(self):
"""
Encodes the object to a xml.etree.ElementTree.Element
:return: the encoded element
:rtype: xml.etree.ElementTree.Element
"""
root_element = ElementTree.Element(self.TAG_NAME)
for value in [value for value in self.__dict__.values() if isinsta... | python | def encode(self):
"""
Encodes the object to a xml.etree.ElementTree.Element
:return: the encoded element
:rtype: xml.etree.ElementTree.Element
"""
root_element = ElementTree.Element(self.TAG_NAME)
for value in [value for value in self.__dict__.values() if isinsta... | [
"def",
"encode",
"(",
"self",
")",
":",
"root_element",
"=",
"ElementTree",
".",
"Element",
"(",
"self",
".",
"TAG_NAME",
")",
"for",
"value",
"in",
"[",
"value",
"for",
"value",
"in",
"self",
".",
"__dict__",
".",
"values",
"(",
")",
"if",
"isinstance... | Encodes the object to a xml.etree.ElementTree.Element
:return: the encoded element
:rtype: xml.etree.ElementTree.Element | [
"Encodes",
"the",
"object",
"to",
"a",
"xml",
".",
"etree",
".",
"ElementTree",
".",
"Element"
] | train | https://github.com/seibert-media/Highton/blob/1519e4fb105f62882c2e7bc81065d994649558d8/highton/parsing/xml_encoder.py#L34-L45 |
flying-sheep/smart-progress | smart_progress.py | progressbar | def progressbar(
iterable=None, length=None, label=None,
show_eta=True, show_percent=None, show_pos=False, item_show_func=None,
fill_char='#', empty_char='-', bar_template='%(label)s [%(bar)s] %(info)s', info_sep=' ',
width=36, file=None, color=None):
"""Create a progressbar that works in Jupyter/IPython noteb... | python | def progressbar(
iterable=None, length=None, label=None,
show_eta=True, show_percent=None, show_pos=False, item_show_func=None,
fill_char='#', empty_char='-', bar_template='%(label)s [%(bar)s] %(info)s', info_sep=' ',
width=36, file=None, color=None):
"""Create a progressbar that works in Jupyter/IPython noteb... | [
"def",
"progressbar",
"(",
"iterable",
"=",
"None",
",",
"length",
"=",
"None",
",",
"label",
"=",
"None",
",",
"show_eta",
"=",
"True",
",",
"show_percent",
"=",
"None",
",",
"show_pos",
"=",
"False",
",",
"item_show_func",
"=",
"None",
",",
"fill_char"... | Create a progressbar that works in Jupyter/IPython notebooks and the terminal | [
"Create",
"a",
"progressbar",
"that",
"works",
"in",
"Jupyter",
"/",
"IPython",
"notebooks",
"and",
"the",
"terminal"
] | train | https://github.com/flying-sheep/smart-progress/blob/1091a0a9cc2d7a6304f992d13cb718d5150a64c6/smart_progress.py#L58-L74 |
luismmontielg/pyplotter | pyplotter/pyplotter.py | Plotter.plot | def plot(graph, show_x_axis=True,
head=None, tail=None, label_length=4, padding=0,
height=2, show_min_max=True, show_data_range=True,
show_title=True):
"""
show_x_axis: Display X axis
head: Show first [head:] elements
tail: Show last [-tail:] elemen... | python | def plot(graph, show_x_axis=True,
head=None, tail=None, label_length=4, padding=0,
height=2, show_min_max=True, show_data_range=True,
show_title=True):
"""
show_x_axis: Display X axis
head: Show first [head:] elements
tail: Show last [-tail:] elemen... | [
"def",
"plot",
"(",
"graph",
",",
"show_x_axis",
"=",
"True",
",",
"head",
"=",
"None",
",",
"tail",
"=",
"None",
",",
"label_length",
"=",
"4",
",",
"padding",
"=",
"0",
",",
"height",
"=",
"2",
",",
"show_min_max",
"=",
"True",
",",
"show_data_rang... | show_x_axis: Display X axis
head: Show first [head:] elements
tail: Show last [-tail:] elements
padding: Padding size between columns (default 0)
height: Override graph height
label_length: Force X axis label string size, may truncate label
show_min_max: Display Min and M... | [
"show_x_axis",
":",
"Display",
"X",
"axis",
"head",
":",
"Show",
"first",
"[",
"head",
":",
"]",
"elements",
"tail",
":",
"Show",
"last",
"[",
"-",
"tail",
":",
"]",
"elements",
"padding",
":",
"Padding",
"size",
"between",
"columns",
"(",
"default",
"... | train | https://github.com/luismmontielg/pyplotter/blob/41a00c7a465113d87c732502fa118893f1376d01/pyplotter/pyplotter.py#L11-L80 |
luismmontielg/pyplotter | pyplotter/pyplotter.py | Graph.strings | def strings(self):
"""
The structure of the bar graph. A list that contains all the strings
that build up a bar in the given position. thise strings are inside a
list, starting from the top level.
structure: [
1st bar -> ['1st level str', ..., 'height-1 str', 'height... | python | def strings(self):
"""
The structure of the bar graph. A list that contains all the strings
that build up a bar in the given position. thise strings are inside a
list, starting from the top level.
structure: [
1st bar -> ['1st level str', ..., 'height-1 str', 'height... | [
"def",
"strings",
"(",
"self",
")",
":",
"def",
"get_strings",
"(",
"stack_id",
",",
"height",
")",
":",
"def",
"_str",
"(",
"i",
")",
":",
"if",
"i",
"==",
"None",
":",
"return",
"VOID_STR",
"return",
"self",
".",
"__list",
"[",
"i",
"]",
"strings... | The structure of the bar graph. A list that contains all the strings
that build up a bar in the given position. thise strings are inside a
list, starting from the top level.
structure: [
1st bar -> ['1st level str', ..., 'height-1 str', 'height str'],
2nd bar -> ['1st le... | [
"The",
"structure",
"of",
"the",
"bar",
"graph",
".",
"A",
"list",
"that",
"contains",
"all",
"the",
"strings",
"that",
"build",
"up",
"a",
"bar",
"in",
"the",
"given",
"position",
".",
"thise",
"strings",
"are",
"inside",
"a",
"list",
"starting",
"from"... | train | https://github.com/luismmontielg/pyplotter/blob/41a00c7a465113d87c732502fa118893f1376d01/pyplotter/pyplotter.py#L202-L244 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.