repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
seryl/Python-Cotendo | cotendo/__init__.py | CotendoHelper.ImportDNS | def ImportDNS(self, config, token=None):
"""
Import a dns configuration file into the helper
Note: This requires that you have the latest token.
To get the latest token, run the GrabDNS command first.
"""
if not token:
raise Exception("You must have the dns t... | python | def ImportDNS(self, config, token=None):
"""
Import a dns configuration file into the helper
Note: This requires that you have the latest token.
To get the latest token, run the GrabDNS command first.
"""
if not token:
raise Exception("You must have the dns t... | [
"def",
"ImportDNS",
"(",
"self",
",",
"config",
",",
"token",
"=",
"None",
")",
":",
"if",
"not",
"token",
":",
"raise",
"Exception",
"(",
"\"You must have the dns token set first.\"",
")",
"self",
".",
"dns",
"=",
"CotendoDNS",
"(",
"[",
"token",
",",
"co... | Import a dns configuration file into the helper
Note: This requires that you have the latest token.
To get the latest token, run the GrabDNS command first. | [
"Import",
"a",
"dns",
"configuration",
"file",
"into",
"the",
"helper"
] | train | https://github.com/seryl/Python-Cotendo/blob/a55e034f0845332319859f6276adc6ba35f5a121/cotendo/__init__.py#L198-L208 |
henrysher/kotocore | kotocore/cache.py | ServiceCache.get_connection | def get_connection(self, service_name):
"""
Retrieves a connection class from the cache, if available.
:param service_name: The service a given ``Connection`` talks to. Ex.
``sqs``, ``sns``, ``dynamodb``, etc.
:type service_name: string
:returns: A <kotocore.connect... | python | def get_connection(self, service_name):
"""
Retrieves a connection class from the cache, if available.
:param service_name: The service a given ``Connection`` talks to. Ex.
``sqs``, ``sns``, ``dynamodb``, etc.
:type service_name: string
:returns: A <kotocore.connect... | [
"def",
"get_connection",
"(",
"self",
",",
"service_name",
")",
":",
"service",
"=",
"self",
".",
"services",
".",
"get",
"(",
"service_name",
",",
"{",
"}",
")",
"connection_class",
"=",
"service",
".",
"get",
"(",
"'connection'",
",",
"None",
")",
"if"... | Retrieves a connection class from the cache, if available.
:param service_name: The service a given ``Connection`` talks to. Ex.
``sqs``, ``sns``, ``dynamodb``, etc.
:type service_name: string
:returns: A <kotocore.connection.Connection> subclass | [
"Retrieves",
"a",
"connection",
"class",
"from",
"the",
"cache",
"if",
"available",
"."
] | train | https://github.com/henrysher/kotocore/blob/c52d2f3878b924ceabca07f61c91abcb1b230ecc/kotocore/cache.py#L47-L66 |
henrysher/kotocore | kotocore/cache.py | ServiceCache.set_connection | def set_connection(self, service_name, to_cache):
"""
Sets a connection class within the cache.
:param service_name: The service a given ``Connection`` talks to. Ex.
``sqs``, ``sns``, ``dynamodb``, etc.
:type service_name: string
:param to_cache: The class to be cac... | python | def set_connection(self, service_name, to_cache):
"""
Sets a connection class within the cache.
:param service_name: The service a given ``Connection`` talks to. Ex.
``sqs``, ``sns``, ``dynamodb``, etc.
:type service_name: string
:param to_cache: The class to be cac... | [
"def",
"set_connection",
"(",
"self",
",",
"service_name",
",",
"to_cache",
")",
":",
"self",
".",
"services",
".",
"setdefault",
"(",
"service_name",
",",
"{",
"}",
")",
"self",
".",
"services",
"[",
"service_name",
"]",
"[",
"'connection'",
"]",
"=",
"... | Sets a connection class within the cache.
:param service_name: The service a given ``Connection`` talks to. Ex.
``sqs``, ``sns``, ``dynamodb``, etc.
:type service_name: string
:param to_cache: The class to be cached for the service.
:type to_cache: class | [
"Sets",
"a",
"connection",
"class",
"within",
"the",
"cache",
"."
] | train | https://github.com/henrysher/kotocore/blob/c52d2f3878b924ceabca07f61c91abcb1b230ecc/kotocore/cache.py#L68-L80 |
henrysher/kotocore | kotocore/cache.py | ServiceCache.get_resource | def get_resource(self, service_name, resource_name, base_class=None):
"""
Retrieves a resource class from the cache, if available.
:param service_name: The service a given ``Resource`` talks to. Ex.
``sqs``, ``sns``, ``dynamodb``, etc.
:type service_name: string
:pa... | python | def get_resource(self, service_name, resource_name, base_class=None):
"""
Retrieves a resource class from the cache, if available.
:param service_name: The service a given ``Resource`` talks to. Ex.
``sqs``, ``sns``, ``dynamodb``, etc.
:type service_name: string
:pa... | [
"def",
"get_resource",
"(",
"self",
",",
"service_name",
",",
"resource_name",
",",
"base_class",
"=",
"None",
")",
":",
"classpath",
"=",
"self",
".",
"build_classpath",
"(",
"base_class",
")",
"service",
"=",
"self",
".",
"services",
".",
"get",
"(",
"se... | Retrieves a resource class from the cache, if available.
:param service_name: The service a given ``Resource`` talks to. Ex.
``sqs``, ``sns``, ``dynamodb``, etc.
:type service_name: string
:param resource_name: The name of the ``Resource``. Ex.
``Queue``, ``Notification... | [
"Retrieves",
"a",
"resource",
"class",
"from",
"the",
"cache",
"if",
"available",
"."
] | train | https://github.com/henrysher/kotocore/blob/c52d2f3878b924ceabca07f61c91abcb1b230ecc/kotocore/cache.py#L110-L142 |
henrysher/kotocore | kotocore/cache.py | ServiceCache.set_resource | def set_resource(self, service_name, resource_name, to_cache):
"""
Sets the resource class within the cache.
:param service_name: The service a given ``Resource`` talks to. Ex.
``sqs``, ``sns``, ``dynamodb``, etc.
:type service_name: string
:param resource_name: The... | python | def set_resource(self, service_name, resource_name, to_cache):
"""
Sets the resource class within the cache.
:param service_name: The service a given ``Resource`` talks to. Ex.
``sqs``, ``sns``, ``dynamodb``, etc.
:type service_name: string
:param resource_name: The... | [
"def",
"set_resource",
"(",
"self",
",",
"service_name",
",",
"resource_name",
",",
"to_cache",
")",
":",
"self",
".",
"services",
".",
"setdefault",
"(",
"service_name",
",",
"{",
"}",
")",
"self",
".",
"services",
"[",
"service_name",
"]",
".",
"setdefau... | Sets the resource class within the cache.
:param service_name: The service a given ``Resource`` talks to. Ex.
``sqs``, ``sns``, ``dynamodb``, etc.
:type service_name: string
:param resource_name: The name of the ``Resource``. Ex.
``Queue``, ``Notification``, ``Table``, ... | [
"Sets",
"the",
"resource",
"class",
"within",
"the",
"cache",
"."
] | train | https://github.com/henrysher/kotocore/blob/c52d2f3878b924ceabca07f61c91abcb1b230ecc/kotocore/cache.py#L144-L168 |
henrysher/kotocore | kotocore/cache.py | ServiceCache.del_resource | def del_resource(self, service_name, resource_name, base_class=None):
"""
Deletes a resource class for a given service.
Fails silently if no connection is found in the cache.
:param service_name: The service a given ``Resource`` talks to. Ex.
``sqs``, ``sns``, ``dynamodb``,... | python | def del_resource(self, service_name, resource_name, base_class=None):
"""
Deletes a resource class for a given service.
Fails silently if no connection is found in the cache.
:param service_name: The service a given ``Resource`` talks to. Ex.
``sqs``, ``sns``, ``dynamodb``,... | [
"def",
"del_resource",
"(",
"self",
",",
"service_name",
",",
"resource_name",
",",
"base_class",
"=",
"None",
")",
":",
"# Unlike ``get_resource``, this should be fire & forget.",
"# We don't really care, as long as it's not in the cache any longer.",
"try",
":",
"classpath",
... | Deletes a resource class for a given service.
Fails silently if no connection is found in the cache.
:param service_name: The service a given ``Resource`` talks to. Ex.
``sqs``, ``sns``, ``dynamodb``, etc.
:type service_name: string
:param base_class: (Optional) The base c... | [
"Deletes",
"a",
"resource",
"class",
"for",
"a",
"given",
"service",
"."
] | train | https://github.com/henrysher/kotocore/blob/c52d2f3878b924ceabca07f61c91abcb1b230ecc/kotocore/cache.py#L170-L192 |
henrysher/kotocore | kotocore/cache.py | ServiceCache.get_collection | def get_collection(self, service_name, collection_name, base_class=None):
"""
Retrieves a collection class from the cache, if available.
:param service_name: The service a given ``Collection`` talks to. Ex.
``sqs``, ``sns``, ``dynamodb``, etc.
:type service_name: string
... | python | def get_collection(self, service_name, collection_name, base_class=None):
"""
Retrieves a collection class from the cache, if available.
:param service_name: The service a given ``Collection`` talks to. Ex.
``sqs``, ``sns``, ``dynamodb``, etc.
:type service_name: string
... | [
"def",
"get_collection",
"(",
"self",
",",
"service_name",
",",
"collection_name",
",",
"base_class",
"=",
"None",
")",
":",
"classpath",
"=",
"self",
".",
"build_classpath",
"(",
"base_class",
")",
"service",
"=",
"self",
".",
"services",
".",
"get",
"(",
... | Retrieves a collection class from the cache, if available.
:param service_name: The service a given ``Collection`` talks to. Ex.
``sqs``, ``sns``, ``dynamodb``, etc.
:type service_name: string
:param collection_name: The name of the ``Collection``. Ex.
``QueueCollection... | [
"Retrieves",
"a",
"collection",
"class",
"from",
"the",
"cache",
"if",
"available",
"."
] | train | https://github.com/henrysher/kotocore/blob/c52d2f3878b924ceabca07f61c91abcb1b230ecc/kotocore/cache.py#L194-L227 |
henrysher/kotocore | kotocore/cache.py | ServiceCache.set_collection | def set_collection(self, service_name, collection_name, to_cache):
"""
Sets a collection class within the cache.
:param service_name: The service a given ``Collection`` talks to. Ex.
``sqs``, ``sns``, ``dynamodb``, etc.
:type service_name: string
:param collection_n... | python | def set_collection(self, service_name, collection_name, to_cache):
"""
Sets a collection class within the cache.
:param service_name: The service a given ``Collection`` talks to. Ex.
``sqs``, ``sns``, ``dynamodb``, etc.
:type service_name: string
:param collection_n... | [
"def",
"set_collection",
"(",
"self",
",",
"service_name",
",",
"collection_name",
",",
"to_cache",
")",
":",
"self",
".",
"services",
".",
"setdefault",
"(",
"service_name",
",",
"{",
"}",
")",
"self",
".",
"services",
"[",
"service_name",
"]",
".",
"setd... | Sets a collection class within the cache.
:param service_name: The service a given ``Collection`` talks to. Ex.
``sqs``, ``sns``, ``dynamodb``, etc.
:type service_name: string
:param collection_name: The name of the ``Collection``. Ex.
``QueueCollection``, ``Notificatio... | [
"Sets",
"a",
"collection",
"class",
"within",
"the",
"cache",
"."
] | train | https://github.com/henrysher/kotocore/blob/c52d2f3878b924ceabca07f61c91abcb1b230ecc/kotocore/cache.py#L229-L254 |
henrysher/kotocore | kotocore/cache.py | ServiceCache.del_collection | def del_collection(self, service_name, collection_name, base_class=None):
"""
Deletes a collection for a given service.
Fails silently if no collection is found in the cache.
:param service_name: The service a given ``Collection`` talks to. Ex.
``sqs``, ``sns``, ``dynamodb`... | python | def del_collection(self, service_name, collection_name, base_class=None):
"""
Deletes a collection for a given service.
Fails silently if no collection is found in the cache.
:param service_name: The service a given ``Collection`` talks to. Ex.
``sqs``, ``sns``, ``dynamodb`... | [
"def",
"del_collection",
"(",
"self",
",",
"service_name",
",",
"collection_name",
",",
"base_class",
"=",
"None",
")",
":",
"# Unlike ``get_collection``, this should be fire & forget.",
"# We don't really care, as long as it's not in the cache any longer.",
"try",
":",
"classpat... | Deletes a collection for a given service.
Fails silently if no collection is found in the cache.
:param service_name: The service a given ``Collection`` talks to. Ex.
``sqs``, ``sns``, ``dynamodb``, etc.
:type service_name: string
:param collection_name: The name of the ``... | [
"Deletes",
"a",
"collection",
"for",
"a",
"given",
"service",
"."
] | train | https://github.com/henrysher/kotocore/blob/c52d2f3878b924ceabca07f61c91abcb1b230ecc/kotocore/cache.py#L256-L283 |
amadev/doan | doan/util.py | chunk | def chunk(seq, n):
# http://stackoverflow.com/a/312464/190597 (Ned Batchelder)
""" Yield successive n-sized chunks from seq."""
for i in range(0, len(seq), n):
yield seq[i:i + n] | python | def chunk(seq, n):
# http://stackoverflow.com/a/312464/190597 (Ned Batchelder)
""" Yield successive n-sized chunks from seq."""
for i in range(0, len(seq), n):
yield seq[i:i + n] | [
"def",
"chunk",
"(",
"seq",
",",
"n",
")",
":",
"# http://stackoverflow.com/a/312464/190597 (Ned Batchelder)",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"seq",
")",
",",
"n",
")",
":",
"yield",
"seq",
"[",
"i",
":",
"i",
"+",
"n",
"]"
] | Yield successive n-sized chunks from seq. | [
"Yield",
"successive",
"n",
"-",
"sized",
"chunks",
"from",
"seq",
"."
] | train | https://github.com/amadev/doan/blob/5adfa983ac547007a688fe7517291a432919aa3e/doan/util.py#L15-L19 |
thespacedoctor/neddy | neddy/_basesearch.py | _basesearch._convert_coordinates_to_decimal_degrees | def _convert_coordinates_to_decimal_degrees(
self):
"""
*convert coordinates to decimal degrees*
"""
self.log.info(
'starting the ``_convert_coordinates_to_decimal_degrees`` method')
converter = unit_conversion(
log=self.log
)
... | python | def _convert_coordinates_to_decimal_degrees(
self):
"""
*convert coordinates to decimal degrees*
"""
self.log.info(
'starting the ``_convert_coordinates_to_decimal_degrees`` method')
converter = unit_conversion(
log=self.log
)
... | [
"def",
"_convert_coordinates_to_decimal_degrees",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"'starting the ``_convert_coordinates_to_decimal_degrees`` method'",
")",
"converter",
"=",
"unit_conversion",
"(",
"log",
"=",
"self",
".",
"log",
")",
"# C... | *convert coordinates to decimal degrees* | [
"*",
"convert",
"coordinates",
"to",
"decimal",
"degrees",
"*"
] | train | https://github.com/thespacedoctor/neddy/blob/f32653b7d6a39a2c46c5845f83b3a29056311e5e/neddy/_basesearch.py#L40-L86 |
thespacedoctor/neddy | neddy/_basesearch.py | _basesearch._parse_the_ned_position_results | def _parse_the_ned_position_results(
self,
ra,
dec,
nedResults):
"""
*parse the ned results*
**Key Arguments:**
- ``ra`` -- the search ra
- ``dec`` -- the search dec
**Return:**
- ``results`` -- list of... | python | def _parse_the_ned_position_results(
self,
ra,
dec,
nedResults):
"""
*parse the ned results*
**Key Arguments:**
- ``ra`` -- the search ra
- ``dec`` -- the search dec
**Return:**
- ``results`` -- list of... | [
"def",
"_parse_the_ned_position_results",
"(",
"self",
",",
"ra",
",",
"dec",
",",
"nedResults",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"'starting the ``_parse_the_ned_results`` method'",
")",
"results",
"=",
"[",
"]",
"resultLen",
"=",
"0",
"if",
"ne... | *parse the ned results*
**Key Arguments:**
- ``ra`` -- the search ra
- ``dec`` -- the search dec
**Return:**
- ``results`` -- list of result dictionaries | [
"*",
"parse",
"the",
"ned",
"results",
"*"
] | train | https://github.com/thespacedoctor/neddy/blob/f32653b7d6a39a2c46c5845f83b3a29056311e5e/neddy/_basesearch.py#L88-L146 |
thespacedoctor/neddy | neddy/_basesearch.py | _basesearch._parse_the_ned_object_results | def _parse_the_ned_object_results(
self):
"""
*parse the ned results*
**Key Arguments:**
# -
**Return:**
- None
.. todo::
- @review: when complete, clean _parse_the_ned_results method
- @review: when complete add log... | python | def _parse_the_ned_object_results(
self):
"""
*parse the ned results*
**Key Arguments:**
# -
**Return:**
- None
.. todo::
- @review: when complete, clean _parse_the_ned_results method
- @review: when complete add log... | [
"def",
"_parse_the_ned_object_results",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"'starting the ``_parse_the_ned_results`` method'",
")",
"results",
"=",
"[",
"]",
"headers",
"=",
"[",
"\"objectName\"",
",",
"\"objectType\"",
",",
"\"raDeg\"",
... | *parse the ned results*
**Key Arguments:**
# -
**Return:**
- None
.. todo::
- @review: when complete, clean _parse_the_ned_results method
- @review: when complete add logging | [
"*",
"parse",
"the",
"ned",
"results",
"*"
] | train | https://github.com/thespacedoctor/neddy/blob/f32653b7d6a39a2c46c5845f83b3a29056311e5e/neddy/_basesearch.py#L149-L234 |
thespacedoctor/neddy | neddy/_basesearch.py | _basesearch._convert_html_to_csv | def _convert_html_to_csv(
self):
"""
*contert html to csv*
**Key Arguments:**
# -
**Return:**
- None
.. todo::
- @review: when complete, clean _convert_html_to_csv method
- @review: when complete add logging
... | python | def _convert_html_to_csv(
self):
"""
*contert html to csv*
**Key Arguments:**
# -
**Return:**
- None
.. todo::
- @review: when complete, clean _convert_html_to_csv method
- @review: when complete add logging
... | [
"def",
"_convert_html_to_csv",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"'starting the ``_convert_html_to_csv`` method'",
")",
"import",
"codecs",
"allData",
"=",
"\"\"",
"regex1",
"=",
"re",
".",
"compile",
"(",
"r'.*<PRE><strong> (.*?)</stron... | *contert html to csv*
**Key Arguments:**
# -
**Return:**
- None
.. todo::
- @review: when complete, clean _convert_html_to_csv method
- @review: when complete add logging | [
"*",
"contert",
"html",
"to",
"csv",
"*"
] | train | https://github.com/thespacedoctor/neddy/blob/f32653b7d6a39a2c46c5845f83b3a29056311e5e/neddy/_basesearch.py#L237-L292 |
thespacedoctor/neddy | neddy/_basesearch.py | _basesearch._parse_the_ned_list_results | def _parse_the_ned_list_results(
self):
"""
*parse the ned results*
**Key Arguments:**
# -
**Return:**
- None
.. todo::
- @review: when complete, clean _parse_the_ned_results method
- @review: when complete add loggi... | python | def _parse_the_ned_list_results(
self):
"""
*parse the ned results*
**Key Arguments:**
# -
**Return:**
- None
.. todo::
- @review: when complete, clean _parse_the_ned_results method
- @review: when complete add loggi... | [
"def",
"_parse_the_ned_list_results",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"'starting the ``_parse_the_ned_list_results`` method'",
")",
"results",
"=",
"[",
"]",
"# CHOOSE VALUES TO RETURN",
"allHeaders",
"=",
"[",
"\"searchIndex\"",
",",
"\"s... | *parse the ned results*
**Key Arguments:**
# -
**Return:**
- None
.. todo::
- @review: when complete, clean _parse_the_ned_results method
- @review: when complete add logging | [
"*",
"parse",
"the",
"ned",
"results",
"*"
] | train | https://github.com/thespacedoctor/neddy/blob/f32653b7d6a39a2c46c5845f83b3a29056311e5e/neddy/_basesearch.py#L295-L399 |
thespacedoctor/neddy | neddy/_basesearch.py | _basesearch._split_incoming_queries_into_batches | def _split_incoming_queries_into_batches(
self,
sources,
searchParams=False):
"""
*split incoming queries into batches*
**Key Arguments:**
- ``sources`` -- sources to split into batches
- ``searchParams`` -- search params associated wi... | python | def _split_incoming_queries_into_batches(
self,
sources,
searchParams=False):
"""
*split incoming queries into batches*
**Key Arguments:**
- ``sources`` -- sources to split into batches
- ``searchParams`` -- search params associated wi... | [
"def",
"_split_incoming_queries_into_batches",
"(",
"self",
",",
"sources",
",",
"searchParams",
"=",
"False",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"'starting the ``_split_incoming_queries_into_batches`` method'",
")",
"batchSize",
"=",
"180",
"total",
"=",... | *split incoming queries into batches*
**Key Arguments:**
- ``sources`` -- sources to split into batches
- ``searchParams`` -- search params associated with batches
**Return:**
- ``theseBatches`` -- list of batches
- ``theseBatchParams`` -- params associa... | [
"*",
"split",
"incoming",
"queries",
"into",
"batches",
"*"
] | train | https://github.com/thespacedoctor/neddy/blob/f32653b7d6a39a2c46c5845f83b3a29056311e5e/neddy/_basesearch.py#L401-L442 |
RayCrafter/clusterlogger | src/clusterlogger/logfilter.py | HazelHenFilter.filter | def filter(self, record):
"""Add contextual information to the log record
:param record: the log record
:type record: :class:`logging.LogRecord`
:returns: True, if log should get sent
:rtype: :class:`bool`
:raises: None
"""
record.sitename = self.sitename... | python | def filter(self, record):
"""Add contextual information to the log record
:param record: the log record
:type record: :class:`logging.LogRecord`
:returns: True, if log should get sent
:rtype: :class:`bool`
:raises: None
"""
record.sitename = self.sitename... | [
"def",
"filter",
"(",
"self",
",",
"record",
")",
":",
"record",
".",
"sitename",
"=",
"self",
".",
"sitename",
"record",
".",
"platform",
"=",
"self",
".",
"platform",
"record",
".",
"jobid",
"=",
"self",
".",
"jobid",
"record",
".",
"submitter",
"=",... | Add contextual information to the log record
:param record: the log record
:type record: :class:`logging.LogRecord`
:returns: True, if log should get sent
:rtype: :class:`bool`
:raises: None | [
"Add",
"contextual",
"information",
"to",
"the",
"log",
"record"
] | train | https://github.com/RayCrafter/clusterlogger/blob/c67a833a0b9d0c007d4054358702462706933df3/src/clusterlogger/logfilter.py#L39-L55 |
mk-fg/txboxdotnet | txboxdotnet/api_v2.py | BoxAuthMixin.auth_user_get_url | def auth_user_get_url(self):
'Build authorization URL for User Agent.'
if not self.client_id: raise AuthenticationError('No client_id specified')
return '{}?{}'.format(self.auth_url_user, urllib.urlencode(dict(
client_id=self.client_id, state=self.auth_state_check,
response_type='code', redirect_uri=self.au... | python | def auth_user_get_url(self):
'Build authorization URL for User Agent.'
if not self.client_id: raise AuthenticationError('No client_id specified')
return '{}?{}'.format(self.auth_url_user, urllib.urlencode(dict(
client_id=self.client_id, state=self.auth_state_check,
response_type='code', redirect_uri=self.au... | [
"def",
"auth_user_get_url",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"client_id",
":",
"raise",
"AuthenticationError",
"(",
"'No client_id specified'",
")",
"return",
"'{}?{}'",
".",
"format",
"(",
"self",
".",
"auth_url_user",
",",
"urllib",
".",
"url... | Build authorization URL for User Agent. | [
"Build",
"authorization",
"URL",
"for",
"User",
"Agent",
"."
] | train | https://github.com/mk-fg/txboxdotnet/blob/4a3e48fbe1388c5e2a17e808aaaf6b2460e61f48/txboxdotnet/api_v2.py#L102-L107 |
mk-fg/txboxdotnet | txboxdotnet/api_v2.py | BoxAPIWrapper.listdir | def listdir(self, folder_id='0', offset=None, limit=None, fields=None):
'Get Box object, representing list of objects in a folder.'
if fields is not None\
and not isinstance(fields, types.StringTypes): fields = ','.join(fields)
return self(
join('folders', folder_id, 'items'),
dict(offset=offset, limit=l... | python | def listdir(self, folder_id='0', offset=None, limit=None, fields=None):
'Get Box object, representing list of objects in a folder.'
if fields is not None\
and not isinstance(fields, types.StringTypes): fields = ','.join(fields)
return self(
join('folders', folder_id, 'items'),
dict(offset=offset, limit=l... | [
"def",
"listdir",
"(",
"self",
",",
"folder_id",
"=",
"'0'",
",",
"offset",
"=",
"None",
",",
"limit",
"=",
"None",
",",
"fields",
"=",
"None",
")",
":",
"if",
"fields",
"is",
"not",
"None",
"and",
"not",
"isinstance",
"(",
"fields",
",",
"types",
... | Get Box object, representing list of objects in a folder. | [
"Get",
"Box",
"object",
"representing",
"list",
"of",
"objects",
"in",
"a",
"folder",
"."
] | train | https://github.com/mk-fg/txboxdotnet/blob/4a3e48fbe1388c5e2a17e808aaaf6b2460e61f48/txboxdotnet/api_v2.py#L213-L219 |
mk-fg/txboxdotnet | txboxdotnet/api_v2.py | BoxAPIWrapper.get | def get(self, file_id, byte_range=None, version=None):
'''Download and return an file (object) or a specified byte_range from it.
Version keyword is API-specific, see "etag" file info key:
http://developers.box.com/docs/#files-file-object-2
See HTTP Range header (rfc2616) for possible byte_range formats,
... | python | def get(self, file_id, byte_range=None, version=None):
'''Download and return an file (object) or a specified byte_range from it.
Version keyword is API-specific, see "etag" file info key:
http://developers.box.com/docs/#files-file-object-2
See HTTP Range header (rfc2616) for possible byte_range formats,
... | [
"def",
"get",
"(",
"self",
",",
"file_id",
",",
"byte_range",
"=",
"None",
",",
"version",
"=",
"None",
")",
":",
"kwz",
"=",
"dict",
"(",
")",
"if",
"byte_range",
":",
"kwz",
"[",
"'headers'",
"]",
"=",
"dict",
"(",
"Range",
"=",
"'bytes={}'",
"."... | Download and return an file (object) or a specified byte_range from it.
Version keyword is API-specific, see "etag" file info key:
http://developers.box.com/docs/#files-file-object-2
See HTTP Range header (rfc2616) for possible byte_range formats,
some examples: "0-499" - byte offsets 0-499 (inclusive), "... | [
"Download",
"and",
"return",
"an",
"file",
"(",
"object",
")",
"or",
"a",
"specified",
"byte_range",
"from",
"it",
".",
"Version",
"keyword",
"is",
"API",
"-",
"specific",
"see",
"etag",
"file",
"info",
"key",
":",
"http",
":",
"//",
"developers",
".",
... | train | https://github.com/mk-fg/txboxdotnet/blob/4a3e48fbe1388c5e2a17e808aaaf6b2460e61f48/txboxdotnet/api_v2.py#L239-L247 |
mk-fg/txboxdotnet | txboxdotnet/api_v2.py | BoxAPIWrapper.put | def put(self, path_or_tuple, folder_id='0', file_id=None, file_etag=None):
'''Upload a file, returning error if a file with the same "name" attribute exists,
unless valid file_id (and optionally file_etag,
to avoid race conditions, raises error 412) is provided.
folder_id is the id of a folder to put file ... | python | def put(self, path_or_tuple, folder_id='0', file_id=None, file_etag=None):
'''Upload a file, returning error if a file with the same "name" attribute exists,
unless valid file_id (and optionally file_etag,
to avoid race conditions, raises error 412) is provided.
folder_id is the id of a folder to put file ... | [
"def",
"put",
"(",
"self",
",",
"path_or_tuple",
",",
"folder_id",
"=",
"'0'",
",",
"file_id",
"=",
"None",
",",
"file_etag",
"=",
"None",
")",
":",
"name",
",",
"src",
"=",
"(",
"basename",
"(",
"path_or_tuple",
")",
",",
"open",
"(",
"path_or_tuple",... | Upload a file, returning error if a file with the same "name" attribute exists,
unless valid file_id (and optionally file_etag,
to avoid race conditions, raises error 412) is provided.
folder_id is the id of a folder to put file into,
but only used if file_id keyword is not passed. | [
"Upload",
"a",
"file",
"returning",
"error",
"if",
"a",
"file",
"with",
"the",
"same",
"name",
"attribute",
"exists",
"unless",
"valid",
"file_id",
"(",
"and",
"optionally",
"file_etag",
"to",
"avoid",
"race",
"conditions",
"raises",
"error",
"412",
")",
"is... | train | https://github.com/mk-fg/txboxdotnet/blob/4a3e48fbe1388c5e2a17e808aaaf6b2460e61f48/txboxdotnet/api_v2.py#L249-L263 |
mk-fg/txboxdotnet | txboxdotnet/api_v2.py | BoxAPIWrapper.mkdir | def mkdir(self, name=None, folder_id='0'):
'''Create a folder with a specified "name" attribute.
folder_id allows to specify a parent folder.'''
return self( 'folders', method='post', encode='json',
data=dict(name=name, parent=dict(id=folder_id)) ) | python | def mkdir(self, name=None, folder_id='0'):
'''Create a folder with a specified "name" attribute.
folder_id allows to specify a parent folder.'''
return self( 'folders', method='post', encode='json',
data=dict(name=name, parent=dict(id=folder_id)) ) | [
"def",
"mkdir",
"(",
"self",
",",
"name",
"=",
"None",
",",
"folder_id",
"=",
"'0'",
")",
":",
"return",
"self",
"(",
"'folders'",
",",
"method",
"=",
"'post'",
",",
"encode",
"=",
"'json'",
",",
"data",
"=",
"dict",
"(",
"name",
"=",
"name",
",",
... | Create a folder with a specified "name" attribute.
folder_id allows to specify a parent folder. | [
"Create",
"a",
"folder",
"with",
"a",
"specified",
"name",
"attribute",
".",
"folder_id",
"allows",
"to",
"specify",
"a",
"parent",
"folder",
"."
] | train | https://github.com/mk-fg/txboxdotnet/blob/4a3e48fbe1388c5e2a17e808aaaf6b2460e61f48/txboxdotnet/api_v2.py#L269-L273 |
mk-fg/txboxdotnet | txboxdotnet/api_v2.py | BoxAPIWrapper.delete_file | def delete_file(self, file_id, file_etag=None):
'''Delete specified file.
Pass file_etag to avoid race conditions (raises error 412).'''
return self( join('files', bytes(file_id)), method='delete',
headers={'If-Match': file_etag} if file_etag else dict() ) | python | def delete_file(self, file_id, file_etag=None):
'''Delete specified file.
Pass file_etag to avoid race conditions (raises error 412).'''
return self( join('files', bytes(file_id)), method='delete',
headers={'If-Match': file_etag} if file_etag else dict() ) | [
"def",
"delete_file",
"(",
"self",
",",
"file_id",
",",
"file_etag",
"=",
"None",
")",
":",
"return",
"self",
"(",
"join",
"(",
"'files'",
",",
"bytes",
"(",
"file_id",
")",
")",
",",
"method",
"=",
"'delete'",
",",
"headers",
"=",
"{",
"'If-Match'",
... | Delete specified file.
Pass file_etag to avoid race conditions (raises error 412). | [
"Delete",
"specified",
"file",
".",
"Pass",
"file_etag",
"to",
"avoid",
"race",
"conditions",
"(",
"raises",
"error",
"412",
")",
"."
] | train | https://github.com/mk-fg/txboxdotnet/blob/4a3e48fbe1388c5e2a17e808aaaf6b2460e61f48/txboxdotnet/api_v2.py#L275-L279 |
mk-fg/txboxdotnet | txboxdotnet/api_v2.py | BoxAPIWrapper.delete_folder | def delete_folder(self, folder_id, folder_etag=None, recursive=None):
'''Delete specified folder.
Pass folder_etag to avoid race conditions (raises error 412).
recursive keyword does just what it says on the tin.'''
return self( join('folders', folder_id),
dict(recursive=recursive), method='delete',
hea... | python | def delete_folder(self, folder_id, folder_etag=None, recursive=None):
'''Delete specified folder.
Pass folder_etag to avoid race conditions (raises error 412).
recursive keyword does just what it says on the tin.'''
return self( join('folders', folder_id),
dict(recursive=recursive), method='delete',
hea... | [
"def",
"delete_folder",
"(",
"self",
",",
"folder_id",
",",
"folder_etag",
"=",
"None",
",",
"recursive",
"=",
"None",
")",
":",
"return",
"self",
"(",
"join",
"(",
"'folders'",
",",
"folder_id",
")",
",",
"dict",
"(",
"recursive",
"=",
"recursive",
")",... | Delete specified folder.
Pass folder_etag to avoid race conditions (raises error 412).
recursive keyword does just what it says on the tin. | [
"Delete",
"specified",
"folder",
".",
"Pass",
"folder_etag",
"to",
"avoid",
"race",
"conditions",
"(",
"raises",
"error",
"412",
")",
".",
"recursive",
"keyword",
"does",
"just",
"what",
"it",
"says",
"on",
"the",
"tin",
"."
] | train | https://github.com/mk-fg/txboxdotnet/blob/4a3e48fbe1388c5e2a17e808aaaf6b2460e61f48/txboxdotnet/api_v2.py#L281-L287 |
mk-fg/txboxdotnet | txboxdotnet/api_v2.py | txBoxAPI.auth_get_token | def auth_get_token(self, check_state=True):
'Refresh or acquire access_token.'
res = self.auth_access_data_raw = yield self._auth_token_request()
defer.returnValue(self._auth_token_process(res, check_state=check_state)) | python | def auth_get_token(self, check_state=True):
'Refresh or acquire access_token.'
res = self.auth_access_data_raw = yield self._auth_token_request()
defer.returnValue(self._auth_token_process(res, check_state=check_state)) | [
"def",
"auth_get_token",
"(",
"self",
",",
"check_state",
"=",
"True",
")",
":",
"res",
"=",
"self",
".",
"auth_access_data_raw",
"=",
"yield",
"self",
".",
"_auth_token_request",
"(",
")",
"defer",
".",
"returnValue",
"(",
"self",
".",
"_auth_token_process",
... | Refresh or acquire access_token. | [
"Refresh",
"or",
"acquire",
"access_token",
"."
] | train | https://github.com/mk-fg/txboxdotnet/blob/4a3e48fbe1388c5e2a17e808aaaf6b2460e61f48/txboxdotnet/api_v2.py#L704-L707 |
mk-fg/txboxdotnet | txboxdotnet/api_v2.py | txBox.resolve_path | def resolve_path( self, path,
root_id='0', objects=False ):
'''Return id (or metadata) of an object, specified by chain
(iterable or fs-style path string) of "name" attributes of it's ancestors,
or raises DoesNotExists error.
Requires a lot of calls to resolve each name in path, so use with care.
roo... | python | def resolve_path( self, path,
root_id='0', objects=False ):
'''Return id (or metadata) of an object, specified by chain
(iterable or fs-style path string) of "name" attributes of it's ancestors,
or raises DoesNotExists error.
Requires a lot of calls to resolve each name in path, so use with care.
roo... | [
"def",
"resolve_path",
"(",
"self",
",",
"path",
",",
"root_id",
"=",
"'0'",
",",
"objects",
"=",
"False",
")",
":",
"if",
"path",
":",
"if",
"isinstance",
"(",
"path",
",",
"types",
".",
"StringTypes",
")",
":",
"path",
"=",
"filter",
"(",
"None",
... | Return id (or metadata) of an object, specified by chain
(iterable or fs-style path string) of "name" attributes of it's ancestors,
or raises DoesNotExists error.
Requires a lot of calls to resolve each name in path, so use with care.
root_id parameter allows to specify path
relative to some folder_i... | [
"Return",
"id",
"(",
"or",
"metadata",
")",
"of",
"an",
"object",
"specified",
"by",
"chain",
"(",
"iterable",
"or",
"fs",
"-",
"style",
"path",
"string",
")",
"of",
"name",
"attributes",
"of",
"it",
"s",
"ancestors",
"or",
"raises",
"DoesNotExists",
"er... | train | https://github.com/mk-fg/txboxdotnet/blob/4a3e48fbe1388c5e2a17e808aaaf6b2460e61f48/txboxdotnet/api_v2.py#L715-L734 |
mk-fg/txboxdotnet | txboxdotnet/api_v2.py | txBox.listdir | def listdir( self, folder_id='0',
type_filter=None, offset=None, limit=None, **listdir_kwz ):
'''Return a list of objects in the specified folder_id.
limit is passed to the API, so might be used as optimization.
None means "fetch all items, with several requests, if necessary".
type_filter can be set to ... | python | def listdir( self, folder_id='0',
type_filter=None, offset=None, limit=None, **listdir_kwz ):
'''Return a list of objects in the specified folder_id.
limit is passed to the API, so might be used as optimization.
None means "fetch all items, with several requests, if necessary".
type_filter can be set to ... | [
"def",
"listdir",
"(",
"self",
",",
"folder_id",
"=",
"'0'",
",",
"type_filter",
"=",
"None",
",",
"offset",
"=",
"None",
",",
"limit",
"=",
"None",
",",
"*",
"*",
"listdir_kwz",
")",
":",
"res",
"=",
"yield",
"super",
"(",
"txBox",
",",
"self",
")... | Return a list of objects in the specified folder_id.
limit is passed to the API, so might be used as optimization.
None means "fetch all items, with several requests, if necessary".
type_filter can be set to type (str) or sequence
of object types to return, post-api-call processing. | [
"Return",
"a",
"list",
"of",
"objects",
"in",
"the",
"specified",
"folder_id",
".",
"limit",
"is",
"passed",
"to",
"the",
"API",
"so",
"might",
"be",
"used",
"as",
"optimization",
".",
"None",
"means",
"fetch",
"all",
"items",
"with",
"several",
"requests"... | train | https://github.com/mk-fg/txboxdotnet/blob/4a3e48fbe1388c5e2a17e808aaaf6b2460e61f48/txboxdotnet/api_v2.py#L737-L757 |
mk-fg/txboxdotnet | txboxdotnet/api_v2.py | txBox.get_quota | def get_quota(self):
'Return tuple of (bytes_available, bytes_quota).'
du, ds = op.itemgetter('space_used', 'space_amount')\
((yield super(txBox, self).info_user()))
defer.returnValue((ds - du, ds)) | python | def get_quota(self):
'Return tuple of (bytes_available, bytes_quota).'
du, ds = op.itemgetter('space_used', 'space_amount')\
((yield super(txBox, self).info_user()))
defer.returnValue((ds - du, ds)) | [
"def",
"get_quota",
"(",
"self",
")",
":",
"du",
",",
"ds",
"=",
"op",
".",
"itemgetter",
"(",
"'space_used'",
",",
"'space_amount'",
")",
"(",
"(",
"yield",
"super",
"(",
"txBox",
",",
"self",
")",
".",
"info_user",
"(",
")",
")",
")",
"defer",
".... | Return tuple of (bytes_available, bytes_quota). | [
"Return",
"tuple",
"of",
"(",
"bytes_available",
"bytes_quota",
")",
"."
] | train | https://github.com/mk-fg/txboxdotnet/blob/4a3e48fbe1388c5e2a17e808aaaf6b2460e61f48/txboxdotnet/api_v2.py#L760-L764 |
coghost/izen | izen/dec.py | retry | def retry(tries, delay=0, back_off=1, raise_msg=''):
"""Retries a function or method until it got True.
- ``delay`` sets the initial delay in seconds
- ``back_off`` sets the factor by which
- ``raise_msg`` if not '', it'll raise an Exception
"""
if back_off < 1:
raise ValueError('back_... | python | def retry(tries, delay=0, back_off=1, raise_msg=''):
"""Retries a function or method until it got True.
- ``delay`` sets the initial delay in seconds
- ``back_off`` sets the factor by which
- ``raise_msg`` if not '', it'll raise an Exception
"""
if back_off < 1:
raise ValueError('back_... | [
"def",
"retry",
"(",
"tries",
",",
"delay",
"=",
"0",
",",
"back_off",
"=",
"1",
",",
"raise_msg",
"=",
"''",
")",
":",
"if",
"back_off",
"<",
"1",
":",
"raise",
"ValueError",
"(",
"'back_off must be 1 or greater'",
")",
"tries",
"=",
"math",
".",
"flo... | Retries a function or method until it got True.
- ``delay`` sets the initial delay in seconds
- ``back_off`` sets the factor by which
- ``raise_msg`` if not '', it'll raise an Exception | [
"Retries",
"a",
"function",
"or",
"method",
"until",
"it",
"got",
"True",
"."
] | train | https://github.com/coghost/izen/blob/432db017f99dd2ba809e1ba1792145ab6510263d/izen/dec.py#L80-L117 |
coghost/izen | izen/dec.py | later | def later(periods=10.0, precision=2.0, offset=0.0, check_interval=0.1, only_run_once=True):
"""
**注意:会阻塞程序运行, 如果后台运行, 请放置于线程中**
这个会阻塞程序运行, 如果不是这个目的, 请确保待装饰程序以线程方式运行
* periods 是正常提供的参数, 如 10s, 则函数每10s 运行一次
* precision 精度,
* 如3s, 则 0~3s 内都可以触发运行
* 如果是0s, 则函数可在 ```sleep check_interva... | python | def later(periods=10.0, precision=2.0, offset=0.0, check_interval=0.1, only_run_once=True):
"""
**注意:会阻塞程序运行, 如果后台运行, 请放置于线程中**
这个会阻塞程序运行, 如果不是这个目的, 请确保待装饰程序以线程方式运行
* periods 是正常提供的参数, 如 10s, 则函数每10s 运行一次
* precision 精度,
* 如3s, 则 0~3s 内都可以触发运行
* 如果是0s, 则函数可在 ```sleep check_interva... | [
"def",
"later",
"(",
"periods",
"=",
"10.0",
",",
"precision",
"=",
"2.0",
",",
"offset",
"=",
"0.0",
",",
"check_interval",
"=",
"0.1",
",",
"only_run_once",
"=",
"True",
")",
":",
"def",
"dec_fn",
"(",
"fn",
")",
":",
"@",
"wraps",
"(",
"fn",
")"... | **注意:会阻塞程序运行, 如果后台运行, 请放置于线程中**
这个会阻塞程序运行, 如果不是这个目的, 请确保待装饰程序以线程方式运行
* periods 是正常提供的参数, 如 10s, 则函数每10s 运行一次
* precision 精度,
* 如3s, 则 0~3s 内都可以触发运行
* 如果是0s, 则函数可在 ```sleep check_interval``` 后, 一直运行
* offset 偏移
* 如果需要在 3s~6s 内运行, 则可设置 offset 为3, 这样到检测时间后, 会延迟 3s 运行
example... | [
"**",
"注意",
":",
"会阻塞程序运行",
"如果后台运行",
"请放置于线程中",
"**"
] | train | https://github.com/coghost/izen/blob/432db017f99dd2ba809e1ba1792145ab6510263d/izen/dec.py#L259-L329 |
coghost/izen | izen/dec.py | _async_raise | def _async_raise(tid, exctype):
"""
raises the exception, performs cleanup if needed
参考: https://www.oschina.net/question/172446_2159505
"""
tid = ctypes.c_long(tid)
if not inspect.isclass(exctype):
exctype = type(exctype)
res = ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, ctypes.... | python | def _async_raise(tid, exctype):
"""
raises the exception, performs cleanup if needed
参考: https://www.oschina.net/question/172446_2159505
"""
tid = ctypes.c_long(tid)
if not inspect.isclass(exctype):
exctype = type(exctype)
res = ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, ctypes.... | [
"def",
"_async_raise",
"(",
"tid",
",",
"exctype",
")",
":",
"tid",
"=",
"ctypes",
".",
"c_long",
"(",
"tid",
")",
"if",
"not",
"inspect",
".",
"isclass",
"(",
"exctype",
")",
":",
"exctype",
"=",
"type",
"(",
"exctype",
")",
"res",
"=",
"ctypes",
... | raises the exception, performs cleanup if needed
参考: https://www.oschina.net/question/172446_2159505 | [
"raises",
"the",
"exception",
"performs",
"cleanup",
"if",
"needed",
"参考",
":",
"https",
":",
"//",
"www",
".",
"oschina",
".",
"net",
"/",
"question",
"/",
"172446_2159505"
] | train | https://github.com/coghost/izen/blob/432db017f99dd2ba809e1ba1792145ab6510263d/izen/dec.py#L332-L348 |
coghost/izen | izen/dec.py | block_until_expired | def block_until_expired(timeout):
""" 阻塞当前程序运行, 直到超时
.. note: 会阻塞当前程序运行
- 如果 ``timeout大于0``, 则当作 ``计时阻塞器`` 来使用
.. code:: python
@run_until(0.1)
def s2():
m = 5
while m:
print('s2: ', m, now())
time.sleep(... | python | def block_until_expired(timeout):
""" 阻塞当前程序运行, 直到超时
.. note: 会阻塞当前程序运行
- 如果 ``timeout大于0``, 则当作 ``计时阻塞器`` 来使用
.. code:: python
@run_until(0.1)
def s2():
m = 5
while m:
print('s2: ', m, now())
time.sleep(... | [
"def",
"block_until_expired",
"(",
"timeout",
")",
":",
"if",
"not",
"callable",
"(",
"timeout",
")",
":",
"def",
"dec",
"(",
"fn",
")",
":",
"@",
"wraps",
"(",
"fn",
")",
"def",
"wrapper_",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"c... | 阻塞当前程序运行, 直到超时
.. note: 会阻塞当前程序运行
- 如果 ``timeout大于0``, 则当作 ``计时阻塞器`` 来使用
.. code:: python
@run_until(0.1)
def s2():
m = 5
while m:
print('s2: ', m, now())
time.sleep(1)
m -= 1
... | [
"阻塞当前程序运行",
"直到超时"
] | train | https://github.com/coghost/izen/blob/432db017f99dd2ba809e1ba1792145ab6510263d/izen/dec.py#L355-L413 |
coghost/izen | izen/dec.py | catch | def catch(do, my_exception=TypeError, hints='', do_raise=None, prt_tb=True):
"""
防止程序出现 exception后异常退出,
但是这里的异常捕获机制仅仅是为了防止程序退出, 无法做相应处理
可以支持有参数或者无参数模式
- ``do == True`` , 则启用捕获异常
- 无参数也启用 try-catch
.. code:: python
@catch
def fnc():
pass
- 在有... | python | def catch(do, my_exception=TypeError, hints='', do_raise=None, prt_tb=True):
"""
防止程序出现 exception后异常退出,
但是这里的异常捕获机制仅仅是为了防止程序退出, 无法做相应处理
可以支持有参数或者无参数模式
- ``do == True`` , 则启用捕获异常
- 无参数也启用 try-catch
.. code:: python
@catch
def fnc():
pass
- 在有... | [
"def",
"catch",
"(",
"do",
",",
"my_exception",
"=",
"TypeError",
",",
"hints",
"=",
"''",
",",
"do_raise",
"=",
"None",
",",
"prt_tb",
"=",
"True",
")",
":",
"if",
"not",
"hasattr",
"(",
"do",
",",
"'__call__'",
")",
":",
"def",
"dec",
"(",
"fn",
... | 防止程序出现 exception后异常退出,
但是这里的异常捕获机制仅仅是为了防止程序退出, 无法做相应处理
可以支持有参数或者无参数模式
- ``do == True`` , 则启用捕获异常
- 无参数也启用 try-catch
.. code:: python
@catch
def fnc():
pass
- 在有可能出错的函数前添加, 不要在最外层添加,
- 这个catch 会捕获从该函数开始的所有异常, 会隐藏下一级函数调用的错误.
- 但是如果在内层的函数也有捕获... | [
"防止程序出现",
"exception后异常退出",
"但是这里的异常捕获机制仅仅是为了防止程序退出",
"无法做相应处理",
"可以支持有参数或者无参数模式"
] | train | https://github.com/coghost/izen/blob/432db017f99dd2ba809e1ba1792145ab6510263d/izen/dec.py#L416-L496 |
coghost/izen | izen/dec.py | prt | def prt(show=False):
"""
通过 ``装饰器`` 打印函数 ``参数, 运行时间, 返回值`` 等信息
- 如果 ``prt(show==True)`` 打印函数信息,
- 否则, 不做任何处理
.. code:: python
@prt(True)
def say():
print 'say'
'''
hello, world
----------------------------------------------------------------
... | python | def prt(show=False):
"""
通过 ``装饰器`` 打印函数 ``参数, 运行时间, 返回值`` 等信息
- 如果 ``prt(show==True)`` 打印函数信息,
- 否则, 不做任何处理
.. code:: python
@prt(True)
def say():
print 'say'
'''
hello, world
----------------------------------------------------------------
... | [
"def",
"prt",
"(",
"show",
"=",
"False",
")",
":",
"def",
"dec",
"(",
"fn",
")",
":",
"@",
"wraps",
"(",
"fn",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"result",
"=",
"None",
"ts",
"=",
"time",
".",
"time",
... | 通过 ``装饰器`` 打印函数 ``参数, 运行时间, 返回值`` 等信息
- 如果 ``prt(show==True)`` 打印函数信息,
- 否则, 不做任何处理
.. code:: python
@prt(True)
def say():
print 'say'
'''
hello, world
----------------------------------------------------------------
function(say) :
... | [
"通过",
"装饰器",
"打印函数",
"参数",
"运行时间",
"返回值",
"等信息"
] | train | https://github.com/coghost/izen/blob/432db017f99dd2ba809e1ba1792145ab6510263d/izen/dec.py#L499-L562 |
drowse314-dev-ymat/xmlpumpkin | xmlpumpkin/__init__.py | parse_to_tree | def parse_to_tree(text):
"""Parse text using CaboCha, then return Tree instance."""
xml_text = cabocha.as_xml(text)
tree = Tree(xml_text)
return tree | python | def parse_to_tree(text):
"""Parse text using CaboCha, then return Tree instance."""
xml_text = cabocha.as_xml(text)
tree = Tree(xml_text)
return tree | [
"def",
"parse_to_tree",
"(",
"text",
")",
":",
"xml_text",
"=",
"cabocha",
".",
"as_xml",
"(",
"text",
")",
"tree",
"=",
"Tree",
"(",
"xml_text",
")",
"return",
"tree"
] | Parse text using CaboCha, then return Tree instance. | [
"Parse",
"text",
"using",
"CaboCha",
"then",
"return",
"Tree",
"instance",
"."
] | train | https://github.com/drowse314-dev-ymat/xmlpumpkin/blob/6ccf5c5408a741e5b4a29f0e47849435cb3a6556/xmlpumpkin/__init__.py#L11-L15 |
renkse/django-devtools | devtools/forms.py | AtLeastOneRequiredInlineFormSet.clean | def clean(self):
"""Check that at least one service has been entered."""
super(AtLeastOneRequiredInlineFormSet, self).clean()
if any(self.errors):
return
if not any(cleaned_data and not cleaned_data.get('DELETE', False) for cleaned_data in self.cleaned_data):
rais... | python | def clean(self):
"""Check that at least one service has been entered."""
super(AtLeastOneRequiredInlineFormSet, self).clean()
if any(self.errors):
return
if not any(cleaned_data and not cleaned_data.get('DELETE', False) for cleaned_data in self.cleaned_data):
rais... | [
"def",
"clean",
"(",
"self",
")",
":",
"super",
"(",
"AtLeastOneRequiredInlineFormSet",
",",
"self",
")",
".",
"clean",
"(",
")",
"if",
"any",
"(",
"self",
".",
"errors",
")",
":",
"return",
"if",
"not",
"any",
"(",
"cleaned_data",
"and",
"not",
"clean... | Check that at least one service has been entered. | [
"Check",
"that",
"at",
"least",
"one",
"service",
"has",
"been",
"entered",
"."
] | train | https://github.com/renkse/django-devtools/blob/7ae285365601ea76e0562d47afeb14f6386ae346/devtools/forms.py#L10-L16 |
ardydedase/pycouchbase | couchbase-python-cffi/couchbase_ffi/_libcouchbase.py | _stage2_bootstrap | def _stage2_bootstrap():
"""
This is the second bootstrap stage. It should be called
_immediately_ after importing this module the first time. The
reason behind this process is to allow this module to be inserted
as a replacement for 'couchbase._libcouchbase' while not loading
dependencies which... | python | def _stage2_bootstrap():
"""
This is the second bootstrap stage. It should be called
_immediately_ after importing this module the first time. The
reason behind this process is to allow this module to be inserted
as a replacement for 'couchbase._libcouchbase' while not loading
dependencies which... | [
"def",
"_stage2_bootstrap",
"(",
")",
":",
"from",
"couchbase_ffi",
".",
"result",
"import",
"(",
"Item",
",",
"Result",
",",
"ObserveInfo",
",",
"MultiResult",
",",
"ValueResult",
",",
"OperationResult",
",",
"HttpResult",
",",
"AsyncResult",
")",
"from",
"co... | This is the second bootstrap stage. It should be called
_immediately_ after importing this module the first time. The
reason behind this process is to allow this module to be inserted
as a replacement for 'couchbase._libcouchbase' while not loading
dependencies which depend on that name. The stage2 load... | [
"This",
"is",
"the",
"second",
"bootstrap",
"stage",
".",
"It",
"should",
"be",
"called",
"_immediately_",
"after",
"importing",
"this",
"module",
"the",
"first",
"time",
".",
"The",
"reason",
"behind",
"this",
"process",
"is",
"to",
"allow",
"this",
"module... | train | https://github.com/ardydedase/pycouchbase/blob/6f010b4d2ef41aead2366878d0cf0b1284c0db0e/couchbase-python-cffi/couchbase_ffi/_libcouchbase.py#L56-L99 |
kervi/kervi-core | kervi/displays/__init__.py | Display.add_page | def add_page(self, page, default = True):
r"""
Add a display page to the display.
:param page: Page to be added
:type display_id: ``DisplayPage``
:param default: True if this page should be shown upon initialization.
:type name: ``bool``
"""
... | python | def add_page(self, page, default = True):
r"""
Add a display page to the display.
:param page: Page to be added
:type display_id: ``DisplayPage``
:param default: True if this page should be shown upon initialization.
:type name: ``bool``
"""
... | [
"def",
"add_page",
"(",
"self",
",",
"page",
",",
"default",
"=",
"True",
")",
":",
"self",
".",
"_pages",
"[",
"page",
".",
"page_id",
"]",
"=",
"page",
"page",
".",
"_add_display",
"(",
"self",
")",
"if",
"default",
"or",
"not",
"self",
".",
"_ac... | r"""
Add a display page to the display.
:param page: Page to be added
:type display_id: ``DisplayPage``
:param default: True if this page should be shown upon initialization.
:type name: ``bool`` | [
"r",
"Add",
"a",
"display",
"page",
"to",
"the",
"display",
"."
] | train | https://github.com/kervi/kervi-core/blob/3c1e3c8a17a7b4d085d8a28b99180ff2a96b0e23/kervi/displays/__init__.py#L69-L83 |
kervi/kervi-core | kervi/displays/__init__.py | Display.activate_page | def activate_page(self, page_id):
r"""
Activates a display page. Content of the active page is shown in the display.
:param page_id: Id of page to activate
:type page_id: ``str``
"""
if page_id == "next":
page_keys = list(self._pages.keys())
key... | python | def activate_page(self, page_id):
r"""
Activates a display page. Content of the active page is shown in the display.
:param page_id: Id of page to activate
:type page_id: ``str``
"""
if page_id == "next":
page_keys = list(self._pages.keys())
key... | [
"def",
"activate_page",
"(",
"self",
",",
"page_id",
")",
":",
"if",
"page_id",
"==",
"\"next\"",
":",
"page_keys",
"=",
"list",
"(",
"self",
".",
"_pages",
".",
"keys",
"(",
")",
")",
"key_count",
"=",
"len",
"(",
"page_keys",
")",
"if",
"key_count",
... | r"""
Activates a display page. Content of the active page is shown in the display.
:param page_id: Id of page to activate
:type page_id: ``str`` | [
"r",
"Activates",
"a",
"display",
"page",
".",
"Content",
"of",
"the",
"active",
"page",
"is",
"shown",
"in",
"the",
"display",
"."
] | train | https://github.com/kervi/kervi-core/blob/3c1e3c8a17a7b4d085d8a28b99180ff2a96b0e23/kervi/displays/__init__.py#L108-L133 |
kervi/kervi-core | kervi/displays/__init__.py | Display._get_font | def _get_font(self, size=8, name="PressStart2P.ttf"):
"""
Returns a font that can be used by pil image functions.
This default font is "SourceSansVariable-Roman" that is available on all platforms.
"""
import kervi.vision as vision
from PIL import ImageFont
vision... | python | def _get_font(self, size=8, name="PressStart2P.ttf"):
"""
Returns a font that can be used by pil image functions.
This default font is "SourceSansVariable-Roman" that is available on all platforms.
"""
import kervi.vision as vision
from PIL import ImageFont
vision... | [
"def",
"_get_font",
"(",
"self",
",",
"size",
"=",
"8",
",",
"name",
"=",
"\"PressStart2P.ttf\"",
")",
":",
"import",
"kervi",
".",
"vision",
"as",
"vision",
"from",
"PIL",
"import",
"ImageFont",
"vision_path",
"=",
"os",
".",
"path",
".",
"dirname",
"("... | Returns a font that can be used by pil image functions.
This default font is "SourceSansVariable-Roman" that is available on all platforms. | [
"Returns",
"a",
"font",
"that",
"can",
"be",
"used",
"by",
"pil",
"image",
"functions",
".",
"This",
"default",
"font",
"is",
"SourceSansVariable",
"-",
"Roman",
"that",
"is",
"available",
"on",
"all",
"platforms",
"."
] | train | https://github.com/kervi/kervi-core/blob/3c1e3c8a17a7b4d085d8a28b99180ff2a96b0e23/kervi/displays/__init__.py#L188-L198 |
jmgilman/Neolib | neolib/pyamf/adapters/_decimal.py | convert_Decimal | def convert_Decimal(x, encoder):
"""
Called when an instance of U{decimal.Decimal<http://
docs.python.org/library/decimal.html#decimal-objects>} is about to be
encoded to an AMF stream.
@return: If the encoder is in 'strict' mode then C{x} will be converted to
a float. Otherwise an L{pyamf.... | python | def convert_Decimal(x, encoder):
"""
Called when an instance of U{decimal.Decimal<http://
docs.python.org/library/decimal.html#decimal-objects>} is about to be
encoded to an AMF stream.
@return: If the encoder is in 'strict' mode then C{x} will be converted to
a float. Otherwise an L{pyamf.... | [
"def",
"convert_Decimal",
"(",
"x",
",",
"encoder",
")",
":",
"if",
"encoder",
".",
"strict",
"is",
"False",
":",
"return",
"float",
"(",
"x",
")",
"raise",
"pyamf",
".",
"EncodeError",
"(",
"'Unable to encode decimal.Decimal instances as '",
"'there is no way to ... | Called when an instance of U{decimal.Decimal<http://
docs.python.org/library/decimal.html#decimal-objects>} is about to be
encoded to an AMF stream.
@return: If the encoder is in 'strict' mode then C{x} will be converted to
a float. Otherwise an L{pyamf.EncodeError} with a friendly message is
... | [
"Called",
"when",
"an",
"instance",
"of",
"U",
"{",
"decimal",
".",
"Decimal<http",
":",
"//",
"docs",
".",
"python",
".",
"org",
"/",
"library",
"/",
"decimal",
".",
"html#decimal",
"-",
"objects",
">",
"}",
"is",
"about",
"to",
"be",
"encoded",
"to",... | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/adapters/_decimal.py#L15-L30 |
johnwlockwood/stream_tap | example/tap_example.py | certain_kind_tap | def certain_kind_tap(data_items):
"""
:param data_items: A sequence of unicode strings
"""
fruit_spigot = Bucket(get_fruit)
metal_spigot = Bucket(get_metal)
items = stream_tap((fruit_spigot, metal_spigot), data_items)
# consume iterator.
for item in items:
print item
retur... | python | def certain_kind_tap(data_items):
"""
:param data_items: A sequence of unicode strings
"""
fruit_spigot = Bucket(get_fruit)
metal_spigot = Bucket(get_metal)
items = stream_tap((fruit_spigot, metal_spigot), data_items)
# consume iterator.
for item in items:
print item
retur... | [
"def",
"certain_kind_tap",
"(",
"data_items",
")",
":",
"fruit_spigot",
"=",
"Bucket",
"(",
"get_fruit",
")",
"metal_spigot",
"=",
"Bucket",
"(",
"get_metal",
")",
"items",
"=",
"stream_tap",
"(",
"(",
"fruit_spigot",
",",
"metal_spigot",
")",
",",
"data_items... | :param data_items: A sequence of unicode strings | [
":",
"param",
"data_items",
":",
"A",
"sequence",
"of",
"unicode",
"strings"
] | train | https://github.com/johnwlockwood/stream_tap/blob/068f6427c39202991a1db2be842b0fa43c6c5b91/example/tap_example.py#L26-L39 |
johnwlockwood/stream_tap | example/tap_example.py | run | def run():
"""
Run the composition of csv_file_consumer and information tap
with the csv files in the input directory, and collect
the results from each file and merge them together,
printing both kinds of results.
"""
data_items = [
[u"mushroom", u"fungus"],
[u"tomato", u"f... | python | def run():
"""
Run the composition of csv_file_consumer and information tap
with the csv files in the input directory, and collect
the results from each file and merge them together,
printing both kinds of results.
"""
data_items = [
[u"mushroom", u"fungus"],
[u"tomato", u"f... | [
"def",
"run",
"(",
")",
":",
"data_items",
"=",
"[",
"[",
"u\"mushroom\"",
",",
"u\"fungus\"",
"]",
",",
"[",
"u\"tomato\"",
",",
"u\"fruit\"",
"]",
",",
"[",
"u\"topaz\"",
",",
"u\"mineral\"",
"]",
",",
"[",
"u\"iron\"",
",",
"u\"metal\"",
"]",
",",
"... | Run the composition of csv_file_consumer and information tap
with the csv files in the input directory, and collect
the results from each file and merge them together,
printing both kinds of results. | [
"Run",
"the",
"composition",
"of",
"csv_file_consumer",
"and",
"information",
"tap",
"with",
"the",
"csv",
"files",
"in",
"the",
"input",
"directory",
"and",
"collect",
"the",
"results",
"from",
"each",
"file",
"and",
"merge",
"them",
"together",
"printing",
"... | train | https://github.com/johnwlockwood/stream_tap/blob/068f6427c39202991a1db2be842b0fa43c6c5b91/example/tap_example.py#L42-L78 |
edeposit/edeposit.amqp.harvester | src/edeposit/amqp/harvester/scrappers/ben_cz.py | _get_last_td | def _get_last_td(el):
"""
Return last <td> found in `el` DOM.
Args:
el (obj): :class:`dhtmlparser.HTMLElement` instance.
Returns:
obj: HTMLElement instance if found, or None if there are no <td> tags.
"""
if not el:
return None
if type(el) in [list, tuple, set]:
... | python | def _get_last_td(el):
"""
Return last <td> found in `el` DOM.
Args:
el (obj): :class:`dhtmlparser.HTMLElement` instance.
Returns:
obj: HTMLElement instance if found, or None if there are no <td> tags.
"""
if not el:
return None
if type(el) in [list, tuple, set]:
... | [
"def",
"_get_last_td",
"(",
"el",
")",
":",
"if",
"not",
"el",
":",
"return",
"None",
"if",
"type",
"(",
"el",
")",
"in",
"[",
"list",
",",
"tuple",
",",
"set",
"]",
":",
"el",
"=",
"el",
"[",
"0",
"]",
"last",
"=",
"el",
".",
"find",
"(",
... | Return last <td> found in `el` DOM.
Args:
el (obj): :class:`dhtmlparser.HTMLElement` instance.
Returns:
obj: HTMLElement instance if found, or None if there are no <td> tags. | [
"Return",
"last",
"<td",
">",
"found",
"in",
"el",
"DOM",
"."
] | train | https://github.com/edeposit/edeposit.amqp.harvester/blob/38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e/src/edeposit/amqp/harvester/scrappers/ben_cz.py#L32-L53 |
edeposit/edeposit.amqp.harvester | src/edeposit/amqp/harvester/scrappers/ben_cz.py | _get_td_or_none | def _get_td_or_none(details, ID):
"""
Get <tr> tag with given `ID` and return content of the last <td> tag from
<tr> root.
Args:
details (obj): :class:`dhtmlparser.HTMLElement` instance.
ID (str): id property of the <tr> tag.
Returns:
str: Content of the last <td> as strign... | python | def _get_td_or_none(details, ID):
"""
Get <tr> tag with given `ID` and return content of the last <td> tag from
<tr> root.
Args:
details (obj): :class:`dhtmlparser.HTMLElement` instance.
ID (str): id property of the <tr> tag.
Returns:
str: Content of the last <td> as strign... | [
"def",
"_get_td_or_none",
"(",
"details",
",",
"ID",
")",
":",
"content",
"=",
"details",
".",
"find",
"(",
"\"tr\"",
",",
"{",
"\"id\"",
":",
"ID",
"}",
")",
"content",
"=",
"_get_last_td",
"(",
"content",
")",
"# if content is None, return it",
"if",
"no... | Get <tr> tag with given `ID` and return content of the last <td> tag from
<tr> root.
Args:
details (obj): :class:`dhtmlparser.HTMLElement` instance.
ID (str): id property of the <tr> tag.
Returns:
str: Content of the last <td> as strign. | [
"Get",
"<tr",
">",
"tag",
"with",
"given",
"ID",
"and",
"return",
"content",
"of",
"the",
"last",
"<td",
">",
"tag",
"from",
"<tr",
">",
"root",
"."
] | train | https://github.com/edeposit/edeposit.amqp.harvester/blob/38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e/src/edeposit/amqp/harvester/scrappers/ben_cz.py#L56-L81 |
edeposit/edeposit.amqp.harvester | src/edeposit/amqp/harvester/scrappers/ben_cz.py | _parse_title | def _parse_title(dom, details):
"""
Parse title/name of the book.
Args:
dom (obj): HTMLElement containing whole HTML page.
details (obj): HTMLElement containing slice of the page with details.
Returns:
str: Book's title.
Raises:
AssertionError: If title not found.
... | python | def _parse_title(dom, details):
"""
Parse title/name of the book.
Args:
dom (obj): HTMLElement containing whole HTML page.
details (obj): HTMLElement containing slice of the page with details.
Returns:
str: Book's title.
Raises:
AssertionError: If title not found.
... | [
"def",
"_parse_title",
"(",
"dom",
",",
"details",
")",
":",
"title",
"=",
"details",
".",
"find",
"(",
"\"h1\"",
")",
"# if the header is missing, try to parse title from the <title> tag",
"if",
"not",
"title",
":",
"title",
"=",
"dom",
".",
"find",
"(",
"\"tit... | Parse title/name of the book.
Args:
dom (obj): HTMLElement containing whole HTML page.
details (obj): HTMLElement containing slice of the page with details.
Returns:
str: Book's title.
Raises:
AssertionError: If title not found. | [
"Parse",
"title",
"/",
"name",
"of",
"the",
"book",
"."
] | train | https://github.com/edeposit/edeposit.amqp.harvester/blob/38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e/src/edeposit/amqp/harvester/scrappers/ben_cz.py#L85-L108 |
edeposit/edeposit.amqp.harvester | src/edeposit/amqp/harvester/scrappers/ben_cz.py | _parse_authors | def _parse_authors(details):
"""
Parse authors of the book.
Args:
details (obj): HTMLElement containing slice of the page with details.
Returns:
list: List of :class:`structures.Author` objects. Blank if no author \
found.
"""
authors = details.find(
"tr",... | python | def _parse_authors(details):
"""
Parse authors of the book.
Args:
details (obj): HTMLElement containing slice of the page with details.
Returns:
list: List of :class:`structures.Author` objects. Blank if no author \
found.
"""
authors = details.find(
"tr",... | [
"def",
"_parse_authors",
"(",
"details",
")",
":",
"authors",
"=",
"details",
".",
"find",
"(",
"\"tr\"",
",",
"{",
"\"id\"",
":",
"\"ctl00_ContentPlaceHolder1_tblRowAutor\"",
"}",
")",
"if",
"not",
"authors",
":",
"return",
"[",
"]",
"# book with unspecified au... | Parse authors of the book.
Args:
details (obj): HTMLElement containing slice of the page with details.
Returns:
list: List of :class:`structures.Author` objects. Blank if no author \
found. | [
"Parse",
"authors",
"of",
"the",
"book",
"."
] | train | https://github.com/edeposit/edeposit.amqp.harvester/blob/38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e/src/edeposit/amqp/harvester/scrappers/ben_cz.py#L111-L140 |
edeposit/edeposit.amqp.harvester | src/edeposit/amqp/harvester/scrappers/ben_cz.py | _parse_publisher | def _parse_publisher(details):
"""
Parse publisher of the book.
Args:
details (obj): HTMLElement containing slice of the page with details.
Returns:
str/None: Publisher's name as string or None if not found.
"""
publisher = _get_td_or_none(
details,
"ctl00_Conte... | python | def _parse_publisher(details):
"""
Parse publisher of the book.
Args:
details (obj): HTMLElement containing slice of the page with details.
Returns:
str/None: Publisher's name as string or None if not found.
"""
publisher = _get_td_or_none(
details,
"ctl00_Conte... | [
"def",
"_parse_publisher",
"(",
"details",
")",
":",
"publisher",
"=",
"_get_td_or_none",
"(",
"details",
",",
"\"ctl00_ContentPlaceHolder1_tblRowNakladatel\"",
")",
"# publisher is not specified",
"if",
"not",
"publisher",
":",
"return",
"None",
"publisher",
"=",
"dhtm... | Parse publisher of the book.
Args:
details (obj): HTMLElement containing slice of the page with details.
Returns:
str/None: Publisher's name as string or None if not found. | [
"Parse",
"publisher",
"of",
"the",
"book",
"."
] | train | https://github.com/edeposit/edeposit.amqp.harvester/blob/38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e/src/edeposit/amqp/harvester/scrappers/ben_cz.py#L143-L168 |
edeposit/edeposit.amqp.harvester | src/edeposit/amqp/harvester/scrappers/ben_cz.py | _parse_pages_binding | def _parse_pages_binding(details):
"""
Parse number of pages and binding of the book.
Args:
details (obj): HTMLElement containing slice of the page with details.
Returns:
(pages, binding): Tuple with two string or two None.
"""
pages = _get_td_or_none(
details,
... | python | def _parse_pages_binding(details):
"""
Parse number of pages and binding of the book.
Args:
details (obj): HTMLElement containing slice of the page with details.
Returns:
(pages, binding): Tuple with two string or two None.
"""
pages = _get_td_or_none(
details,
... | [
"def",
"_parse_pages_binding",
"(",
"details",
")",
":",
"pages",
"=",
"_get_td_or_none",
"(",
"details",
",",
"\"ctl00_ContentPlaceHolder1_tblRowRozsahVazba\"",
")",
"if",
"not",
"pages",
":",
"return",
"None",
",",
"None",
"binding",
"=",
"None",
"# binding info a... | Parse number of pages and binding of the book.
Args:
details (obj): HTMLElement containing slice of the page with details.
Returns:
(pages, binding): Tuple with two string or two None. | [
"Parse",
"number",
"of",
"pages",
"and",
"binding",
"of",
"the",
"book",
"."
] | train | https://github.com/edeposit/edeposit.amqp.harvester/blob/38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e/src/edeposit/amqp/harvester/scrappers/ben_cz.py#L189-L215 |
edeposit/edeposit.amqp.harvester | src/edeposit/amqp/harvester/scrappers/ben_cz.py | _parse_ISBN_EAN | def _parse_ISBN_EAN(details):
"""
Parse ISBN and EAN.
Args:
details (obj): HTMLElement containing slice of the page with details.
Returns:
(ISBN, EAN): Tuple with two string or two None.
"""
isbn_ean = _get_td_or_none(
details,
"ctl00_ContentPlaceHolder1_tblRowI... | python | def _parse_ISBN_EAN(details):
"""
Parse ISBN and EAN.
Args:
details (obj): HTMLElement containing slice of the page with details.
Returns:
(ISBN, EAN): Tuple with two string or two None.
"""
isbn_ean = _get_td_or_none(
details,
"ctl00_ContentPlaceHolder1_tblRowI... | [
"def",
"_parse_ISBN_EAN",
"(",
"details",
")",
":",
"isbn_ean",
"=",
"_get_td_or_none",
"(",
"details",
",",
"\"ctl00_ContentPlaceHolder1_tblRowIsbnEan\"",
")",
"if",
"not",
"isbn_ean",
":",
"return",
"None",
",",
"None",
"ean",
"=",
"None",
"isbn",
"=",
"None",... | Parse ISBN and EAN.
Args:
details (obj): HTMLElement containing slice of the page with details.
Returns:
(ISBN, EAN): Tuple with two string or two None. | [
"Parse",
"ISBN",
"and",
"EAN",
"."
] | train | https://github.com/edeposit/edeposit.amqp.harvester/blob/38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e/src/edeposit/amqp/harvester/scrappers/ben_cz.py#L218-L248 |
edeposit/edeposit.amqp.harvester | src/edeposit/amqp/harvester/scrappers/ben_cz.py | _parse_description | def _parse_description(details):
"""
Parse description of the book.
Args:
details (obj): HTMLElement containing slice of the page with details.
Returns:
str/None: Details as string with currency or None if not found.
"""
description = details.find("div", {"class": "detailPopis"... | python | def _parse_description(details):
"""
Parse description of the book.
Args:
details (obj): HTMLElement containing slice of the page with details.
Returns:
str/None: Details as string with currency or None if not found.
"""
description = details.find("div", {"class": "detailPopis"... | [
"def",
"_parse_description",
"(",
"details",
")",
":",
"description",
"=",
"details",
".",
"find",
"(",
"\"div\"",
",",
"{",
"\"class\"",
":",
"\"detailPopis\"",
"}",
")",
"# description not found",
"if",
"not",
"description",
":",
"return",
"None",
"# remove li... | Parse description of the book.
Args:
details (obj): HTMLElement containing slice of the page with details.
Returns:
str/None: Details as string with currency or None if not found. | [
"Parse",
"description",
"of",
"the",
"book",
"."
] | train | https://github.com/edeposit/edeposit.amqp.harvester/blob/38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e/src/edeposit/amqp/harvester/scrappers/ben_cz.py#L269-L302 |
edeposit/edeposit.amqp.harvester | src/edeposit/amqp/harvester/scrappers/ben_cz.py | _process_book | def _process_book(book_url):
"""
Parse available informations about book from the book details page.
Args:
book_url (str): Absolute URL of the book.
Returns:
obj: :class:`structures.Publication` instance with book details.
"""
data = DOWNER.download(book_url)
dom = dhtmlpar... | python | def _process_book(book_url):
"""
Parse available informations about book from the book details page.
Args:
book_url (str): Absolute URL of the book.
Returns:
obj: :class:`structures.Publication` instance with book details.
"""
data = DOWNER.download(book_url)
dom = dhtmlpar... | [
"def",
"_process_book",
"(",
"book_url",
")",
":",
"data",
"=",
"DOWNER",
".",
"download",
"(",
"book_url",
")",
"dom",
"=",
"dhtmlparser",
".",
"parseString",
"(",
"data",
")",
"details_tags",
"=",
"dom",
".",
"find",
"(",
"\"div\"",
",",
"{",
"\"id\"",... | Parse available informations about book from the book details page.
Args:
book_url (str): Absolute URL of the book.
Returns:
obj: :class:`structures.Publication` instance with book details. | [
"Parse",
"available",
"informations",
"about",
"book",
"from",
"the",
"book",
"details",
"page",
"."
] | train | https://github.com/edeposit/edeposit.amqp.harvester/blob/38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e/src/edeposit/amqp/harvester/scrappers/ben_cz.py#L305-L347 |
edeposit/edeposit.amqp.harvester | src/edeposit/amqp/harvester/scrappers/ben_cz.py | get_publications | def get_publications():
"""
Get list of publication offered by ben.cz.
Returns:
list: List of :class:`structures.Publication` objects.
"""
data = DOWNER.download(URL)
dom = dhtmlparser.parseString(data)
book_list = dom.find("div", {"class": "seznamKniha"})
assert book_list, "C... | python | def get_publications():
"""
Get list of publication offered by ben.cz.
Returns:
list: List of :class:`structures.Publication` objects.
"""
data = DOWNER.download(URL)
dom = dhtmlparser.parseString(data)
book_list = dom.find("div", {"class": "seznamKniha"})
assert book_list, "C... | [
"def",
"get_publications",
"(",
")",
":",
"data",
"=",
"DOWNER",
".",
"download",
"(",
"URL",
")",
"dom",
"=",
"dhtmlparser",
".",
"parseString",
"(",
"data",
")",
"book_list",
"=",
"dom",
".",
"find",
"(",
"\"div\"",
",",
"{",
"\"class\"",
":",
"\"sez... | Get list of publication offered by ben.cz.
Returns:
list: List of :class:`structures.Publication` objects. | [
"Get",
"list",
"of",
"publication",
"offered",
"by",
"ben",
".",
"cz",
"."
] | train | https://github.com/edeposit/edeposit.amqp.harvester/blob/38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e/src/edeposit/amqp/harvester/scrappers/ben_cz.py#L350-L377 |
kervi/kervi-core | kervi/core/utility/settings.py | Settings.store_value | def store_value(self, name, value):
"""Store a value to DB"""
self.spine.send_command("storeSetting", self.group, name, value) | python | def store_value(self, name, value):
"""Store a value to DB"""
self.spine.send_command("storeSetting", self.group, name, value) | [
"def",
"store_value",
"(",
"self",
",",
"name",
",",
"value",
")",
":",
"self",
".",
"spine",
".",
"send_command",
"(",
"\"storeSetting\"",
",",
"self",
".",
"group",
",",
"name",
",",
"value",
")"
] | Store a value to DB | [
"Store",
"a",
"value",
"to",
"DB"
] | train | https://github.com/kervi/kervi-core/blob/3c1e3c8a17a7b4d085d8a28b99180ff2a96b0e23/kervi/core/utility/settings.py#L22-L24 |
kervi/kervi-core | kervi/core/utility/settings.py | Settings.retrieve_value | def retrieve_value(self, name, default_value=None):
"""Retrieve a value from DB"""
value = self.spine.send_query("retrieveSetting", self.group, name, processes=["kervi-main"])
if value is None:
return default_value
elif isinstance(value, list) and len(value) == 0:
... | python | def retrieve_value(self, name, default_value=None):
"""Retrieve a value from DB"""
value = self.spine.send_query("retrieveSetting", self.group, name, processes=["kervi-main"])
if value is None:
return default_value
elif isinstance(value, list) and len(value) == 0:
... | [
"def",
"retrieve_value",
"(",
"self",
",",
"name",
",",
"default_value",
"=",
"None",
")",
":",
"value",
"=",
"self",
".",
"spine",
".",
"send_query",
"(",
"\"retrieveSetting\"",
",",
"self",
".",
"group",
",",
"name",
",",
"processes",
"=",
"[",
"\"kerv... | Retrieve a value from DB | [
"Retrieve",
"a",
"value",
"from",
"DB"
] | train | https://github.com/kervi/kervi-core/blob/3c1e3c8a17a7b4d085d8a28b99180ff2a96b0e23/kervi/core/utility/settings.py#L27-L39 |
cogniteev/docido-python-sdk | docido_sdk/toolbox/rate_limits.py | truncated_exponential_backoff | def truncated_exponential_backoff(
slot_delay, collision=0, max_collisions=5,
op=operator.mul, in_range=True):
"""Truncated Exponential Backoff
see https://en.wikipedia.org/wiki/Exponential_backoff
"""
truncated_collision = collision % max_collisions
if in_range:
slots = random.randi... | python | def truncated_exponential_backoff(
slot_delay, collision=0, max_collisions=5,
op=operator.mul, in_range=True):
"""Truncated Exponential Backoff
see https://en.wikipedia.org/wiki/Exponential_backoff
"""
truncated_collision = collision % max_collisions
if in_range:
slots = random.randi... | [
"def",
"truncated_exponential_backoff",
"(",
"slot_delay",
",",
"collision",
"=",
"0",
",",
"max_collisions",
"=",
"5",
",",
"op",
"=",
"operator",
".",
"mul",
",",
"in_range",
"=",
"True",
")",
":",
"truncated_collision",
"=",
"collision",
"%",
"max_collision... | Truncated Exponential Backoff
see https://en.wikipedia.org/wiki/Exponential_backoff | [
"Truncated",
"Exponential",
"Backoff",
"see",
"https",
":",
"//",
"en",
".",
"wikipedia",
".",
"org",
"/",
"wiki",
"/",
"Exponential_backoff"
] | train | https://github.com/cogniteev/docido-python-sdk/blob/58ecb6c6f5757fd40c0601657ab18368da7ddf33/docido_sdk/toolbox/rate_limits.py#L25-L36 |
cogniteev/docido-python-sdk | docido_sdk/toolbox/rate_limits.py | teb_retry | def teb_retry(exc=RequestException,
when=dict(response__status_code=429),
delay='response__headers__Retry-After',
max_collisions=MAX_COLLISIONS,
default_retry=DEFAULT_RETRY):
"""Decorator catching rate limits exceed events during a crawl task.
It retries t... | python | def teb_retry(exc=RequestException,
when=dict(response__status_code=429),
delay='response__headers__Retry-After',
max_collisions=MAX_COLLISIONS,
default_retry=DEFAULT_RETRY):
"""Decorator catching rate limits exceed events during a crawl task.
It retries t... | [
"def",
"teb_retry",
"(",
"exc",
"=",
"RequestException",
",",
"when",
"=",
"dict",
"(",
"response__status_code",
"=",
"429",
")",
",",
"delay",
"=",
"'response__headers__Retry-After'",
",",
"max_collisions",
"=",
"MAX_COLLISIONS",
",",
"default_retry",
"=",
"DEFAU... | Decorator catching rate limits exceed events during a crawl task.
It retries the task later on, following a truncated exponential backoff. | [
"Decorator",
"catching",
"rate",
"limits",
"exceed",
"events",
"during",
"a",
"crawl",
"task",
".",
"It",
"retries",
"the",
"task",
"later",
"on",
"following",
"a",
"truncated",
"exponential",
"backoff",
"."
] | train | https://github.com/cogniteev/docido-python-sdk/blob/58ecb6c6f5757fd40c0601657ab18368da7ddf33/docido_sdk/toolbox/rate_limits.py#L39-L71 |
cogniteev/docido-python-sdk | docido_sdk/toolbox/rate_limits.py | RLPersistence.uri | def uri(self, context=None):
"""
:param dict context:
keys that were missing in the static context given in
constructor to resolve the butcket name.
"""
if context is None:
context = self.context
else:
ctx = copy.deepcopy(self.context)
... | python | def uri(self, context=None):
"""
:param dict context:
keys that were missing in the static context given in
constructor to resolve the butcket name.
"""
if context is None:
context = self.context
else:
ctx = copy.deepcopy(self.context)
... | [
"def",
"uri",
"(",
"self",
",",
"context",
"=",
"None",
")",
":",
"if",
"context",
"is",
"None",
":",
"context",
"=",
"self",
".",
"context",
"else",
":",
"ctx",
"=",
"copy",
".",
"deepcopy",
"(",
"self",
".",
"context",
")",
"ctx",
".",
"update",
... | :param dict context:
keys that were missing in the static context given in
constructor to resolve the butcket name. | [
":",
"param",
"dict",
"context",
":",
"keys",
"that",
"were",
"missing",
"in",
"the",
"static",
"context",
"given",
"in",
"constructor",
"to",
"resolve",
"the",
"butcket",
"name",
"."
] | train | https://github.com/cogniteev/docido-python-sdk/blob/58ecb6c6f5757fd40c0601657ab18368da7ddf33/docido_sdk/toolbox/rate_limits.py#L102-L114 |
cogniteev/docido-python-sdk | docido_sdk/toolbox/rate_limits.py | RateLimiter.get_configs | def get_configs(cls):
"""Get rate limiters configuration
specified at application level
:rtype: dict of configurations
"""
import docido_sdk.config
http_config = docido_sdk.config.get('http') or {}
session_config = http_config.get('session') or {}
rate_li... | python | def get_configs(cls):
"""Get rate limiters configuration
specified at application level
:rtype: dict of configurations
"""
import docido_sdk.config
http_config = docido_sdk.config.get('http') or {}
session_config = http_config.get('session') or {}
rate_li... | [
"def",
"get_configs",
"(",
"cls",
")",
":",
"import",
"docido_sdk",
".",
"config",
"http_config",
"=",
"docido_sdk",
".",
"config",
".",
"get",
"(",
"'http'",
")",
"or",
"{",
"}",
"session_config",
"=",
"http_config",
".",
"get",
"(",
"'session'",
")",
"... | Get rate limiters configuration
specified at application level
:rtype: dict of configurations | [
"Get",
"rate",
"limiters",
"configuration",
"specified",
"at",
"application",
"level"
] | train | https://github.com/cogniteev/docido-python-sdk/blob/58ecb6c6f5757fd40c0601657ab18368da7ddf33/docido_sdk/toolbox/rate_limits.py#L247-L257 |
cogniteev/docido-python-sdk | docido_sdk/toolbox/rate_limits.py | RateLimiter.get_config | def get_config(cls, service, config=None):
"""Get get configuration of the specified rate limiter
:param str service:
rate limiter name
:param config:
optional global rate limiters configuration.
If not specified, then use rate limiters configuration
spe... | python | def get_config(cls, service, config=None):
"""Get get configuration of the specified rate limiter
:param str service:
rate limiter name
:param config:
optional global rate limiters configuration.
If not specified, then use rate limiters configuration
spe... | [
"def",
"get_config",
"(",
"cls",
",",
"service",
",",
"config",
"=",
"None",
")",
":",
"config",
"=",
"config",
"or",
"cls",
".",
"get_configs",
"(",
")",
"return",
"config",
"[",
"service",
"]"
] | Get get configuration of the specified rate limiter
:param str service:
rate limiter name
:param config:
optional global rate limiters configuration.
If not specified, then use rate limiters configuration
specified at application level | [
"Get",
"get",
"configuration",
"of",
"the",
"specified",
"rate",
"limiter"
] | train | https://github.com/cogniteev/docido-python-sdk/blob/58ecb6c6f5757fd40c0601657ab18368da7ddf33/docido_sdk/toolbox/rate_limits.py#L260-L272 |
cogniteev/docido-python-sdk | docido_sdk/toolbox/rate_limits.py | RateLimiter.get | def get(cls, service, config=None, persistence_kwargs=None, **context):
"""Load a rate-limiter from configuration
:param str service:
rate limiter name to retrieve
:param dict config:
alternate configuration object to use. If `None`, then use the global
application... | python | def get(cls, service, config=None, persistence_kwargs=None, **context):
"""Load a rate-limiter from configuration
:param str service:
rate limiter name to retrieve
:param dict config:
alternate configuration object to use. If `None`, then use the global
application... | [
"def",
"get",
"(",
"cls",
",",
"service",
",",
"config",
"=",
"None",
",",
"persistence_kwargs",
"=",
"None",
",",
"*",
"*",
"context",
")",
":",
"rl_config",
"=",
"cls",
".",
"get_config",
"(",
"service",
",",
"config",
")",
"context",
".",
"update",
... | Load a rate-limiter from configuration
:param str service:
rate limiter name to retrieve
:param dict config:
alternate configuration object to use. If `None`, then use the global
application configuration
:context:
Uniquely describe the consumed resource.... | [
"Load",
"a",
"rate",
"-",
"limiter",
"from",
"configuration"
] | train | https://github.com/cogniteev/docido-python-sdk/blob/58ecb6c6f5757fd40c0601657ab18368da7ddf33/docido_sdk/toolbox/rate_limits.py#L275-L302 |
bschollnick/semantic_url | semantic_url/__init__.py | norm_page_cnt | def norm_page_cnt(page, max_number=None):
"""
Normalize a integer (page).
* Ensure that it is greater than Zero, and is not None.
- If less than 1, or None, set it to 1
* if max_number is None, then do not check for max_number
* if greater than max_number, reset it to be max_number
... | python | def norm_page_cnt(page, max_number=None):
"""
Normalize a integer (page).
* Ensure that it is greater than Zero, and is not None.
- If less than 1, or None, set it to 1
* if max_number is None, then do not check for max_number
* if greater than max_number, reset it to be max_number
... | [
"def",
"norm_page_cnt",
"(",
"page",
",",
"max_number",
"=",
"None",
")",
":",
"if",
"page",
"==",
"None",
"or",
"page",
"<",
"1",
":",
"page",
"=",
"1",
"if",
"max_number",
"!=",
"None",
":",
"if",
"page",
">",
"max_number",
":",
"page",
"=",
"max... | Normalize a integer (page).
* Ensure that it is greater than Zero, and is not None.
- If less than 1, or None, set it to 1
* if max_number is None, then do not check for max_number
* if greater than max_number, reset it to be max_number | [
"Normalize",
"a",
"integer",
"(",
"page",
")",
"."
] | train | https://github.com/bschollnick/semantic_url/blob/3c9b9e24354c0d4c5a2ce82006e610c5980395ad/semantic_url/__init__.py#L60-L76 |
bschollnick/semantic_url | semantic_url/__init__.py | semantic_url.pi_to_number | def pi_to_number(self, page=1, item=1):
"""
Convert subpage & subitem to a integer
* if page == 1, then return 0, since the item count is the true # of items
* if page == 2, then return, page-1 * items_per_page, since we are
returning the # of items on a full page.
Args:
* None
... | python | def pi_to_number(self, page=1, item=1):
"""
Convert subpage & subitem to a integer
* if page == 1, then return 0, since the item count is the true # of items
* if page == 2, then return, page-1 * items_per_page, since we are
returning the # of items on a full page.
Args:
* None
... | [
"def",
"pi_to_number",
"(",
"self",
",",
"page",
"=",
"1",
",",
"item",
"=",
"1",
")",
":",
"if",
"page",
">",
"1",
":",
"return",
"(",
"(",
"page",
"-",
"1",
")",
"*",
"self",
".",
"page_items",
")",
"+",
"item",
"else",
":",
"return",
"0",
... | Convert subpage & subitem to a integer
* if page == 1, then return 0, since the item count is the true # of items
* if page == 2, then return, page-1 * items_per_page, since we are
returning the # of items on a full page.
Args:
* None
Returns:
* Integer - Which represents the nu... | [
"Convert",
"subpage",
"&",
"subitem",
"to",
"a",
"integer"
] | train | https://github.com/bschollnick/semantic_url/blob/3c9b9e24354c0d4c5a2ce82006e610c5980395ad/semantic_url/__init__.py#L126-L143 |
bschollnick/semantic_url | semantic_url/__init__.py | semantic_url.sub_pi_to_number | def sub_pi_to_number(self, subpage=1, subitem=1):
"""
Convert subpage & subitem to a integer
* if page == 1, then return 0, since the item count is the true # of items
* if page == 2, then return, page-1 * items_per_page, since we are
returning the # of items on a full page.
Args:
... | python | def sub_pi_to_number(self, subpage=1, subitem=1):
"""
Convert subpage & subitem to a integer
* if page == 1, then return 0, since the item count is the true # of items
* if page == 2, then return, page-1 * items_per_page, since we are
returning the # of items on a full page.
Args:
... | [
"def",
"sub_pi_to_number",
"(",
"self",
",",
"subpage",
"=",
"1",
",",
"subitem",
"=",
"1",
")",
":",
"if",
"subitem",
"==",
"None",
":",
"subitem",
"=",
"0",
"if",
"subpage",
"==",
"None",
":",
"return",
"0",
"else",
":",
"if",
"subpage",
">",
"1"... | Convert subpage & subitem to a integer
* if page == 1, then return 0, since the item count is the true # of items
* if page == 2, then return, page-1 * items_per_page, since we are
returning the # of items on a full page.
Args:
* None
Returns:
* Integer - Which represents the nu... | [
"Convert",
"subpage",
"&",
"subitem",
"to",
"a",
"integer"
] | train | https://github.com/bschollnick/semantic_url/blob/3c9b9e24354c0d4c5a2ce82006e610c5980395ad/semantic_url/__init__.py#L145-L168 |
bschollnick/semantic_url | semantic_url/__init__.py | semantic_url.current_spi_to_number | def current_spi_to_number(self):
"""
Convert subpage & subitem to a integer
* if page == 1, then return 0, since the item count is the true # of items
* if page == 2, then return, page-1 * items_per_page, since we are
returning the # of items on a full page.
Args:
* None
Ret... | python | def current_spi_to_number(self):
"""
Convert subpage & subitem to a integer
* if page == 1, then return 0, since the item count is the true # of items
* if page == 2, then return, page-1 * items_per_page, since we are
returning the # of items on a full page.
Args:
* None
Ret... | [
"def",
"current_spi_to_number",
"(",
"self",
")",
":",
"if",
"self",
".",
"slots",
"[",
"'subpage'",
"]",
"==",
"None",
":",
"return",
"self",
".",
"sub_pi_to_number",
"(",
"0",
",",
"0",
")",
"else",
":",
"return",
"self",
".",
"sub_pi_to_number",
"(",
... | Convert subpage & subitem to a integer
* if page == 1, then return 0, since the item count is the true # of items
* if page == 2, then return, page-1 * items_per_page, since we are
returning the # of items on a full page.
Args:
* None
Returns:
* Integer - Which represents the nu... | [
"Convert",
"subpage",
"&",
"subitem",
"to",
"a",
"integer"
] | train | https://github.com/bschollnick/semantic_url/blob/3c9b9e24354c0d4c5a2ce82006e610c5980395ad/semantic_url/__init__.py#L170-L188 |
bschollnick/semantic_url | semantic_url/__init__.py | semantic_url.change_page | def change_page(self, offset=None, max_page_count=None, nom=True):
"""
Args:
* offset - Integer - The positive / negative change to apply
to the page.
* max_page_count - The maximum number of pages available.
* nom - None on Max or Min - If max number of pages reached,
... | python | def change_page(self, offset=None, max_page_count=None, nom=True):
"""
Args:
* offset - Integer - The positive / negative change to apply
to the page.
* max_page_count - The maximum number of pages available.
* nom - None on Max or Min - If max number of pages reached,
... | [
"def",
"change_page",
"(",
"self",
",",
"offset",
"=",
"None",
",",
"max_page_count",
"=",
"None",
",",
"nom",
"=",
"True",
")",
":",
"if",
"offset",
"==",
"None",
":",
"return",
"if",
"self",
".",
"slots",
"[",
"'page'",
"]",
"==",
"None",
":",
"s... | Args:
* offset - Integer - The positive / negative change to apply
to the page.
* max_page_count - The maximum number of pages available.
* nom - None on Max or Min - If max number of pages reached,
return none instead of forcing back into range.
Returns:
Boolean... | [
"Args",
":",
"*",
"offset",
"-",
"Integer",
"-",
"The",
"positive",
"/",
"negative",
"change",
"to",
"apply",
"to",
"the",
"page",
".",
"*",
"max_page_count",
"-",
"The",
"maximum",
"number",
"of",
"pages",
"available",
".",
"*",
"nom",
"-",
"None",
"o... | train | https://github.com/bschollnick/semantic_url/blob/3c9b9e24354c0d4c5a2ce82006e610c5980395ad/semantic_url/__init__.py#L269-L295 |
bschollnick/semantic_url | semantic_url/__init__.py | semantic_url.change_subpage | def change_subpage(self, offset=None, max_page_count=None, nom=True):
"""
Args:
* offset - Integer - The positive / negative change to apply
to the page.
* max_page_count - The maximum number of pages available.
* nom - None on Max or Min - If max number of pages reached,
... | python | def change_subpage(self, offset=None, max_page_count=None, nom=True):
"""
Args:
* offset - Integer - The positive / negative change to apply
to the page.
* max_page_count - The maximum number of pages available.
* nom - None on Max or Min - If max number of pages reached,
... | [
"def",
"change_subpage",
"(",
"self",
",",
"offset",
"=",
"None",
",",
"max_page_count",
"=",
"None",
",",
"nom",
"=",
"True",
")",
":",
"if",
"offset",
"==",
"None",
":",
"return",
"if",
"self",
".",
"slots",
"[",
"'subpage'",
"]",
"==",
"None",
":"... | Args:
* offset - Integer - The positive / negative change to apply
to the page.
* max_page_count - The maximum number of pages available.
* nom - None on Max or Min - If max number of pages reached,
return none instead of forcing back into range.
Returns:
Boolean... | [
"Args",
":",
"*",
"offset",
"-",
"Integer",
"-",
"The",
"positive",
"/",
"negative",
"change",
"to",
"apply",
"to",
"the",
"page",
".",
"*",
"max_page_count",
"-",
"The",
"maximum",
"number",
"of",
"pages",
"available",
".",
"*",
"nom",
"-",
"None",
"o... | train | https://github.com/bschollnick/semantic_url/blob/3c9b9e24354c0d4c5a2ce82006e610c5980395ad/semantic_url/__init__.py#L297-L324 |
bschollnick/semantic_url | semantic_url/__init__.py | semantic_url.change_item | def change_item(self, offset=None, max_item_count=None, nom=True):
"""
Args:
* offset - Integer - The positive / negative change to apply
to the item.
* max_item_count - The maximum number of items available.
* nom - None on Max or Min - If max or min number of itemsreached... | python | def change_item(self, offset=None, max_item_count=None, nom=True):
"""
Args:
* offset - Integer - The positive / negative change to apply
to the item.
* max_item_count - The maximum number of items available.
* nom - None on Max or Min - If max or min number of itemsreached... | [
"def",
"change_item",
"(",
"self",
",",
"offset",
"=",
"None",
",",
"max_item_count",
"=",
"None",
",",
"nom",
"=",
"True",
")",
":",
"if",
"offset",
"==",
"None",
":",
"return",
"if",
"self",
".",
"slots",
"[",
"'item'",
"]",
"==",
"None",
":",
"s... | Args:
* offset - Integer - The positive / negative change to apply
to the item.
* max_item_count - The maximum number of items available.
* nom - None on Max or Min - If max or min number of itemsreached,
return none instead of forcing back into range.
Returns:
B... | [
"Args",
":",
"*",
"offset",
"-",
"Integer",
"-",
"The",
"positive",
"/",
"negative",
"change",
"to",
"apply",
"to",
"the",
"item",
".",
"*",
"max_item_count",
"-",
"The",
"maximum",
"number",
"of",
"items",
"available",
".",
"*",
"nom",
"-",
"None",
"o... | train | https://github.com/bschollnick/semantic_url/blob/3c9b9e24354c0d4c5a2ce82006e610c5980395ad/semantic_url/__init__.py#L326-L361 |
bschollnick/semantic_url | semantic_url/__init__.py | semantic_url.change_subitem | def change_subitem(self, offset=None, max_item_count=None, nom=True):
"""
Args:
* offset - Integer - The positive / negative change to apply
to the item.
* max_item_count - The maximum number of items available.
* nom - None on Max or Min - If max or min number of itemsreac... | python | def change_subitem(self, offset=None, max_item_count=None, nom=True):
"""
Args:
* offset - Integer - The positive / negative change to apply
to the item.
* max_item_count - The maximum number of items available.
* nom - None on Max or Min - If max or min number of itemsreac... | [
"def",
"change_subitem",
"(",
"self",
",",
"offset",
"=",
"None",
",",
"max_item_count",
"=",
"None",
",",
"nom",
"=",
"True",
")",
":",
"if",
"offset",
"==",
"None",
":",
"return",
"if",
"self",
".",
"slots",
"[",
"'subitem'",
"]",
"==",
"None",
":"... | Args:
* offset - Integer - The positive / negative change to apply
to the item.
* max_item_count - The maximum number of items available.
* nom - None on Max or Min - If max or min number of itemsreached,
return none instead of forcing back into range.
Returns:
B... | [
"Args",
":",
"*",
"offset",
"-",
"Integer",
"-",
"The",
"positive",
"/",
"negative",
"change",
"to",
"apply",
"to",
"the",
"item",
".",
"*",
"max_item_count",
"-",
"The",
"maximum",
"number",
"of",
"items",
"available",
".",
"*",
"nom",
"-",
"None",
"o... | train | https://github.com/bschollnick/semantic_url/blob/3c9b9e24354c0d4c5a2ce82006e610c5980395ad/semantic_url/__init__.py#L363-L398 |
bschollnick/semantic_url | semantic_url/__init__.py | semantic_url.return_current_uri_page_only | def return_current_uri_page_only(self):
"""
Args:
* None
Returns:
String - Returns the full postpath & semantic components
*NOTE* may not contain the server & port numbers. That depends on
what was provided to the parser.
"""
uri = post... | python | def return_current_uri_page_only(self):
"""
Args:
* None
Returns:
String - Returns the full postpath & semantic components
*NOTE* may not contain the server & port numbers. That depends on
what was provided to the parser.
"""
uri = post... | [
"def",
"return_current_uri_page_only",
"(",
"self",
")",
":",
"uri",
"=",
"post_slash",
"(",
"\"%s%s\"",
"%",
"(",
"post_slash",
"(",
"self",
".",
"current_dir",
"(",
")",
")",
",",
"self",
".",
"slots",
"[",
"'page'",
"]",
")",
")",
"return",
"uri"
] | Args:
* None
Returns:
String - Returns the full postpath & semantic components
*NOTE* may not contain the server & port numbers. That depends on
what was provided to the parser. | [
"Args",
":",
"*",
"None"
] | train | https://github.com/bschollnick/semantic_url/blob/3c9b9e24354c0d4c5a2ce82006e610c5980395ad/semantic_url/__init__.py#L400-L414 |
bschollnick/semantic_url | semantic_url/__init__.py | semantic_url.return_current_uri_subpage | def return_current_uri_subpage(self):
"""
Args:
* None
Returns:
String - Returns the full postpath & semantic components
*NOTE* may not contain the server & port numbers. That depends on
what was provided to the parser.
"""
uri = post_s... | python | def return_current_uri_subpage(self):
"""
Args:
* None
Returns:
String - Returns the full postpath & semantic components
*NOTE* may not contain the server & port numbers. That depends on
what was provided to the parser.
"""
uri = post_s... | [
"def",
"return_current_uri_subpage",
"(",
"self",
")",
":",
"uri",
"=",
"post_slash",
"(",
"\"%s%s/%s/%s\"",
"%",
"(",
"post_slash",
"(",
"self",
".",
"current_dir",
"(",
")",
")",
",",
"self",
".",
"slots",
"[",
"'page'",
"]",
",",
"self",
".",
"slots",... | Args:
* None
Returns:
String - Returns the full postpath & semantic components
*NOTE* may not contain the server & port numbers. That depends on
what was provided to the parser. | [
"Args",
":",
"*",
"None"
] | train | https://github.com/bschollnick/semantic_url/blob/3c9b9e24354c0d4c5a2ce82006e610c5980395ad/semantic_url/__init__.py#L416-L431 |
bschollnick/semantic_url | semantic_url/__init__.py | semantic_url.return_current_uri | def return_current_uri(self):
"""
Args:
* None
Returns:
String - Returns the full postpath & semantic components
*NOTE* may not contain the server & port numbers. That depends on
what was provided to the parser.
"""
uri = post_slash("%s... | python | def return_current_uri(self):
"""
Args:
* None
Returns:
String - Returns the full postpath & semantic components
*NOTE* may not contain the server & port numbers. That depends on
what was provided to the parser.
"""
uri = post_slash("%s... | [
"def",
"return_current_uri",
"(",
"self",
")",
":",
"uri",
"=",
"post_slash",
"(",
"\"%s\"",
"%",
"self",
".",
"current_dir",
"(",
")",
")",
"for",
"uri_part",
"in",
"self",
".",
"slots",
".",
"keys",
"(",
")",
":",
"if",
"self",
".",
"slots",
"[",
... | Args:
* None
Returns:
String - Returns the full postpath & semantic components
*NOTE* may not contain the server & port numbers. That depends on
what was provided to the parser. | [
"Args",
":",
"*",
"None"
] | train | https://github.com/bschollnick/semantic_url/blob/3c9b9e24354c0d4c5a2ce82006e610c5980395ad/semantic_url/__init__.py#L433-L449 |
bschollnick/semantic_url | semantic_url/__init__.py | semantic_url.return_item_count_on_page | def return_item_count_on_page(self, page=1, total_items=1):
"""
Return the number of items on page.
Args:
* page = The Page to test for
* total_items = the total item count
Returns:
* Integer - Which represents the calculated number of items on page.
"""
up_... | python | def return_item_count_on_page(self, page=1, total_items=1):
"""
Return the number of items on page.
Args:
* page = The Page to test for
* total_items = the total item count
Returns:
* Integer - Which represents the calculated number of items on page.
"""
up_... | [
"def",
"return_item_count_on_page",
"(",
"self",
",",
"page",
"=",
"1",
",",
"total_items",
"=",
"1",
")",
":",
"up_to_page",
"=",
"(",
"(",
"page",
"-",
"1",
")",
"*",
"self",
".",
"page_items",
")",
"# Number of items up to the page in question",
"if",
"... | Return the number of items on page.
Args:
* page = The Page to test for
* total_items = the total item count
Returns:
* Integer - Which represents the calculated number of items on page. | [
"Return",
"the",
"number",
"of",
"items",
"on",
"page",
"."
] | train | https://github.com/bschollnick/semantic_url/blob/3c9b9e24354c0d4c5a2ce82006e610c5980395ad/semantic_url/__init__.py#L457-L483 |
bschollnick/semantic_url | semantic_url/__init__.py | semantic_url.return_item_count_on_subpage | def return_item_count_on_subpage(self, subpage=1, total_items=1):
"""
Return the number of items on page.
Args:
* page = The Page to test for
* total_items = the total item count
Returns:
* Integer - Which represents the calculated number of items on page.
"""
... | python | def return_item_count_on_subpage(self, subpage=1, total_items=1):
"""
Return the number of items on page.
Args:
* page = The Page to test for
* total_items = the total item count
Returns:
* Integer - Which represents the calculated number of items on page.
"""
... | [
"def",
"return_item_count_on_subpage",
"(",
"self",
",",
"subpage",
"=",
"1",
",",
"total_items",
"=",
"1",
")",
":",
"up_to_subpage",
"=",
"(",
"(",
"subpage",
"-",
"1",
")",
"*",
"self",
".",
"subpage_items",
")",
"# Number of items up to the page in questio... | Return the number of items on page.
Args:
* page = The Page to test for
* total_items = the total item count
Returns:
* Integer - Which represents the calculated number of items on page. | [
"Return",
"the",
"number",
"of",
"items",
"on",
"page",
"."
] | train | https://github.com/bschollnick/semantic_url/blob/3c9b9e24354c0d4c5a2ce82006e610c5980395ad/semantic_url/__init__.py#L485-L513 |
bschollnick/semantic_url | semantic_url/__init__.py | semantic_url.parse_uri | def parse_uri(self, postpath=None):
"""
postpath - a url broken in to a list (postpath from twisted)
e.g. ["127.0.0.1:8888", "albums", "2", "3", "44", "99"]
Decode the postpath list, and deconstruct the
* Page
* Item
* subpage (Archives)
* subitem (Archives)
code::
... | python | def parse_uri(self, postpath=None):
"""
postpath - a url broken in to a list (postpath from twisted)
e.g. ["127.0.0.1:8888", "albums", "2", "3", "44", "99"]
Decode the postpath list, and deconstruct the
* Page
* Item
* subpage (Archives)
* subitem (Archives)
code::
... | [
"def",
"parse_uri",
"(",
"self",
",",
"postpath",
"=",
"None",
")",
":",
"def",
"find_next_empty",
"(",
")",
":",
"\"\"\"\n return next open slot key\n \"\"\"",
"for",
"x",
"in",
"self",
".",
"slots",
".",
"keys",
"(",
")",
":",
"if",
"se... | postpath - a url broken in to a list (postpath from twisted)
e.g. ["127.0.0.1:8888", "albums", "2", "3", "44", "99"]
Decode the postpath list, and deconstruct the
* Page
* Item
* subpage (Archives)
* subitem (Archives)
code::
import gallery
test =["127.0.0.1:8888", "a... | [
"postpath",
"-",
"a",
"url",
"broken",
"in",
"to",
"a",
"list",
"(",
"postpath",
"from",
"twisted",
")",
"e",
".",
"g",
".",
"[",
"127",
".",
"0",
".",
"0",
".",
"1",
":",
"8888",
"albums",
"2",
"3",
"44",
"99",
"]"
] | train | https://github.com/bschollnick/semantic_url/blob/3c9b9e24354c0d4c5a2ce82006e610c5980395ad/semantic_url/__init__.py#L541-L593 |
fred49/linshare-api | linshareapi/user/jwt.py | Jwt.get | def get(self, uuid):
"""Workaround: missing get entry point"""
for token in self.list():
if token.get('uuid') == uuid:
return token
raise LinShareException(-1, "Can find uuid:" + uuid) | python | def get(self, uuid):
"""Workaround: missing get entry point"""
for token in self.list():
if token.get('uuid') == uuid:
return token
raise LinShareException(-1, "Can find uuid:" + uuid) | [
"def",
"get",
"(",
"self",
",",
"uuid",
")",
":",
"for",
"token",
"in",
"self",
".",
"list",
"(",
")",
":",
"if",
"token",
".",
"get",
"(",
"'uuid'",
")",
"==",
"uuid",
":",
"return",
"token",
"raise",
"LinShareException",
"(",
"-",
"1",
",",
"\"... | Workaround: missing get entry point | [
"Workaround",
":",
"missing",
"get",
"entry",
"point"
] | train | https://github.com/fred49/linshare-api/blob/be646c25aa8ba3718abb6869c620b157d53d6e41/linshareapi/user/jwt.py#L93-L98 |
uw-it-aca/uw-restclients-gradepage | uw_gradepage/grading_status.py | get_grading_status | def get_grading_status(section_id, act_as=None):
"""
Return a restclients.models.gradepage.GradePageStatus object
on the given course
"""
url = "{}/{}".format(url_prefix, quote(section_id))
headers = {}
if act_as is not None:
headers["X-UW-Act-as"] = act_as
response = get_resou... | python | def get_grading_status(section_id, act_as=None):
"""
Return a restclients.models.gradepage.GradePageStatus object
on the given course
"""
url = "{}/{}".format(url_prefix, quote(section_id))
headers = {}
if act_as is not None:
headers["X-UW-Act-as"] = act_as
response = get_resou... | [
"def",
"get_grading_status",
"(",
"section_id",
",",
"act_as",
"=",
"None",
")",
":",
"url",
"=",
"\"{}/{}\"",
".",
"format",
"(",
"url_prefix",
",",
"quote",
"(",
"section_id",
")",
")",
"headers",
"=",
"{",
"}",
"if",
"act_as",
"is",
"not",
"None",
"... | Return a restclients.models.gradepage.GradePageStatus object
on the given course | [
"Return",
"a",
"restclients",
".",
"models",
".",
"gradepage",
".",
"GradePageStatus",
"object",
"on",
"the",
"given",
"course"
] | train | https://github.com/uw-it-aca/uw-restclients-gradepage/blob/207ae8aa5e58f979b77aeb2c5a1772b56bd57e90/uw_gradepage/grading_status.py#L19-L31 |
PushAMP/strictdict3 | strictdict/strictbase/strictdict.py | StrictDict.to_dict | def to_dict(self):
"""
For backwards compatibility
"""
plain_dict = dict()
for k, v in self.items():
if self.__fields__[k].is_list:
if isinstance(self.__fields__[k], ViewModelField):
plain_dict[k] = tuple(vt.to_dict() for vt in v)
... | python | def to_dict(self):
"""
For backwards compatibility
"""
plain_dict = dict()
for k, v in self.items():
if self.__fields__[k].is_list:
if isinstance(self.__fields__[k], ViewModelField):
plain_dict[k] = tuple(vt.to_dict() for vt in v)
... | [
"def",
"to_dict",
"(",
"self",
")",
":",
"plain_dict",
"=",
"dict",
"(",
")",
"for",
"k",
",",
"v",
"in",
"self",
".",
"items",
"(",
")",
":",
"if",
"self",
".",
"__fields__",
"[",
"k",
"]",
".",
"is_list",
":",
"if",
"isinstance",
"(",
"self",
... | For backwards compatibility | [
"For",
"backwards",
"compatibility"
] | train | https://github.com/PushAMP/strictdict3/blob/8b7b91c097ecc57232871137db6135c71fc33a9e/strictdict/strictbase/strictdict.py#L174-L194 |
PushAMP/strictdict3 | strictdict/strictbase/strictdict.py | StrictDict.restore | def restore(cls, data_dict):
"""
Restore from previously simplified data. Data is supposed to be valid,
no checks are performed!
"""
obj = cls.__new__(cls) # Avoid calling constructor
object.__setattr__(obj, '_simplified', data_dict)
object.__setattr__(obj, '_sto... | python | def restore(cls, data_dict):
"""
Restore from previously simplified data. Data is supposed to be valid,
no checks are performed!
"""
obj = cls.__new__(cls) # Avoid calling constructor
object.__setattr__(obj, '_simplified', data_dict)
object.__setattr__(obj, '_sto... | [
"def",
"restore",
"(",
"cls",
",",
"data_dict",
")",
":",
"obj",
"=",
"cls",
".",
"__new__",
"(",
"cls",
")",
"# Avoid calling constructor",
"object",
".",
"__setattr__",
"(",
"obj",
",",
"'_simplified'",
",",
"data_dict",
")",
"object",
".",
"__setattr__",
... | Restore from previously simplified data. Data is supposed to be valid,
no checks are performed! | [
"Restore",
"from",
"previously",
"simplified",
"data",
".",
"Data",
"is",
"supposed",
"to",
"be",
"valid",
"no",
"checks",
"are",
"performed!"
] | train | https://github.com/PushAMP/strictdict3/blob/8b7b91c097ecc57232871137db6135c71fc33a9e/strictdict/strictbase/strictdict.py#L197-L205 |
daknuett/py_register_machine2 | engine_tools/output/gpu_alike/http.py | HTTPOutputServer.interrupt | def interrupt(self):
"""
Invoked by the renderering.Renderer, if the image has changed.
"""
self.image = io.BytesIO()
self.renderer.screen.save(self.image, "png") | python | def interrupt(self):
"""
Invoked by the renderering.Renderer, if the image has changed.
"""
self.image = io.BytesIO()
self.renderer.screen.save(self.image, "png") | [
"def",
"interrupt",
"(",
"self",
")",
":",
"self",
".",
"image",
"=",
"io",
".",
"BytesIO",
"(",
")",
"self",
".",
"renderer",
".",
"screen",
".",
"save",
"(",
"self",
".",
"image",
",",
"\"png\"",
")"
] | Invoked by the renderering.Renderer, if the image has changed. | [
"Invoked",
"by",
"the",
"renderering",
".",
"Renderer",
"if",
"the",
"image",
"has",
"changed",
"."
] | train | https://github.com/daknuett/py_register_machine2/blob/599c53cd7576297d0d7a53344ed5d9aa98acc751/engine_tools/output/gpu_alike/http.py#L49-L54 |
nickmilon/Hellas | Hellas/Athens.py | haversine | def haversine(lon1, lat1, lon2, lat2, earth_radius=6357000):
"""Calculate the great circle distance between two points on earth in Kilometers
on the earth (specified in decimal degrees)
.. seealso:: :func:`distance_points`
:param float lon1: longitude of first place (decimal degrees)
:param float ... | python | def haversine(lon1, lat1, lon2, lat2, earth_radius=6357000):
"""Calculate the great circle distance between two points on earth in Kilometers
on the earth (specified in decimal degrees)
.. seealso:: :func:`distance_points`
:param float lon1: longitude of first place (decimal degrees)
:param float ... | [
"def",
"haversine",
"(",
"lon1",
",",
"lat1",
",",
"lon2",
",",
"lat2",
",",
"earth_radius",
"=",
"6357000",
")",
":",
"# convert decimal degrees to radiant",
"lon1",
",",
"lat1",
",",
"lon2",
",",
"lat2",
"=",
"list",
"(",
"map",
"(",
"math",
".",
"radi... | Calculate the great circle distance between two points on earth in Kilometers
on the earth (specified in decimal degrees)
.. seealso:: :func:`distance_points`
:param float lon1: longitude of first place (decimal degrees)
:param float lat1: latitude of first place (decimal degrees)
:param float lon... | [
"Calculate",
"the",
"great",
"circle",
"distance",
"between",
"two",
"points",
"on",
"earth",
"in",
"Kilometers",
"on",
"the",
"earth",
"(",
"specified",
"in",
"decimal",
"degrees",
")"
] | train | https://github.com/nickmilon/Hellas/blob/542e4778692fbec90753942946f20100412ec9ee/Hellas/Athens.py#L37-L66 |
nickmilon/Hellas | Hellas/Athens.py | dms2dd | def dms2dd(degrees, minutes, seconds, direction):
"""convert degrees, minutes, seconds to dd
:param string direction: one of N S W E
"""
dd = (degrees + minutes/60.0) + (seconds/3600.0) # 60.0 fraction for python 2+ compatibility
return dd * -1 if direction == 'S' or direction == 'W' else ... | python | def dms2dd(degrees, minutes, seconds, direction):
"""convert degrees, minutes, seconds to dd
:param string direction: one of N S W E
"""
dd = (degrees + minutes/60.0) + (seconds/3600.0) # 60.0 fraction for python 2+ compatibility
return dd * -1 if direction == 'S' or direction == 'W' else ... | [
"def",
"dms2dd",
"(",
"degrees",
",",
"minutes",
",",
"seconds",
",",
"direction",
")",
":",
"dd",
"=",
"(",
"degrees",
"+",
"minutes",
"/",
"60.0",
")",
"+",
"(",
"seconds",
"/",
"3600.0",
")",
"# 60.0 fraction for python 2+ compatibility",
"return",
"dd",
... | convert degrees, minutes, seconds to dd
:param string direction: one of N S W E | [
"convert",
"degrees",
"minutes",
"seconds",
"to",
"dd",
":",
"param",
"string",
"direction",
":",
"one",
"of",
"N",
"S",
"W",
"E"
] | train | https://github.com/nickmilon/Hellas/blob/542e4778692fbec90753942946f20100412ec9ee/Hellas/Athens.py#L83-L88 |
jut-io/jut-python-tools | jut/config.py | show | def show():
"""
print the available configurations directly to stdout
"""
if not is_configured():
raise JutException('No configurations available, please run: `jut config add`')
info('Available jut configurations:')
index = 0
for configuration in _CONFIG.sections():
usernam... | python | def show():
"""
print the available configurations directly to stdout
"""
if not is_configured():
raise JutException('No configurations available, please run: `jut config add`')
info('Available jut configurations:')
index = 0
for configuration in _CONFIG.sections():
usernam... | [
"def",
"show",
"(",
")",
":",
"if",
"not",
"is_configured",
"(",
")",
":",
"raise",
"JutException",
"(",
"'No configurations available, please run: `jut config add`'",
")",
"info",
"(",
"'Available jut configurations:'",
")",
"index",
"=",
"0",
"for",
"configuration",... | print the available configurations directly to stdout | [
"print",
"the",
"available",
"configurations",
"directly",
"to",
"stdout"
] | train | https://github.com/jut-io/jut-python-tools/blob/65574d23f51a7bbced9bb25010d02da5ca5d906f/jut/config.py#L41-L67 |
jut-io/jut-python-tools | jut/config.py | set_default | def set_default(name=None, index=None):
"""
set the default configuration by name
"""
default_was_set = False
count = 1
for configuration in _CONFIG.sections():
if index != None:
if count == index:
_CONFIG.set(configuration, 'default', True)
... | python | def set_default(name=None, index=None):
"""
set the default configuration by name
"""
default_was_set = False
count = 1
for configuration in _CONFIG.sections():
if index != None:
if count == index:
_CONFIG.set(configuration, 'default', True)
... | [
"def",
"set_default",
"(",
"name",
"=",
"None",
",",
"index",
"=",
"None",
")",
":",
"default_was_set",
"=",
"False",
"count",
"=",
"1",
"for",
"configuration",
"in",
"_CONFIG",
".",
"sections",
"(",
")",
":",
"if",
"index",
"!=",
"None",
":",
"if",
... | set the default configuration by name | [
"set",
"the",
"default",
"configuration",
"by",
"name"
] | train | https://github.com/jut-io/jut-python-tools/blob/65574d23f51a7bbced9bb25010d02da5ca5d906f/jut/config.py#L78-L109 |
jut-io/jut-python-tools | jut/config.py | add | def add(name, **kwargs):
"""
add a new configuration with the name specified and all of the keywords
as attributes of that configuration.
"""
_CONFIG.add_section(name)
for (key, value) in kwargs.items():
_CONFIG.set(name, key, value)
with open(_CONFIG_FILEPATH, 'w') as configfile:... | python | def add(name, **kwargs):
"""
add a new configuration with the name specified and all of the keywords
as attributes of that configuration.
"""
_CONFIG.add_section(name)
for (key, value) in kwargs.items():
_CONFIG.set(name, key, value)
with open(_CONFIG_FILEPATH, 'w') as configfile:... | [
"def",
"add",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"_CONFIG",
".",
"add_section",
"(",
"name",
")",
"for",
"(",
"key",
",",
"value",
")",
"in",
"kwargs",
".",
"items",
"(",
")",
":",
"_CONFIG",
".",
"set",
"(",
"name",
",",
"key",
",... | add a new configuration with the name specified and all of the keywords
as attributes of that configuration. | [
"add",
"a",
"new",
"configuration",
"with",
"the",
"name",
"specified",
"and",
"all",
"of",
"the",
"keywords",
"as",
"attributes",
"of",
"that",
"configuration",
"."
] | train | https://github.com/jut-io/jut-python-tools/blob/65574d23f51a7bbced9bb25010d02da5ca5d906f/jut/config.py#L116-L130 |
jut-io/jut-python-tools | jut/config.py | get_default | def get_default():
"""
return the attributes associated with the default configuration
"""
if not is_configured():
raise JutException('No configurations available, please run `jut config add`')
for configuration in _CONFIG.sections():
if _CONFIG.has_option(configuration, 'default'... | python | def get_default():
"""
return the attributes associated with the default configuration
"""
if not is_configured():
raise JutException('No configurations available, please run `jut config add`')
for configuration in _CONFIG.sections():
if _CONFIG.has_option(configuration, 'default'... | [
"def",
"get_default",
"(",
")",
":",
"if",
"not",
"is_configured",
"(",
")",
":",
"raise",
"JutException",
"(",
"'No configurations available, please run `jut config add`'",
")",
"for",
"configuration",
"in",
"_CONFIG",
".",
"sections",
"(",
")",
":",
"if",
"_CONF... | return the attributes associated with the default configuration | [
"return",
"the",
"attributes",
"associated",
"with",
"the",
"default",
"configuration"
] | train | https://github.com/jut-io/jut-python-tools/blob/65574d23f51a7bbced9bb25010d02da5ca5d906f/jut/config.py#L133-L144 |
jut-io/jut-python-tools | jut/config.py | remove | def remove(name=None, index=None):
"""
remove the specified configuration
"""
removed = False
count = 1
for configuration in _CONFIG.sections():
if index != None:
if count == index:
_CONFIG.remove_section(configuration)
removed = True
... | python | def remove(name=None, index=None):
"""
remove the specified configuration
"""
removed = False
count = 1
for configuration in _CONFIG.sections():
if index != None:
if count == index:
_CONFIG.remove_section(configuration)
removed = True
... | [
"def",
"remove",
"(",
"name",
"=",
"None",
",",
"index",
"=",
"None",
")",
":",
"removed",
"=",
"False",
"count",
"=",
"1",
"for",
"configuration",
"in",
"_CONFIG",
".",
"sections",
"(",
")",
":",
"if",
"index",
"!=",
"None",
":",
"if",
"count",
"=... | remove the specified configuration | [
"remove",
"the",
"specified",
"configuration"
] | train | https://github.com/jut-io/jut-python-tools/blob/65574d23f51a7bbced9bb25010d02da5ca5d906f/jut/config.py#L147-L174 |
jut-io/jut-python-tools | jut/config.py | is_default | def is_default(name=None, index=None):
"""
returns True if the specified configuration is the default one
"""
if not is_configured():
raise JutException('No configurations available, please run `jut config add`')
count = 1
for configuration in _CONFIG.sections():
if index != ... | python | def is_default(name=None, index=None):
"""
returns True if the specified configuration is the default one
"""
if not is_configured():
raise JutException('No configurations available, please run `jut config add`')
count = 1
for configuration in _CONFIG.sections():
if index != ... | [
"def",
"is_default",
"(",
"name",
"=",
"None",
",",
"index",
"=",
"None",
")",
":",
"if",
"not",
"is_configured",
"(",
")",
":",
"raise",
"JutException",
"(",
"'No configurations available, please run `jut config add`'",
")",
"count",
"=",
"1",
"for",
"configura... | returns True if the specified configuration is the default one | [
"returns",
"True",
"if",
"the",
"specified",
"configuration",
"is",
"the",
"default",
"one"
] | train | https://github.com/jut-io/jut-python-tools/blob/65574d23f51a7bbced9bb25010d02da5ca5d906f/jut/config.py#L177-L199 |
eeue56/PyChat.js | pychatjs/server/room.py | Room.disconnect | def disconnect(self, user):
""" Disconnect a user and send a message to the
connected clients """
self.remove_user(user)
self.send_message(create_message('RoomServer', 'Please all say goodbye to {name}!'.format(name=user.id.name)))
self.send_message(create_disconnect(user.id... | python | def disconnect(self, user):
""" Disconnect a user and send a message to the
connected clients """
self.remove_user(user)
self.send_message(create_message('RoomServer', 'Please all say goodbye to {name}!'.format(name=user.id.name)))
self.send_message(create_disconnect(user.id... | [
"def",
"disconnect",
"(",
"self",
",",
"user",
")",
":",
"self",
".",
"remove_user",
"(",
"user",
")",
"self",
".",
"send_message",
"(",
"create_message",
"(",
"'RoomServer'",
",",
"'Please all say goodbye to {name}!'",
".",
"format",
"(",
"name",
"=",
"user",... | Disconnect a user and send a message to the
connected clients | [
"Disconnect",
"a",
"user",
"and",
"send",
"a",
"message",
"to",
"the",
"connected",
"clients"
] | train | https://github.com/eeue56/PyChat.js/blob/45056de6f988350c90a6dbe674459a4affde8abc/pychatjs/server/room.py#L21-L26 |
eeue56/PyChat.js | pychatjs/server/room.py | Room.get_user | def get_user(self, username):
""" gets a user with given username if connected """
for user in self.users:
if user.id.name == username:
return user
return None | python | def get_user(self, username):
""" gets a user with given username if connected """
for user in self.users:
if user.id.name == username:
return user
return None | [
"def",
"get_user",
"(",
"self",
",",
"username",
")",
":",
"for",
"user",
"in",
"self",
".",
"users",
":",
"if",
"user",
".",
"id",
".",
"name",
"==",
"username",
":",
"return",
"user",
"return",
"None"
] | gets a user with given username if connected | [
"gets",
"a",
"user",
"with",
"given",
"username",
"if",
"connected"
] | train | https://github.com/eeue56/PyChat.js/blob/45056de6f988350c90a6dbe674459a4affde8abc/pychatjs/server/room.py#L28-L33 |
eeue56/PyChat.js | pychatjs/server/room.py | Room.send_message | def send_message(self, message):
""" send a message to each of the users """
for handler in self.users:
logging.info('Handler: ' + str(handler))
handler.write_message(message) | python | def send_message(self, message):
""" send a message to each of the users """
for handler in self.users:
logging.info('Handler: ' + str(handler))
handler.write_message(message) | [
"def",
"send_message",
"(",
"self",
",",
"message",
")",
":",
"for",
"handler",
"in",
"self",
".",
"users",
":",
"logging",
".",
"info",
"(",
"'Handler: '",
"+",
"str",
"(",
"handler",
")",
")",
"handler",
".",
"write_message",
"(",
"message",
")"
] | send a message to each of the users | [
"send",
"a",
"message",
"to",
"each",
"of",
"the",
"users"
] | train | https://github.com/eeue56/PyChat.js/blob/45056de6f988350c90a6dbe674459a4affde8abc/pychatjs/server/room.py#L50-L54 |
eeue56/PyChat.js | pychatjs/server/room.py | Room.welcome | def welcome(self, user):
""" welcomes a user to the roomserver """
self.send_message(create_message('RoomServer', 'Please welcome {name} to the server!\nThere are currently {i} users online -\n {r}\n'.format(name=user.id,
i=self.amount_of_users_connected,
... | python | def welcome(self, user):
""" welcomes a user to the roomserver """
self.send_message(create_message('RoomServer', 'Please welcome {name} to the server!\nThere are currently {i} users online -\n {r}\n'.format(name=user.id,
i=self.amount_of_users_connected,
... | [
"def",
"welcome",
"(",
"self",
",",
"user",
")",
":",
"self",
".",
"send_message",
"(",
"create_message",
"(",
"'RoomServer'",
",",
"'Please welcome {name} to the server!\\nThere are currently {i} users online -\\n {r}\\n'",
".",
"format",
"(",
"name",
"=",
"user",
".",... | welcomes a user to the roomserver | [
"welcomes",
"a",
"user",
"to",
"the",
"roomserver"
] | train | https://github.com/eeue56/PyChat.js/blob/45056de6f988350c90a6dbe674459a4affde8abc/pychatjs/server/room.py#L56-L61 |
tomokinakamaru/mapletree | mapletree/defaults/request/validators.py | float_range | def float_range(string, minimum, maximum, inf, sup):
""" Requires values to be a number and range in a certain range.
:param string: Value to validate
:param minimum: Minimum value to accept
:param maximum: Maximum value to accept
:param inf: Infimum value to accept
:param sup: Supremum value t... | python | def float_range(string, minimum, maximum, inf, sup):
""" Requires values to be a number and range in a certain range.
:param string: Value to validate
:param minimum: Minimum value to accept
:param maximum: Maximum value to accept
:param inf: Infimum value to accept
:param sup: Supremum value t... | [
"def",
"float_range",
"(",
"string",
",",
"minimum",
",",
"maximum",
",",
"inf",
",",
"sup",
")",
":",
"return",
"_inrange",
"(",
"float",
"(",
"string",
")",
",",
"minimum",
",",
"maximum",
",",
"inf",
",",
"sup",
")"
] | Requires values to be a number and range in a certain range.
:param string: Value to validate
:param minimum: Minimum value to accept
:param maximum: Maximum value to accept
:param inf: Infimum value to accept
:param sup: Supremum value to accept
:type string: str
:type minimum: float
:... | [
"Requires",
"values",
"to",
"be",
"a",
"number",
"and",
"range",
"in",
"a",
"certain",
"range",
"."
] | train | https://github.com/tomokinakamaru/mapletree/blob/19ec68769ef2c1cd2e4164ed8623e0c4280279bb/mapletree/defaults/request/validators.py#L56-L70 |
tomokinakamaru/mapletree | mapletree/defaults/request/validators.py | length_range | def length_range(string, minimum, maximum):
""" Requires values' length to be in a certain range.
:param string: Value to validate
:param minimum: Minimum length to accept
:param maximum: Maximum length to accept
:type string: str
:type minimum: int
:type maximum: int
"""
int_range(... | python | def length_range(string, minimum, maximum):
""" Requires values' length to be in a certain range.
:param string: Value to validate
:param minimum: Minimum length to accept
:param maximum: Maximum length to accept
:type string: str
:type minimum: int
:type maximum: int
"""
int_range(... | [
"def",
"length_range",
"(",
"string",
",",
"minimum",
",",
"maximum",
")",
":",
"int_range",
"(",
"len",
"(",
"string",
")",
",",
"minimum",
",",
"maximum",
")",
"return",
"string"
] | Requires values' length to be in a certain range.
:param string: Value to validate
:param minimum: Minimum length to accept
:param maximum: Maximum length to accept
:type string: str
:type minimum: int
:type maximum: int | [
"Requires",
"values",
"length",
"to",
"be",
"in",
"a",
"certain",
"range",
"."
] | train | https://github.com/tomokinakamaru/mapletree/blob/19ec68769ef2c1cd2e4164ed8623e0c4280279bb/mapletree/defaults/request/validators.py#L127-L138 |
tomokinakamaru/mapletree | mapletree/defaults/request/validators.py | int_option | def int_option(string, options):
""" Requires values (int) to be in `args`
:param string: Value to validate
:type string: str
"""
i = int(string)
if i in options:
return i
raise ValueError('Not in allowed options') | python | def int_option(string, options):
""" Requires values (int) to be in `args`
:param string: Value to validate
:type string: str
"""
i = int(string)
if i in options:
return i
raise ValueError('Not in allowed options') | [
"def",
"int_option",
"(",
"string",
",",
"options",
")",
":",
"i",
"=",
"int",
"(",
"string",
")",
"if",
"i",
"in",
"options",
":",
"return",
"i",
"raise",
"ValueError",
"(",
"'Not in allowed options'",
")"
] | Requires values (int) to be in `args`
:param string: Value to validate
:type string: str | [
"Requires",
"values",
"(",
"int",
")",
"to",
"be",
"in",
"args"
] | train | https://github.com/tomokinakamaru/mapletree/blob/19ec68769ef2c1cd2e4164ed8623e0c4280279bb/mapletree/defaults/request/validators.py#L258-L268 |
kcolford/txt2boil | txt2boil/core/gen.py | _Gen.collectTriggers | def collectTriggers(self, rgx, code):
"""Return a dictionary of triggers and their corresponding matches
from the code.
"""
return {m.group(0): m for m in re.finditer(rgx, code)} | python | def collectTriggers(self, rgx, code):
"""Return a dictionary of triggers and their corresponding matches
from the code.
"""
return {m.group(0): m for m in re.finditer(rgx, code)} | [
"def",
"collectTriggers",
"(",
"self",
",",
"rgx",
",",
"code",
")",
":",
"return",
"{",
"m",
".",
"group",
"(",
"0",
")",
":",
"m",
"for",
"m",
"in",
"re",
".",
"finditer",
"(",
"rgx",
",",
"code",
")",
"}"
] | Return a dictionary of triggers and their corresponding matches
from the code. | [
"Return",
"a",
"dictionary",
"of",
"triggers",
"and",
"their",
"corresponding",
"matches",
"from",
"the",
"code",
"."
] | train | https://github.com/kcolford/txt2boil/blob/853a47bb8db27c0224531f24dfd02839c983d027/txt2boil/core/gen.py#L30-L36 |
kcolford/txt2boil | txt2boil/core/gen.py | _Gen.genOutputs | def genOutputs(self, code, match):
"""Return a list out template outputs based on the triggers found in
the code and the template they create.
"""
out = sorted((k, match.output(m)) for (k, m) in
self.collectTriggers(match.match, code).items())
out = list(ma... | python | def genOutputs(self, code, match):
"""Return a list out template outputs based on the triggers found in
the code and the template they create.
"""
out = sorted((k, match.output(m)) for (k, m) in
self.collectTriggers(match.match, code).items())
out = list(ma... | [
"def",
"genOutputs",
"(",
"self",
",",
"code",
",",
"match",
")",
":",
"out",
"=",
"sorted",
"(",
"(",
"k",
",",
"match",
".",
"output",
"(",
"m",
")",
")",
"for",
"(",
"k",
",",
"m",
")",
"in",
"self",
".",
"collectTriggers",
"(",
"match",
"."... | Return a list out template outputs based on the triggers found in
the code and the template they create. | [
"Return",
"a",
"list",
"out",
"template",
"outputs",
"based",
"on",
"the",
"triggers",
"found",
"in",
"the",
"code",
"and",
"the",
"template",
"they",
"create",
"."
] | train | https://github.com/kcolford/txt2boil/blob/853a47bb8db27c0224531f24dfd02839c983d027/txt2boil/core/gen.py#L38-L47 |
kcolford/txt2boil | txt2boil/core/gen.py | _Gen.gen | def gen(self, text, start=0):
"""Return the source code in text, filled with autogenerated code
starting at start.
"""
for cc in self.chunkComment(text, start):
c = self.extractChunkContent(cc)
cc = ''.join(cc)
m = self.matchComment(c)
id... | python | def gen(self, text, start=0):
"""Return the source code in text, filled with autogenerated code
starting at start.
"""
for cc in self.chunkComment(text, start):
c = self.extractChunkContent(cc)
cc = ''.join(cc)
m = self.matchComment(c)
id... | [
"def",
"gen",
"(",
"self",
",",
"text",
",",
"start",
"=",
"0",
")",
":",
"for",
"cc",
"in",
"self",
".",
"chunkComment",
"(",
"text",
",",
"start",
")",
":",
"c",
"=",
"self",
".",
"extractChunkContent",
"(",
"cc",
")",
"cc",
"=",
"''",
".",
"... | Return the source code in text, filled with autogenerated code
starting at start. | [
"Return",
"the",
"source",
"code",
"in",
"text",
"filled",
"with",
"autogenerated",
"code",
"starting",
"at",
"start",
"."
] | train | https://github.com/kcolford/txt2boil/blob/853a47bb8db27c0224531f24dfd02839c983d027/txt2boil/core/gen.py#L49-L74 |
pjuren/pyokit | src/pyokit/statistics/beta.py | beta | def beta(a, b):
"""use gamma function or inbuilt math.gamma() to compute vals of beta func"""
beta = math.exp(math.lgamma(a) + math.lgamma(b) - math.lgamma(a + b))
return beta | python | def beta(a, b):
"""use gamma function or inbuilt math.gamma() to compute vals of beta func"""
beta = math.exp(math.lgamma(a) + math.lgamma(b) - math.lgamma(a + b))
return beta | [
"def",
"beta",
"(",
"a",
",",
"b",
")",
":",
"beta",
"=",
"math",
".",
"exp",
"(",
"math",
".",
"lgamma",
"(",
"a",
")",
"+",
"math",
".",
"lgamma",
"(",
"b",
")",
"-",
"math",
".",
"lgamma",
"(",
"a",
"+",
"b",
")",
")",
"return",
"beta"
] | use gamma function or inbuilt math.gamma() to compute vals of beta func | [
"use",
"gamma",
"function",
"or",
"inbuilt",
"math",
".",
"gamma",
"()",
"to",
"compute",
"vals",
"of",
"beta",
"func"
] | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/statistics/beta.py#L78-L81 |
pjuren/pyokit | src/pyokit/statistics/beta.py | reg_incomplete_beta | def reg_incomplete_beta(a, b, x):
"""
Incomplete beta function; code translated from: Numerical Recipes in C.
:param a: a > 0
:param b: b > 0
:param x: 0 <= x <= 1.
"""
if (x == 0):
return 0
elif (x == 1):
return 1
else:
lbeta = (math.lgamma(a + b) - math.lgamma(a) - math.lgamma(b) +
... | python | def reg_incomplete_beta(a, b, x):
"""
Incomplete beta function; code translated from: Numerical Recipes in C.
:param a: a > 0
:param b: b > 0
:param x: 0 <= x <= 1.
"""
if (x == 0):
return 0
elif (x == 1):
return 1
else:
lbeta = (math.lgamma(a + b) - math.lgamma(a) - math.lgamma(b) +
... | [
"def",
"reg_incomplete_beta",
"(",
"a",
",",
"b",
",",
"x",
")",
":",
"if",
"(",
"x",
"==",
"0",
")",
":",
"return",
"0",
"elif",
"(",
"x",
"==",
"1",
")",
":",
"return",
"1",
"else",
":",
"lbeta",
"=",
"(",
"math",
".",
"lgamma",
"(",
"a",
... | Incomplete beta function; code translated from: Numerical Recipes in C.
:param a: a > 0
:param b: b > 0
:param x: 0 <= x <= 1. | [
"Incomplete",
"beta",
"function",
";",
"code",
"translated",
"from",
":",
"Numerical",
"Recipes",
"in",
"C",
"."
] | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/statistics/beta.py#L84-L103 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.