repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 3
values | summary stringlengths 4 350 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
SHDShim/pytheos | pytheos/eqn_therm_constq.py | constq_grun | def constq_grun(v, v0, gamma0, q):
"""
calculate Gruneisen parameter for constant q
:param v: unit-cell volume in A^3
:param v0: unit-cell volume in A^3 at 1 bar
:param gamma0: Gruneisen parameter at 1 bar
:param q: logarithmic derivative of Grunseinen parameter
:return: Gruneisen parameter... | python | def constq_grun(v, v0, gamma0, q):
"""
calculate Gruneisen parameter for constant q
:param v: unit-cell volume in A^3
:param v0: unit-cell volume in A^3 at 1 bar
:param gamma0: Gruneisen parameter at 1 bar
:param q: logarithmic derivative of Grunseinen parameter
:return: Gruneisen parameter... | [
"def",
"constq_grun",
"(",
"v",
",",
"v0",
",",
"gamma0",
",",
"q",
")",
":",
"x",
"=",
"v",
"/",
"v0",
"return",
"gamma0",
"*",
"np",
".",
"power",
"(",
"x",
",",
"q",
")"
] | calculate Gruneisen parameter for constant q
:param v: unit-cell volume in A^3
:param v0: unit-cell volume in A^3 at 1 bar
:param gamma0: Gruneisen parameter at 1 bar
:param q: logarithmic derivative of Grunseinen parameter
:return: Gruneisen parameter at a given volume | [
"calculate",
"Gruneisen",
"parameter",
"for",
"constant",
"q"
] | be079624405e92fbec60c5ead253eb5917e55237 | https://github.com/SHDShim/pytheos/blob/be079624405e92fbec60c5ead253eb5917e55237/pytheos/eqn_therm_constq.py#L13-L24 | train | calculate Gruneisen parameter for constant q |
SHDShim/pytheos | pytheos/eqn_therm_constq.py | constq_debyetemp | def constq_debyetemp(v, v0, gamma0, q, theta0):
"""
calculate Debye temperature for constant q
:param v: unit-cell volume in A^3
:param v0: unit-cell volume in A^3 at 1 bar
:param gamma0: Gruneisen parameter at 1 bar
:param q: logarithmic derivative of Gruneisen parameter
:param theta0: Deb... | python | def constq_debyetemp(v, v0, gamma0, q, theta0):
"""
calculate Debye temperature for constant q
:param v: unit-cell volume in A^3
:param v0: unit-cell volume in A^3 at 1 bar
:param gamma0: Gruneisen parameter at 1 bar
:param q: logarithmic derivative of Gruneisen parameter
:param theta0: Deb... | [
"def",
"constq_debyetemp",
"(",
"v",
",",
"v0",
",",
"gamma0",
",",
"q",
",",
"theta0",
")",
":",
"gamma",
"=",
"constq_grun",
"(",
"v",
",",
"v0",
",",
"gamma0",
",",
"q",
")",
"if",
"isuncertainties",
"(",
"[",
"v",
",",
"v0",
",",
"gamma0",
",... | calculate Debye temperature for constant q
:param v: unit-cell volume in A^3
:param v0: unit-cell volume in A^3 at 1 bar
:param gamma0: Gruneisen parameter at 1 bar
:param q: logarithmic derivative of Gruneisen parameter
:param theta0: Debye temperature at 1 bar
:return: Debye temperature in K | [
"calculate",
"Debye",
"temperature",
"for",
"constant",
"q"
] | be079624405e92fbec60c5ead253eb5917e55237 | https://github.com/SHDShim/pytheos/blob/be079624405e92fbec60c5ead253eb5917e55237/pytheos/eqn_therm_constq.py#L27-L43 | train | calculate Debye temperature for constant q |
SHDShim/pytheos | pytheos/eqn_therm_constq.py | constq_pth | def constq_pth(v, temp, v0, gamma0, q, theta0, n, z, t_ref=300.,
three_r=3. * constants.R):
"""
calculate thermal pressure for constant q
:param v: unit-cell volume in A^3
:param temp: temperature
:param v0: unit-cell volume in A^3 at 1 bar
:param gamma0: Gruneisen parameter at 1... | python | def constq_pth(v, temp, v0, gamma0, q, theta0, n, z, t_ref=300.,
three_r=3. * constants.R):
"""
calculate thermal pressure for constant q
:param v: unit-cell volume in A^3
:param temp: temperature
:param v0: unit-cell volume in A^3 at 1 bar
:param gamma0: Gruneisen parameter at 1... | [
"def",
"constq_pth",
"(",
"v",
",",
"temp",
",",
"v0",
",",
"gamma0",
",",
"q",
",",
"theta0",
",",
"n",
",",
"z",
",",
"t_ref",
"=",
"300.",
",",
"three_r",
"=",
"3.",
"*",
"constants",
".",
"R",
")",
":",
"v_mol",
"=",
"vol_uc2mol",
"(",
"v",... | calculate thermal pressure for constant q
:param v: unit-cell volume in A^3
:param temp: temperature
:param v0: unit-cell volume in A^3 at 1 bar
:param gamma0: Gruneisen parameter at 1 bar
:param q: logarithmic derivative of Gruneisen parameter
:param theta0: Debye temperature in K
:param n... | [
"calculate",
"thermal",
"pressure",
"for",
"constant",
"q"
] | be079624405e92fbec60c5ead253eb5917e55237 | https://github.com/SHDShim/pytheos/blob/be079624405e92fbec60c5ead253eb5917e55237/pytheos/eqn_therm_constq.py#L46-L78 | train | calculate thermal pressure for constant q |
infothrill/python-launchd | launchd/cmd.py | launchctl | def launchctl(subcommand, *args):
'''
A minimal wrapper to call the launchctl binary and capture the output
:param subcommand: string
'''
if not isinstance(subcommand, six.string_types):
raise ValueError("Argument is invalid: %r" % repr(subcommand))
if isinstance(subcommand, six.text_typ... | python | def launchctl(subcommand, *args):
'''
A minimal wrapper to call the launchctl binary and capture the output
:param subcommand: string
'''
if not isinstance(subcommand, six.string_types):
raise ValueError("Argument is invalid: %r" % repr(subcommand))
if isinstance(subcommand, six.text_typ... | [
"def",
"launchctl",
"(",
"subcommand",
",",
"*",
"args",
")",
":",
"if",
"not",
"isinstance",
"(",
"subcommand",
",",
"six",
".",
"string_types",
")",
":",
"raise",
"ValueError",
"(",
"\"Argument is invalid: %r\"",
"%",
"repr",
"(",
"subcommand",
")",
")",
... | A minimal wrapper to call the launchctl binary and capture the output
:param subcommand: string | [
"A",
"minimal",
"wrapper",
"to",
"call",
"the",
"launchctl",
"binary",
"and",
"capture",
"the",
"output",
":",
"param",
"subcommand",
":",
"string"
] | 2cd50579e808851b116f5a26f9b871a32b65ce0e | https://github.com/infothrill/python-launchd/blob/2cd50579e808851b116f5a26f9b871a32b65ce0e/launchd/cmd.py#L8-L27 | train | A minimal wrapper to call the launchctl binary and capture the output |
Capitains/MyCapytain | MyCapytain/retrievers/cts5.py | HttpCtsRetriever.call | def call(self, parameters):
""" Call an endpoint given the parameters
:param parameters: Dictionary of parameters
:type parameters: dict
:rtype: text
"""
# DEV !
parameters = {
key: str(parameters[key]) for key in parameters if parameters[key] is not ... | python | def call(self, parameters):
""" Call an endpoint given the parameters
:param parameters: Dictionary of parameters
:type parameters: dict
:rtype: text
"""
# DEV !
parameters = {
key: str(parameters[key]) for key in parameters if parameters[key] is not ... | [
"def",
"call",
"(",
"self",
",",
"parameters",
")",
":",
"# DEV !",
"parameters",
"=",
"{",
"key",
":",
"str",
"(",
"parameters",
"[",
"key",
"]",
")",
"for",
"key",
"in",
"parameters",
"if",
"parameters",
"[",
"key",
"]",
"is",
"not",
"None",
"}",
... | Call an endpoint given the parameters
:param parameters: Dictionary of parameters
:type parameters: dict
:rtype: text | [
"Call",
"an",
"endpoint",
"given",
"the",
"parameters"
] | b11bbf6b6ae141fc02be70471e3fbf6907be6593 | https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/retrievers/cts5.py#L40-L58 | train | Call an endpoint given the parameters
|
Capitains/MyCapytain | MyCapytain/retrievers/cts5.py | HttpCtsRetriever.getValidReff | def getValidReff(self, urn, inventory=None, level=None):
""" Retrieve valid urn-references for a text
:param urn: URN identifying the text
:type urn: text
:param inventory: Name of the inventory
:type inventory: text
:param level: Depth of references expected
:ty... | python | def getValidReff(self, urn, inventory=None, level=None):
""" Retrieve valid urn-references for a text
:param urn: URN identifying the text
:type urn: text
:param inventory: Name of the inventory
:type inventory: text
:param level: Depth of references expected
:ty... | [
"def",
"getValidReff",
"(",
"self",
",",
"urn",
",",
"inventory",
"=",
"None",
",",
"level",
"=",
"None",
")",
":",
"return",
"self",
".",
"call",
"(",
"{",
"\"inv\"",
":",
"inventory",
",",
"\"urn\"",
":",
"urn",
",",
"\"level\"",
":",
"level",
",",... | Retrieve valid urn-references for a text
:param urn: URN identifying the text
:type urn: text
:param inventory: Name of the inventory
:type inventory: text
:param level: Depth of references expected
:type level: int
:return: XML Response from the API as string
... | [
"Retrieve",
"valid",
"urn",
"-",
"references",
"for",
"a",
"text"
] | b11bbf6b6ae141fc02be70471e3fbf6907be6593 | https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/retrievers/cts5.py#L75-L92 | train | Retrieve valid urn - references for a text
|
Capitains/MyCapytain | MyCapytain/retrievers/cts5.py | HttpCtsRetriever.getPassage | def getPassage(self, urn, inventory=None, context=None):
""" Retrieve a passage
:param urn: URN identifying the text's passage (Minimum depth : 1)
:type urn: text
:param inventory: Name of the inventory
:type inventory: text
:param context: Number of citation units at th... | python | def getPassage(self, urn, inventory=None, context=None):
""" Retrieve a passage
:param urn: URN identifying the text's passage (Minimum depth : 1)
:type urn: text
:param inventory: Name of the inventory
:type inventory: text
:param context: Number of citation units at th... | [
"def",
"getPassage",
"(",
"self",
",",
"urn",
",",
"inventory",
"=",
"None",
",",
"context",
"=",
"None",
")",
":",
"return",
"self",
".",
"call",
"(",
"{",
"\"inv\"",
":",
"inventory",
",",
"\"urn\"",
":",
"urn",
",",
"\"context\"",
":",
"context",
... | Retrieve a passage
:param urn: URN identifying the text's passage (Minimum depth : 1)
:type urn: text
:param inventory: Name of the inventory
:type inventory: text
:param context: Number of citation units at the same level of the citation hierarchy as the requested urn, immediat... | [
"Retrieve",
"a",
"passage"
] | b11bbf6b6ae141fc02be70471e3fbf6907be6593 | https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/retrievers/cts5.py#L139-L155 | train | Retrieve a passage from the inventory |
Capitains/MyCapytain | MyCapytain/retrievers/cts5.py | HttpCtsRetriever.getPassagePlus | def getPassagePlus(self, urn, inventory=None, context=None):
""" Retrieve a passage and information about it
:param urn: URN identifying the text's passage (Minimum depth : 1)
:type urn: text
:param inventory: Name of the inventory
:type inventory: text
:param context: N... | python | def getPassagePlus(self, urn, inventory=None, context=None):
""" Retrieve a passage and information about it
:param urn: URN identifying the text's passage (Minimum depth : 1)
:type urn: text
:param inventory: Name of the inventory
:type inventory: text
:param context: N... | [
"def",
"getPassagePlus",
"(",
"self",
",",
"urn",
",",
"inventory",
"=",
"None",
",",
"context",
"=",
"None",
")",
":",
"return",
"self",
".",
"call",
"(",
"{",
"\"inv\"",
":",
"inventory",
",",
"\"urn\"",
":",
"urn",
",",
"\"context\"",
":",
"context"... | Retrieve a passage and information about it
:param urn: URN identifying the text's passage (Minimum depth : 1)
:type urn: text
:param inventory: Name of the inventory
:type inventory: text
:param context: Number of citation units at the same level of the citation hierarchy as th... | [
"Retrieve",
"a",
"passage",
"and",
"information",
"about",
"it"
] | b11bbf6b6ae141fc02be70471e3fbf6907be6593 | https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/retrievers/cts5.py#L157-L173 | train | Retrieves a passage and information about it
|
Capitains/MyCapytain | MyCapytain/retrievers/cts5.py | HttpCtsRetriever.getMetadata | def getMetadata(self, objectId=None, **filters):
""" Request metadata about a text or a collection
:param objectId: Filter for some object identifier
:param filters: Kwargs parameters. URN and Inv are available
:return: GetCapabilities CTS API request response
"""
filter... | python | def getMetadata(self, objectId=None, **filters):
""" Request metadata about a text or a collection
:param objectId: Filter for some object identifier
:param filters: Kwargs parameters. URN and Inv are available
:return: GetCapabilities CTS API request response
"""
filter... | [
"def",
"getMetadata",
"(",
"self",
",",
"objectId",
"=",
"None",
",",
"*",
"*",
"filters",
")",
":",
"filters",
".",
"update",
"(",
"{",
"\"urn\"",
":",
"objectId",
"}",
")",
"return",
"self",
".",
"getCapabilities",
"(",
"*",
"*",
"filters",
")"
] | Request metadata about a text or a collection
:param objectId: Filter for some object identifier
:param filters: Kwargs parameters. URN and Inv are available
:return: GetCapabilities CTS API request response | [
"Request",
"metadata",
"about",
"a",
"text",
"or",
"a",
"collection"
] | b11bbf6b6ae141fc02be70471e3fbf6907be6593 | https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/retrievers/cts5.py#L179-L187 | train | Request metadata about a text or a collection of objects. |
Capitains/MyCapytain | MyCapytain/retrievers/cts5.py | HttpCtsRetriever.getTextualNode | def getTextualNode(self, textId, subreference=None, prevnext=False, metadata=False):
""" Retrieve a text node from the API
:param textId: CtsTextMetadata Identifier
:param subreference: CapitainsCtsPassage Reference
:param prevnext: Retrieve graph representing previous and next passage
... | python | def getTextualNode(self, textId, subreference=None, prevnext=False, metadata=False):
""" Retrieve a text node from the API
:param textId: CtsTextMetadata Identifier
:param subreference: CapitainsCtsPassage Reference
:param prevnext: Retrieve graph representing previous and next passage
... | [
"def",
"getTextualNode",
"(",
"self",
",",
"textId",
",",
"subreference",
"=",
"None",
",",
"prevnext",
"=",
"False",
",",
"metadata",
"=",
"False",
")",
":",
"if",
"subreference",
":",
"textId",
"=",
"\"{}:{}\"",
".",
"format",
"(",
"textId",
",",
"subr... | Retrieve a text node from the API
:param textId: CtsTextMetadata Identifier
:param subreference: CapitainsCtsPassage Reference
:param prevnext: Retrieve graph representing previous and next passage
:param metadata: Retrieve metadata about the passage and the text
:return: GetPas... | [
"Retrieve",
"a",
"text",
"node",
"from",
"the",
"API"
] | b11bbf6b6ae141fc02be70471e3fbf6907be6593 | https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/retrievers/cts5.py#L189-L204 | train | Retrieve a text node from the API. |
Capitains/MyCapytain | MyCapytain/retrievers/cts5.py | HttpCtsRetriever.getSiblings | def getSiblings(self, textId, subreference):
""" Retrieve the siblings of a textual node
:param textId: CtsTextMetadata Identifier
:param reference: CapitainsCtsPassage Reference
:return: GetPrevNextUrn request response from the endpoint
"""
textId = "{}:{}".format(textI... | python | def getSiblings(self, textId, subreference):
""" Retrieve the siblings of a textual node
:param textId: CtsTextMetadata Identifier
:param reference: CapitainsCtsPassage Reference
:return: GetPrevNextUrn request response from the endpoint
"""
textId = "{}:{}".format(textI... | [
"def",
"getSiblings",
"(",
"self",
",",
"textId",
",",
"subreference",
")",
":",
"textId",
"=",
"\"{}:{}\"",
".",
"format",
"(",
"textId",
",",
"subreference",
")",
"return",
"self",
".",
"getPrevNextUrn",
"(",
"urn",
"=",
"textId",
")"
] | Retrieve the siblings of a textual node
:param textId: CtsTextMetadata Identifier
:param reference: CapitainsCtsPassage Reference
:return: GetPrevNextUrn request response from the endpoint | [
"Retrieve",
"the",
"siblings",
"of",
"a",
"textual",
"node"
] | b11bbf6b6ae141fc02be70471e3fbf6907be6593 | https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/retrievers/cts5.py#L206-L214 | train | Retrieve the siblings of a textual node |
Capitains/MyCapytain | MyCapytain/retrievers/cts5.py | HttpCtsRetriever.getReffs | def getReffs(self, textId, level=1, subreference=None):
""" Retrieve the siblings of a textual node
:param textId: CtsTextMetadata Identifier
:type textId: str
:param level: Depth for retrieval
:type level: int
:param subreference: CapitainsCtsPassage Reference
:... | python | def getReffs(self, textId, level=1, subreference=None):
""" Retrieve the siblings of a textual node
:param textId: CtsTextMetadata Identifier
:type textId: str
:param level: Depth for retrieval
:type level: int
:param subreference: CapitainsCtsPassage Reference
:... | [
"def",
"getReffs",
"(",
"self",
",",
"textId",
",",
"level",
"=",
"1",
",",
"subreference",
"=",
"None",
")",
":",
"depth",
"=",
"level",
"if",
"subreference",
":",
"textId",
"=",
"\"{}:{}\"",
".",
"format",
"(",
"textId",
",",
"subreference",
")",
"if... | Retrieve the siblings of a textual node
:param textId: CtsTextMetadata Identifier
:type textId: str
:param level: Depth for retrieval
:type level: int
:param subreference: CapitainsCtsPassage Reference
:type subreference: str
:return: List of references
:... | [
"Retrieve",
"the",
"siblings",
"of",
"a",
"textual",
"node"
] | b11bbf6b6ae141fc02be70471e3fbf6907be6593 | https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/retrievers/cts5.py#L216-L238 | train | Retrieve the siblings of a textual node. |
ChrisBeaumont/smother | smother/diff.py | parse_intervals | def parse_intervals(diff_report):
"""
Parse a diff into an iterator of Intervals.
"""
for patch in diff_report.patch_set:
try:
old_pf = diff_report.old_file(patch.source_file)
new_pf = diff_report.new_file(patch.target_file)
except InvalidPythonFile:
... | python | def parse_intervals(diff_report):
"""
Parse a diff into an iterator of Intervals.
"""
for patch in diff_report.patch_set:
try:
old_pf = diff_report.old_file(patch.source_file)
new_pf = diff_report.new_file(patch.target_file)
except InvalidPythonFile:
... | [
"def",
"parse_intervals",
"(",
"diff_report",
")",
":",
"for",
"patch",
"in",
"diff_report",
".",
"patch_set",
":",
"try",
":",
"old_pf",
"=",
"diff_report",
".",
"old_file",
"(",
"patch",
".",
"source_file",
")",
"new_pf",
"=",
"diff_report",
".",
"new_file... | Parse a diff into an iterator of Intervals. | [
"Parse",
"a",
"diff",
"into",
"an",
"iterator",
"of",
"Intervals",
"."
] | 65d1ea6ae0060d213b0dcbb983c5aa8e7fee07bb | https://github.com/ChrisBeaumont/smother/blob/65d1ea6ae0060d213b0dcbb983c5aa8e7fee07bb/smother/diff.py#L31-L54 | train | Parse a diff into an iterator of Intervals. |
totalgood/twip | twip/train.py | lsi | def lsi(tokenize=None, iter_dics=None, ram=0.4, num_docs=5000, num_topics=200, num_tokens=1000000,
num_plots=4, local_path=DATA_PATH, suffix='', ngrams=2,
verbose=1, show=True, save=True, **kwargs):
"""Train an LSI model on a "corpus" of documnets, like tweets
Arguments:
tokenize (callabl... | python | def lsi(tokenize=None, iter_dics=None, ram=0.4, num_docs=5000, num_topics=200, num_tokens=1000000,
num_plots=4, local_path=DATA_PATH, suffix='', ngrams=2,
verbose=1, show=True, save=True, **kwargs):
"""Train an LSI model on a "corpus" of documnets, like tweets
Arguments:
tokenize (callabl... | [
"def",
"lsi",
"(",
"tokenize",
"=",
"None",
",",
"iter_dics",
"=",
"None",
",",
"ram",
"=",
"0.4",
",",
"num_docs",
"=",
"5000",
",",
"num_topics",
"=",
"200",
",",
"num_tokens",
"=",
"1000000",
",",
"num_plots",
"=",
"4",
",",
"local_path",
"=",
"DA... | Train an LSI model on a "corpus" of documnets, like tweets
Arguments:
tokenize (callable): Function that returns a sequence of tokens (str) when passed a document (str)
ram (float): Portion of RAM to limit the document generator from consuming before StopIteration
num_docs (int): Num... | [
"Train",
"an",
"LSI",
"model",
"on",
"a",
"corpus",
"of",
"documnets",
"like",
"tweets"
] | 5c0411d2acfbe5b421841072814c9152591c03f7 | https://github.com/totalgood/twip/blob/5c0411d2acfbe5b421841072814c9152591c03f7/twip/train.py#L204-L282 | train | Train an LSI model on a corpus of documnets. |
aloetesting/aloe_webdriver | aloe_webdriver/util.py | string_literal | def string_literal(content):
"""
Choose a string literal that can wrap our string.
If your string contains a ``\'`` the result will be wrapped in ``\"``.
If your string contains a ``\"`` the result will be wrapped in ``\'``.
Cannot currently handle strings which contain both ``\"`` and ``\'``.
... | python | def string_literal(content):
"""
Choose a string literal that can wrap our string.
If your string contains a ``\'`` the result will be wrapped in ``\"``.
If your string contains a ``\"`` the result will be wrapped in ``\'``.
Cannot currently handle strings which contain both ``\"`` and ``\'``.
... | [
"def",
"string_literal",
"(",
"content",
")",
":",
"if",
"'\"'",
"in",
"content",
"and",
"\"'\"",
"in",
"content",
":",
"# there is no way to escape string literal characters in XPath",
"raise",
"ValueError",
"(",
"\"Cannot represent this string in XPath\"",
")",
"if",
"'... | Choose a string literal that can wrap our string.
If your string contains a ``\'`` the result will be wrapped in ``\"``.
If your string contains a ``\"`` the result will be wrapped in ``\'``.
Cannot currently handle strings which contain both ``\"`` and ``\'``. | [
"Choose",
"a",
"string",
"literal",
"that",
"can",
"wrap",
"our",
"string",
"."
] | 65d847da4bdc63f9c015cb19d4efdee87df8ffad | https://github.com/aloetesting/aloe_webdriver/blob/65d847da4bdc63f9c015cb19d4efdee87df8ffad/aloe_webdriver/util.py#L32-L51 | train | Choose a string literal that can wrap our string. |
aloetesting/aloe_webdriver | aloe_webdriver/util.py | element_id_by_label | def element_id_by_label(browser, label):
"""
The ID of an element referenced by a `label`s ``for`` attribute. The label
must be visible.
:param browser: ``world.browser``
:param label: label text to return the referenced element for
Returns: ``for`` attribute value
"""
label = ElementS... | python | def element_id_by_label(browser, label):
"""
The ID of an element referenced by a `label`s ``for`` attribute. The label
must be visible.
:param browser: ``world.browser``
:param label: label text to return the referenced element for
Returns: ``for`` attribute value
"""
label = ElementS... | [
"def",
"element_id_by_label",
"(",
"browser",
",",
"label",
")",
":",
"label",
"=",
"ElementSelector",
"(",
"browser",
",",
"str",
"(",
"'//label[contains(., %s)]'",
"%",
"string_literal",
"(",
"label",
")",
")",
")",
"if",
"not",
"label",
":",
"return",
"Fa... | The ID of an element referenced by a `label`s ``for`` attribute. The label
must be visible.
:param browser: ``world.browser``
:param label: label text to return the referenced element for
Returns: ``for`` attribute value | [
"The",
"ID",
"of",
"an",
"element",
"referenced",
"by",
"a",
"label",
"s",
"for",
"attribute",
".",
"The",
"label",
"must",
"be",
"visible",
"."
] | 65d847da4bdc63f9c015cb19d4efdee87df8ffad | https://github.com/aloetesting/aloe_webdriver/blob/65d847da4bdc63f9c015cb19d4efdee87df8ffad/aloe_webdriver/util.py#L224-L239 | train | Returns the ID of an element referenced by a label. |
aloetesting/aloe_webdriver | aloe_webdriver/util.py | field_xpath | def field_xpath(field, attribute):
"""
Field helper functions to locate select, textarea, and the other
types of input fields (text, checkbox, radio)
:param field: One of the values 'select', 'textarea', 'option', or
'button-element' to match a corresponding HTML element (and to
match a <button... | python | def field_xpath(field, attribute):
"""
Field helper functions to locate select, textarea, and the other
types of input fields (text, checkbox, radio)
:param field: One of the values 'select', 'textarea', 'option', or
'button-element' to match a corresponding HTML element (and to
match a <button... | [
"def",
"field_xpath",
"(",
"field",
",",
"attribute",
")",
":",
"if",
"field",
"in",
"[",
"'select'",
",",
"'textarea'",
"]",
":",
"xpath",
"=",
"'.//{field}[@{attr}=%s]'",
"elif",
"field",
"==",
"'button-role'",
":",
"if",
"attribute",
"==",
"'value'",
":",... | Field helper functions to locate select, textarea, and the other
types of input fields (text, checkbox, radio)
:param field: One of the values 'select', 'textarea', 'option', or
'button-element' to match a corresponding HTML element (and to
match a <button> in the case of 'button-element'). Otherwise a... | [
"Field",
"helper",
"functions",
"to",
"locate",
"select",
"textarea",
"and",
"the",
"other",
"types",
"of",
"input",
"fields",
"(",
"text",
"checkbox",
"radio",
")"
] | 65d847da4bdc63f9c015cb19d4efdee87df8ffad | https://github.com/aloetesting/aloe_webdriver/blob/65d847da4bdc63f9c015cb19d4efdee87df8ffad/aloe_webdriver/util.py#L242-L277 | train | Returns the XPath expression for the given field and attribute. |
aloetesting/aloe_webdriver | aloe_webdriver/util.py | find_button | def find_button(browser, value):
"""
Find a button with the given value.
Searches for the following different kinds of buttons:
<input type="submit">
<input type="reset">
<input type="button">
<input type="image">
<button>
<{a,p,div,span,...} role="button">
... | python | def find_button(browser, value):
"""
Find a button with the given value.
Searches for the following different kinds of buttons:
<input type="submit">
<input type="reset">
<input type="button">
<input type="image">
<button>
<{a,p,div,span,...} role="button">
... | [
"def",
"find_button",
"(",
"browser",
",",
"value",
")",
":",
"field_types",
"=",
"(",
"'submit'",
",",
"'reset'",
",",
"'button-element'",
",",
"'button'",
",",
"'image'",
",",
"'button-role'",
",",
")",
"return",
"reduce",
"(",
"operator",
".",
"add",
",... | Find a button with the given value.
Searches for the following different kinds of buttons:
<input type="submit">
<input type="reset">
<input type="button">
<input type="image">
<button>
<{a,p,div,span,...} role="button">
Returns: an :class:`ElementSelector` | [
"Find",
"a",
"button",
"with",
"the",
"given",
"value",
"."
] | 65d847da4bdc63f9c015cb19d4efdee87df8ffad | https://github.com/aloetesting/aloe_webdriver/blob/65d847da4bdc63f9c015cb19d4efdee87df8ffad/aloe_webdriver/util.py#L280-L308 | train | Find a button with the given value. |
aloetesting/aloe_webdriver | aloe_webdriver/util.py | find_field | def find_field(browser, field_type, value):
"""
Locate an input field.
:param browser: ``world.browser``
:param string field_type: a field type (i.e. `button`)
:param string value: an id, name or label
This first looks for `value` as the id of the element, else
the name of the element, els... | python | def find_field(browser, field_type, value):
"""
Locate an input field.
:param browser: ``world.browser``
:param string field_type: a field type (i.e. `button`)
:param string value: an id, name or label
This first looks for `value` as the id of the element, else
the name of the element, els... | [
"def",
"find_field",
"(",
"browser",
",",
"field_type",
",",
"value",
")",
":",
"return",
"find_field_by_id",
"(",
"browser",
",",
"field_type",
",",
"value",
")",
"+",
"find_field_by_name",
"(",
"browser",
",",
"field_type",
",",
"value",
")",
"+",
"find_fi... | Locate an input field.
:param browser: ``world.browser``
:param string field_type: a field type (i.e. `button`)
:param string value: an id, name or label
This first looks for `value` as the id of the element, else
the name of the element, else as a label for the element.
Returns: an :class:`E... | [
"Locate",
"an",
"input",
"field",
"."
] | 65d847da4bdc63f9c015cb19d4efdee87df8ffad | https://github.com/aloetesting/aloe_webdriver/blob/65d847da4bdc63f9c015cb19d4efdee87df8ffad/aloe_webdriver/util.py#L331-L346 | train | Locate an input field. |
aloetesting/aloe_webdriver | aloe_webdriver/util.py | find_field_by_id | def find_field_by_id(browser, field_type, id):
"""
Locate the control input with the given ``id``.
:param browser: ``world.browser``
:param string field_type: a field type (i.e. `button`)
:param string id: ``id`` attribute
Returns: an :class:`ElementSelector`
"""
return ElementSelector... | python | def find_field_by_id(browser, field_type, id):
"""
Locate the control input with the given ``id``.
:param browser: ``world.browser``
:param string field_type: a field type (i.e. `button`)
:param string id: ``id`` attribute
Returns: an :class:`ElementSelector`
"""
return ElementSelector... | [
"def",
"find_field_by_id",
"(",
"browser",
",",
"field_type",
",",
"id",
")",
":",
"return",
"ElementSelector",
"(",
"browser",
",",
"xpath",
"=",
"field_xpath",
"(",
"field_type",
",",
"'id'",
")",
"%",
"string_literal",
"(",
"id",
")",
",",
"filter_display... | Locate the control input with the given ``id``.
:param browser: ``world.browser``
:param string field_type: a field type (i.e. `button`)
:param string id: ``id`` attribute
Returns: an :class:`ElementSelector` | [
"Locate",
"the",
"control",
"input",
"with",
"the",
"given",
"id",
"."
] | 65d847da4bdc63f9c015cb19d4efdee87df8ffad | https://github.com/aloetesting/aloe_webdriver/blob/65d847da4bdc63f9c015cb19d4efdee87df8ffad/aloe_webdriver/util.py#L369-L383 | train | Locate the control input with the given id. |
aloetesting/aloe_webdriver | aloe_webdriver/util.py | find_field_by_name | def find_field_by_name(browser, field_type, name):
"""
Locate the control input with the given ``name``.
:param browser: ``world.browser``
:param string field_type: a field type (i.e. `button`)
:param string name: ``name`` attribute
Returns: an :class:`ElementSelector`
"""
return Eleme... | python | def find_field_by_name(browser, field_type, name):
"""
Locate the control input with the given ``name``.
:param browser: ``world.browser``
:param string field_type: a field type (i.e. `button`)
:param string name: ``name`` attribute
Returns: an :class:`ElementSelector`
"""
return Eleme... | [
"def",
"find_field_by_name",
"(",
"browser",
",",
"field_type",
",",
"name",
")",
":",
"return",
"ElementSelector",
"(",
"browser",
",",
"field_xpath",
"(",
"field_type",
",",
"'name'",
")",
"%",
"string_literal",
"(",
"name",
")",
",",
"filter_displayed",
"="... | Locate the control input with the given ``name``.
:param browser: ``world.browser``
:param string field_type: a field type (i.e. `button`)
:param string name: ``name`` attribute
Returns: an :class:`ElementSelector` | [
"Locate",
"the",
"control",
"input",
"with",
"the",
"given",
"name",
"."
] | 65d847da4bdc63f9c015cb19d4efdee87df8ffad | https://github.com/aloetesting/aloe_webdriver/blob/65d847da4bdc63f9c015cb19d4efdee87df8ffad/aloe_webdriver/util.py#L386-L401 | train | Locate the control input with the given name. |
aloetesting/aloe_webdriver | aloe_webdriver/util.py | find_field_by_value | def find_field_by_value(browser, field_type, name):
"""
Locate the control input with the given ``value``. Useful for buttons.
:param browser: ``world.browser``
:param string field_type: a field type (i.e. `button`)
:param string name: ``value`` attribute
Returns: an :class:`ElementSelector`
... | python | def find_field_by_value(browser, field_type, name):
"""
Locate the control input with the given ``value``. Useful for buttons.
:param browser: ``world.browser``
:param string field_type: a field type (i.e. `button`)
:param string name: ``value`` attribute
Returns: an :class:`ElementSelector`
... | [
"def",
"find_field_by_value",
"(",
"browser",
",",
"field_type",
",",
"name",
")",
":",
"xpath",
"=",
"field_xpath",
"(",
"field_type",
",",
"'value'",
")",
"%",
"string_literal",
"(",
"name",
")",
"elems",
"=",
"ElementSelector",
"(",
"browser",
",",
"xpath... | Locate the control input with the given ``value``. Useful for buttons.
:param browser: ``world.browser``
:param string field_type: a field type (i.e. `button`)
:param string name: ``value`` attribute
Returns: an :class:`ElementSelector` | [
"Locate",
"the",
"control",
"input",
"with",
"the",
"given",
"value",
".",
"Useful",
"for",
"buttons",
"."
] | 65d847da4bdc63f9c015cb19d4efdee87df8ffad | https://github.com/aloetesting/aloe_webdriver/blob/65d847da4bdc63f9c015cb19d4efdee87df8ffad/aloe_webdriver/util.py#L404-L432 | train | Locate the control input with the given value. Useful for buttons. |
aloetesting/aloe_webdriver | aloe_webdriver/util.py | find_field_by_label | def find_field_by_label(browser, field_type, label):
"""
Locate the control input that has a label pointing to it.
:param browser: ``world.browser``
:param string field_type: a field type (i.e. `button`)
:param string label: label text
This will first locate the label element that has a label ... | python | def find_field_by_label(browser, field_type, label):
"""
Locate the control input that has a label pointing to it.
:param browser: ``world.browser``
:param string field_type: a field type (i.e. `button`)
:param string label: label text
This will first locate the label element that has a label ... | [
"def",
"find_field_by_label",
"(",
"browser",
",",
"field_type",
",",
"label",
")",
":",
"return",
"ElementSelector",
"(",
"browser",
",",
"xpath",
"=",
"field_xpath",
"(",
"field_type",
",",
"'id'",
")",
"%",
"'//label[contains(., {0})]/@for'",
".",
"format",
"... | Locate the control input that has a label pointing to it.
:param browser: ``world.browser``
:param string field_type: a field type (i.e. `button`)
:param string label: label text
This will first locate the label element that has a label of the given
name. It then pulls the id out of the 'for' attr... | [
"Locate",
"the",
"control",
"input",
"that",
"has",
"a",
"label",
"pointing",
"to",
"it",
"."
] | 65d847da4bdc63f9c015cb19d4efdee87df8ffad | https://github.com/aloetesting/aloe_webdriver/blob/65d847da4bdc63f9c015cb19d4efdee87df8ffad/aloe_webdriver/util.py#L435-L456 | train | Locate the control input that has a label pointing to it. |
aloetesting/aloe_webdriver | aloe_webdriver/util.py | option_in_select | def option_in_select(browser, select_name, option):
"""
Returns the Element specified by @option or None
Looks at the real <select> not the select2 widget, since that doesn't
create the DOM until we click on it.
"""
select = find_field(browser, 'select', select_name)
assert select, "Cannot... | python | def option_in_select(browser, select_name, option):
"""
Returns the Element specified by @option or None
Looks at the real <select> not the select2 widget, since that doesn't
create the DOM until we click on it.
"""
select = find_field(browser, 'select', select_name)
assert select, "Cannot... | [
"def",
"option_in_select",
"(",
"browser",
",",
"select_name",
",",
"option",
")",
":",
"select",
"=",
"find_field",
"(",
"browser",
",",
"'select'",
",",
"select_name",
")",
"assert",
"select",
",",
"\"Cannot find a '{}' select.\"",
".",
"format",
"(",
"select_... | Returns the Element specified by @option or None
Looks at the real <select> not the select2 widget, since that doesn't
create the DOM until we click on it. | [
"Returns",
"the",
"Element",
"specified",
"by",
"@option",
"or",
"None"
] | 65d847da4bdc63f9c015cb19d4efdee87df8ffad | https://github.com/aloetesting/aloe_webdriver/blob/65d847da4bdc63f9c015cb19d4efdee87df8ffad/aloe_webdriver/util.py#L459-L474 | train | Returns the Element specified by option in a select2 widget. |
aloetesting/aloe_webdriver | aloe_webdriver/util.py | wait_for | def wait_for(func):
"""
A decorator to invoke a function, retrying on assertion errors for a
specified time interval.
Adds a kwarg `timeout` to `func` which is a number of seconds to try
for (default 15).
"""
@wraps(func)
def wrapped(*args, **kwargs):
timeout = kwargs.pop('time... | python | def wait_for(func):
"""
A decorator to invoke a function, retrying on assertion errors for a
specified time interval.
Adds a kwarg `timeout` to `func` which is a number of seconds to try
for (default 15).
"""
@wraps(func)
def wrapped(*args, **kwargs):
timeout = kwargs.pop('time... | [
"def",
"wait_for",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"wrapped",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"timeout",
"=",
"kwargs",
".",
"pop",
"(",
"'timeout'",
",",
"TIMEOUT",
")",
"start",
"=",
"None",
"w... | A decorator to invoke a function, retrying on assertion errors for a
specified time interval.
Adds a kwarg `timeout` to `func` which is a number of seconds to try
for (default 15). | [
"A",
"decorator",
"to",
"invoke",
"a",
"function",
"retrying",
"on",
"assertion",
"errors",
"for",
"a",
"specified",
"time",
"interval",
"."
] | 65d847da4bdc63f9c015cb19d4efdee87df8ffad | https://github.com/aloetesting/aloe_webdriver/blob/65d847da4bdc63f9c015cb19d4efdee87df8ffad/aloe_webdriver/util.py#L481-L513 | train | A decorator to invoke a function retrying on assertion errors for a
specified time interval. |
aloetesting/aloe_webdriver | aloe_webdriver/util.py | ElementSelector.filter | def filter(self, displayed=False, enabled=False):
"""
Filter elements by visibility and enabled status.
:param displayed: whether to filter out invisible elements
:param enabled: whether to filter out disabled elements
Returns: an :class:`ElementSelector`
"""
i... | python | def filter(self, displayed=False, enabled=False):
"""
Filter elements by visibility and enabled status.
:param displayed: whether to filter out invisible elements
:param enabled: whether to filter out disabled elements
Returns: an :class:`ElementSelector`
"""
i... | [
"def",
"filter",
"(",
"self",
",",
"displayed",
"=",
"False",
",",
"enabled",
"=",
"False",
")",
":",
"if",
"self",
".",
"evaluated",
":",
"# Filter elements one by one",
"result",
"=",
"self",
"if",
"displayed",
":",
"result",
"=",
"ElementSelector",
"(",
... | Filter elements by visibility and enabled status.
:param displayed: whether to filter out invisible elements
:param enabled: whether to filter out disabled elements
Returns: an :class:`ElementSelector` | [
"Filter",
"elements",
"by",
"visibility",
"and",
"enabled",
"status",
"."
] | 65d847da4bdc63f9c015cb19d4efdee87df8ffad | https://github.com/aloetesting/aloe_webdriver/blob/65d847da4bdc63f9c015cb19d4efdee87df8ffad/aloe_webdriver/util.py#L107-L140 | train | Filter elements by visibility and enabled status. |
aloetesting/aloe_webdriver | aloe_webdriver/util.py | ElementSelector._select | def _select(self):
"""Fetch the elements from the browser."""
for element in self.browser.find_elements_by_xpath(self.xpath):
if self.filter_displayed:
if not element.is_displayed():
continue
if self.filter_enabled:
if not ele... | python | def _select(self):
"""Fetch the elements from the browser."""
for element in self.browser.find_elements_by_xpath(self.xpath):
if self.filter_displayed:
if not element.is_displayed():
continue
if self.filter_enabled:
if not ele... | [
"def",
"_select",
"(",
"self",
")",
":",
"for",
"element",
"in",
"self",
".",
"browser",
".",
"find_elements_by_xpath",
"(",
"self",
".",
"xpath",
")",
":",
"if",
"self",
".",
"filter_displayed",
":",
"if",
"not",
"element",
".",
"is_displayed",
"(",
")"... | Fetch the elements from the browser. | [
"Fetch",
"the",
"elements",
"from",
"the",
"browser",
"."
] | 65d847da4bdc63f9c015cb19d4efdee87df8ffad | https://github.com/aloetesting/aloe_webdriver/blob/65d847da4bdc63f9c015cb19d4efdee87df8ffad/aloe_webdriver/util.py#L142-L154 | train | Fetch the elements from the browser. |
aloetesting/aloe_webdriver | aloe_webdriver/util.py | ElementSelector._elements | def _elements(self):
"""
The cached list of elements.
"""
if not self.evaluated:
setattr(self, '_elements_cached', list(self._select()))
return self._elements_cached | python | def _elements(self):
"""
The cached list of elements.
"""
if not self.evaluated:
setattr(self, '_elements_cached', list(self._select()))
return self._elements_cached | [
"def",
"_elements",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"evaluated",
":",
"setattr",
"(",
"self",
",",
"'_elements_cached'",
",",
"list",
"(",
"self",
".",
"_select",
"(",
")",
")",
")",
"return",
"self",
".",
"_elements_cached"
] | The cached list of elements. | [
"The",
"cached",
"list",
"of",
"elements",
"."
] | 65d847da4bdc63f9c015cb19d4efdee87df8ffad | https://github.com/aloetesting/aloe_webdriver/blob/65d847da4bdc63f9c015cb19d4efdee87df8ffad/aloe_webdriver/util.py#L156-L162 | train | The list of elements in the cache. |
dingusdk/PythonIhcSdk | ihcsdk/ihccontroller.py | IHCController.authenticate | def authenticate(self) -> bool:
"""Authenticate and enable the registered notifications"""
with IHCController._mutex:
if not self.client.authenticate(self._username, self._password):
return False
if self._ihcevents:
self.client.enable_runtime_notif... | python | def authenticate(self) -> bool:
"""Authenticate and enable the registered notifications"""
with IHCController._mutex:
if not self.client.authenticate(self._username, self._password):
return False
if self._ihcevents:
self.client.enable_runtime_notif... | [
"def",
"authenticate",
"(",
"self",
")",
"->",
"bool",
":",
"with",
"IHCController",
".",
"_mutex",
":",
"if",
"not",
"self",
".",
"client",
".",
"authenticate",
"(",
"self",
".",
"_username",
",",
"self",
".",
"_password",
")",
":",
"return",
"False",
... | Authenticate and enable the registered notifications | [
"Authenticate",
"and",
"enable",
"the",
"registered",
"notifications"
] | 7e2067e009fe7600b49f30bff1cf91dc72fc891e | https://github.com/dingusdk/PythonIhcSdk/blob/7e2067e009fe7600b49f30bff1cf91dc72fc891e/ihcsdk/ihccontroller.py#L31-L39 | train | Authenticate and enable the registered notifications |
dingusdk/PythonIhcSdk | ihcsdk/ihccontroller.py | IHCController.get_runtime_value | def get_runtime_value(self, ihcid: int):
""" Get runtime value with re-authenticate if needed"""
if self.client.get_runtime_value(ihcid):
return True
self.re_authenticate()
return self.client.get_runtime_value(ihcid) | python | def get_runtime_value(self, ihcid: int):
""" Get runtime value with re-authenticate if needed"""
if self.client.get_runtime_value(ihcid):
return True
self.re_authenticate()
return self.client.get_runtime_value(ihcid) | [
"def",
"get_runtime_value",
"(",
"self",
",",
"ihcid",
":",
"int",
")",
":",
"if",
"self",
".",
"client",
".",
"get_runtime_value",
"(",
"ihcid",
")",
":",
"return",
"True",
"self",
".",
"re_authenticate",
"(",
")",
"return",
"self",
".",
"client",
".",
... | Get runtime value with re-authenticate if needed | [
"Get",
"runtime",
"value",
"with",
"re",
"-",
"authenticate",
"if",
"needed"
] | 7e2067e009fe7600b49f30bff1cf91dc72fc891e | https://github.com/dingusdk/PythonIhcSdk/blob/7e2067e009fe7600b49f30bff1cf91dc72fc891e/ihcsdk/ihccontroller.py#L47-L52 | train | Get runtime value with re - authenticate if needed |
dingusdk/PythonIhcSdk | ihcsdk/ihccontroller.py | IHCController.set_runtime_value_bool | def set_runtime_value_bool(self, ihcid: int, value: bool) -> bool:
""" Set bool runtime value with re-authenticate if needed"""
if self.client.set_runtime_value_bool(ihcid, value):
return True
self.re_authenticate()
return self.client.set_runtime_value_bool(ihcid, value) | python | def set_runtime_value_bool(self, ihcid: int, value: bool) -> bool:
""" Set bool runtime value with re-authenticate if needed"""
if self.client.set_runtime_value_bool(ihcid, value):
return True
self.re_authenticate()
return self.client.set_runtime_value_bool(ihcid, value) | [
"def",
"set_runtime_value_bool",
"(",
"self",
",",
"ihcid",
":",
"int",
",",
"value",
":",
"bool",
")",
"->",
"bool",
":",
"if",
"self",
".",
"client",
".",
"set_runtime_value_bool",
"(",
"ihcid",
",",
"value",
")",
":",
"return",
"True",
"self",
".",
... | Set bool runtime value with re-authenticate if needed | [
"Set",
"bool",
"runtime",
"value",
"with",
"re",
"-",
"authenticate",
"if",
"needed"
] | 7e2067e009fe7600b49f30bff1cf91dc72fc891e | https://github.com/dingusdk/PythonIhcSdk/blob/7e2067e009fe7600b49f30bff1cf91dc72fc891e/ihcsdk/ihccontroller.py#L54-L59 | train | Set bool runtime value with re - authenticate if needed |
dingusdk/PythonIhcSdk | ihcsdk/ihccontroller.py | IHCController.set_runtime_value_int | def set_runtime_value_int(self, ihcid: int, value: int) -> bool:
""" Set integer runtime value with re-authenticate if needed"""
if self.client.set_runtime_value_int(ihcid, value):
return True
self.re_authenticate()
return self.client.set_runtime_value_int(ihcid, value) | python | def set_runtime_value_int(self, ihcid: int, value: int) -> bool:
""" Set integer runtime value with re-authenticate if needed"""
if self.client.set_runtime_value_int(ihcid, value):
return True
self.re_authenticate()
return self.client.set_runtime_value_int(ihcid, value) | [
"def",
"set_runtime_value_int",
"(",
"self",
",",
"ihcid",
":",
"int",
",",
"value",
":",
"int",
")",
"->",
"bool",
":",
"if",
"self",
".",
"client",
".",
"set_runtime_value_int",
"(",
"ihcid",
",",
"value",
")",
":",
"return",
"True",
"self",
".",
"re... | Set integer runtime value with re-authenticate if needed | [
"Set",
"integer",
"runtime",
"value",
"with",
"re",
"-",
"authenticate",
"if",
"needed"
] | 7e2067e009fe7600b49f30bff1cf91dc72fc891e | https://github.com/dingusdk/PythonIhcSdk/blob/7e2067e009fe7600b49f30bff1cf91dc72fc891e/ihcsdk/ihccontroller.py#L61-L66 | train | Set integer runtime value with re - authenticate if needed |
dingusdk/PythonIhcSdk | ihcsdk/ihccontroller.py | IHCController.set_runtime_value_float | def set_runtime_value_float(self, ihcid: int, value: float) -> bool:
""" Set float runtime value with re-authenticate if needed"""
if self.client.set_runtime_value_float(ihcid, value):
return True
self.re_authenticate()
return self.client.set_runtime_value_float(ihcid, value) | python | def set_runtime_value_float(self, ihcid: int, value: float) -> bool:
""" Set float runtime value with re-authenticate if needed"""
if self.client.set_runtime_value_float(ihcid, value):
return True
self.re_authenticate()
return self.client.set_runtime_value_float(ihcid, value) | [
"def",
"set_runtime_value_float",
"(",
"self",
",",
"ihcid",
":",
"int",
",",
"value",
":",
"float",
")",
"->",
"bool",
":",
"if",
"self",
".",
"client",
".",
"set_runtime_value_float",
"(",
"ihcid",
",",
"value",
")",
":",
"return",
"True",
"self",
".",... | Set float runtime value with re-authenticate if needed | [
"Set",
"float",
"runtime",
"value",
"with",
"re",
"-",
"authenticate",
"if",
"needed"
] | 7e2067e009fe7600b49f30bff1cf91dc72fc891e | https://github.com/dingusdk/PythonIhcSdk/blob/7e2067e009fe7600b49f30bff1cf91dc72fc891e/ihcsdk/ihccontroller.py#L68-L73 | train | Set float runtime value with re - authenticate if needed |
dingusdk/PythonIhcSdk | ihcsdk/ihccontroller.py | IHCController.get_project | def get_project(self) -> str:
""" Get the ihc project and make sure controller is ready before"""
with IHCController._mutex:
if self._project is None:
if self.client.get_state() != IHCSTATE_READY:
ready = self.client.wait_for_state_change(IHCSTATE_READY,
... | python | def get_project(self) -> str:
""" Get the ihc project and make sure controller is ready before"""
with IHCController._mutex:
if self._project is None:
if self.client.get_state() != IHCSTATE_READY:
ready = self.client.wait_for_state_change(IHCSTATE_READY,
... | [
"def",
"get_project",
"(",
"self",
")",
"->",
"str",
":",
"with",
"IHCController",
".",
"_mutex",
":",
"if",
"self",
".",
"_project",
"is",
"None",
":",
"if",
"self",
".",
"client",
".",
"get_state",
"(",
")",
"!=",
"IHCSTATE_READY",
":",
"ready",
"=",... | Get the ihc project and make sure controller is ready before | [
"Get",
"the",
"ihc",
"project",
"and",
"make",
"sure",
"controller",
"is",
"ready",
"before"
] | 7e2067e009fe7600b49f30bff1cf91dc72fc891e | https://github.com/dingusdk/PythonIhcSdk/blob/7e2067e009fe7600b49f30bff1cf91dc72fc891e/ihcsdk/ihccontroller.py#L75-L85 | train | Get the ihc project and make sure controller is ready before |
dingusdk/PythonIhcSdk | ihcsdk/ihccontroller.py | IHCController.add_notify_event | def add_notify_event(self, resourceid: int, callback, delayed=False):
""" Add a notify callback for a specified resource id
If delayed is set to true the enable request will be send from the
notofication thread
"""
with IHCController._mutex:
if resourceid in self._ihc... | python | def add_notify_event(self, resourceid: int, callback, delayed=False):
""" Add a notify callback for a specified resource id
If delayed is set to true the enable request will be send from the
notofication thread
"""
with IHCController._mutex:
if resourceid in self._ihc... | [
"def",
"add_notify_event",
"(",
"self",
",",
"resourceid",
":",
"int",
",",
"callback",
",",
"delayed",
"=",
"False",
")",
":",
"with",
"IHCController",
".",
"_mutex",
":",
"if",
"resourceid",
"in",
"self",
".",
"_ihcevents",
":",
"self",
".",
"_ihcevents"... | Add a notify callback for a specified resource id
If delayed is set to true the enable request will be send from the
notofication thread | [
"Add",
"a",
"notify",
"callback",
"for",
"a",
"specified",
"resource",
"id",
"If",
"delayed",
"is",
"set",
"to",
"true",
"the",
"enable",
"request",
"will",
"be",
"send",
"from",
"the",
"notofication",
"thread"
] | 7e2067e009fe7600b49f30bff1cf91dc72fc891e | https://github.com/dingusdk/PythonIhcSdk/blob/7e2067e009fe7600b49f30bff1cf91dc72fc891e/ihcsdk/ihccontroller.py#L87-L105 | train | Add a callback to be called when a resource is added to the notofication queue. |
dingusdk/PythonIhcSdk | ihcsdk/ihccontroller.py | IHCController._notify_fn | def _notify_fn(self):
"""The notify thread function."""
self._notifyrunning = True
while self._notifyrunning:
try:
with IHCController._mutex:
# Are there are any new ids to be added?
if self._newnotifyids:
... | python | def _notify_fn(self):
"""The notify thread function."""
self._notifyrunning = True
while self._notifyrunning:
try:
with IHCController._mutex:
# Are there are any new ids to be added?
if self._newnotifyids:
... | [
"def",
"_notify_fn",
"(",
"self",
")",
":",
"self",
".",
"_notifyrunning",
"=",
"True",
"while",
"self",
".",
"_notifyrunning",
":",
"try",
":",
"with",
"IHCController",
".",
"_mutex",
":",
"# Are there are any new ids to be added?",
"if",
"self",
".",
"_newnoti... | The notify thread function. | [
"The",
"notify",
"thread",
"function",
"."
] | 7e2067e009fe7600b49f30bff1cf91dc72fc891e | https://github.com/dingusdk/PythonIhcSdk/blob/7e2067e009fe7600b49f30bff1cf91dc72fc891e/ihcsdk/ihccontroller.py#L107-L129 | train | The notify thread function. |
dingusdk/PythonIhcSdk | ihcsdk/ihccontroller.py | IHCController.re_authenticate | def re_authenticate(self, notify: bool=False) -> bool:
"""Authenticate again after failure.
Keep trying with 10 sec interval. If called from the notify thread
we will not have a timeout, but will end if the notify thread has
been cancled.
Will return True if authentic... | python | def re_authenticate(self, notify: bool=False) -> bool:
"""Authenticate again after failure.
Keep trying with 10 sec interval. If called from the notify thread
we will not have a timeout, but will end if the notify thread has
been cancled.
Will return True if authentic... | [
"def",
"re_authenticate",
"(",
"self",
",",
"notify",
":",
"bool",
"=",
"False",
")",
"->",
"bool",
":",
"timeout",
"=",
"datetime",
".",
"now",
"(",
")",
"+",
"timedelta",
"(",
"seconds",
"=",
"self",
".",
"reauthenticatetimeout",
")",
"while",
"True",
... | Authenticate again after failure.
Keep trying with 10 sec interval. If called from the notify thread
we will not have a timeout, but will end if the notify thread has
been cancled.
Will return True if authentication was successful. | [
"Authenticate",
"again",
"after",
"failure",
".",
"Keep",
"trying",
"with",
"10",
"sec",
"interval",
".",
"If",
"called",
"from",
"the",
"notify",
"thread",
"we",
"will",
"not",
"have",
"a",
"timeout",
"but",
"will",
"end",
"if",
"the",
"notify",
"thread",... | 7e2067e009fe7600b49f30bff1cf91dc72fc891e | https://github.com/dingusdk/PythonIhcSdk/blob/7e2067e009fe7600b49f30bff1cf91dc72fc891e/ihcsdk/ihccontroller.py#L131-L151 | train | Authenticate again after failure. |
totalgood/twip | docs/notebooks/shakescorpus.py | generate_lines | def generate_lines(input_file,
start=0,
stop=float('inf')):
"""Generate (yield) lines in a gzipped file (*.txt.gz) one line at a time"""
with gzip.GzipFile(input_file, 'rU') as f:
for i, line in enumerate(f):
if i < start:
continue
... | python | def generate_lines(input_file,
start=0,
stop=float('inf')):
"""Generate (yield) lines in a gzipped file (*.txt.gz) one line at a time"""
with gzip.GzipFile(input_file, 'rU') as f:
for i, line in enumerate(f):
if i < start:
continue
... | [
"def",
"generate_lines",
"(",
"input_file",
",",
"start",
"=",
"0",
",",
"stop",
"=",
"float",
"(",
"'inf'",
")",
")",
":",
"with",
"gzip",
".",
"GzipFile",
"(",
"input_file",
",",
"'rU'",
")",
"as",
"f",
":",
"for",
"i",
",",
"line",
"in",
"enumer... | Generate (yield) lines in a gzipped file (*.txt.gz) one line at a time | [
"Generate",
"(",
"yield",
")",
"lines",
"in",
"a",
"gzipped",
"file",
"(",
"*",
".",
"txt",
".",
"gz",
")",
"one",
"line",
"at",
"a",
"time"
] | 5c0411d2acfbe5b421841072814c9152591c03f7 | https://github.com/totalgood/twip/blob/5c0411d2acfbe5b421841072814c9152591c03f7/docs/notebooks/shakescorpus.py#L52-L62 | train | Generator for generating lines in a gzipped file. |
totalgood/twip | docs/notebooks/shakescorpus.py | segment_shakespeare_works | def segment_shakespeare_works(input_file=PATH_SHAKESPEARE, verbose=False):
"""Find start and end of each volume within _Complete Works of William Shakespeare_
"""
works = [{}]
meta = {}
j = 0
for i, line in enumerate(generate_lines(input_file=input_file)):
if 'title' not in meta:
... | python | def segment_shakespeare_works(input_file=PATH_SHAKESPEARE, verbose=False):
"""Find start and end of each volume within _Complete Works of William Shakespeare_
"""
works = [{}]
meta = {}
j = 0
for i, line in enumerate(generate_lines(input_file=input_file)):
if 'title' not in meta:
... | [
"def",
"segment_shakespeare_works",
"(",
"input_file",
"=",
"PATH_SHAKESPEARE",
",",
"verbose",
"=",
"False",
")",
":",
"works",
"=",
"[",
"{",
"}",
"]",
"meta",
"=",
"{",
"}",
"j",
"=",
"0",
"for",
"i",
",",
"line",
"in",
"enumerate",
"(",
"generate_l... | Find start and end of each volume within _Complete Works of William Shakespeare_ | [
"Find",
"start",
"and",
"end",
"of",
"each",
"volume",
"within",
"_Complete",
"Works",
"of",
"William",
"Shakespeare_"
] | 5c0411d2acfbe5b421841072814c9152591c03f7 | https://github.com/totalgood/twip/blob/5c0411d2acfbe5b421841072814c9152591c03f7/docs/notebooks/shakescorpus.py#L65-L123 | train | Generate a list of _Complete Works of William Shakespeare_ objects. |
totalgood/twip | docs/notebooks/shakescorpus.py | ShakesCorpus.get_texts | def get_texts(self, metadata=None):
"""Iterate over the lines of "The Complete Works of William Shakespeare".
This yields lists of strings (**texts**) rather than vectors (vectorized bags-of-words).
And the **texts** yielded are lines rather than entire plays or sonnets.
If you want vec... | python | def get_texts(self, metadata=None):
"""Iterate over the lines of "The Complete Works of William Shakespeare".
This yields lists of strings (**texts**) rather than vectors (vectorized bags-of-words).
And the **texts** yielded are lines rather than entire plays or sonnets.
If you want vec... | [
"def",
"get_texts",
"(",
"self",
",",
"metadata",
"=",
"None",
")",
":",
"if",
"metadata",
"is",
"None",
":",
"metadata",
"=",
"self",
".",
"metadata",
"self",
".",
"input_file",
"=",
"gzip",
".",
"GzipFile",
"(",
"self",
".",
"input_file_path",
")",
"... | Iterate over the lines of "The Complete Works of William Shakespeare".
This yields lists of strings (**texts**) rather than vectors (vectorized bags-of-words).
And the **texts** yielded are lines rather than entire plays or sonnets.
If you want vectors, use the corpus interface instead of this ... | [
"Iterate",
"over",
"the",
"lines",
"of",
"The",
"Complete",
"Works",
"of",
"William",
"Shakespeare",
"."
] | 5c0411d2acfbe5b421841072814c9152591c03f7 | https://github.com/totalgood/twip/blob/5c0411d2acfbe5b421841072814c9152591c03f7/docs/notebooks/shakescorpus.py#L169-L207 | train | Iterate over the lines of The Complete Works of William Shakespeare. |
totalgood/twip | twip/scripts/clean.py | dropna | def dropna(df, nonnull_rows=100, nonnull_cols=50, nanstrs=('nan', 'NaN', ''), nullstr=''):
"""Drop columns/rows with too many NaNs and replace NaNs in columns of strings with ''
>>> df = pd.DataFrame([['nan',np.nan,'str'],[np.nan,0.1,'and'],[2.0,None,np.nan]])
>>> dropna(df)
Empty DataFrame
Columns... | python | def dropna(df, nonnull_rows=100, nonnull_cols=50, nanstrs=('nan', 'NaN', ''), nullstr=''):
"""Drop columns/rows with too many NaNs and replace NaNs in columns of strings with ''
>>> df = pd.DataFrame([['nan',np.nan,'str'],[np.nan,0.1,'and'],[2.0,None,np.nan]])
>>> dropna(df)
Empty DataFrame
Columns... | [
"def",
"dropna",
"(",
"df",
",",
"nonnull_rows",
"=",
"100",
",",
"nonnull_cols",
"=",
"50",
",",
"nanstrs",
"=",
"(",
"'nan'",
",",
"'NaN'",
",",
"''",
")",
",",
"nullstr",
"=",
"''",
")",
":",
"if",
"0",
"<",
"nonnull_rows",
"<",
"1",
":",
"non... | Drop columns/rows with too many NaNs and replace NaNs in columns of strings with ''
>>> df = pd.DataFrame([['nan',np.nan,'str'],[np.nan,0.1,'and'],[2.0,None,np.nan]])
>>> dropna(df)
Empty DataFrame
Columns: []
Index: []
>>> dropna(df, nonnull_cols=0, nonnull_rows=0)
0 1 2
0 ... | [
"Drop",
"columns",
"/",
"rows",
"with",
"too",
"many",
"NaNs",
"and",
"replace",
"NaNs",
"in",
"columns",
"of",
"strings",
"with"
] | 5c0411d2acfbe5b421841072814c9152591c03f7 | https://github.com/totalgood/twip/blob/5c0411d2acfbe5b421841072814c9152591c03f7/twip/scripts/clean.py#L107-L146 | train | Drop columns and rows with too many NaNs and replace NaNs in columns of strings with '' |
totalgood/twip | twip/scripts/clean.py | normalize | def normalize(df):
"""Flatten compound columns (DataFrames within columns) into top level columns"""
# in ipython notebook, explore and describe the DataFrame columns
print('Of the {} columns, {} are actually DataFrames'.format(len(df.columns), sum([not isinstance(df[col], pd.Series) for col in df.columns])... | python | def normalize(df):
"""Flatten compound columns (DataFrames within columns) into top level columns"""
# in ipython notebook, explore and describe the DataFrame columns
print('Of the {} columns, {} are actually DataFrames'.format(len(df.columns), sum([not isinstance(df[col], pd.Series) for col in df.columns])... | [
"def",
"normalize",
"(",
"df",
")",
":",
"# in ipython notebook, explore and describe the DataFrame columns",
"print",
"(",
"'Of the {} columns, {} are actually DataFrames'",
".",
"format",
"(",
"len",
"(",
"df",
".",
"columns",
")",
",",
"sum",
"(",
"[",
"not",
"isin... | Flatten compound columns (DataFrames within columns) into top level columns | [
"Flatten",
"compound",
"columns",
"(",
"DataFrames",
"within",
"columns",
")",
"into",
"top",
"level",
"columns"
] | 5c0411d2acfbe5b421841072814c9152591c03f7 | https://github.com/totalgood/twip/blob/5c0411d2acfbe5b421841072814c9152591c03f7/twip/scripts/clean.py#L149-L173 | train | Flatten compound columns ( DataFrames within columns ) into top level columns |
totalgood/twip | twip/scripts/clean.py | encode | def encode(df, encoding='utf8', verbosity=1):
"""If you try to encode each element individually with python, this would take days!"""
if verbosity > 0:
# pbar_i = 0
pbar = progressbar.ProgressBar(maxval=df.shape[1])
pbar.start()
# encode strings as UTF-8 so they'll work in python2 an... | python | def encode(df, encoding='utf8', verbosity=1):
"""If you try to encode each element individually with python, this would take days!"""
if verbosity > 0:
# pbar_i = 0
pbar = progressbar.ProgressBar(maxval=df.shape[1])
pbar.start()
# encode strings as UTF-8 so they'll work in python2 an... | [
"def",
"encode",
"(",
"df",
",",
"encoding",
"=",
"'utf8'",
",",
"verbosity",
"=",
"1",
")",
":",
"if",
"verbosity",
">",
"0",
":",
"# pbar_i = 0",
"pbar",
"=",
"progressbar",
".",
"ProgressBar",
"(",
"maxval",
"=",
"df",
".",
"shape",
"[",
"1",
"]",... | If you try to encode each element individually with python, this would take days! | [
"If",
"you",
"try",
"to",
"encode",
"each",
"element",
"individually",
"with",
"python",
"this",
"would",
"take",
"days!"
] | 5c0411d2acfbe5b421841072814c9152591c03f7 | https://github.com/totalgood/twip/blob/5c0411d2acfbe5b421841072814c9152591c03f7/twip/scripts/clean.py#L176-L223 | train | Encode each element of a dataframe in a single thread. |
totalgood/twip | twip/scripts/clean.py | run | def run(verbosity=1):
"""Load all_tweets.csv and run normalize, dropna, encode before dumping to cleaned_tweets.csv.gz
Many columns have "mixed type" to `read_csv` should set `low_memory` to False to ensure they're loaded accurately
>>> df2 = pd.read_csv(os.path.join(DATA_PATH, 'cleaned_tweets.csv.gz'), in... | python | def run(verbosity=1):
"""Load all_tweets.csv and run normalize, dropna, encode before dumping to cleaned_tweets.csv.gz
Many columns have "mixed type" to `read_csv` should set `low_memory` to False to ensure they're loaded accurately
>>> df2 = pd.read_csv(os.path.join(DATA_PATH, 'cleaned_tweets.csv.gz'), in... | [
"def",
"run",
"(",
"verbosity",
"=",
"1",
")",
":",
"filepath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"DATA_PATH",
",",
"'all_tweets.csv'",
")",
"# this should load 100k tweets in about a minute",
"# check the file size and estimate load time from that (see scritps/cat_... | Load all_tweets.csv and run normalize, dropna, encode before dumping to cleaned_tweets.csv.gz
Many columns have "mixed type" to `read_csv` should set `low_memory` to False to ensure they're loaded accurately
>>> df2 = pd.read_csv(os.path.join(DATA_PATH, 'cleaned_tweets.csv.gz'), index_col='id', compression='gz... | [
"Load",
"all_tweets",
".",
"csv",
"and",
"run",
"normalize",
"dropna",
"encode",
"before",
"dumping",
"to",
"cleaned_tweets",
".",
"csv",
".",
"gz"
] | 5c0411d2acfbe5b421841072814c9152591c03f7 | https://github.com/totalgood/twip/blob/5c0411d2acfbe5b421841072814c9152591c03f7/twip/scripts/clean.py#L225-L252 | train | Load all_tweets. csv and run normalize dropna encode before dumping to cleaned_tweets. csv. gz |
briwilcox/Concurrent-Pandas | concurrentpandas.py | data_worker | def data_worker(**kwargs):
"""
Function to be spawned concurrently,
consume data keys from input queue, and push the resulting dataframes to output map
"""
if kwargs is not None:
if "function" in kwargs:
function = kwargs["function"]
else:
Exception("Invalid a... | python | def data_worker(**kwargs):
"""
Function to be spawned concurrently,
consume data keys from input queue, and push the resulting dataframes to output map
"""
if kwargs is not None:
if "function" in kwargs:
function = kwargs["function"]
else:
Exception("Invalid a... | [
"def",
"data_worker",
"(",
"*",
"*",
"kwargs",
")",
":",
"if",
"kwargs",
"is",
"not",
"None",
":",
"if",
"\"function\"",
"in",
"kwargs",
":",
"function",
"=",
"kwargs",
"[",
"\"function\"",
"]",
"else",
":",
"Exception",
"(",
"\"Invalid arguments, no functio... | Function to be spawned concurrently,
consume data keys from input queue, and push the resulting dataframes to output map | [
"Function",
"to",
"be",
"spawned",
"concurrently",
"consume",
"data",
"keys",
"from",
"input",
"queue",
"and",
"push",
"the",
"resulting",
"dataframes",
"to",
"output",
"map"
] | 22cb392dacb712e1bdb5b60c6ba7015c38445c99 | https://github.com/briwilcox/Concurrent-Pandas/blob/22cb392dacb712e1bdb5b60c6ba7015c38445c99/concurrentpandas.py#L35-L75 | train | Function to be spawned concurrently |
briwilcox/Concurrent-Pandas | concurrentpandas.py | get_data | def get_data(data_get, data_key, output_map, retries_left, argdict):
"""
Function to use Python Pandas and / or Quandl to download a dataframe
Insert resulting dataframe into output map
"""
if retries_left <= 0:
print(data_key + " Failed to download.")
ret... | python | def get_data(data_get, data_key, output_map, retries_left, argdict):
"""
Function to use Python Pandas and / or Quandl to download a dataframe
Insert resulting dataframe into output map
"""
if retries_left <= 0:
print(data_key + " Failed to download.")
ret... | [
"def",
"get_data",
"(",
"data_get",
",",
"data_key",
",",
"output_map",
",",
"retries_left",
",",
"argdict",
")",
":",
"if",
"retries_left",
"<=",
"0",
":",
"print",
"(",
"data_key",
"+",
"\" Failed to download.\"",
")",
"return",
"\"\"\"\n Identify type of... | Function to use Python Pandas and / or Quandl to download a dataframe
Insert resulting dataframe into output map | [
"Function",
"to",
"use",
"Python",
"Pandas",
"and",
"/",
"or",
"Quandl",
"to",
"download",
"a",
"dataframe",
"Insert",
"resulting",
"dataframe",
"into",
"output",
"map"
] | 22cb392dacb712e1bdb5b60c6ba7015c38445c99 | https://github.com/briwilcox/Concurrent-Pandas/blob/22cb392dacb712e1bdb5b60c6ba7015c38445c99/concurrentpandas.py#L78-L130 | train | Function to download a dataframe from Yahoo Financial and return a dataframe |
briwilcox/Concurrent-Pandas | concurrentpandas.py | ConcurrentPandas.consume_keys | def consume_keys(self):
"""
Work through the keys to look up sequentially
"""
print("\nLooking up " + self.input_queue.qsize().__str__() + " keys from " + self.source_name + "\n")
self.data_worker(**self.worker_args) | python | def consume_keys(self):
"""
Work through the keys to look up sequentially
"""
print("\nLooking up " + self.input_queue.qsize().__str__() + " keys from " + self.source_name + "\n")
self.data_worker(**self.worker_args) | [
"def",
"consume_keys",
"(",
"self",
")",
":",
"print",
"(",
"\"\\nLooking up \"",
"+",
"self",
".",
"input_queue",
".",
"qsize",
"(",
")",
".",
"__str__",
"(",
")",
"+",
"\" keys from \"",
"+",
"self",
".",
"source_name",
"+",
"\"\\n\"",
")",
"self",
"."... | Work through the keys to look up sequentially | [
"Work",
"through",
"the",
"keys",
"to",
"look",
"up",
"sequentially"
] | 22cb392dacb712e1bdb5b60c6ba7015c38445c99 | https://github.com/briwilcox/Concurrent-Pandas/blob/22cb392dacb712e1bdb5b60c6ba7015c38445c99/concurrentpandas.py#L145-L150 | train | This method is called by the worker thread to look up the keys in the input queue and process them. |
briwilcox/Concurrent-Pandas | concurrentpandas.py | ConcurrentPandas.consume_keys_asynchronous_processes | def consume_keys_asynchronous_processes(self):
"""
Work through the keys to look up asynchronously using multiple processes
"""
print("\nLooking up " + self.input_queue.qsize().__str__() + " keys from " + self.source_name + "\n")
jobs = multiprocessing.cpu_count()*4 if (multiproc... | python | def consume_keys_asynchronous_processes(self):
"""
Work through the keys to look up asynchronously using multiple processes
"""
print("\nLooking up " + self.input_queue.qsize().__str__() + " keys from " + self.source_name + "\n")
jobs = multiprocessing.cpu_count()*4 if (multiproc... | [
"def",
"consume_keys_asynchronous_processes",
"(",
"self",
")",
":",
"print",
"(",
"\"\\nLooking up \"",
"+",
"self",
".",
"input_queue",
".",
"qsize",
"(",
")",
".",
"__str__",
"(",
")",
"+",
"\" keys from \"",
"+",
"self",
".",
"source_name",
"+",
"\"\\n\"",... | Work through the keys to look up asynchronously using multiple processes | [
"Work",
"through",
"the",
"keys",
"to",
"look",
"up",
"asynchronously",
"using",
"multiple",
"processes"
] | 22cb392dacb712e1bdb5b60c6ba7015c38445c99 | https://github.com/briwilcox/Concurrent-Pandas/blob/22cb392dacb712e1bdb5b60c6ba7015c38445c99/concurrentpandas.py#L152-L165 | train | This function is called by the process_input method to process the keys in the input queue asynchronously using multiple processes. |
briwilcox/Concurrent-Pandas | concurrentpandas.py | ConcurrentPandas.consume_keys_asynchronous_threads | def consume_keys_asynchronous_threads(self):
"""
Work through the keys to look up asynchronously using multiple threads
"""
print("\nLooking up " + self.input_queue.qsize().__str__() + " keys from " + self.source_name + "\n")
jobs = multiprocessing.cpu_count()*4 if (multiprocessi... | python | def consume_keys_asynchronous_threads(self):
"""
Work through the keys to look up asynchronously using multiple threads
"""
print("\nLooking up " + self.input_queue.qsize().__str__() + " keys from " + self.source_name + "\n")
jobs = multiprocessing.cpu_count()*4 if (multiprocessi... | [
"def",
"consume_keys_asynchronous_threads",
"(",
"self",
")",
":",
"print",
"(",
"\"\\nLooking up \"",
"+",
"self",
".",
"input_queue",
".",
"qsize",
"(",
")",
".",
"__str__",
"(",
")",
"+",
"\" keys from \"",
"+",
"self",
".",
"source_name",
"+",
"\"\\n\"",
... | Work through the keys to look up asynchronously using multiple threads | [
"Work",
"through",
"the",
"keys",
"to",
"look",
"up",
"asynchronously",
"using",
"multiple",
"threads"
] | 22cb392dacb712e1bdb5b60c6ba7015c38445c99 | https://github.com/briwilcox/Concurrent-Pandas/blob/22cb392dacb712e1bdb5b60c6ba7015c38445c99/concurrentpandas.py#L167-L181 | train | This function is used to consume the keys asynchronously using multiple threads |
briwilcox/Concurrent-Pandas | concurrentpandas.py | ConcurrentPandas.unpack | def unpack(self, to_unpack):
"""
Unpack is a recursive function that will unpack anything that inherits
from abstract base class Container provided it is not also inheriting from Python basestring.
Raise Exception if resulting object is neither a container or a string
Code work... | python | def unpack(self, to_unpack):
"""
Unpack is a recursive function that will unpack anything that inherits
from abstract base class Container provided it is not also inheriting from Python basestring.
Raise Exception if resulting object is neither a container or a string
Code work... | [
"def",
"unpack",
"(",
"self",
",",
"to_unpack",
")",
":",
"# Python 3 lacks basestring type, work around below",
"try",
":",
"isinstance",
"(",
"to_unpack",
",",
"basestring",
")",
"except",
"NameError",
":",
"basestring",
"=",
"str",
"# Base Case",
"if",
"isinstanc... | Unpack is a recursive function that will unpack anything that inherits
from abstract base class Container provided it is not also inheriting from Python basestring.
Raise Exception if resulting object is neither a container or a string
Code working in both Python 2 and Python 3 | [
"Unpack",
"is",
"a",
"recursive",
"function",
"that",
"will",
"unpack",
"anything",
"that",
"inherits",
"from",
"abstract",
"base",
"class",
"Container",
"provided",
"it",
"is",
"not",
"also",
"inheriting",
"from",
"Python",
"basestring",
"."
] | 22cb392dacb712e1bdb5b60c6ba7015c38445c99 | https://github.com/briwilcox/Concurrent-Pandas/blob/22cb392dacb712e1bdb5b60c6ba7015c38445c99/concurrentpandas.py#L202-L239 | train | Unpacks the base class of the object to_unpack and returns the base class of the object. |
briwilcox/Concurrent-Pandas | concurrentpandas.py | ConcurrentPandas.set_source_quandl | def set_source_quandl(self, quandl_token):
"""
Set data source to Quandl
"""
self.data_worker = data_worker
self.worker_args = {"function": Quandl.get, "input": self.input_queue, "output": self.output_map,
"token": quandl_token}
self.source_nam... | python | def set_source_quandl(self, quandl_token):
"""
Set data source to Quandl
"""
self.data_worker = data_worker
self.worker_args = {"function": Quandl.get, "input": self.input_queue, "output": self.output_map,
"token": quandl_token}
self.source_nam... | [
"def",
"set_source_quandl",
"(",
"self",
",",
"quandl_token",
")",
":",
"self",
".",
"data_worker",
"=",
"data_worker",
"self",
".",
"worker_args",
"=",
"{",
"\"function\"",
":",
"Quandl",
".",
"get",
",",
"\"input\"",
":",
"self",
".",
"input_queue",
",",
... | Set data source to Quandl | [
"Set",
"data",
"source",
"to",
"Quandl"
] | 22cb392dacb712e1bdb5b60c6ba7015c38445c99 | https://github.com/briwilcox/Concurrent-Pandas/blob/22cb392dacb712e1bdb5b60c6ba7015c38445c99/concurrentpandas.py#L241-L248 | train | Set data source to Quandl
|
briwilcox/Concurrent-Pandas | concurrentpandas.py | ConcurrentPandas.set_source_google_finance | def set_source_google_finance(self):
"""
Set data source to Google Finance
"""
self.data_worker = data_worker
self.worker_args = {"function": pandas.io.data.DataReader, "input": self.input_queue, "output": self.output_map,
"source": 'google'}
s... | python | def set_source_google_finance(self):
"""
Set data source to Google Finance
"""
self.data_worker = data_worker
self.worker_args = {"function": pandas.io.data.DataReader, "input": self.input_queue, "output": self.output_map,
"source": 'google'}
s... | [
"def",
"set_source_google_finance",
"(",
"self",
")",
":",
"self",
".",
"data_worker",
"=",
"data_worker",
"self",
".",
"worker_args",
"=",
"{",
"\"function\"",
":",
"pandas",
".",
"io",
".",
"data",
".",
"DataReader",
",",
"\"input\"",
":",
"self",
".",
"... | Set data source to Google Finance | [
"Set",
"data",
"source",
"to",
"Google",
"Finance"
] | 22cb392dacb712e1bdb5b60c6ba7015c38445c99 | https://github.com/briwilcox/Concurrent-Pandas/blob/22cb392dacb712e1bdb5b60c6ba7015c38445c99/concurrentpandas.py#L259-L266 | train | Set data source to Google Finance |
briwilcox/Concurrent-Pandas | concurrentpandas.py | ConcurrentPandas.set_source_yahoo_options | def set_source_yahoo_options(self):
"""
Set data source to yahoo finance, specifically to download financial options data
"""
self.data_worker = data_worker
self.worker_args = {"function": Options, "input": self.input_queue, "output": self.output_map,
... | python | def set_source_yahoo_options(self):
"""
Set data source to yahoo finance, specifically to download financial options data
"""
self.data_worker = data_worker
self.worker_args = {"function": Options, "input": self.input_queue, "output": self.output_map,
... | [
"def",
"set_source_yahoo_options",
"(",
"self",
")",
":",
"self",
".",
"data_worker",
"=",
"data_worker",
"self",
".",
"worker_args",
"=",
"{",
"\"function\"",
":",
"Options",
",",
"\"input\"",
":",
"self",
".",
"input_queue",
",",
"\"output\"",
":",
"self",
... | Set data source to yahoo finance, specifically to download financial options data | [
"Set",
"data",
"source",
"to",
"yahoo",
"finance",
"specifically",
"to",
"download",
"financial",
"options",
"data"
] | 22cb392dacb712e1bdb5b60c6ba7015c38445c99 | https://github.com/briwilcox/Concurrent-Pandas/blob/22cb392dacb712e1bdb5b60c6ba7015c38445c99/concurrentpandas.py#L277-L284 | train | Set data source to yahoo finance specifically to download financial options data
|
aloetesting/aloe_webdriver | aloe_webdriver/css.py | load_jquery | def load_jquery(func):
"""
A decorator to ensure a function is run with jQuery available.
If an exception from a function indicates jQuery is missing, it is loaded
and the function re-executed.
The browser to load jQuery into must be the first argument of the function.
"""
@wraps(func)
... | python | def load_jquery(func):
"""
A decorator to ensure a function is run with jQuery available.
If an exception from a function indicates jQuery is missing, it is loaded
and the function re-executed.
The browser to load jQuery into must be the first argument of the function.
"""
@wraps(func)
... | [
"def",
"load_jquery",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"wrapped",
"(",
"browser",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"Run the function, loading jQuery if needed.\"\"\"",
"try",
":",
"return",
"func",
"(",
... | A decorator to ensure a function is run with jQuery available.
If an exception from a function indicates jQuery is missing, it is loaded
and the function re-executed.
The browser to load jQuery into must be the first argument of the function. | [
"A",
"decorator",
"to",
"ensure",
"a",
"function",
"is",
"run",
"with",
"jQuery",
"available",
"."
] | 65d847da4bdc63f9c015cb19d4efdee87df8ffad | https://github.com/aloetesting/aloe_webdriver/blob/65d847da4bdc63f9c015cb19d4efdee87df8ffad/aloe_webdriver/css.py#L64-L98 | train | Decorator that ensures a function is run with jQuery loaded. |
aloetesting/aloe_webdriver | aloe_webdriver/css.py | find_element_by_jquery | def find_element_by_jquery(browser, selector):
"""Find a single HTML element using jQuery-style selectors."""
elements = find_elements_by_jquery(browser, selector)
if not elements:
raise AssertionError("No matching element found.")
if len(elements) > 1:
raise AssertionError("Multiple mat... | python | def find_element_by_jquery(browser, selector):
"""Find a single HTML element using jQuery-style selectors."""
elements = find_elements_by_jquery(browser, selector)
if not elements:
raise AssertionError("No matching element found.")
if len(elements) > 1:
raise AssertionError("Multiple mat... | [
"def",
"find_element_by_jquery",
"(",
"browser",
",",
"selector",
")",
":",
"elements",
"=",
"find_elements_by_jquery",
"(",
"browser",
",",
"selector",
")",
"if",
"not",
"elements",
":",
"raise",
"AssertionError",
"(",
"\"No matching element found.\"",
")",
"if",
... | Find a single HTML element using jQuery-style selectors. | [
"Find",
"a",
"single",
"HTML",
"element",
"using",
"jQuery",
"-",
"style",
"selectors",
"."
] | 65d847da4bdc63f9c015cb19d4efdee87df8ffad | https://github.com/aloetesting/aloe_webdriver/blob/65d847da4bdc63f9c015cb19d4efdee87df8ffad/aloe_webdriver/css.py#L111-L118 | train | Find a single HTML element using jQuery - style selectors. |
aloetesting/aloe_webdriver | aloe_webdriver/css.py | check_element_by_selector | def check_element_by_selector(self, selector):
"""Assert an element exists matching the given selector."""
elems = find_elements_by_jquery(world.browser, selector)
if not elems:
raise AssertionError("Expected matching elements, none found.") | python | def check_element_by_selector(self, selector):
"""Assert an element exists matching the given selector."""
elems = find_elements_by_jquery(world.browser, selector)
if not elems:
raise AssertionError("Expected matching elements, none found.") | [
"def",
"check_element_by_selector",
"(",
"self",
",",
"selector",
")",
":",
"elems",
"=",
"find_elements_by_jquery",
"(",
"world",
".",
"browser",
",",
"selector",
")",
"if",
"not",
"elems",
":",
"raise",
"AssertionError",
"(",
"\"Expected matching elements, none fo... | Assert an element exists matching the given selector. | [
"Assert",
"an",
"element",
"exists",
"matching",
"the",
"given",
"selector",
"."
] | 65d847da4bdc63f9c015cb19d4efdee87df8ffad | https://github.com/aloetesting/aloe_webdriver/blob/65d847da4bdc63f9c015cb19d4efdee87df8ffad/aloe_webdriver/css.py#L133-L137 | train | Assert an element exists matching the given selector. |
aloetesting/aloe_webdriver | aloe_webdriver/css.py | check_no_element_by_selector | def check_no_element_by_selector(self, selector):
"""Assert an element does not exist matching the given selector."""
elems = find_elements_by_jquery(world.browser, selector)
if elems:
raise AssertionError("Expected no matching elements, found {}.".format(
len(elems))) | python | def check_no_element_by_selector(self, selector):
"""Assert an element does not exist matching the given selector."""
elems = find_elements_by_jquery(world.browser, selector)
if elems:
raise AssertionError("Expected no matching elements, found {}.".format(
len(elems))) | [
"def",
"check_no_element_by_selector",
"(",
"self",
",",
"selector",
")",
":",
"elems",
"=",
"find_elements_by_jquery",
"(",
"world",
".",
"browser",
",",
"selector",
")",
"if",
"elems",
":",
"raise",
"AssertionError",
"(",
"\"Expected no matching elements, found {}.\... | Assert an element does not exist matching the given selector. | [
"Assert",
"an",
"element",
"does",
"not",
"exist",
"matching",
"the",
"given",
"selector",
"."
] | 65d847da4bdc63f9c015cb19d4efdee87df8ffad | https://github.com/aloetesting/aloe_webdriver/blob/65d847da4bdc63f9c015cb19d4efdee87df8ffad/aloe_webdriver/css.py#L142-L147 | train | Assert an element does not exist matching the given selector. |
aloetesting/aloe_webdriver | aloe_webdriver/css.py | wait_for_element_by_selector | def wait_for_element_by_selector(self, selector, seconds):
"""
Assert an element exists matching the given selector within the given time
period.
"""
def assert_element_present():
"""Assert an element matching the given selector exists."""
if not find_elements_by_jquery(world.browse... | python | def wait_for_element_by_selector(self, selector, seconds):
"""
Assert an element exists matching the given selector within the given time
period.
"""
def assert_element_present():
"""Assert an element matching the given selector exists."""
if not find_elements_by_jquery(world.browse... | [
"def",
"wait_for_element_by_selector",
"(",
"self",
",",
"selector",
",",
"seconds",
")",
":",
"def",
"assert_element_present",
"(",
")",
":",
"\"\"\"Assert an element matching the given selector exists.\"\"\"",
"if",
"not",
"find_elements_by_jquery",
"(",
"world",
".",
"... | Assert an element exists matching the given selector within the given time
period. | [
"Assert",
"an",
"element",
"exists",
"matching",
"the",
"given",
"selector",
"within",
"the",
"given",
"time",
"period",
"."
] | 65d847da4bdc63f9c015cb19d4efdee87df8ffad | https://github.com/aloetesting/aloe_webdriver/blob/65d847da4bdc63f9c015cb19d4efdee87df8ffad/aloe_webdriver/css.py#L152-L163 | train | Assert an element with the given selector exists within the given time
period. |
aloetesting/aloe_webdriver | aloe_webdriver/css.py | count_elements_exactly_by_selector | def count_elements_exactly_by_selector(self, number, selector):
"""
Assert n elements exist matching the given selector.
"""
elems = find_elements_by_jquery(world.browser, selector)
number = int(number)
if len(elems) != number:
raise AssertionError("Expected {} elements, found {}".format... | python | def count_elements_exactly_by_selector(self, number, selector):
"""
Assert n elements exist matching the given selector.
"""
elems = find_elements_by_jquery(world.browser, selector)
number = int(number)
if len(elems) != number:
raise AssertionError("Expected {} elements, found {}".format... | [
"def",
"count_elements_exactly_by_selector",
"(",
"self",
",",
"number",
",",
"selector",
")",
":",
"elems",
"=",
"find_elements_by_jquery",
"(",
"world",
".",
"browser",
",",
"selector",
")",
"number",
"=",
"int",
"(",
"number",
")",
"if",
"len",
"(",
"elem... | Assert n elements exist matching the given selector. | [
"Assert",
"n",
"elements",
"exist",
"matching",
"the",
"given",
"selector",
"."
] | 65d847da4bdc63f9c015cb19d4efdee87df8ffad | https://github.com/aloetesting/aloe_webdriver/blob/65d847da4bdc63f9c015cb19d4efdee87df8ffad/aloe_webdriver/css.py#L168-L176 | train | Assert n elements exist matching the given selector. |
aloetesting/aloe_webdriver | aloe_webdriver/css.py | fill_in_by_selector | def fill_in_by_selector(self, selector, value):
"""Fill in the form element matching the CSS selector."""
elem = find_element_by_jquery(world.browser, selector)
elem.clear()
elem.send_keys(value) | python | def fill_in_by_selector(self, selector, value):
"""Fill in the form element matching the CSS selector."""
elem = find_element_by_jquery(world.browser, selector)
elem.clear()
elem.send_keys(value) | [
"def",
"fill_in_by_selector",
"(",
"self",
",",
"selector",
",",
"value",
")",
":",
"elem",
"=",
"find_element_by_jquery",
"(",
"world",
".",
"browser",
",",
"selector",
")",
"elem",
".",
"clear",
"(",
")",
"elem",
".",
"send_keys",
"(",
"value",
")"
] | Fill in the form element matching the CSS selector. | [
"Fill",
"in",
"the",
"form",
"element",
"matching",
"the",
"CSS",
"selector",
"."
] | 65d847da4bdc63f9c015cb19d4efdee87df8ffad | https://github.com/aloetesting/aloe_webdriver/blob/65d847da4bdc63f9c015cb19d4efdee87df8ffad/aloe_webdriver/css.py#L181-L185 | train | Fill in the form element matching the CSS selector. |
aloetesting/aloe_webdriver | aloe_webdriver/css.py | submit_by_selector | def submit_by_selector(self, selector):
"""Submit the form matching the CSS selector."""
elem = find_element_by_jquery(world.browser, selector)
elem.submit() | python | def submit_by_selector(self, selector):
"""Submit the form matching the CSS selector."""
elem = find_element_by_jquery(world.browser, selector)
elem.submit() | [
"def",
"submit_by_selector",
"(",
"self",
",",
"selector",
")",
":",
"elem",
"=",
"find_element_by_jquery",
"(",
"world",
".",
"browser",
",",
"selector",
")",
"elem",
".",
"submit",
"(",
")"
] | Submit the form matching the CSS selector. | [
"Submit",
"the",
"form",
"matching",
"the",
"CSS",
"selector",
"."
] | 65d847da4bdc63f9c015cb19d4efdee87df8ffad | https://github.com/aloetesting/aloe_webdriver/blob/65d847da4bdc63f9c015cb19d4efdee87df8ffad/aloe_webdriver/css.py#L190-L193 | train | Submit the form matching the CSS selector. |
aloetesting/aloe_webdriver | aloe_webdriver/css.py | check_by_selector | def check_by_selector(self, selector):
"""Check the checkbox matching the CSS selector."""
elem = find_element_by_jquery(world.browser, selector)
if not elem.is_selected():
elem.click() | python | def check_by_selector(self, selector):
"""Check the checkbox matching the CSS selector."""
elem = find_element_by_jquery(world.browser, selector)
if not elem.is_selected():
elem.click() | [
"def",
"check_by_selector",
"(",
"self",
",",
"selector",
")",
":",
"elem",
"=",
"find_element_by_jquery",
"(",
"world",
".",
"browser",
",",
"selector",
")",
"if",
"not",
"elem",
".",
"is_selected",
"(",
")",
":",
"elem",
".",
"click",
"(",
")"
] | Check the checkbox matching the CSS selector. | [
"Check",
"the",
"checkbox",
"matching",
"the",
"CSS",
"selector",
"."
] | 65d847da4bdc63f9c015cb19d4efdee87df8ffad | https://github.com/aloetesting/aloe_webdriver/blob/65d847da4bdc63f9c015cb19d4efdee87df8ffad/aloe_webdriver/css.py#L198-L202 | train | Check the checkbox matching the CSS selector. |
aloetesting/aloe_webdriver | aloe_webdriver/css.py | click_by_selector | def click_by_selector(self, selector):
"""Click the element matching the CSS selector."""
# No need for separate button press step with selector style.
elem = find_element_by_jquery(world.browser, selector)
elem.click() | python | def click_by_selector(self, selector):
"""Click the element matching the CSS selector."""
# No need for separate button press step with selector style.
elem = find_element_by_jquery(world.browser, selector)
elem.click() | [
"def",
"click_by_selector",
"(",
"self",
",",
"selector",
")",
":",
"# No need for separate button press step with selector style.",
"elem",
"=",
"find_element_by_jquery",
"(",
"world",
".",
"browser",
",",
"selector",
")",
"elem",
".",
"click",
"(",
")"
] | Click the element matching the CSS selector. | [
"Click",
"the",
"element",
"matching",
"the",
"CSS",
"selector",
"."
] | 65d847da4bdc63f9c015cb19d4efdee87df8ffad | https://github.com/aloetesting/aloe_webdriver/blob/65d847da4bdc63f9c015cb19d4efdee87df8ffad/aloe_webdriver/css.py#L207-L211 | train | Click the element matching the CSS selector. |
aloetesting/aloe_webdriver | aloe_webdriver/css.py | follow_link_by_selector | def follow_link_by_selector(self, selector):
"""
Navigate to the href of the element matching the CSS selector.
N.B. this does not click the link, but changes the browser's URL.
"""
elem = find_element_by_jquery(world.browser, selector)
href = elem.get_attribute('href')
world.browser.get(hr... | python | def follow_link_by_selector(self, selector):
"""
Navigate to the href of the element matching the CSS selector.
N.B. this does not click the link, but changes the browser's URL.
"""
elem = find_element_by_jquery(world.browser, selector)
href = elem.get_attribute('href')
world.browser.get(hr... | [
"def",
"follow_link_by_selector",
"(",
"self",
",",
"selector",
")",
":",
"elem",
"=",
"find_element_by_jquery",
"(",
"world",
".",
"browser",
",",
"selector",
")",
"href",
"=",
"elem",
".",
"get_attribute",
"(",
"'href'",
")",
"world",
".",
"browser",
".",
... | Navigate to the href of the element matching the CSS selector.
N.B. this does not click the link, but changes the browser's URL. | [
"Navigate",
"to",
"the",
"href",
"of",
"the",
"element",
"matching",
"the",
"CSS",
"selector",
"."
] | 65d847da4bdc63f9c015cb19d4efdee87df8ffad | https://github.com/aloetesting/aloe_webdriver/blob/65d847da4bdc63f9c015cb19d4efdee87df8ffad/aloe_webdriver/css.py#L216-L224 | train | Navigate to the href of the element matching the CSS selector. |
aloetesting/aloe_webdriver | aloe_webdriver/css.py | is_selected_by_selector | def is_selected_by_selector(self, selector):
"""Assert the option matching the CSS selector is selected."""
elem = find_element_by_jquery(world.browser, selector)
if not elem.is_selected():
raise AssertionError("Element expected to be selected.") | python | def is_selected_by_selector(self, selector):
"""Assert the option matching the CSS selector is selected."""
elem = find_element_by_jquery(world.browser, selector)
if not elem.is_selected():
raise AssertionError("Element expected to be selected.") | [
"def",
"is_selected_by_selector",
"(",
"self",
",",
"selector",
")",
":",
"elem",
"=",
"find_element_by_jquery",
"(",
"world",
".",
"browser",
",",
"selector",
")",
"if",
"not",
"elem",
".",
"is_selected",
"(",
")",
":",
"raise",
"AssertionError",
"(",
"\"El... | Assert the option matching the CSS selector is selected. | [
"Assert",
"the",
"option",
"matching",
"the",
"CSS",
"selector",
"is",
"selected",
"."
] | 65d847da4bdc63f9c015cb19d4efdee87df8ffad | https://github.com/aloetesting/aloe_webdriver/blob/65d847da4bdc63f9c015cb19d4efdee87df8ffad/aloe_webdriver/css.py#L229-L233 | train | Assert the option matching the CSS selector is selected. |
aloetesting/aloe_webdriver | aloe_webdriver/css.py | select_by_selector | def select_by_selector(self, selector):
"""Select the option matching the CSS selector."""
option = find_element_by_jquery(world.browser, selector)
selectors = find_parents_by_jquery(world.browser, selector)
if not selectors:
raise AssertionError("No parent element found for the option.")
se... | python | def select_by_selector(self, selector):
"""Select the option matching the CSS selector."""
option = find_element_by_jquery(world.browser, selector)
selectors = find_parents_by_jquery(world.browser, selector)
if not selectors:
raise AssertionError("No parent element found for the option.")
se... | [
"def",
"select_by_selector",
"(",
"self",
",",
"selector",
")",
":",
"option",
"=",
"find_element_by_jquery",
"(",
"world",
".",
"browser",
",",
"selector",
")",
"selectors",
"=",
"find_parents_by_jquery",
"(",
"world",
".",
"browser",
",",
"selector",
")",
"i... | Select the option matching the CSS selector. | [
"Select",
"the",
"option",
"matching",
"the",
"CSS",
"selector",
"."
] | 65d847da4bdc63f9c015cb19d4efdee87df8ffad | https://github.com/aloetesting/aloe_webdriver/blob/65d847da4bdc63f9c015cb19d4efdee87df8ffad/aloe_webdriver/css.py#L238-L250 | train | Select the option matching the CSS selector. |
aiidateam/aiida-codtools | aiida_codtools/workflows/cif_clean.py | CifCleanWorkChain.run_filter_calculation | def run_filter_calculation(self):
"""Run the CifFilterCalculation on the CifData input node."""
inputs = {
'cif': self.inputs.cif,
'code': self.inputs.cif_filter,
'parameters': self.inputs.cif_filter_parameters,
'metadata': {
'options': sel... | python | def run_filter_calculation(self):
"""Run the CifFilterCalculation on the CifData input node."""
inputs = {
'cif': self.inputs.cif,
'code': self.inputs.cif_filter,
'parameters': self.inputs.cif_filter_parameters,
'metadata': {
'options': sel... | [
"def",
"run_filter_calculation",
"(",
"self",
")",
":",
"inputs",
"=",
"{",
"'cif'",
":",
"self",
".",
"inputs",
".",
"cif",
",",
"'code'",
":",
"self",
".",
"inputs",
".",
"cif_filter",
",",
"'parameters'",
":",
"self",
".",
"inputs",
".",
"cif_filter_p... | Run the CifFilterCalculation on the CifData input node. | [
"Run",
"the",
"CifFilterCalculation",
"on",
"the",
"CifData",
"input",
"node",
"."
] | da5e4259b7a2e86cf0cc3f997e11dd36d445fa94 | https://github.com/aiidateam/aiida-codtools/blob/da5e4259b7a2e86cf0cc3f997e11dd36d445fa94/aiida_codtools/workflows/cif_clean.py#L87-L101 | train | Run the CifFilterCalculation on the CifData input node. |
aiidateam/aiida-codtools | aiida_codtools/workflows/cif_clean.py | CifCleanWorkChain.inspect_filter_calculation | def inspect_filter_calculation(self):
"""Inspect the result of the CifFilterCalculation, verifying that it produced a CifData output node."""
try:
node = self.ctx.cif_filter
self.ctx.cif = node.outputs.cif
except exceptions.NotExistent:
self.report('aborting: ... | python | def inspect_filter_calculation(self):
"""Inspect the result of the CifFilterCalculation, verifying that it produced a CifData output node."""
try:
node = self.ctx.cif_filter
self.ctx.cif = node.outputs.cif
except exceptions.NotExistent:
self.report('aborting: ... | [
"def",
"inspect_filter_calculation",
"(",
"self",
")",
":",
"try",
":",
"node",
"=",
"self",
".",
"ctx",
".",
"cif_filter",
"self",
".",
"ctx",
".",
"cif",
"=",
"node",
".",
"outputs",
".",
"cif",
"except",
"exceptions",
".",
"NotExistent",
":",
"self",
... | Inspect the result of the CifFilterCalculation, verifying that it produced a CifData output node. | [
"Inspect",
"the",
"result",
"of",
"the",
"CifFilterCalculation",
"verifying",
"that",
"it",
"produced",
"a",
"CifData",
"output",
"node",
"."
] | da5e4259b7a2e86cf0cc3f997e11dd36d445fa94 | https://github.com/aiidateam/aiida-codtools/blob/da5e4259b7a2e86cf0cc3f997e11dd36d445fa94/aiida_codtools/workflows/cif_clean.py#L103-L110 | train | Inspect the result of the CifFilterCalculation verifying that it produced a CifData output node. |
aiidateam/aiida-codtools | aiida_codtools/workflows/cif_clean.py | CifCleanWorkChain.run_select_calculation | def run_select_calculation(self):
"""Run the CifSelectCalculation on the CifData output node of the CifFilterCalculation."""
inputs = {
'cif': self.ctx.cif,
'code': self.inputs.cif_select,
'parameters': self.inputs.cif_select_parameters,
'metadata': {
... | python | def run_select_calculation(self):
"""Run the CifSelectCalculation on the CifData output node of the CifFilterCalculation."""
inputs = {
'cif': self.ctx.cif,
'code': self.inputs.cif_select,
'parameters': self.inputs.cif_select_parameters,
'metadata': {
... | [
"def",
"run_select_calculation",
"(",
"self",
")",
":",
"inputs",
"=",
"{",
"'cif'",
":",
"self",
".",
"ctx",
".",
"cif",
",",
"'code'",
":",
"self",
".",
"inputs",
".",
"cif_select",
",",
"'parameters'",
":",
"self",
".",
"inputs",
".",
"cif_select_para... | Run the CifSelectCalculation on the CifData output node of the CifFilterCalculation. | [
"Run",
"the",
"CifSelectCalculation",
"on",
"the",
"CifData",
"output",
"node",
"of",
"the",
"CifFilterCalculation",
"."
] | da5e4259b7a2e86cf0cc3f997e11dd36d445fa94 | https://github.com/aiidateam/aiida-codtools/blob/da5e4259b7a2e86cf0cc3f997e11dd36d445fa94/aiida_codtools/workflows/cif_clean.py#L112-L126 | train | Run the CifSelectCalculation on the CifData output node of the CifFilterCalculation. |
aiidateam/aiida-codtools | aiida_codtools/workflows/cif_clean.py | CifCleanWorkChain.inspect_select_calculation | def inspect_select_calculation(self):
"""Inspect the result of the CifSelectCalculation, verifying that it produced a CifData output node."""
try:
node = self.ctx.cif_select
self.ctx.cif = node.outputs.cif
except exceptions.NotExistent:
self.report('aborting: ... | python | def inspect_select_calculation(self):
"""Inspect the result of the CifSelectCalculation, verifying that it produced a CifData output node."""
try:
node = self.ctx.cif_select
self.ctx.cif = node.outputs.cif
except exceptions.NotExistent:
self.report('aborting: ... | [
"def",
"inspect_select_calculation",
"(",
"self",
")",
":",
"try",
":",
"node",
"=",
"self",
".",
"ctx",
".",
"cif_select",
"self",
".",
"ctx",
".",
"cif",
"=",
"node",
".",
"outputs",
".",
"cif",
"except",
"exceptions",
".",
"NotExistent",
":",
"self",
... | Inspect the result of the CifSelectCalculation, verifying that it produced a CifData output node. | [
"Inspect",
"the",
"result",
"of",
"the",
"CifSelectCalculation",
"verifying",
"that",
"it",
"produced",
"a",
"CifData",
"output",
"node",
"."
] | da5e4259b7a2e86cf0cc3f997e11dd36d445fa94 | https://github.com/aiidateam/aiida-codtools/blob/da5e4259b7a2e86cf0cc3f997e11dd36d445fa94/aiida_codtools/workflows/cif_clean.py#L128-L135 | train | Inspect the result of the CifSelectCalculation verifying that it produced a CifData output node. |
aiidateam/aiida-codtools | aiida_codtools/workflows/cif_clean.py | CifCleanWorkChain.parse_cif_structure | def parse_cif_structure(self):
"""Parse a `StructureData` from the cleaned `CifData` returned by the `CifSelectCalculation`."""
from aiida_codtools.workflows.functions.primitive_structure_from_cif import primitive_structure_from_cif
if self.ctx.cif.has_unknown_species:
self.ctx.exit... | python | def parse_cif_structure(self):
"""Parse a `StructureData` from the cleaned `CifData` returned by the `CifSelectCalculation`."""
from aiida_codtools.workflows.functions.primitive_structure_from_cif import primitive_structure_from_cif
if self.ctx.cif.has_unknown_species:
self.ctx.exit... | [
"def",
"parse_cif_structure",
"(",
"self",
")",
":",
"from",
"aiida_codtools",
".",
"workflows",
".",
"functions",
".",
"primitive_structure_from_cif",
"import",
"primitive_structure_from_cif",
"if",
"self",
".",
"ctx",
".",
"cif",
".",
"has_unknown_species",
":",
"... | Parse a `StructureData` from the cleaned `CifData` returned by the `CifSelectCalculation`. | [
"Parse",
"a",
"StructureData",
"from",
"the",
"cleaned",
"CifData",
"returned",
"by",
"the",
"CifSelectCalculation",
"."
] | da5e4259b7a2e86cf0cc3f997e11dd36d445fa94 | https://github.com/aiidateam/aiida-codtools/blob/da5e4259b7a2e86cf0cc3f997e11dd36d445fa94/aiida_codtools/workflows/cif_clean.py#L141-L178 | train | Parse a StructureData from the cleaned CifData returned by the CifSelectCalculation. |
aiidateam/aiida-codtools | aiida_codtools/workflows/cif_clean.py | CifCleanWorkChain.results | def results(self):
"""If successfully created, add the cleaned `CifData` and `StructureData` as output nodes to the workchain.
The filter and select calculations were successful, so we return the cleaned CifData node. If the `group_cif`
was defined in the inputs, the node is added to it. If the... | python | def results(self):
"""If successfully created, add the cleaned `CifData` and `StructureData` as output nodes to the workchain.
The filter and select calculations were successful, so we return the cleaned CifData node. If the `group_cif`
was defined in the inputs, the node is added to it. If the... | [
"def",
"results",
"(",
"self",
")",
":",
"self",
".",
"out",
"(",
"'cif'",
",",
"self",
".",
"ctx",
".",
"cif",
")",
"if",
"'group_cif'",
"in",
"self",
".",
"inputs",
":",
"self",
".",
"inputs",
".",
"group_cif",
".",
"add_nodes",
"(",
"[",
"self",... | If successfully created, add the cleaned `CifData` and `StructureData` as output nodes to the workchain.
The filter and select calculations were successful, so we return the cleaned CifData node. If the `group_cif`
was defined in the inputs, the node is added to it. If the structure should have been pa... | [
"If",
"successfully",
"created",
"add",
"the",
"cleaned",
"CifData",
"and",
"StructureData",
"as",
"output",
"nodes",
"to",
"the",
"workchain",
"."
] | da5e4259b7a2e86cf0cc3f997e11dd36d445fa94 | https://github.com/aiidateam/aiida-codtools/blob/da5e4259b7a2e86cf0cc3f997e11dd36d445fa94/aiida_codtools/workflows/cif_clean.py#L180-L202 | train | This method is called by the base class to add the cleaned CifData and StructureData nodes to the workchain. |
aiidateam/aiida-codtools | aiida_codtools/common/utils.py | get_input_node | def get_input_node(cls, value):
"""Return a `Node` of a given class and given value.
If a `Node` of the given type and value already exists, that will be returned, otherwise a new one will be created,
stored and returned.
:param cls: the `Node` class
:param value: the value of the `Node`
"""
... | python | def get_input_node(cls, value):
"""Return a `Node` of a given class and given value.
If a `Node` of the given type and value already exists, that will be returned, otherwise a new one will be created,
stored and returned.
:param cls: the `Node` class
:param value: the value of the `Node`
"""
... | [
"def",
"get_input_node",
"(",
"cls",
",",
"value",
")",
":",
"from",
"aiida",
"import",
"orm",
"if",
"cls",
"in",
"(",
"orm",
".",
"Bool",
",",
"orm",
".",
"Float",
",",
"orm",
".",
"Int",
",",
"orm",
".",
"Str",
")",
":",
"result",
"=",
"orm",
... | Return a `Node` of a given class and given value.
If a `Node` of the given type and value already exists, that will be returned, otherwise a new one will be created,
stored and returned.
:param cls: the `Node` class
:param value: the value of the `Node` | [
"Return",
"a",
"Node",
"of",
"a",
"given",
"class",
"and",
"given",
"value",
"."
] | da5e4259b7a2e86cf0cc3f997e11dd36d445fa94 | https://github.com/aiidateam/aiida-codtools/blob/da5e4259b7a2e86cf0cc3f997e11dd36d445fa94/aiida_codtools/common/utils.py#L7-L38 | train | Return a Node of a given class and given value. |
Capitains/MyCapytain | MyCapytain/common/utils/_generic.py | nested_get | def nested_get(dictionary, keys):
""" Get value in dictionary for dictionary[keys[0]][keys[1]][keys[..n]]
:param dictionary: An input dictionary
:param keys: Keys where to store data
:return:
"""
return reduce(lambda d, k: d[k], keys, dictionary) | python | def nested_get(dictionary, keys):
""" Get value in dictionary for dictionary[keys[0]][keys[1]][keys[..n]]
:param dictionary: An input dictionary
:param keys: Keys where to store data
:return:
"""
return reduce(lambda d, k: d[k], keys, dictionary) | [
"def",
"nested_get",
"(",
"dictionary",
",",
"keys",
")",
":",
"return",
"reduce",
"(",
"lambda",
"d",
",",
"k",
":",
"d",
"[",
"k",
"]",
",",
"keys",
",",
"dictionary",
")"
] | Get value in dictionary for dictionary[keys[0]][keys[1]][keys[..n]]
:param dictionary: An input dictionary
:param keys: Keys where to store data
:return: | [
"Get",
"value",
"in",
"dictionary",
"for",
"dictionary",
"[",
"keys",
"[",
"0",
"]]",
"[",
"keys",
"[",
"1",
"]]",
"[",
"keys",
"[",
"..",
"n",
"]]"
] | b11bbf6b6ae141fc02be70471e3fbf6907be6593 | https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/common/utils/_generic.py#L32-L39 | train | Get value in dictionary for nested keys |
klen/muffin-admin | muffin_admin/filters.py | Filter.bind | def bind(self, form):
"""Bind to filters form."""
field = self.field(default=self.default, **self.field_kwargs)
form._fields[self.name] = field.bind(form, self.name, prefix=form._prefix) | python | def bind(self, form):
"""Bind to filters form."""
field = self.field(default=self.default, **self.field_kwargs)
form._fields[self.name] = field.bind(form, self.name, prefix=form._prefix) | [
"def",
"bind",
"(",
"self",
",",
"form",
")",
":",
"field",
"=",
"self",
".",
"field",
"(",
"default",
"=",
"self",
".",
"default",
",",
"*",
"*",
"self",
".",
"field_kwargs",
")",
"form",
".",
"_fields",
"[",
"self",
".",
"name",
"]",
"=",
"fiel... | Bind to filters form. | [
"Bind",
"to",
"filters",
"form",
"."
] | 404dc8e5107e943b7c42fa21c679c34ddb4de1d5 | https://github.com/klen/muffin-admin/blob/404dc8e5107e943b7c42fa21c679c34ddb4de1d5/muffin_admin/filters.py#L33-L36 | train | Bind to filters form. |
klen/muffin-admin | muffin_admin/filters.py | Filter.apply | def apply(self, collection, data):
"""Filter collection."""
value = self.value(data)
if value is self.default:
return collection
return [o for o in collection if getattr(o, self.name, None) == value] | python | def apply(self, collection, data):
"""Filter collection."""
value = self.value(data)
if value is self.default:
return collection
return [o for o in collection if getattr(o, self.name, None) == value] | [
"def",
"apply",
"(",
"self",
",",
"collection",
",",
"data",
")",
":",
"value",
"=",
"self",
".",
"value",
"(",
"data",
")",
"if",
"value",
"is",
"self",
".",
"default",
":",
"return",
"collection",
"return",
"[",
"o",
"for",
"o",
"in",
"collection",... | Filter collection. | [
"Filter",
"collection",
"."
] | 404dc8e5107e943b7c42fa21c679c34ddb4de1d5 | https://github.com/klen/muffin-admin/blob/404dc8e5107e943b7c42fa21c679c34ddb4de1d5/muffin_admin/filters.py#L43-L48 | train | Filter collection by the value of the attribute. |
jedie/PyHardLinkBackup | PyHardLinkBackup/phlb/human.py | human_filesize | def human_filesize(i):
"""
'human-readable' file size (i.e. 13 KB, 4.1 MB, 102 bytes, etc).
"""
bytes = float(i)
if bytes < 1024:
return u"%d Byte%s" % (bytes, bytes != 1 and u"s" or u"")
if bytes < 1024 * 1024:
return u"%.1f KB" % (bytes / 1024)
if bytes < 1024 * 1024 * 1024... | python | def human_filesize(i):
"""
'human-readable' file size (i.e. 13 KB, 4.1 MB, 102 bytes, etc).
"""
bytes = float(i)
if bytes < 1024:
return u"%d Byte%s" % (bytes, bytes != 1 and u"s" or u"")
if bytes < 1024 * 1024:
return u"%.1f KB" % (bytes / 1024)
if bytes < 1024 * 1024 * 1024... | [
"def",
"human_filesize",
"(",
"i",
")",
":",
"bytes",
"=",
"float",
"(",
"i",
")",
"if",
"bytes",
"<",
"1024",
":",
"return",
"u\"%d Byte%s\"",
"%",
"(",
"bytes",
",",
"bytes",
"!=",
"1",
"and",
"u\"s\"",
"or",
"u\"\"",
")",
"if",
"bytes",
"<",
"10... | 'human-readable' file size (i.e. 13 KB, 4.1 MB, 102 bytes, etc). | [
"human",
"-",
"readable",
"file",
"size",
"(",
"i",
".",
"e",
".",
"13",
"KB",
"4",
".",
"1",
"MB",
"102",
"bytes",
"etc",
")",
"."
] | be28666834d2d9e3d8aac1b661cb2d5bd4056c29 | https://github.com/jedie/PyHardLinkBackup/blob/be28666834d2d9e3d8aac1b661cb2d5bd4056c29/PyHardLinkBackup/phlb/human.py#L23-L34 | train | human - readable file size |
jedie/PyHardLinkBackup | PyHardLinkBackup/phlb/human.py | dt2naturaltimesince | def dt2naturaltimesince(dt):
"""
datetime to a human readable representation with how old this entry is information
e.g.:
Jan. 27, 2016, 9:04 p.m. (31 minutes ago)
"""
date = defaultfilters.date(dt, _("DATETIME_FORMAT"))
nt = humanize.naturaltime(dt)
return "%s (%s)" % (date, nt) | python | def dt2naturaltimesince(dt):
"""
datetime to a human readable representation with how old this entry is information
e.g.:
Jan. 27, 2016, 9:04 p.m. (31 minutes ago)
"""
date = defaultfilters.date(dt, _("DATETIME_FORMAT"))
nt = humanize.naturaltime(dt)
return "%s (%s)" % (date, nt) | [
"def",
"dt2naturaltimesince",
"(",
"dt",
")",
":",
"date",
"=",
"defaultfilters",
".",
"date",
"(",
"dt",
",",
"_",
"(",
"\"DATETIME_FORMAT\"",
")",
")",
"nt",
"=",
"humanize",
".",
"naturaltime",
"(",
"dt",
")",
"return",
"\"%s (%s)\"",
"%",
"(",
"date"... | datetime to a human readable representation with how old this entry is information
e.g.:
Jan. 27, 2016, 9:04 p.m. (31 minutes ago) | [
"datetime",
"to",
"a",
"human",
"readable",
"representation",
"with",
"how",
"old",
"this",
"entry",
"is",
"information",
"e",
".",
"g",
".",
":",
"Jan",
".",
"27",
"2016",
"9",
":",
"04",
"p",
".",
"m",
".",
"(",
"31",
"minutes",
"ago",
")"
] | be28666834d2d9e3d8aac1b661cb2d5bd4056c29 | https://github.com/jedie/PyHardLinkBackup/blob/be28666834d2d9e3d8aac1b661cb2d5bd4056c29/PyHardLinkBackup/phlb/human.py#L45-L53 | train | converts a datetime to a human readable representation with how old this entry is information |
jedie/PyHardLinkBackup | PyHardLinkBackup/phlb/human.py | ns2naturaltimesince | def ns2naturaltimesince(ns):
"""
nanoseconds to a human readable representation with how old this entry is information
e.g.:
Jan. 27, 2016, 9:04 p.m. (31 minutes ago)
"""
timestamp = ns / 1000000000
dt = datetime.datetime.utcfromtimestamp(timestamp)
return dt2naturaltimesince(dt) | python | def ns2naturaltimesince(ns):
"""
nanoseconds to a human readable representation with how old this entry is information
e.g.:
Jan. 27, 2016, 9:04 p.m. (31 minutes ago)
"""
timestamp = ns / 1000000000
dt = datetime.datetime.utcfromtimestamp(timestamp)
return dt2naturaltimesince(dt) | [
"def",
"ns2naturaltimesince",
"(",
"ns",
")",
":",
"timestamp",
"=",
"ns",
"/",
"1000000000",
"dt",
"=",
"datetime",
".",
"datetime",
".",
"utcfromtimestamp",
"(",
"timestamp",
")",
"return",
"dt2naturaltimesince",
"(",
"dt",
")"
] | nanoseconds to a human readable representation with how old this entry is information
e.g.:
Jan. 27, 2016, 9:04 p.m. (31 minutes ago) | [
"nanoseconds",
"to",
"a",
"human",
"readable",
"representation",
"with",
"how",
"old",
"this",
"entry",
"is",
"information",
"e",
".",
"g",
".",
":",
"Jan",
".",
"27",
"2016",
"9",
":",
"04",
"p",
".",
"m",
".",
"(",
"31",
"minutes",
"ago",
")"
] | be28666834d2d9e3d8aac1b661cb2d5bd4056c29 | https://github.com/jedie/PyHardLinkBackup/blob/be28666834d2d9e3d8aac1b661cb2d5bd4056c29/PyHardLinkBackup/phlb/human.py#L56-L64 | train | Convert nanoseconds to natural readable representation of the entry. |
persandstrom/python-vasttrafik | vasttrafik/__main__.py | get_config_path | def get_config_path():
"""Put together the default configuration path based on OS."""
dir_path = (os.getenv('APPDATA') if os.name == "nt"
else os.path.expanduser('~'))
return os.path.join(dir_path, '.vtjp') | python | def get_config_path():
"""Put together the default configuration path based on OS."""
dir_path = (os.getenv('APPDATA') if os.name == "nt"
else os.path.expanduser('~'))
return os.path.join(dir_path, '.vtjp') | [
"def",
"get_config_path",
"(",
")",
":",
"dir_path",
"=",
"(",
"os",
".",
"getenv",
"(",
"'APPDATA'",
")",
"if",
"os",
".",
"name",
"==",
"\"nt\"",
"else",
"os",
".",
"path",
".",
"expanduser",
"(",
"'~'",
")",
")",
"return",
"os",
".",
"path",
"."... | Put together the default configuration path based on OS. | [
"Put",
"together",
"the",
"default",
"configuration",
"path",
"based",
"on",
"OS",
"."
] | 9c657fde1e91229c5878ea25530260596d296d37 | https://github.com/persandstrom/python-vasttrafik/blob/9c657fde1e91229c5878ea25530260596d296d37/vasttrafik/__main__.py#L18-L22 | train | Put together the default configuration path based on OS. |
persandstrom/python-vasttrafik | vasttrafik/__main__.py | read_config | def read_config():
"""Read configuration file"""
config = configparser.RawConfigParser(allow_no_value=True)
config.read(get_config_path())
if not config.has_section('credentials'):
config.add_section('credentials')
config.set('credentials', 'key', '')
config.set('credentials', 's... | python | def read_config():
"""Read configuration file"""
config = configparser.RawConfigParser(allow_no_value=True)
config.read(get_config_path())
if not config.has_section('credentials'):
config.add_section('credentials')
config.set('credentials', 'key', '')
config.set('credentials', 's... | [
"def",
"read_config",
"(",
")",
":",
"config",
"=",
"configparser",
".",
"RawConfigParser",
"(",
"allow_no_value",
"=",
"True",
")",
"config",
".",
"read",
"(",
"get_config_path",
"(",
")",
")",
"if",
"not",
"config",
".",
"has_section",
"(",
"'credentials'"... | Read configuration file | [
"Read",
"configuration",
"file"
] | 9c657fde1e91229c5878ea25530260596d296d37 | https://github.com/persandstrom/python-vasttrafik/blob/9c657fde1e91229c5878ea25530260596d296d37/vasttrafik/__main__.py#L25-L34 | train | Read configuration file and return it as a ConfigParser object |
persandstrom/python-vasttrafik | vasttrafik/__main__.py | print_table | def print_table(document, *columns):
""" Print json document as table """
headers = []
for _, header in columns:
headers.append(header)
table = []
for element in document:
row = []
for item, _ in columns:
if item in element:
row.append(element[item... | python | def print_table(document, *columns):
""" Print json document as table """
headers = []
for _, header in columns:
headers.append(header)
table = []
for element in document:
row = []
for item, _ in columns:
if item in element:
row.append(element[item... | [
"def",
"print_table",
"(",
"document",
",",
"*",
"columns",
")",
":",
"headers",
"=",
"[",
"]",
"for",
"_",
",",
"header",
"in",
"columns",
":",
"headers",
".",
"append",
"(",
"header",
")",
"table",
"=",
"[",
"]",
"for",
"element",
"in",
"document",... | Print json document as table | [
"Print",
"json",
"document",
"as",
"table"
] | 9c657fde1e91229c5878ea25530260596d296d37 | https://github.com/persandstrom/python-vasttrafik/blob/9c657fde1e91229c5878ea25530260596d296d37/vasttrafik/__main__.py#L43-L57 | train | Print json document as table |
persandstrom/python-vasttrafik | vasttrafik/__main__.py | print_trip_table | def print_trip_table(document):
""" Print trip table """
headers = [
'Alt.',
'Name',
'Time',
'Track',
'Direction',
'Dest.',
'Track',
'Arrival']
table = []
altnr = 0
for alternative in document:
altnr += 1
first_trip_in_a... | python | def print_trip_table(document):
""" Print trip table """
headers = [
'Alt.',
'Name',
'Time',
'Track',
'Direction',
'Dest.',
'Track',
'Arrival']
table = []
altnr = 0
for alternative in document:
altnr += 1
first_trip_in_a... | [
"def",
"print_trip_table",
"(",
"document",
")",
":",
"headers",
"=",
"[",
"'Alt.'",
",",
"'Name'",
",",
"'Time'",
",",
"'Track'",
",",
"'Direction'",
",",
"'Dest.'",
",",
"'Track'",
",",
"'Arrival'",
"]",
"table",
"=",
"[",
"]",
"altnr",
"=",
"0",
"fo... | Print trip table | [
"Print",
"trip",
"table"
] | 9c657fde1e91229c5878ea25530260596d296d37 | https://github.com/persandstrom/python-vasttrafik/blob/9c657fde1e91229c5878ea25530260596d296d37/vasttrafik/__main__.py#L60-L93 | train | Print trip table. |
persandstrom/python-vasttrafik | vasttrafik/__main__.py | main | def main():
""" Main function """
config = read_config()
key = config.get('credentials', 'key')
secret = config.get('credentials', 'secret')
parser = argparse.ArgumentParser(
description=u'Västtrafik journy planner (vtjp)')
parser.add_argument(
'-k',
'--key',
narg... | python | def main():
""" Main function """
config = read_config()
key = config.get('credentials', 'key')
secret = config.get('credentials', 'secret')
parser = argparse.ArgumentParser(
description=u'Västtrafik journy planner (vtjp)')
parser.add_argument(
'-k',
'--key',
narg... | [
"def",
"main",
"(",
")",
":",
"config",
"=",
"read_config",
"(",
")",
"key",
"=",
"config",
".",
"get",
"(",
"'credentials'",
",",
"'key'",
")",
"secret",
"=",
"config",
".",
"get",
"(",
"'credentials'",
",",
"'secret'",
")",
"parser",
"=",
"argparse",... | Main function | [
"Main",
"function"
] | 9c657fde1e91229c5878ea25530260596d296d37 | https://github.com/persandstrom/python-vasttrafik/blob/9c657fde1e91229c5878ea25530260596d296d37/vasttrafik/__main__.py#L97-L322 | train | Main function for the base class |
azavea/python-sld | sld/__init__.py | SLDNode.makeproperty | def makeproperty(ns, cls=None, name=None, docstring='', descendant=True):
"""
Make a property on an instance of an SLDNode. If cls is omitted, the
property is assumed to be a text node, with no corresponding class
object. If name is omitted, the property is assumed to be a complex
... | python | def makeproperty(ns, cls=None, name=None, docstring='', descendant=True):
"""
Make a property on an instance of an SLDNode. If cls is omitted, the
property is assumed to be a text node, with no corresponding class
object. If name is omitted, the property is assumed to be a complex
... | [
"def",
"makeproperty",
"(",
"ns",
",",
"cls",
"=",
"None",
",",
"name",
"=",
"None",
",",
"docstring",
"=",
"''",
",",
"descendant",
"=",
"True",
")",
":",
"def",
"get_property",
"(",
"self",
")",
":",
"\"\"\"\n A generic property getter.\n ... | Make a property on an instance of an SLDNode. If cls is omitted, the
property is assumed to be a text node, with no corresponding class
object. If name is omitted, the property is assumed to be a complex
node, with a corresponding class wrapper.
@type ns: string
@param ... | [
"Make",
"a",
"property",
"on",
"an",
"instance",
"of",
"an",
"SLDNode",
".",
"If",
"cls",
"is",
"omitted",
"the",
"property",
"is",
"assumed",
"to",
"be",
"a",
"text",
"node",
"with",
"no",
"corresponding",
"class",
"object",
".",
"If",
"name",
"is",
"... | 70e363782b39249bc9512a78dbbc45aaee52aaf5 | https://github.com/azavea/python-sld/blob/70e363782b39249bc9512a78dbbc45aaee52aaf5/sld/__init__.py#L83-L160 | train | This function creates a property on an instance of an SLDNode. |
azavea/python-sld | sld/__init__.py | SLDNode.get_or_create_element | def get_or_create_element(self, ns, name):
"""
Attempt to get the only child element from this SLDNode. If the node
does not exist, create the element, attach it to the DOM, and return
the class object that wraps the node.
@type ns: string
@param ns: The namespace o... | python | def get_or_create_element(self, ns, name):
"""
Attempt to get the only child element from this SLDNode. If the node
does not exist, create the element, attach it to the DOM, and return
the class object that wraps the node.
@type ns: string
@param ns: The namespace o... | [
"def",
"get_or_create_element",
"(",
"self",
",",
"ns",
",",
"name",
")",
":",
"if",
"len",
"(",
"self",
".",
"_node",
".",
"xpath",
"(",
"'%s:%s'",
"%",
"(",
"ns",
",",
"name",
")",
",",
"namespaces",
"=",
"SLDNode",
".",
"_nsmap",
")",
")",
"==",... | Attempt to get the only child element from this SLDNode. If the node
does not exist, create the element, attach it to the DOM, and return
the class object that wraps the node.
@type ns: string
@param ns: The namespace of the new element.
@type name: string
@param n... | [
"Attempt",
"to",
"get",
"the",
"only",
"child",
"element",
"from",
"this",
"SLDNode",
".",
"If",
"the",
"node",
"does",
"not",
"exist",
"create",
"the",
"element",
"attach",
"it",
"to",
"the",
"DOM",
"and",
"return",
"the",
"class",
"object",
"that",
"wr... | 70e363782b39249bc9512a78dbbc45aaee52aaf5 | https://github.com/azavea/python-sld/blob/70e363782b39249bc9512a78dbbc45aaee52aaf5/sld/__init__.py#L162-L179 | train | Attempt to get the only child element from this SLDNode and create it if it does not exist. |
azavea/python-sld | sld/__init__.py | SLDNode.create_element | def create_element(self, ns, name):
"""
Create an element as a child of this SLDNode.
@type ns: string
@param ns: The namespace of the new element.
@type name: string
@param name: The name of the new element.
@rtype: L{SLDNode}
@return: The wrapped ... | python | def create_element(self, ns, name):
"""
Create an element as a child of this SLDNode.
@type ns: string
@param ns: The namespace of the new element.
@type name: string
@param name: The name of the new element.
@rtype: L{SLDNode}
@return: The wrapped ... | [
"def",
"create_element",
"(",
"self",
",",
"ns",
",",
"name",
")",
":",
"elem",
"=",
"self",
".",
"_node",
".",
"makeelement",
"(",
"'{%s}%s'",
"%",
"(",
"SLDNode",
".",
"_nsmap",
"[",
"ns",
"]",
",",
"name",
")",
",",
"nsmap",
"=",
"SLDNode",
".",... | Create an element as a child of this SLDNode.
@type ns: string
@param ns: The namespace of the new element.
@type name: string
@param name: The name of the new element.
@rtype: L{SLDNode}
@return: The wrapped node, in the parent's property class. This will
... | [
"Create",
"an",
"element",
"as",
"a",
"child",
"of",
"this",
"SLDNode",
"."
] | 70e363782b39249bc9512a78dbbc45aaee52aaf5 | https://github.com/azavea/python-sld/blob/70e363782b39249bc9512a78dbbc45aaee52aaf5/sld/__init__.py#L181-L196 | train | Create an element as a child of this node. |
azavea/python-sld | sld/__init__.py | StyleItem.create_cssparameter | def create_cssparameter(self, name=None, value=None):
"""
Create a new L{CssParameter} node as a child of this element, and attach it to the DOM.
Optionally set the name and value of the parameter, if they are both provided.
@type name: string
@param name: Optional. The name ... | python | def create_cssparameter(self, name=None, value=None):
"""
Create a new L{CssParameter} node as a child of this element, and attach it to the DOM.
Optionally set the name and value of the parameter, if they are both provided.
@type name: string
@param name: Optional. The name ... | [
"def",
"create_cssparameter",
"(",
"self",
",",
"name",
"=",
"None",
",",
"value",
"=",
"None",
")",
":",
"elem",
"=",
"self",
".",
"_node",
".",
"makeelement",
"(",
"'{%s}CssParameter'",
"%",
"SLDNode",
".",
"_nsmap",
"[",
"'sld'",
"]",
",",
"nsmap",
... | Create a new L{CssParameter} node as a child of this element, and attach it to the DOM.
Optionally set the name and value of the parameter, if they are both provided.
@type name: string
@param name: Optional. The name of the L{CssParameter}
@type value: string
@param value: ... | [
"Create",
"a",
"new",
"L",
"{",
"CssParameter",
"}",
"node",
"as",
"a",
"child",
"of",
"this",
"element",
"and",
"attach",
"it",
"to",
"the",
"DOM",
".",
"Optionally",
"set",
"the",
"name",
"and",
"value",
"of",
"the",
"parameter",
"if",
"they",
"are",... | 70e363782b39249bc9512a78dbbc45aaee52aaf5 | https://github.com/azavea/python-sld/blob/70e363782b39249bc9512a78dbbc45aaee52aaf5/sld/__init__.py#L365-L384 | train | Create a new style parameter node and attach it to the DOM. |
azavea/python-sld | sld/__init__.py | Rule.normalize | def normalize(self):
"""
Normalize this node prior to validation. This is required, as the
ogc:Filter node must come before any symbolizer nodes. The SLD
is modified in place.
"""
order = [
'sld:Title', 'ogc:Filter', 'sld:MinScaleDenominator',
'sld... | python | def normalize(self):
"""
Normalize this node prior to validation. This is required, as the
ogc:Filter node must come before any symbolizer nodes. The SLD
is modified in place.
"""
order = [
'sld:Title', 'ogc:Filter', 'sld:MinScaleDenominator',
'sld... | [
"def",
"normalize",
"(",
"self",
")",
":",
"order",
"=",
"[",
"'sld:Title'",
",",
"'ogc:Filter'",
",",
"'sld:MinScaleDenominator'",
",",
"'sld:MaxScaleDenominator'",
",",
"'sld:PolygonSymbolizer'",
",",
"'sld:LineSymbolizer'",
",",
"'sld:TextSymbolizer'",
",",
"'sld:Poi... | Normalize this node prior to validation. This is required, as the
ogc:Filter node must come before any symbolizer nodes. The SLD
is modified in place. | [
"Normalize",
"this",
"node",
"prior",
"to",
"validation",
".",
"This",
"is",
"required",
"as",
"the",
"ogc",
":",
"Filter",
"node",
"must",
"come",
"before",
"any",
"symbolizer",
"nodes",
".",
"The",
"SLD",
"is",
"modified",
"in",
"place",
"."
] | 70e363782b39249bc9512a78dbbc45aaee52aaf5 | https://github.com/azavea/python-sld/blob/70e363782b39249bc9512a78dbbc45aaee52aaf5/sld/__init__.py#L1040-L1055 | train | This method is used to normalize the node prior to validation. |
azavea/python-sld | sld/__init__.py | Rule.create_filter | def create_filter(self, propname=None, comparitor=None, value=None):
"""
Create a L{Filter} for this rule. The property name, comparitor, and value
are required to create a valid Filter.
@type propname: string
@param propname: The name of the property to filter.
@ty... | python | def create_filter(self, propname=None, comparitor=None, value=None):
"""
Create a L{Filter} for this rule. The property name, comparitor, and value
are required to create a valid Filter.
@type propname: string
@param propname: The name of the property to filter.
@ty... | [
"def",
"create_filter",
"(",
"self",
",",
"propname",
"=",
"None",
",",
"comparitor",
"=",
"None",
",",
"value",
"=",
"None",
")",
":",
"if",
"propname",
"is",
"None",
"or",
"comparitor",
"is",
"None",
"or",
"value",
"is",
"None",
":",
"return",
"None"... | Create a L{Filter} for this rule. The property name, comparitor, and value
are required to create a valid Filter.
@type propname: string
@param propname: The name of the property to filter.
@type comparitor: string
@param comparitor: The comparison to perform on the proper... | [
"Create",
"a",
"L",
"{",
"Filter",
"}",
"for",
"this",
"rule",
".",
"The",
"property",
"name",
"comparitor",
"and",
"value",
"are",
"required",
"to",
"create",
"a",
"valid",
"Filter",
"."
] | 70e363782b39249bc9512a78dbbc45aaee52aaf5 | https://github.com/azavea/python-sld/blob/70e363782b39249bc9512a78dbbc45aaee52aaf5/sld/__init__.py#L1059-L1101 | train | Creates a new filter for this rule. |
azavea/python-sld | sld/__init__.py | Rules.normalize | def normalize(self):
"""
Normalize this node and all rules contained within. The SLD model is
modified in place.
"""
for i, rnode in enumerate(self._nodes):
rule = Rule(self, i - 1, descendant=False)
rule.normalize() | python | def normalize(self):
"""
Normalize this node and all rules contained within. The SLD model is
modified in place.
"""
for i, rnode in enumerate(self._nodes):
rule = Rule(self, i - 1, descendant=False)
rule.normalize() | [
"def",
"normalize",
"(",
"self",
")",
":",
"for",
"i",
",",
"rnode",
"in",
"enumerate",
"(",
"self",
".",
"_nodes",
")",
":",
"rule",
"=",
"Rule",
"(",
"self",
",",
"i",
"-",
"1",
",",
"descendant",
"=",
"False",
")",
"rule",
".",
"normalize",
"(... | Normalize this node and all rules contained within. The SLD model is
modified in place. | [
"Normalize",
"this",
"node",
"and",
"all",
"rules",
"contained",
"within",
".",
"The",
"SLD",
"model",
"is",
"modified",
"in",
"place",
"."
] | 70e363782b39249bc9512a78dbbc45aaee52aaf5 | https://github.com/azavea/python-sld/blob/70e363782b39249bc9512a78dbbc45aaee52aaf5/sld/__init__.py#L1137-L1144 | train | Normalize this node and all rules contained within. The SLD model is
modified in place. |
azavea/python-sld | sld/__init__.py | FeatureTypeStyle.create_rule | def create_rule(self, title, symbolizer=None, MinScaleDenominator=None, MaxScaleDenominator=None):
"""
Create a L{Rule} object on this style. A rule requires a title and
symbolizer. If no symbolizer is specified, a PointSymbolizer will be
assigned to the rule.
@type title:... | python | def create_rule(self, title, symbolizer=None, MinScaleDenominator=None, MaxScaleDenominator=None):
"""
Create a L{Rule} object on this style. A rule requires a title and
symbolizer. If no symbolizer is specified, a PointSymbolizer will be
assigned to the rule.
@type title:... | [
"def",
"create_rule",
"(",
"self",
",",
"title",
",",
"symbolizer",
"=",
"None",
",",
"MinScaleDenominator",
"=",
"None",
",",
"MaxScaleDenominator",
"=",
"None",
")",
":",
"elem",
"=",
"self",
".",
"_node",
".",
"makeelement",
"(",
"'{%s}Rule'",
"%",
"SLD... | Create a L{Rule} object on this style. A rule requires a title and
symbolizer. If no symbolizer is specified, a PointSymbolizer will be
assigned to the rule.
@type title: string
@param title: The name of the new L{Rule}.
@type symbolizer: L{Symbolizer} I{class}
... | [
"Create",
"a",
"L",
"{",
"Rule",
"}",
"object",
"on",
"this",
"style",
".",
"A",
"rule",
"requires",
"a",
"title",
"and",
"symbolizer",
".",
"If",
"no",
"symbolizer",
"is",
"specified",
"a",
"PointSymbolizer",
"will",
"be",
"assigned",
"to",
"the",
"rule... | 70e363782b39249bc9512a78dbbc45aaee52aaf5 | https://github.com/azavea/python-sld/blob/70e363782b39249bc9512a78dbbc45aaee52aaf5/sld/__init__.py#L1227-L1274 | train | Create a new rule on this style. |
azavea/python-sld | sld/__init__.py | StyledLayerDescriptor.validate | def validate(self):
"""
Validate the current file against the SLD schema. This first normalizes
the SLD document, then validates it. Any schema validation error messages
are logged at the INFO level.
@rtype: boolean
@return: A flag indicating if the SLD is valid.
... | python | def validate(self):
"""
Validate the current file against the SLD schema. This first normalizes
the SLD document, then validates it. Any schema validation error messages
are logged at the INFO level.
@rtype: boolean
@return: A flag indicating if the SLD is valid.
... | [
"def",
"validate",
"(",
"self",
")",
":",
"self",
".",
"normalize",
"(",
")",
"if",
"self",
".",
"_node",
"is",
"None",
":",
"logging",
".",
"debug",
"(",
"'The node is empty, and cannot be validated.'",
")",
"return",
"False",
"if",
"self",
".",
"_schema",
... | Validate the current file against the SLD schema. This first normalizes
the SLD document, then validates it. Any schema validation error messages
are logged at the INFO level.
@rtype: boolean
@return: A flag indicating if the SLD is valid. | [
"Validate",
"the",
"current",
"file",
"against",
"the",
"SLD",
"schema",
".",
"This",
"first",
"normalizes",
"the",
"SLD",
"document",
"then",
"validates",
"it",
".",
"Any",
"schema",
"validation",
"error",
"messages",
"are",
"logged",
"at",
"the",
"INFO",
"... | 70e363782b39249bc9512a78dbbc45aaee52aaf5 | https://github.com/azavea/python-sld/blob/70e363782b39249bc9512a78dbbc45aaee52aaf5/sld/__init__.py#L1488-L1511 | train | Validate the current SLD document against the SLD schema. |
azavea/python-sld | sld/__init__.py | StyledLayerDescriptor.create_namedlayer | def create_namedlayer(self, name):
"""
Create a L{NamedLayer} in this SLD.
@type name: string
@param name: The name of the layer.
@rtype: L{NamedLayer}
@return: The named layer, attached to this SLD.
"""
namedlayer = self.get_or_create_element('sld', 'Na... | python | def create_namedlayer(self, name):
"""
Create a L{NamedLayer} in this SLD.
@type name: string
@param name: The name of the layer.
@rtype: L{NamedLayer}
@return: The named layer, attached to this SLD.
"""
namedlayer = self.get_or_create_element('sld', 'Na... | [
"def",
"create_namedlayer",
"(",
"self",
",",
"name",
")",
":",
"namedlayer",
"=",
"self",
".",
"get_or_create_element",
"(",
"'sld'",
",",
"'NamedLayer'",
")",
"namedlayer",
".",
"Name",
"=",
"name",
"return",
"namedlayer"
] | Create a L{NamedLayer} in this SLD.
@type name: string
@param name: The name of the layer.
@rtype: L{NamedLayer}
@return: The named layer, attached to this SLD. | [
"Create",
"a",
"L",
"{",
"NamedLayer",
"}",
"in",
"this",
"SLD",
"."
] | 70e363782b39249bc9512a78dbbc45aaee52aaf5 | https://github.com/azavea/python-sld/blob/70e363782b39249bc9512a78dbbc45aaee52aaf5/sld/__init__.py#L1527-L1538 | train | Create a named layer in this SLD. |
jedie/PyHardLinkBackup | PyHardLinkBackup/phlb_cli.py | cli | def cli(ctx):
"""PyHardLinkBackup"""
click.secho("\nPyHardLinkBackup v%s\n" % PyHardLinkBackup.__version__, bg="blue", fg="white", bold=True) | python | def cli(ctx):
"""PyHardLinkBackup"""
click.secho("\nPyHardLinkBackup v%s\n" % PyHardLinkBackup.__version__, bg="blue", fg="white", bold=True) | [
"def",
"cli",
"(",
"ctx",
")",
":",
"click",
".",
"secho",
"(",
"\"\\nPyHardLinkBackup v%s\\n\"",
"%",
"PyHardLinkBackup",
".",
"__version__",
",",
"bg",
"=",
"\"blue\"",
",",
"fg",
"=",
"\"white\"",
",",
"bold",
"=",
"True",
")"
] | PyHardLinkBackup | [
"PyHardLinkBackup"
] | be28666834d2d9e3d8aac1b661cb2d5bd4056c29 | https://github.com/jedie/PyHardLinkBackup/blob/be28666834d2d9e3d8aac1b661cb2d5bd4056c29/PyHardLinkBackup/phlb_cli.py#L36-L38 | train | Show version of PyHardLinkBackup. |
jedie/PyHardLinkBackup | PyHardLinkBackup/phlb_cli.py | helper | def helper(path):
"""
link helper files to given path
"""
if sys.platform.startswith("win"):
# link batch files
src_path = os.path.join(PHLB_BASE_DIR, "helper_cmd")
elif sys.platform.startswith("linux"):
# link shell scripts
src_path = os.path.join(PHLB_BASE_DIR, "hel... | python | def helper(path):
"""
link helper files to given path
"""
if sys.platform.startswith("win"):
# link batch files
src_path = os.path.join(PHLB_BASE_DIR, "helper_cmd")
elif sys.platform.startswith("linux"):
# link shell scripts
src_path = os.path.join(PHLB_BASE_DIR, "hel... | [
"def",
"helper",
"(",
"path",
")",
":",
"if",
"sys",
".",
"platform",
".",
"startswith",
"(",
"\"win\"",
")",
":",
"# link batch files",
"src_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"PHLB_BASE_DIR",
",",
"\"helper_cmd\"",
")",
"elif",
"sys",
"."... | link helper files to given path | [
"link",
"helper",
"files",
"to",
"given",
"path"
] | be28666834d2d9e3d8aac1b661cb2d5bd4056c29 | https://github.com/jedie/PyHardLinkBackup/blob/be28666834d2d9e3d8aac1b661cb2d5bd4056c29/PyHardLinkBackup/phlb_cli.py#L43-L79 | train | Link helper files to given path |
jedie/PyHardLinkBackup | PyHardLinkBackup/phlb_cli.py | backup | def backup(path, name=None):
"""Start a Backup run"""
from PyHardLinkBackup.phlb.phlb_main import backup
backup(path, name) | python | def backup(path, name=None):
"""Start a Backup run"""
from PyHardLinkBackup.phlb.phlb_main import backup
backup(path, name) | [
"def",
"backup",
"(",
"path",
",",
"name",
"=",
"None",
")",
":",
"from",
"PyHardLinkBackup",
".",
"phlb",
".",
"phlb_main",
"import",
"backup",
"backup",
"(",
"path",
",",
"name",
")"
] | Start a Backup run | [
"Start",
"a",
"Backup",
"run"
] | be28666834d2d9e3d8aac1b661cb2d5bd4056c29 | https://github.com/jedie/PyHardLinkBackup/blob/be28666834d2d9e3d8aac1b661cb2d5bd4056c29/PyHardLinkBackup/phlb_cli.py#L104-L108 | train | Start a Backup run |
jedie/PyHardLinkBackup | PyHardLinkBackup/phlb_cli.py | verify | def verify(backup_path, fast):
"""Verify a existing backup"""
from PyHardLinkBackup.phlb.verify import verify_backup
verify_backup(backup_path, fast) | python | def verify(backup_path, fast):
"""Verify a existing backup"""
from PyHardLinkBackup.phlb.verify import verify_backup
verify_backup(backup_path, fast) | [
"def",
"verify",
"(",
"backup_path",
",",
"fast",
")",
":",
"from",
"PyHardLinkBackup",
".",
"phlb",
".",
"verify",
"import",
"verify_backup",
"verify_backup",
"(",
"backup_path",
",",
"fast",
")"
] | Verify a existing backup | [
"Verify",
"a",
"existing",
"backup"
] | be28666834d2d9e3d8aac1b661cb2d5bd4056c29 | https://github.com/jedie/PyHardLinkBackup/blob/be28666834d2d9e3d8aac1b661cb2d5bd4056c29/PyHardLinkBackup/phlb_cli.py#L120-L124 | train | Verify a backup |
aiidateam/aiida-codtools | setup.py | setup_package | def setup_package():
"""Setup procedure."""
import json
from setuptools import setup, find_packages
filename_setup_json = 'setup.json'
filename_description = 'README.md'
with open(filename_setup_json, 'r') as handle:
setup_json = json.load(handle)
with open(filename_description, '... | python | def setup_package():
"""Setup procedure."""
import json
from setuptools import setup, find_packages
filename_setup_json = 'setup.json'
filename_description = 'README.md'
with open(filename_setup_json, 'r') as handle:
setup_json = json.load(handle)
with open(filename_description, '... | [
"def",
"setup_package",
"(",
")",
":",
"import",
"json",
"from",
"setuptools",
"import",
"setup",
",",
"find_packages",
"filename_setup_json",
"=",
"'setup.json'",
"filename_description",
"=",
"'README.md'",
"with",
"open",
"(",
"filename_setup_json",
",",
"'r'",
")... | Setup procedure. | [
"Setup",
"procedure",
"."
] | da5e4259b7a2e86cf0cc3f997e11dd36d445fa94 | https://github.com/aiidateam/aiida-codtools/blob/da5e4259b7a2e86cf0cc3f997e11dd36d445fa94/setup.py#L5-L26 | train | Setup procedure. |
Capitains/MyCapytain | MyCapytain/common/utils/_json_ld.py | literal_to_dict | def literal_to_dict(value):
""" Transform an object value into a dict readable value
:param value: Object of a triple which is not a BNode
:type value: Literal or URIRef
:return: dict or str or list
"""
if isinstance(value, Literal):
if value.language is not None:
return {"@... | python | def literal_to_dict(value):
""" Transform an object value into a dict readable value
:param value: Object of a triple which is not a BNode
:type value: Literal or URIRef
:return: dict or str or list
"""
if isinstance(value, Literal):
if value.language is not None:
return {"@... | [
"def",
"literal_to_dict",
"(",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"Literal",
")",
":",
"if",
"value",
".",
"language",
"is",
"not",
"None",
":",
"return",
"{",
"\"@value\"",
":",
"str",
"(",
"value",
")",
",",
"\"@language\"",
":... | Transform an object value into a dict readable value
:param value: Object of a triple which is not a BNode
:type value: Literal or URIRef
:return: dict or str or list | [
"Transform",
"an",
"object",
"value",
"into",
"a",
"dict",
"readable",
"value"
] | b11bbf6b6ae141fc02be70471e3fbf6907be6593 | https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/common/utils/_json_ld.py#L4-L19 | train | Transform an object value into a dict readable value |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.