id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
56,300 | pudo/jsongraph | jsongraph/common.py | GraphOperations.get | def get(self, id, depth=3, schema=None):
""" Construct a single object based on its ID. """
uri = URIRef(id)
if schema is None:
for o in self.graph.objects(subject=uri, predicate=RDF.type):
schema = self.parent.get_schema(str(o))
if schema is not None:... | python | def get(self, id, depth=3, schema=None):
""" Construct a single object based on its ID. """
uri = URIRef(id)
if schema is None:
for o in self.graph.objects(subject=uri, predicate=RDF.type):
schema = self.parent.get_schema(str(o))
if schema is not None:... | [
"def",
"get",
"(",
"self",
",",
"id",
",",
"depth",
"=",
"3",
",",
"schema",
"=",
"None",
")",
":",
"uri",
"=",
"URIRef",
"(",
"id",
")",
"if",
"schema",
"is",
"None",
":",
"for",
"o",
"in",
"self",
".",
"graph",
".",
"objects",
"(",
"subject",... | Construct a single object based on its ID. | [
"Construct",
"a",
"single",
"object",
"based",
"on",
"its",
"ID",
"."
] | 35e4f397dbe69cd5553cf9cb9ab98859c3620f03 | https://github.com/pudo/jsongraph/blob/35e4f397dbe69cd5553cf9cb9ab98859c3620f03/jsongraph/common.py#L17-L28 |
56,301 | inveniosoftware/invenio-openaire | invenio_openaire/loaders.py | BaseOAIRELoader.get_text_node | def get_text_node(self, tree, xpath_str):
"""Return a text node from given XML tree given an lxml XPath."""
try:
text = tree.xpath(xpath_str, namespaces=self.namespaces)[0].text
return text_type(text) if text else ''
except IndexError: # pragma: nocover
retur... | python | def get_text_node(self, tree, xpath_str):
"""Return a text node from given XML tree given an lxml XPath."""
try:
text = tree.xpath(xpath_str, namespaces=self.namespaces)[0].text
return text_type(text) if text else ''
except IndexError: # pragma: nocover
retur... | [
"def",
"get_text_node",
"(",
"self",
",",
"tree",
",",
"xpath_str",
")",
":",
"try",
":",
"text",
"=",
"tree",
".",
"xpath",
"(",
"xpath_str",
",",
"namespaces",
"=",
"self",
".",
"namespaces",
")",
"[",
"0",
"]",
".",
"text",
"return",
"text_type",
... | Return a text node from given XML tree given an lxml XPath. | [
"Return",
"a",
"text",
"node",
"from",
"given",
"XML",
"tree",
"given",
"an",
"lxml",
"XPath",
"."
] | 71860effff6abe7f658d3a11894e064202ef1c36 | https://github.com/inveniosoftware/invenio-openaire/blob/71860effff6abe7f658d3a11894e064202ef1c36/invenio_openaire/loaders.py#L112-L118 |
56,302 | inveniosoftware/invenio-openaire | invenio_openaire/loaders.py | BaseOAIRELoader.get_subtree | def get_subtree(self, tree, xpath_str):
"""Return a subtree given an lxml XPath."""
return tree.xpath(xpath_str, namespaces=self.namespaces) | python | def get_subtree(self, tree, xpath_str):
"""Return a subtree given an lxml XPath."""
return tree.xpath(xpath_str, namespaces=self.namespaces) | [
"def",
"get_subtree",
"(",
"self",
",",
"tree",
",",
"xpath_str",
")",
":",
"return",
"tree",
".",
"xpath",
"(",
"xpath_str",
",",
"namespaces",
"=",
"self",
".",
"namespaces",
")"
] | Return a subtree given an lxml XPath. | [
"Return",
"a",
"subtree",
"given",
"an",
"lxml",
"XPath",
"."
] | 71860effff6abe7f658d3a11894e064202ef1c36 | https://github.com/inveniosoftware/invenio-openaire/blob/71860effff6abe7f658d3a11894e064202ef1c36/invenio_openaire/loaders.py#L120-L122 |
56,303 | inveniosoftware/invenio-openaire | invenio_openaire/loaders.py | BaseOAIRELoader.fundertree2json | def fundertree2json(self, tree, oai_id):
"""Convert OpenAIRE's funder XML to JSON."""
try:
tree = self.get_subtree(tree, 'fundingtree')[0]
except IndexError: # pragma: nocover
pass
funder_node = self.get_subtree(tree, 'funder')
subfunder_node = self.get_... | python | def fundertree2json(self, tree, oai_id):
"""Convert OpenAIRE's funder XML to JSON."""
try:
tree = self.get_subtree(tree, 'fundingtree')[0]
except IndexError: # pragma: nocover
pass
funder_node = self.get_subtree(tree, 'funder')
subfunder_node = self.get_... | [
"def",
"fundertree2json",
"(",
"self",
",",
"tree",
",",
"oai_id",
")",
":",
"try",
":",
"tree",
"=",
"self",
".",
"get_subtree",
"(",
"tree",
",",
"'fundingtree'",
")",
"[",
"0",
"]",
"except",
"IndexError",
":",
"# pragma: nocover",
"pass",
"funder_node"... | Convert OpenAIRE's funder XML to JSON. | [
"Convert",
"OpenAIRE",
"s",
"funder",
"XML",
"to",
"JSON",
"."
] | 71860effff6abe7f658d3a11894e064202ef1c36 | https://github.com/inveniosoftware/invenio-openaire/blob/71860effff6abe7f658d3a11894e064202ef1c36/invenio_openaire/loaders.py#L124-L175 |
56,304 | inveniosoftware/invenio-openaire | invenio_openaire/loaders.py | BaseOAIRELoader.grantxml2json | def grantxml2json(self, grant_xml):
"""Convert OpenAIRE grant XML into JSON."""
tree = etree.fromstring(grant_xml)
# XML harvested from OAI-PMH has a different format/structure
if tree.prefix == 'oai':
ptree = self.get_subtree(
tree, '/oai:record/oai:metadata/... | python | def grantxml2json(self, grant_xml):
"""Convert OpenAIRE grant XML into JSON."""
tree = etree.fromstring(grant_xml)
# XML harvested from OAI-PMH has a different format/structure
if tree.prefix == 'oai':
ptree = self.get_subtree(
tree, '/oai:record/oai:metadata/... | [
"def",
"grantxml2json",
"(",
"self",
",",
"grant_xml",
")",
":",
"tree",
"=",
"etree",
".",
"fromstring",
"(",
"grant_xml",
")",
"# XML harvested from OAI-PMH has a different format/structure",
"if",
"tree",
".",
"prefix",
"==",
"'oai'",
":",
"ptree",
"=",
"self",... | Convert OpenAIRE grant XML into JSON. | [
"Convert",
"OpenAIRE",
"grant",
"XML",
"into",
"JSON",
"."
] | 71860effff6abe7f658d3a11894e064202ef1c36 | https://github.com/inveniosoftware/invenio-openaire/blob/71860effff6abe7f658d3a11894e064202ef1c36/invenio_openaire/loaders.py#L177-L228 |
56,305 | inveniosoftware/invenio-openaire | invenio_openaire/loaders.py | LocalOAIRELoader.iter_grants | def iter_grants(self, as_json=True):
"""Fetch records from the SQLite database."""
self._connect()
result = self.db_connection.cursor().execute(
"SELECT data, format FROM grants"
)
for data, data_format in result:
if (not as_json) and data_format == 'json'... | python | def iter_grants(self, as_json=True):
"""Fetch records from the SQLite database."""
self._connect()
result = self.db_connection.cursor().execute(
"SELECT data, format FROM grants"
)
for data, data_format in result:
if (not as_json) and data_format == 'json'... | [
"def",
"iter_grants",
"(",
"self",
",",
"as_json",
"=",
"True",
")",
":",
"self",
".",
"_connect",
"(",
")",
"result",
"=",
"self",
".",
"db_connection",
".",
"cursor",
"(",
")",
".",
"execute",
"(",
"\"SELECT data, format FROM grants\"",
")",
"for",
"data... | Fetch records from the SQLite database. | [
"Fetch",
"records",
"from",
"the",
"SQLite",
"database",
"."
] | 71860effff6abe7f658d3a11894e064202ef1c36 | https://github.com/inveniosoftware/invenio-openaire/blob/71860effff6abe7f658d3a11894e064202ef1c36/invenio_openaire/loaders.py#L279-L293 |
56,306 | inveniosoftware/invenio-openaire | invenio_openaire/loaders.py | RemoteOAIRELoader.iter_grants | def iter_grants(self, as_json=True):
"""Fetch grants from a remote OAI-PMH endpoint.
Return the Sickle-provided generator object.
"""
records = self.client.ListRecords(metadataPrefix='oaf',
set=self.setspec)
for rec in records:
... | python | def iter_grants(self, as_json=True):
"""Fetch grants from a remote OAI-PMH endpoint.
Return the Sickle-provided generator object.
"""
records = self.client.ListRecords(metadataPrefix='oaf',
set=self.setspec)
for rec in records:
... | [
"def",
"iter_grants",
"(",
"self",
",",
"as_json",
"=",
"True",
")",
":",
"records",
"=",
"self",
".",
"client",
".",
"ListRecords",
"(",
"metadataPrefix",
"=",
"'oaf'",
",",
"set",
"=",
"self",
".",
"setspec",
")",
"for",
"rec",
"in",
"records",
":",
... | Fetch grants from a remote OAI-PMH endpoint.
Return the Sickle-provided generator object. | [
"Fetch",
"grants",
"from",
"a",
"remote",
"OAI",
"-",
"PMH",
"endpoint",
"."
] | 71860effff6abe7f658d3a11894e064202ef1c36 | https://github.com/inveniosoftware/invenio-openaire/blob/71860effff6abe7f658d3a11894e064202ef1c36/invenio_openaire/loaders.py#L311-L326 |
56,307 | inveniosoftware/invenio-openaire | invenio_openaire/loaders.py | OAIREDumper.dump | def dump(self, as_json=True, commit_batch_size=100):
"""
Dump the grant information to a local storage.
:param as_json: Convert XML to JSON before saving (default: True).
"""
connection = sqlite3.connect(self.destination)
format_ = 'json' if as_json else 'xml'
if... | python | def dump(self, as_json=True, commit_batch_size=100):
"""
Dump the grant information to a local storage.
:param as_json: Convert XML to JSON before saving (default: True).
"""
connection = sqlite3.connect(self.destination)
format_ = 'json' if as_json else 'xml'
if... | [
"def",
"dump",
"(",
"self",
",",
"as_json",
"=",
"True",
",",
"commit_batch_size",
"=",
"100",
")",
":",
"connection",
"=",
"sqlite3",
".",
"connect",
"(",
"self",
".",
"destination",
")",
"format_",
"=",
"'json'",
"if",
"as_json",
"else",
"'xml'",
"if",... | Dump the grant information to a local storage.
:param as_json: Convert XML to JSON before saving (default: True). | [
"Dump",
"the",
"grant",
"information",
"to",
"a",
"local",
"storage",
"."
] | 71860effff6abe7f658d3a11894e064202ef1c36 | https://github.com/inveniosoftware/invenio-openaire/blob/71860effff6abe7f658d3a11894e064202ef1c36/invenio_openaire/loaders.py#L357-L382 |
56,308 | inveniosoftware/invenio-openaire | invenio_openaire/loaders.py | BaseFundRefLoader.iter_funders | def iter_funders(self):
"""Get a converted list of Funders as JSON dict."""
root = self.doc_root
funders = root.findall('./skos:Concept', namespaces=self.namespaces)
for funder in funders:
funder_json = self.fundrefxml2json(funder)
yield funder_json | python | def iter_funders(self):
"""Get a converted list of Funders as JSON dict."""
root = self.doc_root
funders = root.findall('./skos:Concept', namespaces=self.namespaces)
for funder in funders:
funder_json = self.fundrefxml2json(funder)
yield funder_json | [
"def",
"iter_funders",
"(",
"self",
")",
":",
"root",
"=",
"self",
".",
"doc_root",
"funders",
"=",
"root",
".",
"findall",
"(",
"'./skos:Concept'",
",",
"namespaces",
"=",
"self",
".",
"namespaces",
")",
"for",
"funder",
"in",
"funders",
":",
"funder_json... | Get a converted list of Funders as JSON dict. | [
"Get",
"a",
"converted",
"list",
"of",
"Funders",
"as",
"JSON",
"dict",
"."
] | 71860effff6abe7f658d3a11894e064202ef1c36 | https://github.com/inveniosoftware/invenio-openaire/blob/71860effff6abe7f658d3a11894e064202ef1c36/invenio_openaire/loaders.py#L503-L509 |
56,309 | inveniosoftware/invenio-openaire | invenio_openaire/loaders.py | FundRefDOIResolver.resolve_by_oai_id | def resolve_by_oai_id(self, oai_id):
"""Resolve the funder from the OpenAIRE OAI record id.
Hack for when funder is not provided in OpenAIRE.
"""
if oai_id.startswith('oai:dnet:'):
oai_id = oai_id[len('oai:dnet:'):]
prefix = oai_id.split("::")[0]
suffix = pre... | python | def resolve_by_oai_id(self, oai_id):
"""Resolve the funder from the OpenAIRE OAI record id.
Hack for when funder is not provided in OpenAIRE.
"""
if oai_id.startswith('oai:dnet:'):
oai_id = oai_id[len('oai:dnet:'):]
prefix = oai_id.split("::")[0]
suffix = pre... | [
"def",
"resolve_by_oai_id",
"(",
"self",
",",
"oai_id",
")",
":",
"if",
"oai_id",
".",
"startswith",
"(",
"'oai:dnet:'",
")",
":",
"oai_id",
"=",
"oai_id",
"[",
"len",
"(",
"'oai:dnet:'",
")",
":",
"]",
"prefix",
"=",
"oai_id",
".",
"split",
"(",
"\"::... | Resolve the funder from the OpenAIRE OAI record id.
Hack for when funder is not provided in OpenAIRE. | [
"Resolve",
"the",
"funder",
"from",
"the",
"OpenAIRE",
"OAI",
"record",
"id",
"."
] | 71860effff6abe7f658d3a11894e064202ef1c36 | https://github.com/inveniosoftware/invenio-openaire/blob/71860effff6abe7f658d3a11894e064202ef1c36/invenio_openaire/loaders.py#L578-L588 |
56,310 | pudo/jsongraph | jsongraph/reflect.py | predicates | def predicates(graph):
""" Return a listing of all known predicates in the registered schemata,
including the schema path they associate with, their name and allowed
types. """
seen = set()
def _traverse(binding):
if binding.path in seen:
return
seen.add(binding.path)
... | python | def predicates(graph):
""" Return a listing of all known predicates in the registered schemata,
including the schema path they associate with, their name and allowed
types. """
seen = set()
def _traverse(binding):
if binding.path in seen:
return
seen.add(binding.path)
... | [
"def",
"predicates",
"(",
"graph",
")",
":",
"seen",
"=",
"set",
"(",
")",
"def",
"_traverse",
"(",
"binding",
")",
":",
"if",
"binding",
".",
"path",
"in",
"seen",
":",
"return",
"seen",
".",
"add",
"(",
"binding",
".",
"path",
")",
"if",
"binding... | Return a listing of all known predicates in the registered schemata,
including the schema path they associate with, their name and allowed
types. | [
"Return",
"a",
"listing",
"of",
"all",
"known",
"predicates",
"in",
"the",
"registered",
"schemata",
"including",
"the",
"schema",
"path",
"they",
"associate",
"with",
"their",
"name",
"and",
"allowed",
"types",
"."
] | 35e4f397dbe69cd5553cf9cb9ab98859c3620f03 | https://github.com/pudo/jsongraph/blob/35e4f397dbe69cd5553cf9cb9ab98859c3620f03/jsongraph/reflect.py#L2-L30 |
56,311 | twisted/mantissa | xmantissa/signup.py | passwordReset1to2 | def passwordReset1to2(old):
"""
Power down and delete the item
"""
new = old.upgradeVersion(old.typeName, 1, 2, installedOn=None)
for iface in new.store.interfacesFor(new):
new.store.powerDown(new, iface)
new.deleteFromStore() | python | def passwordReset1to2(old):
"""
Power down and delete the item
"""
new = old.upgradeVersion(old.typeName, 1, 2, installedOn=None)
for iface in new.store.interfacesFor(new):
new.store.powerDown(new, iface)
new.deleteFromStore() | [
"def",
"passwordReset1to2",
"(",
"old",
")",
":",
"new",
"=",
"old",
".",
"upgradeVersion",
"(",
"old",
".",
"typeName",
",",
"1",
",",
"2",
",",
"installedOn",
"=",
"None",
")",
"for",
"iface",
"in",
"new",
".",
"store",
".",
"interfacesFor",
"(",
"... | Power down and delete the item | [
"Power",
"down",
"and",
"delete",
"the",
"item"
] | 53e5502aba23ce99be78b27f923a276593033fe8 | https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/signup.py#L319-L326 |
56,312 | twisted/mantissa | xmantissa/signup.py | ticket1to2 | def ticket1to2(old):
"""
change Ticket to refer to Products and not benefactor factories.
"""
if isinstance(old.benefactor, Multifactor):
types = list(chain(*[b.powerupNames for b in
old.benefactor.benefactors('ascending')]))
elif isinstance(old.benefactor, InitializerBenefac... | python | def ticket1to2(old):
"""
change Ticket to refer to Products and not benefactor factories.
"""
if isinstance(old.benefactor, Multifactor):
types = list(chain(*[b.powerupNames for b in
old.benefactor.benefactors('ascending')]))
elif isinstance(old.benefactor, InitializerBenefac... | [
"def",
"ticket1to2",
"(",
"old",
")",
":",
"if",
"isinstance",
"(",
"old",
".",
"benefactor",
",",
"Multifactor",
")",
":",
"types",
"=",
"list",
"(",
"chain",
"(",
"*",
"[",
"b",
".",
"powerupNames",
"for",
"b",
"in",
"old",
".",
"benefactor",
".",
... | change Ticket to refer to Products and not benefactor factories. | [
"change",
"Ticket",
"to",
"refer",
"to",
"Products",
"and",
"not",
"benefactor",
"factories",
"."
] | 53e5502aba23ce99be78b27f923a276593033fe8 | https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/signup.py#L982-L1008 |
56,313 | twisted/mantissa | xmantissa/signup.py | _getPublicSignupInfo | def _getPublicSignupInfo(siteStore):
"""
Get information about public web-based signup mechanisms.
@param siteStore: a store with some signups installed on it (as indicated
by _SignupTracker instances).
@return: a generator which yields 2-tuples of (prompt, url) where 'prompt'
is unicode brief... | python | def _getPublicSignupInfo(siteStore):
"""
Get information about public web-based signup mechanisms.
@param siteStore: a store with some signups installed on it (as indicated
by _SignupTracker instances).
@return: a generator which yields 2-tuples of (prompt, url) where 'prompt'
is unicode brief... | [
"def",
"_getPublicSignupInfo",
"(",
"siteStore",
")",
":",
"# Note the underscore; this _should_ be a public API but it is currently an",
"# unfortunate hack; there should be a different powerup interface that",
"# requires prompt and prefixURL attributes rather than _SignupTracker.",
"# -glyph",
... | Get information about public web-based signup mechanisms.
@param siteStore: a store with some signups installed on it (as indicated
by _SignupTracker instances).
@return: a generator which yields 2-tuples of (prompt, url) where 'prompt'
is unicode briefly describing the signup mechanism (e.g. "Sign Up... | [
"Get",
"information",
"about",
"public",
"web",
"-",
"based",
"signup",
"mechanisms",
"."
] | 53e5502aba23ce99be78b27f923a276593033fe8 | https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/signup.py#L1052-L1075 |
56,314 | twisted/mantissa | xmantissa/signup.py | PasswordResetResource.renderHTTP | def renderHTTP(self, ctx):
"""
Handle the password reset form.
The following exchange describes the process:
S: Render C{reset}
C: POST C{username} or C{email}
S: L{handleRequestForUser}, render C{reset-check-email}
(User follows the emailed res... | python | def renderHTTP(self, ctx):
"""
Handle the password reset form.
The following exchange describes the process:
S: Render C{reset}
C: POST C{username} or C{email}
S: L{handleRequestForUser}, render C{reset-check-email}
(User follows the emailed res... | [
"def",
"renderHTTP",
"(",
"self",
",",
"ctx",
")",
":",
"req",
"=",
"inevow",
".",
"IRequest",
"(",
"ctx",
")",
"if",
"req",
".",
"method",
"==",
"'POST'",
":",
"if",
"req",
".",
"args",
".",
"get",
"(",
"'username'",
",",
"[",
"''",
"]",
")",
... | Handle the password reset form.
The following exchange describes the process:
S: Render C{reset}
C: POST C{username} or C{email}
S: L{handleRequestForUser}, render C{reset-check-email}
(User follows the emailed reset link)
S: Render C{reset-step-tw... | [
"Handle",
"the",
"password",
"reset",
"form",
"."
] | 53e5502aba23ce99be78b27f923a276593033fe8 | https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/signup.py#L125-L167 |
56,315 | twisted/mantissa | xmantissa/signup.py | PasswordResetResource._makeKey | def _makeKey(self, usern):
"""
Make a new, probably unique key. This key will be sent in an email to
the user and is used to access the password change form.
"""
return unicode(hashlib.md5(str((usern, time.time(), random.random()))).hexdigest()) | python | def _makeKey(self, usern):
"""
Make a new, probably unique key. This key will be sent in an email to
the user and is used to access the password change form.
"""
return unicode(hashlib.md5(str((usern, time.time(), random.random()))).hexdigest()) | [
"def",
"_makeKey",
"(",
"self",
",",
"usern",
")",
":",
"return",
"unicode",
"(",
"hashlib",
".",
"md5",
"(",
"str",
"(",
"(",
"usern",
",",
"time",
".",
"time",
"(",
")",
",",
"random",
".",
"random",
"(",
")",
")",
")",
")",
".",
"hexdigest",
... | Make a new, probably unique key. This key will be sent in an email to
the user and is used to access the password change form. | [
"Make",
"a",
"new",
"probably",
"unique",
"key",
".",
"This",
"key",
"will",
"be",
"sent",
"in",
"an",
"email",
"to",
"the",
"user",
"and",
"is",
"used",
"to",
"access",
"the",
"password",
"change",
"form",
"."
] | 53e5502aba23ce99be78b27f923a276593033fe8 | https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/signup.py#L223-L228 |
56,316 | twisted/mantissa | xmantissa/signup.py | TicketBooth.issueViaEmail | def issueViaEmail(self, issuer, email, product, templateData,
domainName, httpPort=80):
"""
Send a ticket via email to the supplied address, which, when claimed, will
create an avatar and allow the given product to endow it with
things.
@param issuer: An ob... | python | def issueViaEmail(self, issuer, email, product, templateData,
domainName, httpPort=80):
"""
Send a ticket via email to the supplied address, which, when claimed, will
create an avatar and allow the given product to endow it with
things.
@param issuer: An ob... | [
"def",
"issueViaEmail",
"(",
"self",
",",
"issuer",
",",
"email",
",",
"product",
",",
"templateData",
",",
"domainName",
",",
"httpPort",
"=",
"80",
")",
":",
"ticket",
"=",
"self",
".",
"createTicket",
"(",
"issuer",
",",
"unicode",
"(",
"email",
",",
... | Send a ticket via email to the supplied address, which, when claimed, will
create an avatar and allow the given product to endow it with
things.
@param issuer: An object, preferably a user, to track who issued this
ticket.
@param email: a str, formatted as an rfc2821 email addr... | [
"Send",
"a",
"ticket",
"via",
"email",
"to",
"the",
"supplied",
"address",
"which",
"when",
"claimed",
"will",
"create",
"an",
"avatar",
"and",
"allow",
"the",
"given",
"product",
"to",
"endow",
"it",
"with",
"things",
"."
] | 53e5502aba23ce99be78b27f923a276593033fe8 | https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/signup.py#L400-L451 |
56,317 | twisted/mantissa | xmantissa/signup.py | UserInfoSignup.usernameAvailable | def usernameAvailable(self, username, domain):
"""
Check to see if a username is available for the user to select.
"""
if len(username) < 2:
return [False, u"Username too short"]
for char in u"[ ,:;<>@()!\"'%&\\|\t\b":
if char in username:
... | python | def usernameAvailable(self, username, domain):
"""
Check to see if a username is available for the user to select.
"""
if len(username) < 2:
return [False, u"Username too short"]
for char in u"[ ,:;<>@()!\"'%&\\|\t\b":
if char in username:
... | [
"def",
"usernameAvailable",
"(",
"self",
",",
"username",
",",
"domain",
")",
":",
"if",
"len",
"(",
"username",
")",
"<",
"2",
":",
"return",
"[",
"False",
",",
"u\"Username too short\"",
"]",
"for",
"char",
"in",
"u\"[ ,:;<>@()!\\\"'%&\\\\|\\t\\b\"",
":",
... | Check to see if a username is available for the user to select. | [
"Check",
"to",
"see",
"if",
"a",
"username",
"is",
"available",
"for",
"the",
"user",
"to",
"select",
"."
] | 53e5502aba23ce99be78b27f923a276593033fe8 | https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/signup.py#L750-L775 |
56,318 | twisted/mantissa | xmantissa/signup.py | SignupConfiguration.createSignup | def createSignup(self, creator, signupClass, signupConf,
product, emailTemplate, prompt):
"""
Create a new signup facility in the site store's database.
@param creator: a unicode string describing the creator of the new
signup mechanism, for auditing purposes.
... | python | def createSignup(self, creator, signupClass, signupConf,
product, emailTemplate, prompt):
"""
Create a new signup facility in the site store's database.
@param creator: a unicode string describing the creator of the new
signup mechanism, for auditing purposes.
... | [
"def",
"createSignup",
"(",
"self",
",",
"creator",
",",
"signupClass",
",",
"signupConf",
",",
"product",
",",
"emailTemplate",
",",
"prompt",
")",
":",
"siteStore",
"=",
"self",
".",
"store",
".",
"parent",
"booth",
"=",
"siteStore",
".",
"findOrCreate",
... | Create a new signup facility in the site store's database.
@param creator: a unicode string describing the creator of the new
signup mechanism, for auditing purposes.
@param signupClass: the item type of the signup mechanism to create.
@param signupConf: a dictionary of keyword argume... | [
"Create",
"a",
"new",
"signup",
"facility",
"in",
"the",
"site",
"store",
"s",
"database",
"."
] | 53e5502aba23ce99be78b27f923a276593033fe8 | https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/signup.py#L1099-L1142 |
56,319 | twisted/mantissa | xmantissa/signup.py | ProductFormMixin.makeProductPicker | def makeProductPicker(self):
"""
Make a LiveForm with radio buttons for each Product in the store.
"""
productPicker = liveform.LiveForm(
self.coerceProduct,
[liveform.Parameter(
str(id(product)),
liveform.FORM_INPUT,
live... | python | def makeProductPicker(self):
"""
Make a LiveForm with radio buttons for each Product in the store.
"""
productPicker = liveform.LiveForm(
self.coerceProduct,
[liveform.Parameter(
str(id(product)),
liveform.FORM_INPUT,
live... | [
"def",
"makeProductPicker",
"(",
"self",
")",
":",
"productPicker",
"=",
"liveform",
".",
"LiveForm",
"(",
"self",
".",
"coerceProduct",
",",
"[",
"liveform",
".",
"Parameter",
"(",
"str",
"(",
"id",
"(",
"product",
")",
")",
",",
"liveform",
".",
"FORM_... | Make a LiveForm with radio buttons for each Product in the store. | [
"Make",
"a",
"LiveForm",
"with",
"radio",
"buttons",
"for",
"each",
"Product",
"in",
"the",
"store",
"."
] | 53e5502aba23ce99be78b27f923a276593033fe8 | https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/signup.py#L1148-L1168 |
56,320 | twisted/mantissa | xmantissa/signup.py | SignupFragment._deleteTrackers | def _deleteTrackers(self, trackers):
"""
Delete the given signup trackers and their associated signup resources.
@param trackers: sequence of L{_SignupTrackers}
"""
for tracker in trackers:
if tracker.store is None:
# we're not updating the list of l... | python | def _deleteTrackers(self, trackers):
"""
Delete the given signup trackers and their associated signup resources.
@param trackers: sequence of L{_SignupTrackers}
"""
for tracker in trackers:
if tracker.store is None:
# we're not updating the list of l... | [
"def",
"_deleteTrackers",
"(",
"self",
",",
"trackers",
")",
":",
"for",
"tracker",
"in",
"trackers",
":",
"if",
"tracker",
".",
"store",
"is",
"None",
":",
"# we're not updating the list of live signups client side, so",
"# we might get a signup that has already been delet... | Delete the given signup trackers and their associated signup resources.
@param trackers: sequence of L{_SignupTrackers} | [
"Delete",
"the",
"given",
"signup",
"trackers",
"and",
"their",
"associated",
"signup",
"resources",
"."
] | 53e5502aba23ce99be78b27f923a276593033fe8 | https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/signup.py#L1335-L1359 |
56,321 | jwodder/doapi | doapi/image.py | Image.fetch | def fetch(self):
"""
Fetch & return a new `Image` object representing the image's current
state
:rtype: Image
:raises DOAPIError: if the API endpoint replies with an error (e.g., if
the image no longer exists)
"""
api = self.doapi_manager
retu... | python | def fetch(self):
"""
Fetch & return a new `Image` object representing the image's current
state
:rtype: Image
:raises DOAPIError: if the API endpoint replies with an error (e.g., if
the image no longer exists)
"""
api = self.doapi_manager
retu... | [
"def",
"fetch",
"(",
"self",
")",
":",
"api",
"=",
"self",
".",
"doapi_manager",
"return",
"api",
".",
"_image",
"(",
"api",
".",
"request",
"(",
"self",
".",
"url",
")",
"[",
"\"image\"",
"]",
")"
] | Fetch & return a new `Image` object representing the image's current
state
:rtype: Image
:raises DOAPIError: if the API endpoint replies with an error (e.g., if
the image no longer exists) | [
"Fetch",
"&",
"return",
"a",
"new",
"Image",
"object",
"representing",
"the",
"image",
"s",
"current",
"state"
] | b1306de86a01d8ae7b9c1fe2699765bb82e4f310 | https://github.com/jwodder/doapi/blob/b1306de86a01d8ae7b9c1fe2699765bb82e4f310/doapi/image.py#L69-L79 |
56,322 | fitnr/censusname | censusname/censusname.py | Censusname.generate | def generate(self, nameformat=None, capitalize=None, formatters=None, **kwargs):
'''Pick a random name form a specified list of name parts'''
nameformat = nameformat or self.nameformat
capitalize = capitalize or self.capitalize
formatters = formatters or {}
lines = self._get_li... | python | def generate(self, nameformat=None, capitalize=None, formatters=None, **kwargs):
'''Pick a random name form a specified list of name parts'''
nameformat = nameformat or self.nameformat
capitalize = capitalize or self.capitalize
formatters = formatters or {}
lines = self._get_li... | [
"def",
"generate",
"(",
"self",
",",
"nameformat",
"=",
"None",
",",
"capitalize",
"=",
"None",
",",
"formatters",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"nameformat",
"=",
"nameformat",
"or",
"self",
".",
"nameformat",
"capitalize",
"=",
"capit... | Pick a random name form a specified list of name parts | [
"Pick",
"a",
"random",
"name",
"form",
"a",
"specified",
"list",
"of",
"name",
"parts"
] | df845a60bab4f1be20eca33bcd2cd0f747ec0c0f | https://github.com/fitnr/censusname/blob/df845a60bab4f1be20eca33bcd2cd0f747ec0c0f/censusname/censusname.py#L100-L129 |
56,323 | fitnr/censusname | censusname/censusname.py | Censusname.pick_frequency_line | def pick_frequency_line(self, filename, frequency, cumulativefield='cumulative_frequency'):
'''Given a numeric frequency, pick a line from a csv with a cumulative frequency field'''
if resource_exists('censusname', filename):
with closing(resource_stream('censusname', filename)) as b:
... | python | def pick_frequency_line(self, filename, frequency, cumulativefield='cumulative_frequency'):
'''Given a numeric frequency, pick a line from a csv with a cumulative frequency field'''
if resource_exists('censusname', filename):
with closing(resource_stream('censusname', filename)) as b:
... | [
"def",
"pick_frequency_line",
"(",
"self",
",",
"filename",
",",
"frequency",
",",
"cumulativefield",
"=",
"'cumulative_frequency'",
")",
":",
"if",
"resource_exists",
"(",
"'censusname'",
",",
"filename",
")",
":",
"with",
"closing",
"(",
"resource_stream",
"(",
... | Given a numeric frequency, pick a line from a csv with a cumulative frequency field | [
"Given",
"a",
"numeric",
"frequency",
"pick",
"a",
"line",
"from",
"a",
"csv",
"with",
"a",
"cumulative",
"frequency",
"field"
] | df845a60bab4f1be20eca33bcd2cd0f747ec0c0f | https://github.com/fitnr/censusname/blob/df845a60bab4f1be20eca33bcd2cd0f747ec0c0f/censusname/censusname.py#L157-L165 |
56,324 | richardliaw/track | track/autodetect.py | git_repo | def git_repo():
"""
Returns the git repository root if the cwd is in a repo, else None
"""
try:
reldir = subprocess.check_output(
["git", "rev-parse", "--git-dir"])
reldir = reldir.decode("utf-8")
return os.path.basename(os.path.dirname(os.path.abspath(reldir)))
e... | python | def git_repo():
"""
Returns the git repository root if the cwd is in a repo, else None
"""
try:
reldir = subprocess.check_output(
["git", "rev-parse", "--git-dir"])
reldir = reldir.decode("utf-8")
return os.path.basename(os.path.dirname(os.path.abspath(reldir)))
e... | [
"def",
"git_repo",
"(",
")",
":",
"try",
":",
"reldir",
"=",
"subprocess",
".",
"check_output",
"(",
"[",
"\"git\"",
",",
"\"rev-parse\"",
",",
"\"--git-dir\"",
"]",
")",
"reldir",
"=",
"reldir",
".",
"decode",
"(",
"\"utf-8\"",
")",
"return",
"os",
".",... | Returns the git repository root if the cwd is in a repo, else None | [
"Returns",
"the",
"git",
"repository",
"root",
"if",
"the",
"cwd",
"is",
"in",
"a",
"repo",
"else",
"None"
] | 7ac42ea34e5c1d7bb92fd813e938835a06a63fc7 | https://github.com/richardliaw/track/blob/7ac42ea34e5c1d7bb92fd813e938835a06a63fc7/track/autodetect.py#L32-L42 |
56,325 | richardliaw/track | track/autodetect.py | git_hash | def git_hash():
"""returns the current git hash or unknown if not in git repo"""
if git_repo() is None:
return "unknown"
git_hash = subprocess.check_output(
["git", "rev-parse", "HEAD"])
# git_hash is a byte string; we want a string.
git_hash = git_hash.decode("utf-8")
# git_hash... | python | def git_hash():
"""returns the current git hash or unknown if not in git repo"""
if git_repo() is None:
return "unknown"
git_hash = subprocess.check_output(
["git", "rev-parse", "HEAD"])
# git_hash is a byte string; we want a string.
git_hash = git_hash.decode("utf-8")
# git_hash... | [
"def",
"git_hash",
"(",
")",
":",
"if",
"git_repo",
"(",
")",
"is",
"None",
":",
"return",
"\"unknown\"",
"git_hash",
"=",
"subprocess",
".",
"check_output",
"(",
"[",
"\"git\"",
",",
"\"rev-parse\"",
",",
"\"HEAD\"",
"]",
")",
"# git_hash is a byte string; we... | returns the current git hash or unknown if not in git repo | [
"returns",
"the",
"current",
"git",
"hash",
"or",
"unknown",
"if",
"not",
"in",
"git",
"repo"
] | 7ac42ea34e5c1d7bb92fd813e938835a06a63fc7 | https://github.com/richardliaw/track/blob/7ac42ea34e5c1d7bb92fd813e938835a06a63fc7/track/autodetect.py#L45-L55 |
56,326 | richardliaw/track | track/autodetect.py | git_pretty | def git_pretty():
"""returns a pretty summary of the commit or unkown if not in git repo"""
if git_repo() is None:
return "unknown"
pretty = subprocess.check_output(
["git", "log", "--pretty=format:%h %s", "-n", "1"])
pretty = pretty.decode("utf-8")
pretty = pretty.strip()
return... | python | def git_pretty():
"""returns a pretty summary of the commit or unkown if not in git repo"""
if git_repo() is None:
return "unknown"
pretty = subprocess.check_output(
["git", "log", "--pretty=format:%h %s", "-n", "1"])
pretty = pretty.decode("utf-8")
pretty = pretty.strip()
return... | [
"def",
"git_pretty",
"(",
")",
":",
"if",
"git_repo",
"(",
")",
"is",
"None",
":",
"return",
"\"unknown\"",
"pretty",
"=",
"subprocess",
".",
"check_output",
"(",
"[",
"\"git\"",
",",
"\"log\"",
",",
"\"--pretty=format:%h %s\"",
",",
"\"-n\"",
",",
"\"1\"",
... | returns a pretty summary of the commit or unkown if not in git repo | [
"returns",
"a",
"pretty",
"summary",
"of",
"the",
"commit",
"or",
"unkown",
"if",
"not",
"in",
"git",
"repo"
] | 7ac42ea34e5c1d7bb92fd813e938835a06a63fc7 | https://github.com/richardliaw/track/blob/7ac42ea34e5c1d7bb92fd813e938835a06a63fc7/track/autodetect.py#L57-L65 |
56,327 | richardliaw/track | track/autodetect.py | invocation | def invocation():
"""reconstructs the invocation for this python program"""
cmdargs = [sys.executable] + sys.argv[:]
invocation = " ".join(shlex.quote(s) for s in cmdargs)
return invocation | python | def invocation():
"""reconstructs the invocation for this python program"""
cmdargs = [sys.executable] + sys.argv[:]
invocation = " ".join(shlex.quote(s) for s in cmdargs)
return invocation | [
"def",
"invocation",
"(",
")",
":",
"cmdargs",
"=",
"[",
"sys",
".",
"executable",
"]",
"+",
"sys",
".",
"argv",
"[",
":",
"]",
"invocation",
"=",
"\" \"",
".",
"join",
"(",
"shlex",
".",
"quote",
"(",
"s",
")",
"for",
"s",
"in",
"cmdargs",
")",
... | reconstructs the invocation for this python program | [
"reconstructs",
"the",
"invocation",
"for",
"this",
"python",
"program"
] | 7ac42ea34e5c1d7bb92fd813e938835a06a63fc7 | https://github.com/richardliaw/track/blob/7ac42ea34e5c1d7bb92fd813e938835a06a63fc7/track/autodetect.py#L67-L71 |
56,328 | laurivosandi/butterknife | host/butterknife/api.py | serialize | def serialize(func):
"""
Falcon response serialization
"""
def wrapped(instance, req, resp, **kwargs):
assert not req.get_param("unicode") or req.get_param("unicode") == u"✓", "Unicode sanity check failed"
resp.set_header("Cache-Control", "no-cache, no-store, must-revalidate");
r... | python | def serialize(func):
"""
Falcon response serialization
"""
def wrapped(instance, req, resp, **kwargs):
assert not req.get_param("unicode") or req.get_param("unicode") == u"✓", "Unicode sanity check failed"
resp.set_header("Cache-Control", "no-cache, no-store, must-revalidate");
r... | [
"def",
"serialize",
"(",
"func",
")",
":",
"def",
"wrapped",
"(",
"instance",
",",
"req",
",",
"resp",
",",
"*",
"*",
"kwargs",
")",
":",
"assert",
"not",
"req",
".",
"get_param",
"(",
"\"unicode\"",
")",
"or",
"req",
".",
"get_param",
"(",
"\"unicod... | Falcon response serialization | [
"Falcon",
"response",
"serialization"
] | 076ddabd66dcc1cedda7eba27ddca2a9ebed309e | https://github.com/laurivosandi/butterknife/blob/076ddabd66dcc1cedda7eba27ddca2a9ebed309e/host/butterknife/api.py#L27-L45 |
56,329 | llazzaro/analyzerdam | analyzerdam/excelLib.py | ExcelWrite.openSheet | def openSheet(self, name):
''' set a sheet to write '''
if name not in self.__sheetNameDict:
sheet = self.__workbook.add_sheet(name)
self.__sheetNameDict[name] = sheet
self.__sheet = self.__sheetNameDict[name] | python | def openSheet(self, name):
''' set a sheet to write '''
if name not in self.__sheetNameDict:
sheet = self.__workbook.add_sheet(name)
self.__sheetNameDict[name] = sheet
self.__sheet = self.__sheetNameDict[name] | [
"def",
"openSheet",
"(",
"self",
",",
"name",
")",
":",
"if",
"name",
"not",
"in",
"self",
".",
"__sheetNameDict",
":",
"sheet",
"=",
"self",
".",
"__workbook",
".",
"add_sheet",
"(",
"name",
")",
"self",
".",
"__sheetNameDict",
"[",
"name",
"]",
"=",
... | set a sheet to write | [
"set",
"a",
"sheet",
"to",
"write"
] | c5bc7483dae23bd2e14bbf36147b7a43a0067bc0 | https://github.com/llazzaro/analyzerdam/blob/c5bc7483dae23bd2e14bbf36147b7a43a0067bc0/analyzerdam/excelLib.py#L116-L122 |
56,330 | llazzaro/analyzerdam | analyzerdam/excelLib.py | ExcelWrite.__getSheet | def __getSheet(self, name):
''' get a sheet by name '''
if not self.sheetExsit(name):
raise UfException(Errors.SHEET_NAME_INVALID, "Can't find a sheet named %s" % name)
return self.__sheetNameDict[name] | python | def __getSheet(self, name):
''' get a sheet by name '''
if not self.sheetExsit(name):
raise UfException(Errors.SHEET_NAME_INVALID, "Can't find a sheet named %s" % name)
return self.__sheetNameDict[name] | [
"def",
"__getSheet",
"(",
"self",
",",
"name",
")",
":",
"if",
"not",
"self",
".",
"sheetExsit",
"(",
"name",
")",
":",
"raise",
"UfException",
"(",
"Errors",
".",
"SHEET_NAME_INVALID",
",",
"\"Can't find a sheet named %s\"",
"%",
"name",
")",
"return",
"sel... | get a sheet by name | [
"get",
"a",
"sheet",
"by",
"name"
] | c5bc7483dae23bd2e14bbf36147b7a43a0067bc0 | https://github.com/llazzaro/analyzerdam/blob/c5bc7483dae23bd2e14bbf36147b7a43a0067bc0/analyzerdam/excelLib.py#L124-L129 |
56,331 | llazzaro/analyzerdam | analyzerdam/excelLib.py | ExcelWrite.writeCell | def writeCell(self, row, col, value):
''' write a cell '''
if self.__sheet is None:
self.openSheet(super(ExcelWrite, self).DEFAULT_SHEET)
self.__sheet.write(row, col, value) | python | def writeCell(self, row, col, value):
''' write a cell '''
if self.__sheet is None:
self.openSheet(super(ExcelWrite, self).DEFAULT_SHEET)
self.__sheet.write(row, col, value) | [
"def",
"writeCell",
"(",
"self",
",",
"row",
",",
"col",
",",
"value",
")",
":",
"if",
"self",
".",
"__sheet",
"is",
"None",
":",
"self",
".",
"openSheet",
"(",
"super",
"(",
"ExcelWrite",
",",
"self",
")",
".",
"DEFAULT_SHEET",
")",
"self",
".",
"... | write a cell | [
"write",
"a",
"cell"
] | c5bc7483dae23bd2e14bbf36147b7a43a0067bc0 | https://github.com/llazzaro/analyzerdam/blob/c5bc7483dae23bd2e14bbf36147b7a43a0067bc0/analyzerdam/excelLib.py#L135-L140 |
56,332 | llazzaro/analyzerdam | analyzerdam/excelLib.py | ExcelWrite.writeRow | def writeRow(self, row, values):
'''
write a row
Not sure whether xlwt support write the same cell multiple times
'''
if self.__sheet is None:
self.openSheet(super(ExcelWrite, self).DEFAULT_SHEET)
for index, value in enumerate(values):
se... | python | def writeRow(self, row, values):
'''
write a row
Not sure whether xlwt support write the same cell multiple times
'''
if self.__sheet is None:
self.openSheet(super(ExcelWrite, self).DEFAULT_SHEET)
for index, value in enumerate(values):
se... | [
"def",
"writeRow",
"(",
"self",
",",
"row",
",",
"values",
")",
":",
"if",
"self",
".",
"__sheet",
"is",
"None",
":",
"self",
".",
"openSheet",
"(",
"super",
"(",
"ExcelWrite",
",",
"self",
")",
".",
"DEFAULT_SHEET",
")",
"for",
"index",
",",
"value"... | write a row
Not sure whether xlwt support write the same cell multiple times | [
"write",
"a",
"row",
"Not",
"sure",
"whether",
"xlwt",
"support",
"write",
"the",
"same",
"cell",
"multiple",
"times"
] | c5bc7483dae23bd2e14bbf36147b7a43a0067bc0 | https://github.com/llazzaro/analyzerdam/blob/c5bc7483dae23bd2e14bbf36147b7a43a0067bc0/analyzerdam/excelLib.py#L142-L151 |
56,333 | llazzaro/analyzerdam | analyzerdam/excelLib.py | ExcelRead.readCell | def readCell(self, row, col):
''' read a cell'''
try:
if self.__sheet is None:
self.openSheet(super(ExcelRead, self).DEFAULT_SHEET)
return self.__sheet.cell(row, col).value
except BaseException as excp:
raise UfException(Errors.UNKNOWN... | python | def readCell(self, row, col):
''' read a cell'''
try:
if self.__sheet is None:
self.openSheet(super(ExcelRead, self).DEFAULT_SHEET)
return self.__sheet.cell(row, col).value
except BaseException as excp:
raise UfException(Errors.UNKNOWN... | [
"def",
"readCell",
"(",
"self",
",",
"row",
",",
"col",
")",
":",
"try",
":",
"if",
"self",
".",
"__sheet",
"is",
"None",
":",
"self",
".",
"openSheet",
"(",
"super",
"(",
"ExcelRead",
",",
"self",
")",
".",
"DEFAULT_SHEET",
")",
"return",
"self",
... | read a cell | [
"read",
"a",
"cell"
] | c5bc7483dae23bd2e14bbf36147b7a43a0067bc0 | https://github.com/llazzaro/analyzerdam/blob/c5bc7483dae23bd2e14bbf36147b7a43a0067bc0/analyzerdam/excelLib.py#L207-L215 |
56,334 | openvax/datacache | datacache/cache.py | Cache.delete_url | def delete_url(self, url):
"""
Delete local files downloaded from given URL
"""
# file may exist locally in compressed and decompressed states
# delete both
for decompress in [False, True]:
key = (url, decompress)
if key in self._local_paths:
... | python | def delete_url(self, url):
"""
Delete local files downloaded from given URL
"""
# file may exist locally in compressed and decompressed states
# delete both
for decompress in [False, True]:
key = (url, decompress)
if key in self._local_paths:
... | [
"def",
"delete_url",
"(",
"self",
",",
"url",
")",
":",
"# file may exist locally in compressed and decompressed states",
"# delete both",
"for",
"decompress",
"in",
"[",
"False",
",",
"True",
"]",
":",
"key",
"=",
"(",
"url",
",",
"decompress",
")",
"if",
"key"... | Delete local files downloaded from given URL | [
"Delete",
"local",
"files",
"downloaded",
"from",
"given",
"URL"
] | 73bcac02d37cf153710a07fbdc636aa55cb214ca | https://github.com/openvax/datacache/blob/73bcac02d37cf153710a07fbdc636aa55cb214ca/datacache/cache.py#L36-L56 |
56,335 | openvax/datacache | datacache/cache.py | Cache.fetch | def fetch(
self,
url,
filename=None,
decompress=False,
force=False,
timeout=None,
use_wget_if_available=True):
"""
Return the local path to the downloaded copy of a given URL.
Don't download the file again if it'... | python | def fetch(
self,
url,
filename=None,
decompress=False,
force=False,
timeout=None,
use_wget_if_available=True):
"""
Return the local path to the downloaded copy of a given URL.
Don't download the file again if it'... | [
"def",
"fetch",
"(",
"self",
",",
"url",
",",
"filename",
"=",
"None",
",",
"decompress",
"=",
"False",
",",
"force",
"=",
"False",
",",
"timeout",
"=",
"None",
",",
"use_wget_if_available",
"=",
"True",
")",
":",
"key",
"=",
"(",
"url",
",",
"decomp... | Return the local path to the downloaded copy of a given URL.
Don't download the file again if it's already present,
unless `force` is True. | [
"Return",
"the",
"local",
"path",
"to",
"the",
"downloaded",
"copy",
"of",
"a",
"given",
"URL",
".",
"Don",
"t",
"download",
"the",
"file",
"again",
"if",
"it",
"s",
"already",
"present",
"unless",
"force",
"is",
"True",
"."
] | 73bcac02d37cf153710a07fbdc636aa55cb214ca | https://github.com/openvax/datacache/blob/73bcac02d37cf153710a07fbdc636aa55cb214ca/datacache/cache.py#L74-L104 |
56,336 | openvax/datacache | datacache/cache.py | Cache.local_path | def local_path(self, url, filename=None, decompress=False, download=False):
"""
What will the full local path be if we download the given file?
"""
if download:
return self.fetch(url=url, filename=filename, decompress=decompress)
else:
filename = self.loca... | python | def local_path(self, url, filename=None, decompress=False, download=False):
"""
What will the full local path be if we download the given file?
"""
if download:
return self.fetch(url=url, filename=filename, decompress=decompress)
else:
filename = self.loca... | [
"def",
"local_path",
"(",
"self",
",",
"url",
",",
"filename",
"=",
"None",
",",
"decompress",
"=",
"False",
",",
"download",
"=",
"False",
")",
":",
"if",
"download",
":",
"return",
"self",
".",
"fetch",
"(",
"url",
"=",
"url",
",",
"filename",
"=",... | What will the full local path be if we download the given file? | [
"What",
"will",
"the",
"full",
"local",
"path",
"be",
"if",
"we",
"download",
"the",
"given",
"file?"
] | 73bcac02d37cf153710a07fbdc636aa55cb214ca | https://github.com/openvax/datacache/blob/73bcac02d37cf153710a07fbdc636aa55cb214ca/datacache/cache.py#L117-L125 |
56,337 | 72squared/redpipe | redpipe/connections.py | connect_redis | def connect_redis(redis_client, name=None, transaction=False):
"""
Connect your redis-py instance to redpipe.
Example:
.. code:: python
redpipe.connect_redis(redis.StrictRedis(), name='users')
Do this during your application bootstrapping.
You can also pass a redis-py-cluster insta... | python | def connect_redis(redis_client, name=None, transaction=False):
"""
Connect your redis-py instance to redpipe.
Example:
.. code:: python
redpipe.connect_redis(redis.StrictRedis(), name='users')
Do this during your application bootstrapping.
You can also pass a redis-py-cluster insta... | [
"def",
"connect_redis",
"(",
"redis_client",
",",
"name",
"=",
"None",
",",
"transaction",
"=",
"False",
")",
":",
"return",
"ConnectionManager",
".",
"connect_redis",
"(",
"redis_client",
"=",
"redis_client",
",",
"name",
"=",
"name",
",",
"transaction",
"=",... | Connect your redis-py instance to redpipe.
Example:
.. code:: python
redpipe.connect_redis(redis.StrictRedis(), name='users')
Do this during your application bootstrapping.
You can also pass a redis-py-cluster instance to this method.
.. code:: python
redpipe.connect_redis(re... | [
"Connect",
"your",
"redis",
"-",
"py",
"instance",
"to",
"redpipe",
"."
] | e6ee518bc9f3e2fee323c8c53d08997799bd9b1b | https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/connections.py#L156-L191 |
56,338 | 72squared/redpipe | redpipe/connections.py | ConnectionManager.connect | def connect(cls, pipeline_method, name=None):
"""
Low level logic to bind a callable method to a name.
Don't call this directly unless you know what you are doing.
:param pipeline_method: callable
:param name: str optional
:return: None
"""
new_pool = pip... | python | def connect(cls, pipeline_method, name=None):
"""
Low level logic to bind a callable method to a name.
Don't call this directly unless you know what you are doing.
:param pipeline_method: callable
:param name: str optional
:return: None
"""
new_pool = pip... | [
"def",
"connect",
"(",
"cls",
",",
"pipeline_method",
",",
"name",
"=",
"None",
")",
":",
"new_pool",
"=",
"pipeline_method",
"(",
")",
".",
"connection_pool",
"try",
":",
"if",
"cls",
".",
"get",
"(",
"name",
")",
".",
"connection_pool",
"!=",
"new_pool... | Low level logic to bind a callable method to a name.
Don't call this directly unless you know what you are doing.
:param pipeline_method: callable
:param name: str optional
:return: None | [
"Low",
"level",
"logic",
"to",
"bind",
"a",
"callable",
"method",
"to",
"a",
"name",
".",
"Don",
"t",
"call",
"this",
"directly",
"unless",
"you",
"know",
"what",
"you",
"are",
"doing",
"."
] | e6ee518bc9f3e2fee323c8c53d08997799bd9b1b | https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/connections.py#L56-L72 |
56,339 | 72squared/redpipe | redpipe/connections.py | ConnectionManager.connect_redis | def connect_redis(cls, redis_client, name=None, transaction=False):
"""
Store the redis connection in our connector instance.
Do this during your application bootstrapping.
We call the pipeline method of the redis client.
The ``redis_client`` can be either a redis or redisclus... | python | def connect_redis(cls, redis_client, name=None, transaction=False):
"""
Store the redis connection in our connector instance.
Do this during your application bootstrapping.
We call the pipeline method of the redis client.
The ``redis_client`` can be either a redis or redisclus... | [
"def",
"connect_redis",
"(",
"cls",
",",
"redis_client",
",",
"name",
"=",
"None",
",",
"transaction",
"=",
"False",
")",
":",
"connection_pool",
"=",
"redis_client",
".",
"connection_pool",
"if",
"connection_pool",
".",
"connection_kwargs",
".",
"get",
"(",
"... | Store the redis connection in our connector instance.
Do this during your application bootstrapping.
We call the pipeline method of the redis client.
The ``redis_client`` can be either a redis or rediscluster client.
We use the interface, not the actual class.
That means we c... | [
"Store",
"the",
"redis",
"connection",
"in",
"our",
"connector",
"instance",
"."
] | e6ee518bc9f3e2fee323c8c53d08997799bd9b1b | https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/connections.py#L75-L127 |
56,340 | twisted/mantissa | xmantissa/fulltext.py | remoteIndexer1to2 | def remoteIndexer1to2(oldIndexer):
"""
Previously external application code was responsible for adding a
RemoteListener to a batch work source as a reliable listener. This
precluded the possibility of the RemoteListener resetting itself
unilaterally. With version 2, RemoteListener takes control of... | python | def remoteIndexer1to2(oldIndexer):
"""
Previously external application code was responsible for adding a
RemoteListener to a batch work source as a reliable listener. This
precluded the possibility of the RemoteListener resetting itself
unilaterally. With version 2, RemoteListener takes control of... | [
"def",
"remoteIndexer1to2",
"(",
"oldIndexer",
")",
":",
"newIndexer",
"=",
"oldIndexer",
".",
"upgradeVersion",
"(",
"oldIndexer",
".",
"typeName",
",",
"1",
",",
"2",
",",
"indexCount",
"=",
"oldIndexer",
".",
"indexCount",
",",
"installedOn",
"=",
"oldIndex... | Previously external application code was responsible for adding a
RemoteListener to a batch work source as a reliable listener. This
precluded the possibility of the RemoteListener resetting itself
unilaterally. With version 2, RemoteListener takes control of adding
itself as a reliable listener and k... | [
"Previously",
"external",
"application",
"code",
"was",
"responsible",
"for",
"adding",
"a",
"RemoteListener",
"to",
"a",
"batch",
"work",
"source",
"as",
"a",
"reliable",
"listener",
".",
"This",
"precluded",
"the",
"possibility",
"of",
"the",
"RemoteListener",
... | 53e5502aba23ce99be78b27f923a276593033fe8 | https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/fulltext.py#L660-L685 |
56,341 | twisted/mantissa | xmantissa/fulltext.py | remoteIndexer2to3 | def remoteIndexer2to3(oldIndexer):
"""
The documentType keyword was added to all indexable items. Indexes need to
be regenerated for this to take effect. Also, PyLucene no longer stores
the text of messages it indexes, so deleting and re-creating the indexes
will make them much smaller.
"""
... | python | def remoteIndexer2to3(oldIndexer):
"""
The documentType keyword was added to all indexable items. Indexes need to
be regenerated for this to take effect. Also, PyLucene no longer stores
the text of messages it indexes, so deleting and re-creating the indexes
will make them much smaller.
"""
... | [
"def",
"remoteIndexer2to3",
"(",
"oldIndexer",
")",
":",
"newIndexer",
"=",
"oldIndexer",
".",
"upgradeVersion",
"(",
"oldIndexer",
".",
"typeName",
",",
"2",
",",
"3",
",",
"indexCount",
"=",
"oldIndexer",
".",
"indexCount",
",",
"installedOn",
"=",
"oldIndex... | The documentType keyword was added to all indexable items. Indexes need to
be regenerated for this to take effect. Also, PyLucene no longer stores
the text of messages it indexes, so deleting and re-creating the indexes
will make them much smaller. | [
"The",
"documentType",
"keyword",
"was",
"added",
"to",
"all",
"indexable",
"items",
".",
"Indexes",
"need",
"to",
"be",
"regenerated",
"for",
"this",
"to",
"take",
"effect",
".",
"Also",
"PyLucene",
"no",
"longer",
"stores",
"the",
"text",
"of",
"messages",... | 53e5502aba23ce99be78b27f923a276593033fe8 | https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/fulltext.py#L687-L703 |
56,342 | twisted/mantissa | xmantissa/fulltext.py | pyLuceneIndexer4to5 | def pyLuceneIndexer4to5(old):
"""
Copy attributes, reset index due because information about deleted
documents has been lost, and power up for IFulltextIndexer so other code
can find this item.
"""
new = old.upgradeVersion(PyLuceneIndexer.typeName, 4, 5,
indexCount=o... | python | def pyLuceneIndexer4to5(old):
"""
Copy attributes, reset index due because information about deleted
documents has been lost, and power up for IFulltextIndexer so other code
can find this item.
"""
new = old.upgradeVersion(PyLuceneIndexer.typeName, 4, 5,
indexCount=o... | [
"def",
"pyLuceneIndexer4to5",
"(",
"old",
")",
":",
"new",
"=",
"old",
".",
"upgradeVersion",
"(",
"PyLuceneIndexer",
".",
"typeName",
",",
"4",
",",
"5",
",",
"indexCount",
"=",
"old",
".",
"indexCount",
",",
"installedOn",
"=",
"old",
".",
"installedOn",... | Copy attributes, reset index due because information about deleted
documents has been lost, and power up for IFulltextIndexer so other code
can find this item. | [
"Copy",
"attributes",
"reset",
"index",
"due",
"because",
"information",
"about",
"deleted",
"documents",
"has",
"been",
"lost",
"and",
"power",
"up",
"for",
"IFulltextIndexer",
"so",
"other",
"code",
"can",
"find",
"this",
"item",
"."
] | 53e5502aba23ce99be78b27f923a276593033fe8 | https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/fulltext.py#L735-L747 |
56,343 | twisted/mantissa | xmantissa/fulltext.py | RemoteIndexer.reset | def reset(self):
"""
Process everything all over again.
"""
self.indexCount = 0
indexDir = self.store.newDirectory(self.indexDirectory)
if indexDir.exists():
indexDir.remove()
for src in self.getSources():
src.removeReliableListener(self)
... | python | def reset(self):
"""
Process everything all over again.
"""
self.indexCount = 0
indexDir = self.store.newDirectory(self.indexDirectory)
if indexDir.exists():
indexDir.remove()
for src in self.getSources():
src.removeReliableListener(self)
... | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"indexCount",
"=",
"0",
"indexDir",
"=",
"self",
".",
"store",
".",
"newDirectory",
"(",
"self",
".",
"indexDirectory",
")",
"if",
"indexDir",
".",
"exists",
"(",
")",
":",
"indexDir",
".",
"remove",
... | Process everything all over again. | [
"Process",
"everything",
"all",
"over",
"again",
"."
] | 53e5502aba23ce99be78b27f923a276593033fe8 | https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/fulltext.py#L134-L144 |
56,344 | twisted/mantissa | xmantissa/fulltext.py | RemoteIndexer._flush | def _flush(self):
"""
Deal with pending result-affecting things.
This should always be called before issuing a search.
"""
remove = self.store.query(_RemoveDocument)
documentIdentifiers = list(remove.getColumn("documentIdentifier"))
if VERBOSE:
log.ms... | python | def _flush(self):
"""
Deal with pending result-affecting things.
This should always be called before issuing a search.
"""
remove = self.store.query(_RemoveDocument)
documentIdentifiers = list(remove.getColumn("documentIdentifier"))
if VERBOSE:
log.ms... | [
"def",
"_flush",
"(",
"self",
")",
":",
"remove",
"=",
"self",
".",
"store",
".",
"query",
"(",
"_RemoveDocument",
")",
"documentIdentifiers",
"=",
"list",
"(",
"remove",
".",
"getColumn",
"(",
"\"documentIdentifier\"",
")",
")",
"if",
"VERBOSE",
":",
"log... | Deal with pending result-affecting things.
This should always be called before issuing a search. | [
"Deal",
"with",
"pending",
"result",
"-",
"affecting",
"things",
"."
] | 53e5502aba23ce99be78b27f923a276593033fe8 | https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/fulltext.py#L185-L198 |
56,345 | twisted/mantissa | xmantissa/fulltext.py | _SQLiteIndex.add | def add(self, document):
"""
Add a document to the database.
"""
docid = int(document.uniqueIdentifier())
text = u' '.join(document.textParts())
self.store.executeSQL(self.addSQL, (docid, text)) | python | def add(self, document):
"""
Add a document to the database.
"""
docid = int(document.uniqueIdentifier())
text = u' '.join(document.textParts())
self.store.executeSQL(self.addSQL, (docid, text)) | [
"def",
"add",
"(",
"self",
",",
"document",
")",
":",
"docid",
"=",
"int",
"(",
"document",
".",
"uniqueIdentifier",
"(",
")",
")",
"text",
"=",
"u' '",
".",
"join",
"(",
"document",
".",
"textParts",
"(",
")",
")",
"self",
".",
"store",
".",
"exec... | Add a document to the database. | [
"Add",
"a",
"document",
"to",
"the",
"database",
"."
] | 53e5502aba23ce99be78b27f923a276593033fe8 | https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/fulltext.py#L787-L794 |
56,346 | twisted/mantissa | xmantissa/fulltext.py | _SQLiteIndex.remove | def remove(self, docid):
"""
Remove a document from the database.
"""
docid = int(docid)
self.store.executeSQL(self.removeSQL, (docid,)) | python | def remove(self, docid):
"""
Remove a document from the database.
"""
docid = int(docid)
self.store.executeSQL(self.removeSQL, (docid,)) | [
"def",
"remove",
"(",
"self",
",",
"docid",
")",
":",
"docid",
"=",
"int",
"(",
"docid",
")",
"self",
".",
"store",
".",
"executeSQL",
"(",
"self",
".",
"removeSQL",
",",
"(",
"docid",
",",
")",
")"
] | Remove a document from the database. | [
"Remove",
"a",
"document",
"from",
"the",
"database",
"."
] | 53e5502aba23ce99be78b27f923a276593033fe8 | https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/fulltext.py#L797-L802 |
56,347 | twisted/mantissa | xmantissa/fulltext.py | _SQLiteIndex.search | def search(self, term, keywords=None, sortAscending=True):
"""
Search the database.
"""
if sortAscending:
direction = 'ASC'
else:
direction = 'DESC'
return [_SQLiteResultWrapper(r[0]) for r in
self.store.querySQL(self.searchSQL % (... | python | def search(self, term, keywords=None, sortAscending=True):
"""
Search the database.
"""
if sortAscending:
direction = 'ASC'
else:
direction = 'DESC'
return [_SQLiteResultWrapper(r[0]) for r in
self.store.querySQL(self.searchSQL % (... | [
"def",
"search",
"(",
"self",
",",
"term",
",",
"keywords",
"=",
"None",
",",
"sortAscending",
"=",
"True",
")",
":",
"if",
"sortAscending",
":",
"direction",
"=",
"'ASC'",
"else",
":",
"direction",
"=",
"'DESC'",
"return",
"[",
"_SQLiteResultWrapper",
"("... | Search the database. | [
"Search",
"the",
"database",
"."
] | 53e5502aba23ce99be78b27f923a276593033fe8 | https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/fulltext.py#L805-L815 |
56,348 | twisted/mantissa | xmantissa/fulltext.py | SQLiteIndexer._getStore | def _getStore(self):
"""
Get the Store used for FTS.
If it does not exist, it is created and initialised.
"""
storeDir = self.store.newDirectory(self.indexDirectory)
if not storeDir.exists():
store = Store(storeDir)
self._initStore(store)
... | python | def _getStore(self):
"""
Get the Store used for FTS.
If it does not exist, it is created and initialised.
"""
storeDir = self.store.newDirectory(self.indexDirectory)
if not storeDir.exists():
store = Store(storeDir)
self._initStore(store)
... | [
"def",
"_getStore",
"(",
"self",
")",
":",
"storeDir",
"=",
"self",
".",
"store",
".",
"newDirectory",
"(",
"self",
".",
"indexDirectory",
")",
"if",
"not",
"storeDir",
".",
"exists",
"(",
")",
":",
"store",
"=",
"Store",
"(",
"storeDir",
")",
"self",
... | Get the Store used for FTS.
If it does not exist, it is created and initialised. | [
"Get",
"the",
"Store",
"used",
"for",
"FTS",
"."
] | 53e5502aba23ce99be78b27f923a276593033fe8 | https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/fulltext.py#L835-L847 |
56,349 | p3trus/slave | slave/types.py | SingleType.dump | def dump(self, value):
"""Dumps the value to string.
:returns: Returns the stringified version of the value.
:raises: TypeError, ValueError
"""
value = self.__convert__(value)
self.__validate__(value)
return self.__serialize__(value) | python | def dump(self, value):
"""Dumps the value to string.
:returns: Returns the stringified version of the value.
:raises: TypeError, ValueError
"""
value = self.__convert__(value)
self.__validate__(value)
return self.__serialize__(value) | [
"def",
"dump",
"(",
"self",
",",
"value",
")",
":",
"value",
"=",
"self",
".",
"__convert__",
"(",
"value",
")",
"self",
".",
"__validate__",
"(",
"value",
")",
"return",
"self",
".",
"__serialize__",
"(",
"value",
")"
] | Dumps the value to string.
:returns: Returns the stringified version of the value.
:raises: TypeError, ValueError | [
"Dumps",
"the",
"value",
"to",
"string",
"."
] | bdc74e73bd0f47b74a090c43aa2283c469cde3be | https://github.com/p3trus/slave/blob/bdc74e73bd0f47b74a090c43aa2283c469cde3be/slave/types.py#L114-L123 |
56,350 | p3trus/slave | slave/types.py | Integer.simulate | def simulate(self):
"""Generates a random integer in the available range."""
min_ = (-sys.maxsize - 1) if self._min is None else self._min
max_ = sys.maxsize if self._max is None else self._max
return random.randint(min_, max_) | python | def simulate(self):
"""Generates a random integer in the available range."""
min_ = (-sys.maxsize - 1) if self._min is None else self._min
max_ = sys.maxsize if self._max is None else self._max
return random.randint(min_, max_) | [
"def",
"simulate",
"(",
"self",
")",
":",
"min_",
"=",
"(",
"-",
"sys",
".",
"maxsize",
"-",
"1",
")",
"if",
"self",
".",
"_min",
"is",
"None",
"else",
"self",
".",
"_min",
"max_",
"=",
"sys",
".",
"maxsize",
"if",
"self",
".",
"_max",
"is",
"N... | Generates a random integer in the available range. | [
"Generates",
"a",
"random",
"integer",
"in",
"the",
"available",
"range",
"."
] | bdc74e73bd0f47b74a090c43aa2283c469cde3be | https://github.com/p3trus/slave/blob/bdc74e73bd0f47b74a090c43aa2283c469cde3be/slave/types.py#L191-L195 |
56,351 | p3trus/slave | slave/types.py | String.simulate | def simulate(self):
"""Returns a randomly constructed string.
Simulate randomly constructs a string with a length between min and
max. If min is not present, a minimum length of 1 is assumed, if max
is not present a maximum length of 10 is used.
"""
min_ = 1 if self._min... | python | def simulate(self):
"""Returns a randomly constructed string.
Simulate randomly constructs a string with a length between min and
max. If min is not present, a minimum length of 1 is assumed, if max
is not present a maximum length of 10 is used.
"""
min_ = 1 if self._min... | [
"def",
"simulate",
"(",
"self",
")",
":",
"min_",
"=",
"1",
"if",
"self",
".",
"_min",
"is",
"None",
"else",
"self",
".",
"_min",
"max_",
"=",
"10",
"if",
"self",
".",
"_max",
"is",
"None",
"else",
"self",
".",
"_max",
"n",
"=",
"min_",
"if",
"... | Returns a randomly constructed string.
Simulate randomly constructs a string with a length between min and
max. If min is not present, a minimum length of 1 is assumed, if max
is not present a maximum length of 10 is used. | [
"Returns",
"a",
"randomly",
"constructed",
"string",
"."
] | bdc74e73bd0f47b74a090c43aa2283c469cde3be | https://github.com/p3trus/slave/blob/bdc74e73bd0f47b74a090c43aa2283c469cde3be/slave/types.py#L233-L244 |
56,352 | p3trus/slave | slave/types.py | Stream.simulate | def simulate(self):
"""Simulates a stream of types."""
# Simulates zero to 10 types
return [t.simulate() for t in itertools.islice(self, random.choice(range(10)))] | python | def simulate(self):
"""Simulates a stream of types."""
# Simulates zero to 10 types
return [t.simulate() for t in itertools.islice(self, random.choice(range(10)))] | [
"def",
"simulate",
"(",
"self",
")",
":",
"# Simulates zero to 10 types",
"return",
"[",
"t",
".",
"simulate",
"(",
")",
"for",
"t",
"in",
"itertools",
".",
"islice",
"(",
"self",
",",
"random",
".",
"choice",
"(",
"range",
"(",
"10",
")",
")",
")",
... | Simulates a stream of types. | [
"Simulates",
"a",
"stream",
"of",
"types",
"."
] | bdc74e73bd0f47b74a090c43aa2283c469cde3be | https://github.com/p3trus/slave/blob/bdc74e73bd0f47b74a090c43aa2283c469cde3be/slave/types.py#L381-L384 |
56,353 | llazzaro/analyzerdam | analyzerdam/excelDAM.py | ExcelDAM.__findRange | def __findRange(self, excelLib, start, end):
''' return low and high as excel range '''
inc = 1
low = 0
high = 0
dates = excelLib.readCol(0, 1)
for index, date in enumerate(dates):
if int(start) <= int(date):
low = index + inc
... | python | def __findRange(self, excelLib, start, end):
''' return low and high as excel range '''
inc = 1
low = 0
high = 0
dates = excelLib.readCol(0, 1)
for index, date in enumerate(dates):
if int(start) <= int(date):
low = index + inc
... | [
"def",
"__findRange",
"(",
"self",
",",
"excelLib",
",",
"start",
",",
"end",
")",
":",
"inc",
"=",
"1",
"low",
"=",
"0",
"high",
"=",
"0",
"dates",
"=",
"excelLib",
".",
"readCol",
"(",
"0",
",",
"1",
")",
"for",
"index",
",",
"date",
"in",
"e... | return low and high as excel range | [
"return",
"low",
"and",
"high",
"as",
"excel",
"range"
] | c5bc7483dae23bd2e14bbf36147b7a43a0067bc0 | https://github.com/llazzaro/analyzerdam/blob/c5bc7483dae23bd2e14bbf36147b7a43a0067bc0/analyzerdam/excelDAM.py#L29-L47 |
56,354 | p3trus/slave | slave/srs/sr850.py | SR850.snap | def snap(self, *args):
"""Records multiple values at once.
It takes two to six arguments specifying which values should be
recorded together. Valid arguments are 'x', 'y', 'r', 'theta',
'aux1', 'aux2', 'aux3', 'aux4', 'frequency', 'trace1', 'trace2',
'trace3' and 'trace4'.
... | python | def snap(self, *args):
"""Records multiple values at once.
It takes two to six arguments specifying which values should be
recorded together. Valid arguments are 'x', 'y', 'r', 'theta',
'aux1', 'aux2', 'aux3', 'aux4', 'frequency', 'trace1', 'trace2',
'trace3' and 'trace4'.
... | [
"def",
"snap",
"(",
"self",
",",
"*",
"args",
")",
":",
"length",
"=",
"len",
"(",
"args",
")",
"if",
"not",
"2",
"<=",
"length",
"<=",
"6",
":",
"msg",
"=",
"'snap takes 2 to 6 arguments, {0} given.'",
".",
"format",
"(",
"length",
")",
"raise",
"Type... | Records multiple values at once.
It takes two to six arguments specifying which values should be
recorded together. Valid arguments are 'x', 'y', 'r', 'theta',
'aux1', 'aux2', 'aux3', 'aux4', 'frequency', 'trace1', 'trace2',
'trace3' and 'trace4'.
snap is faster since it avoids... | [
"Records",
"multiple",
"values",
"at",
"once",
"."
] | bdc74e73bd0f47b74a090c43aa2283c469cde3be | https://github.com/p3trus/slave/blob/bdc74e73bd0f47b74a090c43aa2283c469cde3be/slave/srs/sr850.py#L698-L728 |
56,355 | p3trus/slave | slave/srs/sr850.py | SR850.fit | def fit(self, range, function=None):
"""Fits a function to the active display's data trace within a
specified range of the time window.
E.g.::
# Fit's a gaussian to the first 30% of the time window.
lockin.fit(range=(0, 30), function='gauss')
:param start: The ... | python | def fit(self, range, function=None):
"""Fits a function to the active display's data trace within a
specified range of the time window.
E.g.::
# Fit's a gaussian to the first 30% of the time window.
lockin.fit(range=(0, 30), function='gauss')
:param start: The ... | [
"def",
"fit",
"(",
"self",
",",
"range",
",",
"function",
"=",
"None",
")",
":",
"if",
"function",
"is",
"not",
"None",
":",
"self",
".",
"fit_function",
"=",
"function",
"cmd",
"=",
"'FITT'",
",",
"Integer",
"(",
"min",
"=",
"0",
",",
"max",
"=",
... | Fits a function to the active display's data trace within a
specified range of the time window.
E.g.::
# Fit's a gaussian to the first 30% of the time window.
lockin.fit(range=(0, 30), function='gauss')
:param start: The left limit of the time window in percent.
... | [
"Fits",
"a",
"function",
"to",
"the",
"active",
"display",
"s",
"data",
"trace",
"within",
"a",
"specified",
"range",
"of",
"the",
"time",
"window",
"."
] | bdc74e73bd0f47b74a090c43aa2283c469cde3be | https://github.com/p3trus/slave/blob/bdc74e73bd0f47b74a090c43aa2283c469cde3be/slave/srs/sr850.py#L796-L826 |
56,356 | p3trus/slave | slave/srs/sr850.py | SR850.calculate_statistics | def calculate_statistics(self, start, stop):
"""Starts the statistics calculation.
:param start: The left limit of the time window in percent.
:param stop: The right limit of the time window in percent.
.. note::
The calculation takes some time. Check the status byte to se... | python | def calculate_statistics(self, start, stop):
"""Starts the statistics calculation.
:param start: The left limit of the time window in percent.
:param stop: The right limit of the time window in percent.
.. note::
The calculation takes some time. Check the status byte to se... | [
"def",
"calculate_statistics",
"(",
"self",
",",
"start",
",",
"stop",
")",
":",
"cmd",
"=",
"'STAT'",
",",
"Integer",
",",
"Integer",
"self",
".",
"_write",
"(",
"cmd",
",",
"start",
",",
"stop",
")"
] | Starts the statistics calculation.
:param start: The left limit of the time window in percent.
:param stop: The right limit of the time window in percent.
.. note::
The calculation takes some time. Check the status byte to see when
the operation is done. A running scan... | [
"Starts",
"the",
"statistics",
"calculation",
"."
] | bdc74e73bd0f47b74a090c43aa2283c469cde3be | https://github.com/p3trus/slave/blob/bdc74e73bd0f47b74a090c43aa2283c469cde3be/slave/srs/sr850.py#L828-L847 |
56,357 | p3trus/slave | slave/srs/sr850.py | SR850.calculate | def calculate(self, operation=None, trace=None, constant=None, type=None):
"""Starts the calculation.
The calculation operates on the trace graphed in the active display.
The math operation is defined by the :attr:`~.SR850.math_operation`,
the second argument by the :attr:`~.SR850.math_... | python | def calculate(self, operation=None, trace=None, constant=None, type=None):
"""Starts the calculation.
The calculation operates on the trace graphed in the active display.
The math operation is defined by the :attr:`~.SR850.math_operation`,
the second argument by the :attr:`~.SR850.math_... | [
"def",
"calculate",
"(",
"self",
",",
"operation",
"=",
"None",
",",
"trace",
"=",
"None",
",",
"constant",
"=",
"None",
",",
"type",
"=",
"None",
")",
":",
"if",
"operation",
"is",
"not",
"None",
":",
"self",
".",
"math_operation",
"=",
"operation",
... | Starts the calculation.
The calculation operates on the trace graphed in the active display.
The math operation is defined by the :attr:`~.SR850.math_operation`,
the second argument by the :attr:`~.SR850.math_argument_type`.
For convenience, the operation and the second argument, can b... | [
"Starts",
"the",
"calculation",
"."
] | bdc74e73bd0f47b74a090c43aa2283c469cde3be | https://github.com/p3trus/slave/blob/bdc74e73bd0f47b74a090c43aa2283c469cde3be/slave/srs/sr850.py#L849-L905 |
56,358 | p3trus/slave | slave/srs/sr850.py | Mark.bin | def bin(self):
"""The bin index of this mark.
:returns: An integer bin index or None if the mark is inactive.
"""
bin = self._query(('MBIN?', Integer, Integer), self.idx)
return None if bin == -1 else bin | python | def bin(self):
"""The bin index of this mark.
:returns: An integer bin index or None if the mark is inactive.
"""
bin = self._query(('MBIN?', Integer, Integer), self.idx)
return None if bin == -1 else bin | [
"def",
"bin",
"(",
"self",
")",
":",
"bin",
"=",
"self",
".",
"_query",
"(",
"(",
"'MBIN?'",
",",
"Integer",
",",
"Integer",
")",
",",
"self",
".",
"idx",
")",
"return",
"None",
"if",
"bin",
"==",
"-",
"1",
"else",
"bin"
] | The bin index of this mark.
:returns: An integer bin index or None if the mark is inactive. | [
"The",
"bin",
"index",
"of",
"this",
"mark",
"."
] | bdc74e73bd0f47b74a090c43aa2283c469cde3be | https://github.com/p3trus/slave/blob/bdc74e73bd0f47b74a090c43aa2283c469cde3be/slave/srs/sr850.py#L1180-L1187 |
56,359 | p3trus/slave | slave/srs/sr850.py | MarkList.active | def active(self):
"""The indices of the active marks."""
# TODO avoid direct usage of transport object.
marks = tuple(int(x) for x in transport.ask('MACT').split(','))
return marks[1:] | python | def active(self):
"""The indices of the active marks."""
# TODO avoid direct usage of transport object.
marks = tuple(int(x) for x in transport.ask('MACT').split(','))
return marks[1:] | [
"def",
"active",
"(",
"self",
")",
":",
"# TODO avoid direct usage of transport object.",
"marks",
"=",
"tuple",
"(",
"int",
"(",
"x",
")",
"for",
"x",
"in",
"transport",
".",
"ask",
"(",
"'MACT'",
")",
".",
"split",
"(",
"','",
")",
")",
"return",
"mark... | The indices of the active marks. | [
"The",
"indices",
"of",
"the",
"active",
"marks",
"."
] | bdc74e73bd0f47b74a090c43aa2283c469cde3be | https://github.com/p3trus/slave/blob/bdc74e73bd0f47b74a090c43aa2283c469cde3be/slave/srs/sr850.py#L1220-L1224 |
56,360 | datacratic/pymldb | pymldb/__init__.py | Connection.put_and_track | def put_and_track(self, url, payload, refresh_rate_sec=1):
"""
Put and track progress, displaying progress bars.
May display the wrong progress if 2 things post/put on the same
procedure name at the same time.
"""
if not url.startswith('/v1/procedures'):
rais... | python | def put_and_track(self, url, payload, refresh_rate_sec=1):
"""
Put and track progress, displaying progress bars.
May display the wrong progress if 2 things post/put on the same
procedure name at the same time.
"""
if not url.startswith('/v1/procedures'):
rais... | [
"def",
"put_and_track",
"(",
"self",
",",
"url",
",",
"payload",
",",
"refresh_rate_sec",
"=",
"1",
")",
":",
"if",
"not",
"url",
".",
"startswith",
"(",
"'/v1/procedures'",
")",
":",
"raise",
"Exception",
"(",
"\"The only supported route is /v1/procedures\"",
"... | Put and track progress, displaying progress bars.
May display the wrong progress if 2 things post/put on the same
procedure name at the same time. | [
"Put",
"and",
"track",
"progress",
"displaying",
"progress",
"bars",
"."
] | e41f3c37138e9fd4a82ef3db685899cdafa4125e | https://github.com/datacratic/pymldb/blob/e41f3c37138e9fd4a82ef3db685899cdafa4125e/pymldb/__init__.py#L92-L129 |
56,361 | datacratic/pymldb | pymldb/__init__.py | Connection.post_and_track | def post_and_track(self, url, payload, refresh_rate_sec=1):
"""
Post and track progress, displaying progress bars.
May display the wrong progress if 2 things post/put on the same
procedure name at the same time.
"""
if not url.startswith('/v1/procedures'):
ra... | python | def post_and_track(self, url, payload, refresh_rate_sec=1):
"""
Post and track progress, displaying progress bars.
May display the wrong progress if 2 things post/put on the same
procedure name at the same time.
"""
if not url.startswith('/v1/procedures'):
ra... | [
"def",
"post_and_track",
"(",
"self",
",",
"url",
",",
"payload",
",",
"refresh_rate_sec",
"=",
"1",
")",
":",
"if",
"not",
"url",
".",
"startswith",
"(",
"'/v1/procedures'",
")",
":",
"raise",
"Exception",
"(",
"\"The only supported route is /v1/procedures\"",
... | Post and track progress, displaying progress bars.
May display the wrong progress if 2 things post/put on the same
procedure name at the same time. | [
"Post",
"and",
"track",
"progress",
"displaying",
"progress",
"bars",
"."
] | e41f3c37138e9fd4a82ef3db685899cdafa4125e | https://github.com/datacratic/pymldb/blob/e41f3c37138e9fd4a82ef3db685899cdafa4125e/pymldb/__init__.py#L131-L165 |
56,362 | twisted/mantissa | xmantissa/port.py | StringEndpointPort._makeService | def _makeService(self):
"""
Construct a service for the endpoint as described.
"""
if self._endpointService is None:
_service = service
else:
_service = self._endpointService
return _service(
self.description.encode('ascii'), self.facto... | python | def _makeService(self):
"""
Construct a service for the endpoint as described.
"""
if self._endpointService is None:
_service = service
else:
_service = self._endpointService
return _service(
self.description.encode('ascii'), self.facto... | [
"def",
"_makeService",
"(",
"self",
")",
":",
"if",
"self",
".",
"_endpointService",
"is",
"None",
":",
"_service",
"=",
"service",
"else",
":",
"_service",
"=",
"self",
".",
"_endpointService",
"return",
"_service",
"(",
"self",
".",
"description",
".",
"... | Construct a service for the endpoint as described. | [
"Construct",
"a",
"service",
"for",
"the",
"endpoint",
"as",
"described",
"."
] | 53e5502aba23ce99be78b27f923a276593033fe8 | https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/port.py#L313-L322 |
56,363 | twisted/mantissa | xmantissa/port.py | ListOptions.postOptions | def postOptions(self):
"""
Display details about the ports which already exist.
"""
store = self.parent.parent.getStore()
port = None
factories = {}
for portType in [TCPPort, SSLPort, StringEndpointPort]:
for port in store.query(portType):
... | python | def postOptions(self):
"""
Display details about the ports which already exist.
"""
store = self.parent.parent.getStore()
port = None
factories = {}
for portType in [TCPPort, SSLPort, StringEndpointPort]:
for port in store.query(portType):
... | [
"def",
"postOptions",
"(",
"self",
")",
":",
"store",
"=",
"self",
".",
"parent",
".",
"parent",
".",
"getStore",
"(",
")",
"port",
"=",
"None",
"factories",
"=",
"{",
"}",
"for",
"portType",
"in",
"[",
"TCPPort",
",",
"SSLPort",
",",
"StringEndpointPo... | Display details about the ports which already exist. | [
"Display",
"details",
"about",
"the",
"ports",
"which",
"already",
"exist",
"."
] | 53e5502aba23ce99be78b27f923a276593033fe8 | https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/port.py#L349-L398 |
56,364 | twisted/mantissa | xmantissa/port.py | DeleteOptions._delete | def _delete(self, store, portIDs):
"""
Try to delete the ports with the given store IDs.
@param store: The Axiom store from which to delete items.
@param portIDs: A list of Axiom store IDs for TCPPort or SSLPort items.
@raise L{SystemExit}: If one of the store IDs does not ide... | python | def _delete(self, store, portIDs):
"""
Try to delete the ports with the given store IDs.
@param store: The Axiom store from which to delete items.
@param portIDs: A list of Axiom store IDs for TCPPort or SSLPort items.
@raise L{SystemExit}: If one of the store IDs does not ide... | [
"def",
"_delete",
"(",
"self",
",",
"store",
",",
"portIDs",
")",
":",
"for",
"portID",
"in",
"portIDs",
":",
"try",
":",
"port",
"=",
"store",
".",
"getItemByID",
"(",
"portID",
")",
"except",
"KeyError",
":",
"print",
"\"%d does not identify an item.\"",
... | Try to delete the ports with the given store IDs.
@param store: The Axiom store from which to delete items.
@param portIDs: A list of Axiom store IDs for TCPPort or SSLPort items.
@raise L{SystemExit}: If one of the store IDs does not identify a port
item. | [
"Try",
"to",
"delete",
"the",
"ports",
"with",
"the",
"given",
"store",
"IDs",
"."
] | 53e5502aba23ce99be78b27f923a276593033fe8 | https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/port.py#L428-L449 |
56,365 | twisted/mantissa | xmantissa/port.py | DeleteOptions.postOptions | def postOptions(self):
"""
Delete the ports specified with the port-identifier option.
"""
if self.portIdentifiers:
store = self.parent.parent.getStore()
store.transact(self._delete, store, self.portIdentifiers)
print "Deleted."
raise Syste... | python | def postOptions(self):
"""
Delete the ports specified with the port-identifier option.
"""
if self.portIdentifiers:
store = self.parent.parent.getStore()
store.transact(self._delete, store, self.portIdentifiers)
print "Deleted."
raise Syste... | [
"def",
"postOptions",
"(",
"self",
")",
":",
"if",
"self",
".",
"portIdentifiers",
":",
"store",
"=",
"self",
".",
"parent",
".",
"parent",
".",
"getStore",
"(",
")",
"store",
".",
"transact",
"(",
"self",
".",
"_delete",
",",
"store",
",",
"self",
"... | Delete the ports specified with the port-identifier option. | [
"Delete",
"the",
"ports",
"specified",
"with",
"the",
"port",
"-",
"identifier",
"option",
"."
] | 53e5502aba23ce99be78b27f923a276593033fe8 | https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/port.py#L452-L462 |
56,366 | richardliaw/track | track/convenience.py | absl_flags | def absl_flags():
"""
Extracts absl-py flags that the user has specified and outputs their
key-value mapping.
By default, extracts only those flags in the current __package__
and mainfile.
Useful to put into a trial's param_map.
"""
# TODO: need same thing for argparse
flags_dict =... | python | def absl_flags():
"""
Extracts absl-py flags that the user has specified and outputs their
key-value mapping.
By default, extracts only those flags in the current __package__
and mainfile.
Useful to put into a trial's param_map.
"""
# TODO: need same thing for argparse
flags_dict =... | [
"def",
"absl_flags",
"(",
")",
":",
"# TODO: need same thing for argparse",
"flags_dict",
"=",
"flags",
".",
"FLAGS",
".",
"flags_by_module_dict",
"(",
")",
"# only include parameters from modules the user probably cares about",
"def",
"_relevant_module",
"(",
"module_name",
... | Extracts absl-py flags that the user has specified and outputs their
key-value mapping.
By default, extracts only those flags in the current __package__
and mainfile.
Useful to put into a trial's param_map. | [
"Extracts",
"absl",
"-",
"py",
"flags",
"that",
"the",
"user",
"has",
"specified",
"and",
"outputs",
"their",
"key",
"-",
"value",
"mapping",
"."
] | 7ac42ea34e5c1d7bb92fd813e938835a06a63fc7 | https://github.com/richardliaw/track/blob/7ac42ea34e5c1d7bb92fd813e938835a06a63fc7/track/convenience.py#L10-L31 |
56,367 | 72squared/redpipe | redpipe/pipelines.py | pipeline | def pipeline(pipe=None, name=None, autoexec=False, exit_handler=None):
"""
This is the foundational function for all of redpipe.
Everything goes through here.
create pipelines, nest pipelines, get pipelines for a specific name.
It all happens here.
Here's a simple example:
.. code:: python... | python | def pipeline(pipe=None, name=None, autoexec=False, exit_handler=None):
"""
This is the foundational function for all of redpipe.
Everything goes through here.
create pipelines, nest pipelines, get pipelines for a specific name.
It all happens here.
Here's a simple example:
.. code:: python... | [
"def",
"pipeline",
"(",
"pipe",
"=",
"None",
",",
"name",
"=",
"None",
",",
"autoexec",
"=",
"False",
",",
"exit_handler",
"=",
"None",
")",
":",
"if",
"pipe",
"is",
"None",
":",
"return",
"Pipeline",
"(",
"name",
"=",
"name",
",",
"autoexec",
"=",
... | This is the foundational function for all of redpipe.
Everything goes through here.
create pipelines, nest pipelines, get pipelines for a specific name.
It all happens here.
Here's a simple example:
.. code:: python
with pipeline() as pipe:
pipe.set('foo', 'bar')
f... | [
"This",
"is",
"the",
"foundational",
"function",
"for",
"all",
"of",
"redpipe",
".",
"Everything",
"goes",
"through",
"here",
".",
"create",
"pipelines",
"nest",
"pipelines",
"get",
"pipelines",
"for",
"a",
"specific",
"name",
".",
"It",
"all",
"happens",
"h... | e6ee518bc9f3e2fee323c8c53d08997799bd9b1b | https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/pipelines.py#L392-L448 |
56,368 | 72squared/redpipe | redpipe/pipelines.py | autoexec | def autoexec(pipe=None, name=None, exit_handler=None):
"""
create a pipeline with a context that will automatically execute the
pipeline upon leaving the context if no exception was raised.
:param pipe:
:param name:
:return:
"""
return pipeline(pipe=pipe, name=name, autoexec=True,
... | python | def autoexec(pipe=None, name=None, exit_handler=None):
"""
create a pipeline with a context that will automatically execute the
pipeline upon leaving the context if no exception was raised.
:param pipe:
:param name:
:return:
"""
return pipeline(pipe=pipe, name=name, autoexec=True,
... | [
"def",
"autoexec",
"(",
"pipe",
"=",
"None",
",",
"name",
"=",
"None",
",",
"exit_handler",
"=",
"None",
")",
":",
"return",
"pipeline",
"(",
"pipe",
"=",
"pipe",
",",
"name",
"=",
"name",
",",
"autoexec",
"=",
"True",
",",
"exit_handler",
"=",
"exit... | create a pipeline with a context that will automatically execute the
pipeline upon leaving the context if no exception was raised.
:param pipe:
:param name:
:return: | [
"create",
"a",
"pipeline",
"with",
"a",
"context",
"that",
"will",
"automatically",
"execute",
"the",
"pipeline",
"upon",
"leaving",
"the",
"context",
"if",
"no",
"exception",
"was",
"raised",
"."
] | e6ee518bc9f3e2fee323c8c53d08997799bd9b1b | https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/pipelines.py#L451-L461 |
56,369 | inveniosoftware/dcxml | dcxml/xmlutils.py | dump_etree_helper | def dump_etree_helper(container_name, data, rules, nsmap, attrib):
"""Convert DataCite JSON format to DataCite XML.
JSON should be validated before it is given to to_xml.
"""
output = etree.Element(container_name, nsmap=nsmap, attrib=attrib)
for rule in rules:
if rule not in data:
... | python | def dump_etree_helper(container_name, data, rules, nsmap, attrib):
"""Convert DataCite JSON format to DataCite XML.
JSON should be validated before it is given to to_xml.
"""
output = etree.Element(container_name, nsmap=nsmap, attrib=attrib)
for rule in rules:
if rule not in data:
... | [
"def",
"dump_etree_helper",
"(",
"container_name",
",",
"data",
",",
"rules",
",",
"nsmap",
",",
"attrib",
")",
":",
"output",
"=",
"etree",
".",
"Element",
"(",
"container_name",
",",
"nsmap",
"=",
"nsmap",
",",
"attrib",
"=",
"attrib",
")",
"for",
"rul... | Convert DataCite JSON format to DataCite XML.
JSON should be validated before it is given to to_xml. | [
"Convert",
"DataCite",
"JSON",
"format",
"to",
"DataCite",
"XML",
"."
] | 9fed6123ec0f3f2e2f645ff91653a7e86a39138d | https://github.com/inveniosoftware/dcxml/blob/9fed6123ec0f3f2e2f645ff91653a7e86a39138d/dcxml/xmlutils.py#L18-L33 |
56,370 | inveniosoftware/dcxml | dcxml/xmlutils.py | etree_to_string | def etree_to_string(root, pretty_print=True, xml_declaration=True,
encoding='utf-8'):
"""Dump XML etree as a string."""
return etree.tostring(
root,
pretty_print=pretty_print,
xml_declaration=xml_declaration,
encoding=encoding,
).decode('utf-8') | python | def etree_to_string(root, pretty_print=True, xml_declaration=True,
encoding='utf-8'):
"""Dump XML etree as a string."""
return etree.tostring(
root,
pretty_print=pretty_print,
xml_declaration=xml_declaration,
encoding=encoding,
).decode('utf-8') | [
"def",
"etree_to_string",
"(",
"root",
",",
"pretty_print",
"=",
"True",
",",
"xml_declaration",
"=",
"True",
",",
"encoding",
"=",
"'utf-8'",
")",
":",
"return",
"etree",
".",
"tostring",
"(",
"root",
",",
"pretty_print",
"=",
"pretty_print",
",",
"xml_decl... | Dump XML etree as a string. | [
"Dump",
"XML",
"etree",
"as",
"a",
"string",
"."
] | 9fed6123ec0f3f2e2f645ff91653a7e86a39138d | https://github.com/inveniosoftware/dcxml/blob/9fed6123ec0f3f2e2f645ff91653a7e86a39138d/dcxml/xmlutils.py#L36-L44 |
56,371 | inveniosoftware/dcxml | dcxml/xmlutils.py | Rules.rule | def rule(self, key):
"""Decorate as a rule for a key in top level JSON."""
def register(f):
self.rules[key] = f
return f
return register | python | def rule(self, key):
"""Decorate as a rule for a key in top level JSON."""
def register(f):
self.rules[key] = f
return f
return register | [
"def",
"rule",
"(",
"self",
",",
"key",
")",
":",
"def",
"register",
"(",
"f",
")",
":",
"self",
".",
"rules",
"[",
"key",
"]",
"=",
"f",
"return",
"f",
"return",
"register"
] | Decorate as a rule for a key in top level JSON. | [
"Decorate",
"as",
"a",
"rule",
"for",
"a",
"key",
"in",
"top",
"level",
"JSON",
"."
] | 9fed6123ec0f3f2e2f645ff91653a7e86a39138d | https://github.com/inveniosoftware/dcxml/blob/9fed6123ec0f3f2e2f645ff91653a7e86a39138d/dcxml/xmlutils.py#L62-L67 |
56,372 | openvax/datacache | datacache/database_table.py | DatabaseTable.from_dataframe | def from_dataframe(cls, name, df, indices, primary_key=None):
"""Infer table metadata from a DataFrame"""
# ordered list (column_name, column_type) pairs
column_types = []
# which columns have nullable values
nullable = set()
# tag cached database by dataframe's number ... | python | def from_dataframe(cls, name, df, indices, primary_key=None):
"""Infer table metadata from a DataFrame"""
# ordered list (column_name, column_type) pairs
column_types = []
# which columns have nullable values
nullable = set()
# tag cached database by dataframe's number ... | [
"def",
"from_dataframe",
"(",
"cls",
",",
"name",
",",
"df",
",",
"indices",
",",
"primary_key",
"=",
"None",
")",
":",
"# ordered list (column_name, column_type) pairs",
"column_types",
"=",
"[",
"]",
"# which columns have nullable values",
"nullable",
"=",
"set",
... | Infer table metadata from a DataFrame | [
"Infer",
"table",
"metadata",
"from",
"a",
"DataFrame"
] | 73bcac02d37cf153710a07fbdc636aa55cb214ca | https://github.com/openvax/datacache/blob/73bcac02d37cf153710a07fbdc636aa55cb214ca/datacache/database_table.py#L43-L68 |
56,373 | rmed/pyemtmad | pyemtmad/api/parking.py | ParkingApi.detail_parking | def detail_parking(self, **kwargs):
"""Obtain detailed info of a given parking.
Args:
lang (str): Language code (*es* or *en*).
day (int): Day of the month in format DD.
The number is automatically padded if it only has one digit.
month (int): Month ... | python | def detail_parking(self, **kwargs):
"""Obtain detailed info of a given parking.
Args:
lang (str): Language code (*es* or *en*).
day (int): Day of the month in format DD.
The number is automatically padded if it only has one digit.
month (int): Month ... | [
"def",
"detail_parking",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# Endpoint parameters",
"date",
"=",
"util",
".",
"datetime_string",
"(",
"kwargs",
".",
"get",
"(",
"'day'",
",",
"1",
")",
",",
"kwargs",
".",
"get",
"(",
"'month'",
",",
"1",
... | Obtain detailed info of a given parking.
Args:
lang (str): Language code (*es* or *en*).
day (int): Day of the month in format DD.
The number is automatically padded if it only has one digit.
month (int): Month number in format MM.
The number... | [
"Obtain",
"detailed",
"info",
"of",
"a",
"given",
"parking",
"."
] | c21c42d0c7b50035dfed29540d7e64ab67833728 | https://github.com/rmed/pyemtmad/blob/c21c42d0c7b50035dfed29540d7e64ab67833728/pyemtmad/api/parking.py#L39-L85 |
56,374 | rmed/pyemtmad | pyemtmad/api/parking.py | ParkingApi.detail_poi | def detail_poi(self, **kwargs):
"""Obtain detailed info of a given POI.
Args:
family (str): Family code of the POI (3 chars).
lang (str): Language code (*es* or *en*).
id (int): Optional, ID of the POI to query. Passing value -1 will
result in informa... | python | def detail_poi(self, **kwargs):
"""Obtain detailed info of a given POI.
Args:
family (str): Family code of the POI (3 chars).
lang (str): Language code (*es* or *en*).
id (int): Optional, ID of the POI to query. Passing value -1 will
result in informa... | [
"def",
"detail_poi",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# Endpoint parameters",
"params",
"=",
"{",
"'language'",
":",
"util",
".",
"language_code",
"(",
"kwargs",
".",
"get",
"(",
"'lang'",
")",
")",
",",
"'family'",
":",
"kwargs",
".",
... | Obtain detailed info of a given POI.
Args:
family (str): Family code of the POI (3 chars).
lang (str): Language code (*es* or *en*).
id (int): Optional, ID of the POI to query. Passing value -1 will
result in information from all POIs.
Returns:
... | [
"Obtain",
"detailed",
"info",
"of",
"a",
"given",
"POI",
"."
] | c21c42d0c7b50035dfed29540d7e64ab67833728 | https://github.com/rmed/pyemtmad/blob/c21c42d0c7b50035dfed29540d7e64ab67833728/pyemtmad/api/parking.py#L87-L117 |
56,375 | rmed/pyemtmad | pyemtmad/api/parking.py | ParkingApi.icon_description | def icon_description(self, **kwargs):
"""Obtain a list of elements that have an associated icon.
Args:
lang (str): Language code (*es* or *en*).
Returns:
Status boolean and parsed response (list[IconDescription]), or
message string in case of error.
... | python | def icon_description(self, **kwargs):
"""Obtain a list of elements that have an associated icon.
Args:
lang (str): Language code (*es* or *en*).
Returns:
Status boolean and parsed response (list[IconDescription]), or
message string in case of error.
... | [
"def",
"icon_description",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# Endpoint parameters",
"params",
"=",
"{",
"'language'",
":",
"util",
".",
"language_code",
"(",
"kwargs",
".",
"get",
"(",
"'lang'",
")",
")",
"}",
"# Request",
"result",
"=",
... | Obtain a list of elements that have an associated icon.
Args:
lang (str): Language code (*es* or *en*).
Returns:
Status boolean and parsed response (list[IconDescription]), or
message string in case of error. | [
"Obtain",
"a",
"list",
"of",
"elements",
"that",
"have",
"an",
"associated",
"icon",
"."
] | c21c42d0c7b50035dfed29540d7e64ab67833728 | https://github.com/rmed/pyemtmad/blob/c21c42d0c7b50035dfed29540d7e64ab67833728/pyemtmad/api/parking.py#L119-L140 |
56,376 | rmed/pyemtmad | pyemtmad/api/parking.py | ParkingApi.info_parking_poi | def info_parking_poi(self, **kwargs):
"""Obtain generic information on POIs and parkings.
This returns a list of elements in a given radius from the coordinates.
Args:
radius (int): Radius of the search (in meters).
latitude (double): Latitude in decimal degrees.
... | python | def info_parking_poi(self, **kwargs):
"""Obtain generic information on POIs and parkings.
This returns a list of elements in a given radius from the coordinates.
Args:
radius (int): Radius of the search (in meters).
latitude (double): Latitude in decimal degrees.
... | [
"def",
"info_parking_poi",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# Endpoint parameters",
"date",
"=",
"util",
".",
"datetime_string",
"(",
"kwargs",
".",
"get",
"(",
"'day'",
",",
"1",
")",
",",
"kwargs",
".",
"get",
"(",
"'month'",
",",
"1"... | Obtain generic information on POIs and parkings.
This returns a list of elements in a given radius from the coordinates.
Args:
radius (int): Radius of the search (in meters).
latitude (double): Latitude in decimal degrees.
longitude (double): Longitude in decimal de... | [
"Obtain",
"generic",
"information",
"on",
"POIs",
"and",
"parkings",
"."
] | c21c42d0c7b50035dfed29540d7e64ab67833728 | https://github.com/rmed/pyemtmad/blob/c21c42d0c7b50035dfed29540d7e64ab67833728/pyemtmad/api/parking.py#L142-L228 |
56,377 | rmed/pyemtmad | pyemtmad/api/parking.py | ParkingApi.list_street_poi_parking | def list_street_poi_parking(self, **kwargs):
"""Obtain a list of addresses and POIs.
This endpoint uses an address to perform the search
Args:
lang (str): Language code (*es* or *en*).
address (str): Address in which to perform the search.
Returns:
... | python | def list_street_poi_parking(self, **kwargs):
"""Obtain a list of addresses and POIs.
This endpoint uses an address to perform the search
Args:
lang (str): Language code (*es* or *en*).
address (str): Address in which to perform the search.
Returns:
... | [
"def",
"list_street_poi_parking",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# Endpoint parameters",
"url_args",
"=",
"{",
"'language'",
":",
"util",
".",
"language_code",
"(",
"kwargs",
".",
"get",
"(",
"'lang'",
")",
")",
",",
"'address'",
":",
"kw... | Obtain a list of addresses and POIs.
This endpoint uses an address to perform the search
Args:
lang (str): Language code (*es* or *en*).
address (str): Address in which to perform the search.
Returns:
Status boolean and parsed response (list[ParkingPoi]), o... | [
"Obtain",
"a",
"list",
"of",
"addresses",
"and",
"POIs",
"."
] | c21c42d0c7b50035dfed29540d7e64ab67833728 | https://github.com/rmed/pyemtmad/blob/c21c42d0c7b50035dfed29540d7e64ab67833728/pyemtmad/api/parking.py#L279-L306 |
56,378 | rmed/pyemtmad | pyemtmad/api/parking.py | ParkingApi.list_types_poi | def list_types_poi(self, **kwargs):
"""Obtain a list of families, types and categories of POI.
Args:
lang (str): Language code (*es* or *en*).
Returns:
Status boolean and parsed response (list[ParkingPoiType]), or message
string in case of error.
"""... | python | def list_types_poi(self, **kwargs):
"""Obtain a list of families, types and categories of POI.
Args:
lang (str): Language code (*es* or *en*).
Returns:
Status boolean and parsed response (list[ParkingPoiType]), or message
string in case of error.
"""... | [
"def",
"list_types_poi",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# Endpoint parameters",
"url_args",
"=",
"{",
"'language'",
":",
"util",
".",
"language_code",
"(",
"kwargs",
".",
"get",
"(",
"'lang'",
")",
")",
"}",
"# Request",
"result",
"=",
... | Obtain a list of families, types and categories of POI.
Args:
lang (str): Language code (*es* or *en*).
Returns:
Status boolean and parsed response (list[ParkingPoiType]), or message
string in case of error. | [
"Obtain",
"a",
"list",
"of",
"families",
"types",
"and",
"categories",
"of",
"POI",
"."
] | c21c42d0c7b50035dfed29540d7e64ab67833728 | https://github.com/rmed/pyemtmad/blob/c21c42d0c7b50035dfed29540d7e64ab67833728/pyemtmad/api/parking.py#L308-L329 |
56,379 | llazzaro/analyzerdam | analyzerdam/yahooDAM.py | YahooDAM.readQuotes | def readQuotes(self, start, end):
''' read quotes from Yahoo Financial'''
if self.symbol is None:
LOG.debug('Symbol is None')
return []
return self.__yf.getQuotes(self.symbol, start, end) | python | def readQuotes(self, start, end):
''' read quotes from Yahoo Financial'''
if self.symbol is None:
LOG.debug('Symbol is None')
return []
return self.__yf.getQuotes(self.symbol, start, end) | [
"def",
"readQuotes",
"(",
"self",
",",
"start",
",",
"end",
")",
":",
"if",
"self",
".",
"symbol",
"is",
"None",
":",
"LOG",
".",
"debug",
"(",
"'Symbol is None'",
")",
"return",
"[",
"]",
"return",
"self",
".",
"__yf",
".",
"getQuotes",
"(",
"self",... | read quotes from Yahoo Financial | [
"read",
"quotes",
"from",
"Yahoo",
"Financial"
] | c5bc7483dae23bd2e14bbf36147b7a43a0067bc0 | https://github.com/llazzaro/analyzerdam/blob/c5bc7483dae23bd2e14bbf36147b7a43a0067bc0/analyzerdam/yahooDAM.py#L20-L26 |
56,380 | rande/python-simple-ioc | ioc/helper.py | deepcopy | def deepcopy(value):
"""
The default copy.deepcopy seems to copy all objects and some are not
`copy-able`.
We only need to make sure the provided data is a copy per key, object does
not need to be copied.
"""
if not isinstance(value, (dict, list, tuple)):
return value
if isins... | python | def deepcopy(value):
"""
The default copy.deepcopy seems to copy all objects and some are not
`copy-able`.
We only need to make sure the provided data is a copy per key, object does
not need to be copied.
"""
if not isinstance(value, (dict, list, tuple)):
return value
if isins... | [
"def",
"deepcopy",
"(",
"value",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"(",
"dict",
",",
"list",
",",
"tuple",
")",
")",
":",
"return",
"value",
"if",
"isinstance",
"(",
"value",
",",
"dict",
")",
":",
"copy",
"=",
"{",
"}",
"fo... | The default copy.deepcopy seems to copy all objects and some are not
`copy-able`.
We only need to make sure the provided data is a copy per key, object does
not need to be copied. | [
"The",
"default",
"copy",
".",
"deepcopy",
"seems",
"to",
"copy",
"all",
"objects",
"and",
"some",
"are",
"not",
"copy",
"-",
"able",
"."
] | 36ddf667c1213a07a53cd4cdd708d02494e5190b | https://github.com/rande/python-simple-ioc/blob/36ddf667c1213a07a53cd4cdd708d02494e5190b/ioc/helper.py#L20-L51 |
56,381 | p3trus/slave | slave/lakeshore/ls370.py | LS370._factory_default | def _factory_default(self, confirm=False):
"""Resets the device to factory defaults.
:param confirm: This function should not normally be used, to prevent
accidental resets, a confirm value of `True` must be used.
"""
if confirm is True:
self._write(('DFLT', Int... | python | def _factory_default(self, confirm=False):
"""Resets the device to factory defaults.
:param confirm: This function should not normally be used, to prevent
accidental resets, a confirm value of `True` must be used.
"""
if confirm is True:
self._write(('DFLT', Int... | [
"def",
"_factory_default",
"(",
"self",
",",
"confirm",
"=",
"False",
")",
":",
"if",
"confirm",
"is",
"True",
":",
"self",
".",
"_write",
"(",
"(",
"'DFLT'",
",",
"Integer",
")",
",",
"99",
")",
"else",
":",
"raise",
"ValueError",
"(",
"'Reset to fact... | Resets the device to factory defaults.
:param confirm: This function should not normally be used, to prevent
accidental resets, a confirm value of `True` must be used. | [
"Resets",
"the",
"device",
"to",
"factory",
"defaults",
"."
] | bdc74e73bd0f47b74a090c43aa2283c469cde3be | https://github.com/p3trus/slave/blob/bdc74e73bd0f47b74a090c43aa2283c469cde3be/slave/lakeshore/ls370.py#L682-L692 |
56,382 | twisted/mantissa | xmantissa/websession.py | PersistentSessionWrapper.createSessionForKey | def createSessionForKey(self, key, user):
"""
Create a persistent session in the database.
@type key: L{bytes}
@param key: The persistent session identifier.
@type user: L{bytes}
@param user: The username the session will belong to.
"""
PersistentSession... | python | def createSessionForKey(self, key, user):
"""
Create a persistent session in the database.
@type key: L{bytes}
@param key: The persistent session identifier.
@type user: L{bytes}
@param user: The username the session will belong to.
"""
PersistentSession... | [
"def",
"createSessionForKey",
"(",
"self",
",",
"key",
",",
"user",
")",
":",
"PersistentSession",
"(",
"store",
"=",
"self",
".",
"store",
",",
"sessionKey",
"=",
"key",
",",
"authenticatedAs",
"=",
"user",
")"
] | Create a persistent session in the database.
@type key: L{bytes}
@param key: The persistent session identifier.
@type user: L{bytes}
@param user: The username the session will belong to. | [
"Create",
"a",
"persistent",
"session",
"in",
"the",
"database",
"."
] | 53e5502aba23ce99be78b27f923a276593033fe8 | https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/websession.py#L180-L193 |
56,383 | twisted/mantissa | xmantissa/websession.py | PersistentSessionWrapper.authenticatedUserForKey | def authenticatedUserForKey(self, key):
"""
Find a persistent session for a user.
@type key: L{bytes}
@param key: The persistent session identifier.
@rtype: L{bytes} or C{None}
@return: The avatar ID the session belongs to, or C{None} if no such
session exis... | python | def authenticatedUserForKey(self, key):
"""
Find a persistent session for a user.
@type key: L{bytes}
@param key: The persistent session identifier.
@rtype: L{bytes} or C{None}
@return: The avatar ID the session belongs to, or C{None} if no such
session exis... | [
"def",
"authenticatedUserForKey",
"(",
"self",
",",
"key",
")",
":",
"session",
"=",
"self",
".",
"store",
".",
"findFirst",
"(",
"PersistentSession",
",",
"PersistentSession",
".",
"sessionKey",
"==",
"key",
")",
"if",
"session",
"is",
"None",
":",
"return"... | Find a persistent session for a user.
@type key: L{bytes}
@param key: The persistent session identifier.
@rtype: L{bytes} or C{None}
@return: The avatar ID the session belongs to, or C{None} if no such
session exists. | [
"Find",
"a",
"persistent",
"session",
"for",
"a",
"user",
"."
] | 53e5502aba23ce99be78b27f923a276593033fe8 | https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/websession.py#L196-L213 |
56,384 | twisted/mantissa | xmantissa/websession.py | PersistentSessionWrapper.removeSessionWithKey | def removeSessionWithKey(self, key):
"""
Remove a persistent session, if it exists.
@type key: L{bytes}
@param key: The persistent session identifier.
"""
self.store.query(
PersistentSession,
PersistentSession.sessionKey == key).deleteFromStore() | python | def removeSessionWithKey(self, key):
"""
Remove a persistent session, if it exists.
@type key: L{bytes}
@param key: The persistent session identifier.
"""
self.store.query(
PersistentSession,
PersistentSession.sessionKey == key).deleteFromStore() | [
"def",
"removeSessionWithKey",
"(",
"self",
",",
"key",
")",
":",
"self",
".",
"store",
".",
"query",
"(",
"PersistentSession",
",",
"PersistentSession",
".",
"sessionKey",
"==",
"key",
")",
".",
"deleteFromStore",
"(",
")"
] | Remove a persistent session, if it exists.
@type key: L{bytes}
@param key: The persistent session identifier. | [
"Remove",
"a",
"persistent",
"session",
"if",
"it",
"exists",
"."
] | 53e5502aba23ce99be78b27f923a276593033fe8 | https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/websession.py#L216-L225 |
56,385 | twisted/mantissa | xmantissa/websession.py | PersistentSessionWrapper._cleanSessions | def _cleanSessions(self):
"""
Clean expired sesisons.
"""
tooOld = extime.Time() - timedelta(seconds=PERSISTENT_SESSION_LIFETIME)
self.store.query(
PersistentSession,
PersistentSession.lastUsed < tooOld).deleteFromStore()
self._lastClean = self._cl... | python | def _cleanSessions(self):
"""
Clean expired sesisons.
"""
tooOld = extime.Time() - timedelta(seconds=PERSISTENT_SESSION_LIFETIME)
self.store.query(
PersistentSession,
PersistentSession.lastUsed < tooOld).deleteFromStore()
self._lastClean = self._cl... | [
"def",
"_cleanSessions",
"(",
"self",
")",
":",
"tooOld",
"=",
"extime",
".",
"Time",
"(",
")",
"-",
"timedelta",
"(",
"seconds",
"=",
"PERSISTENT_SESSION_LIFETIME",
")",
"self",
".",
"store",
".",
"query",
"(",
"PersistentSession",
",",
"PersistentSession",
... | Clean expired sesisons. | [
"Clean",
"expired",
"sesisons",
"."
] | 53e5502aba23ce99be78b27f923a276593033fe8 | https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/websession.py#L228-L236 |
56,386 | twisted/mantissa | xmantissa/websession.py | PersistentSessionWrapper._maybeCleanSessions | def _maybeCleanSessions(self):
"""
Clean expired sessions if it's been long enough since the last clean.
"""
sinceLast = self._clock.seconds() - self._lastClean
if sinceLast > self.sessionCleanFrequency:
self._cleanSessions() | python | def _maybeCleanSessions(self):
"""
Clean expired sessions if it's been long enough since the last clean.
"""
sinceLast = self._clock.seconds() - self._lastClean
if sinceLast > self.sessionCleanFrequency:
self._cleanSessions() | [
"def",
"_maybeCleanSessions",
"(",
"self",
")",
":",
"sinceLast",
"=",
"self",
".",
"_clock",
".",
"seconds",
"(",
")",
"-",
"self",
".",
"_lastClean",
"if",
"sinceLast",
">",
"self",
".",
"sessionCleanFrequency",
":",
"self",
".",
"_cleanSessions",
"(",
"... | Clean expired sessions if it's been long enough since the last clean. | [
"Clean",
"expired",
"sessions",
"if",
"it",
"s",
"been",
"long",
"enough",
"since",
"the",
"last",
"clean",
"."
] | 53e5502aba23ce99be78b27f923a276593033fe8 | https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/websession.py#L239-L245 |
56,387 | twisted/mantissa | xmantissa/websession.py | PersistentSessionWrapper.cookieDomainForRequest | def cookieDomainForRequest(self, request):
"""
Pick a domain to use when setting cookies.
@type request: L{nevow.inevow.IRequest}
@param request: Request to determine cookie domain for
@rtype: C{str} or C{None}
@return: Domain name to use when setting cookies, or C{None... | python | def cookieDomainForRequest(self, request):
"""
Pick a domain to use when setting cookies.
@type request: L{nevow.inevow.IRequest}
@param request: Request to determine cookie domain for
@rtype: C{str} or C{None}
@return: Domain name to use when setting cookies, or C{None... | [
"def",
"cookieDomainForRequest",
"(",
"self",
",",
"request",
")",
":",
"host",
"=",
"request",
".",
"getHeader",
"(",
"'host'",
")",
"if",
"host",
"is",
"None",
":",
"# This is a malformed request that we cannot possibly handle",
"# safely, fall back to the default behav... | Pick a domain to use when setting cookies.
@type request: L{nevow.inevow.IRequest}
@param request: Request to determine cookie domain for
@rtype: C{str} or C{None}
@return: Domain name to use when setting cookies, or C{None} to
indicate that only the domain in the request s... | [
"Pick",
"a",
"domain",
"to",
"use",
"when",
"setting",
"cookies",
"."
] | 53e5502aba23ce99be78b27f923a276593033fe8 | https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/websession.py#L248-L297 |
56,388 | twisted/mantissa | xmantissa/websession.py | PersistentSessionWrapper.savorSessionCookie | def savorSessionCookie(self, request):
"""
Make the session cookie last as long as the persistent session.
@type request: L{nevow.inevow.IRequest}
@param request: The HTTP request object for the guard login URL.
"""
cookieValue = request.getSession().uid
request.... | python | def savorSessionCookie(self, request):
"""
Make the session cookie last as long as the persistent session.
@type request: L{nevow.inevow.IRequest}
@param request: The HTTP request object for the guard login URL.
"""
cookieValue = request.getSession().uid
request.... | [
"def",
"savorSessionCookie",
"(",
"self",
",",
"request",
")",
":",
"cookieValue",
"=",
"request",
".",
"getSession",
"(",
")",
".",
"uid",
"request",
".",
"addCookie",
"(",
"self",
".",
"cookieKey",
",",
"cookieValue",
",",
"path",
"=",
"'/'",
",",
"max... | Make the session cookie last as long as the persistent session.
@type request: L{nevow.inevow.IRequest}
@param request: The HTTP request object for the guard login URL. | [
"Make",
"the",
"session",
"cookie",
"last",
"as",
"long",
"as",
"the",
"persistent",
"session",
"."
] | 53e5502aba23ce99be78b27f923a276593033fe8 | https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/websession.py#L300-L311 |
56,389 | twisted/mantissa | xmantissa/websession.py | PersistentSessionWrapper.login | def login(self, request, session, creds, segments):
"""
Called to check the credentials of a user.
Here we extend guard's implementation to preauthenticate users if they
have a valid persistent session.
@type request: L{nevow.inevow.IRequest}
@param request: The HTTP re... | python | def login(self, request, session, creds, segments):
"""
Called to check the credentials of a user.
Here we extend guard's implementation to preauthenticate users if they
have a valid persistent session.
@type request: L{nevow.inevow.IRequest}
@param request: The HTTP re... | [
"def",
"login",
"(",
"self",
",",
"request",
",",
"session",
",",
"creds",
",",
"segments",
")",
":",
"self",
".",
"_maybeCleanSessions",
"(",
")",
"if",
"isinstance",
"(",
"creds",
",",
"credentials",
".",
"Anonymous",
")",
":",
"preauth",
"=",
"self",
... | Called to check the credentials of a user.
Here we extend guard's implementation to preauthenticate users if they
have a valid persistent session.
@type request: L{nevow.inevow.IRequest}
@param request: The HTTP request being handled.
@type session: L{nevow.guard.GuardSession}... | [
"Called",
"to",
"check",
"the",
"credentials",
"of",
"a",
"user",
"."
] | 53e5502aba23ce99be78b27f923a276593033fe8 | https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/websession.py#L314-L362 |
56,390 | twisted/mantissa | xmantissa/websession.py | PersistentSessionWrapper.explicitLogout | def explicitLogout(self, session):
"""
Handle a user-requested logout.
Here we override guard's behaviour for the logout action to delete the
persistent session. In this case the user has explicitly requested a
logout, so the persistent session must be deleted to require the us... | python | def explicitLogout(self, session):
"""
Handle a user-requested logout.
Here we override guard's behaviour for the logout action to delete the
persistent session. In this case the user has explicitly requested a
logout, so the persistent session must be deleted to require the us... | [
"def",
"explicitLogout",
"(",
"self",
",",
"session",
")",
":",
"guard",
".",
"SessionWrapper",
".",
"explicitLogout",
"(",
"self",
",",
"session",
")",
"self",
".",
"removeSessionWithKey",
"(",
"session",
".",
"uid",
")"
] | Handle a user-requested logout.
Here we override guard's behaviour for the logout action to delete the
persistent session. In this case the user has explicitly requested a
logout, so the persistent session must be deleted to require the user
to log in on the next request.
@typ... | [
"Handle",
"a",
"user",
"-",
"requested",
"logout",
"."
] | 53e5502aba23ce99be78b27f923a276593033fe8 | https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/websession.py#L365-L378 |
56,391 | twisted/mantissa | xmantissa/websession.py | PersistentSessionWrapper.getCredentials | def getCredentials(self, request):
"""
Derive credentials from an HTTP request.
Override SessionWrapper.getCredentials to add the Host: header to the
credentials. This will make web-based virtual hosting work.
@type request: L{nevow.inevow.IRequest}
@param request: The... | python | def getCredentials(self, request):
"""
Derive credentials from an HTTP request.
Override SessionWrapper.getCredentials to add the Host: header to the
credentials. This will make web-based virtual hosting work.
@type request: L{nevow.inevow.IRequest}
@param request: The... | [
"def",
"getCredentials",
"(",
"self",
",",
"request",
")",
":",
"username",
"=",
"usernameFromRequest",
"(",
"request",
")",
"password",
"=",
"request",
".",
"args",
".",
"get",
"(",
"'password'",
",",
"[",
"''",
"]",
")",
"[",
"0",
"]",
"return",
"cre... | Derive credentials from an HTTP request.
Override SessionWrapper.getCredentials to add the Host: header to the
credentials. This will make web-based virtual hosting work.
@type request: L{nevow.inevow.IRequest}
@param request: The request being handled.
@rtype: L{twisted.cred... | [
"Derive",
"credentials",
"from",
"an",
"HTTP",
"request",
"."
] | 53e5502aba23ce99be78b27f923a276593033fe8 | https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/websession.py#L381-L396 |
56,392 | twisted/mantissa | xmantissa/webnav.py | startMenu | def startMenu(translator, navigation, tag):
"""
Drop-down menu-style navigation view.
For each primary navigation element available, a copy of the I{tab}
pattern will be loaded from the tag. It will have its I{href} slot
filled with the URL for that navigation item. It will have its I{name}
s... | python | def startMenu(translator, navigation, tag):
"""
Drop-down menu-style navigation view.
For each primary navigation element available, a copy of the I{tab}
pattern will be loaded from the tag. It will have its I{href} slot
filled with the URL for that navigation item. It will have its I{name}
s... | [
"def",
"startMenu",
"(",
"translator",
",",
"navigation",
",",
"tag",
")",
":",
"setTabURLs",
"(",
"navigation",
",",
"translator",
")",
"getp",
"=",
"IQ",
"(",
"tag",
")",
".",
"onePattern",
"def",
"fillSlots",
"(",
"tabs",
")",
":",
"for",
"tab",
"in... | Drop-down menu-style navigation view.
For each primary navigation element available, a copy of the I{tab}
pattern will be loaded from the tag. It will have its I{href} slot
filled with the URL for that navigation item. It will have its I{name}
slot filled with the user-visible name of the navigation ... | [
"Drop",
"-",
"down",
"menu",
"-",
"style",
"navigation",
"view",
"."
] | 53e5502aba23ce99be78b27f923a276593033fe8 | https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/webnav.py#L202-L236 |
56,393 | twisted/mantissa | xmantissa/webnav.py | applicationNavigation | def applicationNavigation(ctx, translator, navigation):
"""
Horizontal, primary-only navigation view.
For the navigation element currently being viewed, copies of the
I{selected-app-tab} and I{selected-tab-contents} patterns will be
loaded from the tag. For all other navigation elements, copies of... | python | def applicationNavigation(ctx, translator, navigation):
"""
Horizontal, primary-only navigation view.
For the navigation element currently being viewed, copies of the
I{selected-app-tab} and I{selected-tab-contents} patterns will be
loaded from the tag. For all other navigation elements, copies of... | [
"def",
"applicationNavigation",
"(",
"ctx",
",",
"translator",
",",
"navigation",
")",
":",
"setTabURLs",
"(",
"navigation",
",",
"translator",
")",
"selectedTab",
"=",
"getSelectedTab",
"(",
"navigation",
",",
"url",
".",
"URL",
".",
"fromContext",
"(",
"ctx"... | Horizontal, primary-only navigation view.
For the navigation element currently being viewed, copies of the
I{selected-app-tab} and I{selected-tab-contents} patterns will be
loaded from the tag. For all other navigation elements, copies of the
I{app-tab} and I{tab-contents} patterns will be loaded.
... | [
"Horizontal",
"primary",
"-",
"only",
"navigation",
"view",
"."
] | 53e5502aba23ce99be78b27f923a276593033fe8 | https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/webnav.py#L251-L310 |
56,394 | twisted/mantissa | xmantissa/terminal.py | _generate | def _generate():
"""
Generate a new SSH key pair.
"""
privateKey = rsa.generate_private_key(
public_exponent=65537,
key_size=4096,
backend=default_backend())
return Key(privateKey).toString('openssh') | python | def _generate():
"""
Generate a new SSH key pair.
"""
privateKey = rsa.generate_private_key(
public_exponent=65537,
key_size=4096,
backend=default_backend())
return Key(privateKey).toString('openssh') | [
"def",
"_generate",
"(",
")",
":",
"privateKey",
"=",
"rsa",
".",
"generate_private_key",
"(",
"public_exponent",
"=",
"65537",
",",
"key_size",
"=",
"4096",
",",
"backend",
"=",
"default_backend",
"(",
")",
")",
"return",
"Key",
"(",
"privateKey",
")",
".... | Generate a new SSH key pair. | [
"Generate",
"a",
"new",
"SSH",
"key",
"pair",
"."
] | 53e5502aba23ce99be78b27f923a276593033fe8 | https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/terminal.py#L43-L51 |
56,395 | twisted/mantissa | xmantissa/terminal.py | ShellServer._draw | def _draw(self):
"""
Call the drawing API for the main menu widget with the current known
terminal size and the terminal.
"""
self._window.draw(self._width, self._height, self.terminal) | python | def _draw(self):
"""
Call the drawing API for the main menu widget with the current known
terminal size and the terminal.
"""
self._window.draw(self._width, self._height, self.terminal) | [
"def",
"_draw",
"(",
"self",
")",
":",
"self",
".",
"_window",
".",
"draw",
"(",
"self",
".",
"_width",
",",
"self",
".",
"_height",
",",
"self",
".",
"terminal",
")"
] | Call the drawing API for the main menu widget with the current known
terminal size and the terminal. | [
"Call",
"the",
"drawing",
"API",
"for",
"the",
"main",
"menu",
"widget",
"with",
"the",
"current",
"known",
"terminal",
"size",
"and",
"the",
"terminal",
"."
] | 53e5502aba23ce99be78b27f923a276593033fe8 | https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/terminal.py#L181-L186 |
56,396 | twisted/mantissa | xmantissa/terminal.py | ShellServer.reactivate | def reactivate(self):
"""
Called when a sub-protocol is finished. This disconnects the
sub-protocol and redraws the main menu UI.
"""
self._protocol.connectionLost(None)
self._protocol = None
self.terminal.reset()
self._window.filthy()
self._windo... | python | def reactivate(self):
"""
Called when a sub-protocol is finished. This disconnects the
sub-protocol and redraws the main menu UI.
"""
self._protocol.connectionLost(None)
self._protocol = None
self.terminal.reset()
self._window.filthy()
self._windo... | [
"def",
"reactivate",
"(",
"self",
")",
":",
"self",
".",
"_protocol",
".",
"connectionLost",
"(",
"None",
")",
"self",
".",
"_protocol",
"=",
"None",
"self",
".",
"terminal",
".",
"reset",
"(",
")",
"self",
".",
"_window",
".",
"filthy",
"(",
")",
"s... | Called when a sub-protocol is finished. This disconnects the
sub-protocol and redraws the main menu UI. | [
"Called",
"when",
"a",
"sub",
"-",
"protocol",
"is",
"finished",
".",
"This",
"disconnects",
"the",
"sub",
"-",
"protocol",
"and",
"redraws",
"the",
"main",
"menu",
"UI",
"."
] | 53e5502aba23ce99be78b27f923a276593033fe8 | https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/terminal.py#L220-L229 |
56,397 | twisted/mantissa | xmantissa/terminal.py | ShellServer.keystrokeReceived | def keystrokeReceived(self, keyID, modifier):
"""
Forward input events to the application-supplied protocol if one is
currently active, otherwise forward them to the main menu UI.
"""
if self._protocol is not None:
self._protocol.keystrokeReceived(keyID, modifier)
... | python | def keystrokeReceived(self, keyID, modifier):
"""
Forward input events to the application-supplied protocol if one is
currently active, otherwise forward them to the main menu UI.
"""
if self._protocol is not None:
self._protocol.keystrokeReceived(keyID, modifier)
... | [
"def",
"keystrokeReceived",
"(",
"self",
",",
"keyID",
",",
"modifier",
")",
":",
"if",
"self",
".",
"_protocol",
"is",
"not",
"None",
":",
"self",
".",
"_protocol",
".",
"keystrokeReceived",
"(",
"keyID",
",",
"modifier",
")",
"else",
":",
"self",
".",
... | Forward input events to the application-supplied protocol if one is
currently active, otherwise forward them to the main menu UI. | [
"Forward",
"input",
"events",
"to",
"the",
"application",
"-",
"supplied",
"protocol",
"if",
"one",
"is",
"currently",
"active",
"otherwise",
"forward",
"them",
"to",
"the",
"main",
"menu",
"UI",
"."
] | 53e5502aba23ce99be78b27f923a276593033fe8 | https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/terminal.py#L249-L257 |
56,398 | jwodder/doapi | doapi/floating_ip.py | FloatingIP.fetch | def fetch(self):
"""
Fetch & return a new `FloatingIP` object representing the floating IP's
current state
:rtype: FloatingIP
:raises DOAPIError: if the API endpoint replies with an error (e.g., if
the floating IP no longer exists)
"""
api = self.doap... | python | def fetch(self):
"""
Fetch & return a new `FloatingIP` object representing the floating IP's
current state
:rtype: FloatingIP
:raises DOAPIError: if the API endpoint replies with an error (e.g., if
the floating IP no longer exists)
"""
api = self.doap... | [
"def",
"fetch",
"(",
"self",
")",
":",
"api",
"=",
"self",
".",
"doapi_manager",
"return",
"api",
".",
"_floating_ip",
"(",
"api",
".",
"request",
"(",
"self",
".",
"url",
")",
"[",
"\"floating_ip\"",
"]",
")"
] | Fetch & return a new `FloatingIP` object representing the floating IP's
current state
:rtype: FloatingIP
:raises DOAPIError: if the API endpoint replies with an error (e.g., if
the floating IP no longer exists) | [
"Fetch",
"&",
"return",
"a",
"new",
"FloatingIP",
"object",
"representing",
"the",
"floating",
"IP",
"s",
"current",
"state"
] | b1306de86a01d8ae7b9c1fe2699765bb82e4f310 | https://github.com/jwodder/doapi/blob/b1306de86a01d8ae7b9c1fe2699765bb82e4f310/doapi/floating_ip.py#L60-L70 |
56,399 | jwodder/doapi | doapi/floating_ip.py | FloatingIP.assign | def assign(self, droplet_id):
"""
Assign the floating IP to a droplet
:param droplet_id: the droplet to assign the floating IP to as either
an ID or a `Droplet` object
:type droplet_id: integer or `Droplet`
:return: an `Action` representing the in-progress operation ... | python | def assign(self, droplet_id):
"""
Assign the floating IP to a droplet
:param droplet_id: the droplet to assign the floating IP to as either
an ID or a `Droplet` object
:type droplet_id: integer or `Droplet`
:return: an `Action` representing the in-progress operation ... | [
"def",
"assign",
"(",
"self",
",",
"droplet_id",
")",
":",
"if",
"isinstance",
"(",
"droplet_id",
",",
"Droplet",
")",
":",
"droplet_id",
"=",
"droplet_id",
".",
"id",
"return",
"self",
".",
"act",
"(",
"type",
"=",
"'assign'",
",",
"droplet_id",
"=",
... | Assign the floating IP to a droplet
:param droplet_id: the droplet to assign the floating IP to as either
an ID or a `Droplet` object
:type droplet_id: integer or `Droplet`
:return: an `Action` representing the in-progress operation on the
floating IP
:rtype: Act... | [
"Assign",
"the",
"floating",
"IP",
"to",
"a",
"droplet"
] | b1306de86a01d8ae7b9c1fe2699765bb82e4f310 | https://github.com/jwodder/doapi/blob/b1306de86a01d8ae7b9c1fe2699765bb82e4f310/doapi/floating_ip.py#L81-L95 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.