repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 3
values | summary stringlengths 4 350 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
networks-lab/tidyextractors | tidyextractors/tidymbox/mbox_to_pandas.py | mbox_to_pandas | def mbox_to_pandas(mbox_path):
"""
Extracts all mbox messages from mbox files in mbox_path.
:param mbox_path: Path to an mbox file OR a directory containing mbox files.
:return: A Pandas DataFrame with messages as rows/observations.
"""
if os.path.isfile(mbox_path):
mbox_files = [mbox_pa... | python | def mbox_to_pandas(mbox_path):
"""
Extracts all mbox messages from mbox files in mbox_path.
:param mbox_path: Path to an mbox file OR a directory containing mbox files.
:return: A Pandas DataFrame with messages as rows/observations.
"""
if os.path.isfile(mbox_path):
mbox_files = [mbox_pa... | [
"def",
"mbox_to_pandas",
"(",
"mbox_path",
")",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"mbox_path",
")",
":",
"mbox_files",
"=",
"[",
"mbox_path",
"]",
"else",
":",
"mbox_files",
"=",
"[",
"os",
".",
"path",
".",
"join",
"(",
"dirpath",
",... | Extracts all mbox messages from mbox files in mbox_path.
:param mbox_path: Path to an mbox file OR a directory containing mbox files.
:return: A Pandas DataFrame with messages as rows/observations. | [
"Extracts",
"all",
"mbox",
"messages",
"from",
"mbox",
"files",
"in",
"mbox_path",
".",
":",
"param",
"mbox_path",
":",
"Path",
"to",
"an",
"mbox",
"file",
"OR",
"a",
"directory",
"containing",
"mbox",
"files",
".",
":",
"return",
":",
"A",
"Pandas",
"Da... | 658448ed533beecf32adcc188fc64d1068d15ca6 | https://github.com/networks-lab/tidyextractors/blob/658448ed533beecf32adcc188fc64d1068d15ca6/tidyextractors/tidymbox/mbox_to_pandas.py#L167-L191 | train | Extracts all mbox messages from mbox files in mbox_path and returns a Pandas DataFrame with rows as rows. |
TkTech/Jawa | jawa/attribute.py | get_attribute_classes | def get_attribute_classes() -> Dict[str, Attribute]:
"""
Lookup all builtin Attribute subclasses, load them, and return a dict
"""
attribute_children = pkgutil.iter_modules(
importlib.import_module('jawa.attributes').__path__,
prefix='jawa.attributes.'
)
result = {}
for _, n... | python | def get_attribute_classes() -> Dict[str, Attribute]:
"""
Lookup all builtin Attribute subclasses, load them, and return a dict
"""
attribute_children = pkgutil.iter_modules(
importlib.import_module('jawa.attributes').__path__,
prefix='jawa.attributes.'
)
result = {}
for _, n... | [
"def",
"get_attribute_classes",
"(",
")",
"->",
"Dict",
"[",
"str",
",",
"Attribute",
"]",
":",
"attribute_children",
"=",
"pkgutil",
".",
"iter_modules",
"(",
"importlib",
".",
"import_module",
"(",
"'jawa.attributes'",
")",
".",
"__path__",
",",
"prefix",
"=... | Lookup all builtin Attribute subclasses, load them, and return a dict | [
"Lookup",
"all",
"builtin",
"Attribute",
"subclasses",
"load",
"them",
"and",
"return",
"a",
"dict"
] | 94c8424e699029ac33fbc0e866fff0ecb2742289 | https://github.com/TkTech/Jawa/blob/94c8424e699029ac33fbc0e866fff0ecb2742289/jawa/attribute.py#L161-L184 | train | Lookup all builtin Attribute subclasses load them and return a dict containing the class that is a builtin attribute. |
TkTech/Jawa | jawa/attribute.py | AttributeTable.unpack | def unpack(self, source: IO):
"""
Read the ConstantPool from the file-like object `source`.
.. note::
Advanced usage only. You will typically never need to call this
method as it will be called for you when loading a ClassFile.
:param source: Any file-like obje... | python | def unpack(self, source: IO):
"""
Read the ConstantPool from the file-like object `source`.
.. note::
Advanced usage only. You will typically never need to call this
method as it will be called for you when loading a ClassFile.
:param source: Any file-like obje... | [
"def",
"unpack",
"(",
"self",
",",
"source",
":",
"IO",
")",
":",
"count",
"=",
"unpack",
"(",
"'>H'",
",",
"source",
".",
"read",
"(",
"2",
")",
")",
"[",
"0",
"]",
"for",
"_",
"in",
"repeat",
"(",
"None",
",",
"count",
")",
":",
"name_index",... | Read the ConstantPool from the file-like object `source`.
.. note::
Advanced usage only. You will typically never need to call this
method as it will be called for you when loading a ClassFile.
:param source: Any file-like object providing `read()` | [
"Read",
"the",
"ConstantPool",
"from",
"the",
"file",
"-",
"like",
"object",
"source",
"."
] | 94c8424e699029ac33fbc0e866fff0ecb2742289 | https://github.com/TkTech/Jawa/blob/94c8424e699029ac33fbc0e866fff0ecb2742289/jawa/attribute.py#L67-L82 | train | Read the ConstantPool from the file - like object source. |
TkTech/Jawa | jawa/attribute.py | AttributeTable.pack | def pack(self, out: IO):
"""
Write the AttributeTable to the file-like object `out`.
.. note::
Advanced usage only. You will typically never need to call this
method as it will be called for you when saving a ClassFile.
:param out: Any file-like object providin... | python | def pack(self, out: IO):
"""
Write the AttributeTable to the file-like object `out`.
.. note::
Advanced usage only. You will typically never need to call this
method as it will be called for you when saving a ClassFile.
:param out: Any file-like object providin... | [
"def",
"pack",
"(",
"self",
",",
"out",
":",
"IO",
")",
":",
"out",
".",
"write",
"(",
"pack",
"(",
"'>H'",
",",
"len",
"(",
"self",
".",
"_table",
")",
")",
")",
"for",
"attribute",
"in",
"self",
":",
"info",
"=",
"attribute",
".",
"pack",
"("... | Write the AttributeTable to the file-like object `out`.
.. note::
Advanced usage only. You will typically never need to call this
method as it will be called for you when saving a ClassFile.
:param out: Any file-like object providing `write()` | [
"Write",
"the",
"AttributeTable",
"to",
"the",
"file",
"-",
"like",
"object",
"out",
"."
] | 94c8424e699029ac33fbc0e866fff0ecb2742289 | https://github.com/TkTech/Jawa/blob/94c8424e699029ac33fbc0e866fff0ecb2742289/jawa/attribute.py#L103-L122 | train | Write the attribute table to the file - like object out. |
TkTech/Jawa | jawa/attribute.py | AttributeTable.create | def create(self, type_, *args, **kwargs) -> Any:
"""
Creates a new attribute of `type_`, appending it to the attribute
table and returning it.
"""
attribute = type_(self, *args, **kwargs)
self._table.append(attribute)
return attribute | python | def create(self, type_, *args, **kwargs) -> Any:
"""
Creates a new attribute of `type_`, appending it to the attribute
table and returning it.
"""
attribute = type_(self, *args, **kwargs)
self._table.append(attribute)
return attribute | [
"def",
"create",
"(",
"self",
",",
"type_",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"->",
"Any",
":",
"attribute",
"=",
"type_",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"self",
".",
"_table",
".",
"append",
"(",
"at... | Creates a new attribute of `type_`, appending it to the attribute
table and returning it. | [
"Creates",
"a",
"new",
"attribute",
"of",
"type_",
"appending",
"it",
"to",
"the",
"attribute",
"table",
"and",
"returning",
"it",
"."
] | 94c8424e699029ac33fbc0e866fff0ecb2742289 | https://github.com/TkTech/Jawa/blob/94c8424e699029ac33fbc0e866fff0ecb2742289/jawa/attribute.py#L124-L131 | train | Creates a new attribute of type_ appending it to the attribute
table and returning it. |
thespacedoctor/polyglot | polyglot/cl_utils.py | main | def main(arguments=None):
"""
*The main function used when ``cl_utils.py`` is run as a single script from the cl, or when installed as a cl command*
"""
# setup the command-line util settings
su = tools(
arguments=arguments,
docString=__doc__,
logLevel="WARNING",
opti... | python | def main(arguments=None):
"""
*The main function used when ``cl_utils.py`` is run as a single script from the cl, or when installed as a cl command*
"""
# setup the command-line util settings
su = tools(
arguments=arguments,
docString=__doc__,
logLevel="WARNING",
opti... | [
"def",
"main",
"(",
"arguments",
"=",
"None",
")",
":",
"# setup the command-line util settings",
"su",
"=",
"tools",
"(",
"arguments",
"=",
"arguments",
",",
"docString",
"=",
"__doc__",
",",
"logLevel",
"=",
"\"WARNING\"",
",",
"options_first",
"=",
"False",
... | *The main function used when ``cl_utils.py`` is run as a single script from the cl, or when installed as a cl command* | [
"*",
"The",
"main",
"function",
"used",
"when",
"cl_utils",
".",
"py",
"is",
"run",
"as",
"a",
"single",
"script",
"from",
"the",
"cl",
"or",
"when",
"installed",
"as",
"a",
"cl",
"command",
"*"
] | 98038d746aa67e343b73b3ccee1e02d31dab81ec | https://github.com/thespacedoctor/polyglot/blob/98038d746aa67e343b73b3ccee1e02d31dab81ec/polyglot/cl_utils.py#L48-L218 | train | This function is the main function used by the cl_utils. py module. |
openstack/stacktach-timex | timex/parser.py | TimexParser.p_unit | def p_unit(self, p):
"""unit : SECOND
| MICROSECOND
| MINUTE
| HOUR
| DAY
| MONTH
| YEAR
"""
unit = TimexLexer.reserved_words[p[1]]
unit = unit.lower()
p[0] = unit | python | def p_unit(self, p):
"""unit : SECOND
| MICROSECOND
| MINUTE
| HOUR
| DAY
| MONTH
| YEAR
"""
unit = TimexLexer.reserved_words[p[1]]
unit = unit.lower()
p[0] = unit | [
"def",
"p_unit",
"(",
"self",
",",
"p",
")",
":",
"unit",
"=",
"TimexLexer",
".",
"reserved_words",
"[",
"p",
"[",
"1",
"]",
"]",
"unit",
"=",
"unit",
".",
"lower",
"(",
")",
"p",
"[",
"0",
"]",
"=",
"unit"
] | unit : SECOND
| MICROSECOND
| MINUTE
| HOUR
| DAY
| MONTH
| YEAR | [
"unit",
":",
"SECOND",
"|",
"MICROSECOND",
"|",
"MINUTE",
"|",
"HOUR",
"|",
"DAY",
"|",
"MONTH",
"|",
"YEAR"
] | 2c143c84cf91bc18ce9175022f4d9295e1fee18c | https://github.com/openstack/stacktach-timex/blob/2c143c84cf91bc18ce9175022f4d9295e1fee18c/timex/parser.py#L204-L215 | train | Parse the unit of the current token. |
networks-lab/tidyextractors | tidyextractors/tidygit/git_extractor.py | GitExtractor._extract | def _extract(self, source, *args, **kwargs):
"""
Extracts data from a local git repository. Mutates _data.
:param str source: The path to a local git repository.
:param args: Arbitrary arguments for extensibility.
:param kwargs: Arbitrary keyword arguments for extensibility.
... | python | def _extract(self, source, *args, **kwargs):
"""
Extracts data from a local git repository. Mutates _data.
:param str source: The path to a local git repository.
:param args: Arbitrary arguments for extensibility.
:param kwargs: Arbitrary keyword arguments for extensibility.
... | [
"def",
"_extract",
"(",
"self",
",",
"source",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Extract git test_data",
"self",
".",
"_data",
"=",
"extract_log",
"(",
"source",
")",
"# Shorten hashes",
"self",
".",
"_data",
"[",
"'hexsha'",
"]",
"... | Extracts data from a local git repository. Mutates _data.
:param str source: The path to a local git repository.
:param args: Arbitrary arguments for extensibility.
:param kwargs: Arbitrary keyword arguments for extensibility.
:return: None | [
"Extracts",
"data",
"from",
"a",
"local",
"git",
"repository",
".",
"Mutates",
"_data",
".",
":",
"param",
"str",
"source",
":",
"The",
"path",
"to",
"a",
"local",
"git",
"repository",
".",
":",
"param",
"args",
":",
"Arbitrary",
"arguments",
"for",
"ext... | 658448ed533beecf32adcc188fc64d1068d15ca6 | https://github.com/networks-lab/tidyextractors/blob/658448ed533beecf32adcc188fc64d1068d15ca6/tidyextractors/tidygit/git_extractor.py#L34-L47 | train | Extracts data from a local git repository. Mutates _data. |
networks-lab/tidyextractors | tidyextractors/tidygit/git_extractor.py | GitExtractor.commits | def commits(self, drop_collections=True):
"""
Returns a table of git log data, with "commits" as rows/observations.
:param bool drop_collections: Defaults to True. Indicates whether columns with lists/dicts/sets will be dropped.
:return: pandas.DataFrame
"""
base_df = s... | python | def commits(self, drop_collections=True):
"""
Returns a table of git log data, with "commits" as rows/observations.
:param bool drop_collections: Defaults to True. Indicates whether columns with lists/dicts/sets will be dropped.
:return: pandas.DataFrame
"""
base_df = s... | [
"def",
"commits",
"(",
"self",
",",
"drop_collections",
"=",
"True",
")",
":",
"base_df",
"=",
"self",
".",
"_data",
"if",
"drop_collections",
"is",
"True",
":",
"out_df",
"=",
"self",
".",
"_drop_collections",
"(",
"base_df",
")",
"else",
":",
"out_df",
... | Returns a table of git log data, with "commits" as rows/observations.
:param bool drop_collections: Defaults to True. Indicates whether columns with lists/dicts/sets will be dropped.
:return: pandas.DataFrame | [
"Returns",
"a",
"table",
"of",
"git",
"log",
"data",
"with",
"commits",
"as",
"rows",
"/",
"observations",
"."
] | 658448ed533beecf32adcc188fc64d1068d15ca6 | https://github.com/networks-lab/tidyextractors/blob/658448ed533beecf32adcc188fc64d1068d15ca6/tidyextractors/tidygit/git_extractor.py#L49-L62 | train | Returns a table of git log data with commits as rows and observations as rows. |
piotr-rusin/spam-lists | spam_lists/composites.py | RedirectURLResolver.get_locations | def get_locations(self, url):
"""Get valid location header values from responses.
:param url: a URL address. If a HEAD request sent to it
fails because the address has invalid schema, times out
or there is a connection error, the generator yields nothing.
:returns: valid redirec... | python | def get_locations(self, url):
"""Get valid location header values from responses.
:param url: a URL address. If a HEAD request sent to it
fails because the address has invalid schema, times out
or there is a connection error, the generator yields nothing.
:returns: valid redirec... | [
"def",
"get_locations",
"(",
"self",
",",
"url",
")",
":",
"if",
"not",
"is_valid_url",
"(",
"url",
")",
":",
"raise",
"InvalidURLError",
"(",
"'{} is not a valid URL'",
".",
"format",
"(",
"url",
")",
")",
"try",
":",
"response",
"=",
"self",
".",
"sess... | Get valid location header values from responses.
:param url: a URL address. If a HEAD request sent to it
fails because the address has invalid schema, times out
or there is a connection error, the generator yields nothing.
:returns: valid redirection addresses. If a request for
... | [
"Get",
"valid",
"location",
"header",
"values",
"from",
"responses",
"."
] | fd616e8761b28f3eaa503fee5e45f7748e8f88f2 | https://github.com/piotr-rusin/spam-lists/blob/fd616e8761b28f3eaa503fee5e45f7748e8f88f2/spam_lists/composites.py#L68-L98 | train | Get valid redirection addresses from a HEAD request. |
piotr-rusin/spam-lists | spam_lists/composites.py | RedirectURLResolver.get_new_locations | def get_new_locations(self, urls):
"""Get valid location header values for all given URLs.
The returned values are new, that is: they do not repeat any
value contained in the original input. Only unique values
are yielded.
:param urls: a list of URL addresses
:returns: ... | python | def get_new_locations(self, urls):
"""Get valid location header values for all given URLs.
The returned values are new, that is: they do not repeat any
value contained in the original input. Only unique values
are yielded.
:param urls: a list of URL addresses
:returns: ... | [
"def",
"get_new_locations",
"(",
"self",
",",
"urls",
")",
":",
"seen",
"=",
"set",
"(",
"urls",
")",
"for",
"i",
"in",
"urls",
":",
"for",
"k",
"in",
"self",
".",
"get_locations",
"(",
"i",
")",
":",
"if",
"k",
"not",
"in",
"seen",
":",
"seen",
... | Get valid location header values for all given URLs.
The returned values are new, that is: they do not repeat any
value contained in the original input. Only unique values
are yielded.
:param urls: a list of URL addresses
:returns: valid location header values from responses
... | [
"Get",
"valid",
"location",
"header",
"values",
"for",
"all",
"given",
"URLs",
"."
] | fd616e8761b28f3eaa503fee5e45f7748e8f88f2 | https://github.com/piotr-rusin/spam-lists/blob/fd616e8761b28f3eaa503fee5e45f7748e8f88f2/spam_lists/composites.py#L100-L116 | train | Get valid location header values for all given URLs. |
piotr-rusin/spam-lists | spam_lists/composites.py | RedirectURLResolver.get_urls_and_locations | def get_urls_and_locations(self, urls):
"""Get URLs and their redirection addresses.
:param urls: a list of URL addresses
:returns: an instance of CachedIterable containing given URLs
and valid location header values of their responses
"""
location_generator = self.get_n... | python | def get_urls_and_locations(self, urls):
"""Get URLs and their redirection addresses.
:param urls: a list of URL addresses
:returns: an instance of CachedIterable containing given URLs
and valid location header values of their responses
"""
location_generator = self.get_n... | [
"def",
"get_urls_and_locations",
"(",
"self",
",",
"urls",
")",
":",
"location_generator",
"=",
"self",
".",
"get_new_locations",
"(",
"urls",
")",
"initial_cache",
"=",
"list",
"(",
"set",
"(",
"urls",
")",
")",
"return",
"CachedIterable",
"(",
"location_gene... | Get URLs and their redirection addresses.
:param urls: a list of URL addresses
:returns: an instance of CachedIterable containing given URLs
and valid location header values of their responses | [
"Get",
"URLs",
"and",
"their",
"redirection",
"addresses",
"."
] | fd616e8761b28f3eaa503fee5e45f7748e8f88f2 | https://github.com/piotr-rusin/spam-lists/blob/fd616e8761b28f3eaa503fee5e45f7748e8f88f2/spam_lists/composites.py#L118-L127 | train | Get URLs and their redirection addresses. |
threema-ch/ocspresponder | ocspresponder/__init__.py | OCSPResponder._handle_get | def _handle_get(self, request_data):
"""
An OCSP GET request contains the DER-in-base64 encoded OCSP request in the
HTTP request URL.
"""
der = base64.b64decode(request_data)
ocsp_request = self._parse_ocsp_request(der)
return self._build_http_response(ocsp_reques... | python | def _handle_get(self, request_data):
"""
An OCSP GET request contains the DER-in-base64 encoded OCSP request in the
HTTP request URL.
"""
der = base64.b64decode(request_data)
ocsp_request = self._parse_ocsp_request(der)
return self._build_http_response(ocsp_reques... | [
"def",
"_handle_get",
"(",
"self",
",",
"request_data",
")",
":",
"der",
"=",
"base64",
".",
"b64decode",
"(",
"request_data",
")",
"ocsp_request",
"=",
"self",
".",
"_parse_ocsp_request",
"(",
"der",
")",
"return",
"self",
".",
"_build_http_response",
"(",
... | An OCSP GET request contains the DER-in-base64 encoded OCSP request in the
HTTP request URL. | [
"An",
"OCSP",
"GET",
"request",
"contains",
"the",
"DER",
"-",
"in",
"-",
"base64",
"encoded",
"OCSP",
"request",
"in",
"the",
"HTTP",
"request",
"URL",
"."
] | b9486af68dd02b84e01bedabe4f6843a6ff0f698 | https://github.com/threema-ch/ocspresponder/blob/b9486af68dd02b84e01bedabe4f6843a6ff0f698/ocspresponder/__init__.py#L111-L118 | train | Handle an OCSP GET request. |
threema-ch/ocspresponder | ocspresponder/__init__.py | OCSPResponder._handle_post | def _handle_post(self):
"""
An OCSP POST request contains the DER encoded OCSP request in the HTTP
request body.
"""
der = request.body.read()
ocsp_request = self._parse_ocsp_request(der)
return self._build_http_response(ocsp_request) | python | def _handle_post(self):
"""
An OCSP POST request contains the DER encoded OCSP request in the HTTP
request body.
"""
der = request.body.read()
ocsp_request = self._parse_ocsp_request(der)
return self._build_http_response(ocsp_request) | [
"def",
"_handle_post",
"(",
"self",
")",
":",
"der",
"=",
"request",
".",
"body",
".",
"read",
"(",
")",
"ocsp_request",
"=",
"self",
".",
"_parse_ocsp_request",
"(",
"der",
")",
"return",
"self",
".",
"_build_http_response",
"(",
"ocsp_request",
")"
] | An OCSP POST request contains the DER encoded OCSP request in the HTTP
request body. | [
"An",
"OCSP",
"POST",
"request",
"contains",
"the",
"DER",
"encoded",
"OCSP",
"request",
"in",
"the",
"HTTP",
"request",
"body",
"."
] | b9486af68dd02b84e01bedabe4f6843a6ff0f698 | https://github.com/threema-ch/ocspresponder/blob/b9486af68dd02b84e01bedabe4f6843a6ff0f698/ocspresponder/__init__.py#L120-L127 | train | Handle an OCSP POST request. |
threema-ch/ocspresponder | ocspresponder/__init__.py | OCSPResponder._build_ocsp_response | def _build_ocsp_response(self, ocsp_request: OCSPRequest) -> OCSPResponse:
"""
Create and return an OCSP response from an OCSP request.
"""
# Get the certificate serial
tbs_request = ocsp_request['tbs_request']
request_list = tbs_request['request_list']
if len(req... | python | def _build_ocsp_response(self, ocsp_request: OCSPRequest) -> OCSPResponse:
"""
Create and return an OCSP response from an OCSP request.
"""
# Get the certificate serial
tbs_request = ocsp_request['tbs_request']
request_list = tbs_request['request_list']
if len(req... | [
"def",
"_build_ocsp_response",
"(",
"self",
",",
"ocsp_request",
":",
"OCSPRequest",
")",
"->",
"OCSPResponse",
":",
"# Get the certificate serial",
"tbs_request",
"=",
"ocsp_request",
"[",
"'tbs_request'",
"]",
"request_list",
"=",
"tbs_request",
"[",
"'request_list'",... | Create and return an OCSP response from an OCSP request. | [
"Create",
"and",
"return",
"an",
"OCSP",
"response",
"from",
"an",
"OCSP",
"request",
"."
] | b9486af68dd02b84e01bedabe4f6843a6ff0f698 | https://github.com/threema-ch/ocspresponder/blob/b9486af68dd02b84e01bedabe4f6843a6ff0f698/ocspresponder/__init__.py#L139-L217 | train | Builds an OCSP response from an OCSP request. |
rambleraptor/amusement | amusement/parks/universal/UniversalPark.py | UniversalPark._buildPark | def _buildPark(self):
token = self._get_token()
ride_page = self._get_request(token, self.getUrl())
show_page = self._get_request(token, SHOW_URL)
for ride in ride_page['Results']:
if ride['VenueId'] == self.getId():
self._make_attraction(ride)
"""
... | python | def _buildPark(self):
token = self._get_token()
ride_page = self._get_request(token, self.getUrl())
show_page = self._get_request(token, SHOW_URL)
for ride in ride_page['Results']:
if ride['VenueId'] == self.getId():
self._make_attraction(ride)
"""
... | [
"def",
"_buildPark",
"(",
"self",
")",
":",
"token",
"=",
"self",
".",
"_get_token",
"(",
")",
"ride_page",
"=",
"self",
".",
"_get_request",
"(",
"token",
",",
"self",
".",
"getUrl",
"(",
")",
")",
"show_page",
"=",
"self",
".",
"_get_request",
"(",
... | for show in page['Shows']:
if show['VenueId'] == self.getId():
self._make_show(show) | [
"for",
"show",
"in",
"page",
"[",
"Shows",
"]",
":",
"if",
"show",
"[",
"VenueId",
"]",
"==",
"self",
".",
"getId",
"()",
":",
"self",
".",
"_make_show",
"(",
"show",
")"
] | ec850035747a5b0549f9ea2ee4399bff035460be | https://github.com/rambleraptor/amusement/blob/ec850035747a5b0549f9ea2ee4399bff035460be/amusement/parks/universal/UniversalPark.py#L34-L46 | train | Builds the dark and dark tags for the user. |
nitely/django-hooks | hooks/templatetags/hooks_tags.py | hook_tag | def hook_tag(context, name, *args, **kwargs):
"""
Hook tag to call within templates
:param dict context: This is automatically passed,\
contains the template state/variables
:param str name: The hook which will be dispatched
:param \*args: Positional arguments, will be passed to hook callbacks
... | python | def hook_tag(context, name, *args, **kwargs):
"""
Hook tag to call within templates
:param dict context: This is automatically passed,\
contains the template state/variables
:param str name: The hook which will be dispatched
:param \*args: Positional arguments, will be passed to hook callbacks
... | [
"def",
"hook_tag",
"(",
"context",
",",
"name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"format_html_join",
"(",
"sep",
"=",
"\"\\n\"",
",",
"format_string",
"=",
"\"{}\"",
",",
"args_generator",
"=",
"(",
"(",
"response",
",",
"... | Hook tag to call within templates
:param dict context: This is automatically passed,\
contains the template state/variables
:param str name: The hook which will be dispatched
:param \*args: Positional arguments, will be passed to hook callbacks
:param \*\*kwargs: Keyword arguments, will be passed t... | [
"Hook",
"tag",
"to",
"call",
"within",
"templates"
] | 26ea2150c9be110e90b9ee60fbfd1065ac30ab1d | https://github.com/nitely/django-hooks/blob/26ea2150c9be110e90b9ee60fbfd1065ac30ab1d/hooks/templatetags/hooks_tags.py#L15-L35 | train | Returns a string that can be used to call a hook within a sequence of templates. |
nitely/django-hooks | hooks/templatetags/hooks_tags.py | template_hook_collect | def template_hook_collect(module, hook_name, *args, **kwargs):
"""
Helper to include in your own templatetag, for static TemplateHooks
Example::
import myhooks
from hooks.templatetags import template_hook_collect
@register.simple_tag(takes_context=True)
def hook(context, n... | python | def template_hook_collect(module, hook_name, *args, **kwargs):
"""
Helper to include in your own templatetag, for static TemplateHooks
Example::
import myhooks
from hooks.templatetags import template_hook_collect
@register.simple_tag(takes_context=True)
def hook(context, n... | [
"def",
"template_hook_collect",
"(",
"module",
",",
"hook_name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"templatehook",
"=",
"getattr",
"(",
"module",
",",
"hook_name",
")",
"except",
"AttributeError",
":",
"return",
"\"\"",
"retu... | Helper to include in your own templatetag, for static TemplateHooks
Example::
import myhooks
from hooks.templatetags import template_hook_collect
@register.simple_tag(takes_context=True)
def hook(context, name, *args, **kwargs):
return template_hook_collect(myhooks, na... | [
"Helper",
"to",
"include",
"in",
"your",
"own",
"templatetag",
"for",
"static",
"TemplateHooks"
] | 26ea2150c9be110e90b9ee60fbfd1065ac30ab1d | https://github.com/nitely/django-hooks/blob/26ea2150c9be110e90b9ee60fbfd1065ac30ab1d/hooks/templatetags/hooks_tags.py#L38-L71 | train | This function is used to include in your own templatetag for static TemplateHooks. |
networks-lab/tidyextractors | tidyextractors/tidymbox/mbox_extractor.py | MboxExtractor._extract | def _extract(self, source, *args, **kwargs):
"""
Extracts data from mbox files. Mutates _data.
:param str source: The path to one or more mbox files.
:param args: Arbitrary arguments for extensibility.
:param kwargs: Arbitrary keyword arguments for extensibility.
:return... | python | def _extract(self, source, *args, **kwargs):
"""
Extracts data from mbox files. Mutates _data.
:param str source: The path to one or more mbox files.
:param args: Arbitrary arguments for extensibility.
:param kwargs: Arbitrary keyword arguments for extensibility.
:return... | [
"def",
"_extract",
"(",
"self",
",",
"source",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Extract data",
"self",
".",
"_data",
"=",
"mbox_to_pandas",
"(",
"source",
")",
"self",
".",
"_data",
"[",
"'MessageID'",
"]",
"=",
"pd",
".",
"Ser... | Extracts data from mbox files. Mutates _data.
:param str source: The path to one or more mbox files.
:param args: Arbitrary arguments for extensibility.
:param kwargs: Arbitrary keyword arguments for extensibility.
:return: None | [
"Extracts",
"data",
"from",
"mbox",
"files",
".",
"Mutates",
"_data",
"."
] | 658448ed533beecf32adcc188fc64d1068d15ca6 | https://github.com/networks-lab/tidyextractors/blob/658448ed533beecf32adcc188fc64d1068d15ca6/tidyextractors/tidymbox/mbox_extractor.py#L36-L47 | train | Extracts data from mbox files. Mutates _data. |
networks-lab/tidyextractors | tidyextractors/tidymbox/mbox_extractor.py | MboxExtractor.emails | def emails(self, drop_collections = True):
"""
Returns a table of mbox message data, with "messages" as rows/observations.
:param bool drop_collections: Defaults to True. Indicates whether columns with lists/dicts/sets will be dropped.
:return: pandas.DataFrame
"""
base... | python | def emails(self, drop_collections = True):
"""
Returns a table of mbox message data, with "messages" as rows/observations.
:param bool drop_collections: Defaults to True. Indicates whether columns with lists/dicts/sets will be dropped.
:return: pandas.DataFrame
"""
base... | [
"def",
"emails",
"(",
"self",
",",
"drop_collections",
"=",
"True",
")",
":",
"base_df",
"=",
"self",
".",
"_data",
"if",
"drop_collections",
"is",
"True",
":",
"out_df",
"=",
"self",
".",
"_drop_collections",
"(",
"base_df",
")",
"else",
":",
"out_df",
... | Returns a table of mbox message data, with "messages" as rows/observations.
:param bool drop_collections: Defaults to True. Indicates whether columns with lists/dicts/sets will be dropped.
:return: pandas.DataFrame | [
"Returns",
"a",
"table",
"of",
"mbox",
"message",
"data",
"with",
"messages",
"as",
"rows",
"/",
"observations",
"."
] | 658448ed533beecf32adcc188fc64d1068d15ca6 | https://github.com/networks-lab/tidyextractors/blob/658448ed533beecf32adcc188fc64d1068d15ca6/tidyextractors/tidymbox/mbox_extractor.py#L49-L62 | train | Returns a table of mbox message data with messages as rows and observations as rows. |
networks-lab/tidyextractors | tidyextractors/tidymbox/mbox_extractor.py | MboxExtractor.sends | def sends(self):
"""
Returns a table of mbox message data, with "sender/recipient" pairs as rows/observations.
.. note::
Rows may have a recipient from either "TO" or "CC". SendType column specifies this for each row.
.. note::
drop_collections is not availabl... | python | def sends(self):
"""
Returns a table of mbox message data, with "sender/recipient" pairs as rows/observations.
.. note::
Rows may have a recipient from either "TO" or "CC". SendType column specifies this for each row.
.. note::
drop_collections is not availabl... | [
"def",
"sends",
"(",
"self",
")",
":",
"# Expand on each \"to\" field",
"on_to_df",
"=",
"self",
".",
"expand_on",
"(",
"'From'",
",",
"'To'",
",",
"rename1",
"=",
"'From'",
",",
"rename2",
"=",
"'Recipient'",
")",
"on_cc_df",
"=",
"self",
".",
"expand_on",
... | Returns a table of mbox message data, with "sender/recipient" pairs as rows/observations.
.. note::
Rows may have a recipient from either "TO" or "CC". SendType column specifies this for each row.
.. note::
drop_collections is not available for this method, since there are no... | [
"Returns",
"a",
"table",
"of",
"mbox",
"message",
"data",
"with",
"sender",
"/",
"recipient",
"pairs",
"as",
"rows",
"/",
"observations",
"."
] | 658448ed533beecf32adcc188fc64d1068d15ca6 | https://github.com/networks-lab/tidyextractors/blob/658448ed533beecf32adcc188fc64d1068d15ca6/tidyextractors/tidymbox/mbox_extractor.py#L64-L89 | train | Returns a table of mbox message data with sender and recipient pairs as rows and observations as rows. |
Azure/azure-python-devtools | src/azure_devtools/ci_tools/bot_framework.py | build_from_issue_comment | def build_from_issue_comment(gh_token, body):
"""Create a WebhookMetadata from a comment added to an issue.
"""
if body["action"] in ["created", "edited"]:
github_con = Github(gh_token)
repo = github_con.get_repo(body['repository']['full_name'])
issue = repo.get_issue(body['issue']['... | python | def build_from_issue_comment(gh_token, body):
"""Create a WebhookMetadata from a comment added to an issue.
"""
if body["action"] in ["created", "edited"]:
github_con = Github(gh_token)
repo = github_con.get_repo(body['repository']['full_name'])
issue = repo.get_issue(body['issue']['... | [
"def",
"build_from_issue_comment",
"(",
"gh_token",
",",
"body",
")",
":",
"if",
"body",
"[",
"\"action\"",
"]",
"in",
"[",
"\"created\"",
",",
"\"edited\"",
"]",
":",
"github_con",
"=",
"Github",
"(",
"gh_token",
")",
"repo",
"=",
"github_con",
".",
"get_... | Create a WebhookMetadata from a comment added to an issue. | [
"Create",
"a",
"WebhookMetadata",
"from",
"a",
"comment",
"added",
"to",
"an",
"issue",
"."
] | 2bf87b1f3cedd2b26fb2e4fd47a9baf435dcf936 | https://github.com/Azure/azure-python-devtools/blob/2bf87b1f3cedd2b26fb2e4fd47a9baf435dcf936/src/azure_devtools/ci_tools/bot_framework.py#L25-L39 | train | Create a WebhookMetadata from a comment added to an issue. |
Azure/azure-python-devtools | src/azure_devtools/ci_tools/bot_framework.py | build_from_issues | def build_from_issues(gh_token, body):
"""Create a WebhookMetadata from an opening issue text.
"""
if body["action"] in ["opened", "edited"]:
github_con = Github(gh_token)
repo = github_con.get_repo(body['repository']['full_name'])
issue = repo.get_issue(body['issue']['number'])
... | python | def build_from_issues(gh_token, body):
"""Create a WebhookMetadata from an opening issue text.
"""
if body["action"] in ["opened", "edited"]:
github_con = Github(gh_token)
repo = github_con.get_repo(body['repository']['full_name'])
issue = repo.get_issue(body['issue']['number'])
... | [
"def",
"build_from_issues",
"(",
"gh_token",
",",
"body",
")",
":",
"if",
"body",
"[",
"\"action\"",
"]",
"in",
"[",
"\"opened\"",
",",
"\"edited\"",
"]",
":",
"github_con",
"=",
"Github",
"(",
"gh_token",
")",
"repo",
"=",
"github_con",
".",
"get_repo",
... | Create a WebhookMetadata from an opening issue text. | [
"Create",
"a",
"WebhookMetadata",
"from",
"an",
"opening",
"issue",
"text",
"."
] | 2bf87b1f3cedd2b26fb2e4fd47a9baf435dcf936 | https://github.com/Azure/azure-python-devtools/blob/2bf87b1f3cedd2b26fb2e4fd47a9baf435dcf936/src/azure_devtools/ci_tools/bot_framework.py#L41-L51 | train | Create a WebhookMetadata from an opening issue text. |
Azure/azure-python-devtools | src/azure_devtools/ci_tools/bot_framework.py | BotHandler.orders | def orders(self):
"""Return method tagged "order" in the handler.
"""
return [order_cmd for order_cmd in dir(self.handler)
if getattr(getattr(self.handler, order_cmd), "bot_order", False)] | python | def orders(self):
"""Return method tagged "order" in the handler.
"""
return [order_cmd for order_cmd in dir(self.handler)
if getattr(getattr(self.handler, order_cmd), "bot_order", False)] | [
"def",
"orders",
"(",
"self",
")",
":",
"return",
"[",
"order_cmd",
"for",
"order_cmd",
"in",
"dir",
"(",
"self",
".",
"handler",
")",
"if",
"getattr",
"(",
"getattr",
"(",
"self",
".",
"handler",
",",
"order_cmd",
")",
",",
"\"bot_order\"",
",",
"Fals... | Return method tagged "order" in the handler. | [
"Return",
"method",
"tagged",
"order",
"in",
"the",
"handler",
"."
] | 2bf87b1f3cedd2b26fb2e4fd47a9baf435dcf936 | https://github.com/Azure/azure-python-devtools/blob/2bf87b1f3cedd2b26fb2e4fd47a9baf435dcf936/src/azure_devtools/ci_tools/bot_framework.py#L80-L84 | train | Return method tagged order in the handler.
|
TkTech/Jawa | jawa/util/flags.py | Flags.set | def set(self, name, value):
"""
Sets the value of the field `name` to `value`, which is `True` or
`False`.
"""
flag = self.flags[name]
self._value = (self.value | flag) if value else (self.value & ~flag) | python | def set(self, name, value):
"""
Sets the value of the field `name` to `value`, which is `True` or
`False`.
"""
flag = self.flags[name]
self._value = (self.value | flag) if value else (self.value & ~flag) | [
"def",
"set",
"(",
"self",
",",
"name",
",",
"value",
")",
":",
"flag",
"=",
"self",
".",
"flags",
"[",
"name",
"]",
"self",
".",
"_value",
"=",
"(",
"self",
".",
"value",
"|",
"flag",
")",
"if",
"value",
"else",
"(",
"self",
".",
"value",
"&",... | Sets the value of the field `name` to `value`, which is `True` or
`False`. | [
"Sets",
"the",
"value",
"of",
"the",
"field",
"name",
"to",
"value",
"which",
"is",
"True",
"or",
"False",
"."
] | 94c8424e699029ac33fbc0e866fff0ecb2742289 | https://github.com/TkTech/Jawa/blob/94c8424e699029ac33fbc0e866fff0ecb2742289/jawa/util/flags.py#L40-L46 | train | Sets the value of the field name to value which is True or False. |
TkTech/Jawa | jawa/util/flags.py | Flags.to_dict | def to_dict(self):
"""
Returns this `Flags` object's fields as a dictionary.
"""
return dict((k, self.get(k)) for k in self.flags.keys()) | python | def to_dict(self):
"""
Returns this `Flags` object's fields as a dictionary.
"""
return dict((k, self.get(k)) for k in self.flags.keys()) | [
"def",
"to_dict",
"(",
"self",
")",
":",
"return",
"dict",
"(",
"(",
"k",
",",
"self",
".",
"get",
"(",
"k",
")",
")",
"for",
"k",
"in",
"self",
".",
"flags",
".",
"keys",
"(",
")",
")"
] | Returns this `Flags` object's fields as a dictionary. | [
"Returns",
"this",
"Flags",
"object",
"s",
"fields",
"as",
"a",
"dictionary",
"."
] | 94c8424e699029ac33fbc0e866fff0ecb2742289 | https://github.com/TkTech/Jawa/blob/94c8424e699029ac33fbc0e866fff0ecb2742289/jawa/util/flags.py#L58-L62 | train | Returns this Flags object s fields as a dictionary. |
piotr-rusin/spam-lists | spam_lists/host_collections.py | BaseHostCollection.add | def add(self, host_value):
"""Add the given value to the collection.
:param host: an ip address or a hostname
:raises InvalidHostError: raised when the given value
is not a valid ip address nor a hostname
"""
host_obj = self._host_factory(host_value)
if self._get... | python | def add(self, host_value):
"""Add the given value to the collection.
:param host: an ip address or a hostname
:raises InvalidHostError: raised when the given value
is not a valid ip address nor a hostname
"""
host_obj = self._host_factory(host_value)
if self._get... | [
"def",
"add",
"(",
"self",
",",
"host_value",
")",
":",
"host_obj",
"=",
"self",
".",
"_host_factory",
"(",
"host_value",
")",
"if",
"self",
".",
"_get_match",
"(",
"host_obj",
")",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_add_new",
"(",
"hos... | Add the given value to the collection.
:param host: an ip address or a hostname
:raises InvalidHostError: raised when the given value
is not a valid ip address nor a hostname | [
"Add",
"the",
"given",
"value",
"to",
"the",
"collection",
"."
] | fd616e8761b28f3eaa503fee5e45f7748e8f88f2 | https://github.com/piotr-rusin/spam-lists/blob/fd616e8761b28f3eaa503fee5e45f7748e8f88f2/spam_lists/host_collections.py#L64-L74 | train | Adds the given value to the collection. |
piotr-rusin/spam-lists | spam_lists/host_collections.py | SortedHostCollection._get_match | def _get_match(self, host_object):
"""Get an item matching the given host object.
The item may be either a parent domain or identical value.
Parent domains and existing identical values always precede
insertion point for given value - therefore, we treat
an item just before inse... | python | def _get_match(self, host_object):
"""Get an item matching the given host object.
The item may be either a parent domain or identical value.
Parent domains and existing identical values always precede
insertion point for given value - therefore, we treat
an item just before inse... | [
"def",
"_get_match",
"(",
"self",
",",
"host_object",
")",
":",
"i",
"=",
"self",
".",
"_get_insertion_point",
"(",
"host_object",
")",
"potential_match",
"=",
"None",
"try",
":",
"potential_match",
"=",
"self",
"[",
"i",
"-",
"1",
"]",
"except",
"IndexErr... | Get an item matching the given host object.
The item may be either a parent domain or identical value.
Parent domains and existing identical values always precede
insertion point for given value - therefore, we treat
an item just before insertion point as potential match.
:para... | [
"Get",
"an",
"item",
"matching",
"the",
"given",
"host",
"object",
"."
] | fd616e8761b28f3eaa503fee5e45f7748e8f88f2 | https://github.com/piotr-rusin/spam-lists/blob/fd616e8761b28f3eaa503fee5e45f7748e8f88f2/spam_lists/host_collections.py#L118-L138 | train | Get an item matching the given host object. |
piotr-rusin/spam-lists | spam_lists/host_collections.py | SortedHostCollection._add_new | def _add_new(self, host_object):
"""Add a new host to the collection.
Before a new hostname can be added, all its subdomains already
present in the collection must be removed. Since the collection
is sorted, we can limit our search for them to a slice of
the collection starting ... | python | def _add_new(self, host_object):
"""Add a new host to the collection.
Before a new hostname can be added, all its subdomains already
present in the collection must be removed. Since the collection
is sorted, we can limit our search for them to a slice of
the collection starting ... | [
"def",
"_add_new",
"(",
"self",
",",
"host_object",
")",
":",
"i",
"=",
"self",
".",
"_get_insertion_point",
"(",
"host_object",
")",
"for",
"listed",
"in",
"self",
"[",
"i",
":",
"]",
":",
"if",
"not",
"listed",
".",
"is_subdomain",
"(",
"host_object",
... | Add a new host to the collection.
Before a new hostname can be added, all its subdomains already
present in the collection must be removed. Since the collection
is sorted, we can limit our search for them to a slice of
the collection starting from insertion point and ending with
... | [
"Add",
"a",
"new",
"host",
"to",
"the",
"collection",
"."
] | fd616e8761b28f3eaa503fee5e45f7748e8f88f2 | https://github.com/piotr-rusin/spam-lists/blob/fd616e8761b28f3eaa503fee5e45f7748e8f88f2/spam_lists/host_collections.py#L140-L160 | train | Add a new host to the collection. |
TkTech/Jawa | jawa/util/descriptor.py | method_descriptor | def method_descriptor(descriptor: str) -> MethodDescriptor:
"""
Parses a Method descriptor as described in section 4.3.3 of the JVM
specification.
"""
end_para = descriptor.find(')')
returns = descriptor[end_para + 1:]
args = descriptor[1:end_para]
return MethodDescriptor(
parse... | python | def method_descriptor(descriptor: str) -> MethodDescriptor:
"""
Parses a Method descriptor as described in section 4.3.3 of the JVM
specification.
"""
end_para = descriptor.find(')')
returns = descriptor[end_para + 1:]
args = descriptor[1:end_para]
return MethodDescriptor(
parse... | [
"def",
"method_descriptor",
"(",
"descriptor",
":",
"str",
")",
"->",
"MethodDescriptor",
":",
"end_para",
"=",
"descriptor",
".",
"find",
"(",
"')'",
")",
"returns",
"=",
"descriptor",
"[",
"end_para",
"+",
"1",
":",
"]",
"args",
"=",
"descriptor",
"[",
... | Parses a Method descriptor as described in section 4.3.3 of the JVM
specification. | [
"Parses",
"a",
"Method",
"descriptor",
"as",
"described",
"in",
"section",
"4",
".",
"3",
".",
"3",
"of",
"the",
"JVM",
"specification",
"."
] | 94c8424e699029ac33fbc0e866fff0ecb2742289 | https://github.com/TkTech/Jawa/blob/94c8424e699029ac33fbc0e866fff0ecb2742289/jawa/util/descriptor.py#L22-L37 | train | Parses a Method descriptor as described in section 4. 3. 3 of the JVM
specification. |
TkTech/Jawa | jawa/util/descriptor.py | parse_descriptor | def parse_descriptor(descriptor: str) -> list:
"""
Uses a tiny state machine to parse JVM descriptors. To get useful wrappers
around the results, use :py:func:`jawa.core.descriptor.method_descriptor`
or :py:func:`jawa.core.descriptor.field_descriptor`.
"""
# States:
# 10 == NORMAL,
# ... | python | def parse_descriptor(descriptor: str) -> list:
"""
Uses a tiny state machine to parse JVM descriptors. To get useful wrappers
around the results, use :py:func:`jawa.core.descriptor.method_descriptor`
or :py:func:`jawa.core.descriptor.field_descriptor`.
"""
# States:
# 10 == NORMAL,
# ... | [
"def",
"parse_descriptor",
"(",
"descriptor",
":",
"str",
")",
"->",
"list",
":",
"# States:",
"# 10 == NORMAL,",
"# 20 == OBJECT REFERENCE",
"state",
"=",
"10",
"tokens",
"=",
"[",
"]",
"token",
"=",
"[",
"]",
"dimensions",
"=",
"0",
"for",
"char",
"in"... | Uses a tiny state machine to parse JVM descriptors. To get useful wrappers
around the results, use :py:func:`jawa.core.descriptor.method_descriptor`
or :py:func:`jawa.core.descriptor.field_descriptor`. | [
"Uses",
"a",
"tiny",
"state",
"machine",
"to",
"parse",
"JVM",
"descriptors",
".",
"To",
"get",
"useful",
"wrappers",
"around",
"the",
"results",
"use",
":",
"py",
":",
"func",
":",
"jawa",
".",
"core",
".",
"descriptor",
".",
"method_descriptor",
"or",
... | 94c8424e699029ac33fbc0e866fff0ecb2742289 | https://github.com/TkTech/Jawa/blob/94c8424e699029ac33fbc0e866fff0ecb2742289/jawa/util/descriptor.py#L64-L92 | train | Parses a JVM descriptor into a list of JVM types. |
qwiglydee/drf-mongo-filters | drf_mongo_filters/filters.py | Filter.make_field | def make_field(self, **kwargs):
""" create serializer field """
kwargs['required'] = False
kwargs['allow_null'] = True
return self.field_class(**kwargs) | python | def make_field(self, **kwargs):
""" create serializer field """
kwargs['required'] = False
kwargs['allow_null'] = True
return self.field_class(**kwargs) | [
"def",
"make_field",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'required'",
"]",
"=",
"False",
"kwargs",
"[",
"'allow_null'",
"]",
"=",
"True",
"return",
"self",
".",
"field_class",
"(",
"*",
"*",
"kwargs",
")"
] | create serializer field | [
"create",
"serializer",
"field"
] | f7e397c329bac6d7b8cbb1df70d96eccdcfbc1ec | https://github.com/qwiglydee/drf-mongo-filters/blob/f7e397c329bac6d7b8cbb1df70d96eccdcfbc1ec/drf_mongo_filters/filters.py#L48-L52 | train | create serializer field |
qwiglydee/drf-mongo-filters | drf_mongo_filters/filters.py | Filter.bind | def bind(self, name, filterset):
""" attach filter to filterset
gives a name to use to extract arguments from querydict
"""
if self.name is not None:
name = self.name
self.field.bind(name, self) | python | def bind(self, name, filterset):
""" attach filter to filterset
gives a name to use to extract arguments from querydict
"""
if self.name is not None:
name = self.name
self.field.bind(name, self) | [
"def",
"bind",
"(",
"self",
",",
"name",
",",
"filterset",
")",
":",
"if",
"self",
".",
"name",
"is",
"not",
"None",
":",
"name",
"=",
"self",
".",
"name",
"self",
".",
"field",
".",
"bind",
"(",
"name",
",",
"self",
")"
] | attach filter to filterset
gives a name to use to extract arguments from querydict | [
"attach",
"filter",
"to",
"filterset"
] | f7e397c329bac6d7b8cbb1df70d96eccdcfbc1ec | https://github.com/qwiglydee/drf-mongo-filters/blob/f7e397c329bac6d7b8cbb1df70d96eccdcfbc1ec/drf_mongo_filters/filters.py#L54-L61 | train | bind to the filterset that will be used to extract arguments from the querydict |
qwiglydee/drf-mongo-filters | drf_mongo_filters/filters.py | Filter.parse_value | def parse_value(self, querydict):
""" extract value
extarct value from querydict and convert it to native
missing and empty values result to None
"""
value = self.field.get_value(querydict)
if value in (None, fields.empty, ''):
return None
return self... | python | def parse_value(self, querydict):
""" extract value
extarct value from querydict and convert it to native
missing and empty values result to None
"""
value = self.field.get_value(querydict)
if value in (None, fields.empty, ''):
return None
return self... | [
"def",
"parse_value",
"(",
"self",
",",
"querydict",
")",
":",
"value",
"=",
"self",
".",
"field",
".",
"get_value",
"(",
"querydict",
")",
"if",
"value",
"in",
"(",
"None",
",",
"fields",
".",
"empty",
",",
"''",
")",
":",
"return",
"None",
"return"... | extract value
extarct value from querydict and convert it to native
missing and empty values result to None | [
"extract",
"value"
] | f7e397c329bac6d7b8cbb1df70d96eccdcfbc1ec | https://github.com/qwiglydee/drf-mongo-filters/blob/f7e397c329bac6d7b8cbb1df70d96eccdcfbc1ec/drf_mongo_filters/filters.py#L67-L76 | train | extract value from querydict and convert it to internal value |
qwiglydee/drf-mongo-filters | drf_mongo_filters/filters.py | Filter.filter_params | def filter_params(self, value):
""" return filtering params """
if value is None:
return {}
key = self.target
if self.lookup_type is not None:
key += '__' + self.lookup_type
return { key: value } | python | def filter_params(self, value):
""" return filtering params """
if value is None:
return {}
key = self.target
if self.lookup_type is not None:
key += '__' + self.lookup_type
return { key: value } | [
"def",
"filter_params",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"None",
":",
"return",
"{",
"}",
"key",
"=",
"self",
".",
"target",
"if",
"self",
".",
"lookup_type",
"is",
"not",
"None",
":",
"key",
"+=",
"'__'",
"+",
"self",
".",... | return filtering params | [
"return",
"filtering",
"params"
] | f7e397c329bac6d7b8cbb1df70d96eccdcfbc1ec | https://github.com/qwiglydee/drf-mongo-filters/blob/f7e397c329bac6d7b8cbb1df70d96eccdcfbc1ec/drf_mongo_filters/filters.py#L78-L86 | train | return filtering params |
qwiglydee/drf-mongo-filters | drf_mongo_filters/filters.py | ReferenceFilter.filter_params | def filter_params(self, value):
""" return filtering params """
if value is None:
return {}
target = ".".join(self.field.source_attrs)
return { '__raw__': { target + ".$id": value } } | python | def filter_params(self, value):
""" return filtering params """
if value is None:
return {}
target = ".".join(self.field.source_attrs)
return { '__raw__': { target + ".$id": value } } | [
"def",
"filter_params",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"None",
":",
"return",
"{",
"}",
"target",
"=",
"\".\"",
".",
"join",
"(",
"self",
".",
"field",
".",
"source_attrs",
")",
"return",
"{",
"'__raw__'",
":",
"{",
"target... | return filtering params | [
"return",
"filtering",
"params"
] | f7e397c329bac6d7b8cbb1df70d96eccdcfbc1ec | https://github.com/qwiglydee/drf-mongo-filters/blob/f7e397c329bac6d7b8cbb1df70d96eccdcfbc1ec/drf_mongo_filters/filters.py#L126-L131 | train | return filtering params |
qwiglydee/drf-mongo-filters | drf_mongo_filters/filters.py | RangeFilter.filter_params | def filter_params(self, value):
""" return filtering params """
if value is None:
return {}
val_min = value.get('min', None)
val_max = value.get('max', None)
params = {}
if val_min == val_max:
return { self.target: val_min }
key = self.t... | python | def filter_params(self, value):
""" return filtering params """
if value is None:
return {}
val_min = value.get('min', None)
val_max = value.get('max', None)
params = {}
if val_min == val_max:
return { self.target: val_min }
key = self.t... | [
"def",
"filter_params",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"None",
":",
"return",
"{",
"}",
"val_min",
"=",
"value",
".",
"get",
"(",
"'min'",
",",
"None",
")",
"val_max",
"=",
"value",
".",
"get",
"(",
"'max'",
",",
"None",
... | return filtering params | [
"return",
"filtering",
"params"
] | f7e397c329bac6d7b8cbb1df70d96eccdcfbc1ec | https://github.com/qwiglydee/drf-mongo-filters/blob/f7e397c329bac6d7b8cbb1df70d96eccdcfbc1ec/drf_mongo_filters/filters.py#L161-L179 | train | return filtering params |
thespacedoctor/polyglot | polyglot/printpdf.py | printpdf.get | def get(self):
"""
*get the PDF*
**Return:**
- ``pdfPath`` -- the path to the generated PDF
"""
self.log.debug('starting the ``get`` method')
# APPEND TO FILENAME?
if not self.append:
self.append = ""
if not self.readability:
... | python | def get(self):
"""
*get the PDF*
**Return:**
- ``pdfPath`` -- the path to the generated PDF
"""
self.log.debug('starting the ``get`` method')
# APPEND TO FILENAME?
if not self.append:
self.append = ""
if not self.readability:
... | [
"def",
"get",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'starting the ``get`` method'",
")",
"# APPEND TO FILENAME?",
"if",
"not",
"self",
".",
"append",
":",
"self",
".",
"append",
"=",
"\"\"",
"if",
"not",
"self",
".",
"readability",... | *get the PDF*
**Return:**
- ``pdfPath`` -- the path to the generated PDF | [
"*",
"get",
"the",
"PDF",
"*"
] | 98038d746aa67e343b73b3ccee1e02d31dab81ec | https://github.com/thespacedoctor/polyglot/blob/98038d746aa67e343b73b3ccee1e02d31dab81ec/polyglot/printpdf.py#L140-L167 | train | get the PDF |
thespacedoctor/polyglot | polyglot/printpdf.py | printpdf._print_original_webpage | def _print_original_webpage(
self):
"""*print the original webpage*
**Return:**
- ``pdfPath`` -- the path to the generated PDF
"""
self.log.debug('starting the ``_print_original_webpage`` method')
if not self.title:
r = requests.get(self.url)... | python | def _print_original_webpage(
self):
"""*print the original webpage*
**Return:**
- ``pdfPath`` -- the path to the generated PDF
"""
self.log.debug('starting the ``_print_original_webpage`` method')
if not self.title:
r = requests.get(self.url)... | [
"def",
"_print_original_webpage",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'starting the ``_print_original_webpage`` method'",
")",
"if",
"not",
"self",
".",
"title",
":",
"r",
"=",
"requests",
".",
"get",
"(",
"self",
".",
"url",
")",
... | *print the original webpage*
**Return:**
- ``pdfPath`` -- the path to the generated PDF | [
"*",
"print",
"the",
"original",
"webpage",
"*"
] | 98038d746aa67e343b73b3ccee1e02d31dab81ec | https://github.com/thespacedoctor/polyglot/blob/98038d746aa67e343b73b3ccee1e02d31dab81ec/polyglot/printpdf.py#L169-L203 | train | print the original webpage |
thespacedoctor/polyglot | polyglot/printpdf.py | printpdf._print_parsed_webpage | def _print_parsed_webpage(
self):
"""*print the parsed/cleaned webpage*
**Return:**
- ``pdfPath`` -- the path to the generated PDF
"""
self.log.debug('starting the ``_print_parsed_webpage()`` method')
from polyglot import htmlCleaner
cleaner = ht... | python | def _print_parsed_webpage(
self):
"""*print the parsed/cleaned webpage*
**Return:**
- ``pdfPath`` -- the path to the generated PDF
"""
self.log.debug('starting the ``_print_parsed_webpage()`` method')
from polyglot import htmlCleaner
cleaner = ht... | [
"def",
"_print_parsed_webpage",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'starting the ``_print_parsed_webpage()`` method'",
")",
"from",
"polyglot",
"import",
"htmlCleaner",
"cleaner",
"=",
"htmlCleaner",
"(",
"log",
"=",
"self",
".",
"log",... | *print the parsed/cleaned webpage*
**Return:**
- ``pdfPath`` -- the path to the generated PDF | [
"*",
"print",
"the",
"parsed",
"/",
"cleaned",
"webpage",
"*"
] | 98038d746aa67e343b73b3ccee1e02d31dab81ec | https://github.com/thespacedoctor/polyglot/blob/98038d746aa67e343b73b3ccee1e02d31dab81ec/polyglot/printpdf.py#L205-L249 | train | print the parsed webpage and clean it up |
mardix/pylot | pylot/utils.py | get_base_dir | def get_base_dir():
"""
Return the base directory
"""
return os.path.split(os.path.abspath(os.path.dirname(__file__)))[0] | python | def get_base_dir():
"""
Return the base directory
"""
return os.path.split(os.path.abspath(os.path.dirname(__file__)))[0] | [
"def",
"get_base_dir",
"(",
")",
":",
"return",
"os",
".",
"path",
".",
"split",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
")",
")",
"[",
"0",
"]"
] | Return the base directory | [
"Return",
"the",
"base",
"directory"
] | 506a33a56ebdfc0925b94015e8cf98ccb16a143c | https://github.com/mardix/pylot/blob/506a33a56ebdfc0925b94015e8cf98ccb16a143c/pylot/utils.py#L20-L24 | train | Returns the base directory of the base directory of the current project. |
mardix/pylot | pylot/utils.py | is_valid_password | def is_valid_password(password):
"""
Check if a password is valid
"""
pattern = re.compile(r"^.{4,25}$")
return password and pattern.match(password) | python | def is_valid_password(password):
"""
Check if a password is valid
"""
pattern = re.compile(r"^.{4,25}$")
return password and pattern.match(password) | [
"def",
"is_valid_password",
"(",
"password",
")",
":",
"pattern",
"=",
"re",
".",
"compile",
"(",
"r\"^.{4,25}$\"",
")",
"return",
"password",
"and",
"pattern",
".",
"match",
"(",
"password",
")"
] | Check if a password is valid | [
"Check",
"if",
"a",
"password",
"is",
"valid"
] | 506a33a56ebdfc0925b94015e8cf98ccb16a143c | https://github.com/mardix/pylot/blob/506a33a56ebdfc0925b94015e8cf98ccb16a143c/pylot/utils.py#L35-L40 | train | Check if a password is valid |
mardix/pylot | pylot/utils.py | is_valid_url | def is_valid_url(url):
"""
Check if url is valid
"""
regex = re.compile(
r'^(?:http|ftp)s?://' # http:// or https://
r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|' #domain...
#r'localhost|' #localhost...
r'\d{1,3}\.\d{... | python | def is_valid_url(url):
"""
Check if url is valid
"""
regex = re.compile(
r'^(?:http|ftp)s?://' # http:// or https://
r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|' #domain...
#r'localhost|' #localhost...
r'\d{1,3}\.\d{... | [
"def",
"is_valid_url",
"(",
"url",
")",
":",
"regex",
"=",
"re",
".",
"compile",
"(",
"r'^(?:http|ftp)s?://'",
"# http:// or https://",
"r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\\.)+(?:[A-Z]{2,6}\\.?|[A-Z0-9-]{2,}\\.?)|'",
"#domain...",
"#r'localhost|' #localhost...",
"r'\\d{1,... | Check if url is valid | [
"Check",
"if",
"url",
"is",
"valid"
] | 506a33a56ebdfc0925b94015e8cf98ccb16a143c | https://github.com/mardix/pylot/blob/506a33a56ebdfc0925b94015e8cf98ccb16a143c/pylot/utils.py#L43-L54 | train | Check if url is valid
|
mardix/pylot | pylot/utils.py | time_to_seconds | def time_to_seconds(t):
"""
Convert time H:M:S to seconds
"""
l = list(map(int, t.split(':')))
return sum(n * sec for n, sec in zip(l[::-1], (1, 60, 3600))) | python | def time_to_seconds(t):
"""
Convert time H:M:S to seconds
"""
l = list(map(int, t.split(':')))
return sum(n * sec for n, sec in zip(l[::-1], (1, 60, 3600))) | [
"def",
"time_to_seconds",
"(",
"t",
")",
":",
"l",
"=",
"list",
"(",
"map",
"(",
"int",
",",
"t",
".",
"split",
"(",
"':'",
")",
")",
")",
"return",
"sum",
"(",
"n",
"*",
"sec",
"for",
"n",
",",
"sec",
"in",
"zip",
"(",
"l",
"[",
":",
":",
... | Convert time H:M:S to seconds | [
"Convert",
"time",
"H",
":",
"M",
":",
"S",
"to",
"seconds"
] | 506a33a56ebdfc0925b94015e8cf98ccb16a143c | https://github.com/mardix/pylot/blob/506a33a56ebdfc0925b94015e8cf98ccb16a143c/pylot/utils.py#L88-L93 | train | Convert time H : M : S to seconds |
mardix/pylot | pylot/utils.py | generate_random_string | def generate_random_string(length=8):
"""
Generate a random string
"""
char_set = string.ascii_uppercase + string.digits
return ''.join(random.sample(char_set * (length - 1), length)) | python | def generate_random_string(length=8):
"""
Generate a random string
"""
char_set = string.ascii_uppercase + string.digits
return ''.join(random.sample(char_set * (length - 1), length)) | [
"def",
"generate_random_string",
"(",
"length",
"=",
"8",
")",
":",
"char_set",
"=",
"string",
".",
"ascii_uppercase",
"+",
"string",
".",
"digits",
"return",
"''",
".",
"join",
"(",
"random",
".",
"sample",
"(",
"char_set",
"*",
"(",
"length",
"-",
"1",... | Generate a random string | [
"Generate",
"a",
"random",
"string"
] | 506a33a56ebdfc0925b94015e8cf98ccb16a143c | https://github.com/mardix/pylot/blob/506a33a56ebdfc0925b94015e8cf98ccb16a143c/pylot/utils.py#L117-L122 | train | Generate a random string of given length |
mardix/pylot | pylot/utils.py | filter_stopwords | def filter_stopwords(str):
"""
Stop word filter
returns list
"""
STOPWORDS = ['a', 'able', 'about', 'across', 'after', 'all', 'almost',
'also', 'am', 'among', 'an', 'and', 'any', 'are', 'as', 'at',
'be', 'because', 'been', 'but', 'by', 'can', 'cannot',
... | python | def filter_stopwords(str):
"""
Stop word filter
returns list
"""
STOPWORDS = ['a', 'able', 'about', 'across', 'after', 'all', 'almost',
'also', 'am', 'among', 'an', 'and', 'any', 'are', 'as', 'at',
'be', 'because', 'been', 'but', 'by', 'can', 'cannot',
... | [
"def",
"filter_stopwords",
"(",
"str",
")",
":",
"STOPWORDS",
"=",
"[",
"'a'",
",",
"'able'",
",",
"'about'",
",",
"'across'",
",",
"'after'",
",",
"'all'",
",",
"'almost'",
",",
"'also'",
",",
"'am'",
",",
"'among'",
",",
"'an'",
",",
"'and'",
",",
... | Stop word filter
returns list | [
"Stop",
"word",
"filter",
"returns",
"list"
] | 506a33a56ebdfc0925b94015e8cf98ccb16a143c | https://github.com/mardix/pylot/blob/506a33a56ebdfc0925b94015e8cf98ccb16a143c/pylot/utils.py#L139-L161 | train | Returns a list of stop words in a stop word string. |
mardix/pylot | pylot/utils.py | is_port_open | def is_port_open(port, host="127.0.0.1"):
"""
Check if a port is open
:param port:
:param host:
:return bool:
"""
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
s.connect((host, int(port)))
s.shutdown(2)
return True
except Exception as e:
r... | python | def is_port_open(port, host="127.0.0.1"):
"""
Check if a port is open
:param port:
:param host:
:return bool:
"""
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
s.connect((host, int(port)))
s.shutdown(2)
return True
except Exception as e:
r... | [
"def",
"is_port_open",
"(",
"port",
",",
"host",
"=",
"\"127.0.0.1\"",
")",
":",
"s",
"=",
"socket",
".",
"socket",
"(",
"socket",
".",
"AF_INET",
",",
"socket",
".",
"SOCK_STREAM",
")",
"try",
":",
"s",
".",
"connect",
"(",
"(",
"host",
",",
"int",
... | Check if a port is open
:param port:
:param host:
:return bool: | [
"Check",
"if",
"a",
"port",
"is",
"open",
":",
"param",
"port",
":",
":",
"param",
"host",
":",
":",
"return",
"bool",
":"
] | 506a33a56ebdfc0925b94015e8cf98ccb16a143c | https://github.com/mardix/pylot/blob/506a33a56ebdfc0925b94015e8cf98ccb16a143c/pylot/utils.py#L170-L183 | train | Check if a port is open |
mardix/pylot | pylot/utils.py | convert_bytes | def convert_bytes(bytes):
"""
Convert bytes into human readable
"""
bytes = float(bytes)
if bytes >= 1099511627776:
terabytes = bytes / 1099511627776
size = '%.2fT' % terabytes
elif bytes >= 1073741824:
gigabytes = bytes / 1073741824
size = '%.2fG' % gigabytes
... | python | def convert_bytes(bytes):
"""
Convert bytes into human readable
"""
bytes = float(bytes)
if bytes >= 1099511627776:
terabytes = bytes / 1099511627776
size = '%.2fT' % terabytes
elif bytes >= 1073741824:
gigabytes = bytes / 1073741824
size = '%.2fG' % gigabytes
... | [
"def",
"convert_bytes",
"(",
"bytes",
")",
":",
"bytes",
"=",
"float",
"(",
"bytes",
")",
"if",
"bytes",
">=",
"1099511627776",
":",
"terabytes",
"=",
"bytes",
"/",
"1099511627776",
"size",
"=",
"'%.2fT'",
"%",
"terabytes",
"elif",
"bytes",
">=",
"10737418... | Convert bytes into human readable | [
"Convert",
"bytes",
"into",
"human",
"readable"
] | 506a33a56ebdfc0925b94015e8cf98ccb16a143c | https://github.com/mardix/pylot/blob/506a33a56ebdfc0925b94015e8cf98ccb16a143c/pylot/utils.py#L192-L211 | train | Convert bytes into human readable format |
mardix/pylot | pylot/utils.py | list_chunks | def list_chunks(l, n):
"""
Return a list of chunks
:param l: List
:param n: int The number of items per chunk
:return: List
"""
if n < 1:
n = 1
return [l[i:i + n] for i in range(0, len(l), n)] | python | def list_chunks(l, n):
"""
Return a list of chunks
:param l: List
:param n: int The number of items per chunk
:return: List
"""
if n < 1:
n = 1
return [l[i:i + n] for i in range(0, len(l), n)] | [
"def",
"list_chunks",
"(",
"l",
",",
"n",
")",
":",
"if",
"n",
"<",
"1",
":",
"n",
"=",
"1",
"return",
"[",
"l",
"[",
"i",
":",
"i",
"+",
"n",
"]",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"l",
")",
",",
"n",
")",
"]"
] | Return a list of chunks
:param l: List
:param n: int The number of items per chunk
:return: List | [
"Return",
"a",
"list",
"of",
"chunks",
":",
"param",
"l",
":",
"List",
":",
"param",
"n",
":",
"int",
"The",
"number",
"of",
"items",
"per",
"chunk",
":",
"return",
":",
"List"
] | 506a33a56ebdfc0925b94015e8cf98ccb16a143c | https://github.com/mardix/pylot/blob/506a33a56ebdfc0925b94015e8cf98ccb16a143c/pylot/utils.py#L214-L223 | train | Return a list of n items per chunk in list l |
mardix/pylot | pylot/utils.py | any_in_string | def any_in_string(l, s):
"""
Check if any items in a list is in a string
:params l: dict
:params s: string
:return bool:
"""
return any([i in l for i in l if i in s]) | python | def any_in_string(l, s):
"""
Check if any items in a list is in a string
:params l: dict
:params s: string
:return bool:
"""
return any([i in l for i in l if i in s]) | [
"def",
"any_in_string",
"(",
"l",
",",
"s",
")",
":",
"return",
"any",
"(",
"[",
"i",
"in",
"l",
"for",
"i",
"in",
"l",
"if",
"i",
"in",
"s",
"]",
")"
] | Check if any items in a list is in a string
:params l: dict
:params s: string
:return bool: | [
"Check",
"if",
"any",
"items",
"in",
"a",
"list",
"is",
"in",
"a",
"string",
":",
"params",
"l",
":",
"dict",
":",
"params",
"s",
":",
"string",
":",
"return",
"bool",
":"
] | 506a33a56ebdfc0925b94015e8cf98ccb16a143c | https://github.com/mardix/pylot/blob/506a33a56ebdfc0925b94015e8cf98ccb16a143c/pylot/utils.py#L225-L232 | train | Check if any items in a list is in a string |
mardix/pylot | pylot/utils.py | add_path_to_jinja | def add_path_to_jinja(flask_app, path):
"""
To add path to jinja so it can be loaded
:param flask_app:
:param path:
:return:
"""
template_dir = path
my_loader = jinja2.ChoiceLoader([
flask_app.jinja_loader,
jinja2.FileSystemLoader(template_dir)
])
flask_app.jinja_... | python | def add_path_to_jinja(flask_app, path):
"""
To add path to jinja so it can be loaded
:param flask_app:
:param path:
:return:
"""
template_dir = path
my_loader = jinja2.ChoiceLoader([
flask_app.jinja_loader,
jinja2.FileSystemLoader(template_dir)
])
flask_app.jinja_... | [
"def",
"add_path_to_jinja",
"(",
"flask_app",
",",
"path",
")",
":",
"template_dir",
"=",
"path",
"my_loader",
"=",
"jinja2",
".",
"ChoiceLoader",
"(",
"[",
"flask_app",
".",
"jinja_loader",
",",
"jinja2",
".",
"FileSystemLoader",
"(",
"template_dir",
")",
"]"... | To add path to jinja so it can be loaded
:param flask_app:
:param path:
:return: | [
"To",
"add",
"path",
"to",
"jinja",
"so",
"it",
"can",
"be",
"loaded",
":",
"param",
"flask_app",
":",
":",
"param",
"path",
":",
":",
"return",
":"
] | 506a33a56ebdfc0925b94015e8cf98ccb16a143c | https://github.com/mardix/pylot/blob/506a33a56ebdfc0925b94015e8cf98ccb16a143c/pylot/utils.py#L234-L246 | train | Add path to jinja so it can be loaded |
mardix/pylot | pylot/utils.py | bg_process | def bg_process(func):
"""
A multiprocess decorator
:param func:
:return:
"""
@functools.wraps(func)
def wrapper(*args, **kwargs):
p = multiprocessing.Process(target=func, args=args, kwargs=kwargs)
p.start()
return wrapper | python | def bg_process(func):
"""
A multiprocess decorator
:param func:
:return:
"""
@functools.wraps(func)
def wrapper(*args, **kwargs):
p = multiprocessing.Process(target=func, args=args, kwargs=kwargs)
p.start()
return wrapper | [
"def",
"bg_process",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"p",
"=",
"multiprocessing",
".",
"Process",
"(",
"target",
"=",
"func",
",",
"args... | A multiprocess decorator
:param func:
:return: | [
"A",
"multiprocess",
"decorator",
":",
"param",
"func",
":",
":",
"return",
":"
] | 506a33a56ebdfc0925b94015e8cf98ccb16a143c | https://github.com/mardix/pylot/blob/506a33a56ebdfc0925b94015e8cf98ccb16a143c/pylot/utils.py#L252-L262 | train | A multiprocess decorator that starts a process and returns it. |
mardix/pylot | pylot/utils.py | bg_thread | def bg_thread(func):
"""
A threading decorator
:param func:
:return:
"""
@functools.wraps(func)
def wrapper(*args, **kwargs):
p = threading.Thread(target=func, args=args, kwargs=kwargs)
p.start()
return wrapper | python | def bg_thread(func):
"""
A threading decorator
:param func:
:return:
"""
@functools.wraps(func)
def wrapper(*args, **kwargs):
p = threading.Thread(target=func, args=args, kwargs=kwargs)
p.start()
return wrapper | [
"def",
"bg_thread",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"p",
"=",
"threading",
".",
"Thread",
"(",
"target",
"=",
"func",
",",
"args",
"="... | A threading decorator
:param func:
:return: | [
"A",
"threading",
"decorator",
":",
"param",
"func",
":",
":",
"return",
":"
] | 506a33a56ebdfc0925b94015e8cf98ccb16a143c | https://github.com/mardix/pylot/blob/506a33a56ebdfc0925b94015e8cf98ccb16a143c/pylot/utils.py#L264-L274 | train | A thread decorator that starts a new thread and returns it. |
TyVik/YaDiskClient | YaDiskClient/YaDiskClient.py | YaDiskXML.find | def find(self, node, path):
"""Wrapper for lxml`s find."""
return node.find(path, namespaces=self.namespaces) | python | def find(self, node, path):
"""Wrapper for lxml`s find."""
return node.find(path, namespaces=self.namespaces) | [
"def",
"find",
"(",
"self",
",",
"node",
",",
"path",
")",
":",
"return",
"node",
".",
"find",
"(",
"path",
",",
"namespaces",
"=",
"self",
".",
"namespaces",
")"
] | Wrapper for lxml`s find. | [
"Wrapper",
"for",
"lxml",
"s",
"find",
"."
] | ee60163bac8c5696d81e98c8ee1d8b321e46fae4 | https://github.com/TyVik/YaDiskClient/blob/ee60163bac8c5696d81e98c8ee1d8b321e46fae4/YaDiskClient/YaDiskClient.py#L24-L27 | train | Wrapper for lxml s find. |
TyVik/YaDiskClient | YaDiskClient/YaDiskClient.py | YaDiskXML.xpath | def xpath(self, node, path):
"""Wrapper for lxml`s xpath."""
return node.xpath(path, namespaces=self.namespaces) | python | def xpath(self, node, path):
"""Wrapper for lxml`s xpath."""
return node.xpath(path, namespaces=self.namespaces) | [
"def",
"xpath",
"(",
"self",
",",
"node",
",",
"path",
")",
":",
"return",
"node",
".",
"xpath",
"(",
"path",
",",
"namespaces",
"=",
"self",
".",
"namespaces",
")"
] | Wrapper for lxml`s xpath. | [
"Wrapper",
"for",
"lxml",
"s",
"xpath",
"."
] | ee60163bac8c5696d81e98c8ee1d8b321e46fae4 | https://github.com/TyVik/YaDiskClient/blob/ee60163bac8c5696d81e98c8ee1d8b321e46fae4/YaDiskClient/YaDiskClient.py#L29-L32 | train | Wrapper for lxml s xpath. |
TyVik/YaDiskClient | YaDiskClient/YaDiskClient.py | YaDisk.ls | def ls(self, path, offset=None, amount=None):
"""
Return list of files/directories. Each item is a dict.
Keys: 'path', 'creationdate', 'displayname', 'length', 'lastmodified', 'isDir'.
"""
def parseContent(content):
result = []
root = ET.fromstri... | python | def ls(self, path, offset=None, amount=None):
"""
Return list of files/directories. Each item is a dict.
Keys: 'path', 'creationdate', 'displayname', 'length', 'lastmodified', 'isDir'.
"""
def parseContent(content):
result = []
root = ET.fromstri... | [
"def",
"ls",
"(",
"self",
",",
"path",
",",
"offset",
"=",
"None",
",",
"amount",
"=",
"None",
")",
":",
"def",
"parseContent",
"(",
"content",
")",
":",
"result",
"=",
"[",
"]",
"root",
"=",
"ET",
".",
"fromstring",
"(",
"content",
")",
"for",
"... | Return list of files/directories. Each item is a dict.
Keys: 'path', 'creationdate', 'displayname', 'length', 'lastmodified', 'isDir'. | [
"Return",
"list",
"of",
"files",
"/",
"directories",
".",
"Each",
"item",
"is",
"a",
"dict",
".",
"Keys",
":",
"path",
"creationdate",
"displayname",
"length",
"lastmodified",
"isDir",
"."
] | ee60163bac8c5696d81e98c8ee1d8b321e46fae4 | https://github.com/TyVik/YaDiskClient/blob/ee60163bac8c5696d81e98c8ee1d8b321e46fae4/YaDiskClient/YaDiskClient.py#L61-L92 | train | List all files and directories in a path. |
TyVik/YaDiskClient | YaDiskClient/YaDiskClient.py | YaDisk.df | def df(self):
"""Return dict with size of Ya.Disk. Keys: 'available', 'used'."""
def parseContent(content):
root = ET.fromstring(content)
return {
'available': root.find(".//d:quota-available-bytes", namespaces=self.namespaces).text,
'used': root... | python | def df(self):
"""Return dict with size of Ya.Disk. Keys: 'available', 'used'."""
def parseContent(content):
root = ET.fromstring(content)
return {
'available': root.find(".//d:quota-available-bytes", namespaces=self.namespaces).text,
'used': root... | [
"def",
"df",
"(",
"self",
")",
":",
"def",
"parseContent",
"(",
"content",
")",
":",
"root",
"=",
"ET",
".",
"fromstring",
"(",
"content",
")",
"return",
"{",
"'available'",
":",
"root",
".",
"find",
"(",
"\".//d:quota-available-bytes\"",
",",
"namespaces"... | Return dict with size of Ya.Disk. Keys: 'available', 'used'. | [
"Return",
"dict",
"with",
"size",
"of",
"Ya",
".",
"Disk",
".",
"Keys",
":",
"available",
"used",
"."
] | ee60163bac8c5696d81e98c8ee1d8b321e46fae4 | https://github.com/TyVik/YaDiskClient/blob/ee60163bac8c5696d81e98c8ee1d8b321e46fae4/YaDiskClient/YaDiskClient.py#L94-L116 | train | Return dict with size of Ya. Disk. Keys available and used. |
TyVik/YaDiskClient | YaDiskClient/YaDiskClient.py | YaDisk.mkdir | def mkdir(self, path):
"""Create directory. All part of path must be exists. Raise exception when path already exists."""
resp = self._sendRequest("MKCOL", path)
if resp.status_code != 201:
if resp.status_code == 409:
raise YaDiskException(409, "Part of path {} does ... | python | def mkdir(self, path):
"""Create directory. All part of path must be exists. Raise exception when path already exists."""
resp = self._sendRequest("MKCOL", path)
if resp.status_code != 201:
if resp.status_code == 409:
raise YaDiskException(409, "Part of path {} does ... | [
"def",
"mkdir",
"(",
"self",
",",
"path",
")",
":",
"resp",
"=",
"self",
".",
"_sendRequest",
"(",
"\"MKCOL\"",
",",
"path",
")",
"if",
"resp",
".",
"status_code",
"!=",
"201",
":",
"if",
"resp",
".",
"status_code",
"==",
"409",
":",
"raise",
"YaDisk... | Create directory. All part of path must be exists. Raise exception when path already exists. | [
"Create",
"directory",
".",
"All",
"part",
"of",
"path",
"must",
"be",
"exists",
".",
"Raise",
"exception",
"when",
"path",
"already",
"exists",
"."
] | ee60163bac8c5696d81e98c8ee1d8b321e46fae4 | https://github.com/TyVik/YaDiskClient/blob/ee60163bac8c5696d81e98c8ee1d8b321e46fae4/YaDiskClient/YaDiskClient.py#L118-L128 | train | Create directory. All part of path must be exists. Raise exception when path already exists. Raise exception when path already exists. Raise exception when path already exists. |
TyVik/YaDiskClient | YaDiskClient/YaDiskClient.py | YaDisk.rm | def rm(self, path):
"""Delete file or directory."""
resp = self._sendRequest("DELETE", path)
# By documentation server must return 200 "OK", but I get 204 "No Content".
# Anyway file or directory have been removed.
if not (resp.status_code in (200, 204)):
raise YaDis... | python | def rm(self, path):
"""Delete file or directory."""
resp = self._sendRequest("DELETE", path)
# By documentation server must return 200 "OK", but I get 204 "No Content".
# Anyway file or directory have been removed.
if not (resp.status_code in (200, 204)):
raise YaDis... | [
"def",
"rm",
"(",
"self",
",",
"path",
")",
":",
"resp",
"=",
"self",
".",
"_sendRequest",
"(",
"\"DELETE\"",
",",
"path",
")",
"# By documentation server must return 200 \"OK\", but I get 204 \"No Content\".",
"# Anyway file or directory have been removed.",
"if",
"not",
... | Delete file or directory. | [
"Delete",
"file",
"or",
"directory",
"."
] | ee60163bac8c5696d81e98c8ee1d8b321e46fae4 | https://github.com/TyVik/YaDiskClient/blob/ee60163bac8c5696d81e98c8ee1d8b321e46fae4/YaDiskClient/YaDiskClient.py#L130-L137 | train | Delete file or directory. |
TyVik/YaDiskClient | YaDiskClient/YaDiskClient.py | YaDisk.cp | def cp(self, src, dst):
"""Copy file or directory."""
_check_dst_absolute(dst)
resp = self._sendRequest("COPY", src, {'Destination': dst})
if resp.status_code != 201:
raise YaDiskException(resp.status_code, resp.content) | python | def cp(self, src, dst):
"""Copy file or directory."""
_check_dst_absolute(dst)
resp = self._sendRequest("COPY", src, {'Destination': dst})
if resp.status_code != 201:
raise YaDiskException(resp.status_code, resp.content) | [
"def",
"cp",
"(",
"self",
",",
"src",
",",
"dst",
")",
":",
"_check_dst_absolute",
"(",
"dst",
")",
"resp",
"=",
"self",
".",
"_sendRequest",
"(",
"\"COPY\"",
",",
"src",
",",
"{",
"'Destination'",
":",
"dst",
"}",
")",
"if",
"resp",
".",
"status_cod... | Copy file or directory. | [
"Copy",
"file",
"or",
"directory",
"."
] | ee60163bac8c5696d81e98c8ee1d8b321e46fae4 | https://github.com/TyVik/YaDiskClient/blob/ee60163bac8c5696d81e98c8ee1d8b321e46fae4/YaDiskClient/YaDiskClient.py#L139-L145 | train | Copy file or directory. |
TyVik/YaDiskClient | YaDiskClient/YaDiskClient.py | YaDisk.upload | def upload(self, file, path):
"""Upload file."""
with open(file, "rb") as f:
resp = self._sendRequest("PUT", path, data=f)
if resp.status_code != 201:
raise YaDiskException(resp.status_code, resp.content) | python | def upload(self, file, path):
"""Upload file."""
with open(file, "rb") as f:
resp = self._sendRequest("PUT", path, data=f)
if resp.status_code != 201:
raise YaDiskException(resp.status_code, resp.content) | [
"def",
"upload",
"(",
"self",
",",
"file",
",",
"path",
")",
":",
"with",
"open",
"(",
"file",
",",
"\"rb\"",
")",
"as",
"f",
":",
"resp",
"=",
"self",
".",
"_sendRequest",
"(",
"\"PUT\"",
",",
"path",
",",
"data",
"=",
"f",
")",
"if",
"resp",
... | Upload file. | [
"Upload",
"file",
"."
] | ee60163bac8c5696d81e98c8ee1d8b321e46fae4 | https://github.com/TyVik/YaDiskClient/blob/ee60163bac8c5696d81e98c8ee1d8b321e46fae4/YaDiskClient/YaDiskClient.py#L155-L161 | train | Upload file to a user s archive. |
TyVik/YaDiskClient | YaDiskClient/YaDiskClient.py | YaDisk.download | def download(self, path, file):
"""Download remote file to disk."""
resp = self._sendRequest("GET", path)
if resp.status_code == 200:
with open(file, "wb") as f:
f.write(resp.content)
else:
raise YaDiskException(resp.status_code, resp.content) | python | def download(self, path, file):
"""Download remote file to disk."""
resp = self._sendRequest("GET", path)
if resp.status_code == 200:
with open(file, "wb") as f:
f.write(resp.content)
else:
raise YaDiskException(resp.status_code, resp.content) | [
"def",
"download",
"(",
"self",
",",
"path",
",",
"file",
")",
":",
"resp",
"=",
"self",
".",
"_sendRequest",
"(",
"\"GET\"",
",",
"path",
")",
"if",
"resp",
".",
"status_code",
"==",
"200",
":",
"with",
"open",
"(",
"file",
",",
"\"wb\"",
")",
"as... | Download remote file to disk. | [
"Download",
"remote",
"file",
"to",
"disk",
"."
] | ee60163bac8c5696d81e98c8ee1d8b321e46fae4 | https://github.com/TyVik/YaDiskClient/blob/ee60163bac8c5696d81e98c8ee1d8b321e46fae4/YaDiskClient/YaDiskClient.py#L163-L171 | train | Download remote file to disk. |
TyVik/YaDiskClient | YaDiskClient/YaDiskClient.py | YaDisk.publish | def publish(self, path):
"""Publish file or folder and return public url"""
def parseContent(content):
root = ET.fromstring(content)
prop = root.find(".//d:prop", namespaces=self.namespaces)
return prop.find("{urn:yandex:disk:meta}public_url").text.strip()
... | python | def publish(self, path):
"""Publish file or folder and return public url"""
def parseContent(content):
root = ET.fromstring(content)
prop = root.find(".//d:prop", namespaces=self.namespaces)
return prop.find("{urn:yandex:disk:meta}public_url").text.strip()
... | [
"def",
"publish",
"(",
"self",
",",
"path",
")",
":",
"def",
"parseContent",
"(",
"content",
")",
":",
"root",
"=",
"ET",
".",
"fromstring",
"(",
"content",
")",
"prop",
"=",
"root",
".",
"find",
"(",
"\".//d:prop\"",
",",
"namespaces",
"=",
"self",
... | Publish file or folder and return public url | [
"Publish",
"file",
"or",
"folder",
"and",
"return",
"public",
"url"
] | ee60163bac8c5696d81e98c8ee1d8b321e46fae4 | https://github.com/TyVik/YaDiskClient/blob/ee60163bac8c5696d81e98c8ee1d8b321e46fae4/YaDiskClient/YaDiskClient.py#L173-L196 | train | Publish file or folder and return public url |
TyVik/YaDiskClient | YaDiskClient/YaDiskClient.py | YaDisk.unpublish | def unpublish(self, path):
"""Make public file or folder private (delete public url)"""
data = """
<propertyupdate xmlns="DAV:">
<remove>
<prop>
<public_url xmlns="urn:yandex:disk:meta" />
</prop>
</remove>
</propertyupdate>
"""
_check_dst_absolute(pat... | python | def unpublish(self, path):
"""Make public file or folder private (delete public url)"""
data = """
<propertyupdate xmlns="DAV:">
<remove>
<prop>
<public_url xmlns="urn:yandex:disk:meta" />
</prop>
</remove>
</propertyupdate>
"""
_check_dst_absolute(pat... | [
"def",
"unpublish",
"(",
"self",
",",
"path",
")",
":",
"data",
"=",
"\"\"\"\n<propertyupdate xmlns=\"DAV:\">\n <remove>\n <prop>\n <public_url xmlns=\"urn:yandex:disk:meta\" />\n </prop>\n </remove>\n</propertyupdate>\n \"\"\"",
"_check_dst_absolute",
"(",
"path",
")... | Make public file or folder private (delete public url) | [
"Make",
"public",
"file",
"or",
"folder",
"private",
"(",
"delete",
"public",
"url",
")"
] | ee60163bac8c5696d81e98c8ee1d8b321e46fae4 | https://github.com/TyVik/YaDiskClient/blob/ee60163bac8c5696d81e98c8ee1d8b321e46fae4/YaDiskClient/YaDiskClient.py#L198-L216 | train | Unpublish a public file or folder. |
TkTech/Jawa | jawa/util/bytecode.py | write_instruction | def write_instruction(fout, start_pos, ins):
"""
Writes a single instruction of `opcode` with `operands` to `fout`.
:param fout: Any file-like object providing ``write()``.
:param start_pos: The current position in the stream.
:param ins: The `Instruction` to write.
"""
opcode, operands = i... | python | def write_instruction(fout, start_pos, ins):
"""
Writes a single instruction of `opcode` with `operands` to `fout`.
:param fout: Any file-like object providing ``write()``.
:param start_pos: The current position in the stream.
:param ins: The `Instruction` to write.
"""
opcode, operands = i... | [
"def",
"write_instruction",
"(",
"fout",
",",
"start_pos",
",",
"ins",
")",
":",
"opcode",
",",
"operands",
"=",
"ins",
".",
"opcode",
",",
"ins",
".",
"operands",
"fmt_operands",
"=",
"opcode_table",
"[",
"opcode",
"]",
"[",
"'operands'",
"]",
"if",
"in... | Writes a single instruction of `opcode` with `operands` to `fout`.
:param fout: Any file-like object providing ``write()``.
:param start_pos: The current position in the stream.
:param ins: The `Instruction` to write. | [
"Writes",
"a",
"single",
"instruction",
"of",
"opcode",
"with",
"operands",
"to",
"fout",
"."
] | 94c8424e699029ac33fbc0e866fff0ecb2742289 | https://github.com/TkTech/Jawa/blob/94c8424e699029ac33fbc0e866fff0ecb2742289/jawa/util/bytecode.py#L123-L178 | train | Writes a single instruction of opcode with operands to fout. |
TkTech/Jawa | jawa/util/bytecode.py | read_instruction | def read_instruction(fio, start_pos):
"""
Reads a single instruction from `fio` and returns it, or ``None`` if
the stream is empty.
:param fio: Any file-like object providing ``read()``.
:param start_pos: The current position in the stream.
"""
op = fio.read(1)
if not op:
retur... | python | def read_instruction(fio, start_pos):
"""
Reads a single instruction from `fio` and returns it, or ``None`` if
the stream is empty.
:param fio: Any file-like object providing ``read()``.
:param start_pos: The current position in the stream.
"""
op = fio.read(1)
if not op:
retur... | [
"def",
"read_instruction",
"(",
"fio",
",",
"start_pos",
")",
":",
"op",
"=",
"fio",
".",
"read",
"(",
"1",
")",
"if",
"not",
"op",
":",
"return",
"None",
"op",
"=",
"ord",
"(",
"op",
")",
"ins",
"=",
"opcode_table",
"[",
"op",
"]",
"operands",
"... | Reads a single instruction from `fio` and returns it, or ``None`` if
the stream is empty.
:param fio: Any file-like object providing ``read()``.
:param start_pos: The current position in the stream. | [
"Reads",
"a",
"single",
"instruction",
"from",
"fio",
"and",
"returns",
"it",
"or",
"None",
"if",
"the",
"stream",
"is",
"empty",
"."
] | 94c8424e699029ac33fbc0e866fff0ecb2742289 | https://github.com/TkTech/Jawa/blob/94c8424e699029ac33fbc0e866fff0ecb2742289/jawa/util/bytecode.py#L181-L259 | train | Reads a single instruction from fio and returns it. |
TkTech/Jawa | jawa/util/bytecode.py | load_bytecode_definitions | def load_bytecode_definitions(*, path=None) -> dict:
"""Load bytecode definitions from JSON file.
If no path is provided the default bytecode.json will be loaded.
:param path: Either None or a path to a JSON file to load containing
bytecode definitions.
"""
if path is not None:
... | python | def load_bytecode_definitions(*, path=None) -> dict:
"""Load bytecode definitions from JSON file.
If no path is provided the default bytecode.json will be loaded.
:param path: Either None or a path to a JSON file to load containing
bytecode definitions.
"""
if path is not None:
... | [
"def",
"load_bytecode_definitions",
"(",
"*",
",",
"path",
"=",
"None",
")",
"->",
"dict",
":",
"if",
"path",
"is",
"not",
"None",
":",
"with",
"open",
"(",
"path",
",",
"'rb'",
")",
"as",
"file_in",
":",
"j",
"=",
"json",
".",
"load",
"(",
"file_i... | Load bytecode definitions from JSON file.
If no path is provided the default bytecode.json will be loaded.
:param path: Either None or a path to a JSON file to load containing
bytecode definitions. | [
"Load",
"bytecode",
"definitions",
"from",
"JSON",
"file",
"."
] | 94c8424e699029ac33fbc0e866fff0ecb2742289 | https://github.com/TkTech/Jawa/blob/94c8424e699029ac33fbc0e866fff0ecb2742289/jawa/util/bytecode.py#L262-L293 | train | Load bytecode. json file and return a dictionary containing mnemonic and opcode keys. |
TkTech/Jawa | jawa/util/bytecode.py | Instruction.size_on_disk | def size_on_disk(self, start_pos=0):
"""
Returns the size of this instruction and its operands when
packed. `start_pos` is required for the `tableswitch` and
`lookupswitch` instruction as the padding depends on alignment.
"""
# All instructions are at least 1 byte (the op... | python | def size_on_disk(self, start_pos=0):
"""
Returns the size of this instruction and its operands when
packed. `start_pos` is required for the `tableswitch` and
`lookupswitch` instruction as the padding depends on alignment.
"""
# All instructions are at least 1 byte (the op... | [
"def",
"size_on_disk",
"(",
"self",
",",
"start_pos",
"=",
"0",
")",
":",
"# All instructions are at least 1 byte (the opcode itself)",
"size",
"=",
"1",
"fmts",
"=",
"opcode_table",
"[",
"self",
".",
"opcode",
"]",
"[",
"'operands'",
"]",
"if",
"self",
".",
"... | Returns the size of this instruction and its operands when
packed. `start_pos` is required for the `tableswitch` and
`lookupswitch` instruction as the padding depends on alignment. | [
"Returns",
"the",
"size",
"of",
"this",
"instruction",
"and",
"its",
"operands",
"when",
"packed",
".",
"start_pos",
"is",
"required",
"for",
"the",
"tableswitch",
"and",
"lookupswitch",
"instruction",
"as",
"the",
"padding",
"depends",
"on",
"alignment",
"."
] | 94c8424e699029ac33fbc0e866fff0ecb2742289 | https://github.com/TkTech/Jawa/blob/94c8424e699029ac33fbc0e866fff0ecb2742289/jawa/util/bytecode.py#L27-L58 | train | Returns the size of this instruction and its operands when the packed version is at least 1 byte. |
TkTech/Jawa | jawa/util/bytecode.py | Instruction.wide | def wide(self):
"""
``True`` if this instruction needs to be prefixed by the WIDE
opcode.
"""
if not opcode_table[self.opcode].get('can_be_wide'):
return False
if self.operands[0].value >= 255:
return True
if self.opcode == 0x84:
... | python | def wide(self):
"""
``True`` if this instruction needs to be prefixed by the WIDE
opcode.
"""
if not opcode_table[self.opcode].get('can_be_wide'):
return False
if self.operands[0].value >= 255:
return True
if self.opcode == 0x84:
... | [
"def",
"wide",
"(",
"self",
")",
":",
"if",
"not",
"opcode_table",
"[",
"self",
".",
"opcode",
"]",
".",
"get",
"(",
"'can_be_wide'",
")",
":",
"return",
"False",
"if",
"self",
".",
"operands",
"[",
"0",
"]",
".",
"value",
">=",
"255",
":",
"return... | ``True`` if this instruction needs to be prefixed by the WIDE
opcode. | [
"True",
"if",
"this",
"instruction",
"needs",
"to",
"be",
"prefixed",
"by",
"the",
"WIDE",
"opcode",
"."
] | 94c8424e699029ac33fbc0e866fff0ecb2742289 | https://github.com/TkTech/Jawa/blob/94c8424e699029ac33fbc0e866fff0ecb2742289/jawa/util/bytecode.py#L61-L76 | train | Returns True if the instruction can be prefixed by the WIDE
opcode. |
thespacedoctor/polyglot | polyglot/kindle.py | kindle.send | def send(
self):
"""*send the mobi book generated to kindle email address(es)*
**Return:**
- ``success`` -- True or False depending on the success/failure of sending the email to the kindle email address(es).
"""
self.log.debug('starting the ``send`` method')
... | python | def send(
self):
"""*send the mobi book generated to kindle email address(es)*
**Return:**
- ``success`` -- True or False depending on the success/failure of sending the email to the kindle email address(es).
"""
self.log.debug('starting the ``send`` method')
... | [
"def",
"send",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'starting the ``send`` method'",
")",
"if",
"self",
".",
"urlOrPath",
".",
"split",
"(",
"\".\"",
")",
"[",
"-",
"1",
"]",
"==",
"\"docx\"",
":",
"if",
"self",
".",
"title"... | *send the mobi book generated to kindle email address(es)*
**Return:**
- ``success`` -- True or False depending on the success/failure of sending the email to the kindle email address(es). | [
"*",
"send",
"the",
"mobi",
"book",
"generated",
"to",
"kindle",
"email",
"address",
"(",
"es",
")",
"*"
] | 98038d746aa67e343b73b3ccee1e02d31dab81ec | https://github.com/thespacedoctor/polyglot/blob/98038d746aa67e343b73b3ccee1e02d31dab81ec/polyglot/kindle.py#L88-L146 | train | send the mobi book to the kindle |
thespacedoctor/polyglot | polyglot/kindle.py | kindle.get_attachment | def get_attachment(self, file_path):
'''Get file as MIMEBase message'''
try:
file_ = open(file_path, 'rb')
attachment = MIMEBase('application', 'octet-stream')
attachment.set_payload(file_.read())
file_.close()
encoders.encode_base64(attachmen... | python | def get_attachment(self, file_path):
'''Get file as MIMEBase message'''
try:
file_ = open(file_path, 'rb')
attachment = MIMEBase('application', 'octet-stream')
attachment.set_payload(file_.read())
file_.close()
encoders.encode_base64(attachmen... | [
"def",
"get_attachment",
"(",
"self",
",",
"file_path",
")",
":",
"try",
":",
"file_",
"=",
"open",
"(",
"file_path",
",",
"'rb'",
")",
"attachment",
"=",
"MIMEBase",
"(",
"'application'",
",",
"'octet-stream'",
")",
"attachment",
".",
"set_payload",
"(",
... | Get file as MIMEBase message | [
"Get",
"file",
"as",
"MIMEBase",
"message"
] | 98038d746aa67e343b73b3ccee1e02d31dab81ec | https://github.com/thespacedoctor/polyglot/blob/98038d746aa67e343b73b3ccee1e02d31dab81ec/polyglot/kindle.py#L148-L166 | train | Get file as MIMEBase message |
piotr-rusin/spam-lists | spam_lists/host_list.py | HostList.lookup | def lookup(self, host_value):
"""Get a host value matching the given value.
:param host_value: a value of the host of a type that can be
listed by the service
:returns: an instance of AddressListItem representing
a matched value
:raises InvalidHostError: if the argument ... | python | def lookup(self, host_value):
"""Get a host value matching the given value.
:param host_value: a value of the host of a type that can be
listed by the service
:returns: an instance of AddressListItem representing
a matched value
:raises InvalidHostError: if the argument ... | [
"def",
"lookup",
"(",
"self",
",",
"host_value",
")",
":",
"try",
":",
"host_object",
"=",
"self",
".",
"_host_factory",
"(",
"host_value",
")",
"except",
"InvalidHostError",
":",
"return",
"None",
"result",
"=",
"self",
".",
"_get_match_and_classification",
"... | Get a host value matching the given value.
:param host_value: a value of the host of a type that can be
listed by the service
:returns: an instance of AddressListItem representing
a matched value
:raises InvalidHostError: if the argument is not a valid
host string | [
"Get",
"a",
"host",
"value",
"matching",
"the",
"given",
"value",
"."
] | fd616e8761b28f3eaa503fee5e45f7748e8f88f2 | https://github.com/piotr-rusin/spam-lists/blob/fd616e8761b28f3eaa503fee5e45f7748e8f88f2/spam_lists/host_list.py#L66-L90 | train | Returns an instance of AddressListItem representing the given value. |
piotr-rusin/spam-lists | spam_lists/host_list.py | HostList.any_match | def any_match(self, urls):
"""Check if any of the given URLs has a matching host.
:param urls: an iterable containing URLs
:returns: True if any host has a listed match
:raises InvalidURLError: if there are any invalid URLs in
the sequence
"""
return any(urlparse... | python | def any_match(self, urls):
"""Check if any of the given URLs has a matching host.
:param urls: an iterable containing URLs
:returns: True if any host has a listed match
:raises InvalidURLError: if there are any invalid URLs in
the sequence
"""
return any(urlparse... | [
"def",
"any_match",
"(",
"self",
",",
"urls",
")",
":",
"return",
"any",
"(",
"urlparse",
"(",
"u",
")",
".",
"hostname",
"in",
"self",
"for",
"u",
"in",
"urls",
")"
] | Check if any of the given URLs has a matching host.
:param urls: an iterable containing URLs
:returns: True if any host has a listed match
:raises InvalidURLError: if there are any invalid URLs in
the sequence | [
"Check",
"if",
"any",
"of",
"the",
"given",
"URLs",
"has",
"a",
"matching",
"host",
"."
] | fd616e8761b28f3eaa503fee5e45f7748e8f88f2 | https://github.com/piotr-rusin/spam-lists/blob/fd616e8761b28f3eaa503fee5e45f7748e8f88f2/spam_lists/host_list.py#L93-L101 | train | Check if any of the given URLs has a matching host. |
piotr-rusin/spam-lists | spam_lists/host_list.py | HostList.lookup_matching | def lookup_matching(self, urls):
"""Get matching hosts for the given URLs.
:param urls: an iterable containing URLs
:returns: instances of AddressListItem representing listed
hosts matching the ones used by the given URLs
:raises InvalidURLError: if there are any invalid URLs in... | python | def lookup_matching(self, urls):
"""Get matching hosts for the given URLs.
:param urls: an iterable containing URLs
:returns: instances of AddressListItem representing listed
hosts matching the ones used by the given URLs
:raises InvalidURLError: if there are any invalid URLs in... | [
"def",
"lookup_matching",
"(",
"self",
",",
"urls",
")",
":",
"hosts",
"=",
"(",
"urlparse",
"(",
"u",
")",
".",
"hostname",
"for",
"u",
"in",
"urls",
")",
"for",
"val",
"in",
"hosts",
":",
"item",
"=",
"self",
".",
"lookup",
"(",
"val",
")",
"if... | Get matching hosts for the given URLs.
:param urls: an iterable containing URLs
:returns: instances of AddressListItem representing listed
hosts matching the ones used by the given URLs
:raises InvalidURLError: if there are any invalid URLs in
the sequence | [
"Get",
"matching",
"hosts",
"for",
"the",
"given",
"URLs",
"."
] | fd616e8761b28f3eaa503fee5e45f7748e8f88f2 | https://github.com/piotr-rusin/spam-lists/blob/fd616e8761b28f3eaa503fee5e45f7748e8f88f2/spam_lists/host_list.py#L104-L117 | train | Get matching hosts for the given URLs. |
piotr-rusin/spam-lists | spam_lists/host_list.py | HostList.filter_matching | def filter_matching(self, urls):
"""Get URLs with hosts matching any listed ones.
:param urls: an iterable containing URLs to filter
:returns: a generator yielding matching URLs
:raises InvalidURLError: if there are any invalid URLs in
the sequence
"""
for url in... | python | def filter_matching(self, urls):
"""Get URLs with hosts matching any listed ones.
:param urls: an iterable containing URLs to filter
:returns: a generator yielding matching URLs
:raises InvalidURLError: if there are any invalid URLs in
the sequence
"""
for url in... | [
"def",
"filter_matching",
"(",
"self",
",",
"urls",
")",
":",
"for",
"url",
"in",
"urls",
":",
"if",
"urlparse",
"(",
"url",
")",
".",
"hostname",
"in",
"self",
":",
"yield",
"url"
] | Get URLs with hosts matching any listed ones.
:param urls: an iterable containing URLs to filter
:returns: a generator yielding matching URLs
:raises InvalidURLError: if there are any invalid URLs in
the sequence | [
"Get",
"URLs",
"with",
"hosts",
"matching",
"any",
"listed",
"ones",
"."
] | fd616e8761b28f3eaa503fee5e45f7748e8f88f2 | https://github.com/piotr-rusin/spam-lists/blob/fd616e8761b28f3eaa503fee5e45f7748e8f88f2/spam_lists/host_list.py#L120-L130 | train | Get URLs with hosts matching any listed ones. |
TkTech/Jawa | jawa/util/utf.py | decode_modified_utf8 | def decode_modified_utf8(s: bytes) -> str:
"""
Decodes a bytestring containing modified UTF-8 as defined in section
4.4.7 of the JVM specification.
:param s: bytestring to be converted.
:returns: A unicode representation of the original string.
"""
s = bytearray(s)
buff = []
buffer_... | python | def decode_modified_utf8(s: bytes) -> str:
"""
Decodes a bytestring containing modified UTF-8 as defined in section
4.4.7 of the JVM specification.
:param s: bytestring to be converted.
:returns: A unicode representation of the original string.
"""
s = bytearray(s)
buff = []
buffer_... | [
"def",
"decode_modified_utf8",
"(",
"s",
":",
"bytes",
")",
"->",
"str",
":",
"s",
"=",
"bytearray",
"(",
"s",
")",
"buff",
"=",
"[",
"]",
"buffer_append",
"=",
"buff",
".",
"append",
"ix",
"=",
"0",
"while",
"ix",
"<",
"len",
"(",
"s",
")",
":",... | Decodes a bytestring containing modified UTF-8 as defined in section
4.4.7 of the JVM specification.
:param s: bytestring to be converted.
:returns: A unicode representation of the original string. | [
"Decodes",
"a",
"bytestring",
"containing",
"modified",
"UTF",
"-",
"8",
"as",
"defined",
"in",
"section",
"4",
".",
"4",
".",
"7",
"of",
"the",
"JVM",
"specification",
"."
] | 94c8424e699029ac33fbc0e866fff0ecb2742289 | https://github.com/TkTech/Jawa/blob/94c8424e699029ac33fbc0e866fff0ecb2742289/jawa/util/utf.py#L12-L52 | train | Decodes a bytestring containing modified UTF - 8 as defined in section 6. 4. 7 of the JVM specification. |
TkTech/Jawa | jawa/util/utf.py | encode_modified_utf8 | def encode_modified_utf8(u: str) -> bytearray:
"""
Encodes a unicode string as modified UTF-8 as defined in section 4.4.7
of the JVM specification.
:param u: unicode string to be converted.
:returns: A decoded bytearray.
"""
final_string = bytearray()
for c in [ord(char) for char in u]... | python | def encode_modified_utf8(u: str) -> bytearray:
"""
Encodes a unicode string as modified UTF-8 as defined in section 4.4.7
of the JVM specification.
:param u: unicode string to be converted.
:returns: A decoded bytearray.
"""
final_string = bytearray()
for c in [ord(char) for char in u]... | [
"def",
"encode_modified_utf8",
"(",
"u",
":",
"str",
")",
"->",
"bytearray",
":",
"final_string",
"=",
"bytearray",
"(",
")",
"for",
"c",
"in",
"[",
"ord",
"(",
"char",
")",
"for",
"char",
"in",
"u",
"]",
":",
"if",
"c",
"==",
"0x00",
"or",
"(",
... | Encodes a unicode string as modified UTF-8 as defined in section 4.4.7
of the JVM specification.
:param u: unicode string to be converted.
:returns: A decoded bytearray. | [
"Encodes",
"a",
"unicode",
"string",
"as",
"modified",
"UTF",
"-",
"8",
"as",
"defined",
"in",
"section",
"4",
".",
"4",
".",
"7",
"of",
"the",
"JVM",
"specification",
"."
] | 94c8424e699029ac33fbc0e866fff0ecb2742289 | https://github.com/TkTech/Jawa/blob/94c8424e699029ac33fbc0e866fff0ecb2742289/jawa/util/utf.py#L55-L80 | train | Encodes a unicode string as modified UTF - 8 as defined in section 4. 7. |
nitely/django-hooks | hooks/templatehook.py | Hook._register | def _register(self, name):
"""
@Api private
Add new :py:class:`TemplateHook` into the registry
:param str name: Hook name
:return: Instance of :py:class:`TemplateHook`
:rtype: :py:class:`TemplateHook`
"""
templatehook = TemplateHook()
self._regist... | python | def _register(self, name):
"""
@Api private
Add new :py:class:`TemplateHook` into the registry
:param str name: Hook name
:return: Instance of :py:class:`TemplateHook`
:rtype: :py:class:`TemplateHook`
"""
templatehook = TemplateHook()
self._regist... | [
"def",
"_register",
"(",
"self",
",",
"name",
")",
":",
"templatehook",
"=",
"TemplateHook",
"(",
")",
"self",
".",
"_registry",
"[",
"name",
"]",
"=",
"templatehook",
"return",
"templatehook"
] | @Api private
Add new :py:class:`TemplateHook` into the registry
:param str name: Hook name
:return: Instance of :py:class:`TemplateHook`
:rtype: :py:class:`TemplateHook` | [
"@Api",
"private",
"Add",
"new",
":",
"py",
":",
"class",
":",
"TemplateHook",
"into",
"the",
"registry"
] | 26ea2150c9be110e90b9ee60fbfd1065ac30ab1d | https://github.com/nitely/django-hooks/blob/26ea2150c9be110e90b9ee60fbfd1065ac30ab1d/hooks/templatehook.py#L86-L97 | train | Private method to register a new template hook into the registry. |
nitely/django-hooks | hooks/templatehook.py | Hook.register | def register(self, name, func):
"""
Register a new callback.\
When the name/id is not found\
a new hook is created under its name,\
meaning the hook is usually created by\
the first registered callback
:param str name: Hook name
:param callable func: A fu... | python | def register(self, name, func):
"""
Register a new callback.\
When the name/id is not found\
a new hook is created under its name,\
meaning the hook is usually created by\
the first registered callback
:param str name: Hook name
:param callable func: A fu... | [
"def",
"register",
"(",
"self",
",",
"name",
",",
"func",
")",
":",
"try",
":",
"templatehook",
"=",
"self",
".",
"_registry",
"[",
"name",
"]",
"except",
"KeyError",
":",
"templatehook",
"=",
"self",
".",
"_register",
"(",
"name",
")",
"templatehook",
... | Register a new callback.\
When the name/id is not found\
a new hook is created under its name,\
meaning the hook is usually created by\
the first registered callback
:param str name: Hook name
:param callable func: A func reference (callback) | [
"Register",
"a",
"new",
"callback",
".",
"\\",
"When",
"the",
"name",
"/",
"id",
"is",
"not",
"found",
"\\",
"a",
"new",
"hook",
"is",
"created",
"under",
"its",
"name",
"\\",
"meaning",
"the",
"hook",
"is",
"usually",
"created",
"by",
"\\",
"the",
"... | 26ea2150c9be110e90b9ee60fbfd1065ac30ab1d | https://github.com/nitely/django-hooks/blob/26ea2150c9be110e90b9ee60fbfd1065ac30ab1d/hooks/templatehook.py#L99-L115 | train | Register a new callback. |
nitely/django-hooks | hooks/templatehook.py | Hook.unregister | def unregister(self, name, func):
"""
Remove a previously registered callback
:param str name: Hook name
:param callable func: A function reference\
that was registered previously
"""
try:
templatehook = self._registry[name]
except KeyError:
... | python | def unregister(self, name, func):
"""
Remove a previously registered callback
:param str name: Hook name
:param callable func: A function reference\
that was registered previously
"""
try:
templatehook = self._registry[name]
except KeyError:
... | [
"def",
"unregister",
"(",
"self",
",",
"name",
",",
"func",
")",
":",
"try",
":",
"templatehook",
"=",
"self",
".",
"_registry",
"[",
"name",
"]",
"except",
"KeyError",
":",
"return",
"templatehook",
".",
"unregister",
"(",
"func",
")"
] | Remove a previously registered callback
:param str name: Hook name
:param callable func: A function reference\
that was registered previously | [
"Remove",
"a",
"previously",
"registered",
"callback"
] | 26ea2150c9be110e90b9ee60fbfd1065ac30ab1d | https://github.com/nitely/django-hooks/blob/26ea2150c9be110e90b9ee60fbfd1065ac30ab1d/hooks/templatehook.py#L117-L130 | train | Unregister a previously registered callback |
nitely/django-hooks | hooks/templatehook.py | Hook.unregister_all | def unregister_all(self, name):
"""
Remove all callbacks
:param str name: Hook name
"""
try:
templatehook = self._registry[name]
except KeyError:
return
templatehook.unregister_all() | python | def unregister_all(self, name):
"""
Remove all callbacks
:param str name: Hook name
"""
try:
templatehook = self._registry[name]
except KeyError:
return
templatehook.unregister_all() | [
"def",
"unregister_all",
"(",
"self",
",",
"name",
")",
":",
"try",
":",
"templatehook",
"=",
"self",
".",
"_registry",
"[",
"name",
"]",
"except",
"KeyError",
":",
"return",
"templatehook",
".",
"unregister_all",
"(",
")"
] | Remove all callbacks
:param str name: Hook name | [
"Remove",
"all",
"callbacks"
] | 26ea2150c9be110e90b9ee60fbfd1065ac30ab1d | https://github.com/nitely/django-hooks/blob/26ea2150c9be110e90b9ee60fbfd1065ac30ab1d/hooks/templatehook.py#L132-L143 | train | Remove all callbacks for a specific hook |
mezz64/pyEmby | pyemby/helpers.py | deprecated_name | def deprecated_name(name):
"""Allow old method names for backwards compatability. """
def decorator(func):
"""Decorator function."""
def func_wrapper(self):
"""Wrapper for original function."""
if hasattr(self, name):
# Return the old property
... | python | def deprecated_name(name):
"""Allow old method names for backwards compatability. """
def decorator(func):
"""Decorator function."""
def func_wrapper(self):
"""Wrapper for original function."""
if hasattr(self, name):
# Return the old property
... | [
"def",
"deprecated_name",
"(",
"name",
")",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"\"\"\"Decorator function.\"\"\"",
"def",
"func_wrapper",
"(",
"self",
")",
":",
"\"\"\"Wrapper for original function.\"\"\"",
"if",
"hasattr",
"(",
"self",
",",
"name",
")... | Allow old method names for backwards compatability. | [
"Allow",
"old",
"method",
"names",
"for",
"backwards",
"compatability",
"."
] | 6bb621e4e25bf1b9b0aba2c38b588e68f8816226 | https://github.com/mezz64/pyEmby/blob/6bb621e4e25bf1b9b0aba2c38b588e68f8816226/pyemby/helpers.py#L10-L22 | train | Allow old method names for backwards compatability. |
rhattersley/pyepsg | pyepsg.py | get | def get(code):
"""
Return an object that corresponds to the given EPSG code.
Currently supported object types are:
- :class:`GeodeticCRS`
- :class:`ProjectedCRS`
- :class:`CartesianCS`
- :class:`UOM`
For example::
>>> print(get(27700))
<ProjectedCRS: 27... | python | def get(code):
"""
Return an object that corresponds to the given EPSG code.
Currently supported object types are:
- :class:`GeodeticCRS`
- :class:`ProjectedCRS`
- :class:`CartesianCS`
- :class:`UOM`
For example::
>>> print(get(27700))
<ProjectedCRS: 27... | [
"def",
"get",
"(",
"code",
")",
":",
"instance",
"=",
"_cache",
".",
"get",
"(",
"code",
")",
"if",
"instance",
"is",
"None",
":",
"url",
"=",
"'{prefix}{code}.gml?download'",
".",
"format",
"(",
"prefix",
"=",
"EPSG_IO_URL",
",",
"code",
"=",
"code",
... | Return an object that corresponds to the given EPSG code.
Currently supported object types are:
- :class:`GeodeticCRS`
- :class:`ProjectedCRS`
- :class:`CartesianCS`
- :class:`UOM`
For example::
>>> print(get(27700))
<ProjectedCRS: 27700, OSGB 1936 / British Na... | [
"Return",
"an",
"object",
"that",
"corresponds",
"to",
"the",
"given",
"EPSG",
"code",
"."
] | 0ddd79287f8d42483c8f70ce50aba1cc6b5d780a | https://github.com/rhattersley/pyepsg/blob/0ddd79287f8d42483c8f70ce50aba1cc6b5d780a/pyepsg.py#L263-L301 | train | Get an object that corresponds to the given EPSG code. |
rhattersley/pyepsg | pyepsg.py | CartesianCS.axes | def axes(self):
"""An ordered list of :class:`Axis` objects describing X and Y."""
axes = self.element.findall(GML_NS + 'axis')
return [Axis(axis.find(GML_NS + 'CoordinateSystemAxis')) for
axis in axes] | python | def axes(self):
"""An ordered list of :class:`Axis` objects describing X and Y."""
axes = self.element.findall(GML_NS + 'axis')
return [Axis(axis.find(GML_NS + 'CoordinateSystemAxis')) for
axis in axes] | [
"def",
"axes",
"(",
"self",
")",
":",
"axes",
"=",
"self",
".",
"element",
".",
"findall",
"(",
"GML_NS",
"+",
"'axis'",
")",
"return",
"[",
"Axis",
"(",
"axis",
".",
"find",
"(",
"GML_NS",
"+",
"'CoordinateSystemAxis'",
")",
")",
"for",
"axis",
"in"... | An ordered list of :class:`Axis` objects describing X and Y. | [
"An",
"ordered",
"list",
"of",
":",
"class",
":",
"Axis",
"objects",
"describing",
"X",
"and",
"Y",
"."
] | 0ddd79287f8d42483c8f70ce50aba1cc6b5d780a | https://github.com/rhattersley/pyepsg/blob/0ddd79287f8d42483c8f70ce50aba1cc6b5d780a/pyepsg.py#L81-L85 | train | An ordered list of Axis objects describing X and Y. |
rhattersley/pyepsg | pyepsg.py | CRS.id | def id(self):
"""The EPSG code for this CRS."""
id = self.element.attrib[GML_NS + 'id']
code = id.split('-')[-1]
return code | python | def id(self):
"""The EPSG code for this CRS."""
id = self.element.attrib[GML_NS + 'id']
code = id.split('-')[-1]
return code | [
"def",
"id",
"(",
"self",
")",
":",
"id",
"=",
"self",
".",
"element",
".",
"attrib",
"[",
"GML_NS",
"+",
"'id'",
"]",
"code",
"=",
"id",
".",
"split",
"(",
"'-'",
")",
"[",
"-",
"1",
"]",
"return",
"code"
] | The EPSG code for this CRS. | [
"The",
"EPSG",
"code",
"for",
"this",
"CRS",
"."
] | 0ddd79287f8d42483c8f70ce50aba1cc6b5d780a | https://github.com/rhattersley/pyepsg/blob/0ddd79287f8d42483c8f70ce50aba1cc6b5d780a/pyepsg.py#L112-L116 | train | The EPSG code for this CRS. |
rhattersley/pyepsg | pyepsg.py | CRS.as_html | def as_html(self):
"""
Return the OGC WKT which corresponds to the CRS as HTML.
For example::
>>> print(get(27700).as_html()) # doctest: +ELLIPSIS
<div class="syntax"><pre><span class="gh">PROJCS</span><span...
"""
url = '{prefix}{code}.html?download'.... | python | def as_html(self):
"""
Return the OGC WKT which corresponds to the CRS as HTML.
For example::
>>> print(get(27700).as_html()) # doctest: +ELLIPSIS
<div class="syntax"><pre><span class="gh">PROJCS</span><span...
"""
url = '{prefix}{code}.html?download'.... | [
"def",
"as_html",
"(",
"self",
")",
":",
"url",
"=",
"'{prefix}{code}.html?download'",
".",
"format",
"(",
"prefix",
"=",
"EPSG_IO_URL",
",",
"code",
"=",
"self",
".",
"id",
")",
"return",
"requests",
".",
"get",
"(",
"url",
")",
".",
"text"
] | Return the OGC WKT which corresponds to the CRS as HTML.
For example::
>>> print(get(27700).as_html()) # doctest: +ELLIPSIS
<div class="syntax"><pre><span class="gh">PROJCS</span><span... | [
"Return",
"the",
"OGC",
"WKT",
"which",
"corresponds",
"to",
"the",
"CRS",
"as",
"HTML",
"."
] | 0ddd79287f8d42483c8f70ce50aba1cc6b5d780a | https://github.com/rhattersley/pyepsg/blob/0ddd79287f8d42483c8f70ce50aba1cc6b5d780a/pyepsg.py#L142-L154 | train | Return the OGC WKT which corresponds to the CRS as HTML. |
rhattersley/pyepsg | pyepsg.py | CRS.as_proj4 | def as_proj4(self):
"""
Return the PROJ.4 string which corresponds to the CRS.
For example::
>>> print(get(21781).as_proj4())
+proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 \
+k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel \
+towgs84=674.4,15.1,405.3,0,0,0,... | python | def as_proj4(self):
"""
Return the PROJ.4 string which corresponds to the CRS.
For example::
>>> print(get(21781).as_proj4())
+proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 \
+k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel \
+towgs84=674.4,15.1,405.3,0,0,0,... | [
"def",
"as_proj4",
"(",
"self",
")",
":",
"url",
"=",
"'{prefix}{code}.proj4?download'",
".",
"format",
"(",
"prefix",
"=",
"EPSG_IO_URL",
",",
"code",
"=",
"self",
".",
"id",
")",
"return",
"requests",
".",
"get",
"(",
"url",
")",
".",
"text",
".",
"s... | Return the PROJ.4 string which corresponds to the CRS.
For example::
>>> print(get(21781).as_proj4())
+proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 \
+k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel \
+towgs84=674.4,15.1,405.3,0,0,0,0 +units=m +no_defs | [
"Return",
"the",
"PROJ",
".",
"4",
"string",
"which",
"corresponds",
"to",
"the",
"CRS",
"."
] | 0ddd79287f8d42483c8f70ce50aba1cc6b5d780a | https://github.com/rhattersley/pyepsg/blob/0ddd79287f8d42483c8f70ce50aba1cc6b5d780a/pyepsg.py#L156-L170 | train | Return the PROJ. 4 string which corresponds to the CRS. |
rhattersley/pyepsg | pyepsg.py | CRS.domain_of_validity | def domain_of_validity(self):
"""
Return the domain of validity for this CRS as:
(west, east, south, north).
For example::
>>> print(get(21781).domain_of_validity())
[5.96, 10.49, 45.82, 47.81]
"""
# TODO: Generalise interface to return a polyg... | python | def domain_of_validity(self):
"""
Return the domain of validity for this CRS as:
(west, east, south, north).
For example::
>>> print(get(21781).domain_of_validity())
[5.96, 10.49, 45.82, 47.81]
"""
# TODO: Generalise interface to return a polyg... | [
"def",
"domain_of_validity",
"(",
"self",
")",
":",
"# TODO: Generalise interface to return a polygon? (Can we find",
"# something that uses a polygon instead?)",
"domain",
"=",
"self",
".",
"element",
".",
"find",
"(",
"GML_NS",
"+",
"'domainOfValidity'",
")",
"domain_href",... | Return the domain of validity for this CRS as:
(west, east, south, north).
For example::
>>> print(get(21781).domain_of_validity())
[5.96, 10.49, 45.82, 47.81] | [
"Return",
"the",
"domain",
"of",
"validity",
"for",
"this",
"CRS",
"as",
":",
"(",
"west",
"east",
"south",
"north",
")",
"."
] | 0ddd79287f8d42483c8f70ce50aba1cc6b5d780a | https://github.com/rhattersley/pyepsg/blob/0ddd79287f8d42483c8f70ce50aba1cc6b5d780a/pyepsg.py#L186-L218 | train | Return the domain of validity for this CRS as a list of tuples. |
rhattersley/pyepsg | pyepsg.py | ProjectedCRS.base_geodetic_crs | def base_geodetic_crs(self):
"""The :class:`GeodeticCRS` on which this projection is based."""
base = self.element.find(GML_NS + 'baseGeodeticCRS')
href = base.attrib[XLINK_NS + 'href']
return get(href) | python | def base_geodetic_crs(self):
"""The :class:`GeodeticCRS` on which this projection is based."""
base = self.element.find(GML_NS + 'baseGeodeticCRS')
href = base.attrib[XLINK_NS + 'href']
return get(href) | [
"def",
"base_geodetic_crs",
"(",
"self",
")",
":",
"base",
"=",
"self",
".",
"element",
".",
"find",
"(",
"GML_NS",
"+",
"'baseGeodeticCRS'",
")",
"href",
"=",
"base",
".",
"attrib",
"[",
"XLINK_NS",
"+",
"'href'",
"]",
"return",
"get",
"(",
"href",
")... | The :class:`GeodeticCRS` on which this projection is based. | [
"The",
":",
"class",
":",
"GeodeticCRS",
"on",
"which",
"this",
"projection",
"is",
"based",
"."
] | 0ddd79287f8d42483c8f70ce50aba1cc6b5d780a | https://github.com/rhattersley/pyepsg/blob/0ddd79287f8d42483c8f70ce50aba1cc6b5d780a/pyepsg.py#L237-L241 | train | The base Geodetic CRS on which this projection is based. |
rhattersley/pyepsg | pyepsg.py | ProjectedCRS.cartesian_cs | def cartesian_cs(self):
"""The :class:`CartesianCS` which describes the coordinate axes."""
cs = self.element.find(GML_NS + 'cartesianCS')
href = cs.attrib[XLINK_NS + 'href']
return get(href) | python | def cartesian_cs(self):
"""The :class:`CartesianCS` which describes the coordinate axes."""
cs = self.element.find(GML_NS + 'cartesianCS')
href = cs.attrib[XLINK_NS + 'href']
return get(href) | [
"def",
"cartesian_cs",
"(",
"self",
")",
":",
"cs",
"=",
"self",
".",
"element",
".",
"find",
"(",
"GML_NS",
"+",
"'cartesianCS'",
")",
"href",
"=",
"cs",
".",
"attrib",
"[",
"XLINK_NS",
"+",
"'href'",
"]",
"return",
"get",
"(",
"href",
")"
] | The :class:`CartesianCS` which describes the coordinate axes. | [
"The",
":",
"class",
":",
"CartesianCS",
"which",
"describes",
"the",
"coordinate",
"axes",
"."
] | 0ddd79287f8d42483c8f70ce50aba1cc6b5d780a | https://github.com/rhattersley/pyepsg/blob/0ddd79287f8d42483c8f70ce50aba1cc6b5d780a/pyepsg.py#L244-L248 | train | The CartesianCS which describes the coordinate axes. |
snowman2/pangaea | pangaea/log.py | log_to_console | def log_to_console(status=True, level=None):
"""Log events to the console.
Args:
status (bool, Optional, Default=True)
whether logging to console should be turned on(True) or off(False)
level (string, Optional, Default=None) :
level of logging; whichever level is chosen... | python | def log_to_console(status=True, level=None):
"""Log events to the console.
Args:
status (bool, Optional, Default=True)
whether logging to console should be turned on(True) or off(False)
level (string, Optional, Default=None) :
level of logging; whichever level is chosen... | [
"def",
"log_to_console",
"(",
"status",
"=",
"True",
",",
"level",
"=",
"None",
")",
":",
"if",
"status",
":",
"if",
"level",
"is",
"not",
"None",
":",
"LOGGER",
".",
"setLevel",
"(",
"level",
")",
"console_handler",
"=",
"logging",
".",
"StreamHandler",... | Log events to the console.
Args:
status (bool, Optional, Default=True)
whether logging to console should be turned on(True) or off(False)
level (string, Optional, Default=None) :
level of logging; whichever level is chosen all higher levels
will be logged.
... | [
"Log",
"events",
"to",
"the",
"console",
"."
] | a304e9a489cfc0bc1c74e7cb50c3335a4f3d596f | https://github.com/snowman2/pangaea/blob/a304e9a489cfc0bc1c74e7cb50c3335a4f3d596f/pangaea/log.py#L30-L58 | train | Log events to the console. |
snowman2/pangaea | pangaea/log.py | log_to_file | def log_to_file(status=True, filename=DEFAULT_LOG_FILE, level=None):
"""Log events to a file.
Args:
status (bool, Optional, Default=True)
whether logging to file should be turned on(True) or off(False)
filename (string, Optional, Default=None) :
path of file to log to
... | python | def log_to_file(status=True, filename=DEFAULT_LOG_FILE, level=None):
"""Log events to a file.
Args:
status (bool, Optional, Default=True)
whether logging to file should be turned on(True) or off(False)
filename (string, Optional, Default=None) :
path of file to log to
... | [
"def",
"log_to_file",
"(",
"status",
"=",
"True",
",",
"filename",
"=",
"DEFAULT_LOG_FILE",
",",
"level",
"=",
"None",
")",
":",
"if",
"status",
":",
"if",
"level",
"is",
"not",
"None",
":",
"LOGGER",
".",
"setLevel",
"(",
"level",
")",
"try",
":",
"... | Log events to a file.
Args:
status (bool, Optional, Default=True)
whether logging to file should be turned on(True) or off(False)
filename (string, Optional, Default=None) :
path of file to log to
level (string, Optional, Default=None) :
level of logging;... | [
"Log",
"events",
"to",
"a",
"file",
"."
] | a304e9a489cfc0bc1c74e7cb50c3335a4f3d596f | https://github.com/snowman2/pangaea/blob/a304e9a489cfc0bc1c74e7cb50c3335a4f3d596f/pangaea/log.py#L61-L97 | train | Log events to a file. |
TkTech/Jawa | jawa/methods.py | MethodTable.remove | def remove(self, method: Method):
"""
Removes a `method` from the table by identity.
"""
self._table = [fld for fld in self._table if fld is not method] | python | def remove(self, method: Method):
"""
Removes a `method` from the table by identity.
"""
self._table = [fld for fld in self._table if fld is not method] | [
"def",
"remove",
"(",
"self",
",",
"method",
":",
"Method",
")",
":",
"self",
".",
"_table",
"=",
"[",
"fld",
"for",
"fld",
"in",
"self",
".",
"_table",
"if",
"fld",
"is",
"not",
"method",
"]"
] | Removes a `method` from the table by identity. | [
"Removes",
"a",
"method",
"from",
"the",
"table",
"by",
"identity",
"."
] | 94c8424e699029ac33fbc0e866fff0ecb2742289 | https://github.com/TkTech/Jawa/blob/94c8424e699029ac33fbc0e866fff0ecb2742289/jawa/methods.py#L122-L126 | train | Removes a method from the table by identity. |
TkTech/Jawa | jawa/methods.py | MethodTable.create | def create(self, name: str, descriptor: str,
code: CodeAttribute=None) -> Method:
"""
Creates a new method from `name` and `descriptor`. If `code` is not
``None``, add a `Code` attribute to this method.
"""
method = Method(self._cf)
name = self._cf.constant... | python | def create(self, name: str, descriptor: str,
code: CodeAttribute=None) -> Method:
"""
Creates a new method from `name` and `descriptor`. If `code` is not
``None``, add a `Code` attribute to this method.
"""
method = Method(self._cf)
name = self._cf.constant... | [
"def",
"create",
"(",
"self",
",",
"name",
":",
"str",
",",
"descriptor",
":",
"str",
",",
"code",
":",
"CodeAttribute",
"=",
"None",
")",
"->",
"Method",
":",
"method",
"=",
"Method",
"(",
"self",
".",
"_cf",
")",
"name",
"=",
"self",
".",
"_cf",
... | Creates a new method from `name` and `descriptor`. If `code` is not
``None``, add a `Code` attribute to this method. | [
"Creates",
"a",
"new",
"method",
"from",
"name",
"and",
"descriptor",
".",
"If",
"code",
"is",
"not",
"None",
"add",
"a",
"Code",
"attribute",
"to",
"this",
"method",
"."
] | 94c8424e699029ac33fbc0e866fff0ecb2742289 | https://github.com/TkTech/Jawa/blob/94c8424e699029ac33fbc0e866fff0ecb2742289/jawa/methods.py#L128-L145 | train | Creates a new method from name and descriptor. |
TkTech/Jawa | jawa/methods.py | MethodTable.unpack | def unpack(self, source: IO):
"""
Read the MethodTable from the file-like object `source`.
.. note::
Advanced usage only. You will typically never need to call this
method as it will be called for you when loading a ClassFile.
:param source: Any file-like objec... | python | def unpack(self, source: IO):
"""
Read the MethodTable from the file-like object `source`.
.. note::
Advanced usage only. You will typically never need to call this
method as it will be called for you when loading a ClassFile.
:param source: Any file-like objec... | [
"def",
"unpack",
"(",
"self",
",",
"source",
":",
"IO",
")",
":",
"method_count",
"=",
"unpack",
"(",
"'>H'",
",",
"source",
".",
"read",
"(",
"2",
")",
")",
"[",
"0",
"]",
"for",
"_",
"in",
"repeat",
"(",
"None",
",",
"method_count",
")",
":",
... | Read the MethodTable from the file-like object `source`.
.. note::
Advanced usage only. You will typically never need to call this
method as it will be called for you when loading a ClassFile.
:param source: Any file-like object providing `read()` | [
"Read",
"the",
"MethodTable",
"from",
"the",
"file",
"-",
"like",
"object",
"source",
"."
] | 94c8424e699029ac33fbc0e866fff0ecb2742289 | https://github.com/TkTech/Jawa/blob/94c8424e699029ac33fbc0e866fff0ecb2742289/jawa/methods.py#L151-L166 | train | Read the MethodTable from the file - like object source. |
TkTech/Jawa | jawa/methods.py | MethodTable.pack | def pack(self, out: IO):
"""
Write the MethodTable to the file-like object `out`.
.. note::
Advanced usage only. You will typically never need to call this
method as it will be called for you when saving a ClassFile.
:param out: Any file-like object providing `... | python | def pack(self, out: IO):
"""
Write the MethodTable to the file-like object `out`.
.. note::
Advanced usage only. You will typically never need to call this
method as it will be called for you when saving a ClassFile.
:param out: Any file-like object providing `... | [
"def",
"pack",
"(",
"self",
",",
"out",
":",
"IO",
")",
":",
"out",
".",
"write",
"(",
"pack",
"(",
"'>H'",
",",
"len",
"(",
"self",
")",
")",
")",
"for",
"method",
"in",
"self",
".",
"_table",
":",
"method",
".",
"pack",
"(",
"out",
")"
] | Write the MethodTable to the file-like object `out`.
.. note::
Advanced usage only. You will typically never need to call this
method as it will be called for you when saving a ClassFile.
:param out: Any file-like object providing `write()` | [
"Write",
"the",
"MethodTable",
"to",
"the",
"file",
"-",
"like",
"object",
"out",
"."
] | 94c8424e699029ac33fbc0e866fff0ecb2742289 | https://github.com/TkTech/Jawa/blob/94c8424e699029ac33fbc0e866fff0ecb2742289/jawa/methods.py#L168-L181 | train | Write the MethodTable to out. |
TkTech/Jawa | jawa/methods.py | MethodTable.find | def find(self, *, name: str=None, args: str=None, returns: str=None,
f: Callable=None) -> Iterator[Method]:
"""
Iterates over the methods table, yielding each matching method. Calling
without any arguments is equivalent to iterating over the table. For
example, to get all me... | python | def find(self, *, name: str=None, args: str=None, returns: str=None,
f: Callable=None) -> Iterator[Method]:
"""
Iterates over the methods table, yielding each matching method. Calling
without any arguments is equivalent to iterating over the table. For
example, to get all me... | [
"def",
"find",
"(",
"self",
",",
"*",
",",
"name",
":",
"str",
"=",
"None",
",",
"args",
":",
"str",
"=",
"None",
",",
"returns",
":",
"str",
"=",
"None",
",",
"f",
":",
"Callable",
"=",
"None",
")",
"->",
"Iterator",
"[",
"Method",
"]",
":",
... | Iterates over the methods table, yielding each matching method. Calling
without any arguments is equivalent to iterating over the table. For
example, to get all methods that take three integers and return void::
for method in cf.methods.find(args='III', returns='V'):
print(m... | [
"Iterates",
"over",
"the",
"methods",
"table",
"yielding",
"each",
"matching",
"method",
".",
"Calling",
"without",
"any",
"arguments",
"is",
"equivalent",
"to",
"iterating",
"over",
"the",
"table",
".",
"For",
"example",
"to",
"get",
"all",
"methods",
"that",... | 94c8424e699029ac33fbc0e866fff0ecb2742289 | https://github.com/TkTech/Jawa/blob/94c8424e699029ac33fbc0e866fff0ecb2742289/jawa/methods.py#L183-L222 | train | Iterates over the methods table yielding each matching method. |
TkTech/Jawa | jawa/attributes/code.py | CodeAttribute.unpack | def unpack(self, info):
"""
Read the CodeAttribute from the byte string `info`.
.. note::
Advanced usage only. You will typically never need to call this
method as it will be called for you when loading a ClassFile.
:param info: A byte string containing an unpa... | python | def unpack(self, info):
"""
Read the CodeAttribute from the byte string `info`.
.. note::
Advanced usage only. You will typically never need to call this
method as it will be called for you when loading a ClassFile.
:param info: A byte string containing an unpa... | [
"def",
"unpack",
"(",
"self",
",",
"info",
")",
":",
"self",
".",
"max_stack",
",",
"self",
".",
"max_locals",
",",
"c_len",
"=",
"info",
".",
"unpack",
"(",
"'>HHI'",
")",
"self",
".",
"_code",
"=",
"info",
".",
"read",
"(",
"c_len",
")",
"# The e... | Read the CodeAttribute from the byte string `info`.
.. note::
Advanced usage only. You will typically never need to call this
method as it will be called for you when loading a ClassFile.
:param info: A byte string containing an unparsed CodeAttribute. | [
"Read",
"the",
"CodeAttribute",
"from",
"the",
"byte",
"string",
"info",
"."
] | 94c8424e699029ac33fbc0e866fff0ecb2742289 | https://github.com/TkTech/Jawa/blob/94c8424e699029ac33fbc0e866fff0ecb2742289/jawa/attributes/code.py#L70-L91 | train | Read the CodeAttribute from the byte string info. |
TkTech/Jawa | jawa/attributes/code.py | CodeAttribute.pack | def pack(self):
"""
The `CodeAttribute` in packed byte string form.
"""
with io.BytesIO() as file_out:
file_out.write(pack(
'>HHI',
self.max_stack,
self.max_locals,
len(self._code)
))
file... | python | def pack(self):
"""
The `CodeAttribute` in packed byte string form.
"""
with io.BytesIO() as file_out:
file_out.write(pack(
'>HHI',
self.max_stack,
self.max_locals,
len(self._code)
))
file... | [
"def",
"pack",
"(",
"self",
")",
":",
"with",
"io",
".",
"BytesIO",
"(",
")",
"as",
"file_out",
":",
"file_out",
".",
"write",
"(",
"pack",
"(",
"'>HHI'",
",",
"self",
".",
"max_stack",
",",
"self",
".",
"max_locals",
",",
"len",
"(",
"self",
".",
... | The `CodeAttribute` in packed byte string form. | [
"The",
"CodeAttribute",
"in",
"packed",
"byte",
"string",
"form",
"."
] | 94c8424e699029ac33fbc0e866fff0ecb2742289 | https://github.com/TkTech/Jawa/blob/94c8424e699029ac33fbc0e866fff0ecb2742289/jawa/attributes/code.py#L93-L111 | train | Returns a byte string form of the code attribute. |
TkTech/Jawa | jawa/attributes/code.py | CodeAttribute.assemble | def assemble(self, code):
"""
Assembles an iterable of :class:`~jawa.util.bytecode.Instruction`
objects into a method's code body.
"""
with io.BytesIO() as code_out:
for ins in code:
write_instruction(code_out, code_out.tell(), ins)
self._c... | python | def assemble(self, code):
"""
Assembles an iterable of :class:`~jawa.util.bytecode.Instruction`
objects into a method's code body.
"""
with io.BytesIO() as code_out:
for ins in code:
write_instruction(code_out, code_out.tell(), ins)
self._c... | [
"def",
"assemble",
"(",
"self",
",",
"code",
")",
":",
"with",
"io",
".",
"BytesIO",
"(",
")",
"as",
"code_out",
":",
"for",
"ins",
"in",
"code",
":",
"write_instruction",
"(",
"code_out",
",",
"code_out",
".",
"tell",
"(",
")",
",",
"ins",
")",
"s... | Assembles an iterable of :class:`~jawa.util.bytecode.Instruction`
objects into a method's code body. | [
"Assembles",
"an",
"iterable",
"of",
":",
"class",
":",
"~jawa",
".",
"util",
".",
"bytecode",
".",
"Instruction",
"objects",
"into",
"a",
"method",
"s",
"code",
"body",
"."
] | 94c8424e699029ac33fbc0e866fff0ecb2742289 | https://github.com/TkTech/Jawa/blob/94c8424e699029ac33fbc0e866fff0ecb2742289/jawa/attributes/code.py#L113-L121 | train | Assembles an iterable of ~jawa. util. bytecode. Instruction objects into a method s code body. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.