repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
fr33jc/bang | bang/config.py | find_component_tarball | def find_component_tarball(bucket, comp_name, comp_config):
"""
Returns True if the component tarball is found in the bucket.
Otherwise, returns False.
"""
values = {
'name': comp_name,
'version': comp_config['version'],
'platform': comp_config['platform'],
... | python | def find_component_tarball(bucket, comp_name, comp_config):
"""
Returns True if the component tarball is found in the bucket.
Otherwise, returns False.
"""
values = {
'name': comp_name,
'version': comp_config['version'],
'platform': comp_config['platform'],
... | [
"def",
"find_component_tarball",
"(",
"bucket",
",",
"comp_name",
",",
"comp_config",
")",
":",
"values",
"=",
"{",
"'name'",
":",
"comp_name",
",",
"'version'",
":",
"comp_config",
"[",
"'version'",
"]",
",",
"'platform'",
":",
"comp_config",
"[",
"'platform'... | Returns True if the component tarball is found in the bucket.
Otherwise, returns False. | [
"Returns",
"True",
"if",
"the",
"component",
"tarball",
"is",
"found",
"in",
"the",
"bucket",
"."
] | train | https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/config.py#L43-L62 |
fr33jc/bang | bang/config.py | parse_bangrc | def parse_bangrc():
"""
Parses ``$HOME/.bangrc`` for global settings and deployer credentials. The
``.bangrc`` file is expected to be a YAML file whose outermost structure is
a key-value map.
Note that even though ``.bangrc`` is just a YAML file in which a user could
store any top-level keys, ... | python | def parse_bangrc():
"""
Parses ``$HOME/.bangrc`` for global settings and deployer credentials. The
``.bangrc`` file is expected to be a YAML file whose outermost structure is
a key-value map.
Note that even though ``.bangrc`` is just a YAML file in which a user could
store any top-level keys, ... | [
"def",
"parse_bangrc",
"(",
")",
":",
"raw",
"=",
"read_raw_bangrc",
"(",
")",
"return",
"dict",
"(",
"(",
"k",
",",
"raw",
"[",
"k",
"]",
")",
"for",
"k",
"in",
"raw",
"if",
"k",
"in",
"RC_KEYS",
")"
] | Parses ``$HOME/.bangrc`` for global settings and deployer credentials. The
``.bangrc`` file is expected to be a YAML file whose outermost structure is
a key-value map.
Note that even though ``.bangrc`` is just a YAML file in which a user could
store any top-level keys, it is not expected to be used as... | [
"Parses",
"$HOME",
"/",
".",
"bangrc",
"for",
"global",
"settings",
"and",
"deployer",
"credentials",
".",
"The",
".",
"bangrc",
"file",
"is",
"expected",
"to",
"be",
"a",
"YAML",
"file",
"whose",
"outermost",
"structure",
"is",
"a",
"key",
"-",
"value",
... | train | https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/config.py#L76-L93 |
fr33jc/bang | bang/config.py | resolve_config_spec | def resolve_config_spec(config_spec, config_dir=''):
"""
Resolves :attr:`config_spec` to a path to a config file.
:param str config_spec: Valid config specs:
- The basename of a YAML config file *without* the ``.yml`` extension.
The full path to the config file is resolved by appending ... | python | def resolve_config_spec(config_spec, config_dir=''):
"""
Resolves :attr:`config_spec` to a path to a config file.
:param str config_spec: Valid config specs:
- The basename of a YAML config file *without* the ``.yml`` extension.
The full path to the config file is resolved by appending ... | [
"def",
"resolve_config_spec",
"(",
"config_spec",
",",
"config_dir",
"=",
"''",
")",
":",
"if",
"'/'",
"in",
"config_spec",
"or",
"config_spec",
".",
"endswith",
"(",
"'.yml'",
")",
":",
"return",
"config_spec",
"return",
"os",
".",
"path",
".",
"join",
"(... | Resolves :attr:`config_spec` to a path to a config file.
:param str config_spec: Valid config specs:
- The basename of a YAML config file *without* the ``.yml`` extension.
The full path to the config file is resolved by appending ``.yml`` to
the basename, then by searching for the res... | [
"Resolves",
":",
"attr",
":",
"config_spec",
"to",
"a",
"path",
"to",
"a",
"config",
"file",
"."
] | train | https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/config.py#L96-L120 |
fr33jc/bang | bang/config.py | Config.from_config_specs | def from_config_specs(cls, config_specs, prepare=True):
"""
Alternate constructor that merges config attributes from
``$HOME/.bangrc`` and :attr:`config_specs` into a single
:class:`Config` object.
The first (and potentially *only* spec) in :attr:`config_specs` should
be... | python | def from_config_specs(cls, config_specs, prepare=True):
"""
Alternate constructor that merges config attributes from
``$HOME/.bangrc`` and :attr:`config_specs` into a single
:class:`Config` object.
The first (and potentially *only* spec) in :attr:`config_specs` should
be... | [
"def",
"from_config_specs",
"(",
"cls",
",",
"config_specs",
",",
"prepare",
"=",
"True",
")",
":",
"bangrc",
"=",
"parse_bangrc",
"(",
")",
"config_dir",
"=",
"bangrc",
".",
"get",
"(",
"A",
".",
"CONFIG_DIR",
",",
"DEFAULT_CONFIG_DIR",
")",
"config_paths",... | Alternate constructor that merges config attributes from
``$HOME/.bangrc`` and :attr:`config_specs` into a single
:class:`Config` object.
The first (and potentially *only* spec) in :attr:`config_specs` should
be main configuration file for the stack to be deployed. The returned
... | [
"Alternate",
"constructor",
"that",
"merges",
"config",
"attributes",
"from",
"$HOME",
"/",
".",
"bangrc",
"and",
":",
"attr",
":",
"config_specs",
"into",
"a",
"single",
":",
"class",
":",
"Config",
"object",
"."
] | train | https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/config.py#L140-L178 |
fr33jc/bang | bang/config.py | Config._prepare_servers | def _prepare_servers(self):
"""
Prepare the variables that are exposed to the servers.
Most attributes in the server config are used directly. However, due
to variations in how cloud providers treat regions and availability
zones, this method allows either the ``availability_zo... | python | def _prepare_servers(self):
"""
Prepare the variables that are exposed to the servers.
Most attributes in the server config are used directly. However, due
to variations in how cloud providers treat regions and availability
zones, this method allows either the ``availability_zo... | [
"def",
"_prepare_servers",
"(",
"self",
")",
":",
"stack",
"=",
"{",
"A",
".",
"NAME",
":",
"self",
"[",
"A",
".",
"NAME",
"]",
",",
"A",
".",
"VERSION",
":",
"self",
"[",
"A",
".",
"VERSION",
"]",
",",
"}",
"for",
"server",
"in",
"self",
".",
... | Prepare the variables that are exposed to the servers.
Most attributes in the server config are used directly. However, due
to variations in how cloud providers treat regions and availability
zones, this method allows either the ``availability_zone`` or the
``region_name`` to be used a... | [
"Prepare",
"the",
"variables",
"that",
"are",
"exposed",
"to",
"the",
"servers",
"."
] | train | https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/config.py#L308-L354 |
fr33jc/bang | bang/config.py | Config._prepare_load_balancers | def _prepare_load_balancers(self):
"""
Prepare load balancer variables
"""
stack = {
A.NAME: self[A.NAME],
A.VERSION: self[A.VERSION],
}
for load_balancer in self.get(R.LOAD_BALANCERS, []):
svars = {A.STACK: stack}
... | python | def _prepare_load_balancers(self):
"""
Prepare load balancer variables
"""
stack = {
A.NAME: self[A.NAME],
A.VERSION: self[A.VERSION],
}
for load_balancer in self.get(R.LOAD_BALANCERS, []):
svars = {A.STACK: stack}
... | [
"def",
"_prepare_load_balancers",
"(",
"self",
")",
":",
"stack",
"=",
"{",
"A",
".",
"NAME",
":",
"self",
"[",
"A",
".",
"NAME",
"]",
",",
"A",
".",
"VERSION",
":",
"self",
"[",
"A",
".",
"VERSION",
"]",
",",
"}",
"for",
"load_balancer",
"in",
"... | Prepare load balancer variables | [
"Prepare",
"load",
"balancer",
"variables"
] | train | https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/config.py#L356-L367 |
fr33jc/bang | bang/config.py | Config._convert_to_list | def _convert_to_list(self, stanza_key, name_key):
"""
Convert self[stanza_key] to a list. For each k, v
k, v = self[stanza_key].iteritems() assign
v[name_key] = k
"""
converted_list = []
for k, v in self.get(stanza_key, {}).iteritems():
v[name_key] = k... | python | def _convert_to_list(self, stanza_key, name_key):
"""
Convert self[stanza_key] to a list. For each k, v
k, v = self[stanza_key].iteritems() assign
v[name_key] = k
"""
converted_list = []
for k, v in self.get(stanza_key, {}).iteritems():
v[name_key] = k... | [
"def",
"_convert_to_list",
"(",
"self",
",",
"stanza_key",
",",
"name_key",
")",
":",
"converted_list",
"=",
"[",
"]",
"for",
"k",
",",
"v",
"in",
"self",
".",
"get",
"(",
"stanza_key",
",",
"{",
"}",
")",
".",
"iteritems",
"(",
")",
":",
"v",
"[",... | Convert self[stanza_key] to a list. For each k, v
k, v = self[stanza_key].iteritems() assign
v[name_key] = k | [
"Convert",
"self",
"[",
"stanza_key",
"]",
"to",
"a",
"list",
".",
"For",
"each",
"k",
"v",
"k",
"v",
"=",
"self",
"[",
"stanza_key",
"]",
".",
"iteritems",
"()",
"assign",
"v",
"[",
"name_key",
"]",
"=",
"k"
] | train | https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/config.py#L369-L379 |
fr33jc/bang | bang/config.py | Config.prepare | def prepare(self):
"""
Reorganizes the data such that the deployment logic can find it all
where it expects to be.
The raw configuration file is intended to be as human-friendly as
possible partly through the following mechanisms:
- In order to minimize repetition, ... | python | def prepare(self):
"""
Reorganizes the data such that the deployment logic can find it all
where it expects to be.
The raw configuration file is intended to be as human-friendly as
possible partly through the following mechanisms:
- In order to minimize repetition, ... | [
"def",
"prepare",
"(",
"self",
")",
":",
"# TODO: take server_common_attributes and disperse it among the various",
"# server stanzas",
"# First stage - turn all the dicts (SERVER, SECGROUP, DATABASE, LOADBAL)",
"# into lists now they're merged properly",
"for",
"stanza_key",
",",
"name_ke... | Reorganizes the data such that the deployment logic can find it all
where it expects to be.
The raw configuration file is intended to be as human-friendly as
possible partly through the following mechanisms:
- In order to minimize repetition, any attributes that are common
... | [
"Reorganizes",
"the",
"data",
"such",
"that",
"the",
"deployment",
"logic",
"can",
"find",
"it",
"all",
"where",
"it",
"expects",
"to",
"be",
"."
] | train | https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/config.py#L381-L426 |
fr33jc/bang | bang/config.py | Config.autoinc | def autoinc(self):
"""
Conditionally updates the stack version in the file associated with
this config.
This handles both official releases (i.e. QA configs), and release
candidates. Assumptions about version:
- Official release versions are MAJOR.minor, where MAJ... | python | def autoinc(self):
"""
Conditionally updates the stack version in the file associated with
this config.
This handles both official releases (i.e. QA configs), and release
candidates. Assumptions about version:
- Official release versions are MAJOR.minor, where MAJ... | [
"def",
"autoinc",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"get",
"(",
"'autoinc_version'",
")",
":",
"return",
"oldver",
"=",
"self",
"[",
"'version'",
"]",
"newver",
"=",
"bump_version_tail",
"(",
"oldver",
")",
"config_path",
"=",
"self",
".",... | Conditionally updates the stack version in the file associated with
this config.
This handles both official releases (i.e. QA configs), and release
candidates. Assumptions about version:
- Official release versions are MAJOR.minor, where MAJOR and minor
are both non... | [
"Conditionally",
"updates",
"the",
"stack",
"version",
"in",
"the",
"file",
"associated",
"with",
"this",
"config",
"."
] | train | https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/config.py#L437-L484 |
Rafiot/PubSubLogger | pubsublogger/subscriber.py | setup | def setup(name, path='log', enable_debug=False):
"""
Prepare a NestedSetup.
:param name: the channel name
:param path: the path where the logs will be written
:param enable_debug: do we want to save the message at the DEBUG level
:return a nested Setup
"""
path_tmpl = os.path.join(path... | python | def setup(name, path='log', enable_debug=False):
"""
Prepare a NestedSetup.
:param name: the channel name
:param path: the path where the logs will be written
:param enable_debug: do we want to save the message at the DEBUG level
:return a nested Setup
"""
path_tmpl = os.path.join(path... | [
"def",
"setup",
"(",
"name",
",",
"path",
"=",
"'log'",
",",
"enable_debug",
"=",
"False",
")",
":",
"path_tmpl",
"=",
"os",
".",
"path",
".",
"join",
"(",
"path",
",",
"'{name}_{level}.log'",
")",
"info",
"=",
"path_tmpl",
".",
"format",
"(",
"name",
... | Prepare a NestedSetup.
:param name: the channel name
:param path: the path where the logs will be written
:param enable_debug: do we want to save the message at the DEBUG level
:return a nested Setup | [
"Prepare",
"a",
"NestedSetup",
"."
] | train | https://github.com/Rafiot/PubSubLogger/blob/4f28ad673f42ee2ec7792d414d325aef9a56da53/pubsublogger/subscriber.py#L43-L91 |
Rafiot/PubSubLogger | pubsublogger/subscriber.py | mail_setup | def mail_setup(path):
"""
Set the variables to be able to send emails.
:param path: path to the config file
"""
global dest_mails
global smtp_server
global smtp_port
global src_server
config = configparser.RawConfigParser()
config.readfp(path)
dest_mails = config.get('mail',... | python | def mail_setup(path):
"""
Set the variables to be able to send emails.
:param path: path to the config file
"""
global dest_mails
global smtp_server
global smtp_port
global src_server
config = configparser.RawConfigParser()
config.readfp(path)
dest_mails = config.get('mail',... | [
"def",
"mail_setup",
"(",
"path",
")",
":",
"global",
"dest_mails",
"global",
"smtp_server",
"global",
"smtp_port",
"global",
"src_server",
"config",
"=",
"configparser",
".",
"RawConfigParser",
"(",
")",
"config",
".",
"readfp",
"(",
"path",
")",
"dest_mails",
... | Set the variables to be able to send emails.
:param path: path to the config file | [
"Set",
"the",
"variables",
"to",
"be",
"able",
"to",
"send",
"emails",
"."
] | train | https://github.com/Rafiot/PubSubLogger/blob/4f28ad673f42ee2ec7792d414d325aef9a56da53/pubsublogger/subscriber.py#L94-L109 |
Rafiot/PubSubLogger | pubsublogger/subscriber.py | run | def run(log_name, path, debug=False, mail=None, timeout=0):
"""
Run a subscriber and pass the messages to the logbook setup.
Stays alive as long as the pubsub instance listen to something.
:param log_name: the channel to listen to
:param path: the path where the log files will be written
:param... | python | def run(log_name, path, debug=False, mail=None, timeout=0):
"""
Run a subscriber and pass the messages to the logbook setup.
Stays alive as long as the pubsub instance listen to something.
:param log_name: the channel to listen to
:param path: the path where the log files will be written
:param... | [
"def",
"run",
"(",
"log_name",
",",
"path",
",",
"debug",
"=",
"False",
",",
"mail",
"=",
"None",
",",
"timeout",
"=",
"0",
")",
":",
"global",
"pubsub",
"global",
"channel",
"channel",
"=",
"log_name",
"if",
"use_tcp_socket",
":",
"r",
"=",
"redis",
... | Run a subscriber and pass the messages to the logbook setup.
Stays alive as long as the pubsub instance listen to something.
:param log_name: the channel to listen to
:param path: the path where the log files will be written
:param debug: True if you want to save the debug messages too
:param mail:... | [
"Run",
"a",
"subscriber",
"and",
"pass",
"the",
"messages",
"to",
"the",
"logbook",
"setup",
".",
"Stays",
"alive",
"as",
"long",
"as",
"the",
"pubsub",
"instance",
"listen",
"to",
"something",
"."
] | train | https://github.com/Rafiot/PubSubLogger/blob/4f28ad673f42ee2ec7792d414d325aef9a56da53/pubsublogger/subscriber.py#L112-L158 |
tylertrussell/flake8-docstrings-catnado | flake8_docstrings.py | pep257Checker.parse_options | def parse_options(cls, options):
"""Pass options through to this plugin."""
cls.ignore_decorators = options.ignore_decorators
cls.exclude_from_doctest = options.exclude_from_doctest
if not isinstance(cls.exclude_from_doctest, list):
cls.exclude_from_doctest = [cls.exclude_from_doctest] | python | def parse_options(cls, options):
"""Pass options through to this plugin."""
cls.ignore_decorators = options.ignore_decorators
cls.exclude_from_doctest = options.exclude_from_doctest
if not isinstance(cls.exclude_from_doctest, list):
cls.exclude_from_doctest = [cls.exclude_from_doctest] | [
"def",
"parse_options",
"(",
"cls",
",",
"options",
")",
":",
"cls",
".",
"ignore_decorators",
"=",
"options",
".",
"ignore_decorators",
"cls",
".",
"exclude_from_doctest",
"=",
"options",
".",
"exclude_from_doctest",
"if",
"not",
"isinstance",
"(",
"cls",
".",
... | Pass options through to this plugin. | [
"Pass",
"options",
"through",
"to",
"this",
"plugin",
"."
] | train | https://github.com/tylertrussell/flake8-docstrings-catnado/blob/76a9e202a93c8dfb11994c95911487b3722d75c9/flake8_docstrings.py#L75-L80 |
tylertrussell/flake8-docstrings-catnado | flake8_docstrings.py | pep257Checker.run | def run(self):
"""Use directly check() api from pydocstyle."""
if self.exclude_from_doctest:
for pattern in self.exclude_from_doctest:
if fnmatch.fnmatch(self.filename, pattern):
return
checked_codes = pep257.conventions.pep257 | {'D998', 'D999'}
for error in self._check_source(... | python | def run(self):
"""Use directly check() api from pydocstyle."""
if self.exclude_from_doctest:
for pattern in self.exclude_from_doctest:
if fnmatch.fnmatch(self.filename, pattern):
return
checked_codes = pep257.conventions.pep257 | {'D998', 'D999'}
for error in self._check_source(... | [
"def",
"run",
"(",
"self",
")",
":",
"if",
"self",
".",
"exclude_from_doctest",
":",
"for",
"pattern",
"in",
"self",
".",
"exclude_from_doctest",
":",
"if",
"fnmatch",
".",
"fnmatch",
"(",
"self",
".",
"filename",
",",
"pattern",
")",
":",
"return",
"che... | Use directly check() api from pydocstyle. | [
"Use",
"directly",
"check",
"()",
"api",
"from",
"pydocstyle",
"."
] | train | https://github.com/tylertrussell/flake8-docstrings-catnado/blob/76a9e202a93c8dfb11994c95911487b3722d75c9/flake8_docstrings.py#L100-L112 |
tylertrussell/flake8-docstrings-catnado | flake8_docstrings.py | pep257Checker.load_source | def load_source(self):
"""Load the source for the specified file."""
if self.filename in self.STDIN_NAMES:
self.filename = 'stdin'
self.source = pycodestyle.stdin_get_value()
else:
with pep257.tokenize_open(self.filename) as fd:
self.source = fd.read() | python | def load_source(self):
"""Load the source for the specified file."""
if self.filename in self.STDIN_NAMES:
self.filename = 'stdin'
self.source = pycodestyle.stdin_get_value()
else:
with pep257.tokenize_open(self.filename) as fd:
self.source = fd.read() | [
"def",
"load_source",
"(",
"self",
")",
":",
"if",
"self",
".",
"filename",
"in",
"self",
".",
"STDIN_NAMES",
":",
"self",
".",
"filename",
"=",
"'stdin'",
"self",
".",
"source",
"=",
"pycodestyle",
".",
"stdin_get_value",
"(",
")",
"else",
":",
"with",
... | Load the source for the specified file. | [
"Load",
"the",
"source",
"for",
"the",
"specified",
"file",
"."
] | train | https://github.com/tylertrussell/flake8-docstrings-catnado/blob/76a9e202a93c8dfb11994c95911487b3722d75c9/flake8_docstrings.py#L114-L121 |
casebeer/factual | factual/common/requests.py | Request.join_params | def join_params(self, params, suppress_null=True):
'''
Custom alternative to urllib.urlencode that keeps URL length
down by not escaping certain special characters that Factual
can tolerate unescaped. This is especially useful for the
JSON special chars {}[],:.
The full list of usually-escaped-but-ok-fo... | python | def join_params(self, params, suppress_null=True):
'''
Custom alternative to urllib.urlencode that keeps URL length
down by not escaping certain special characters that Factual
can tolerate unescaped. This is especially useful for the
JSON special chars {}[],:.
The full list of usually-escaped-but-ok-fo... | [
"def",
"join_params",
"(",
"self",
",",
"params",
",",
"suppress_null",
"=",
"True",
")",
":",
"# ensure all params and values are properly urlencoded",
"# since we may have numbers, etc. here, cast to unicode and encode back to utf-8",
"return",
"\"&\"",
".",
"join",
"(",
"[",... | Custom alternative to urllib.urlencode that keeps URL length
down by not escaping certain special characters that Factual
can tolerate unescaped. This is especially useful for the
JSON special chars {}[],:.
The full list of usually-escaped-but-ok-for-factual characters is:
/ { } ' $ : , [ ]
The API... | [
"Custom",
"alternative",
"to",
"urllib",
".",
"urlencode",
"that",
"keeps",
"URL",
"length",
"down",
"by",
"not",
"escaping",
"certain",
"special",
"characters",
"that",
"Factual",
"can",
"tolerate",
"unescaped",
".",
"This",
"is",
"especially",
"useful",
"for",... | train | https://github.com/casebeer/factual/blob/f2795a8c9fd447c5d62887ae0f960481ce13be84/factual/common/requests.py#L43-L71 |
GMadorell/abris | abris_transform/abris.py | Abris.prepare | def prepare(self, data_source):
"""
Called with the training data.
@param data_source: Either a pandas.DataFrame or a file-like object.
"""
dataframe = self.__get_dataframe(data_source, use_target=True)
self.__config.get_data_model().set_features_types_from_dataframe(data... | python | def prepare(self, data_source):
"""
Called with the training data.
@param data_source: Either a pandas.DataFrame or a file-like object.
"""
dataframe = self.__get_dataframe(data_source, use_target=True)
self.__config.get_data_model().set_features_types_from_dataframe(data... | [
"def",
"prepare",
"(",
"self",
",",
"data_source",
")",
":",
"dataframe",
"=",
"self",
".",
"__get_dataframe",
"(",
"data_source",
",",
"use_target",
"=",
"True",
")",
"self",
".",
"__config",
".",
"get_data_model",
"(",
")",
".",
"set_features_types_from_data... | Called with the training data.
@param data_source: Either a pandas.DataFrame or a file-like object. | [
"Called",
"with",
"the",
"training",
"data",
"."
] | train | https://github.com/GMadorell/abris/blob/0d8ab7ec506835a45fae6935d129f5d7e6937bb2/abris_transform/abris.py#L22-L30 |
GMadorell/abris | abris_transform/abris.py | Abris.apply | def apply(self, data_source):
"""
Called with the predict data (new information).
@param data_source: Either a pandas.DataFrame or a file-like object.
"""
dataframe = self.__get_dataframe(data_source, use_target=False)
dataframe = self.__cleaner.apply(dataframe)
d... | python | def apply(self, data_source):
"""
Called with the predict data (new information).
@param data_source: Either a pandas.DataFrame or a file-like object.
"""
dataframe = self.__get_dataframe(data_source, use_target=False)
dataframe = self.__cleaner.apply(dataframe)
d... | [
"def",
"apply",
"(",
"self",
",",
"data_source",
")",
":",
"dataframe",
"=",
"self",
".",
"__get_dataframe",
"(",
"data_source",
",",
"use_target",
"=",
"False",
")",
"dataframe",
"=",
"self",
".",
"__cleaner",
".",
"apply",
"(",
"dataframe",
")",
"datafra... | Called with the predict data (new information).
@param data_source: Either a pandas.DataFrame or a file-like object. | [
"Called",
"with",
"the",
"predict",
"data",
"(",
"new",
"information",
")",
"."
] | train | https://github.com/GMadorell/abris/blob/0d8ab7ec506835a45fae6935d129f5d7e6937bb2/abris_transform/abris.py#L32-L40 |
phenomecentre/isaExplorer | isaExplorer/isaExplorer.py | exploreISA | def exploreISA(pathToISATABFile, verbose=True):
"""
This function loops through the ISATAB file and lists its Studies and their associated Assays.
:param pathToISATABFile: The path to the ISATAB file.
:type xpathToISATABFile: str
:param verbose: Whether (or not) to print out details of Studies and A... | python | def exploreISA(pathToISATABFile, verbose=True):
"""
This function loops through the ISATAB file and lists its Studies and their associated Assays.
:param pathToISATABFile: The path to the ISATAB file.
:type xpathToISATABFile: str
:param verbose: Whether (or not) to print out details of Studies and A... | [
"def",
"exploreISA",
"(",
"pathToISATABFile",
",",
"verbose",
"=",
"True",
")",
":",
"try",
":",
"isa_tab_record",
"=",
"isatab",
".",
"load",
"(",
"pathToISATABFile",
",",
"skip_load_tables",
"=",
"True",
")",
"if",
"verbose",
":",
"print",
"(",
"'In this I... | This function loops through the ISATAB file and lists its Studies and their associated Assays.
:param pathToISATABFile: The path to the ISATAB file.
:type xpathToISATABFile: str
:param verbose: Whether (or not) to print out details of Studies and Assays (default: True)
:type verbose: boolean
:raise ... | [
"This",
"function",
"loops",
"through",
"the",
"ISATAB",
"file",
"and",
"lists",
"its",
"Studies",
"and",
"their",
"associated",
"Assays",
".",
":",
"param",
"pathToISATABFile",
":",
"The",
"path",
"to",
"the",
"ISATAB",
"file",
".",
":",
"type",
"xpathToISA... | train | https://github.com/phenomecentre/isaExplorer/blob/2fc817d53b6acba46918a0db8dd2f72e5e1d785e/isaExplorer/isaExplorer.py#L7-L28 |
phenomecentre/isaExplorer | isaExplorer/isaExplorer.py | getISAAssay | def getISAAssay(assayNum, studyNum, pathToISATABFile):
"""
This function returns an Assay object given the assay and study numbers in an ISA file
Typically, you should use the exploreISA function to check the contents
of the ISA file and retrieve the assay and study numbers you are interested in!
:p... | python | def getISAAssay(assayNum, studyNum, pathToISATABFile):
"""
This function returns an Assay object given the assay and study numbers in an ISA file
Typically, you should use the exploreISA function to check the contents
of the ISA file and retrieve the assay and study numbers you are interested in!
:p... | [
"def",
"getISAAssay",
"(",
"assayNum",
",",
"studyNum",
",",
"pathToISATABFile",
")",
":",
"from",
"isatools",
"import",
"isatab",
"import",
"copy",
"try",
":",
"isa",
"=",
"isatab",
".",
"load",
"(",
"pathToISATABFile",
",",
"skip_load_tables",
"=",
"True",
... | This function returns an Assay object given the assay and study numbers in an ISA file
Typically, you should use the exploreISA function to check the contents
of the ISA file and retrieve the assay and study numbers you are interested in!
:param assayNum: The Assay number (notice it's not zero-based index).... | [
"This",
"function",
"returns",
"an",
"Assay",
"object",
"given",
"the",
"assay",
"and",
"study",
"numbers",
"in",
"an",
"ISA",
"file",
"Typically",
"you",
"should",
"use",
"the",
"exploreISA",
"function",
"to",
"check",
"the",
"contents",
"of",
"the",
"ISA",... | train | https://github.com/phenomecentre/isaExplorer/blob/2fc817d53b6acba46918a0db8dd2f72e5e1d785e/isaExplorer/isaExplorer.py#L30-L50 |
phenomecentre/isaExplorer | isaExplorer/isaExplorer.py | getISAStudy | def getISAStudy(studyNum, pathToISATABFile, noAssays = True):
"""
This function returns a Study object given the study number in an ISA file
Typically, you should use the exploreISA function to check the contents
of the ISA file and retrieve the study number you are interested in!
:param studyNum: T... | python | def getISAStudy(studyNum, pathToISATABFile, noAssays = True):
"""
This function returns a Study object given the study number in an ISA file
Typically, you should use the exploreISA function to check the contents
of the ISA file and retrieve the study number you are interested in!
:param studyNum: T... | [
"def",
"getISAStudy",
"(",
"studyNum",
",",
"pathToISATABFile",
",",
"noAssays",
"=",
"True",
")",
":",
"from",
"isatools",
"import",
"isatab",
"import",
"copy",
"try",
":",
"isa",
"=",
"isatab",
".",
"load",
"(",
"pathToISATABFile",
",",
"skip_load_tables",
... | This function returns a Study object given the study number in an ISA file
Typically, you should use the exploreISA function to check the contents
of the ISA file and retrieve the study number you are interested in!
:param studyNum: The Study number (notice it's not zero-based index).
:type studyNum: in... | [
"This",
"function",
"returns",
"a",
"Study",
"object",
"given",
"the",
"study",
"number",
"in",
"an",
"ISA",
"file",
"Typically",
"you",
"should",
"use",
"the",
"exploreISA",
"function",
"to",
"check",
"the",
"contents",
"of",
"the",
"ISA",
"file",
"and",
... | train | https://github.com/phenomecentre/isaExplorer/blob/2fc817d53b6acba46918a0db8dd2f72e5e1d785e/isaExplorer/isaExplorer.py#L52-L74 |
phenomecentre/isaExplorer | isaExplorer/isaExplorer.py | appendStudytoISA | def appendStudytoISA(study, pathToISATABFile):
"""
This function appends a Study object to an ISA file
Typically, you should use the exploreISA function to check the contents
of the ISA file!
:param study: The Study object.
:type study: ISA Study object
:param pathToISATABFile: The path to t... | python | def appendStudytoISA(study, pathToISATABFile):
"""
This function appends a Study object to an ISA file
Typically, you should use the exploreISA function to check the contents
of the ISA file!
:param study: The Study object.
:type study: ISA Study object
:param pathToISATABFile: The path to t... | [
"def",
"appendStudytoISA",
"(",
"study",
",",
"pathToISATABFile",
")",
":",
"from",
"isatools",
"import",
"isatab",
"import",
"os",
"try",
":",
"isa",
"=",
"isatab",
".",
"load",
"(",
"pathToISATABFile",
",",
"skip_load_tables",
"=",
"True",
")",
"lngth",
"=... | This function appends a Study object to an ISA file
Typically, you should use the exploreISA function to check the contents
of the ISA file!
:param study: The Study object.
:type study: ISA Study object
:param pathToISATABFile: The path to the ISATAB file
:type pathToISATABFile: string
:rais... | [
"This",
"function",
"appends",
"a",
"Study",
"object",
"to",
"an",
"ISA",
"file",
"Typically",
"you",
"should",
"use",
"the",
"exploreISA",
"function",
"to",
"check",
"the",
"contents",
"of",
"the",
"ISA",
"file!",
":",
"param",
"study",
":",
"The",
"Study... | train | https://github.com/phenomecentre/isaExplorer/blob/2fc817d53b6acba46918a0db8dd2f72e5e1d785e/isaExplorer/isaExplorer.py#L76-L101 |
phenomecentre/isaExplorer | isaExplorer/isaExplorer.py | appendAssayToStudy | def appendAssayToStudy(assay, studyNum, pathToISATABFile):
"""
This function appends an Assay object to a study in an ISA file
Typically, you should use the exploreISA function to check the contents
of the ISA file and retrieve the assay and study number you are interested in!
:param assay: The Assa... | python | def appendAssayToStudy(assay, studyNum, pathToISATABFile):
"""
This function appends an Assay object to a study in an ISA file
Typically, you should use the exploreISA function to check the contents
of the ISA file and retrieve the assay and study number you are interested in!
:param assay: The Assa... | [
"def",
"appendAssayToStudy",
"(",
"assay",
",",
"studyNum",
",",
"pathToISATABFile",
")",
":",
"from",
"isatools",
"import",
"isatab",
"try",
":",
"isa",
"=",
"isatab",
".",
"load",
"(",
"pathToISATABFile",
",",
"skip_load_tables",
"=",
"True",
")",
"std",
"... | This function appends an Assay object to a study in an ISA file
Typically, you should use the exploreISA function to check the contents
of the ISA file and retrieve the assay and study number you are interested in!
:param assay: The Assay
:type assay: ISA Assay object
:param studyNum: The Study numb... | [
"This",
"function",
"appends",
"an",
"Assay",
"object",
"to",
"a",
"study",
"in",
"an",
"ISA",
"file",
"Typically",
"you",
"should",
"use",
"the",
"exploreISA",
"function",
"to",
"check",
"the",
"contents",
"of",
"the",
"ISA",
"file",
"and",
"retrieve",
"t... | train | https://github.com/phenomecentre/isaExplorer/blob/2fc817d53b6acba46918a0db8dd2f72e5e1d785e/isaExplorer/isaExplorer.py#L103-L130 |
phenomecentre/isaExplorer | isaExplorer/isaExplorer.py | dropAssayFromStudy | def dropAssayFromStudy(assayNum, studyNum, pathToISATABFile):
"""
This function removes an Assay from a study in an ISA file
Typically, you should use the exploreISA function to check the contents
of the ISA file and retrieve the assay and study numbers you are interested in!
:param assayNum: The As... | python | def dropAssayFromStudy(assayNum, studyNum, pathToISATABFile):
"""
This function removes an Assay from a study in an ISA file
Typically, you should use the exploreISA function to check the contents
of the ISA file and retrieve the assay and study numbers you are interested in!
:param assayNum: The As... | [
"def",
"dropAssayFromStudy",
"(",
"assayNum",
",",
"studyNum",
",",
"pathToISATABFile",
")",
":",
"from",
"isatools",
"import",
"isatab",
"import",
"os",
"try",
":",
"isa",
"=",
"isatab",
".",
"load",
"(",
"pathToISATABFile",
",",
"skip_load_tables",
"=",
"Tru... | This function removes an Assay from a study in an ISA file
Typically, you should use the exploreISA function to check the contents
of the ISA file and retrieve the assay and study numbers you are interested in!
:param assayNum: The Assay number (notice it's 1-based index).
:type assayNum: int
:param... | [
"This",
"function",
"removes",
"an",
"Assay",
"from",
"a",
"study",
"in",
"an",
"ISA",
"file",
"Typically",
"you",
"should",
"use",
"the",
"exploreISA",
"function",
"to",
"check",
"the",
"contents",
"of",
"the",
"ISA",
"file",
"and",
"retrieve",
"the",
"as... | train | https://github.com/phenomecentre/isaExplorer/blob/2fc817d53b6acba46918a0db8dd2f72e5e1d785e/isaExplorer/isaExplorer.py#L132-L156 |
phenomecentre/isaExplorer | isaExplorer/isaExplorer.py | dropStudyFromISA | def dropStudyFromISA(studyNum, pathToISATABFile):
"""
This function removes a study from an ISA file
Typically, you should use the exploreISA function to check the contents
of the ISA file and retrieve the study number you are interested in!
Warning: this function deletes the given study and all its... | python | def dropStudyFromISA(studyNum, pathToISATABFile):
"""
This function removes a study from an ISA file
Typically, you should use the exploreISA function to check the contents
of the ISA file and retrieve the study number you are interested in!
Warning: this function deletes the given study and all its... | [
"def",
"dropStudyFromISA",
"(",
"studyNum",
",",
"pathToISATABFile",
")",
":",
"from",
"isatools",
"import",
"isatab",
"import",
"os",
"try",
":",
"isa",
"=",
"isatab",
".",
"load",
"(",
"pathToISATABFile",
",",
"skip_load_tables",
"=",
"True",
")",
"studies",... | This function removes a study from an ISA file
Typically, you should use the exploreISA function to check the contents
of the ISA file and retrieve the study number you are interested in!
Warning: this function deletes the given study and all its associated assays
:param studyNum: The Study number (noti... | [
"This",
"function",
"removes",
"a",
"study",
"from",
"an",
"ISA",
"file",
"Typically",
"you",
"should",
"use",
"the",
"exploreISA",
"function",
"to",
"check",
"the",
"contents",
"of",
"the",
"ISA",
"file",
"and",
"retrieve",
"the",
"study",
"number",
"you",
... | train | https://github.com/phenomecentre/isaExplorer/blob/2fc817d53b6acba46918a0db8dd2f72e5e1d785e/isaExplorer/isaExplorer.py#L158-L183 |
jlesquembre/jlle | jlle/releaser/utils.py | ask | def ask(question, default=True, exact=False):
"""Ask the question in y/n form and return True/False.
If you don't want a default 'yes', set default to None (or to False if you
want a default 'no').
With exact=True, we want to get a literal 'yes' or 'no', at least
when it does not match the default... | python | def ask(question, default=True, exact=False):
"""Ask the question in y/n form and return True/False.
If you don't want a default 'yes', set default to None (or to False if you
want a default 'no').
With exact=True, we want to get a literal 'yes' or 'no', at least
when it does not match the default... | [
"def",
"ask",
"(",
"question",
",",
"default",
"=",
"True",
",",
"exact",
"=",
"False",
")",
":",
"if",
"AUTO_RESPONSE",
":",
"if",
"default",
"is",
"None",
":",
"msg",
"=",
"(",
"\"The question '%s' requires a manual answer, but \"",
"+",
"\"we're running in --... | Ask the question in y/n form and return True/False.
If you don't want a default 'yes', set default to None (or to False if you
want a default 'no').
With exact=True, we want to get a literal 'yes' or 'no', at least
when it does not match the default. | [
"Ask",
"the",
"question",
"in",
"y",
"/",
"n",
"form",
"and",
"return",
"True",
"/",
"False",
"."
] | train | https://github.com/jlesquembre/jlle/blob/3645d8f203708355853ef911f4b887ae4d794826/jlle/releaser/utils.py#L41-L87 |
jlesquembre/jlle | jlle/releaser/utils.py | system | def system(command, answer=''):
"""commands.getoutput() replacement that also works on windows"""
p = subprocess.Popen(command,
shell=True,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
... | python | def system(command, answer=''):
"""commands.getoutput() replacement that also works on windows"""
p = subprocess.Popen(command,
shell=True,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
... | [
"def",
"system",
"(",
"command",
",",
"answer",
"=",
"''",
")",
":",
"p",
"=",
"subprocess",
".",
"Popen",
"(",
"command",
",",
"shell",
"=",
"True",
",",
"stdin",
"=",
"subprocess",
".",
"PIPE",
",",
"stdout",
"=",
"subprocess",
".",
"PIPE",
",",
... | commands.getoutput() replacement that also works on windows | [
"commands",
".",
"getoutput",
"()",
"replacement",
"that",
"also",
"works",
"on",
"windows"
] | train | https://github.com/jlesquembre/jlle/blob/3645d8f203708355853ef911f4b887ae4d794826/jlle/releaser/utils.py#L90-L105 |
jlesquembre/jlle | jlle/releaser/utils.py | fix_rst_heading | def fix_rst_heading(heading, below):
"""If the 'below' line looks like a reST line, give it the correct length.
This allows for different characters being used as header lines.
"""
if len(below) == 0:
return below
first = below[0]
if first not in '-=`~':
return below
if not ... | python | def fix_rst_heading(heading, below):
"""If the 'below' line looks like a reST line, give it the correct length.
This allows for different characters being used as header lines.
"""
if len(below) == 0:
return below
first = below[0]
if first not in '-=`~':
return below
if not ... | [
"def",
"fix_rst_heading",
"(",
"heading",
",",
"below",
")",
":",
"if",
"len",
"(",
"below",
")",
"==",
"0",
":",
"return",
"below",
"first",
"=",
"below",
"[",
"0",
"]",
"if",
"first",
"not",
"in",
"'-=`~'",
":",
"return",
"below",
"if",
"not",
"l... | If the 'below' line looks like a reST line, give it the correct length.
This allows for different characters being used as header lines. | [
"If",
"the",
"below",
"line",
"looks",
"like",
"a",
"reST",
"line",
"give",
"it",
"the",
"correct",
"length",
"."
] | train | https://github.com/jlesquembre/jlle/blob/3645d8f203708355853ef911f4b887ae4d794826/jlle/releaser/utils.py#L108-L123 |
jlesquembre/jlle | jlle/releaser/utils.py | extract_headings_from_history | def extract_headings_from_history(history_lines):
"""Return list of dicts with version-like headers.
We check for patterns like '2.10 (unreleased)', so with either
'unreleased' or a date between parenthesis as that's the format we're
using. Just fix up your first heading and you should be set.
As ... | python | def extract_headings_from_history(history_lines):
"""Return list of dicts with version-like headers.
We check for patterns like '2.10 (unreleased)', so with either
'unreleased' or a date between parenthesis as that's the format we're
using. Just fix up your first heading and you should be set.
As ... | [
"def",
"extract_headings_from_history",
"(",
"history_lines",
")",
":",
"pattern",
"=",
"re",
".",
"compile",
"(",
"r\"\"\"\n (?P<version>.+) # Version string\n \\( # Opening (\n (?P<date>.+) # Date\n \\) # Closing )\n \\W*$ # Possi... | Return list of dicts with version-like headers.
We check for patterns like '2.10 (unreleased)', so with either
'unreleased' or a date between parenthesis as that's the format we're
using. Just fix up your first heading and you should be set.
As an alternative, we support an alternative format used by ... | [
"Return",
"list",
"of",
"dicts",
"with",
"version",
"-",
"like",
"headers",
"."
] | train | https://github.com/jlesquembre/jlle/blob/3645d8f203708355853ef911f4b887ae4d794826/jlle/releaser/utils.py#L126-L171 |
jlesquembre/jlle | jlle/releaser/utils.py | extract_headings_from_history_modified | def extract_headings_from_history_modified(changelog):
"""Return list of dicts with version-like headers.
We check for patterns like '2.10 (unreleased)', so with either
'unreleased' or a date between parenthesis as that's the format we're
using. Just fix up your first heading and you should be set.
... | python | def extract_headings_from_history_modified(changelog):
"""Return list of dicts with version-like headers.
We check for patterns like '2.10 (unreleased)', so with either
'unreleased' or a date between parenthesis as that's the format we're
using. Just fix up your first heading and you should be set.
... | [
"def",
"extract_headings_from_history_modified",
"(",
"changelog",
")",
":",
"pattern",
"=",
"re",
".",
"compile",
"(",
"r\"\"\"\n (?P<version>.+) # Version string\n \\( # Opening (\n (?P<date>.+) # Date\n \\) # Closing )\n \\W*$ # ... | Return list of dicts with version-like headers.
We check for patterns like '2.10 (unreleased)', so with either
'unreleased' or a date between parenthesis as that's the format we're
using. Just fix up your first heading and you should be set.
As an alternative, we support an alternative format used by ... | [
"Return",
"list",
"of",
"dicts",
"with",
"version",
"-",
"like",
"headers",
"."
] | train | https://github.com/jlesquembre/jlle/blob/3645d8f203708355853ef911f4b887ae4d794826/jlle/releaser/utils.py#L174-L220 |
jlesquembre/jlle | jlle/releaser/utils.py | sanity_check | def sanity_check(vcs):
"""Do sanity check before making changes
Check that we are not on a tag and/or do not have local changes.
Returns True when all is fine.
"""
if not vcs.is_clean_checkout():
q = ("This is NOT a clean checkout. You are on a tag or you have "
"local changes... | python | def sanity_check(vcs):
"""Do sanity check before making changes
Check that we are not on a tag and/or do not have local changes.
Returns True when all is fine.
"""
if not vcs.is_clean_checkout():
q = ("This is NOT a clean checkout. You are on a tag or you have "
"local changes... | [
"def",
"sanity_check",
"(",
"vcs",
")",
":",
"if",
"not",
"vcs",
".",
"is_clean_checkout",
"(",
")",
":",
"q",
"=",
"(",
"\"This is NOT a clean checkout. You are on a tag or you have \"",
"\"local changes.\\n\"",
"\"Are you sure you want to continue?\"",
")",
"if",
"not",... | Do sanity check before making changes
Check that we are not on a tag and/or do not have local changes.
Returns True when all is fine. | [
"Do",
"sanity",
"check",
"before",
"making",
"changes"
] | train | https://github.com/jlesquembre/jlle/blob/3645d8f203708355853ef911f4b887ae4d794826/jlle/releaser/utils.py#L223-L235 |
jlesquembre/jlle | jlle/releaser/utils.py | check_recommended_files | def check_recommended_files(data, vcs):
"""Do check for recommended files.
Returns True when all is fine.
"""
main_files = os.listdir(data['workingdir'])
if not 'setup.py' in main_files and not 'setup.cfg' in main_files:
# Not a python package. We have no recommendations.
return Tr... | python | def check_recommended_files(data, vcs):
"""Do check for recommended files.
Returns True when all is fine.
"""
main_files = os.listdir(data['workingdir'])
if not 'setup.py' in main_files and not 'setup.cfg' in main_files:
# Not a python package. We have no recommendations.
return Tr... | [
"def",
"check_recommended_files",
"(",
"data",
",",
"vcs",
")",
":",
"main_files",
"=",
"os",
".",
"listdir",
"(",
"data",
"[",
"'workingdir'",
"]",
")",
"if",
"not",
"'setup.py'",
"in",
"main_files",
"and",
"not",
"'setup.cfg'",
"in",
"main_files",
":",
"... | Do check for recommended files.
Returns True when all is fine. | [
"Do",
"check",
"for",
"recommended",
"files",
"."
] | train | https://github.com/jlesquembre/jlle/blob/3645d8f203708355853ef911f4b887ae4d794826/jlle/releaser/utils.py#L238-L270 |
jlesquembre/jlle | jlle/releaser/utils.py | cleanup_version | def cleanup_version(version):
"""Check if the version looks like a development version."""
for w in WRONG_IN_VERSION:
if version.find(w) != -1:
logger.debug("Version indicates development: %s.", version)
version = version[:version.find(w)].strip()
logger.debug("Removi... | python | def cleanup_version(version):
"""Check if the version looks like a development version."""
for w in WRONG_IN_VERSION:
if version.find(w) != -1:
logger.debug("Version indicates development: %s.", version)
version = version[:version.find(w)].strip()
logger.debug("Removi... | [
"def",
"cleanup_version",
"(",
"version",
")",
":",
"for",
"w",
"in",
"WRONG_IN_VERSION",
":",
"if",
"version",
".",
"find",
"(",
"w",
")",
"!=",
"-",
"1",
":",
"logger",
".",
"debug",
"(",
"\"Version indicates development: %s.\"",
",",
"version",
")",
"ve... | Check if the version looks like a development version. | [
"Check",
"if",
"the",
"version",
"looks",
"like",
"a",
"development",
"version",
"."
] | train | https://github.com/jlesquembre/jlle/blob/3645d8f203708355853ef911f4b887ae4d794826/jlle/releaser/utils.py#L284-L292 |
jlesquembre/jlle | jlle/releaser/utils.py | show_first_and_last_lines | def show_first_and_last_lines(result):
"""Just print the first and last five lines of (pypi) output"""
lines = [line for line in result.split('\n')]
if len(lines) < 11:
for line in lines:
print(line)
return
print('Showing first few lines...')
for line in lines[:5]:
... | python | def show_first_and_last_lines(result):
"""Just print the first and last five lines of (pypi) output"""
lines = [line for line in result.split('\n')]
if len(lines) < 11:
for line in lines:
print(line)
return
print('Showing first few lines...')
for line in lines[:5]:
... | [
"def",
"show_first_and_last_lines",
"(",
"result",
")",
":",
"lines",
"=",
"[",
"line",
"for",
"line",
"in",
"result",
".",
"split",
"(",
"'\\n'",
")",
"]",
"if",
"len",
"(",
"lines",
")",
"<",
"11",
":",
"for",
"line",
"in",
"lines",
":",
"print",
... | Just print the first and last five lines of (pypi) output | [
"Just",
"print",
"the",
"first",
"and",
"last",
"five",
"lines",
"of",
"(",
"pypi",
")",
"output"
] | train | https://github.com/jlesquembre/jlle/blob/3645d8f203708355853ef911f4b887ae4d794826/jlle/releaser/utils.py#L295-L308 |
JCharante/padr | padr/padr.py | pad | def pad(lines, delim):
"""
Right Pads text split by their delim.
:param lines:
:param delim:
:return:
"""
"""
Populates text into chunks. If the delim was & then
['12 & 344', '344 & 8', '8 & 88'] would be stored in chunks as
[['12', '344', '8'], ['344', '8', '88']]
"""
chunks = []
for i in range(len(lin... | python | def pad(lines, delim):
"""
Right Pads text split by their delim.
:param lines:
:param delim:
:return:
"""
"""
Populates text into chunks. If the delim was & then
['12 & 344', '344 & 8', '8 & 88'] would be stored in chunks as
[['12', '344', '8'], ['344', '8', '88']]
"""
chunks = []
for i in range(len(lin... | [
"def",
"pad",
"(",
"lines",
",",
"delim",
")",
":",
"\"\"\"\n\tPopulates text into chunks. If the delim was & then\n\t['12 & 344', '344 & 8', '8 & 88'] would be stored in chunks as\n\t[['12', '344', '8'], ['344', '8', '88']]\n\t\"\"\"",
"chunks",
"=",
"[",
"]",
"for",
"i",
"in",
"ran... | Right Pads text split by their delim.
:param lines:
:param delim:
:return: | [
"Right",
"Pads",
"text",
"split",
"by",
"their",
"delim",
".",
":",
"param",
"lines",
":",
":",
"param",
"delim",
":",
":",
"return",
":"
] | train | https://github.com/JCharante/padr/blob/1deb66263fb92919a4025ef49e504cb33af05662/padr/padr.py#L1-L41 |
JNRowe/jnrbase | jnrbase/pager.py | pager | def pager(__text: str, *, pager: Optional[str] = 'less'):
"""Pass output through pager.
See :manpage:`less(1)`, if you wish to configure the default pager. For
example, you may wish to check ``FRSX`` options.
Args:
__text: Text to page
pager: Pager to use
"""
if pager:
... | python | def pager(__text: str, *, pager: Optional[str] = 'less'):
"""Pass output through pager.
See :manpage:`less(1)`, if you wish to configure the default pager. For
example, you may wish to check ``FRSX`` options.
Args:
__text: Text to page
pager: Pager to use
"""
if pager:
... | [
"def",
"pager",
"(",
"__text",
":",
"str",
",",
"*",
",",
"pager",
":",
"Optional",
"[",
"str",
"]",
"=",
"'less'",
")",
":",
"if",
"pager",
":",
"run",
"(",
"[",
"pager",
",",
"]",
",",
"input",
"=",
"__text",
".",
"encode",
"(",
")",
")",
"... | Pass output through pager.
See :manpage:`less(1)`, if you wish to configure the default pager. For
example, you may wish to check ``FRSX`` options.
Args:
__text: Text to page
pager: Pager to use | [
"Pass",
"output",
"through",
"pager",
"."
] | train | https://github.com/JNRowe/jnrbase/blob/ae505ef69a9feb739b5f4e62c5a8e6533104d3ea/jnrbase/pager.py#L26-L39 |
mayfield/shellish | shellish/rendering/md.py | mdprint | def mdprint(*values, plain=None, **options):
""" Convert HTML to VTML and then print it.
Follows same semantics as vtmlprint. """
print(*[mdrender(x, plain=plain) for x in values], **options) | python | def mdprint(*values, plain=None, **options):
""" Convert HTML to VTML and then print it.
Follows same semantics as vtmlprint. """
print(*[mdrender(x, plain=plain) for x in values], **options) | [
"def",
"mdprint",
"(",
"*",
"values",
",",
"plain",
"=",
"None",
",",
"*",
"*",
"options",
")",
":",
"print",
"(",
"*",
"[",
"mdrender",
"(",
"x",
",",
"plain",
"=",
"plain",
")",
"for",
"x",
"in",
"values",
"]",
",",
"*",
"*",
"options",
")"
] | Convert HTML to VTML and then print it.
Follows same semantics as vtmlprint. | [
"Convert",
"HTML",
"to",
"VTML",
"and",
"then",
"print",
"it",
".",
"Follows",
"same",
"semantics",
"as",
"vtmlprint",
"."
] | train | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/rendering/md.py#L22-L25 |
zeromake/aiko | aiko/application.py | Application.listen | def listen(self, **kwargs: Any) -> Server:
"""
bind host, port or sock
"""
loop = cast(asyncio.AbstractEventLoop, self._loop)
return (yield from loop.create_server(
lambda: self._protocol(
loop=loop,
handle=self._handle,
... | python | def listen(self, **kwargs: Any) -> Server:
"""
bind host, port or sock
"""
loop = cast(asyncio.AbstractEventLoop, self._loop)
return (yield from loop.create_server(
lambda: self._protocol(
loop=loop,
handle=self._handle,
... | [
"def",
"listen",
"(",
"self",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"Server",
":",
"loop",
"=",
"cast",
"(",
"asyncio",
".",
"AbstractEventLoop",
",",
"self",
".",
"_loop",
")",
"return",
"(",
"yield",
"from",
"loop",
".",
"create_server",
... | bind host, port or sock | [
"bind",
"host",
"port",
"or",
"sock"
] | train | https://github.com/zeromake/aiko/blob/53b246fa88652466a9e38ac3d1a99a6198195b0f/aiko/application.py#L128-L141 |
zeromake/aiko | aiko/application.py | Application.run | def run(self, host: str = "0.0.0.0", port: int = 5000) -> None:
"""
debug run
:param host: the hostname to listen on, default is ``'0.0.0.0'``
:param port: the port of the server, default id ``5000``
"""
loop = cast(asyncio.AbstractEventLoop, self._loop)
listen = ... | python | def run(self, host: str = "0.0.0.0", port: int = 5000) -> None:
"""
debug run
:param host: the hostname to listen on, default is ``'0.0.0.0'``
:param port: the port of the server, default id ``5000``
"""
loop = cast(asyncio.AbstractEventLoop, self._loop)
listen = ... | [
"def",
"run",
"(",
"self",
",",
"host",
":",
"str",
"=",
"\"0.0.0.0\"",
",",
"port",
":",
"int",
"=",
"5000",
")",
"->",
"None",
":",
"loop",
"=",
"cast",
"(",
"asyncio",
".",
"AbstractEventLoop",
",",
"self",
".",
"_loop",
")",
"listen",
"=",
"sel... | debug run
:param host: the hostname to listen on, default is ``'0.0.0.0'``
:param port: the port of the server, default id ``5000`` | [
"debug",
"run",
":",
"param",
"host",
":",
"the",
"hostname",
"to",
"listen",
"on",
"default",
"is",
"0",
".",
"0",
".",
"0",
".",
"0",
":",
"param",
"port",
":",
"the",
"port",
"of",
"the",
"server",
"default",
"id",
"5000"
] | train | https://github.com/zeromake/aiko/blob/53b246fa88652466a9e38ac3d1a99a6198195b0f/aiko/application.py#L143-L162 |
zeromake/aiko | aiko/application.py | Application.create_server | def create_server(
self,
loop: asyncio.AbstractEventLoop,
sock: Any,
ssl: SSLContext,
) -> TypeGenerator[Any, None, Server]:
"""
提供给 Worker 使用的调用
"""
if loop is not None and self._loop is not loop:
self._loop = loop
... | python | def create_server(
self,
loop: asyncio.AbstractEventLoop,
sock: Any,
ssl: SSLContext,
) -> TypeGenerator[Any, None, Server]:
"""
提供给 Worker 使用的调用
"""
if loop is not None and self._loop is not loop:
self._loop = loop
... | [
"def",
"create_server",
"(",
"self",
",",
"loop",
":",
"asyncio",
".",
"AbstractEventLoop",
",",
"sock",
":",
"Any",
",",
"ssl",
":",
"SSLContext",
",",
")",
"->",
"TypeGenerator",
"[",
"Any",
",",
"None",
",",
"Server",
"]",
":",
"if",
"loop",
"is",
... | 提供给 Worker 使用的调用 | [
"提供给",
"Worker",
"使用的调用"
] | train | https://github.com/zeromake/aiko/blob/53b246fa88652466a9e38ac3d1a99a6198195b0f/aiko/application.py#L165-L179 |
zeromake/aiko | aiko/application.py | Application._next_middleware | def _next_middleware(
self,
middlewares: Iterator[MIDDLEWARE_TYPE],
ctx: Context,
) -> NEXT_CALL_TYPE:
"""
生成 next_call 的调用
使用迭代器,这个方法每调用一次都会指向下一个中间件。
"""
@asyncio.coroutine
def next_call() -> NEXT_CALL_RES_TYPE:
"""
... | python | def _next_middleware(
self,
middlewares: Iterator[MIDDLEWARE_TYPE],
ctx: Context,
) -> NEXT_CALL_TYPE:
"""
生成 next_call 的调用
使用迭代器,这个方法每调用一次都会指向下一个中间件。
"""
@asyncio.coroutine
def next_call() -> NEXT_CALL_RES_TYPE:
"""
... | [
"def",
"_next_middleware",
"(",
"self",
",",
"middlewares",
":",
"Iterator",
"[",
"MIDDLEWARE_TYPE",
"]",
",",
"ctx",
":",
"Context",
",",
")",
"->",
"NEXT_CALL_TYPE",
":",
"@",
"asyncio",
".",
"coroutine",
"def",
"next_call",
"(",
")",
"->",
"NEXT_CALL_RES_... | 生成 next_call 的调用
使用迭代器,这个方法每调用一次都会指向下一个中间件。 | [
"生成",
"next_call",
"的调用",
"使用迭代器,这个方法每调用一次都会指向下一个中间件。"
] | train | https://github.com/zeromake/aiko/blob/53b246fa88652466a9e38ac3d1a99a6198195b0f/aiko/application.py#L181-L196 |
zeromake/aiko | aiko/application.py | Application._middleware_call | def _middleware_call(
self,
middlewares: Iterator[MIDDLEWARE_TYPE],
ctx: Context,
next_call: NEXT_CALL_TYPE,
) -> TypeGenerator[Any, None, None]:
"""
从迭代器中取出一个中间件,执行
"""
middleware = None
try:
middleware = next(middl... | python | def _middleware_call(
self,
middlewares: Iterator[MIDDLEWARE_TYPE],
ctx: Context,
next_call: NEXT_CALL_TYPE,
) -> TypeGenerator[Any, None, None]:
"""
从迭代器中取出一个中间件,执行
"""
middleware = None
try:
middleware = next(middl... | [
"def",
"_middleware_call",
"(",
"self",
",",
"middlewares",
":",
"Iterator",
"[",
"MIDDLEWARE_TYPE",
"]",
",",
"ctx",
":",
"Context",
",",
"next_call",
":",
"NEXT_CALL_TYPE",
",",
")",
"->",
"TypeGenerator",
"[",
"Any",
",",
"None",
",",
"None",
"]",
":",
... | 从迭代器中取出一个中间件,执行 | [
"从迭代器中取出一个中间件,执行"
] | train | https://github.com/zeromake/aiko/blob/53b246fa88652466a9e38ac3d1a99a6198195b0f/aiko/application.py#L199-L250 |
zeromake/aiko | aiko/application.py | Application._handle | def _handle(self, request: Request, response: Response) -> TypeGenerator[Any, None, None]:
"""
request 解析后的回调,调用中间件,并处理 headers, body 发送。
"""
# request.start_time = datetime.now().timestamp()
# 创建一个新的会话上下文
ctx = self._context(
cast(asyncio.AbstractEventLoop, s... | python | def _handle(self, request: Request, response: Response) -> TypeGenerator[Any, None, None]:
"""
request 解析后的回调,调用中间件,并处理 headers, body 发送。
"""
# request.start_time = datetime.now().timestamp()
# 创建一个新的会话上下文
ctx = self._context(
cast(asyncio.AbstractEventLoop, s... | [
"def",
"_handle",
"(",
"self",
",",
"request",
":",
"Request",
",",
"response",
":",
"Response",
")",
"->",
"TypeGenerator",
"[",
"Any",
",",
"None",
",",
"None",
"]",
":",
"# request.start_time = datetime.now().timestamp()",
"# 创建一个新的会话上下文",
"ctx",
"=",
"self",... | request 解析后的回调,调用中间件,并处理 headers, body 发送。 | [
"request",
"解析后的回调,调用中间件,并处理",
"headers",
"body",
"发送。"
] | train | https://github.com/zeromake/aiko/blob/53b246fa88652466a9e38ac3d1a99a6198195b0f/aiko/application.py#L253-L285 |
armstrong/armstrong.hatband | armstrong/hatband/views/search.py | GenericKeyFacetsMixin.generic_key_facets | def generic_key_facets(self, request):
"""Find all available facets/Models for VisualSearch"""
excluded_apps = Q(app_label__in=EXCLUDED_APPS_FROM_FACETS)
excluded_models = Q()
for app_label, model in EXCLUDED_MODELS_FROM_FACETS:
excluded_models = excluded_models | Q(app_labe... | python | def generic_key_facets(self, request):
"""Find all available facets/Models for VisualSearch"""
excluded_apps = Q(app_label__in=EXCLUDED_APPS_FROM_FACETS)
excluded_models = Q()
for app_label, model in EXCLUDED_MODELS_FROM_FACETS:
excluded_models = excluded_models | Q(app_labe... | [
"def",
"generic_key_facets",
"(",
"self",
",",
"request",
")",
":",
"excluded_apps",
"=",
"Q",
"(",
"app_label__in",
"=",
"EXCLUDED_APPS_FROM_FACETS",
")",
"excluded_models",
"=",
"Q",
"(",
")",
"for",
"app_label",
",",
"model",
"in",
"EXCLUDED_MODELS_FROM_FACETS"... | Find all available facets/Models for VisualSearch | [
"Find",
"all",
"available",
"facets",
"/",
"Models",
"for",
"VisualSearch"
] | train | https://github.com/armstrong/armstrong.hatband/blob/b34027c85a8ccfe2ee37aa9348d98e143d300082/armstrong/hatband/views/search.py#L49-L61 |
armstrong/armstrong.hatband | armstrong/hatband/views/search.py | ModelSearchBackfillMixin.generic_key_modelsearch | def generic_key_modelsearch(self, request, app_label, model_name):
"""
Find instances for the requested model and return them as JSON.
# TODO: add test coverage for this
We don't have to worry about invalid app_label/model_name parameters
because the URLs are pre-built with the ... | python | def generic_key_modelsearch(self, request, app_label, model_name):
"""
Find instances for the requested model and return them as JSON.
# TODO: add test coverage for this
We don't have to worry about invalid app_label/model_name parameters
because the URLs are pre-built with the ... | [
"def",
"generic_key_modelsearch",
"(",
"self",
",",
"request",
",",
"app_label",
",",
"model_name",
")",
":",
"content_type",
"=",
"ContentType",
".",
"objects",
".",
"get",
"(",
"app_label",
"=",
"app_label",
",",
"model",
"=",
"model_name",
")",
"model",
"... | Find instances for the requested model and return them as JSON.
# TODO: add test coverage for this
We don't have to worry about invalid app_label/model_name parameters
because the URLs are pre-built with the kwargs in `get_urls()`. | [
"Find",
"instances",
"for",
"the",
"requested",
"model",
"and",
"return",
"them",
"as",
"JSON",
".",
"#",
"TODO",
":",
"add",
"test",
"coverage",
"for",
"this"
] | train | https://github.com/armstrong/armstrong.hatband/blob/b34027c85a8ccfe2ee37aa9348d98e143d300082/armstrong/hatband/views/search.py#L88-L102 |
armstrong/armstrong.hatband | armstrong/hatband/views/search.py | TypeAndModelQueryMixin.type_and_model_to_query | def type_and_model_to_query(self, request):
"""
Return JSON for an individual Model instance
If the required parameters are wrong, return 400 Bad Request
If the parameters are correct but there is no data, return empty JSON
"""
try:
content_type_id = request... | python | def type_and_model_to_query(self, request):
"""
Return JSON for an individual Model instance
If the required parameters are wrong, return 400 Bad Request
If the parameters are correct but there is no data, return empty JSON
"""
try:
content_type_id = request... | [
"def",
"type_and_model_to_query",
"(",
"self",
",",
"request",
")",
":",
"try",
":",
"content_type_id",
"=",
"request",
".",
"GET",
"[",
"\"content_type_id\"",
"]",
"object_id",
"=",
"request",
".",
"GET",
"[",
"\"object_id\"",
"]",
"except",
"KeyError",
":",
... | Return JSON for an individual Model instance
If the required parameters are wrong, return 400 Bad Request
If the parameters are correct but there is no data, return empty JSON | [
"Return",
"JSON",
"for",
"an",
"individual",
"Model",
"instance"
] | train | https://github.com/armstrong/armstrong.hatband/blob/b34027c85a8ccfe2ee37aa9348d98e143d300082/armstrong/hatband/views/search.py#L151-L174 |
wtsi-hgi/gitlab-build-variables | gitlabbuildvariables/executables/gitlab_update_variables.py | _parse_args | def _parse_args(args: List[str]) -> _UpdateArgumentsRunConfig:
"""
Parses the given CLI arguments to get a run configuration.
:param args: CLI arguments
:return: run configuration derived from the given CLI arguments
"""
parser = argparse.ArgumentParser(
prog="gitlab-update-variables", d... | python | def _parse_args(args: List[str]) -> _UpdateArgumentsRunConfig:
"""
Parses the given CLI arguments to get a run configuration.
:param args: CLI arguments
:return: run configuration derived from the given CLI arguments
"""
parser = argparse.ArgumentParser(
prog="gitlab-update-variables", d... | [
"def",
"_parse_args",
"(",
"args",
":",
"List",
"[",
"str",
"]",
")",
"->",
"_UpdateArgumentsRunConfig",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"prog",
"=",
"\"gitlab-update-variables\"",
",",
"description",
"=",
"\"Tool for setting a GitLab pro... | Parses the given CLI arguments to get a run configuration.
:param args: CLI arguments
:return: run configuration derived from the given CLI arguments | [
"Parses",
"the",
"given",
"CLI",
"arguments",
"to",
"get",
"a",
"run",
"configuration",
".",
":",
"param",
"args",
":",
"CLI",
"arguments",
":",
"return",
":",
"run",
"configuration",
"derived",
"from",
"the",
"given",
"CLI",
"arguments"
] | train | https://github.com/wtsi-hgi/gitlab-build-variables/blob/ed1afe50bc41fa20ffb29cacba5ff6dbc2446808/gitlabbuildvariables/executables/gitlab_update_variables.py#L24-L42 |
wtsi-hgi/gitlab-build-variables | gitlabbuildvariables/executables/gitlab_update_variables.py | main | def main():
"""
Main method.
"""
run_config = _parse_args(sys.argv[1:])
if run_config.debug:
logger.setLevel(logging.DEBUG)
else:
logger.setLevel(logging.INFO)
gitlab_config = GitLabConfig(run_config.url, run_config.token)
project_updater_builder = FileBasedProjectVariab... | python | def main():
"""
Main method.
"""
run_config = _parse_args(sys.argv[1:])
if run_config.debug:
logger.setLevel(logging.DEBUG)
else:
logger.setLevel(logging.INFO)
gitlab_config = GitLabConfig(run_config.url, run_config.token)
project_updater_builder = FileBasedProjectVariab... | [
"def",
"main",
"(",
")",
":",
"run_config",
"=",
"_parse_args",
"(",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
")",
"if",
"run_config",
".",
"debug",
":",
"logger",
".",
"setLevel",
"(",
"logging",
".",
"DEBUG",
")",
"else",
":",
"logger",
".",
"setL... | Main method. | [
"Main",
"method",
"."
] | train | https://github.com/wtsi-hgi/gitlab-build-variables/blob/ed1afe50bc41fa20ffb29cacba5ff6dbc2446808/gitlabbuildvariables/executables/gitlab_update_variables.py#L45-L62 |
vinu76jsr/pipsort | lib/pipsort/core/_config.py | _Config.load | def load(self, paths, params=None):
""" Load data from configuration files.
Configuration values are read from a sequence of one or more YAML
files. Files are read in the given order, and a duplicate value will
overwrite the existing value.
The optional 'params' argument is a d... | python | def load(self, paths, params=None):
""" Load data from configuration files.
Configuration values are read from a sequence of one or more YAML
files. Files are read in the given order, and a duplicate value will
overwrite the existing value.
The optional 'params' argument is a d... | [
"def",
"load",
"(",
"self",
",",
"paths",
",",
"params",
"=",
"None",
")",
":",
"def",
"replace",
"(",
"match",
")",
":",
"\"\"\" Callback for re.sub to do parameter replacement. \"\"\"",
"# This allows for multi-pattern substitution in a single pass.",
"return",
"params",
... | Load data from configuration files.
Configuration values are read from a sequence of one or more YAML
files. Files are read in the given order, and a duplicate value will
overwrite the existing value.
The optional 'params' argument is a dict-like object to use for
parameter sub... | [
"Load",
"data",
"from",
"configuration",
"files",
"."
] | train | https://github.com/vinu76jsr/pipsort/blob/71ead1269de85ee0255741390bf1da85d81b7d16/lib/pipsort/core/_config.py#L48-L82 |
mdeous/fatbotslim | fatbotslim/irc/__init__.py | u | def u(s, errors='ignore'):
"""
Automatically detects given string's encoding and returns its unicode form.
Decoding errors are handled according to the `errors` argument, see `unicode()`
documentation for more details.
:param s: string to decode.
:type s: str
:param errors: decoding error h... | python | def u(s, errors='ignore'):
"""
Automatically detects given string's encoding and returns its unicode form.
Decoding errors are handled according to the `errors` argument, see `unicode()`
documentation for more details.
:param s: string to decode.
:type s: str
:param errors: decoding error h... | [
"def",
"u",
"(",
"s",
",",
"errors",
"=",
"'ignore'",
")",
":",
"try",
":",
"return",
"s",
".",
"decode",
"(",
"'utf-8'",
",",
"errors",
"=",
"errors",
")",
"except",
"UnicodeDecodeError",
":",
"encoding",
"=",
"chardet",
".",
"detect",
"(",
"s",
")"... | Automatically detects given string's encoding and returns its unicode form.
Decoding errors are handled according to the `errors` argument, see `unicode()`
documentation for more details.
:param s: string to decode.
:type s: str
:param errors: decoding error handling behaviour.
:type errors: st... | [
"Automatically",
"detects",
"given",
"string",
"s",
"encoding",
"and",
"returns",
"its",
"unicode",
"form",
".",
"Decoding",
"errors",
"are",
"handled",
"according",
"to",
"the",
"errors",
"argument",
"see",
"unicode",
"()",
"documentation",
"for",
"more",
"deta... | train | https://github.com/mdeous/fatbotslim/blob/341595d24454a79caee23750eac271f9d0626c88/fatbotslim/irc/__init__.py#L22-L39 |
universalcore/unicore.distribute | unicore/distribute/utils.py | get_repositories | def get_repositories(path):
"""
Return an array of tuples with the name and path for
repositories found in a directory.
:param str path:
The path to find repositories in
:returns: tuple
"""
return [get_repository(os.path.join(path, subdir))
for subdir in os.listdir(path)... | python | def get_repositories(path):
"""
Return an array of tuples with the name and path for
repositories found in a directory.
:param str path:
The path to find repositories in
:returns: tuple
"""
return [get_repository(os.path.join(path, subdir))
for subdir in os.listdir(path)... | [
"def",
"get_repositories",
"(",
"path",
")",
":",
"return",
"[",
"get_repository",
"(",
"os",
".",
"path",
".",
"join",
"(",
"path",
",",
"subdir",
")",
")",
"for",
"subdir",
"in",
"os",
".",
"listdir",
"(",
"path",
")",
"if",
"os",
".",
"path",
".... | Return an array of tuples with the name and path for
repositories found in a directory.
:param str path:
The path to find repositories in
:returns: tuple | [
"Return",
"an",
"array",
"of",
"tuples",
"with",
"the",
"name",
"and",
"path",
"for",
"repositories",
"found",
"in",
"a",
"directory",
"."
] | train | https://github.com/universalcore/unicore.distribute/blob/f3216fefd9df5aef31b3d1b666eb3f79db032d98/unicore/distribute/utils.py#L72-L84 |
universalcore/unicore.distribute | unicore/distribute/utils.py | get_repository_names | def get_repository_names(path):
"""
Return an array of the path name for
repositories found in a directory.
:param str path:
The path to find repositories in
:returns: array
"""
return [subdir
for subdir in os.listdir(path)
if os.path.isdir(os.path.join(path,... | python | def get_repository_names(path):
"""
Return an array of the path name for
repositories found in a directory.
:param str path:
The path to find repositories in
:returns: array
"""
return [subdir
for subdir in os.listdir(path)
if os.path.isdir(os.path.join(path,... | [
"def",
"get_repository_names",
"(",
"path",
")",
":",
"return",
"[",
"subdir",
"for",
"subdir",
"in",
"os",
".",
"listdir",
"(",
"path",
")",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"os",
".",
"path",
".",
"join",
"(",
"path",
",",
"subdir",
",... | Return an array of the path name for
repositories found in a directory.
:param str path:
The path to find repositories in
:returns: array | [
"Return",
"an",
"array",
"of",
"the",
"path",
"name",
"for",
"repositories",
"found",
"in",
"a",
"directory",
"."
] | train | https://github.com/universalcore/unicore.distribute/blob/f3216fefd9df5aef31b3d1b666eb3f79db032d98/unicore/distribute/utils.py#L87-L98 |
universalcore/unicore.distribute | unicore/distribute/utils.py | list_schemas | def list_schemas(repo):
"""
Return a list of parsed avro schemas as dictionaries.
:param Repo repo:
The git repository.
:returns: dict
"""
schema_files = glob.glob(
os.path.join(repo.working_dir, '_schemas', '*.avsc'))
schemas = {}
for schema_file in schema_files:
... | python | def list_schemas(repo):
"""
Return a list of parsed avro schemas as dictionaries.
:param Repo repo:
The git repository.
:returns: dict
"""
schema_files = glob.glob(
os.path.join(repo.working_dir, '_schemas', '*.avsc'))
schemas = {}
for schema_file in schema_files:
... | [
"def",
"list_schemas",
"(",
"repo",
")",
":",
"schema_files",
"=",
"glob",
".",
"glob",
"(",
"os",
".",
"path",
".",
"join",
"(",
"repo",
".",
"working_dir",
",",
"'_schemas'",
",",
"'*.avsc'",
")",
")",
"schemas",
"=",
"{",
"}",
"for",
"schema_file",
... | Return a list of parsed avro schemas as dictionaries.
:param Repo repo:
The git repository.
:returns: dict | [
"Return",
"a",
"list",
"of",
"parsed",
"avro",
"schemas",
"as",
"dictionaries",
"."
] | train | https://github.com/universalcore/unicore.distribute/blob/f3216fefd9df5aef31b3d1b666eb3f79db032d98/unicore/distribute/utils.py#L126-L141 |
universalcore/unicore.distribute | unicore/distribute/utils.py | list_content_types | def list_content_types(repo):
"""
Return a list of content types in a repository.
:param Repo repo:
The git repository.
:returns: list
"""
schema_files = glob.glob(
os.path.join(repo.working_dir, '_schemas', '*.avsc'))
return [os.path.splitext(os.path.basename(schema_file))[... | python | def list_content_types(repo):
"""
Return a list of content types in a repository.
:param Repo repo:
The git repository.
:returns: list
"""
schema_files = glob.glob(
os.path.join(repo.working_dir, '_schemas', '*.avsc'))
return [os.path.splitext(os.path.basename(schema_file))[... | [
"def",
"list_content_types",
"(",
"repo",
")",
":",
"schema_files",
"=",
"glob",
".",
"glob",
"(",
"os",
".",
"path",
".",
"join",
"(",
"repo",
".",
"working_dir",
",",
"'_schemas'",
",",
"'*.avsc'",
")",
")",
"return",
"[",
"os",
".",
"path",
".",
"... | Return a list of content types in a repository.
:param Repo repo:
The git repository.
:returns: list | [
"Return",
"a",
"list",
"of",
"content",
"types",
"in",
"a",
"repository",
"."
] | train | https://github.com/universalcore/unicore.distribute/blob/f3216fefd9df5aef31b3d1b666eb3f79db032d98/unicore/distribute/utils.py#L144-L155 |
universalcore/unicore.distribute | unicore/distribute/utils.py | get_schema | def get_schema(repo, content_type):
"""
Return a schema for a content type in a repository.
:param Repo repo:
The git repository.
:returns: dict
"""
try:
with open(
os.path.join(repo.working_dir,
'_schemas',
... | python | def get_schema(repo, content_type):
"""
Return a schema for a content type in a repository.
:param Repo repo:
The git repository.
:returns: dict
"""
try:
with open(
os.path.join(repo.working_dir,
'_schemas',
... | [
"def",
"get_schema",
"(",
"repo",
",",
"content_type",
")",
":",
"try",
":",
"with",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"repo",
".",
"working_dir",
",",
"'_schemas'",
",",
"'%s.avsc'",
"%",
"(",
"content_type",
",",
")",
")",
",",
"'r'... | Return a schema for a content type in a repository.
:param Repo repo:
The git repository.
:returns: dict | [
"Return",
"a",
"schema",
"for",
"a",
"content",
"type",
"in",
"a",
"repository",
"."
] | train | https://github.com/universalcore/unicore.distribute/blob/f3216fefd9df5aef31b3d1b666eb3f79db032d98/unicore/distribute/utils.py#L158-L174 |
universalcore/unicore.distribute | unicore/distribute/utils.py | get_mapping | def get_mapping(repo, content_type):
"""
Return an ES mapping for a content type in a repository.
:param Repo repo:
This git repository.
:returns: dict
"""
try:
with open(
os.path.join(repo.working_dir,
'_mappings',
'... | python | def get_mapping(repo, content_type):
"""
Return an ES mapping for a content type in a repository.
:param Repo repo:
This git repository.
:returns: dict
"""
try:
with open(
os.path.join(repo.working_dir,
'_mappings',
'... | [
"def",
"get_mapping",
"(",
"repo",
",",
"content_type",
")",
":",
"try",
":",
"with",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"repo",
".",
"working_dir",
",",
"'_mappings'",
",",
"'%s.json'",
"%",
"(",
"content_type",
",",
")",
")",
",",
"'... | Return an ES mapping for a content type in a repository.
:param Repo repo:
This git repository.
:returns: dict | [
"Return",
"an",
"ES",
"mapping",
"for",
"a",
"content",
"type",
"in",
"a",
"repository",
"."
] | train | https://github.com/universalcore/unicore.distribute/blob/f3216fefd9df5aef31b3d1b666eb3f79db032d98/unicore/distribute/utils.py#L177-L192 |
universalcore/unicore.distribute | unicore/distribute/utils.py | format_repo | def format_repo(repo):
"""
Return a dictionary representing the repository
It returns ``None`` for things we do not support or are not
relevant.
:param str repo_name:
The name of the repository.
:param git.Repo repo:
The repository object.
:param str base_url:
The b... | python | def format_repo(repo):
"""
Return a dictionary representing the repository
It returns ``None`` for things we do not support or are not
relevant.
:param str repo_name:
The name of the repository.
:param git.Repo repo:
The repository object.
:param str base_url:
The b... | [
"def",
"format_repo",
"(",
"repo",
")",
":",
"commit",
"=",
"repo",
".",
"commit",
"(",
")",
"return",
"{",
"'name'",
":",
"os",
".",
"path",
".",
"basename",
"(",
"repo",
".",
"working_dir",
")",
",",
"'branch'",
":",
"repo",
".",
"active_branch",
"... | Return a dictionary representing the repository
It returns ``None`` for things we do not support or are not
relevant.
:param str repo_name:
The name of the repository.
:param git.Repo repo:
The repository object.
:param str base_url:
The base URL for the repository's links.... | [
"Return",
"a",
"dictionary",
"representing",
"the",
"repository"
] | train | https://github.com/universalcore/unicore.distribute/blob/f3216fefd9df5aef31b3d1b666eb3f79db032d98/unicore/distribute/utils.py#L195-L220 |
universalcore/unicore.distribute | unicore/distribute/utils.py | format_diffindex | def format_diffindex(diff_index):
"""
Return a JSON formattable representation of a DiffIndex.
Returns a generator that returns dictionaries representing the changes.
.. code::
[
{
'type': 'A',
'path': 'path/to/added/file.txt',
},
... | python | def format_diffindex(diff_index):
"""
Return a JSON formattable representation of a DiffIndex.
Returns a generator that returns dictionaries representing the changes.
.. code::
[
{
'type': 'A',
'path': 'path/to/added/file.txt',
},
... | [
"def",
"format_diffindex",
"(",
"diff_index",
")",
":",
"for",
"diff",
"in",
"diff_index",
":",
"if",
"diff",
".",
"new_file",
":",
"yield",
"format_diff_A",
"(",
"diff",
")",
"elif",
"diff",
".",
"deleted_file",
":",
"yield",
"format_diff_D",
"(",
"diff",
... | Return a JSON formattable representation of a DiffIndex.
Returns a generator that returns dictionaries representing the changes.
.. code::
[
{
'type': 'A',
'path': 'path/to/added/file.txt',
},
{
'type': 'D',
... | [
"Return",
"a",
"JSON",
"formattable",
"representation",
"of",
"a",
"DiffIndex",
"."
] | train | https://github.com/universalcore/unicore.distribute/blob/f3216fefd9df5aef31b3d1b666eb3f79db032d98/unicore/distribute/utils.py#L252-L290 |
universalcore/unicore.distribute | unicore/distribute/utils.py | format_content_type | def format_content_type(repo, content_type):
"""
Return a list of all content objects for a given content type
in a repository.
:param Repo repo:
The git repository.
:param str content_type:
The content type to list
:returns: list
"""
storage_manager = StorageManager(rep... | python | def format_content_type(repo, content_type):
"""
Return a list of all content objects for a given content type
in a repository.
:param Repo repo:
The git repository.
:param str content_type:
The content type to list
:returns: list
"""
storage_manager = StorageManager(rep... | [
"def",
"format_content_type",
"(",
"repo",
",",
"content_type",
")",
":",
"storage_manager",
"=",
"StorageManager",
"(",
"repo",
")",
"model_class",
"=",
"load_model_class",
"(",
"repo",
",",
"content_type",
")",
"return",
"[",
"dict",
"(",
"model_obj",
")",
"... | Return a list of all content objects for a given content type
in a repository.
:param Repo repo:
The git repository.
:param str content_type:
The content type to list
:returns: list | [
"Return",
"a",
"list",
"of",
"all",
"content",
"objects",
"for",
"a",
"given",
"content",
"type",
"in",
"a",
"repository",
"."
] | train | https://github.com/universalcore/unicore.distribute/blob/f3216fefd9df5aef31b3d1b666eb3f79db032d98/unicore/distribute/utils.py#L293-L307 |
universalcore/unicore.distribute | unicore/distribute/utils.py | format_content_type_object | def format_content_type_object(repo, content_type, uuid):
"""
Return a content object from a repository for a given content_type
and uuid
:param Repo repo:
The git repository.
:param str content_type:
The content type to list
:returns: dict
"""
try:
storage_manag... | python | def format_content_type_object(repo, content_type, uuid):
"""
Return a content object from a repository for a given content_type
and uuid
:param Repo repo:
The git repository.
:param str content_type:
The content type to list
:returns: dict
"""
try:
storage_manag... | [
"def",
"format_content_type_object",
"(",
"repo",
",",
"content_type",
",",
"uuid",
")",
":",
"try",
":",
"storage_manager",
"=",
"StorageManager",
"(",
"repo",
")",
"model_class",
"=",
"load_model_class",
"(",
"repo",
",",
"content_type",
")",
"return",
"dict",... | Return a content object from a repository for a given content_type
and uuid
:param Repo repo:
The git repository.
:param str content_type:
The content type to list
:returns: dict | [
"Return",
"a",
"content",
"object",
"from",
"a",
"repository",
"for",
"a",
"given",
"content_type",
"and",
"uuid"
] | train | https://github.com/universalcore/unicore.distribute/blob/f3216fefd9df5aef31b3d1b666eb3f79db032d98/unicore/distribute/utils.py#L310-L326 |
universalcore/unicore.distribute | unicore/distribute/utils.py | format_repo_status | def format_repo_status(repo):
"""
Return a dictionary representing the repository status
It returns ``None`` for things we do not support or are not
relevant.
:param str repo_name:
The name of the repository.
:returns: dict
"""
commit = repo.commit()
return {
'name... | python | def format_repo_status(repo):
"""
Return a dictionary representing the repository status
It returns ``None`` for things we do not support or are not
relevant.
:param str repo_name:
The name of the repository.
:returns: dict
"""
commit = repo.commit()
return {
'name... | [
"def",
"format_repo_status",
"(",
"repo",
")",
":",
"commit",
"=",
"repo",
".",
"commit",
"(",
")",
"return",
"{",
"'name'",
":",
"os",
".",
"path",
".",
"basename",
"(",
"repo",
".",
"working_dir",
")",
",",
"'commit'",
":",
"commit",
".",
"hexsha",
... | Return a dictionary representing the repository status
It returns ``None`` for things we do not support or are not
relevant.
:param str repo_name:
The name of the repository.
:returns: dict | [
"Return",
"a",
"dictionary",
"representing",
"the",
"repository",
"status"
] | train | https://github.com/universalcore/unicore.distribute/blob/f3216fefd9df5aef31b3d1b666eb3f79db032d98/unicore/distribute/utils.py#L329-L347 |
universalcore/unicore.distribute | unicore/distribute/utils.py | save_content_type_object | def save_content_type_object(repo, schema, uuid, data):
"""
Save an object as a certain content type
"""
storage_manager = StorageManager(repo)
model_class = deserialize(schema,
module_name=schema['namespace'])
model = model_class(data)
commit = storage_manager.... | python | def save_content_type_object(repo, schema, uuid, data):
"""
Save an object as a certain content type
"""
storage_manager = StorageManager(repo)
model_class = deserialize(schema,
module_name=schema['namespace'])
model = model_class(data)
commit = storage_manager.... | [
"def",
"save_content_type_object",
"(",
"repo",
",",
"schema",
",",
"uuid",
",",
"data",
")",
":",
"storage_manager",
"=",
"StorageManager",
"(",
"repo",
")",
"model_class",
"=",
"deserialize",
"(",
"schema",
",",
"module_name",
"=",
"schema",
"[",
"'namespace... | Save an object as a certain content type | [
"Save",
"an",
"object",
"as",
"a",
"certain",
"content",
"type"
] | train | https://github.com/universalcore/unicore.distribute/blob/f3216fefd9df5aef31b3d1b666eb3f79db032d98/unicore/distribute/utils.py#L350-L359 |
universalcore/unicore.distribute | unicore/distribute/utils.py | delete_content_type_object | def delete_content_type_object(repo, content_type, uuid):
"""
Delete an object of a certain content type
"""
storage_manager = StorageManager(repo)
model_class = load_model_class(repo, content_type)
model = storage_manager.get(model_class, uuid)
commit = storage_manager.delete(model, 'Delete... | python | def delete_content_type_object(repo, content_type, uuid):
"""
Delete an object of a certain content type
"""
storage_manager = StorageManager(repo)
model_class = load_model_class(repo, content_type)
model = storage_manager.get(model_class, uuid)
commit = storage_manager.delete(model, 'Delete... | [
"def",
"delete_content_type_object",
"(",
"repo",
",",
"content_type",
",",
"uuid",
")",
":",
"storage_manager",
"=",
"StorageManager",
"(",
"repo",
")",
"model_class",
"=",
"load_model_class",
"(",
"repo",
",",
"content_type",
")",
"model",
"=",
"storage_manager"... | Delete an object of a certain content type | [
"Delete",
"an",
"object",
"of",
"a",
"certain",
"content",
"type"
] | train | https://github.com/universalcore/unicore.distribute/blob/f3216fefd9df5aef31b3d1b666eb3f79db032d98/unicore/distribute/utils.py#L362-L370 |
universalcore/unicore.distribute | unicore/distribute/utils.py | load_model_class | def load_model_class(repo, content_type):
"""
Return a model class for a content type in a repository.
:param Repo repo:
The git repository.
:param str content_type:
The content type to list
:returns: class
"""
schema = get_schema(repo, content_type).to_json()
return des... | python | def load_model_class(repo, content_type):
"""
Return a model class for a content type in a repository.
:param Repo repo:
The git repository.
:param str content_type:
The content type to list
:returns: class
"""
schema = get_schema(repo, content_type).to_json()
return des... | [
"def",
"load_model_class",
"(",
"repo",
",",
"content_type",
")",
":",
"schema",
"=",
"get_schema",
"(",
"repo",
",",
"content_type",
")",
".",
"to_json",
"(",
")",
"return",
"deserialize",
"(",
"schema",
",",
"module_name",
"=",
"schema",
"[",
"'namespace'"... | Return a model class for a content type in a repository.
:param Repo repo:
The git repository.
:param str content_type:
The content type to list
:returns: class | [
"Return",
"a",
"model",
"class",
"for",
"a",
"content",
"type",
"in",
"a",
"repository",
"."
] | train | https://github.com/universalcore/unicore.distribute/blob/f3216fefd9df5aef31b3d1b666eb3f79db032d98/unicore/distribute/utils.py#L409-L420 |
universalcore/unicore.distribute | unicore/distribute/utils.py | UCConfigParser.get_list | def get_list(self, section, option):
"""
This allows for loading of Pyramid list style configuration
options:
[foo]
bar =
baz
qux
zap
``get_list('foo', 'bar')`` returns ``['baz', 'qux', 'zap']``
:param str section:
... | python | def get_list(self, section, option):
"""
This allows for loading of Pyramid list style configuration
options:
[foo]
bar =
baz
qux
zap
``get_list('foo', 'bar')`` returns ``['baz', 'qux', 'zap']``
:param str section:
... | [
"def",
"get_list",
"(",
"self",
",",
"section",
",",
"option",
")",
":",
"value",
"=",
"self",
".",
"get",
"(",
"section",
",",
"option",
")",
"return",
"list",
"(",
"filter",
"(",
"None",
",",
"(",
"x",
".",
"strip",
"(",
")",
"for",
"x",
"in",
... | This allows for loading of Pyramid list style configuration
options:
[foo]
bar =
baz
qux
zap
``get_list('foo', 'bar')`` returns ``['baz', 'qux', 'zap']``
:param str section:
The section to read.
:param str option:
... | [
"This",
"allows",
"for",
"loading",
"of",
"Pyramid",
"list",
"style",
"configuration",
"options",
":"
] | train | https://github.com/universalcore/unicore.distribute/blob/f3216fefd9df5aef31b3d1b666eb3f79db032d98/unicore/distribute/utils.py#L28-L48 |
universalcore/unicore.distribute | unicore/distribute/utils.py | UCConfigParser.get_dict | def get_dict(self, section, option):
"""
This allows for loading of Pyramid dictionary style configuration
options:
[foo]
bar =
baz=qux
zap=paz
``get_dict('foo', 'bar')`` returns ``{'baz': 'qux', 'zap': 'paz'}``
:param str section:
... | python | def get_dict(self, section, option):
"""
This allows for loading of Pyramid dictionary style configuration
options:
[foo]
bar =
baz=qux
zap=paz
``get_dict('foo', 'bar')`` returns ``{'baz': 'qux', 'zap': 'paz'}``
:param str section:
... | [
"def",
"get_dict",
"(",
"self",
",",
"section",
",",
"option",
")",
":",
"return",
"dict",
"(",
"re",
".",
"split",
"(",
"'\\s*=\\s*'",
",",
"value",
")",
"for",
"value",
"in",
"self",
".",
"get_list",
"(",
"section",
",",
"option",
")",
")"
] | This allows for loading of Pyramid dictionary style configuration
options:
[foo]
bar =
baz=qux
zap=paz
``get_dict('foo', 'bar')`` returns ``{'baz': 'qux', 'zap': 'paz'}``
:param str section:
The section to read.
:param str option:
... | [
"This",
"allows",
"for",
"loading",
"of",
"Pyramid",
"dictionary",
"style",
"configuration",
"options",
":"
] | train | https://github.com/universalcore/unicore.distribute/blob/f3216fefd9df5aef31b3d1b666eb3f79db032d98/unicore/distribute/utils.py#L50-L69 |
zeromake/aiko | aiko/worker.py | GunicornWorker.init_process | def init_process(self) -> None:
"""
GunicornWorker 初始化回调
"""
default_loop = asyncio.get_event_loop()
if default_loop.is_running():
default_loop.close()
self.loop = asyncio.new_event_loop()
asyncio.set_event_loop(self.loop)
else:
... | python | def init_process(self) -> None:
"""
GunicornWorker 初始化回调
"""
default_loop = asyncio.get_event_loop()
if default_loop.is_running():
default_loop.close()
self.loop = asyncio.new_event_loop()
asyncio.set_event_loop(self.loop)
else:
... | [
"def",
"init_process",
"(",
"self",
")",
"->",
"None",
":",
"default_loop",
"=",
"asyncio",
".",
"get_event_loop",
"(",
")",
"if",
"default_loop",
".",
"is_running",
"(",
")",
":",
"default_loop",
".",
"close",
"(",
")",
"self",
".",
"loop",
"=",
"asynci... | GunicornWorker 初始化回调 | [
"GunicornWorker",
"初始化回调"
] | train | https://github.com/zeromake/aiko/blob/53b246fa88652466a9e38ac3d1a99a6198195b0f/aiko/worker.py#L25-L36 |
zeromake/aiko | aiko/worker.py | GunicornWorker.run | def run(self) -> None:
"""
创建了 sock 的运行回调
"""
if self.loop is None:
return
create_server = asyncio.ensure_future(self._run(), loop=self.loop) # type: ignore
try:
self.loop.run_until_complete(create_server)
self.loop.run_until_complete(... | python | def run(self) -> None:
"""
创建了 sock 的运行回调
"""
if self.loop is None:
return
create_server = asyncio.ensure_future(self._run(), loop=self.loop) # type: ignore
try:
self.loop.run_until_complete(create_server)
self.loop.run_until_complete(... | [
"def",
"run",
"(",
"self",
")",
"->",
"None",
":",
"if",
"self",
".",
"loop",
"is",
"None",
":",
"return",
"create_server",
"=",
"asyncio",
".",
"ensure_future",
"(",
"self",
".",
"_run",
"(",
")",
",",
"loop",
"=",
"self",
".",
"loop",
")",
"# typ... | 创建了 sock 的运行回调 | [
"创建了",
"sock",
"的运行回调"
] | train | https://github.com/zeromake/aiko/blob/53b246fa88652466a9e38ac3d1a99a6198195b0f/aiko/worker.py#L38-L50 |
zeromake/aiko | aiko/worker.py | GunicornWorker._check_alive | def _check_alive(self) -> Generator[Any, None, None]:
"""
等待结束信号
"""
if self.loop is None:
return
pid = os.getpid()
try:
while self.alive: # type: ignore
self.notify()
if pid == os.getpid() and self.ppid != os.getp... | python | def _check_alive(self) -> Generator[Any, None, None]:
"""
等待结束信号
"""
if self.loop is None:
return
pid = os.getpid()
try:
while self.alive: # type: ignore
self.notify()
if pid == os.getpid() and self.ppid != os.getp... | [
"def",
"_check_alive",
"(",
"self",
")",
"->",
"Generator",
"[",
"Any",
",",
"None",
",",
"None",
"]",
":",
"if",
"self",
".",
"loop",
"is",
"None",
":",
"return",
"pid",
"=",
"os",
".",
"getpid",
"(",
")",
"try",
":",
"while",
"self",
".",
"aliv... | 等待结束信号 | [
"等待结束信号"
] | train | https://github.com/zeromake/aiko/blob/53b246fa88652466a9e38ac3d1a99a6198195b0f/aiko/worker.py#L53-L71 |
zeromake/aiko | aiko/worker.py | GunicornWorker._run | def _run(self) -> Generator[Any, None, None]:
"""
创建 Server
"""
ssl_context = self._create_ssl_context()
# access_logger = self.log.access_log if self.cfg.accesslog else None
for sock in self.sockets:
# max_fields_size = self.cfg.limit_request_fields * self.cf... | python | def _run(self) -> Generator[Any, None, None]:
"""
创建 Server
"""
ssl_context = self._create_ssl_context()
# access_logger = self.log.access_log if self.cfg.accesslog else None
for sock in self.sockets:
# max_fields_size = self.cfg.limit_request_fields * self.cf... | [
"def",
"_run",
"(",
"self",
")",
"->",
"Generator",
"[",
"Any",
",",
"None",
",",
"None",
"]",
":",
"ssl_context",
"=",
"self",
".",
"_create_ssl_context",
"(",
")",
"# access_logger = self.log.access_log if self.cfg.accesslog else None",
"for",
"sock",
"in",
"sel... | 创建 Server | [
"创建",
"Server"
] | train | https://github.com/zeromake/aiko/blob/53b246fa88652466a9e38ac3d1a99a6198195b0f/aiko/worker.py#L74-L84 |
zeromake/aiko | aiko/worker.py | GunicornWorker._create_ssl_context | def _create_ssl_context(self) -> Optional[SSLContext]:
"""
创建 ssl
"""
ssl_context = None
if self.cfg.is_ssl:
ssl_context = SSLContext(self.cfg.ssl_version)
ssl_context.load_cert_chain(self.cfg.certfile, self.cfg.keyfile)
if self.cfg.ca_certs:
... | python | def _create_ssl_context(self) -> Optional[SSLContext]:
"""
创建 ssl
"""
ssl_context = None
if self.cfg.is_ssl:
ssl_context = SSLContext(self.cfg.ssl_version)
ssl_context.load_cert_chain(self.cfg.certfile, self.cfg.keyfile)
if self.cfg.ca_certs:
... | [
"def",
"_create_ssl_context",
"(",
"self",
")",
"->",
"Optional",
"[",
"SSLContext",
"]",
":",
"ssl_context",
"=",
"None",
"if",
"self",
".",
"cfg",
".",
"is_ssl",
":",
"ssl_context",
"=",
"SSLContext",
"(",
"self",
".",
"cfg",
".",
"ssl_version",
")",
"... | 创建 ssl | [
"创建",
"ssl"
] | train | https://github.com/zeromake/aiko/blob/53b246fa88652466a9e38ac3d1a99a6198195b0f/aiko/worker.py#L86-L99 |
zeromake/aiko | aiko/worker.py | GunicornWorker.close | def close(self) -> Generator[Any, None, None]:
"""
关闭回调
"""
for server in self.servers:
server.close()
yield from server.wait_closed() | python | def close(self) -> Generator[Any, None, None]:
"""
关闭回调
"""
for server in self.servers:
server.close()
yield from server.wait_closed() | [
"def",
"close",
"(",
"self",
")",
"->",
"Generator",
"[",
"Any",
",",
"None",
",",
"None",
"]",
":",
"for",
"server",
"in",
"self",
".",
"servers",
":",
"server",
".",
"close",
"(",
")",
"yield",
"from",
"server",
".",
"wait_closed",
"(",
")"
] | 关闭回调 | [
"关闭回调"
] | train | https://github.com/zeromake/aiko/blob/53b246fa88652466a9e38ac3d1a99a6198195b0f/aiko/worker.py#L102-L108 |
binilinlquad/bing-search-api | bing_search_api/api.py | quote | def quote(query):
'''Quote query with sign(')'''
if query.startswith('\'') is not True:
query = '\'' + query
if query.endswith('\'') is not True:
query = query + '\''
return query | python | def quote(query):
'''Quote query with sign(')'''
if query.startswith('\'') is not True:
query = '\'' + query
if query.endswith('\'') is not True:
query = query + '\''
return query | [
"def",
"quote",
"(",
"query",
")",
":",
"if",
"query",
".",
"startswith",
"(",
"'\\''",
")",
"is",
"not",
"True",
":",
"query",
"=",
"'\\''",
"+",
"query",
"if",
"query",
".",
"endswith",
"(",
"'\\''",
")",
"is",
"not",
"True",
":",
"query",
"=",
... | Quote query with sign(') | [
"Quote",
"query",
"with",
"sign",
"(",
")"
] | train | https://github.com/binilinlquad/bing-search-api/blob/c3a296ad7d0050dc929eda9d9760df5c15faa51a/bing_search_api/api.py#L4-L12 |
binilinlquad/bing-search-api | bing_search_api/api.py | BingSearchAPI.search | def search(self, query, search_type, payload=None):
'''Search implementation'''
url = self.url + search_type
headers = {'User-Agent': self.user_agent}
if payload is not None:
payload['Query'] = quote(query)
else:
payload = {'Query': quote(query)}
... | python | def search(self, query, search_type, payload=None):
'''Search implementation'''
url = self.url + search_type
headers = {'User-Agent': self.user_agent}
if payload is not None:
payload['Query'] = quote(query)
else:
payload = {'Query': quote(query)}
... | [
"def",
"search",
"(",
"self",
",",
"query",
",",
"search_type",
",",
"payload",
"=",
"None",
")",
":",
"url",
"=",
"self",
".",
"url",
"+",
"search_type",
"headers",
"=",
"{",
"'User-Agent'",
":",
"self",
".",
"user_agent",
"}",
"if",
"payload",
"is",
... | Search implementation | [
"Search",
"implementation"
] | train | https://github.com/binilinlquad/bing-search-api/blob/c3a296ad7d0050dc929eda9d9760df5c15faa51a/bing_search_api/api.py#L25-L36 |
binilinlquad/bing-search-api | bing_search_api/api.py | BingSearchAPI.search_composite | def search_composite(self, query, source, payload=None):
'''Shortcut search with composite source'''
source = '+'.join(source)
if payload is None:
payload = dict(Sources=quote(source))
else:
payload['Sources'] = quote(source)
return self.search(query, 'C... | python | def search_composite(self, query, source, payload=None):
'''Shortcut search with composite source'''
source = '+'.join(source)
if payload is None:
payload = dict(Sources=quote(source))
else:
payload['Sources'] = quote(source)
return self.search(query, 'C... | [
"def",
"search_composite",
"(",
"self",
",",
"query",
",",
"source",
",",
"payload",
"=",
"None",
")",
":",
"source",
"=",
"'+'",
".",
"join",
"(",
"source",
")",
"if",
"payload",
"is",
"None",
":",
"payload",
"=",
"dict",
"(",
"Sources",
"=",
"quote... | Shortcut search with composite source | [
"Shortcut",
"search",
"with",
"composite",
"source"
] | train | https://github.com/binilinlquad/bing-search-api/blob/c3a296ad7d0050dc929eda9d9760df5c15faa51a/bing_search_api/api.py#L62-L71 |
pop/GrindStone | grindstone/lib.py | key_of | def key_of(d):
"""
Returns the key of a single element dict.
"""
if len(d) > 1 and not type(d) == dict():
raise ValueError('key_of(d) may only except single element dict')
else:
return keys_of(d)[0] | python | def key_of(d):
"""
Returns the key of a single element dict.
"""
if len(d) > 1 and not type(d) == dict():
raise ValueError('key_of(d) may only except single element dict')
else:
return keys_of(d)[0] | [
"def",
"key_of",
"(",
"d",
")",
":",
"if",
"len",
"(",
"d",
")",
">",
"1",
"and",
"not",
"type",
"(",
"d",
")",
"==",
"dict",
"(",
")",
":",
"raise",
"ValueError",
"(",
"'key_of(d) may only except single element dict'",
")",
"else",
":",
"return",
"key... | Returns the key of a single element dict. | [
"Returns",
"the",
"key",
"of",
"a",
"single",
"element",
"dict",
"."
] | train | https://github.com/pop/GrindStone/blob/1c788389689faa3f9b223763eb1c946f59ab972a/grindstone/lib.py#L12-L19 |
pop/GrindStone | grindstone/lib.py | GrindStone.open_grindstone | def open_grindstone(self):
"""
Opens a grindstone file and populates the grindstone with it's
contents.
Returns an empty grindstone json object if a file does not exist.
"""
try:
with open(self.grindstone_path, 'r') as f:
# Try opening the file... | python | def open_grindstone(self):
"""
Opens a grindstone file and populates the grindstone with it's
contents.
Returns an empty grindstone json object if a file does not exist.
"""
try:
with open(self.grindstone_path, 'r') as f:
# Try opening the file... | [
"def",
"open_grindstone",
"(",
"self",
")",
":",
"try",
":",
"with",
"open",
"(",
"self",
".",
"grindstone_path",
",",
"'r'",
")",
"as",
"f",
":",
"# Try opening the file",
"return",
"json",
".",
"loads",
"(",
"f",
".",
"read",
"(",
")",
")",
"# If the... | Opens a grindstone file and populates the grindstone with it's
contents.
Returns an empty grindstone json object if a file does not exist. | [
"Opens",
"a",
"grindstone",
"file",
"and",
"populates",
"the",
"grindstone",
"with",
"it",
"s",
"contents",
".",
"Returns",
"an",
"empty",
"grindstone",
"json",
"object",
"if",
"a",
"file",
"does",
"not",
"exist",
"."
] | train | https://github.com/pop/GrindStone/blob/1c788389689faa3f9b223763eb1c946f59ab972a/grindstone/lib.py#L49-L66 |
pop/GrindStone | grindstone/lib.py | GrindStone.add_task | def add_task(self, name=None, desc=None):
"""
Adds object to list of grindstone['tasks'].
"""
# A name is required to create a task
for k in self.get_tasks():
if name in keys_of(k):
raise ValueError('Task already exists')
if name is not None:
... | python | def add_task(self, name=None, desc=None):
"""
Adds object to list of grindstone['tasks'].
"""
# A name is required to create a task
for k in self.get_tasks():
if name in keys_of(k):
raise ValueError('Task already exists')
if name is not None:
... | [
"def",
"add_task",
"(",
"self",
",",
"name",
"=",
"None",
",",
"desc",
"=",
"None",
")",
":",
"# A name is required to create a task",
"for",
"k",
"in",
"self",
".",
"get_tasks",
"(",
")",
":",
"if",
"name",
"in",
"keys_of",
"(",
"k",
")",
":",
"raise"... | Adds object to list of grindstone['tasks']. | [
"Adds",
"object",
"to",
"list",
"of",
"grindstone",
"[",
"tasks",
"]",
"."
] | train | https://github.com/pop/GrindStone/blob/1c788389689faa3f9b223763eb1c946f59ab972a/grindstone/lib.py#L69-L83 |
pop/GrindStone | grindstone/lib.py | GrindStone.delete_task | def delete_task(self, task=None):
"""
Deletes a given task by name.
"""
# Iterate over the list of tasks
for t in self.grindstone['tasks']:
# If they key of the task matches the task given
if key_of(t) == task:
# Remove that task
... | python | def delete_task(self, task=None):
"""
Deletes a given task by name.
"""
# Iterate over the list of tasks
for t in self.grindstone['tasks']:
# If they key of the task matches the task given
if key_of(t) == task:
# Remove that task
... | [
"def",
"delete_task",
"(",
"self",
",",
"task",
"=",
"None",
")",
":",
"# Iterate over the list of tasks",
"for",
"t",
"in",
"self",
".",
"grindstone",
"[",
"'tasks'",
"]",
":",
"# If they key of the task matches the task given",
"if",
"key_of",
"(",
"t",
")",
"... | Deletes a given task by name. | [
"Deletes",
"a",
"given",
"task",
"by",
"name",
"."
] | train | https://github.com/pop/GrindStone/blob/1c788389689faa3f9b223763eb1c946f59ab972a/grindstone/lib.py#L86-L99 |
pop/GrindStone | grindstone/lib.py | GrindStone.write_grindstone | def write_grindstone(self):
"""
Writes self.gs to self.grindstone_path.
"""
with open(self.grindstone_path, 'w') as f:
# Write the JSON dump of the file
f.write(json.dumps(self.grindstone)) | python | def write_grindstone(self):
"""
Writes self.gs to self.grindstone_path.
"""
with open(self.grindstone_path, 'w') as f:
# Write the JSON dump of the file
f.write(json.dumps(self.grindstone)) | [
"def",
"write_grindstone",
"(",
"self",
")",
":",
"with",
"open",
"(",
"self",
".",
"grindstone_path",
",",
"'w'",
")",
"as",
"f",
":",
"# Write the JSON dump of the file",
"f",
".",
"write",
"(",
"json",
".",
"dumps",
"(",
"self",
".",
"grindstone",
")",
... | Writes self.gs to self.grindstone_path. | [
"Writes",
"self",
".",
"gs",
"to",
"self",
".",
"grindstone_path",
"."
] | train | https://github.com/pop/GrindStone/blob/1c788389689faa3f9b223763eb1c946f59ab972a/grindstone/lib.py#L102-L108 |
pop/GrindStone | grindstone/lib.py | GrindStone.get_task | def get_task(self, task=None):
"""
Returns a (task, description) tuple for a given task
"""
# Iterate over the grindstone tasks
for t in self.grindstone['tasks']:
# if they key matches the task
if key_of(t) == task:
# Return this task
... | python | def get_task(self, task=None):
"""
Returns a (task, description) tuple for a given task
"""
# Iterate over the grindstone tasks
for t in self.grindstone['tasks']:
# if they key matches the task
if key_of(t) == task:
# Return this task
... | [
"def",
"get_task",
"(",
"self",
",",
"task",
"=",
"None",
")",
":",
"# Iterate over the grindstone tasks",
"for",
"t",
"in",
"self",
".",
"grindstone",
"[",
"'tasks'",
"]",
":",
"# if they key matches the task",
"if",
"key_of",
"(",
"t",
")",
"==",
"task",
"... | Returns a (task, description) tuple for a given task | [
"Returns",
"a",
"(",
"task",
"description",
")",
"tuple",
"for",
"a",
"given",
"task"
] | train | https://github.com/pop/GrindStone/blob/1c788389689faa3f9b223763eb1c946f59ab972a/grindstone/lib.py#L111-L122 |
Harvard-University-iCommons/dj-log-config-helper | dj_log_config_helper.py | build_app_loggers | def build_app_loggers(log_level, apps, handlers=None):
""" Return a logger dict for app packages with the given log level and no
propogation since the apps list is parsed/normalized to be the set of top-
level apps. The optional handlers argument is provided so that this pattern
of app loggers can be u... | python | def build_app_loggers(log_level, apps, handlers=None):
""" Return a logger dict for app packages with the given log level and no
propogation since the apps list is parsed/normalized to be the set of top-
level apps. The optional handlers argument is provided so that this pattern
of app loggers can be u... | [
"def",
"build_app_loggers",
"(",
"log_level",
",",
"apps",
",",
"handlers",
"=",
"None",
")",
":",
"# Use 'default' handler provided by DEFAULT_LOGGING config if",
"# not supplied.",
"if",
"handlers",
"is",
"None",
":",
"handlers",
"=",
"[",
"'default'",
"]",
"# The l... | Return a logger dict for app packages with the given log level and no
propogation since the apps list is parsed/normalized to be the set of top-
level apps. The optional handlers argument is provided so that this pattern
of app loggers can be used independently of the configure_logger method
below, if ... | [
"Return",
"a",
"logger",
"dict",
"for",
"app",
"packages",
"with",
"the",
"given",
"log",
"level",
"and",
"no",
"propogation",
"since",
"the",
"apps",
"list",
"is",
"parsed",
"/",
"normalized",
"to",
"be",
"the",
"set",
"of",
"top",
"-",
"level",
"apps",... | train | https://github.com/Harvard-University-iCommons/dj-log-config-helper/blob/5e568a65c455ca984d8f6d652986df190ed2a6dd/dj_log_config_helper.py#L55-L81 |
Harvard-University-iCommons/dj-log-config-helper | dj_log_config_helper.py | _build_logging_config | def _build_logging_config(level, apps_list, verbose, filename=None):
""" Return a copy of the DEFAULT_LOGGING config with installed application
loggers at the given log level. The 'default' handler is kept as a
console/stream writer unless a filename is passed in, which swaps the stream
handler out for... | python | def _build_logging_config(level, apps_list, verbose, filename=None):
""" Return a copy of the DEFAULT_LOGGING config with installed application
loggers at the given log level. The 'default' handler is kept as a
console/stream writer unless a filename is passed in, which swaps the stream
handler out for... | [
"def",
"_build_logging_config",
"(",
"level",
",",
"apps_list",
",",
"verbose",
",",
"filename",
"=",
"None",
")",
":",
"config",
"=",
"copy",
".",
"deepcopy",
"(",
"DEFAULT_LOGGING",
")",
"# Swap out default stream handler for a file handler, if",
"# a filename is give... | Return a copy of the DEFAULT_LOGGING config with installed application
loggers at the given log level. The 'default' handler is kept as a
console/stream writer unless a filename is passed in, which swaps the stream
handler out for a file handler. The 'verbose' formatter is used if
verbosity is enabled... | [
"Return",
"a",
"copy",
"of",
"the",
"DEFAULT_LOGGING",
"config",
"with",
"installed",
"application",
"loggers",
"at",
"the",
"given",
"log",
"level",
".",
"The",
"default",
"handler",
"is",
"kept",
"as",
"a",
"console",
"/",
"stream",
"writer",
"unless",
"a"... | train | https://github.com/Harvard-University-iCommons/dj-log-config-helper/blob/5e568a65c455ca984d8f6d652986df190ed2a6dd/dj_log_config_helper.py#L84-L107 |
Harvard-University-iCommons/dj-log-config-helper | dj_log_config_helper.py | configure_installed_apps_logger | def configure_installed_apps_logger(level, verbose=False,
additional_packages=None, filename=None):
"""Builds and enables a logger with a logger list of the top-level list of
installed app modules (based on package name) plus any additional
application packages passed in ... | python | def configure_installed_apps_logger(level, verbose=False,
additional_packages=None, filename=None):
"""Builds and enables a logger with a logger list of the top-level list of
installed app modules (based on package name) plus any additional
application packages passed in ... | [
"def",
"configure_installed_apps_logger",
"(",
"level",
",",
"verbose",
"=",
"False",
",",
"additional_packages",
"=",
"None",
",",
"filename",
"=",
"None",
")",
":",
"if",
"settings",
".",
"LOGGING_CONFIG",
":",
"raise",
"ImproperlyConfigured",
"(",
"LOGGING_CONF... | Builds and enables a logger with a logger list of the top-level list of
installed app modules (based on package name) plus any additional
application packages passed in - for example, a user may want to log a
dependent package of one the installed apps. The logger will write either
to the console or to... | [
"Builds",
"and",
"enables",
"a",
"logger",
"with",
"a",
"logger",
"list",
"of",
"the",
"top",
"-",
"level",
"list",
"of",
"installed",
"app",
"modules",
"(",
"based",
"on",
"package",
"name",
")",
"plus",
"any",
"additional",
"application",
"packages",
"pa... | train | https://github.com/Harvard-University-iCommons/dj-log-config-helper/blob/5e568a65c455ca984d8f6d652986df190ed2a6dd/dj_log_config_helper.py#L110-L135 |
scivision/histutils | histutils/timedmc.py | ut12frame | def ut12frame(treq, ind, ut1_unix):
"""
Given treq, output index(ces) to extract via rawDMCreader
treq: scalar or vector of ut1_unix time (seconds since Jan 1, 1970)
ind: zero-based frame index corresponding to ut1_unix, corresponding to input data file.
"""
if treq is None: # have to do this s... | python | def ut12frame(treq, ind, ut1_unix):
"""
Given treq, output index(ces) to extract via rawDMCreader
treq: scalar or vector of ut1_unix time (seconds since Jan 1, 1970)
ind: zero-based frame index corresponding to ut1_unix, corresponding to input data file.
"""
if treq is None: # have to do this s... | [
"def",
"ut12frame",
"(",
"treq",
",",
"ind",
",",
"ut1_unix",
")",
":",
"if",
"treq",
"is",
"None",
":",
"# have to do this since interp1 will return last index otherwise",
"return",
"treq",
"=",
"atleast_1d",
"(",
"treq",
")",
"# %% handle human specified string scalar... | Given treq, output index(ces) to extract via rawDMCreader
treq: scalar or vector of ut1_unix time (seconds since Jan 1, 1970)
ind: zero-based frame index corresponding to ut1_unix, corresponding to input data file. | [
"Given",
"treq",
"output",
"index",
"(",
"ces",
")",
"to",
"extract",
"via",
"rawDMCreader",
"treq",
":",
"scalar",
"or",
"vector",
"of",
"ut1_unix",
"time",
"(",
"seconds",
"since",
"Jan",
"1",
"1970",
")",
"ind",
":",
"zero",
"-",
"based",
"frame",
"... | train | https://github.com/scivision/histutils/blob/859a91d3894cb57faed34881c6ea16130b90571e/histutils/timedmc.py#L38-L66 |
scivision/histutils | histutils/timedmc.py | datetime2unix | def datetime2unix(T):
"""
converts datetime to UT1 unix epoch time
"""
T = atleast_1d(T)
ut1_unix = empty(T.shape, dtype=float)
for i, t in enumerate(T):
if isinstance(t, (datetime, datetime64)):
pass
elif isinstance(t, str):
try:
ut1_unix... | python | def datetime2unix(T):
"""
converts datetime to UT1 unix epoch time
"""
T = atleast_1d(T)
ut1_unix = empty(T.shape, dtype=float)
for i, t in enumerate(T):
if isinstance(t, (datetime, datetime64)):
pass
elif isinstance(t, str):
try:
ut1_unix... | [
"def",
"datetime2unix",
"(",
"T",
")",
":",
"T",
"=",
"atleast_1d",
"(",
"T",
")",
"ut1_unix",
"=",
"empty",
"(",
"T",
".",
"shape",
",",
"dtype",
"=",
"float",
")",
"for",
"i",
",",
"t",
"in",
"enumerate",
"(",
"T",
")",
":",
"if",
"isinstance",... | converts datetime to UT1 unix epoch time | [
"converts",
"datetime",
"to",
"UT1",
"unix",
"epoch",
"time"
] | train | https://github.com/scivision/histutils/blob/859a91d3894cb57faed34881c6ea16130b90571e/histutils/timedmc.py#L69-L93 |
tshlabs/tunic | tunic/install.py | _is_iterable | def _is_iterable(val):
"""Ensure that a value is iterable and not some sort of string"""
try:
iter(val)
except (ValueError, TypeError):
return False
else:
return not isinstance(val, basestring) | python | def _is_iterable(val):
"""Ensure that a value is iterable and not some sort of string"""
try:
iter(val)
except (ValueError, TypeError):
return False
else:
return not isinstance(val, basestring) | [
"def",
"_is_iterable",
"(",
"val",
")",
":",
"try",
":",
"iter",
"(",
"val",
")",
"except",
"(",
"ValueError",
",",
"TypeError",
")",
":",
"return",
"False",
"else",
":",
"return",
"not",
"isinstance",
"(",
"val",
",",
"basestring",
")"
] | Ensure that a value is iterable and not some sort of string | [
"Ensure",
"that",
"a",
"value",
"is",
"iterable",
"and",
"not",
"some",
"sort",
"of",
"string"
] | train | https://github.com/tshlabs/tunic/blob/621f4398d59a9c9eb8dd602beadff11616048aa0/tunic/install.py#L23-L30 |
tshlabs/tunic | tunic/install.py | download_url | def download_url(url, destination, retries=None, retry_delay=None, runner=None):
"""Download the given URL with wget to the provided path. The command is
run via Fabric on the current remote machine. Therefore, the destination
path should be for the remote machine.
:param str url: URL to download onto ... | python | def download_url(url, destination, retries=None, retry_delay=None, runner=None):
"""Download the given URL with wget to the provided path. The command is
run via Fabric on the current remote machine. Therefore, the destination
path should be for the remote machine.
:param str url: URL to download onto ... | [
"def",
"download_url",
"(",
"url",
",",
"destination",
",",
"retries",
"=",
"None",
",",
"retry_delay",
"=",
"None",
",",
"runner",
"=",
"None",
")",
":",
"runner",
"=",
"runner",
"if",
"runner",
"is",
"not",
"None",
"else",
"FabRunner",
"(",
")",
"ret... | Download the given URL with wget to the provided path. The command is
run via Fabric on the current remote machine. Therefore, the destination
path should be for the remote machine.
:param str url: URL to download onto the remote machine
:param str destination: Path to download the URL to on the remote... | [
"Download",
"the",
"given",
"URL",
"with",
"wget",
"to",
"the",
"provided",
"path",
".",
"The",
"command",
"is",
"run",
"via",
"Fabric",
"on",
"the",
"current",
"remote",
"machine",
".",
"Therefore",
"the",
"destination",
"path",
"should",
"be",
"for",
"th... | train | https://github.com/tshlabs/tunic/blob/621f4398d59a9c9eb8dd602beadff11616048aa0/tunic/install.py#L287-L305 |
tshlabs/tunic | tunic/install.py | VirtualEnvInstallation._get_install_sources | def _get_install_sources(self):
"""Construct arguments to use alternative package indexes if
there were sources supplied, empty string if there were not.
"""
if not self._sources:
return ''
parts = ['--no-index']
for source in self._sources:
parts.... | python | def _get_install_sources(self):
"""Construct arguments to use alternative package indexes if
there were sources supplied, empty string if there were not.
"""
if not self._sources:
return ''
parts = ['--no-index']
for source in self._sources:
parts.... | [
"def",
"_get_install_sources",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_sources",
":",
"return",
"''",
"parts",
"=",
"[",
"'--no-index'",
"]",
"for",
"source",
"in",
"self",
".",
"_sources",
":",
"parts",
".",
"append",
"(",
"\"--find-links '{0}'... | Construct arguments to use alternative package indexes if
there were sources supplied, empty string if there were not. | [
"Construct",
"arguments",
"to",
"use",
"alternative",
"package",
"indexes",
"if",
"there",
"were",
"sources",
"supplied",
"empty",
"string",
"if",
"there",
"were",
"not",
"."
] | train | https://github.com/tshlabs/tunic/blob/621f4398d59a9c9eb8dd602beadff11616048aa0/tunic/install.py#L95-L104 |
tshlabs/tunic | tunic/install.py | VirtualEnvInstallation.install | def install(self, release_id, upgrade=False):
"""Install target packages into a virtual environment.
If the virtual environment for the given release ID does not
exist on the remote system, it will be created. The virtual
environment will be created according to the standard Tunic
... | python | def install(self, release_id, upgrade=False):
"""Install target packages into a virtual environment.
If the virtual environment for the given release ID does not
exist on the remote system, it will be created. The virtual
environment will be created according to the standard Tunic
... | [
"def",
"install",
"(",
"self",
",",
"release_id",
",",
"upgrade",
"=",
"False",
")",
":",
"release_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"_releases",
",",
"release_id",
")",
"if",
"not",
"self",
".",
"_runner",
".",
"exists",
... | Install target packages into a virtual environment.
If the virtual environment for the given release ID does not
exist on the remote system, it will be created. The virtual
environment will be created according to the standard Tunic
directory structure (see :doc:`design`).
If `... | [
"Install",
"target",
"packages",
"into",
"a",
"virtual",
"environment",
"."
] | train | https://github.com/tshlabs/tunic/blob/621f4398d59a9c9eb8dd602beadff11616048aa0/tunic/install.py#L106-L143 |
tshlabs/tunic | tunic/install.py | StaticFileInstallation.install | def install(self, release_id):
"""Install the contents of the local directory into a release directory.
If the directory for the given release ID does not exist on the remote
system, it will be created. The directory will be created according to
the standard Tunic directory structure (s... | python | def install(self, release_id):
"""Install the contents of the local directory into a release directory.
If the directory for the given release ID does not exist on the remote
system, it will be created. The directory will be created according to
the standard Tunic directory structure (s... | [
"def",
"install",
"(",
"self",
",",
"release_id",
")",
":",
"release_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"_releases",
",",
"release_id",
")",
"if",
"not",
"self",
".",
"_runner",
".",
"exists",
"(",
"release_path",
")",
":",
... | Install the contents of the local directory into a release directory.
If the directory for the given release ID does not exist on the remote
system, it will be created. The directory will be created according to
the standard Tunic directory structure (see :doc:`design`).
Note that the ... | [
"Install",
"the",
"contents",
"of",
"the",
"local",
"directory",
"into",
"a",
"release",
"directory",
"."
] | train | https://github.com/tshlabs/tunic/blob/621f4398d59a9c9eb8dd602beadff11616048aa0/tunic/install.py#L181-L209 |
tshlabs/tunic | tunic/install.py | LocalArtifactInstallation.install | def install(self, release_id):
"""Install the local artifact into the remote release directory, optionally
with a different name than the artifact had locally.
If the directory for the given release ID does not exist on the remote
system, it will be created. The directory will be create... | python | def install(self, release_id):
"""Install the local artifact into the remote release directory, optionally
with a different name than the artifact had locally.
If the directory for the given release ID does not exist on the remote
system, it will be created. The directory will be create... | [
"def",
"install",
"(",
"self",
",",
"release_id",
")",
":",
"release_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"_releases",
",",
"release_id",
")",
"if",
"not",
"self",
".",
"_runner",
".",
"exists",
"(",
"release_path",
")",
":",
... | Install the local artifact into the remote release directory, optionally
with a different name than the artifact had locally.
If the directory for the given release ID does not exist on the remote
system, it will be created. The directory will be created according to
the standard Tunic ... | [
"Install",
"the",
"local",
"artifact",
"into",
"the",
"remote",
"release",
"directory",
"optionally",
"with",
"a",
"different",
"name",
"than",
"the",
"artifact",
"had",
"locally",
"."
] | train | https://github.com/tshlabs/tunic/blob/621f4398d59a9c9eb8dd602beadff11616048aa0/tunic/install.py#L256-L284 |
tshlabs/tunic | tunic/install.py | HttpArtifactInstallation._get_file_from_url | def _get_file_from_url(url):
"""Get the filename part of the path component from a URL."""
path = urlparse(url).path
if not path:
raise ValueError("Could not extract path from URL '{0}'".format(url))
name = os.path.basename(path)
if not name:
raise ValueEr... | python | def _get_file_from_url(url):
"""Get the filename part of the path component from a URL."""
path = urlparse(url).path
if not path:
raise ValueError("Could not extract path from URL '{0}'".format(url))
name = os.path.basename(path)
if not name:
raise ValueEr... | [
"def",
"_get_file_from_url",
"(",
"url",
")",
":",
"path",
"=",
"urlparse",
"(",
"url",
")",
".",
"path",
"if",
"not",
"path",
":",
"raise",
"ValueError",
"(",
"\"Could not extract path from URL '{0}'\"",
".",
"format",
"(",
"url",
")",
")",
"name",
"=",
"... | Get the filename part of the path component from a URL. | [
"Get",
"the",
"filename",
"part",
"of",
"the",
"path",
"component",
"from",
"a",
"URL",
"."
] | train | https://github.com/tshlabs/tunic/blob/621f4398d59a9c9eb8dd602beadff11616048aa0/tunic/install.py#L388-L396 |
tshlabs/tunic | tunic/install.py | HttpArtifactInstallation.install | def install(self, release_id):
"""Download and install an artifact into the remote release directory,
optionally with a different name the the artifact had.
If the directory for the given release ID does not exist on the remote
system, it will be created. The directory will be created a... | python | def install(self, release_id):
"""Download and install an artifact into the remote release directory,
optionally with a different name the the artifact had.
If the directory for the given release ID does not exist on the remote
system, it will be created. The directory will be created a... | [
"def",
"install",
"(",
"self",
",",
"release_id",
")",
":",
"release_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"_releases",
",",
"release_id",
")",
"if",
"not",
"self",
".",
"_runner",
".",
"exists",
"(",
"release_path",
")",
":",
... | Download and install an artifact into the remote release directory,
optionally with a different name the the artifact had.
If the directory for the given release ID does not exist on the remote
system, it will be created. The directory will be created according to
the standard Tunic dir... | [
"Download",
"and",
"install",
"an",
"artifact",
"into",
"the",
"remote",
"release",
"directory",
"optionally",
"with",
"a",
"different",
"name",
"the",
"the",
"artifact",
"had",
"."
] | train | https://github.com/tshlabs/tunic/blob/621f4398d59a9c9eb8dd602beadff11616048aa0/tunic/install.py#L398-L435 |
mrstephenneal/dirutility | dirutility/walk/walk.py | pool_process | def pool_process(func, iterable, process_name='Pool processing', cpus=cpu_count()):
"""
Apply a function to each element in an iterable and return a result list.
:param func: A function that returns a value
:param iterable: A list or set of elements to be passed to the func as the singular parameter
... | python | def pool_process(func, iterable, process_name='Pool processing', cpus=cpu_count()):
"""
Apply a function to each element in an iterable and return a result list.
:param func: A function that returns a value
:param iterable: A list or set of elements to be passed to the func as the singular parameter
... | [
"def",
"pool_process",
"(",
"func",
",",
"iterable",
",",
"process_name",
"=",
"'Pool processing'",
",",
"cpus",
"=",
"cpu_count",
"(",
")",
")",
":",
"with",
"Timer",
"(",
"'\\t{0} ({1}) completed in'",
".",
"format",
"(",
"process_name",
",",
"str",
"(",
"... | Apply a function to each element in an iterable and return a result list.
:param func: A function that returns a value
:param iterable: A list or set of elements to be passed to the func as the singular parameter
:param process_name: Name of the process, for printing purposes only
:param cpus: Number o... | [
"Apply",
"a",
"function",
"to",
"each",
"element",
"in",
"an",
"iterable",
"and",
"return",
"a",
"result",
"list",
"."
] | train | https://github.com/mrstephenneal/dirutility/blob/339378659e2d7e09c53acfc51c5df745bb0cd517/dirutility/walk/walk.py#L35-L49 |
mrstephenneal/dirutility | dirutility/walk/walk.py | remover | def remover(file_path):
"""Delete a file or directory path only if it exists."""
if os.path.isfile(file_path):
os.remove(file_path)
return True
elif os.path.isdir(file_path):
shutil.rmtree(file_path)
return True
else:
return False | python | def remover(file_path):
"""Delete a file or directory path only if it exists."""
if os.path.isfile(file_path):
os.remove(file_path)
return True
elif os.path.isdir(file_path):
shutil.rmtree(file_path)
return True
else:
return False | [
"def",
"remover",
"(",
"file_path",
")",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"file_path",
")",
":",
"os",
".",
"remove",
"(",
"file_path",
")",
"return",
"True",
"elif",
"os",
".",
"path",
".",
"isdir",
"(",
"file_path",
")",
":",
"sh... | Delete a file or directory path only if it exists. | [
"Delete",
"a",
"file",
"or",
"directory",
"path",
"only",
"if",
"it",
"exists",
"."
] | train | https://github.com/mrstephenneal/dirutility/blob/339378659e2d7e09c53acfc51c5df745bb0cd517/dirutility/walk/walk.py#L68-L77 |
mrstephenneal/dirutility | dirutility/walk/walk.py | creation_date | def creation_date(path_to_file, return_datetime=True):
"""
Retrieve a file's creation date.
Try to get the date that a file was created, falling back to when it was
last modified if that isn't possible.
See http://stackoverflow.com/a/39501288/1709587 for explanation.
:param path_to_file: File... | python | def creation_date(path_to_file, return_datetime=True):
"""
Retrieve a file's creation date.
Try to get the date that a file was created, falling back to when it was
last modified if that isn't possible.
See http://stackoverflow.com/a/39501288/1709587 for explanation.
:param path_to_file: File... | [
"def",
"creation_date",
"(",
"path_to_file",
",",
"return_datetime",
"=",
"True",
")",
":",
"if",
"platform",
".",
"system",
"(",
")",
"==",
"'Windows'",
":",
"created_at",
"=",
"os",
".",
"path",
".",
"getctime",
"(",
"path_to_file",
")",
"else",
":",
"... | Retrieve a file's creation date.
Try to get the date that a file was created, falling back to when it was
last modified if that isn't possible.
See http://stackoverflow.com/a/39501288/1709587 for explanation.
:param path_to_file: File path
:param return_datetime: Bool, returns value in Datetime f... | [
"Retrieve",
"a",
"file",
"s",
"creation",
"date",
"."
] | train | https://github.com/mrstephenneal/dirutility/blob/339378659e2d7e09c53acfc51c5df745bb0cd517/dirutility/walk/walk.py#L80-L107 |
mrstephenneal/dirutility | dirutility/walk/walk.py | DirPaths._get_filepaths | def _get_filepaths(self):
"""Filters list of file paths to remove non-included, remove excluded files and concatenate full paths."""
self._printer(str(self.__len__()) + " file paths have been parsed in " + str(self.timer.end))
if self._hash_files:
return pool_hash(self.filepaths)
... | python | def _get_filepaths(self):
"""Filters list of file paths to remove non-included, remove excluded files and concatenate full paths."""
self._printer(str(self.__len__()) + " file paths have been parsed in " + str(self.timer.end))
if self._hash_files:
return pool_hash(self.filepaths)
... | [
"def",
"_get_filepaths",
"(",
"self",
")",
":",
"self",
".",
"_printer",
"(",
"str",
"(",
"self",
".",
"__len__",
"(",
")",
")",
"+",
"\" file paths have been parsed in \"",
"+",
"str",
"(",
"self",
".",
"timer",
".",
"end",
")",
")",
"if",
"self",
"."... | Filters list of file paths to remove non-included, remove excluded files and concatenate full paths. | [
"Filters",
"list",
"of",
"file",
"paths",
"to",
"remove",
"non",
"-",
"included",
"remove",
"excluded",
"files",
"and",
"concatenate",
"full",
"paths",
"."
] | train | https://github.com/mrstephenneal/dirutility/blob/339378659e2d7e09c53acfc51c5df745bb0cd517/dirutility/walk/walk.py#L182-L188 |
mrstephenneal/dirutility | dirutility/walk/walk.py | DirPaths.creation_dates | def creation_dates(self, sort=True):
"""
Return a list of (file_path, creation_date) tuples created from list of walked paths.
:param sort: Bool, sorts file_paths on created_date from newest to oldest.
:return: List of (file_path, created_date) tuples.
"""
if not sort:
... | python | def creation_dates(self, sort=True):
"""
Return a list of (file_path, creation_date) tuples created from list of walked paths.
:param sort: Bool, sorts file_paths on created_date from newest to oldest.
:return: List of (file_path, created_date) tuples.
"""
if not sort:
... | [
"def",
"creation_dates",
"(",
"self",
",",
"sort",
"=",
"True",
")",
":",
"if",
"not",
"sort",
":",
"return",
"pool_creation_date",
"(",
"self",
".",
"filepaths",
")",
"else",
":",
"pcd",
"=",
"pool_creation_date",
"(",
"self",
".",
"filepaths",
")",
"pc... | Return a list of (file_path, creation_date) tuples created from list of walked paths.
:param sort: Bool, sorts file_paths on created_date from newest to oldest.
:return: List of (file_path, created_date) tuples. | [
"Return",
"a",
"list",
"of",
"(",
"file_path",
"creation_date",
")",
"tuples",
"created",
"from",
"list",
"of",
"walked",
"paths",
"."
] | train | https://github.com/mrstephenneal/dirutility/blob/339378659e2d7e09c53acfc51c5df745bb0cd517/dirutility/walk/walk.py#L190-L202 |
mrstephenneal/dirutility | dirutility/walk/walk.py | DirPaths.walk | def walk(self):
"""
Default file path retrieval function.
sprinter() - Generates file path list using pool processing and Queues
crawler() - Generates file path list using os.walk() in sequence
"""
if self.parallelize:
self.filepaths = Sprinter(self.directory,... | python | def walk(self):
"""
Default file path retrieval function.
sprinter() - Generates file path list using pool processing and Queues
crawler() - Generates file path list using os.walk() in sequence
"""
if self.parallelize:
self.filepaths = Sprinter(self.directory,... | [
"def",
"walk",
"(",
"self",
")",
":",
"if",
"self",
".",
"parallelize",
":",
"self",
".",
"filepaths",
"=",
"Sprinter",
"(",
"self",
".",
"directory",
",",
"self",
".",
"filters",
",",
"self",
".",
"full_paths",
",",
"self",
".",
"pool_size",
",",
"s... | Default file path retrieval function.
sprinter() - Generates file path list using pool processing and Queues
crawler() - Generates file path list using os.walk() in sequence | [
"Default",
"file",
"path",
"retrieval",
"function",
".",
"sprinter",
"()",
"-",
"Generates",
"file",
"path",
"list",
"using",
"pool",
"processing",
"and",
"Queues",
"crawler",
"()",
"-",
"Generates",
"file",
"path",
"list",
"using",
"os",
".",
"walk",
"()",
... | train | https://github.com/mrstephenneal/dirutility/blob/339378659e2d7e09c53acfc51c5df745bb0cd517/dirutility/walk/walk.py#L204-L214 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.