repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens listlengths 20 707 | docstring stringlengths 3 17.3k | docstring_tokens listlengths 3 222 | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value | idx int64 0 252k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
calmjs/nunja | src/nunja/engine.py | Engine.execute | def execute(self, mold_id, data, wrapper_tag='div'):
"""
Execute a mold `mold_id` by rendering through ``env``.
This is done using its default template, with data provided as
dict.
This returns the wrapped content, which contains the bits that
the client-side on-load sc... | python | def execute(self, mold_id, data, wrapper_tag='div'):
"""
Execute a mold `mold_id` by rendering through ``env``.
This is done using its default template, with data provided as
dict.
This returns the wrapped content, which contains the bits that
the client-side on-load sc... | [
"def",
"execute",
"(",
"self",
",",
"mold_id",
",",
"data",
",",
"wrapper_tag",
"=",
"'div'",
")",
":",
"template",
"=",
"self",
".",
"load_mold",
"(",
"mold_id",
")",
"kwargs",
"=",
"{",
"}",
"kwargs",
".",
"update",
"(",
"data",
")",
"kwargs",
"[",... | Execute a mold `mold_id` by rendering through ``env``.
This is done using its default template, with data provided as
dict.
This returns the wrapped content, which contains the bits that
the client-side on-load script trigger will execute the index.js
defined for this mold; if ... | [
"Execute",
"a",
"mold",
"mold_id",
"by",
"rendering",
"through",
"env",
"."
] | 37ba114ca2239322718fd9994bb078c037682c33 | https://github.com/calmjs/nunja/blob/37ba114ca2239322718fd9994bb078c037682c33/src/nunja/engine.py#L101-L122 | train | 58,100 |
calmjs/nunja | src/nunja/engine.py | Engine.render | def render(self, mold_id, data):
"""
Render a mold `mold_id`. No wrappers are applied as only the
default template defined for the mold is rendered.
"""
template = self.load_mold(mold_id)
return template.render(**data) | python | def render(self, mold_id, data):
"""
Render a mold `mold_id`. No wrappers are applied as only the
default template defined for the mold is rendered.
"""
template = self.load_mold(mold_id)
return template.render(**data) | [
"def",
"render",
"(",
"self",
",",
"mold_id",
",",
"data",
")",
":",
"template",
"=",
"self",
".",
"load_mold",
"(",
"mold_id",
")",
"return",
"template",
".",
"render",
"(",
"*",
"*",
"data",
")"
] | Render a mold `mold_id`. No wrappers are applied as only the
default template defined for the mold is rendered. | [
"Render",
"a",
"mold",
"mold_id",
".",
"No",
"wrappers",
"are",
"applied",
"as",
"only",
"the",
"default",
"template",
"defined",
"for",
"the",
"mold",
"is",
"rendered",
"."
] | 37ba114ca2239322718fd9994bb078c037682c33 | https://github.com/calmjs/nunja/blob/37ba114ca2239322718fd9994bb078c037682c33/src/nunja/engine.py#L124-L131 | train | 58,101 |
hatemile/hatemile-for-python | hatemile/implementation/assoc.py | AccessibleAssociationImplementation._get_model_table | def _get_model_table(self, part):
"""
Returns a list that represents the table.
:param part: The table header, table footer or table body.
:type part: hatemile.util.html.htmldomelement.HTMLDOMElement
:return: The list that represents the table.
:rtype: list(list(hatemile... | python | def _get_model_table(self, part):
"""
Returns a list that represents the table.
:param part: The table header, table footer or table body.
:type part: hatemile.util.html.htmldomelement.HTMLDOMElement
:return: The list that represents the table.
:rtype: list(list(hatemile... | [
"def",
"_get_model_table",
"(",
"self",
",",
"part",
")",
":",
"rows",
"=",
"self",
".",
"parser",
".",
"find",
"(",
"part",
")",
".",
"find_children",
"(",
"'tr'",
")",
".",
"list_results",
"(",
")",
"table",
"=",
"[",
"]",
"for",
"row",
"in",
"ro... | Returns a list that represents the table.
:param part: The table header, table footer or table body.
:type part: hatemile.util.html.htmldomelement.HTMLDOMElement
:return: The list that represents the table.
:rtype: list(list(hatemile.util.html.htmldomelement.HTMLDOMElement)) | [
"Returns",
"a",
"list",
"that",
"represents",
"the",
"table",
"."
] | 1e914f9aa09f6f8d78282af131311546ecba9fb8 | https://github.com/hatemile/hatemile-for-python/blob/1e914f9aa09f6f8d78282af131311546ecba9fb8/hatemile/implementation/assoc.py#L46-L62 | train | 58,102 |
hatemile/hatemile-for-python | hatemile/implementation/assoc.py | AccessibleAssociationImplementation._get_valid_model_table | def _get_valid_model_table(self, ros):
"""
Returns a list that represents the table with the rowspans.
:param ros: The list that represents the table without the rowspans.
:type ros: list(list(hatemile.util.html.htmldomelement.HTMLDOMElement))
:return The list that represents th... | python | def _get_valid_model_table(self, ros):
"""
Returns a list that represents the table with the rowspans.
:param ros: The list that represents the table without the rowspans.
:type ros: list(list(hatemile.util.html.htmldomelement.HTMLDOMElement))
:return The list that represents th... | [
"def",
"_get_valid_model_table",
"(",
"self",
",",
"ros",
")",
":",
"# pylint: disable=no-self-use",
"new_table",
"=",
"[",
"]",
"if",
"bool",
"(",
"ros",
")",
":",
"length_table",
"=",
"len",
"(",
"ros",
")",
"for",
"row_index",
"in",
"range",
"(",
"0",
... | Returns a list that represents the table with the rowspans.
:param ros: The list that represents the table without the rowspans.
:type ros: list(list(hatemile.util.html.htmldomelement.HTMLDOMElement))
:return The list that represents the table with the rowspans.
:rtype: list(list(hatemi... | [
"Returns",
"a",
"list",
"that",
"represents",
"the",
"table",
"with",
"the",
"rowspans",
"."
] | 1e914f9aa09f6f8d78282af131311546ecba9fb8 | https://github.com/hatemile/hatemile-for-python/blob/1e914f9aa09f6f8d78282af131311546ecba9fb8/hatemile/implementation/assoc.py#L64-L111 | train | 58,103 |
hatemile/hatemile-for-python | hatemile/implementation/assoc.py | AccessibleAssociationImplementation._get_model_row | def _get_model_row(self, row):
"""
Returns a list that represents the line of table with the colspans.
:param row: The list that represents the line of table without the
colspans.
:type row: list(hatemile.util.html.htmldomelement.HTMLDOMElement)
:return: The ... | python | def _get_model_row(self, row):
"""
Returns a list that represents the line of table with the colspans.
:param row: The list that represents the line of table without the
colspans.
:type row: list(hatemile.util.html.htmldomelement.HTMLDOMElement)
:return: The ... | [
"def",
"_get_model_row",
"(",
"self",
",",
"row",
")",
":",
"# pylint: disable=no-self-use",
"new_row",
"=",
"[",
"]",
"+",
"row",
"size",
"=",
"len",
"(",
"row",
")",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"size",
")",
":",
"cell",
"=",
"row",
... | Returns a list that represents the line of table with the colspans.
:param row: The list that represents the line of table without the
colspans.
:type row: list(hatemile.util.html.htmldomelement.HTMLDOMElement)
:return: The list that represents the line of table with the col... | [
"Returns",
"a",
"list",
"that",
"represents",
"the",
"line",
"of",
"table",
"with",
"the",
"colspans",
"."
] | 1e914f9aa09f6f8d78282af131311546ecba9fb8 | https://github.com/hatemile/hatemile-for-python/blob/1e914f9aa09f6f8d78282af131311546ecba9fb8/hatemile/implementation/assoc.py#L113-L134 | train | 58,104 |
hatemile/hatemile-for-python | hatemile/implementation/assoc.py | AccessibleAssociationImplementation._validate_header | def _validate_header(self, hed):
"""
Validate the list that represents the table header.
:param hed: The list that represents the table header.
:type hed: list(list(hatemile.util.html.htmldomelement.HTMLDOMElement))
:return: True if the table header is valid or False if the tabl... | python | def _validate_header(self, hed):
"""
Validate the list that represents the table header.
:param hed: The list that represents the table header.
:type hed: list(list(hatemile.util.html.htmldomelement.HTMLDOMElement))
:return: True if the table header is valid or False if the tabl... | [
"def",
"_validate_header",
"(",
"self",
",",
"hed",
")",
":",
"# pylint: disable=no-self-use",
"if",
"not",
"bool",
"(",
"hed",
")",
":",
"return",
"False",
"length",
"=",
"-",
"1",
"for",
"row",
"in",
"hed",
":",
"if",
"not",
"bool",
"(",
"row",
")",
... | Validate the list that represents the table header.
:param hed: The list that represents the table header.
:type hed: list(list(hatemile.util.html.htmldomelement.HTMLDOMElement))
:return: True if the table header is valid or False if the table header
is not valid.
:rtyp... | [
"Validate",
"the",
"list",
"that",
"represents",
"the",
"table",
"header",
"."
] | 1e914f9aa09f6f8d78282af131311546ecba9fb8 | https://github.com/hatemile/hatemile-for-python/blob/1e914f9aa09f6f8d78282af131311546ecba9fb8/hatemile/implementation/assoc.py#L136-L158 | train | 58,105 |
hatemile/hatemile-for-python | hatemile/implementation/assoc.py | AccessibleAssociationImplementation._get_cells_headers_ids | def _get_cells_headers_ids(self, hed, index):
"""
Returns a list with ids of rows of same column.
:param hed: The list that represents the table header.
:type hed: list(list(hatemile.util.html.htmldomelement.HTMLDOMElement))
:param index: The index of columns.
:type inde... | python | def _get_cells_headers_ids(self, hed, index):
"""
Returns a list with ids of rows of same column.
:param hed: The list that represents the table header.
:type hed: list(list(hatemile.util.html.htmldomelement.HTMLDOMElement))
:param index: The index of columns.
:type inde... | [
"def",
"_get_cells_headers_ids",
"(",
"self",
",",
"hed",
",",
"index",
")",
":",
"# pylint: disable=no-self-use",
"ids",
"=",
"[",
"]",
"for",
"row",
"in",
"hed",
":",
"if",
"row",
"[",
"index",
"]",
".",
"get_tag_name",
"(",
")",
"==",
"'TH'",
":",
"... | Returns a list with ids of rows of same column.
:param hed: The list that represents the table header.
:type hed: list(list(hatemile.util.html.htmldomelement.HTMLDOMElement))
:param index: The index of columns.
:type index: int
:return: The list with ids of rows of same column.
... | [
"Returns",
"a",
"list",
"with",
"ids",
"of",
"rows",
"of",
"same",
"column",
"."
] | 1e914f9aa09f6f8d78282af131311546ecba9fb8 | https://github.com/hatemile/hatemile-for-python/blob/1e914f9aa09f6f8d78282af131311546ecba9fb8/hatemile/implementation/assoc.py#L160-L177 | train | 58,106 |
hatemile/hatemile-for-python | hatemile/implementation/assoc.py | AccessibleAssociationImplementation._associate_data_cells_with_header_cells_of_row | def _associate_data_cells_with_header_cells_of_row(self, element):
"""
Associate the data cell with header cell of row.
:param element: The table body or table footer.
:type element: hatemile.util.html.htmldomelement.HTMLDOMElement
"""
table = self._get_model_table(elem... | python | def _associate_data_cells_with_header_cells_of_row(self, element):
"""
Associate the data cell with header cell of row.
:param element: The table body or table footer.
:type element: hatemile.util.html.htmldomelement.HTMLDOMElement
"""
table = self._get_model_table(elem... | [
"def",
"_associate_data_cells_with_header_cells_of_row",
"(",
"self",
",",
"element",
")",
":",
"table",
"=",
"self",
".",
"_get_model_table",
"(",
"element",
")",
"for",
"row",
"in",
"table",
":",
"headers_ids",
"=",
"[",
"]",
"for",
"cell",
"in",
"row",
":... | Associate the data cell with header cell of row.
:param element: The table body or table footer.
:type element: hatemile.util.html.htmldomelement.HTMLDOMElement | [
"Associate",
"the",
"data",
"cell",
"with",
"header",
"cell",
"of",
"row",
"."
] | 1e914f9aa09f6f8d78282af131311546ecba9fb8 | https://github.com/hatemile/hatemile-for-python/blob/1e914f9aa09f6f8d78282af131311546ecba9fb8/hatemile/implementation/assoc.py#L179-L205 | train | 58,107 |
hatemile/hatemile-for-python | hatemile/implementation/assoc.py | AccessibleAssociationImplementation._prepare_header_cells | def _prepare_header_cells(self, table_header):
"""
Set the scope of header cells of table header.
:param table_header: The table header.
:type table_header: hatemile.util.html.htmldomelement.HTMLDOMElement
"""
cells = self.parser.find(table_header).find_children(
... | python | def _prepare_header_cells(self, table_header):
"""
Set the scope of header cells of table header.
:param table_header: The table header.
:type table_header: hatemile.util.html.htmldomelement.HTMLDOMElement
"""
cells = self.parser.find(table_header).find_children(
... | [
"def",
"_prepare_header_cells",
"(",
"self",
",",
"table_header",
")",
":",
"cells",
"=",
"self",
".",
"parser",
".",
"find",
"(",
"table_header",
")",
".",
"find_children",
"(",
"'tr'",
")",
".",
"find_children",
"(",
"'th'",
")",
".",
"list_results",
"("... | Set the scope of header cells of table header.
:param table_header: The table header.
:type table_header: hatemile.util.html.htmldomelement.HTMLDOMElement | [
"Set",
"the",
"scope",
"of",
"header",
"cells",
"of",
"table",
"header",
"."
] | 1e914f9aa09f6f8d78282af131311546ecba9fb8 | https://github.com/hatemile/hatemile-for-python/blob/1e914f9aa09f6f8d78282af131311546ecba9fb8/hatemile/implementation/assoc.py#L207-L221 | train | 58,108 |
AtomHash/evernode | evernode/classes/security.py | Security.encrypt | def encrypt(clear_text) -> str:
""" Use config.json key to encrypt """
if not isinstance(clear_text, bytes):
clear_text = str.encode(clear_text)
cipher = Fernet(current_app.config['KEY'])
return cipher.encrypt(clear_text).decode("utf-8") | python | def encrypt(clear_text) -> str:
""" Use config.json key to encrypt """
if not isinstance(clear_text, bytes):
clear_text = str.encode(clear_text)
cipher = Fernet(current_app.config['KEY'])
return cipher.encrypt(clear_text).decode("utf-8") | [
"def",
"encrypt",
"(",
"clear_text",
")",
"->",
"str",
":",
"if",
"not",
"isinstance",
"(",
"clear_text",
",",
"bytes",
")",
":",
"clear_text",
"=",
"str",
".",
"encode",
"(",
"clear_text",
")",
"cipher",
"=",
"Fernet",
"(",
"current_app",
".",
"config",... | Use config.json key to encrypt | [
"Use",
"config",
".",
"json",
"key",
"to",
"encrypt"
] | b2fb91555fb937a3f3eba41db56dee26f9b034be | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/security.py#L30-L35 | train | 58,109 |
AtomHash/evernode | evernode/classes/security.py | Security.decrypt | def decrypt(crypt_text) -> str:
""" Use config.json key to decrypt """
cipher = Fernet(current_app.config['KEY'])
if not isinstance(crypt_text, bytes):
crypt_text = str.encode(crypt_text)
return cipher.decrypt(crypt_text).decode("utf-8") | python | def decrypt(crypt_text) -> str:
""" Use config.json key to decrypt """
cipher = Fernet(current_app.config['KEY'])
if not isinstance(crypt_text, bytes):
crypt_text = str.encode(crypt_text)
return cipher.decrypt(crypt_text).decode("utf-8") | [
"def",
"decrypt",
"(",
"crypt_text",
")",
"->",
"str",
":",
"cipher",
"=",
"Fernet",
"(",
"current_app",
".",
"config",
"[",
"'KEY'",
"]",
")",
"if",
"not",
"isinstance",
"(",
"crypt_text",
",",
"bytes",
")",
":",
"crypt_text",
"=",
"str",
".",
"encode... | Use config.json key to decrypt | [
"Use",
"config",
".",
"json",
"key",
"to",
"decrypt"
] | b2fb91555fb937a3f3eba41db56dee26f9b034be | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/security.py#L38-L43 | train | 58,110 |
rackerlabs/python-lunrclient | lunrclient/tools.py | Tools.get_volume | def get_volume(self, id):
"""
return volume information if the argument is an id or a path
"""
# If the id is actually a path
if exists(id):
with open(id) as file:
size = os.lseek(file.fileno(), 0, os.SEEK_END)
return {'path': id, 'size': s... | python | def get_volume(self, id):
"""
return volume information if the argument is an id or a path
"""
# If the id is actually a path
if exists(id):
with open(id) as file:
size = os.lseek(file.fileno(), 0, os.SEEK_END)
return {'path': id, 'size': s... | [
"def",
"get_volume",
"(",
"self",
",",
"id",
")",
":",
"# If the id is actually a path",
"if",
"exists",
"(",
"id",
")",
":",
"with",
"open",
"(",
"id",
")",
"as",
"file",
":",
"size",
"=",
"os",
".",
"lseek",
"(",
"file",
".",
"fileno",
"(",
")",
... | return volume information if the argument is an id or a path | [
"return",
"volume",
"information",
"if",
"the",
"argument",
"is",
"an",
"id",
"or",
"a",
"path"
] | f26a450a422600f492480bfa42cbee50a5c7016f | https://github.com/rackerlabs/python-lunrclient/blob/f26a450a422600f492480bfa42cbee50a5c7016f/lunrclient/tools.py#L57-L66 | train | 58,111 |
rackerlabs/python-lunrclient | lunrclient/tools.py | Tools.randomize | def randomize(self, device=None, percent=100, silent=False):
"""
Writes random data to the beginning of each 4MB block on a block device
this is useful when performance testing the backup process
(Without any optional arguments will randomize the first 32k of each
4MB block on 1... | python | def randomize(self, device=None, percent=100, silent=False):
"""
Writes random data to the beginning of each 4MB block on a block device
this is useful when performance testing the backup process
(Without any optional arguments will randomize the first 32k of each
4MB block on 1... | [
"def",
"randomize",
"(",
"self",
",",
"device",
"=",
"None",
",",
"percent",
"=",
"100",
",",
"silent",
"=",
"False",
")",
":",
"volume",
"=",
"self",
".",
"get_volume",
"(",
"device",
")",
"# The number of blocks in the volume",
"blocks",
"=",
"int",
"(",... | Writes random data to the beginning of each 4MB block on a block device
this is useful when performance testing the backup process
(Without any optional arguments will randomize the first 32k of each
4MB block on 100 percent of the device) | [
"Writes",
"random",
"data",
"to",
"the",
"beginning",
"of",
"each",
"4MB",
"block",
"on",
"a",
"block",
"device",
"this",
"is",
"useful",
"when",
"performance",
"testing",
"the",
"backup",
"process"
] | f26a450a422600f492480bfa42cbee50a5c7016f | https://github.com/rackerlabs/python-lunrclient/blob/f26a450a422600f492480bfa42cbee50a5c7016f/lunrclient/tools.py#L78-L111 | train | 58,112 |
rackerlabs/python-lunrclient | lunrclient/tools.py | Tools.backup | def backup(self, id=None, src=None, timestamp=None):
"""
This runs a backup job outside of the storage api,
which is useful for performance testing backups
"""
# Set basic Logging
logging.basicConfig()
# Get the lunr logger
log = logger.get_logger()
... | python | def backup(self, id=None, src=None, timestamp=None):
"""
This runs a backup job outside of the storage api,
which is useful for performance testing backups
"""
# Set basic Logging
logging.basicConfig()
# Get the lunr logger
log = logger.get_logger()
... | [
"def",
"backup",
"(",
"self",
",",
"id",
"=",
"None",
",",
"src",
"=",
"None",
",",
"timestamp",
"=",
"None",
")",
":",
"# Set basic Logging",
"logging",
".",
"basicConfig",
"(",
")",
"# Get the lunr logger",
"log",
"=",
"logger",
".",
"get_logger",
"(",
... | This runs a backup job outside of the storage api,
which is useful for performance testing backups | [
"This",
"runs",
"a",
"backup",
"job",
"outside",
"of",
"the",
"storage",
"api",
"which",
"is",
"useful",
"for",
"performance",
"testing",
"backups"
] | f26a450a422600f492480bfa42cbee50a5c7016f | https://github.com/rackerlabs/python-lunrclient/blob/f26a450a422600f492480bfa42cbee50a5c7016f/lunrclient/tools.py#L176-L216 | train | 58,113 |
Yipit/eventlib | eventlib/util.py | get_ip | def get_ip(request):
"""Return the IP address inside the HTTP_X_FORWARDED_FOR var inside
the `request` object.
The return of this function can be overrided by the
`LOCAL_GEOLOCATION_IP` variable in the `conf` module.
This function will skip local IPs (starting with 10. and equals to
127.0.0.1)... | python | def get_ip(request):
"""Return the IP address inside the HTTP_X_FORWARDED_FOR var inside
the `request` object.
The return of this function can be overrided by the
`LOCAL_GEOLOCATION_IP` variable in the `conf` module.
This function will skip local IPs (starting with 10. and equals to
127.0.0.1)... | [
"def",
"get_ip",
"(",
"request",
")",
":",
"if",
"getsetting",
"(",
"'LOCAL_GEOLOCATION_IP'",
")",
":",
"return",
"getsetting",
"(",
"'LOCAL_GEOLOCATION_IP'",
")",
"forwarded_for",
"=",
"request",
".",
"META",
".",
"get",
"(",
"'HTTP_X_FORWARDED_FOR'",
")",
"if"... | Return the IP address inside the HTTP_X_FORWARDED_FOR var inside
the `request` object.
The return of this function can be overrided by the
`LOCAL_GEOLOCATION_IP` variable in the `conf` module.
This function will skip local IPs (starting with 10. and equals to
127.0.0.1). | [
"Return",
"the",
"IP",
"address",
"inside",
"the",
"HTTP_X_FORWARDED_FOR",
"var",
"inside",
"the",
"request",
"object",
"."
] | 0cf29e5251a59fcbfc727af5f5157a3bb03832e2 | https://github.com/Yipit/eventlib/blob/0cf29e5251a59fcbfc727af5f5157a3bb03832e2/eventlib/util.py#L23-L46 | train | 58,114 |
Yipit/eventlib | eventlib/util.py | ConnectionManager.get_connection | def get_connection(self):
"""Return a valid redis connection based on the following settings
* `REDIS_CONNECTIONS`
* `EVENTLIB_REDIS_CONFIG_NAME`
The first one is a dictionary in the following format:
>>> {
... 'server1': {'HOST': 'redis-server-1', 'POST': 90... | python | def get_connection(self):
"""Return a valid redis connection based on the following settings
* `REDIS_CONNECTIONS`
* `EVENTLIB_REDIS_CONFIG_NAME`
The first one is a dictionary in the following format:
>>> {
... 'server1': {'HOST': 'redis-server-1', 'POST': 90... | [
"def",
"get_connection",
"(",
"self",
")",
":",
"if",
"self",
".",
"conn",
":",
"return",
"self",
".",
"conn",
"redis_configs",
"=",
"getsetting",
"(",
"'REDIS_CONNECTIONS'",
")",
"if",
"redis_configs",
":",
"config_name",
"=",
"getsetting",
"(",
"'EVENTLIB_RE... | Return a valid redis connection based on the following settings
* `REDIS_CONNECTIONS`
* `EVENTLIB_REDIS_CONFIG_NAME`
The first one is a dictionary in the following format:
>>> {
... 'server1': {'HOST': 'redis-server-1', 'POST': 9001},
... 'server2': {'HOS... | [
"Return",
"a",
"valid",
"redis",
"connection",
"based",
"on",
"the",
"following",
"settings"
] | 0cf29e5251a59fcbfc727af5f5157a3bb03832e2 | https://github.com/Yipit/eventlib/blob/0cf29e5251a59fcbfc727af5f5157a3bb03832e2/eventlib/util.py#L54-L83 | train | 58,115 |
Jarn/jarn.mkrelease | jarn/mkrelease/setuptools.py | Setuptools._run_setup_py | def _run_setup_py(self, args, echo=True, echo2=True, ff=''):
"""Run setup.py with monkey-patched setuptools.
The patch forces setuptools to use the file-finder 'ff'.
If 'ff' is the empty string, the patch is not applied.
'args' is the list of arguments that should be passed to
... | python | def _run_setup_py(self, args, echo=True, echo2=True, ff=''):
"""Run setup.py with monkey-patched setuptools.
The patch forces setuptools to use the file-finder 'ff'.
If 'ff' is the empty string, the patch is not applied.
'args' is the list of arguments that should be passed to
... | [
"def",
"_run_setup_py",
"(",
"self",
",",
"args",
",",
"echo",
"=",
"True",
",",
"echo2",
"=",
"True",
",",
"ff",
"=",
"''",
")",
":",
"python",
"=",
"self",
".",
"python",
"if",
"ff",
":",
"setup_py",
"=",
"'-c\"%s\"'",
"%",
"(",
"RUN_SETUP",
"%",... | Run setup.py with monkey-patched setuptools.
The patch forces setuptools to use the file-finder 'ff'.
If 'ff' is the empty string, the patch is not applied.
'args' is the list of arguments that should be passed to
setup.py. | [
"Run",
"setup",
".",
"py",
"with",
"monkey",
"-",
"patched",
"setuptools",
"."
] | 844377f37a3cdc0a154148790a926f991019ec4a | https://github.com/Jarn/jarn.mkrelease/blob/844377f37a3cdc0a154148790a926f991019ec4a/jarn/mkrelease/setuptools.py#L192-L211 | train | 58,116 |
helixyte/everest | everest/run.py | app_factory | def app_factory(global_settings, **local_settings): # pylint: disable=W0613
"""
Default factory for creating a WSGI application using the everest
configurator and root factory.
:param dict global_settings: Global settings extracted from an ini file.
Not used in this default app factory.
:pa... | python | def app_factory(global_settings, **local_settings): # pylint: disable=W0613
"""
Default factory for creating a WSGI application using the everest
configurator and root factory.
:param dict global_settings: Global settings extracted from an ini file.
Not used in this default app factory.
:pa... | [
"def",
"app_factory",
"(",
"global_settings",
",",
"*",
"*",
"local_settings",
")",
":",
"# pylint: disable=W0613",
"config",
"=",
"Configurator",
"(",
")",
"config",
".",
"setup_registry",
"(",
"settings",
"=",
"local_settings",
",",
"root_factory",
"=",
"RootFac... | Default factory for creating a WSGI application using the everest
configurator and root factory.
:param dict global_settings: Global settings extracted from an ini file.
Not used in this default app factory.
:param dict local_settings: App settings extracted from an ini file. | [
"Default",
"factory",
"for",
"creating",
"a",
"WSGI",
"application",
"using",
"the",
"everest",
"configurator",
"and",
"root",
"factory",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/run.py#L18-L40 | train | 58,117 |
Overboard/httpfind | httpfind/httpfind.py | fetch_page | async def fetch_page(session, host):
""" Perform the page fetch from an individual host.
`session` - An aiohttp
[client session](http://aiohttp.readthedocs.io/en/stable/client_reference.html#client-session)
`host` - URL to fetch
`return` tuple with the following:
* The host parameter
... | python | async def fetch_page(session, host):
""" Perform the page fetch from an individual host.
`session` - An aiohttp
[client session](http://aiohttp.readthedocs.io/en/stable/client_reference.html#client-session)
`host` - URL to fetch
`return` tuple with the following:
* The host parameter
... | [
"async",
"def",
"fetch_page",
"(",
"session",
",",
"host",
")",
":",
"await",
"asyncio",
".",
"sleep",
"(",
"random",
".",
"randint",
"(",
"0",
",",
"25",
")",
"*",
"0.1",
")",
"start",
"=",
"time",
".",
"time",
"(",
")",
"logger",
".",
"info",
"... | Perform the page fetch from an individual host.
`session` - An aiohttp
[client session](http://aiohttp.readthedocs.io/en/stable/client_reference.html#client-session)
`host` - URL to fetch
`return` tuple with the following:
* The host parameter
* A vague status string
* Text ... | [
"Perform",
"the",
"page",
"fetch",
"from",
"an",
"individual",
"host",
"."
] | 2c372daa66dcc7158e8bb179b29d8001d473bc4a | https://github.com/Overboard/httpfind/blob/2c372daa66dcc7158e8bb179b29d8001d473bc4a/httpfind/httpfind.py#L17-L65 | train | 58,118 |
Overboard/httpfind | httpfind/httpfind.py | asynchronous | async def asynchronous(urls=None, re_filter=None):
""" Asynchronous request manager for session. Returns list of responses that
match the filter.
`urls` - tuple of URLs to request
`re_filter` - a compiled regular expression
[object](https://docs.python.org/3/library/re.html#re-objects)
"""
... | python | async def asynchronous(urls=None, re_filter=None):
""" Asynchronous request manager for session. Returns list of responses that
match the filter.
`urls` - tuple of URLs to request
`re_filter` - a compiled regular expression
[object](https://docs.python.org/3/library/re.html#re-objects)
"""
... | [
"async",
"def",
"asynchronous",
"(",
"urls",
"=",
"None",
",",
"re_filter",
"=",
"None",
")",
":",
"class",
"_URLBase",
"(",
"str",
")",
":",
"\"\"\" Convenient access to hostname (ip) portion of the URL \"\"\"",
"@",
"property",
"def",
"hostname",
"(",
"self",
")... | Asynchronous request manager for session. Returns list of responses that
match the filter.
`urls` - tuple of URLs to request
`re_filter` - a compiled regular expression
[object](https://docs.python.org/3/library/re.html#re-objects) | [
"Asynchronous",
"request",
"manager",
"for",
"session",
".",
"Returns",
"list",
"of",
"responses",
"that",
"match",
"the",
"filter",
"."
] | 2c372daa66dcc7158e8bb179b29d8001d473bc4a | https://github.com/Overboard/httpfind/blob/2c372daa66dcc7158e8bb179b29d8001d473bc4a/httpfind/httpfind.py#L68-L102 | train | 58,119 |
Overboard/httpfind | httpfind/httpfind.py | url_generator | def url_generator(network=None, path=''):
""" Return a tuple of URLs with path, one for each host on network
`network` - IP address and subnet mask compatible with
[ipaddress library](https://docs.python.org/3/library/ipaddress.html#ipaddress.ip_network)
`path` - Path portion of a URL as defined by ... | python | def url_generator(network=None, path=''):
""" Return a tuple of URLs with path, one for each host on network
`network` - IP address and subnet mask compatible with
[ipaddress library](https://docs.python.org/3/library/ipaddress.html#ipaddress.ip_network)
`path` - Path portion of a URL as defined by ... | [
"def",
"url_generator",
"(",
"network",
"=",
"None",
",",
"path",
"=",
"''",
")",
":",
"network_object",
"=",
"ipaddress",
".",
"ip_network",
"(",
"network",
")",
"if",
"network_object",
".",
"num_addresses",
">",
"256",
":",
"# will need to batch process this c... | Return a tuple of URLs with path, one for each host on network
`network` - IP address and subnet mask compatible with
[ipaddress library](https://docs.python.org/3/library/ipaddress.html#ipaddress.ip_network)
`path` - Path portion of a URL as defined by
[url(un)split](https://docs.python.org/3/libr... | [
"Return",
"a",
"tuple",
"of",
"URLs",
"with",
"path",
"one",
"for",
"each",
"host",
"on",
"network"
] | 2c372daa66dcc7158e8bb179b29d8001d473bc4a | https://github.com/Overboard/httpfind/blob/2c372daa66dcc7158e8bb179b29d8001d473bc4a/httpfind/httpfind.py#L105-L124 | train | 58,120 |
Overboard/httpfind | httpfind/httpfind.py | survey | def survey(network=None, path='', pattern='', log=False):
""" Search network for hosts with a response to path that matches pattern
`network` - IP address and subnet mask compatible with
[ipaddress library](https://docs.python.org/3/library/ipaddress.html#ipaddress.ip_network)
`path` - Path portion ... | python | def survey(network=None, path='', pattern='', log=False):
""" Search network for hosts with a response to path that matches pattern
`network` - IP address and subnet mask compatible with
[ipaddress library](https://docs.python.org/3/library/ipaddress.html#ipaddress.ip_network)
`path` - Path portion ... | [
"def",
"survey",
"(",
"network",
"=",
"None",
",",
"path",
"=",
"''",
",",
"pattern",
"=",
"''",
",",
"log",
"=",
"False",
")",
":",
"if",
"log",
":",
"logger",
".",
"setLevel",
"(",
"logging",
".",
"DEBUG",
")",
"else",
":",
"logger",
".",
"setL... | Search network for hosts with a response to path that matches pattern
`network` - IP address and subnet mask compatible with
[ipaddress library](https://docs.python.org/3/library/ipaddress.html#ipaddress.ip_network)
`path` - Path portion of a URL as defined by
[url(un)split](https://docs.python.org... | [
"Search",
"network",
"for",
"hosts",
"with",
"a",
"response",
"to",
"path",
"that",
"matches",
"pattern"
] | 2c372daa66dcc7158e8bb179b29d8001d473bc4a | https://github.com/Overboard/httpfind/blob/2c372daa66dcc7158e8bb179b29d8001d473bc4a/httpfind/httpfind.py#L127-L154 | train | 58,121 |
contains-io/rcli | rcli/display.py | hidden_cursor | def hidden_cursor():
"""Temporarily hide the terminal cursor."""
if sys.stdout.isatty():
_LOGGER.debug('Hiding cursor.')
print('\x1B[?25l', end='')
sys.stdout.flush()
try:
yield
finally:
if sys.stdout.isatty():
_LOGGER.debug('Showing cursor.')
... | python | def hidden_cursor():
"""Temporarily hide the terminal cursor."""
if sys.stdout.isatty():
_LOGGER.debug('Hiding cursor.')
print('\x1B[?25l', end='')
sys.stdout.flush()
try:
yield
finally:
if sys.stdout.isatty():
_LOGGER.debug('Showing cursor.')
... | [
"def",
"hidden_cursor",
"(",
")",
":",
"if",
"sys",
".",
"stdout",
".",
"isatty",
"(",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"'Hiding cursor.'",
")",
"print",
"(",
"'\\x1B[?25l'",
",",
"end",
"=",
"''",
")",
"sys",
".",
"stdout",
".",
"flush",
"(",... | Temporarily hide the terminal cursor. | [
"Temporarily",
"hide",
"the",
"terminal",
"cursor",
"."
] | cdd6191a0e0a19bc767f84921650835d099349cf | https://github.com/contains-io/rcli/blob/cdd6191a0e0a19bc767f84921650835d099349cf/rcli/display.py#L64-L76 | train | 58,122 |
contains-io/rcli | rcli/display.py | display_status | def display_status():
"""Display an OK or FAILED message for the context block."""
def print_status(msg, color):
"""Print the status message.
Args:
msg: The message to display (e.g. OK or FAILED).
color: The ANSI color code to use in displaying the message.
"""
... | python | def display_status():
"""Display an OK or FAILED message for the context block."""
def print_status(msg, color):
"""Print the status message.
Args:
msg: The message to display (e.g. OK or FAILED).
color: The ANSI color code to use in displaying the message.
"""
... | [
"def",
"display_status",
"(",
")",
":",
"def",
"print_status",
"(",
"msg",
",",
"color",
")",
":",
"\"\"\"Print the status message.\n\n Args:\n msg: The message to display (e.g. OK or FAILED).\n color: The ANSI color code to use in displaying the message.\n ... | Display an OK or FAILED message for the context block. | [
"Display",
"an",
"OK",
"or",
"FAILED",
"message",
"for",
"the",
"context",
"block",
"."
] | cdd6191a0e0a19bc767f84921650835d099349cf | https://github.com/contains-io/rcli/blob/cdd6191a0e0a19bc767f84921650835d099349cf/rcli/display.py#L80-L113 | train | 58,123 |
mcash/merchant-api-python-sdk | mcash/mapi_client/pusherconnector.py | PusherConnector._pusher_connect_handler | def _pusher_connect_handler(self, data):
"""Event handler for the connection_established event. Binds the
shortlink_scanned event
"""
self.channel = self.pusher.subscribe(self.pos_callback_chan)
for listener in self.pusher_connected_listeners:
listener(data) | python | def _pusher_connect_handler(self, data):
"""Event handler for the connection_established event. Binds the
shortlink_scanned event
"""
self.channel = self.pusher.subscribe(self.pos_callback_chan)
for listener in self.pusher_connected_listeners:
listener(data) | [
"def",
"_pusher_connect_handler",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"channel",
"=",
"self",
".",
"pusher",
".",
"subscribe",
"(",
"self",
".",
"pos_callback_chan",
")",
"for",
"listener",
"in",
"self",
".",
"pusher_connected_listeners",
":",
"... | Event handler for the connection_established event. Binds the
shortlink_scanned event | [
"Event",
"handler",
"for",
"the",
"connection_established",
"event",
".",
"Binds",
"the",
"shortlink_scanned",
"event"
] | ebe8734126790354b71077aca519ff263235944e | https://github.com/mcash/merchant-api-python-sdk/blob/ebe8734126790354b71077aca519ff263235944e/mcash/mapi_client/pusherconnector.py#L33-L39 | train | 58,124 |
mcash/merchant-api-python-sdk | mcash/mapi_client/pusherconnector.py | PusherConnector._runForever | def _runForever(self, stop_event):
"""Runs the main loop
Arguments:
stop_event: threading.Event() as a stop signal
"""
while(not stop_event.is_set()):
state = self.pusher.connection.state
if (state is not "connecting" and
state is... | python | def _runForever(self, stop_event):
"""Runs the main loop
Arguments:
stop_event: threading.Event() as a stop signal
"""
while(not stop_event.is_set()):
state = self.pusher.connection.state
if (state is not "connecting" and
state is... | [
"def",
"_runForever",
"(",
"self",
",",
"stop_event",
")",
":",
"while",
"(",
"not",
"stop_event",
".",
"is_set",
"(",
")",
")",
":",
"state",
"=",
"self",
".",
"pusher",
".",
"connection",
".",
"state",
"if",
"(",
"state",
"is",
"not",
"\"connecting\"... | Runs the main loop
Arguments:
stop_event: threading.Event() as a stop signal | [
"Runs",
"the",
"main",
"loop"
] | ebe8734126790354b71077aca519ff263235944e | https://github.com/mcash/merchant-api-python-sdk/blob/ebe8734126790354b71077aca519ff263235944e/mcash/mapi_client/pusherconnector.py#L50-L65 | train | 58,125 |
mcash/merchant-api-python-sdk | mcash/mapi_client/pusherconnector.py | PusherConnector.stop | def stop(self):
"""Stops the pusherclient cleanly
"""
self.pusherthread_stop.set()
self.pusher.disconnect()
# wait until pusher is down
while self.pusher.connection.state is "connected":
sleep(0.1)
logging.info("shutting down pusher connector thread") | python | def stop(self):
"""Stops the pusherclient cleanly
"""
self.pusherthread_stop.set()
self.pusher.disconnect()
# wait until pusher is down
while self.pusher.connection.state is "connected":
sleep(0.1)
logging.info("shutting down pusher connector thread") | [
"def",
"stop",
"(",
"self",
")",
":",
"self",
".",
"pusherthread_stop",
".",
"set",
"(",
")",
"self",
".",
"pusher",
".",
"disconnect",
"(",
")",
"# wait until pusher is down",
"while",
"self",
".",
"pusher",
".",
"connection",
".",
"state",
"is",
"\"conne... | Stops the pusherclient cleanly | [
"Stops",
"the",
"pusherclient",
"cleanly"
] | ebe8734126790354b71077aca519ff263235944e | https://github.com/mcash/merchant-api-python-sdk/blob/ebe8734126790354b71077aca519ff263235944e/mcash/mapi_client/pusherconnector.py#L67-L76 | train | 58,126 |
dariusbakunas/rawdisk | rawdisk/scheme/gpt.py | Gpt.load | def load(self, filename, bs=512):
"""Loads GPT partition table.
Args:
filename (str): path to file or device to open for reading
bs (uint): Block size of the volume, default: 512
Raises:
IOError: If file does not exist or not readable
"""
wit... | python | def load(self, filename, bs=512):
"""Loads GPT partition table.
Args:
filename (str): path to file or device to open for reading
bs (uint): Block size of the volume, default: 512
Raises:
IOError: If file does not exist or not readable
"""
wit... | [
"def",
"load",
"(",
"self",
",",
"filename",
",",
"bs",
"=",
"512",
")",
":",
"with",
"open",
"(",
"filename",
",",
"'rb'",
")",
"as",
"f",
":",
"f",
".",
"seek",
"(",
"GPT_HEADER_OFFSET",
"+",
"0x0C",
")",
"header_size",
"=",
"struct",
".",
"unpac... | Loads GPT partition table.
Args:
filename (str): path to file or device to open for reading
bs (uint): Block size of the volume, default: 512
Raises:
IOError: If file does not exist or not readable | [
"Loads",
"GPT",
"partition",
"table",
"."
] | 1dc9d0b377fe5da3c406ccec4abc238c54167403 | https://github.com/dariusbakunas/rawdisk/blob/1dc9d0b377fe5da3c406ccec4abc238c54167403/rawdisk/scheme/gpt.py#L66-L87 | train | 58,127 |
cstatz/maui | maui/backend/index.py | IndexMapper.global_to_local | def global_to_local(self, index):
""" Calculate local index from global index
:param index: input index
:return: local index for data
"""
if (type(index) is int) or (type(index) is slice):
if len(self.__mask) > 1:
raise IndexError('check length of par... | python | def global_to_local(self, index):
""" Calculate local index from global index
:param index: input index
:return: local index for data
"""
if (type(index) is int) or (type(index) is slice):
if len(self.__mask) > 1:
raise IndexError('check length of par... | [
"def",
"global_to_local",
"(",
"self",
",",
"index",
")",
":",
"if",
"(",
"type",
"(",
"index",
")",
"is",
"int",
")",
"or",
"(",
"type",
"(",
"index",
")",
"is",
"slice",
")",
":",
"if",
"len",
"(",
"self",
".",
"__mask",
")",
">",
"1",
":",
... | Calculate local index from global index
:param index: input index
:return: local index for data | [
"Calculate",
"local",
"index",
"from",
"global",
"index"
] | db99986e93699ee20c5cffdd5b4ee446f8607c5d | https://github.com/cstatz/maui/blob/db99986e93699ee20c5cffdd5b4ee446f8607c5d/maui/backend/index.py#L158-L202 | train | 58,128 |
cstatz/maui | maui/backend/index.py | IndexMapper.int_global_to_local_start | def int_global_to_local_start(self, index, axis=0):
""" Calculate local index from global index from start_index
:param index: global index as integer
:param axis: current axis to process
:return:
"""
if index >= self.__mask[axis].stop-self.__halos[1][axis]:
... | python | def int_global_to_local_start(self, index, axis=0):
""" Calculate local index from global index from start_index
:param index: global index as integer
:param axis: current axis to process
:return:
"""
if index >= self.__mask[axis].stop-self.__halos[1][axis]:
... | [
"def",
"int_global_to_local_start",
"(",
"self",
",",
"index",
",",
"axis",
"=",
"0",
")",
":",
"if",
"index",
">=",
"self",
".",
"__mask",
"[",
"axis",
"]",
".",
"stop",
"-",
"self",
".",
"__halos",
"[",
"1",
"]",
"[",
"axis",
"]",
":",
"return",
... | Calculate local index from global index from start_index
:param index: global index as integer
:param axis: current axis to process
:return: | [
"Calculate",
"local",
"index",
"from",
"global",
"index",
"from",
"start_index"
] | db99986e93699ee20c5cffdd5b4ee446f8607c5d | https://github.com/cstatz/maui/blob/db99986e93699ee20c5cffdd5b4ee446f8607c5d/maui/backend/index.py#L204-L217 | train | 58,129 |
cstatz/maui | maui/backend/index.py | IndexMapper.int_global_to_local_stop | def int_global_to_local_stop(self, index, axis=0):
""" Calculate local index from global index from stop_index
:param index: global index as integer
:param axis: current axis to process
:return:
"""
if index < self.__mask[axis].start+self.__halos[0][axis]:
re... | python | def int_global_to_local_stop(self, index, axis=0):
""" Calculate local index from global index from stop_index
:param index: global index as integer
:param axis: current axis to process
:return:
"""
if index < self.__mask[axis].start+self.__halos[0][axis]:
re... | [
"def",
"int_global_to_local_stop",
"(",
"self",
",",
"index",
",",
"axis",
"=",
"0",
")",
":",
"if",
"index",
"<",
"self",
".",
"__mask",
"[",
"axis",
"]",
".",
"start",
"+",
"self",
".",
"__halos",
"[",
"0",
"]",
"[",
"axis",
"]",
":",
"return",
... | Calculate local index from global index from stop_index
:param index: global index as integer
:param axis: current axis to process
:return: | [
"Calculate",
"local",
"index",
"from",
"global",
"index",
"from",
"stop_index"
] | db99986e93699ee20c5cffdd5b4ee446f8607c5d | https://github.com/cstatz/maui/blob/db99986e93699ee20c5cffdd5b4ee446f8607c5d/maui/backend/index.py#L219-L232 | train | 58,130 |
cstatz/maui | maui/backend/index.py | IndexMapper.int_global_to_local | def int_global_to_local(self, index, axis=0):
""" Calculate local index from global index for integer input
:param index: global index as integer
:param axis: current axis to process
:return:
"""
# Warum >= an dieser Stelle. Eigentlich sollte > ausreichend sein! Test!
... | python | def int_global_to_local(self, index, axis=0):
""" Calculate local index from global index for integer input
:param index: global index as integer
:param axis: current axis to process
:return:
"""
# Warum >= an dieser Stelle. Eigentlich sollte > ausreichend sein! Test!
... | [
"def",
"int_global_to_local",
"(",
"self",
",",
"index",
",",
"axis",
"=",
"0",
")",
":",
"# Warum >= an dieser Stelle. Eigentlich sollte > ausreichend sein! Test!",
"if",
"index",
">=",
"self",
".",
"__mask",
"[",
"axis",
"]",
".",
"stop",
"-",
"self",
".",
"__... | Calculate local index from global index for integer input
:param index: global index as integer
:param axis: current axis to process
:return: | [
"Calculate",
"local",
"index",
"from",
"global",
"index",
"for",
"integer",
"input"
] | db99986e93699ee20c5cffdd5b4ee446f8607c5d | https://github.com/cstatz/maui/blob/db99986e93699ee20c5cffdd5b4ee446f8607c5d/maui/backend/index.py#L234-L249 | train | 58,131 |
cstatz/maui | maui/backend/index.py | IndexBoundsHandler.int_out_of_bounds | def int_out_of_bounds(self, index, axis=0):
""" examples if index is out of local processing bounds
function is used to perform examples for index of type integer
:param index: global index to examples as type int
:param axis: current axis to examples
:return: return input or ra... | python | def int_out_of_bounds(self, index, axis=0):
""" examples if index is out of local processing bounds
function is used to perform examples for index of type integer
:param index: global index to examples as type int
:param axis: current axis to examples
:return: return input or ra... | [
"def",
"int_out_of_bounds",
"(",
"self",
",",
"index",
",",
"axis",
"=",
"0",
")",
":",
"#if index >= self._global_shape[axis]:",
"if",
"index",
">",
"self",
".",
"_global_shape",
"[",
"axis",
"]",
":",
"raise",
"IndexError",
"(",
"'index is larger than the upper ... | examples if index is out of local processing bounds
function is used to perform examples for index of type integer
:param index: global index to examples as type int
:param axis: current axis to examples
:return: return input or raise error | [
"examples",
"if",
"index",
"is",
"out",
"of",
"local",
"processing",
"bounds"
] | db99986e93699ee20c5cffdd5b4ee446f8607c5d | https://github.com/cstatz/maui/blob/db99986e93699ee20c5cffdd5b4ee446f8607c5d/maui/backend/index.py#L264-L285 | train | 58,132 |
cstatz/maui | maui/backend/index.py | IndexBoundsHandler.out_of_bounds | def out_of_bounds(self, index):
""" Check index for out of bounds
:param index: index as integer, tuple or slice
:return: local index as tuple
"""
if type(index) is int:
return self.int_out_of_bounds(index)
elif type(index) is slice:
return self.... | python | def out_of_bounds(self, index):
""" Check index for out of bounds
:param index: index as integer, tuple or slice
:return: local index as tuple
"""
if type(index) is int:
return self.int_out_of_bounds(index)
elif type(index) is slice:
return self.... | [
"def",
"out_of_bounds",
"(",
"self",
",",
"index",
")",
":",
"if",
"type",
"(",
"index",
")",
"is",
"int",
":",
"return",
"self",
".",
"int_out_of_bounds",
"(",
"index",
")",
"elif",
"type",
"(",
"index",
")",
"is",
"slice",
":",
"return",
"self",
".... | Check index for out of bounds
:param index: index as integer, tuple or slice
:return: local index as tuple | [
"Check",
"index",
"for",
"out",
"of",
"bounds"
] | db99986e93699ee20c5cffdd5b4ee446f8607c5d | https://github.com/cstatz/maui/blob/db99986e93699ee20c5cffdd5b4ee446f8607c5d/maui/backend/index.py#L304-L333 | train | 58,133 |
silver-castle/mach9 | mach9/server.py | Server.get_server_setting | def get_server_setting(self, protocol, host='127.0.0.1', port=8000,
debug=False, ssl=None, sock=None, workers=1,
loop=None, backlog=100, has_log=True):
'''Helper function used by `run`.'''
if isinstance(ssl, dict):
# try common aliaseses... | python | def get_server_setting(self, protocol, host='127.0.0.1', port=8000,
debug=False, ssl=None, sock=None, workers=1,
loop=None, backlog=100, has_log=True):
'''Helper function used by `run`.'''
if isinstance(ssl, dict):
# try common aliaseses... | [
"def",
"get_server_setting",
"(",
"self",
",",
"protocol",
",",
"host",
"=",
"'127.0.0.1'",
",",
"port",
"=",
"8000",
",",
"debug",
"=",
"False",
",",
"ssl",
"=",
"None",
",",
"sock",
"=",
"None",
",",
"workers",
"=",
"1",
",",
"loop",
"=",
"None",
... | Helper function used by `run`. | [
"Helper",
"function",
"used",
"by",
"run",
"."
] | 7a623aab3c70d89d36ade6901b6307e115400c5e | https://github.com/silver-castle/mach9/blob/7a623aab3c70d89d36ade6901b6307e115400c5e/mach9/server.py#L40-L95 | train | 58,134 |
RI-imaging/qpformat | qpformat/file_formats/series_hdf5_qpimage.py | SeriesHdf5Qpimage.verify | def verify(path):
"""Verify that `path` has the qpimage series file format"""
valid = False
try:
h5 = h5py.File(path, mode="r")
qpi0 = h5["qpi_0"]
except (OSError, KeyError):
pass
else:
if ("qpimage version" in qpi0.attrs and
... | python | def verify(path):
"""Verify that `path` has the qpimage series file format"""
valid = False
try:
h5 = h5py.File(path, mode="r")
qpi0 = h5["qpi_0"]
except (OSError, KeyError):
pass
else:
if ("qpimage version" in qpi0.attrs and
... | [
"def",
"verify",
"(",
"path",
")",
":",
"valid",
"=",
"False",
"try",
":",
"h5",
"=",
"h5py",
".",
"File",
"(",
"path",
",",
"mode",
"=",
"\"r\"",
")",
"qpi0",
"=",
"h5",
"[",
"\"qpi_0\"",
"]",
"except",
"(",
"OSError",
",",
"KeyError",
")",
":",... | Verify that `path` has the qpimage series file format | [
"Verify",
"that",
"path",
"has",
"the",
"qpimage",
"series",
"file",
"format"
] | 364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb | https://github.com/RI-imaging/qpformat/blob/364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb/qpformat/file_formats/series_hdf5_qpimage.py#L63-L78 | train | 58,135 |
callowayproject/Calloway | calloway/apps/django_ext/management/commands/generate_reqs.py | generate_requirements | def generate_requirements(output_path=None):
"""
Loop through the INSTALLED_APPS and create a set of requirements for pip.
if output_path is ``None`` then write to standard out, otherwise write
to the path.
"""
from django.conf import settings
reqs = set()
for app in settings.I... | python | def generate_requirements(output_path=None):
"""
Loop through the INSTALLED_APPS and create a set of requirements for pip.
if output_path is ``None`` then write to standard out, otherwise write
to the path.
"""
from django.conf import settings
reqs = set()
for app in settings.I... | [
"def",
"generate_requirements",
"(",
"output_path",
"=",
"None",
")",
":",
"from",
"django",
".",
"conf",
"import",
"settings",
"reqs",
"=",
"set",
"(",
")",
"for",
"app",
"in",
"settings",
".",
"INSTALLED_APPS",
":",
"if",
"app",
"in",
"mapping",
".",
"... | Loop through the INSTALLED_APPS and create a set of requirements for pip.
if output_path is ``None`` then write to standard out, otherwise write
to the path. | [
"Loop",
"through",
"the",
"INSTALLED_APPS",
"and",
"create",
"a",
"set",
"of",
"requirements",
"for",
"pip",
".",
"if",
"output_path",
"is",
"None",
"then",
"write",
"to",
"standard",
"out",
"otherwise",
"write",
"to",
"the",
"path",
"."
] | d22e98d41fbd298ab6393ba7bd84a75528be9f81 | https://github.com/callowayproject/Calloway/blob/d22e98d41fbd298ab6393ba7bd84a75528be9f81/calloway/apps/django_ext/management/commands/generate_reqs.py#L60-L84 | train | 58,136 |
dariusbakunas/rawdisk | rawdisk/filesystems/detector.py | FilesystemDetector.register_mbr_plugin | def register_mbr_plugin(self, fs_id, plugin):
"""Used in plugin's registration routine,
to associate it's detection method with given filesystem id
Args:
fs_id: filesystem id that is read from MBR partition entry
plugin: plugin that supports this filesystem
"""
... | python | def register_mbr_plugin(self, fs_id, plugin):
"""Used in plugin's registration routine,
to associate it's detection method with given filesystem id
Args:
fs_id: filesystem id that is read from MBR partition entry
plugin: plugin that supports this filesystem
"""
... | [
"def",
"register_mbr_plugin",
"(",
"self",
",",
"fs_id",
",",
"plugin",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"'MBR: {}, FS ID: {}'",
".",
"format",
"(",
"self",
".",
"__get_plugin_name",
"(",
"plugin",
")",
",",
"fs_id",
")",
")",
"self",
... | Used in plugin's registration routine,
to associate it's detection method with given filesystem id
Args:
fs_id: filesystem id that is read from MBR partition entry
plugin: plugin that supports this filesystem | [
"Used",
"in",
"plugin",
"s",
"registration",
"routine",
"to",
"associate",
"it",
"s",
"detection",
"method",
"with",
"given",
"filesystem",
"id"
] | 1dc9d0b377fe5da3c406ccec4abc238c54167403 | https://github.com/dariusbakunas/rawdisk/blob/1dc9d0b377fe5da3c406ccec4abc238c54167403/rawdisk/filesystems/detector.py#L67-L77 | train | 58,137 |
dariusbakunas/rawdisk | rawdisk/filesystems/detector.py | FilesystemDetector.register_gpt_plugin | def register_gpt_plugin(self, fs_guid, plugin):
"""Used in plugin's registration routine,
to associate it's detection method with given filesystem guid
Args:
fs_guid: filesystem guid that is read from GPT partition entry
plugin: plugin that supports this filesystem
... | python | def register_gpt_plugin(self, fs_guid, plugin):
"""Used in plugin's registration routine,
to associate it's detection method with given filesystem guid
Args:
fs_guid: filesystem guid that is read from GPT partition entry
plugin: plugin that supports this filesystem
... | [
"def",
"register_gpt_plugin",
"(",
"self",
",",
"fs_guid",
",",
"plugin",
")",
":",
"key",
"=",
"uuid",
".",
"UUID",
"(",
"fs_guid",
".",
"lower",
"(",
")",
")",
"self",
".",
"logger",
".",
"debug",
"(",
"'GPT: {}, GUID: {}'",
".",
"format",
"(",
"self... | Used in plugin's registration routine,
to associate it's detection method with given filesystem guid
Args:
fs_guid: filesystem guid that is read from GPT partition entry
plugin: plugin that supports this filesystem | [
"Used",
"in",
"plugin",
"s",
"registration",
"routine",
"to",
"associate",
"it",
"s",
"detection",
"method",
"with",
"given",
"filesystem",
"guid"
] | 1dc9d0b377fe5da3c406ccec4abc238c54167403 | https://github.com/dariusbakunas/rawdisk/blob/1dc9d0b377fe5da3c406ccec4abc238c54167403/rawdisk/filesystems/detector.py#L79-L91 | train | 58,138 |
dariusbakunas/rawdisk | rawdisk/filesystems/detector.py | FilesystemDetector.detect_mbr | def detect_mbr(self, filename, offset, fs_id):
"""Used by rawdisk.session.Session to match mbr partitions against
filesystem plugins.
Args:
filename: device or file that it will read in order to detect
the filesystem fs_id: filesystem id to match (ex. 0x07)
o... | python | def detect_mbr(self, filename, offset, fs_id):
"""Used by rawdisk.session.Session to match mbr partitions against
filesystem plugins.
Args:
filename: device or file that it will read in order to detect
the filesystem fs_id: filesystem id to match (ex. 0x07)
o... | [
"def",
"detect_mbr",
"(",
"self",
",",
"filename",
",",
"offset",
",",
"fs_id",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"'Detecting MBR partition type'",
")",
"if",
"fs_id",
"not",
"in",
"self",
".",
"__mbr_plugins",
":",
"return",
"None",
"els... | Used by rawdisk.session.Session to match mbr partitions against
filesystem plugins.
Args:
filename: device or file that it will read in order to detect
the filesystem fs_id: filesystem id to match (ex. 0x07)
offset: offset for the filesystem that is being matched
... | [
"Used",
"by",
"rawdisk",
".",
"session",
".",
"Session",
"to",
"match",
"mbr",
"partitions",
"against",
"filesystem",
"plugins",
"."
] | 1dc9d0b377fe5da3c406ccec4abc238c54167403 | https://github.com/dariusbakunas/rawdisk/blob/1dc9d0b377fe5da3c406ccec4abc238c54167403/rawdisk/filesystems/detector.py#L98-L120 | train | 58,139 |
dariusbakunas/rawdisk | rawdisk/filesystems/detector.py | FilesystemDetector.detect_gpt | def detect_gpt(self, filename, offset, fs_guid):
"""Used by rawdisk.session.Session to match gpt partitions agains
filesystem plugins.
Args:
filename: device or file that it will read in order to detect the
filesystem
fs_id: filesystem guid to match
... | python | def detect_gpt(self, filename, offset, fs_guid):
"""Used by rawdisk.session.Session to match gpt partitions agains
filesystem plugins.
Args:
filename: device or file that it will read in order to detect the
filesystem
fs_id: filesystem guid to match
... | [
"def",
"detect_gpt",
"(",
"self",
",",
"filename",
",",
"offset",
",",
"fs_guid",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"'Detecting GPT partition type'",
")",
"if",
"fs_guid",
"not",
"in",
"self",
".",
"__gpt_plugins",
":",
"return",
"None",
... | Used by rawdisk.session.Session to match gpt partitions agains
filesystem plugins.
Args:
filename: device or file that it will read in order to detect the
filesystem
fs_id: filesystem guid to match
(ex. {EBD0A0A2-B9E5-4433-87C0-68B6B72699C7})
... | [
"Used",
"by",
"rawdisk",
".",
"session",
".",
"Session",
"to",
"match",
"gpt",
"partitions",
"agains",
"filesystem",
"plugins",
"."
] | 1dc9d0b377fe5da3c406ccec4abc238c54167403 | https://github.com/dariusbakunas/rawdisk/blob/1dc9d0b377fe5da3c406ccec4abc238c54167403/rawdisk/filesystems/detector.py#L122-L147 | train | 58,140 |
xolox/python-update-dotdee | update_dotdee/__init__.py | inject_documentation | def inject_documentation(**options):
"""
Generate configuration documentation in reStructuredText_ syntax.
:param options: Any keyword arguments are passed on to the
:class:`ConfigLoader` initializer.
This methods injects the generated documentation into the output generated
by... | python | def inject_documentation(**options):
"""
Generate configuration documentation in reStructuredText_ syntax.
:param options: Any keyword arguments are passed on to the
:class:`ConfigLoader` initializer.
This methods injects the generated documentation into the output generated
by... | [
"def",
"inject_documentation",
"(",
"*",
"*",
"options",
")",
":",
"import",
"cog",
"loader",
"=",
"ConfigLoader",
"(",
"*",
"*",
"options",
")",
"cog",
".",
"out",
"(",
"\"\\n\"",
"+",
"loader",
".",
"documentation",
"+",
"\"\\n\\n\"",
")"
] | Generate configuration documentation in reStructuredText_ syntax.
:param options: Any keyword arguments are passed on to the
:class:`ConfigLoader` initializer.
This methods injects the generated documentation into the output generated
by cog_.
.. _cog: https://pypi.python.org/pypi... | [
"Generate",
"configuration",
"documentation",
"in",
"reStructuredText_",
"syntax",
"."
] | 04d5836f0d217e32778745b533beeb8159d80c32 | https://github.com/xolox/python-update-dotdee/blob/04d5836f0d217e32778745b533beeb8159d80c32/update_dotdee/__init__.py#L478-L492 | train | 58,141 |
xolox/python-update-dotdee | update_dotdee/__init__.py | UpdateDotDee.read_file | def read_file(self, filename):
"""
Read a text file and provide feedback to the user.
:param filename: The pathname of the file to read (a string).
:returns: The contents of the file (a string).
"""
logger.info("Reading file: %s", format_path(filename))
contents ... | python | def read_file(self, filename):
"""
Read a text file and provide feedback to the user.
:param filename: The pathname of the file to read (a string).
:returns: The contents of the file (a string).
"""
logger.info("Reading file: %s", format_path(filename))
contents ... | [
"def",
"read_file",
"(",
"self",
",",
"filename",
")",
":",
"logger",
".",
"info",
"(",
"\"Reading file: %s\"",
",",
"format_path",
"(",
"filename",
")",
")",
"contents",
"=",
"self",
".",
"context",
".",
"read_file",
"(",
"filename",
")",
"num_lines",
"="... | Read a text file and provide feedback to the user.
:param filename: The pathname of the file to read (a string).
:returns: The contents of the file (a string). | [
"Read",
"a",
"text",
"file",
"and",
"provide",
"feedback",
"to",
"the",
"user",
"."
] | 04d5836f0d217e32778745b533beeb8159d80c32 | https://github.com/xolox/python-update-dotdee/blob/04d5836f0d217e32778745b533beeb8159d80c32/update_dotdee/__init__.py#L184-L197 | train | 58,142 |
xolox/python-update-dotdee | update_dotdee/__init__.py | UpdateDotDee.execute_file | def execute_file(self, filename):
"""
Execute a file and provide feedback to the user.
:param filename: The pathname of the file to execute (a string).
:returns: Whatever the executed file returns on stdout (a string).
"""
logger.info("Executing file: %s", format_path(fi... | python | def execute_file(self, filename):
"""
Execute a file and provide feedback to the user.
:param filename: The pathname of the file to execute (a string).
:returns: Whatever the executed file returns on stdout (a string).
"""
logger.info("Executing file: %s", format_path(fi... | [
"def",
"execute_file",
"(",
"self",
",",
"filename",
")",
":",
"logger",
".",
"info",
"(",
"\"Executing file: %s\"",
",",
"format_path",
"(",
"filename",
")",
")",
"contents",
"=",
"self",
".",
"context",
".",
"execute",
"(",
"filename",
",",
"capture",
"=... | Execute a file and provide feedback to the user.
:param filename: The pathname of the file to execute (a string).
:returns: Whatever the executed file returns on stdout (a string). | [
"Execute",
"a",
"file",
"and",
"provide",
"feedback",
"to",
"the",
"user",
"."
] | 04d5836f0d217e32778745b533beeb8159d80c32 | https://github.com/xolox/python-update-dotdee/blob/04d5836f0d217e32778745b533beeb8159d80c32/update_dotdee/__init__.py#L199-L212 | train | 58,143 |
xolox/python-update-dotdee | update_dotdee/__init__.py | UpdateDotDee.write_file | def write_file(self, filename, contents):
"""
Write a text file and provide feedback to the user.
:param filename: The pathname of the file to write (a string).
:param contents: The new contents of the file (a string).
"""
logger.info("Writing file: %s", format_path(file... | python | def write_file(self, filename, contents):
"""
Write a text file and provide feedback to the user.
:param filename: The pathname of the file to write (a string).
:param contents: The new contents of the file (a string).
"""
logger.info("Writing file: %s", format_path(file... | [
"def",
"write_file",
"(",
"self",
",",
"filename",
",",
"contents",
")",
":",
"logger",
".",
"info",
"(",
"\"Writing file: %s\"",
",",
"format_path",
"(",
"filename",
")",
")",
"contents",
"=",
"contents",
".",
"rstrip",
"(",
")",
"+",
"b\"\\n\"",
"self",
... | Write a text file and provide feedback to the user.
:param filename: The pathname of the file to write (a string).
:param contents: The new contents of the file (a string). | [
"Write",
"a",
"text",
"file",
"and",
"provide",
"feedback",
"to",
"the",
"user",
"."
] | 04d5836f0d217e32778745b533beeb8159d80c32 | https://github.com/xolox/python-update-dotdee/blob/04d5836f0d217e32778745b533beeb8159d80c32/update_dotdee/__init__.py#L214-L226 | train | 58,144 |
mcash/merchant-api-python-sdk | mcash/mapi_client/validation.py | validate_input | def validate_input(function):
"""Decorator that validates the kwargs of the function passed to it."""
@wraps(function)
def wrapper(*args, **kwargs):
try:
name = function.__name__ + '_validator' # find validator name
globals()[name](kwargs) # call validation function
... | python | def validate_input(function):
"""Decorator that validates the kwargs of the function passed to it."""
@wraps(function)
def wrapper(*args, **kwargs):
try:
name = function.__name__ + '_validator' # find validator name
globals()[name](kwargs) # call validation function
... | [
"def",
"validate_input",
"(",
"function",
")",
":",
"@",
"wraps",
"(",
"function",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"name",
"=",
"function",
".",
"__name__",
"+",
"'_validator'",
"# find validator na... | Decorator that validates the kwargs of the function passed to it. | [
"Decorator",
"that",
"validates",
"the",
"kwargs",
"of",
"the",
"function",
"passed",
"to",
"it",
"."
] | ebe8734126790354b71077aca519ff263235944e | https://github.com/mcash/merchant-api-python-sdk/blob/ebe8734126790354b71077aca519ff263235944e/mcash/mapi_client/validation.py#L5-L16 | train | 58,145 |
brmscheiner/ideogram | ideogram/importAnalysis.py | getModulePath | def getModulePath(project_path,module_name,verbose):
'''Searches for module_name in searchpath and returns the filepath.
If no filepath was found, returns None.'''
if not module_name:
return None
sys.path.append(project_path)
try:
package = pkgutil.get_loader(module_name)
except ... | python | def getModulePath(project_path,module_name,verbose):
'''Searches for module_name in searchpath and returns the filepath.
If no filepath was found, returns None.'''
if not module_name:
return None
sys.path.append(project_path)
try:
package = pkgutil.get_loader(module_name)
except ... | [
"def",
"getModulePath",
"(",
"project_path",
",",
"module_name",
",",
"verbose",
")",
":",
"if",
"not",
"module_name",
":",
"return",
"None",
"sys",
".",
"path",
".",
"append",
"(",
"project_path",
")",
"try",
":",
"package",
"=",
"pkgutil",
".",
"get_load... | Searches for module_name in searchpath and returns the filepath.
If no filepath was found, returns None. | [
"Searches",
"for",
"module_name",
"in",
"searchpath",
"and",
"returns",
"the",
"filepath",
".",
"If",
"no",
"filepath",
"was",
"found",
"returns",
"None",
"."
] | 422bf566c51fd56f7bbb6e75b16d18d52b4c7568 | https://github.com/brmscheiner/ideogram/blob/422bf566c51fd56f7bbb6e75b16d18d52b4c7568/ideogram/importAnalysis.py#L4-L44 | train | 58,146 |
brmscheiner/ideogram | ideogram/importAnalysis.py | getImportFromObjects | def getImportFromObjects(node):
'''Returns a list of objects referenced by import from node'''
somenames = [x.asname for x in node.names if x.asname]
othernames = [x.name for x in node.names if not x.asname]
return somenames+othernames | python | def getImportFromObjects(node):
'''Returns a list of objects referenced by import from node'''
somenames = [x.asname for x in node.names if x.asname]
othernames = [x.name for x in node.names if not x.asname]
return somenames+othernames | [
"def",
"getImportFromObjects",
"(",
"node",
")",
":",
"somenames",
"=",
"[",
"x",
".",
"asname",
"for",
"x",
"in",
"node",
".",
"names",
"if",
"x",
".",
"asname",
"]",
"othernames",
"=",
"[",
"x",
".",
"name",
"for",
"x",
"in",
"node",
".",
"names"... | Returns a list of objects referenced by import from node | [
"Returns",
"a",
"list",
"of",
"objects",
"referenced",
"by",
"import",
"from",
"node"
] | 422bf566c51fd56f7bbb6e75b16d18d52b4c7568 | https://github.com/brmscheiner/ideogram/blob/422bf566c51fd56f7bbb6e75b16d18d52b4c7568/ideogram/importAnalysis.py#L51-L55 | train | 58,147 |
helixyte/everest | everest/repositories/rdb/utils.py | as_slug_expression | def as_slug_expression(attr):
"""
Converts the given instrumented string attribute into an SQL expression
that can be used as a slug.
Slugs are identifiers for members in a collection that can be used in an
URL. We create slug columns by replacing non-URL characters with dashes
and lower casing... | python | def as_slug_expression(attr):
"""
Converts the given instrumented string attribute into an SQL expression
that can be used as a slug.
Slugs are identifiers for members in a collection that can be used in an
URL. We create slug columns by replacing non-URL characters with dashes
and lower casing... | [
"def",
"as_slug_expression",
"(",
"attr",
")",
":",
"slug_expr",
"=",
"sa_func",
".",
"replace",
"(",
"attr",
",",
"' '",
",",
"'-'",
")",
"slug_expr",
"=",
"sa_func",
".",
"replace",
"(",
"slug_expr",
",",
"'_'",
",",
"'-'",
")",
"slug_expr",
"=",
"sa... | Converts the given instrumented string attribute into an SQL expression
that can be used as a slug.
Slugs are identifiers for members in a collection that can be used in an
URL. We create slug columns by replacing non-URL characters with dashes
and lower casing the result. We need this at the ORM level... | [
"Converts",
"the",
"given",
"instrumented",
"string",
"attribute",
"into",
"an",
"SQL",
"expression",
"that",
"can",
"be",
"used",
"as",
"a",
"slug",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/repositories/rdb/utils.py#L90-L103 | train | 58,148 |
helixyte/everest | everest/repositories/rdb/utils.py | mapper | def mapper(class_, local_table=None, id_attribute='id', slug_expression=None,
*args, **kwargs):
"""
Convenience wrapper around the SA mapper which will set up the hybrid
"id" and "slug" attributes required by everest after calling the SA
mapper.
If you (e.g., for testing purposes) want t... | python | def mapper(class_, local_table=None, id_attribute='id', slug_expression=None,
*args, **kwargs):
"""
Convenience wrapper around the SA mapper which will set up the hybrid
"id" and "slug" attributes required by everest after calling the SA
mapper.
If you (e.g., for testing purposes) want t... | [
"def",
"mapper",
"(",
"class_",
",",
"local_table",
"=",
"None",
",",
"id_attribute",
"=",
"'id'",
",",
"slug_expression",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"mpr",
"=",
"sa_mapper",
"(",
"class_",
",",
"local_table",
"="... | Convenience wrapper around the SA mapper which will set up the hybrid
"id" and "slug" attributes required by everest after calling the SA
mapper.
If you (e.g., for testing purposes) want to clear mappers created with
this function, use the :func:`clear_mappers` function in this module.
:param str ... | [
"Convenience",
"wrapper",
"around",
"the",
"SA",
"mapper",
"which",
"will",
"set",
"up",
"the",
"hybrid",
"id",
"and",
"slug",
"attributes",
"required",
"by",
"everest",
"after",
"calling",
"the",
"SA",
"mapper",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/repositories/rdb/utils.py#L121-L173 | train | 58,149 |
helixyte/everest | everest/repositories/rdb/utils.py | synonym | def synonym(name):
"""
Utility function mimicking the behavior of the old SA synonym function
with the new hybrid property semantics.
"""
return hybrid_property(lambda inst: getattr(inst, name),
lambda inst, value: setattr(inst, name, value),
exp... | python | def synonym(name):
"""
Utility function mimicking the behavior of the old SA synonym function
with the new hybrid property semantics.
"""
return hybrid_property(lambda inst: getattr(inst, name),
lambda inst, value: setattr(inst, name, value),
exp... | [
"def",
"synonym",
"(",
"name",
")",
":",
"return",
"hybrid_property",
"(",
"lambda",
"inst",
":",
"getattr",
"(",
"inst",
",",
"name",
")",
",",
"lambda",
"inst",
",",
"value",
":",
"setattr",
"(",
"inst",
",",
"name",
",",
"value",
")",
",",
"expr",... | Utility function mimicking the behavior of the old SA synonym function
with the new hybrid property semantics. | [
"Utility",
"function",
"mimicking",
"the",
"behavior",
"of",
"the",
"old",
"SA",
"synonym",
"function",
"with",
"the",
"new",
"hybrid",
"property",
"semantics",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/repositories/rdb/utils.py#L176-L183 | train | 58,150 |
helixyte/everest | everest/repositories/rdb/utils.py | map_system_entities | def map_system_entities(engine, metadata, reset):
"""
Maps all system entities.
"""
# Map the user message system entity.
msg_tbl = Table('_user_messages', metadata,
Column('guid', String, nullable=False, primary_key=True),
Column('text', String, nullable=Fals... | python | def map_system_entities(engine, metadata, reset):
"""
Maps all system entities.
"""
# Map the user message system entity.
msg_tbl = Table('_user_messages', metadata,
Column('guid', String, nullable=False, primary_key=True),
Column('text', String, nullable=Fals... | [
"def",
"map_system_entities",
"(",
"engine",
",",
"metadata",
",",
"reset",
")",
":",
"# Map the user message system entity.",
"msg_tbl",
"=",
"Table",
"(",
"'_user_messages'",
",",
"metadata",
",",
"Column",
"(",
"'guid'",
",",
"String",
",",
"nullable",
"=",
"... | Maps all system entities. | [
"Maps",
"all",
"system",
"entities",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/repositories/rdb/utils.py#L186-L200 | train | 58,151 |
BlackEarth/bxml | bxml/schema.py | Schema.schematron | def schematron(self, fn=None, outfn=None, ext='.sch'):
"""convert the Schema to schematron and save at the given output filename or with the given extension."""
from .xslt import XSLT
from . import PATH, XML, etree
fn = fn or self.fn
if os.path.splitext(fn)[-1].lower()==ext:
... | python | def schematron(self, fn=None, outfn=None, ext='.sch'):
"""convert the Schema to schematron and save at the given output filename or with the given extension."""
from .xslt import XSLT
from . import PATH, XML, etree
fn = fn or self.fn
if os.path.splitext(fn)[-1].lower()==ext:
... | [
"def",
"schematron",
"(",
"self",
",",
"fn",
"=",
"None",
",",
"outfn",
"=",
"None",
",",
"ext",
"=",
"'.sch'",
")",
":",
"from",
".",
"xslt",
"import",
"XSLT",
"from",
".",
"import",
"PATH",
",",
"XML",
",",
"etree",
"fn",
"=",
"fn",
"or",
"self... | convert the Schema to schematron and save at the given output filename or with the given extension. | [
"convert",
"the",
"Schema",
"to",
"schematron",
"and",
"save",
"at",
"the",
"given",
"output",
"filename",
"or",
"with",
"the",
"given",
"extension",
"."
] | 8fbea5dad7fadc7b854ddbeff6ecfb55aaceeb77 | https://github.com/BlackEarth/bxml/blob/8fbea5dad7fadc7b854ddbeff6ecfb55aaceeb77/bxml/schema.py#L36-L50 | train | 58,152 |
BlackEarth/bxml | bxml/schema.py | Schema.xhtml | def xhtml(self, outfn=None, ext='.xhtml', css=None, **params):
"""convert the Schema to XHTML with the given output filename or with the given extension."""
from markdown import markdown
from copy import deepcopy
from bl.file import File
from .xslt import XSLT
from .rng i... | python | def xhtml(self, outfn=None, ext='.xhtml', css=None, **params):
"""convert the Schema to XHTML with the given output filename or with the given extension."""
from markdown import markdown
from copy import deepcopy
from bl.file import File
from .xslt import XSLT
from .rng i... | [
"def",
"xhtml",
"(",
"self",
",",
"outfn",
"=",
"None",
",",
"ext",
"=",
"'.xhtml'",
",",
"css",
"=",
"None",
",",
"*",
"*",
"params",
")",
":",
"from",
"markdown",
"import",
"markdown",
"from",
"copy",
"import",
"deepcopy",
"from",
"bl",
".",
"file"... | convert the Schema to XHTML with the given output filename or with the given extension. | [
"convert",
"the",
"Schema",
"to",
"XHTML",
"with",
"the",
"given",
"output",
"filename",
"or",
"with",
"the",
"given",
"extension",
"."
] | 8fbea5dad7fadc7b854ddbeff6ecfb55aaceeb77 | https://github.com/BlackEarth/bxml/blob/8fbea5dad7fadc7b854ddbeff6ecfb55aaceeb77/bxml/schema.py#L52-L119 | train | 58,153 |
BlackEarth/bxml | bxml/schema.py | Schema.from_tag | def from_tag(cls, tag, schemas, ext='.rnc'):
"""load a schema using an element's tag. schemas can be a string or a list of strings"""
return cls(fn=cls.filename(tag, schemas, ext=ext)) | python | def from_tag(cls, tag, schemas, ext='.rnc'):
"""load a schema using an element's tag. schemas can be a string or a list of strings"""
return cls(fn=cls.filename(tag, schemas, ext=ext)) | [
"def",
"from_tag",
"(",
"cls",
",",
"tag",
",",
"schemas",
",",
"ext",
"=",
"'.rnc'",
")",
":",
"return",
"cls",
"(",
"fn",
"=",
"cls",
".",
"filename",
"(",
"tag",
",",
"schemas",
",",
"ext",
"=",
"ext",
")",
")"
] | load a schema using an element's tag. schemas can be a string or a list of strings | [
"load",
"a",
"schema",
"using",
"an",
"element",
"s",
"tag",
".",
"schemas",
"can",
"be",
"a",
"string",
"or",
"a",
"list",
"of",
"strings"
] | 8fbea5dad7fadc7b854ddbeff6ecfb55aaceeb77 | https://github.com/BlackEarth/bxml/blob/8fbea5dad7fadc7b854ddbeff6ecfb55aaceeb77/bxml/schema.py#L122-L124 | train | 58,154 |
BlackEarth/bxml | bxml/schema.py | Schema.filename | def filename(cls, tag, schemas, ext='.rnc'):
"""given a tag and a list of schemas, return the filename of the schema.
If schemas is a string, treat it as a comma-separated list.
"""
if type(schemas)==str:
schemas = re.split("\s*,\s*", schemas)
for schema in schemas:
... | python | def filename(cls, tag, schemas, ext='.rnc'):
"""given a tag and a list of schemas, return the filename of the schema.
If schemas is a string, treat it as a comma-separated list.
"""
if type(schemas)==str:
schemas = re.split("\s*,\s*", schemas)
for schema in schemas:
... | [
"def",
"filename",
"(",
"cls",
",",
"tag",
",",
"schemas",
",",
"ext",
"=",
"'.rnc'",
")",
":",
"if",
"type",
"(",
"schemas",
")",
"==",
"str",
":",
"schemas",
"=",
"re",
".",
"split",
"(",
"\"\\s*,\\s*\"",
",",
"schemas",
")",
"for",
"schema",
"in... | given a tag and a list of schemas, return the filename of the schema.
If schemas is a string, treat it as a comma-separated list. | [
"given",
"a",
"tag",
"and",
"a",
"list",
"of",
"schemas",
"return",
"the",
"filename",
"of",
"the",
"schema",
".",
"If",
"schemas",
"is",
"a",
"string",
"treat",
"it",
"as",
"a",
"comma",
"-",
"separated",
"list",
"."
] | 8fbea5dad7fadc7b854ddbeff6ecfb55aaceeb77 | https://github.com/BlackEarth/bxml/blob/8fbea5dad7fadc7b854ddbeff6ecfb55aaceeb77/bxml/schema.py#L127-L136 | train | 58,155 |
vicalloy/lbutils | lbutils/forms.py | FormHelperMixin.errors_as_text | def errors_as_text(self):
"""
only available to Django 1.7+
"""
errors = []
errors.append(self.non_field_errors().as_text())
errors_data = self.errors.as_data()
for key, value in errors_data.items():
field_label = self.fields[key].label
err... | python | def errors_as_text(self):
"""
only available to Django 1.7+
"""
errors = []
errors.append(self.non_field_errors().as_text())
errors_data = self.errors.as_data()
for key, value in errors_data.items():
field_label = self.fields[key].label
err... | [
"def",
"errors_as_text",
"(",
"self",
")",
":",
"errors",
"=",
"[",
"]",
"errors",
".",
"append",
"(",
"self",
".",
"non_field_errors",
"(",
")",
".",
"as_text",
"(",
")",
")",
"errors_data",
"=",
"self",
".",
"errors",
".",
"as_data",
"(",
")",
"for... | only available to Django 1.7+ | [
"only",
"available",
"to",
"Django",
"1",
".",
"7",
"+"
] | 66ae7e73bc939f073cdc1b91602a95e67caf4ba6 | https://github.com/vicalloy/lbutils/blob/66ae7e73bc939f073cdc1b91602a95e67caf4ba6/lbutils/forms.py#L32-L44 | train | 58,156 |
vicalloy/lbutils | lbutils/forms.py | FormHelperMixin.add_attr2fields | def add_attr2fields(self, attr_name, attr_val, fields=[], exclude=[], include_all_if_empty=True):
"""
add attr to fields
"""
for f in self.filter_fields(fields, exclude, include_all_if_empty):
f = self.fields[f.name]
org_val = f.widget.attrs.get(attr_name, '')
... | python | def add_attr2fields(self, attr_name, attr_val, fields=[], exclude=[], include_all_if_empty=True):
"""
add attr to fields
"""
for f in self.filter_fields(fields, exclude, include_all_if_empty):
f = self.fields[f.name]
org_val = f.widget.attrs.get(attr_name, '')
... | [
"def",
"add_attr2fields",
"(",
"self",
",",
"attr_name",
",",
"attr_val",
",",
"fields",
"=",
"[",
"]",
",",
"exclude",
"=",
"[",
"]",
",",
"include_all_if_empty",
"=",
"True",
")",
":",
"for",
"f",
"in",
"self",
".",
"filter_fields",
"(",
"fields",
",... | add attr to fields | [
"add",
"attr",
"to",
"fields"
] | 66ae7e73bc939f073cdc1b91602a95e67caf4ba6 | https://github.com/vicalloy/lbutils/blob/66ae7e73bc939f073cdc1b91602a95e67caf4ba6/lbutils/forms.py#L65-L72 | train | 58,157 |
vicalloy/lbutils | lbutils/forms.py | FormHelperMixin.add_class2fields | def add_class2fields(self, html_class, fields=[], exclude=[], include_all_if_empty=True):
"""
add class to html widgets.
"""
self.add_attr2fields('class', html_class, fields, exclude) | python | def add_class2fields(self, html_class, fields=[], exclude=[], include_all_if_empty=True):
"""
add class to html widgets.
"""
self.add_attr2fields('class', html_class, fields, exclude) | [
"def",
"add_class2fields",
"(",
"self",
",",
"html_class",
",",
"fields",
"=",
"[",
"]",
",",
"exclude",
"=",
"[",
"]",
",",
"include_all_if_empty",
"=",
"True",
")",
":",
"self",
".",
"add_attr2fields",
"(",
"'class'",
",",
"html_class",
",",
"fields",
... | add class to html widgets. | [
"add",
"class",
"to",
"html",
"widgets",
"."
] | 66ae7e73bc939f073cdc1b91602a95e67caf4ba6 | https://github.com/vicalloy/lbutils/blob/66ae7e73bc939f073cdc1b91602a95e67caf4ba6/lbutils/forms.py#L74-L78 | train | 58,158 |
vicalloy/lbutils | lbutils/forms.py | FormHelperMixin.as_required_fields | def as_required_fields(self, fields=[]):
""" set required to True """
fields = self.filter_fields(fields)
for f in fields:
f = self.fields[f.name]
f.required = True | python | def as_required_fields(self, fields=[]):
""" set required to True """
fields = self.filter_fields(fields)
for f in fields:
f = self.fields[f.name]
f.required = True | [
"def",
"as_required_fields",
"(",
"self",
",",
"fields",
"=",
"[",
"]",
")",
":",
"fields",
"=",
"self",
".",
"filter_fields",
"(",
"fields",
")",
"for",
"f",
"in",
"fields",
":",
"f",
"=",
"self",
".",
"fields",
"[",
"f",
".",
"name",
"]",
"f",
... | set required to True | [
"set",
"required",
"to",
"True"
] | 66ae7e73bc939f073cdc1b91602a95e67caf4ba6 | https://github.com/vicalloy/lbutils/blob/66ae7e73bc939f073cdc1b91602a95e67caf4ba6/lbutils/forms.py#L101-L106 | train | 58,159 |
vicalloy/lbutils | lbutils/forms.py | FormHelperMixin.check_uniqe | def check_uniqe(self, obj_class, error_msg=_('Must be unique'), **kwargs):
""" check if this object is unique """
if obj_class.objects.filter(**kwargs).exclude(pk=self.instance.pk):
raise forms.ValidationError(error_msg) | python | def check_uniqe(self, obj_class, error_msg=_('Must be unique'), **kwargs):
""" check if this object is unique """
if obj_class.objects.filter(**kwargs).exclude(pk=self.instance.pk):
raise forms.ValidationError(error_msg) | [
"def",
"check_uniqe",
"(",
"self",
",",
"obj_class",
",",
"error_msg",
"=",
"_",
"(",
"'Must be unique'",
")",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"obj_class",
".",
"objects",
".",
"filter",
"(",
"*",
"*",
"kwargs",
")",
".",
"exclude",
"(",
"pk... | check if this object is unique | [
"check",
"if",
"this",
"object",
"is",
"unique"
] | 66ae7e73bc939f073cdc1b91602a95e67caf4ba6 | https://github.com/vicalloy/lbutils/blob/66ae7e73bc939f073cdc1b91602a95e67caf4ba6/lbutils/forms.py#L108-L111 | train | 58,160 |
danbradham/scrim | setup.py | get_info | def get_info(pyfile):
'''Retrieve dunder values from a pyfile'''
info = {}
info_re = re.compile(r"^__(\w+)__ = ['\"](.*)['\"]")
with open(pyfile, 'r') as f:
for line in f.readlines():
match = info_re.search(line)
if match:
info[match.group(1)] = match.grou... | python | def get_info(pyfile):
'''Retrieve dunder values from a pyfile'''
info = {}
info_re = re.compile(r"^__(\w+)__ = ['\"](.*)['\"]")
with open(pyfile, 'r') as f:
for line in f.readlines():
match = info_re.search(line)
if match:
info[match.group(1)] = match.grou... | [
"def",
"get_info",
"(",
"pyfile",
")",
":",
"info",
"=",
"{",
"}",
"info_re",
"=",
"re",
".",
"compile",
"(",
"r\"^__(\\w+)__ = ['\\\"](.*)['\\\"]\"",
")",
"with",
"open",
"(",
"pyfile",
",",
"'r'",
")",
"as",
"f",
":",
"for",
"line",
"in",
"f",
".",
... | Retrieve dunder values from a pyfile | [
"Retrieve",
"dunder",
"values",
"from",
"a",
"pyfile"
] | 982a5db1db6e4ef40267f15642af2c7ea0e803ae | https://github.com/danbradham/scrim/blob/982a5db1db6e4ef40267f15642af2c7ea0e803ae/setup.py#L20-L29 | train | 58,161 |
lsst-sqre/lander | lander/main.py | main | def main():
"""Entrypoint for ``lander`` executable."""
args = parse_args()
config_logger(args)
logger = structlog.get_logger(__name__)
if args.show_version:
# only print the version
print_version()
sys.exit(0)
version = pkg_resources.get_distribution('lander').version
... | python | def main():
"""Entrypoint for ``lander`` executable."""
args = parse_args()
config_logger(args)
logger = structlog.get_logger(__name__)
if args.show_version:
# only print the version
print_version()
sys.exit(0)
version = pkg_resources.get_distribution('lander').version
... | [
"def",
"main",
"(",
")",
":",
"args",
"=",
"parse_args",
"(",
")",
"config_logger",
"(",
"args",
")",
"logger",
"=",
"structlog",
".",
"get_logger",
"(",
"__name__",
")",
"if",
"args",
".",
"show_version",
":",
"# only print the version",
"print_version",
"(... | Entrypoint for ``lander`` executable. | [
"Entrypoint",
"for",
"lander",
"executable",
"."
] | 5e4f6123e48b451ba21963724ace0dc59798618e | https://github.com/lsst-sqre/lander/blob/5e4f6123e48b451ba21963724ace0dc59798618e/lander/main.py#L171-L200 | train | 58,162 |
brap/brap | brap/graph.py | Graph.insert_node | def insert_node(self, node):
"""
Adds node if name is available or pre-existing node
returns True if added
returns False if not added
"""
if self._is_node_reserved(node):
return False
# Put node in map
self._node_map[node.get_id()] = node
... | python | def insert_node(self, node):
"""
Adds node if name is available or pre-existing node
returns True if added
returns False if not added
"""
if self._is_node_reserved(node):
return False
# Put node in map
self._node_map[node.get_id()] = node
... | [
"def",
"insert_node",
"(",
"self",
",",
"node",
")",
":",
"if",
"self",
".",
"_is_node_reserved",
"(",
"node",
")",
":",
"return",
"False",
"# Put node in map",
"self",
".",
"_node_map",
"[",
"node",
".",
"get_id",
"(",
")",
"]",
"=",
"node",
"return",
... | Adds node if name is available or pre-existing node
returns True if added
returns False if not added | [
"Adds",
"node",
"if",
"name",
"is",
"available",
"or",
"pre",
"-",
"existing",
"node",
"returns",
"True",
"if",
"added",
"returns",
"False",
"if",
"not",
"added"
] | 227d1b6ce2799b7caf1d98d8805e821d19d0969b | https://github.com/brap/brap/blob/227d1b6ce2799b7caf1d98d8805e821d19d0969b/brap/graph.py#L16-L27 | train | 58,163 |
Jarn/jarn.mkrelease | jarn/mkrelease/mkrelease.py | Locations.join | def join(self, distbase, location):
"""Join 'distbase' and 'location' in such way that the
result is a valid scp destination.
"""
sep = ''
if distbase and distbase[-1] not in (':', '/'):
sep = '/'
return distbase + sep + location | python | def join(self, distbase, location):
"""Join 'distbase' and 'location' in such way that the
result is a valid scp destination.
"""
sep = ''
if distbase and distbase[-1] not in (':', '/'):
sep = '/'
return distbase + sep + location | [
"def",
"join",
"(",
"self",
",",
"distbase",
",",
"location",
")",
":",
"sep",
"=",
"''",
"if",
"distbase",
"and",
"distbase",
"[",
"-",
"1",
"]",
"not",
"in",
"(",
"':'",
",",
"'/'",
")",
":",
"sep",
"=",
"'/'",
"return",
"distbase",
"+",
"sep",... | Join 'distbase' and 'location' in such way that the
result is a valid scp destination. | [
"Join",
"distbase",
"and",
"location",
"in",
"such",
"way",
"that",
"the",
"result",
"is",
"a",
"valid",
"scp",
"destination",
"."
] | 844377f37a3cdc0a154148790a926f991019ec4a | https://github.com/Jarn/jarn.mkrelease/blob/844377f37a3cdc0a154148790a926f991019ec4a/jarn/mkrelease/mkrelease.py#L182-L189 | train | 58,164 |
Jarn/jarn.mkrelease | jarn/mkrelease/mkrelease.py | Locations.get_location | def get_location(self, location, depth=0):
"""Resolve aliases and apply distbase.
"""
if not location:
return []
if location in self.aliases:
res = []
if depth > MAXALIASDEPTH:
err_exit('Maximum alias depth exceeded: %(location)s' % loc... | python | def get_location(self, location, depth=0):
"""Resolve aliases and apply distbase.
"""
if not location:
return []
if location in self.aliases:
res = []
if depth > MAXALIASDEPTH:
err_exit('Maximum alias depth exceeded: %(location)s' % loc... | [
"def",
"get_location",
"(",
"self",
",",
"location",
",",
"depth",
"=",
"0",
")",
":",
"if",
"not",
"location",
":",
"return",
"[",
"]",
"if",
"location",
"in",
"self",
".",
"aliases",
":",
"res",
"=",
"[",
"]",
"if",
"depth",
">",
"MAXALIASDEPTH",
... | Resolve aliases and apply distbase. | [
"Resolve",
"aliases",
"and",
"apply",
"distbase",
"."
] | 844377f37a3cdc0a154148790a926f991019ec4a | https://github.com/Jarn/jarn.mkrelease/blob/844377f37a3cdc0a154148790a926f991019ec4a/jarn/mkrelease/mkrelease.py#L191-L212 | train | 58,165 |
Jarn/jarn.mkrelease | jarn/mkrelease/mkrelease.py | Locations.get_default_location | def get_default_location(self):
"""Return the default location.
"""
res = []
for location in self.distdefault:
res.extend(self.get_location(location))
return res | python | def get_default_location(self):
"""Return the default location.
"""
res = []
for location in self.distdefault:
res.extend(self.get_location(location))
return res | [
"def",
"get_default_location",
"(",
"self",
")",
":",
"res",
"=",
"[",
"]",
"for",
"location",
"in",
"self",
".",
"distdefault",
":",
"res",
".",
"extend",
"(",
"self",
".",
"get_location",
"(",
"location",
")",
")",
"return",
"res"
] | Return the default location. | [
"Return",
"the",
"default",
"location",
"."
] | 844377f37a3cdc0a154148790a926f991019ec4a | https://github.com/Jarn/jarn.mkrelease/blob/844377f37a3cdc0a154148790a926f991019ec4a/jarn/mkrelease/mkrelease.py#L214-L220 | train | 58,166 |
Jarn/jarn.mkrelease | jarn/mkrelease/mkrelease.py | Locations.check_empty_locations | def check_empty_locations(self, locations=None):
"""Fail if 'locations' is empty.
"""
if locations is None:
locations = self.locations
if not locations:
err_exit('mkrelease: option -d is required\n%s' % USAGE) | python | def check_empty_locations(self, locations=None):
"""Fail if 'locations' is empty.
"""
if locations is None:
locations = self.locations
if not locations:
err_exit('mkrelease: option -d is required\n%s' % USAGE) | [
"def",
"check_empty_locations",
"(",
"self",
",",
"locations",
"=",
"None",
")",
":",
"if",
"locations",
"is",
"None",
":",
"locations",
"=",
"self",
".",
"locations",
"if",
"not",
"locations",
":",
"err_exit",
"(",
"'mkrelease: option -d is required\\n%s'",
"%"... | Fail if 'locations' is empty. | [
"Fail",
"if",
"locations",
"is",
"empty",
"."
] | 844377f37a3cdc0a154148790a926f991019ec4a | https://github.com/Jarn/jarn.mkrelease/blob/844377f37a3cdc0a154148790a926f991019ec4a/jarn/mkrelease/mkrelease.py#L222-L228 | train | 58,167 |
Jarn/jarn.mkrelease | jarn/mkrelease/mkrelease.py | Locations.check_valid_locations | def check_valid_locations(self, locations=None):
"""Fail if 'locations' contains bad destinations.
"""
if locations is None:
locations = self.locations
for location in locations:
if (not self.is_server(location) and
not self.is_ssh_url(location) an... | python | def check_valid_locations(self, locations=None):
"""Fail if 'locations' contains bad destinations.
"""
if locations is None:
locations = self.locations
for location in locations:
if (not self.is_server(location) and
not self.is_ssh_url(location) an... | [
"def",
"check_valid_locations",
"(",
"self",
",",
"locations",
"=",
"None",
")",
":",
"if",
"locations",
"is",
"None",
":",
"locations",
"=",
"self",
".",
"locations",
"for",
"location",
"in",
"locations",
":",
"if",
"(",
"not",
"self",
".",
"is_server",
... | Fail if 'locations' contains bad destinations. | [
"Fail",
"if",
"locations",
"contains",
"bad",
"destinations",
"."
] | 844377f37a3cdc0a154148790a926f991019ec4a | https://github.com/Jarn/jarn.mkrelease/blob/844377f37a3cdc0a154148790a926f991019ec4a/jarn/mkrelease/mkrelease.py#L230-L239 | train | 58,168 |
Jarn/jarn.mkrelease | jarn/mkrelease/mkrelease.py | ReleaseMaker.list_locations | def list_locations(self):
"""Print known dist-locations and exit.
"""
known = self.defaults.get_known_locations()
for default in self.defaults.distdefault:
if default not in known:
known.add(default)
if not known:
err_exit('No locations', 0... | python | def list_locations(self):
"""Print known dist-locations and exit.
"""
known = self.defaults.get_known_locations()
for default in self.defaults.distdefault:
if default not in known:
known.add(default)
if not known:
err_exit('No locations', 0... | [
"def",
"list_locations",
"(",
"self",
")",
":",
"known",
"=",
"self",
".",
"defaults",
".",
"get_known_locations",
"(",
")",
"for",
"default",
"in",
"self",
".",
"defaults",
".",
"distdefault",
":",
"if",
"default",
"not",
"in",
"known",
":",
"known",
".... | Print known dist-locations and exit. | [
"Print",
"known",
"dist",
"-",
"locations",
"and",
"exit",
"."
] | 844377f37a3cdc0a154148790a926f991019ec4a | https://github.com/Jarn/jarn.mkrelease/blob/844377f37a3cdc0a154148790a926f991019ec4a/jarn/mkrelease/mkrelease.py#L355-L369 | train | 58,169 |
Jarn/jarn.mkrelease | jarn/mkrelease/mkrelease.py | ReleaseMaker.get_uploadflags | def get_uploadflags(self, location):
"""Return uploadflags for the given server.
"""
uploadflags = []
server = self.defaults.servers[location]
if self.sign:
uploadflags.append('--sign')
elif server.sign is not None:
if server.sign:
... | python | def get_uploadflags(self, location):
"""Return uploadflags for the given server.
"""
uploadflags = []
server = self.defaults.servers[location]
if self.sign:
uploadflags.append('--sign')
elif server.sign is not None:
if server.sign:
... | [
"def",
"get_uploadflags",
"(",
"self",
",",
"location",
")",
":",
"uploadflags",
"=",
"[",
"]",
"server",
"=",
"self",
".",
"defaults",
".",
"servers",
"[",
"location",
"]",
"if",
"self",
".",
"sign",
":",
"uploadflags",
".",
"append",
"(",
"'--sign'",
... | Return uploadflags for the given server. | [
"Return",
"uploadflags",
"for",
"the",
"given",
"server",
"."
] | 844377f37a3cdc0a154148790a926f991019ec4a | https://github.com/Jarn/jarn.mkrelease/blob/844377f37a3cdc0a154148790a926f991019ec4a/jarn/mkrelease/mkrelease.py#L393-L418 | train | 58,170 |
Jarn/jarn.mkrelease | jarn/mkrelease/mkrelease.py | ReleaseMaker.get_options | def get_options(self):
"""Process the command line.
"""
args = self.parse_options(self.args)
if args:
self.directory = args[0]
if self.develop:
self.skiptag = True
if not self.develop:
self.develop = self.defaults.develop
if n... | python | def get_options(self):
"""Process the command line.
"""
args = self.parse_options(self.args)
if args:
self.directory = args[0]
if self.develop:
self.skiptag = True
if not self.develop:
self.develop = self.defaults.develop
if n... | [
"def",
"get_options",
"(",
"self",
")",
":",
"args",
"=",
"self",
".",
"parse_options",
"(",
"self",
".",
"args",
")",
"if",
"args",
":",
"self",
".",
"directory",
"=",
"args",
"[",
"0",
"]",
"if",
"self",
".",
"develop",
":",
"self",
".",
"skiptag... | Process the command line. | [
"Process",
"the",
"command",
"line",
"."
] | 844377f37a3cdc0a154148790a926f991019ec4a | https://github.com/Jarn/jarn.mkrelease/blob/844377f37a3cdc0a154148790a926f991019ec4a/jarn/mkrelease/mkrelease.py#L425-L476 | train | 58,171 |
Jarn/jarn.mkrelease | jarn/mkrelease/mkrelease.py | ReleaseMaker.get_package | def get_package(self):
"""Get the URL or sandbox to release.
"""
directory = self.directory
develop = self.develop
scmtype = self.scmtype
self.scm = self.scms.get_scm(scmtype, directory)
if self.scm.is_valid_url(directory):
directory = self.urlparser... | python | def get_package(self):
"""Get the URL or sandbox to release.
"""
directory = self.directory
develop = self.develop
scmtype = self.scmtype
self.scm = self.scms.get_scm(scmtype, directory)
if self.scm.is_valid_url(directory):
directory = self.urlparser... | [
"def",
"get_package",
"(",
"self",
")",
":",
"directory",
"=",
"self",
".",
"directory",
"develop",
"=",
"self",
".",
"develop",
"scmtype",
"=",
"self",
".",
"scmtype",
"self",
".",
"scm",
"=",
"self",
".",
"scms",
".",
"get_scm",
"(",
"scmtype",
",",
... | Get the URL or sandbox to release. | [
"Get",
"the",
"URL",
"or",
"sandbox",
"to",
"release",
"."
] | 844377f37a3cdc0a154148790a926f991019ec4a | https://github.com/Jarn/jarn.mkrelease/blob/844377f37a3cdc0a154148790a926f991019ec4a/jarn/mkrelease/mkrelease.py#L478-L504 | train | 58,172 |
Jarn/jarn.mkrelease | jarn/mkrelease/mkrelease.py | ReleaseMaker.make_release | def make_release(self):
"""Build and distribute the package.
"""
directory = self.directory
infoflags = self.infoflags
branch = self.branch
develop = self.develop
scmtype = self.scm.name
tempdir = abspath(tempfile.mkdtemp(prefix='mkrelease-'))
try... | python | def make_release(self):
"""Build and distribute the package.
"""
directory = self.directory
infoflags = self.infoflags
branch = self.branch
develop = self.develop
scmtype = self.scm.name
tempdir = abspath(tempfile.mkdtemp(prefix='mkrelease-'))
try... | [
"def",
"make_release",
"(",
"self",
")",
":",
"directory",
"=",
"self",
".",
"directory",
"infoflags",
"=",
"self",
".",
"infoflags",
"branch",
"=",
"self",
".",
"branch",
"develop",
"=",
"self",
".",
"develop",
"scmtype",
"=",
"self",
".",
"scm",
".",
... | Build and distribute the package. | [
"Build",
"and",
"distribute",
"the",
"package",
"."
] | 844377f37a3cdc0a154148790a926f991019ec4a | https://github.com/Jarn/jarn.mkrelease/blob/844377f37a3cdc0a154148790a926f991019ec4a/jarn/mkrelease/mkrelease.py#L506-L578 | train | 58,173 |
asphalt-framework/asphalt-py4j | asphalt/py4j/component.py | Py4JComponent.configure_gateway | def configure_gateway(
cls, launch_jvm: bool = True,
gateway: Union[GatewayParameters, Dict[str, Any]] = None,
callback_server: Union[CallbackServerParameters, Dict[str, Any]] = False,
javaopts: Iterable[str] = (), classpath: Iterable[str] = ''):
"""
Confi... | python | def configure_gateway(
cls, launch_jvm: bool = True,
gateway: Union[GatewayParameters, Dict[str, Any]] = None,
callback_server: Union[CallbackServerParameters, Dict[str, Any]] = False,
javaopts: Iterable[str] = (), classpath: Iterable[str] = ''):
"""
Confi... | [
"def",
"configure_gateway",
"(",
"cls",
",",
"launch_jvm",
":",
"bool",
"=",
"True",
",",
"gateway",
":",
"Union",
"[",
"GatewayParameters",
",",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
"=",
"None",
",",
"callback_server",
":",
"Union",
"[",
"CallbackS... | Configure a Py4J gateway.
:param launch_jvm: ``True`` to spawn a Java Virtual Machine in a subprocess and connect to
it, ``False`` to connect to an existing Py4J enabled JVM
:param gateway: either a :class:`~py4j.java_gateway.GatewayParameters` object or a
dictionary of keyword ... | [
"Configure",
"a",
"Py4J",
"gateway",
"."
] | e803c696967e9a57c84397b33d3b0651b6f2d08c | https://github.com/asphalt-framework/asphalt-py4j/blob/e803c696967e9a57c84397b33d3b0651b6f2d08c/asphalt/py4j/component.py#L48-L89 | train | 58,174 |
dariusbakunas/rawdisk | rawdisk/plugins/filesystems/ntfs/ntfs_volume.py | NtfsVolume.load | def load(self, filename, offset):
"""Loads NTFS volume information
Args:
filename (str): Path to file/device to read the volume \
information from.
offset (uint): Valid NTFS partition offset from the beginning \
of the file/device.
Raises:
... | python | def load(self, filename, offset):
"""Loads NTFS volume information
Args:
filename (str): Path to file/device to read the volume \
information from.
offset (uint): Valid NTFS partition offset from the beginning \
of the file/device.
Raises:
... | [
"def",
"load",
"(",
"self",
",",
"filename",
",",
"offset",
")",
":",
"self",
".",
"offset",
"=",
"offset",
"self",
".",
"filename",
"=",
"filename",
"self",
".",
"bootsector",
"=",
"BootSector",
"(",
"filename",
"=",
"filename",
",",
"length",
"=",
"N... | Loads NTFS volume information
Args:
filename (str): Path to file/device to read the volume \
information from.
offset (uint): Valid NTFS partition offset from the beginning \
of the file/device.
Raises:
IOError: If source file/device does not... | [
"Loads",
"NTFS",
"volume",
"information"
] | 1dc9d0b377fe5da3c406ccec4abc238c54167403 | https://github.com/dariusbakunas/rawdisk/blob/1dc9d0b377fe5da3c406ccec4abc238c54167403/rawdisk/plugins/filesystems/ntfs/ntfs_volume.py#L39-L67 | train | 58,175 |
dariusbakunas/rawdisk | rawdisk/plugins/filesystems/ntfs/ntfs_volume.py | NtfsVolume._get_mft_zone_size | def _get_mft_zone_size(self, num_clusters, mft_zone_multiplier=1):
"""Returns mft zone size in clusters.
From ntfs_progs.1.22."""
sizes = {
4: num_clusters >> 1, # 50%
3: (num_clusters * 3) >> 3, # 37,5%
2: num_clusters >> 2, # 25%
... | python | def _get_mft_zone_size(self, num_clusters, mft_zone_multiplier=1):
"""Returns mft zone size in clusters.
From ntfs_progs.1.22."""
sizes = {
4: num_clusters >> 1, # 50%
3: (num_clusters * 3) >> 3, # 37,5%
2: num_clusters >> 2, # 25%
... | [
"def",
"_get_mft_zone_size",
"(",
"self",
",",
"num_clusters",
",",
"mft_zone_multiplier",
"=",
"1",
")",
":",
"sizes",
"=",
"{",
"4",
":",
"num_clusters",
">>",
"1",
",",
"# 50%",
"3",
":",
"(",
"num_clusters",
"*",
"3",
")",
">>",
"3",
",",
"# 37,5%"... | Returns mft zone size in clusters.
From ntfs_progs.1.22. | [
"Returns",
"mft",
"zone",
"size",
"in",
"clusters",
".",
"From",
"ntfs_progs",
".",
"1",
".",
"22",
"."
] | 1dc9d0b377fe5da3c406ccec4abc238c54167403 | https://github.com/dariusbakunas/rawdisk/blob/1dc9d0b377fe5da3c406ccec4abc238c54167403/rawdisk/plugins/filesystems/ntfs/ntfs_volume.py#L88-L98 | train | 58,176 |
childsish/lhc-python | lhc/itertools/sorted_iterator_merger.py | SortedIteratorMerger.close | def close(self):
"""
Closes all the iterators.
This is particularly important if the iterators are files.
"""
if hasattr(self, 'iterators'):
for it in self.iterators:
if hasattr(it, 'close'):
it.close() | python | def close(self):
"""
Closes all the iterators.
This is particularly important if the iterators are files.
"""
if hasattr(self, 'iterators'):
for it in self.iterators:
if hasattr(it, 'close'):
it.close() | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'iterators'",
")",
":",
"for",
"it",
"in",
"self",
".",
"iterators",
":",
"if",
"hasattr",
"(",
"it",
",",
"'close'",
")",
":",
"it",
".",
"close",
"(",
")"
] | Closes all the iterators.
This is particularly important if the iterators are files. | [
"Closes",
"all",
"the",
"iterators",
"."
] | 0a669f46a40a39f24d28665e8b5b606dc7e86beb | https://github.com/childsish/lhc-python/blob/0a669f46a40a39f24d28665e8b5b606dc7e86beb/lhc/itertools/sorted_iterator_merger.py#L38-L47 | train | 58,177 |
childsish/lhc-python | lhc/itertools/sorted_iterator_merger.py | SortedIteratorMerger._update_sorting | def _update_sorting(self):
""" Insert new entries into the merged iterator.
:param sorted_tops: A SortedDict.
:param tops: The most recent entry from each iterator.
:param idxs: The indices to update.
"""
key = self.key
sorted_tops = self.sorted_tops
tops... | python | def _update_sorting(self):
""" Insert new entries into the merged iterator.
:param sorted_tops: A SortedDict.
:param tops: The most recent entry from each iterator.
:param idxs: The indices to update.
"""
key = self.key
sorted_tops = self.sorted_tops
tops... | [
"def",
"_update_sorting",
"(",
"self",
")",
":",
"key",
"=",
"self",
".",
"key",
"sorted_tops",
"=",
"self",
".",
"sorted_tops",
"tops",
"=",
"self",
".",
"tops",
"iterators",
"=",
"self",
".",
"iterators",
"for",
"idx",
"in",
"self",
".",
"idxs",
":",... | Insert new entries into the merged iterator.
:param sorted_tops: A SortedDict.
:param tops: The most recent entry from each iterator.
:param idxs: The indices to update. | [
"Insert",
"new",
"entries",
"into",
"the",
"merged",
"iterator",
"."
] | 0a669f46a40a39f24d28665e8b5b606dc7e86beb | https://github.com/childsish/lhc-python/blob/0a669f46a40a39f24d28665e8b5b606dc7e86beb/lhc/itertools/sorted_iterator_merger.py#L49-L72 | train | 58,178 |
CMUSTRUDEL/strudel.utils | stutils/email_utils.py | domain_user_stats | def domain_user_stats():
# type: () -> pd.Series
""" Get number of distinct email addresses in observed domains
TODO: get up to date with new projects layout
How to build email_domain_users.csv:
from collections import defaultdict
import logging
from common import utils as common
impor... | python | def domain_user_stats():
# type: () -> pd.Series
""" Get number of distinct email addresses in observed domains
TODO: get up to date with new projects layout
How to build email_domain_users.csv:
from collections import defaultdict
import logging
from common import utils as common
impor... | [
"def",
"domain_user_stats",
"(",
")",
":",
"# type: () -> pd.Series",
"fname",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"\"email_domain_users.csv\"",
")",
"stats",
"=",
"pd",
".",
"read_csv",
"... | Get number of distinct email addresses in observed domains
TODO: get up to date with new projects layout
How to build email_domain_users.csv:
from collections import defaultdict
import logging
from common import utils as common
import stscraper as scraper
log = logging.getLogger("domain_u... | [
"Get",
"number",
"of",
"distinct",
"email",
"addresses",
"in",
"observed",
"domains"
] | 888ef72fcdb851b5873092bc9c4d6958733691f2 | https://github.com/CMUSTRUDEL/strudel.utils/blob/888ef72fcdb851b5873092bc9c4d6958733691f2/stutils/email_utils.py#L149-L186 | train | 58,179 |
CMUSTRUDEL/strudel.utils | stutils/email_utils.py | is_university | def is_university(addr):
# type: (Union[str, unicode]) -> bool
""" Check if provided email has a university domain
- either in .edu domain
(except public sercices like england.edu or australia.edu)
- or in .edu.TLD (non-US based institutions, like edu.au)
- or listed in a public list of uni... | python | def is_university(addr):
# type: (Union[str, unicode]) -> bool
""" Check if provided email has a university domain
- either in .edu domain
(except public sercices like england.edu or australia.edu)
- or in .edu.TLD (non-US based institutions, like edu.au)
- or listed in a public list of uni... | [
"def",
"is_university",
"(",
"addr",
")",
":",
"# type: (Union[str, unicode]) -> bool",
"addr_domain",
"=",
"domain",
"(",
"addr",
")",
"if",
"not",
"addr_domain",
":",
"# invalid email",
"return",
"False",
"chunks",
"=",
"addr_domain",
".",
"split",
"(",
"\".\"",... | Check if provided email has a university domain
- either in .edu domain
(except public sercices like england.edu or australia.edu)
- or in .edu.TLD (non-US based institutions, like edu.au)
- or listed in a public list of universities
since universities often have department addresses as wel... | [
"Check",
"if",
"provided",
"email",
"has",
"a",
"university",
"domain"
] | 888ef72fcdb851b5873092bc9c4d6958733691f2 | https://github.com/CMUSTRUDEL/strudel.utils/blob/888ef72fcdb851b5873092bc9c4d6958733691f2/stutils/email_utils.py#L211-L243 | train | 58,180 |
CMUSTRUDEL/strudel.utils | stutils/email_utils.py | is_public | def is_public(addr):
# type: (Union[str, unicode]) -> bool
""" Check if the passed email registered at a free pubic mail server
:param addr: email address to check
:return: bool
>>> is_public("john@cmu.edu")
False
>>> is_public("john@gmail.com")
True
"""
addr_domain = domain(add... | python | def is_public(addr):
# type: (Union[str, unicode]) -> bool
""" Check if the passed email registered at a free pubic mail server
:param addr: email address to check
:return: bool
>>> is_public("john@cmu.edu")
False
>>> is_public("john@gmail.com")
True
"""
addr_domain = domain(add... | [
"def",
"is_public",
"(",
"addr",
")",
":",
"# type: (Union[str, unicode]) -> bool",
"addr_domain",
"=",
"domain",
"(",
"addr",
")",
"if",
"not",
"addr_domain",
":",
"# anybody can use invalid email",
"return",
"True",
"chunks",
"=",
"addr_domain",
".",
"rsplit",
"("... | Check if the passed email registered at a free pubic mail server
:param addr: email address to check
:return: bool
>>> is_public("john@cmu.edu")
False
>>> is_public("john@gmail.com")
True | [
"Check",
"if",
"the",
"passed",
"email",
"registered",
"at",
"a",
"free",
"pubic",
"mail",
"server"
] | 888ef72fcdb851b5873092bc9c4d6958733691f2 | https://github.com/CMUSTRUDEL/strudel.utils/blob/888ef72fcdb851b5873092bc9c4d6958733691f2/stutils/email_utils.py#L246-L265 | train | 58,181 |
SeattleTestbed/seash | pyreadline/console/ironpython_console.py | Console.write_color | def write_color(self, text, attr=None):
'''write text at current cursor position and interpret color escapes.
return the number of characters written.
'''
log(u'write_color("%s", %s)' % (text, attr))
chunks = self.terminal_escape.split(text)
log(u'chunks=%s' % rep... | python | def write_color(self, text, attr=None):
'''write text at current cursor position and interpret color escapes.
return the number of characters written.
'''
log(u'write_color("%s", %s)' % (text, attr))
chunks = self.terminal_escape.split(text)
log(u'chunks=%s' % rep... | [
"def",
"write_color",
"(",
"self",
",",
"text",
",",
"attr",
"=",
"None",
")",
":",
"log",
"(",
"u'write_color(\"%s\", %s)'",
"%",
"(",
"text",
",",
"attr",
")",
")",
"chunks",
"=",
"self",
".",
"terminal_escape",
".",
"split",
"(",
"text",
")",
"log",... | write text at current cursor position and interpret color escapes.
return the number of characters written. | [
"write",
"text",
"at",
"current",
"cursor",
"position",
"and",
"interpret",
"color",
"escapes",
".",
"return",
"the",
"number",
"of",
"characters",
"written",
"."
] | 40f9d2285662ff8b61e0468b4196acee089b273b | https://github.com/SeattleTestbed/seash/blob/40f9d2285662ff8b61e0468b4196acee089b273b/pyreadline/console/ironpython_console.py#L195-L222 | train | 58,182 |
RI-imaging/qpformat | qpformat/file_formats/series_zip_tif_holo.py | SeriesZipTifHolo.files | def files(self):
"""List of hologram data file names in the input zip file"""
if self._files is None:
self._files = SeriesZipTifHolo._index_files(self.path)
return self._files | python | def files(self):
"""List of hologram data file names in the input zip file"""
if self._files is None:
self._files = SeriesZipTifHolo._index_files(self.path)
return self._files | [
"def",
"files",
"(",
"self",
")",
":",
"if",
"self",
".",
"_files",
"is",
"None",
":",
"self",
".",
"_files",
"=",
"SeriesZipTifHolo",
".",
"_index_files",
"(",
"self",
".",
"path",
")",
"return",
"self",
".",
"_files"
] | List of hologram data file names in the input zip file | [
"List",
"of",
"hologram",
"data",
"file",
"names",
"in",
"the",
"input",
"zip",
"file"
] | 364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb | https://github.com/RI-imaging/qpformat/blob/364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb/qpformat/file_formats/series_zip_tif_holo.py#L57-L61 | train | 58,183 |
RI-imaging/qpformat | qpformat/file_formats/series_zip_tif_holo.py | SeriesZipTifHolo.get_time | def get_time(self, idx):
"""Time for each TIFF file
If there are no metadata keyword arguments defined for the
TIFF file format, then the zip file `date_time` value is
used.
"""
# first try to get the time from the TIFF file
# (possible meta data keywords)
... | python | def get_time(self, idx):
"""Time for each TIFF file
If there are no metadata keyword arguments defined for the
TIFF file format, then the zip file `date_time` value is
used.
"""
# first try to get the time from the TIFF file
# (possible meta data keywords)
... | [
"def",
"get_time",
"(",
"self",
",",
"idx",
")",
":",
"# first try to get the time from the TIFF file",
"# (possible meta data keywords)",
"ds",
"=",
"self",
".",
"_get_dataset",
"(",
"idx",
")",
"thetime",
"=",
"ds",
".",
"get_time",
"(",
")",
"if",
"np",
".",
... | Time for each TIFF file
If there are no metadata keyword arguments defined for the
TIFF file format, then the zip file `date_time` value is
used. | [
"Time",
"for",
"each",
"TIFF",
"file"
] | 364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb | https://github.com/RI-imaging/qpformat/blob/364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb/qpformat/file_formats/series_zip_tif_holo.py#L63-L80 | train | 58,184 |
asascience-open/paegan-transport | paegan/transport/parallel_manager.py | DataController.get_remote_data | def get_remote_data(self, localvars, remotevars, inds, shape):
"""
Method that does the updating of local netcdf cache
with remote data
"""
# If user specifies 'all' then entire xy domain is
# grabbed, default is 4, specified in the model_controller
if sel... | python | def get_remote_data(self, localvars, remotevars, inds, shape):
"""
Method that does the updating of local netcdf cache
with remote data
"""
# If user specifies 'all' then entire xy domain is
# grabbed, default is 4, specified in the model_controller
if sel... | [
"def",
"get_remote_data",
"(",
"self",
",",
"localvars",
",",
"remotevars",
",",
"inds",
",",
"shape",
")",
":",
"# If user specifies 'all' then entire xy domain is",
"# grabbed, default is 4, specified in the model_controller",
"if",
"self",
".",
"horiz_size",
"==",
"'all'... | Method that does the updating of local netcdf cache
with remote data | [
"Method",
"that",
"does",
"the",
"updating",
"of",
"local",
"netcdf",
"cache",
"with",
"remote",
"data"
] | 99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3 | https://github.com/asascience-open/paegan-transport/blob/99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3/paegan/transport/parallel_manager.py#L114-L153 | train | 58,185 |
asascience-open/paegan-transport | paegan/transport/parallel_manager.py | ForceParticle.need_data | def need_data(self, i):
"""
Method to test if cache contains the data that
the particle needs
"""
# If we are not caching, we always grab data from the raw source
if self.caching is False:
return False
logger.debug("Checking cache for data av... | python | def need_data(self, i):
"""
Method to test if cache contains the data that
the particle needs
"""
# If we are not caching, we always grab data from the raw source
if self.caching is False:
return False
logger.debug("Checking cache for data av... | [
"def",
"need_data",
"(",
"self",
",",
"i",
")",
":",
"# If we are not caching, we always grab data from the raw source",
"if",
"self",
".",
"caching",
"is",
"False",
":",
"return",
"False",
"logger",
".",
"debug",
"(",
"\"Checking cache for data availability at %s.\"",
... | Method to test if cache contains the data that
the particle needs | [
"Method",
"to",
"test",
"if",
"cache",
"contains",
"the",
"data",
"that",
"the",
"particle",
"needs"
] | 99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3 | https://github.com/asascience-open/paegan-transport/blob/99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3/paegan/transport/parallel_manager.py#L485-L527 | train | 58,186 |
asascience-open/paegan-transport | paegan/transport/parallel_manager.py | ForceParticle.linterp | def linterp(self, setx, sety, x):
"""
Linear interp of model data values between time steps
"""
if math.isnan(sety[0]) or math.isnan(setx[0]):
return np.nan
#if math.isnan(sety[0]):
# sety[0] = 0.
#if math.isnan(sety[1]):
# sety[1] = ... | python | def linterp(self, setx, sety, x):
"""
Linear interp of model data values between time steps
"""
if math.isnan(sety[0]) or math.isnan(setx[0]):
return np.nan
#if math.isnan(sety[0]):
# sety[0] = 0.
#if math.isnan(sety[1]):
# sety[1] = ... | [
"def",
"linterp",
"(",
"self",
",",
"setx",
",",
"sety",
",",
"x",
")",
":",
"if",
"math",
".",
"isnan",
"(",
"sety",
"[",
"0",
"]",
")",
"or",
"math",
".",
"isnan",
"(",
"setx",
"[",
"0",
"]",
")",
":",
"return",
"np",
".",
"nan",
"#if math.... | Linear interp of model data values between time steps | [
"Linear",
"interp",
"of",
"model",
"data",
"values",
"between",
"time",
"steps"
] | 99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3 | https://github.com/asascience-open/paegan-transport/blob/99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3/paegan/transport/parallel_manager.py#L529-L539 | train | 58,187 |
asascience-open/paegan-transport | paegan/transport/parallel_manager.py | ForceParticle.boundary_interaction | def boundary_interaction(self, **kwargs):
"""
Returns a list of Location4D objects
"""
particle = kwargs.pop('particle')
starting = kwargs.pop('starting')
ending = kwargs.pop('ending')
# shoreline
if self.useshore:
intersection_point = sel... | python | def boundary_interaction(self, **kwargs):
"""
Returns a list of Location4D objects
"""
particle = kwargs.pop('particle')
starting = kwargs.pop('starting')
ending = kwargs.pop('ending')
# shoreline
if self.useshore:
intersection_point = sel... | [
"def",
"boundary_interaction",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"particle",
"=",
"kwargs",
".",
"pop",
"(",
"'particle'",
")",
"starting",
"=",
"kwargs",
".",
"pop",
"(",
"'starting'",
")",
"ending",
"=",
"kwargs",
".",
"pop",
"(",
"'end... | Returns a list of Location4D objects | [
"Returns",
"a",
"list",
"of",
"Location4D",
"objects"
] | 99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3 | https://github.com/asascience-open/paegan-transport/blob/99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3/paegan/transport/parallel_manager.py#L918-L967 | train | 58,188 |
yougov/vr.common | vr/common/paths.py | get_buildfile_path | def get_buildfile_path(settings):
"""
Path to which a build tarball should be downloaded.
"""
base = os.path.basename(settings.build_url)
return os.path.join(BUILDS_ROOT, base) | python | def get_buildfile_path(settings):
"""
Path to which a build tarball should be downloaded.
"""
base = os.path.basename(settings.build_url)
return os.path.join(BUILDS_ROOT, base) | [
"def",
"get_buildfile_path",
"(",
"settings",
")",
":",
"base",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"settings",
".",
"build_url",
")",
"return",
"os",
".",
"path",
".",
"join",
"(",
"BUILDS_ROOT",
",",
"base",
")"
] | Path to which a build tarball should be downloaded. | [
"Path",
"to",
"which",
"a",
"build",
"tarball",
"should",
"be",
"downloaded",
"."
] | ca8ed0c50ba873fc51fdfeeaa25d3b8ec1b54eb4 | https://github.com/yougov/vr.common/blob/ca8ed0c50ba873fc51fdfeeaa25d3b8ec1b54eb4/vr/common/paths.py#L52-L57 | train | 58,189 |
brews/snakebacon | snakebacon/mcmcbackends/__init__.py | Bacon.prior_dates | def prior_dates(*args, **kwargs):
"""Get the prior distribution of calibrated radiocarbon dates"""
try:
chron = args[0]
except IndexError:
chron = kwargs['coredates']
d_r = np.array(kwargs['d_r'])
d_std = np.array(kwargs['d_std'])
t_a = np.array(k... | python | def prior_dates(*args, **kwargs):
"""Get the prior distribution of calibrated radiocarbon dates"""
try:
chron = args[0]
except IndexError:
chron = kwargs['coredates']
d_r = np.array(kwargs['d_r'])
d_std = np.array(kwargs['d_std'])
t_a = np.array(k... | [
"def",
"prior_dates",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"chron",
"=",
"args",
"[",
"0",
"]",
"except",
"IndexError",
":",
"chron",
"=",
"kwargs",
"[",
"'coredates'",
"]",
"d_r",
"=",
"np",
".",
"array",
"(",
"kwargs",... | Get the prior distribution of calibrated radiocarbon dates | [
"Get",
"the",
"prior",
"distribution",
"of",
"calibrated",
"radiocarbon",
"dates"
] | f5363d0d1225912adc30031bf2c13b54000de8f2 | https://github.com/brews/snakebacon/blob/f5363d0d1225912adc30031bf2c13b54000de8f2/snakebacon/mcmcbackends/__init__.py#L11-L49 | train | 58,190 |
brews/snakebacon | snakebacon/mcmcbackends/__init__.py | Bacon.prior_sediment_rate | def prior_sediment_rate(*args, **kwargs):
"""Get the prior density of sediment rates
Returns
-------
y : ndarray
Array giving the density.
x : ndarray
Array of sediment accumulation values (yr/cm) over which the density was evaluated.
"""
... | python | def prior_sediment_rate(*args, **kwargs):
"""Get the prior density of sediment rates
Returns
-------
y : ndarray
Array giving the density.
x : ndarray
Array of sediment accumulation values (yr/cm) over which the density was evaluated.
"""
... | [
"def",
"prior_sediment_rate",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# PlotAccPrior @ Bacon.R ln 113 -> ln 1097-1115",
"# alpha = acc_shape, beta = acc_shape / acc_mean",
"# TODO(brews): Check that these stats are correctly translated to scipy.stats distribs.",
"acc_mean",... | Get the prior density of sediment rates
Returns
-------
y : ndarray
Array giving the density.
x : ndarray
Array of sediment accumulation values (yr/cm) over which the density was evaluated. | [
"Get",
"the",
"prior",
"density",
"of",
"sediment",
"rates"
] | f5363d0d1225912adc30031bf2c13b54000de8f2 | https://github.com/brews/snakebacon/blob/f5363d0d1225912adc30031bf2c13b54000de8f2/snakebacon/mcmcbackends/__init__.py#L52-L70 | train | 58,191 |
brews/snakebacon | snakebacon/mcmcbackends/__init__.py | Bacon.prior_sediment_memory | def prior_sediment_memory(*args, **kwargs):
"""Get the prior density of sediment memory
Returns
-------
y : ndarray
Array giving the density.
x : ndarray
Array of Memory (ratio) values over which the density was evaluated.
"""
# "plot the ... | python | def prior_sediment_memory(*args, **kwargs):
"""Get the prior density of sediment memory
Returns
-------
y : ndarray
Array giving the density.
x : ndarray
Array of Memory (ratio) values over which the density was evaluated.
"""
# "plot the ... | [
"def",
"prior_sediment_memory",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# \"plot the prior for the memory (= accumulation rate varibility between neighbouring depths)\"",
"# PlotMemPrior @ Bacon.R ln 114 -> ln 1119 - 1141",
"# w_a = mem_strength * mem_mean, w_b = mem_strength... | Get the prior density of sediment memory
Returns
-------
y : ndarray
Array giving the density.
x : ndarray
Array of Memory (ratio) values over which the density was evaluated. | [
"Get",
"the",
"prior",
"density",
"of",
"sediment",
"memory"
] | f5363d0d1225912adc30031bf2c13b54000de8f2 | https://github.com/brews/snakebacon/blob/f5363d0d1225912adc30031bf2c13b54000de8f2/snakebacon/mcmcbackends/__init__.py#L73-L92 | train | 58,192 |
inveniosoftware-attic/invenio-client | invenio_client/contrib/cds.py | CDSInvenioConnector._init_browser | def _init_browser(self):
"""Update this everytime the CERN SSO login form is refactored."""
self.browser = splinter.Browser('phantomjs')
self.browser.visit(self.server_url)
self.browser.find_link_by_partial_text("Sign in").click()
self.browser.fill(
'ctl00$ctl00$NICEM... | python | def _init_browser(self):
"""Update this everytime the CERN SSO login form is refactored."""
self.browser = splinter.Browser('phantomjs')
self.browser.visit(self.server_url)
self.browser.find_link_by_partial_text("Sign in").click()
self.browser.fill(
'ctl00$ctl00$NICEM... | [
"def",
"_init_browser",
"(",
"self",
")",
":",
"self",
".",
"browser",
"=",
"splinter",
".",
"Browser",
"(",
"'phantomjs'",
")",
"self",
".",
"browser",
".",
"visit",
"(",
"self",
".",
"server_url",
")",
"self",
".",
"browser",
".",
"find_link_by_partial_t... | Update this everytime the CERN SSO login form is refactored. | [
"Update",
"this",
"everytime",
"the",
"CERN",
"SSO",
"login",
"form",
"is",
"refactored",
"."
] | 3f9ddb6f3b3ce3a21d399d1098d6769bf05cdd6c | https://github.com/inveniosoftware-attic/invenio-client/blob/3f9ddb6f3b3ce3a21d399d1098d6769bf05cdd6c/invenio_client/contrib/cds.py#L46-L58 | train | 58,193 |
koehlma/pygrooveshark | src/grooveshark/classes/song.py | Song.download | def download(self, directory='~/Music', song_name='%a - %s - %A'):
"""
Download a song to a directory.
:param directory: A system file path.
:param song_name: A name that will be formatted with :meth:`format`.
:return: The formatted song name.
"""
formatted = sel... | python | def download(self, directory='~/Music', song_name='%a - %s - %A'):
"""
Download a song to a directory.
:param directory: A system file path.
:param song_name: A name that will be formatted with :meth:`format`.
:return: The formatted song name.
"""
formatted = sel... | [
"def",
"download",
"(",
"self",
",",
"directory",
"=",
"'~/Music'",
",",
"song_name",
"=",
"'%a - %s - %A'",
")",
":",
"formatted",
"=",
"self",
".",
"format",
"(",
"song_name",
")",
"path",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"directory",
")... | Download a song to a directory.
:param directory: A system file path.
:param song_name: A name that will be formatted with :meth:`format`.
:return: The formatted song name. | [
"Download",
"a",
"song",
"to",
"a",
"directory",
"."
] | 17673758ac12f54dc26ac879c30ea44f13b81057 | https://github.com/koehlma/pygrooveshark/blob/17673758ac12f54dc26ac879c30ea44f13b81057/src/grooveshark/classes/song.py#L203-L219 | train | 58,194 |
koehlma/pygrooveshark | src/grooveshark/classes/song.py | Song.safe_download | def safe_download(self):
"""Download a song respecting Grooveshark's API.
:return: The raw song data.
"""
def _markStreamKeyOver30Seconds(stream):
self._connection.request(
'markStreamKeyOver30Seconds',
{'streamServerID': stream.ip,
... | python | def safe_download(self):
"""Download a song respecting Grooveshark's API.
:return: The raw song data.
"""
def _markStreamKeyOver30Seconds(stream):
self._connection.request(
'markStreamKeyOver30Seconds',
{'streamServerID': stream.ip,
... | [
"def",
"safe_download",
"(",
"self",
")",
":",
"def",
"_markStreamKeyOver30Seconds",
"(",
"stream",
")",
":",
"self",
".",
"_connection",
".",
"request",
"(",
"'markStreamKeyOver30Seconds'",
",",
"{",
"'streamServerID'",
":",
"stream",
".",
"ip",
",",
"'artistID... | Download a song respecting Grooveshark's API.
:return: The raw song data. | [
"Download",
"a",
"song",
"respecting",
"Grooveshark",
"s",
"API",
"."
] | 17673758ac12f54dc26ac879c30ea44f13b81057 | https://github.com/koehlma/pygrooveshark/blob/17673758ac12f54dc26ac879c30ea44f13b81057/src/grooveshark/classes/song.py#L221-L258 | train | 58,195 |
helixyte/everest | everest/representers/config.py | RepresenterConfiguration.copy | def copy(self):
"""
Return a copy of this configuration.
"""
return self.__class__(options=self.__options,
attribute_options=self.__attribute_options) | python | def copy(self):
"""
Return a copy of this configuration.
"""
return self.__class__(options=self.__options,
attribute_options=self.__attribute_options) | [
"def",
"copy",
"(",
"self",
")",
":",
"return",
"self",
".",
"__class__",
"(",
"options",
"=",
"self",
".",
"__options",
",",
"attribute_options",
"=",
"self",
".",
"__attribute_options",
")"
] | Return a copy of this configuration. | [
"Return",
"a",
"copy",
"of",
"this",
"configuration",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/config.py#L78-L83 | train | 58,196 |
helixyte/everest | everest/representers/config.py | RepresenterConfiguration.get_option | def get_option(self, name):
"""
Returns the value for the specified generic configuration option.
:returns: configuration option value or `None`, if the option was not
set.
"""
self.__validate_option_name(name)
return self.__options.get(name, None) | python | def get_option(self, name):
"""
Returns the value for the specified generic configuration option.
:returns: configuration option value or `None`, if the option was not
set.
"""
self.__validate_option_name(name)
return self.__options.get(name, None) | [
"def",
"get_option",
"(",
"self",
",",
"name",
")",
":",
"self",
".",
"__validate_option_name",
"(",
"name",
")",
"return",
"self",
".",
"__options",
".",
"get",
"(",
"name",
",",
"None",
")"
] | Returns the value for the specified generic configuration option.
:returns: configuration option value or `None`, if the option was not
set. | [
"Returns",
"the",
"value",
"for",
"the",
"specified",
"generic",
"configuration",
"option",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/config.py#L93-L101 | train | 58,197 |
helixyte/everest | everest/representers/config.py | RepresenterConfiguration.set_option | def set_option(self, name, value):
"""
Sets the specified generic configuration option to the given value.
"""
self.__validate_option_name(name)
self.__options[name] = value | python | def set_option(self, name, value):
"""
Sets the specified generic configuration option to the given value.
"""
self.__validate_option_name(name)
self.__options[name] = value | [
"def",
"set_option",
"(",
"self",
",",
"name",
",",
"value",
")",
":",
"self",
".",
"__validate_option_name",
"(",
"name",
")",
"self",
".",
"__options",
"[",
"name",
"]",
"=",
"value"
] | Sets the specified generic configuration option to the given value. | [
"Sets",
"the",
"specified",
"generic",
"configuration",
"option",
"to",
"the",
"given",
"value",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/config.py#L103-L108 | train | 58,198 |
helixyte/everest | everest/representers/config.py | RepresenterConfiguration.set_attribute_option | def set_attribute_option(self, attribute, option_name, option_value):
"""
Sets the given attribute option to the given value for the specified
attribute.
"""
self.__validate_attribute_option_name(option_name)
attribute_key = self.__make_key(attribute)
mp_options =... | python | def set_attribute_option(self, attribute, option_name, option_value):
"""
Sets the given attribute option to the given value for the specified
attribute.
"""
self.__validate_attribute_option_name(option_name)
attribute_key = self.__make_key(attribute)
mp_options =... | [
"def",
"set_attribute_option",
"(",
"self",
",",
"attribute",
",",
"option_name",
",",
"option_value",
")",
":",
"self",
".",
"__validate_attribute_option_name",
"(",
"option_name",
")",
"attribute_key",
"=",
"self",
".",
"__make_key",
"(",
"attribute",
")",
"mp_o... | Sets the given attribute option to the given value for the specified
attribute. | [
"Sets",
"the",
"given",
"attribute",
"option",
"to",
"the",
"given",
"value",
"for",
"the",
"specified",
"attribute",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/config.py#L116-L124 | train | 58,199 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.