Search is not available for this dataset
identifier stringlengths 1 155 | parameters stringlengths 2 6.09k | docstring stringlengths 11 63.4k | docstring_summary stringlengths 0 63.4k | function stringlengths 29 99.8k | function_tokens list | start_point list | end_point list | language stringclasses 1
value | docstring_language stringlengths 2 7 | docstring_language_predictions stringlengths 18 23 | is_langid_reliable stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
IResourceProvider.resource_isdir | (resource_name) | Is the named resource a directory? (like ``os.path.isdir()``) | Is the named resource a directory? (like ``os.path.isdir()``) | def resource_isdir(resource_name):
"""Is the named resource a directory? (like ``os.path.isdir()``)""" | [
"def",
"resource_isdir",
"(",
"resource_name",
")",
":"
] | [
529,
4
] | [
530,
76
] | python | en | ['en', 'en', 'en'] | True |
IResourceProvider.resource_listdir | (resource_name) | List of resource names in the directory (like ``os.listdir()``) | List of resource names in the directory (like ``os.listdir()``) | def resource_listdir(resource_name):
"""List of resource names in the directory (like ``os.listdir()``)""" | [
"def",
"resource_listdir",
"(",
"resource_name",
")",
":"
] | [
532,
4
] | [
533,
77
] | python | en | ['en', 'en', 'en'] | True |
WorkingSet.__init__ | (self, entries=None) | Create working set from list of path entries (default=sys.path) | Create working set from list of path entries (default=sys.path) | def __init__(self, entries=None):
"""Create working set from list of path entries (default=sys.path)"""
self.entries = []
self.entry_keys = {}
self.by_key = {}
self.callbacks = []
if entries is None:
entries = sys.path
for entry in entries:
... | [
"def",
"__init__",
"(",
"self",
",",
"entries",
"=",
"None",
")",
":",
"self",
".",
"entries",
"=",
"[",
"]",
"self",
".",
"entry_keys",
"=",
"{",
"}",
"self",
".",
"by_key",
"=",
"{",
"}",
"self",
".",
"callbacks",
"=",
"[",
"]",
"if",
"entries"... | [
539,
4
] | [
550,
33
] | python | en | ['en', 'en', 'en'] | True |
WorkingSet._build_master | (cls) |
Prepare the master working set.
|
Prepare the master working set.
| def _build_master(cls):
"""
Prepare the master working set.
"""
ws = cls()
try:
from __main__ import __requires__
except ImportError:
# The main program does not list any requirements
return ws
# ensure the requirements are met... | [
"def",
"_build_master",
"(",
"cls",
")",
":",
"ws",
"=",
"cls",
"(",
")",
"try",
":",
"from",
"__main__",
"import",
"__requires__",
"except",
"ImportError",
":",
"# The main program does not list any requirements",
"return",
"ws",
"# ensure the requirements are met",
... | [
553,
4
] | [
570,
17
] | python | en | ['en', 'error', 'th'] | False |
WorkingSet._build_from_requirements | (cls, req_spec) |
Build a working set from a requirement spec. Rewrites sys.path.
|
Build a working set from a requirement spec. Rewrites sys.path.
| def _build_from_requirements(cls, req_spec):
"""
Build a working set from a requirement spec. Rewrites sys.path.
"""
# try it without defaults already on sys.path
# by starting with an empty path
ws = cls([])
reqs = parse_requirements(req_spec)
dists = ws.... | [
"def",
"_build_from_requirements",
"(",
"cls",
",",
"req_spec",
")",
":",
"# try it without defaults already on sys.path",
"# by starting with an empty path",
"ws",
"=",
"cls",
"(",
"[",
"]",
")",
"reqs",
"=",
"parse_requirements",
"(",
"req_spec",
")",
"dists",
"=",
... | [
573,
4
] | [
592,
17
] | python | en | ['en', 'error', 'th'] | False |
WorkingSet.add_entry | (self, entry) | Add a path item to ``.entries``, finding any distributions on it
``find_distributions(entry, True)`` is used to find distributions
corresponding to the path entry, and they are added. `entry` is
always appended to ``.entries``, even if it is already present.
(This is because ``sys.path... | Add a path item to ``.entries``, finding any distributions on it | def add_entry(self, entry):
"""Add a path item to ``.entries``, finding any distributions on it
``find_distributions(entry, True)`` is used to find distributions
corresponding to the path entry, and they are added. `entry` is
always appended to ``.entries``, even if it is already prese... | [
"def",
"add_entry",
"(",
"self",
",",
"entry",
")",
":",
"self",
".",
"entry_keys",
".",
"setdefault",
"(",
"entry",
",",
"[",
"]",
")",
"self",
".",
"entries",
".",
"append",
"(",
"entry",
")",
"for",
"dist",
"in",
"find_distributions",
"(",
"entry",
... | [
594,
4
] | [
607,
40
] | python | en | ['en', 'en', 'en'] | True |
WorkingSet.__contains__ | (self, dist) | True if `dist` is the active distribution for its project | True if `dist` is the active distribution for its project | def __contains__(self, dist):
"""True if `dist` is the active distribution for its project"""
return self.by_key.get(dist.key) == dist | [
"def",
"__contains__",
"(",
"self",
",",
"dist",
")",
":",
"return",
"self",
".",
"by_key",
".",
"get",
"(",
"dist",
".",
"key",
")",
"==",
"dist"
] | [
609,
4
] | [
611,
48
] | python | en | ['en', 'en', 'en'] | True |
WorkingSet.find | (self, req) | Find a distribution matching requirement `req`
If there is an active distribution for the requested project, this
returns it as long as it meets the version requirement specified by
`req`. But, if there is an active distribution for the project and it
does *not* meet the `req` requirem... | Find a distribution matching requirement `req` | def find(self, req):
"""Find a distribution matching requirement `req`
If there is an active distribution for the requested project, this
returns it as long as it meets the version requirement specified by
`req`. But, if there is an active distribution for the project and it
do... | [
"def",
"find",
"(",
"self",
",",
"req",
")",
":",
"dist",
"=",
"self",
".",
"by_key",
".",
"get",
"(",
"req",
".",
"key",
")",
"if",
"dist",
"is",
"not",
"None",
"and",
"dist",
"not",
"in",
"req",
":",
"# XXX add more info",
"raise",
"VersionConflict... | [
613,
4
] | [
627,
19
] | python | en | ['en', 'en', 'en'] | True |
WorkingSet.iter_entry_points | (self, group, name=None) | Yield entry point objects from `group` matching `name`
If `name` is None, yields all entry points in `group` from all
distributions in the working set, otherwise only ones matching
both `group` and `name` are yielded (in distribution order).
| Yield entry point objects from `group` matching `name` | def iter_entry_points(self, group, name=None):
"""Yield entry point objects from `group` matching `name`
If `name` is None, yields all entry points in `group` from all
distributions in the working set, otherwise only ones matching
both `group` and `name` are yielded (in distribution ord... | [
"def",
"iter_entry_points",
"(",
"self",
",",
"group",
",",
"name",
"=",
"None",
")",
":",
"return",
"(",
"entry",
"for",
"dist",
"in",
"self",
"for",
"entry",
"in",
"dist",
".",
"get_entry_map",
"(",
"group",
")",
".",
"values",
"(",
")",
"if",
"nam... | [
629,
4
] | [
641,
9
] | python | en | ['en', 'en', 'en'] | True |
WorkingSet.run_script | (self, requires, script_name) | Locate distribution for `requires` and run `script_name` script | Locate distribution for `requires` and run `script_name` script | def run_script(self, requires, script_name):
"""Locate distribution for `requires` and run `script_name` script"""
ns = sys._getframe(1).f_globals
name = ns['__name__']
ns.clear()
ns['__name__'] = name
self.require(requires)[0].run_script(script_name, ns) | [
"def",
"run_script",
"(",
"self",
",",
"requires",
",",
"script_name",
")",
":",
"ns",
"=",
"sys",
".",
"_getframe",
"(",
"1",
")",
".",
"f_globals",
"name",
"=",
"ns",
"[",
"'__name__'",
"]",
"ns",
".",
"clear",
"(",
")",
"ns",
"[",
"'__name__'",
... | [
643,
4
] | [
649,
61
] | python | en | ['en', 'en', 'en'] | True |
WorkingSet.__iter__ | (self) | Yield distributions for non-duplicate projects in the working set
The yield order is the order in which the items' path entries were
added to the working set.
| Yield distributions for non-duplicate projects in the working set | def __iter__(self):
"""Yield distributions for non-duplicate projects in the working set
The yield order is the order in which the items' path entries were
added to the working set.
"""
seen = {}
for item in self.entries:
if item not in self.entry_keys:
... | [
"def",
"__iter__",
"(",
"self",
")",
":",
"seen",
"=",
"{",
"}",
"for",
"item",
"in",
"self",
".",
"entries",
":",
"if",
"item",
"not",
"in",
"self",
".",
"entry_keys",
":",
"# workaround a cache issue",
"continue",
"for",
"key",
"in",
"self",
".",
"en... | [
651,
4
] | [
666,
42
] | python | en | ['en', 'en', 'en'] | True |
WorkingSet.add | (self, dist, entry=None, insert=True, replace=False) | Add `dist` to working set, associated with `entry`
If `entry` is unspecified, it defaults to the ``.location`` of `dist`.
On exit from this routine, `entry` is added to the end of the working
set's ``.entries`` (if it wasn't already present).
`dist` is only added to the working set if ... | Add `dist` to working set, associated with `entry` | def add(self, dist, entry=None, insert=True, replace=False):
"""Add `dist` to working set, associated with `entry`
If `entry` is unspecified, it defaults to the ``.location`` of `dist`.
On exit from this routine, `entry` is added to the end of the working
set's ``.entries`` (if it wasn'... | [
"def",
"add",
"(",
"self",
",",
"dist",
",",
"entry",
"=",
"None",
",",
"insert",
"=",
"True",
",",
"replace",
"=",
"False",
")",
":",
"if",
"insert",
":",
"dist",
".",
"insert_on",
"(",
"self",
".",
"entries",
",",
"entry",
",",
"replace",
"=",
... | [
668,
4
] | [
696,
29
] | python | en | ['en', 'en', 'en'] | True |
WorkingSet.resolve | (self, requirements, env=None, installer=None,
replace_conflicting=False, extras=None) | List all distributions needed to (recursively) meet `requirements`
`requirements` must be a sequence of ``Requirement`` objects. `env`,
if supplied, should be an ``Environment`` instance. If
not supplied, it defaults to all distributions available within any
entry or distribution in t... | List all distributions needed to (recursively) meet `requirements` | def resolve(self, requirements, env=None, installer=None,
replace_conflicting=False, extras=None):
"""List all distributions needed to (recursively) meet `requirements`
`requirements` must be a sequence of ``Requirement`` objects. `env`,
if supplied, should be an ``Environment`... | [
"def",
"resolve",
"(",
"self",
",",
"requirements",
",",
"env",
"=",
"None",
",",
"installer",
"=",
"None",
",",
"replace_conflicting",
"=",
"False",
",",
"extras",
"=",
"None",
")",
":",
"# set up the stack",
"requirements",
"=",
"list",
"(",
"requirements"... | [
698,
4
] | [
788,
26
] | python | en | ['en', 'en', 'en'] | True |
WorkingSet.find_plugins | (
self, plugin_env, full_env=None, installer=None, fallback=True) | Find all activatable distributions in `plugin_env`
Example usage::
distributions, errors = working_set.find_plugins(
Environment(plugin_dirlist)
)
# add plugins+libs to sys.path
map(working_set.add, distributions)
# display errors
... | Find all activatable distributions in `plugin_env` | def find_plugins(
self, plugin_env, full_env=None, installer=None, fallback=True):
"""Find all activatable distributions in `plugin_env`
Example usage::
distributions, errors = working_set.find_plugins(
Environment(plugin_dirlist)
)
# add... | [
"def",
"find_plugins",
"(",
"self",
",",
"plugin_env",
",",
"full_env",
"=",
"None",
",",
"installer",
"=",
"None",
",",
"fallback",
"=",
"True",
")",
":",
"plugin_projects",
"=",
"list",
"(",
"plugin_env",
")",
"# scan project names in alphabetic order",
"plugi... | [
790,
4
] | [
872,
40
] | python | en | ['en', 'en', 'en'] | True |
WorkingSet.require | (self, *requirements) | Ensure that distributions matching `requirements` are activated
`requirements` must be a string or a (possibly-nested) sequence
thereof, specifying the distributions and versions required. The
return value is a sequence of the distributions that needed to be
activated to fulfill the re... | Ensure that distributions matching `requirements` are activated | def require(self, *requirements):
"""Ensure that distributions matching `requirements` are activated
`requirements` must be a string or a (possibly-nested) sequence
thereof, specifying the distributions and versions required. The
return value is a sequence of the distributions that nee... | [
"def",
"require",
"(",
"self",
",",
"*",
"requirements",
")",
":",
"needed",
"=",
"self",
".",
"resolve",
"(",
"parse_requirements",
"(",
"requirements",
")",
")",
"for",
"dist",
"in",
"needed",
":",
"self",
".",
"add",
"(",
"dist",
")",
"return",
"nee... | [
874,
4
] | [
888,
21
] | python | en | ['en', 'en', 'en'] | True |
WorkingSet.subscribe | (self, callback, existing=True) | Invoke `callback` for all distributions
If `existing=True` (default),
call on all existing ones, as well.
| Invoke `callback` for all distributions | def subscribe(self, callback, existing=True):
"""Invoke `callback` for all distributions
If `existing=True` (default),
call on all existing ones, as well.
"""
if callback in self.callbacks:
return
self.callbacks.append(callback)
if not existing:
... | [
"def",
"subscribe",
"(",
"self",
",",
"callback",
",",
"existing",
"=",
"True",
")",
":",
"if",
"callback",
"in",
"self",
".",
"callbacks",
":",
"return",
"self",
".",
"callbacks",
".",
"append",
"(",
"callback",
")",
"if",
"not",
"existing",
":",
"ret... | [
890,
4
] | [
902,
26
] | python | en | ['en', 'no', 'en'] | True |
_ReqExtras.markers_pass | (self, req, extras=None) |
Evaluate markers for req against each extra that
demanded it.
Return False if the req has a marker and fails
evaluation. Otherwise, return True.
|
Evaluate markers for req against each extra that
demanded it. | def markers_pass(self, req, extras=None):
"""
Evaluate markers for req against each extra that
demanded it.
Return False if the req has a marker and fails
evaluation. Otherwise, return True.
"""
extra_evals = (
req.marker.evaluate({'extra': extra})
... | [
"def",
"markers_pass",
"(",
"self",
",",
"req",
",",
"extras",
"=",
"None",
")",
":",
"extra_evals",
"=",
"(",
"req",
".",
"marker",
".",
"evaluate",
"(",
"{",
"'extra'",
":",
"extra",
"}",
")",
"for",
"extra",
"in",
"self",
".",
"get",
"(",
"req",... | [
927,
4
] | [
939,
49
] | python | en | ['en', 'error', 'th'] | False |
Environment.__init__ | (
self, search_path=None, platform=get_supported_platform(),
python=PY_MAJOR) | Snapshot distributions available on a search path
Any distributions found on `search_path` are added to the environment.
`search_path` should be a sequence of ``sys.path`` items. If not
supplied, ``sys.path`` is used.
`platform` is an optional string specifying the name of the platfor... | Snapshot distributions available on a search path | def __init__(
self, search_path=None, platform=get_supported_platform(),
python=PY_MAJOR):
"""Snapshot distributions available on a search path
Any distributions found on `search_path` are added to the environment.
`search_path` should be a sequence of ``sys.path`` items... | [
"def",
"__init__",
"(",
"self",
",",
"search_path",
"=",
"None",
",",
"platform",
"=",
"get_supported_platform",
"(",
")",
",",
"python",
"=",
"PY_MAJOR",
")",
":",
"self",
".",
"_distmap",
"=",
"{",
"}",
"self",
".",
"platform",
"=",
"platform",
"self",... | [
945,
4
] | [
967,
30
] | python | en | ['en', 'en', 'en'] | True |
Environment.can_add | (self, dist) | Is distribution `dist` acceptable for this environment?
The distribution must match the platform and python version
requirements specified when this environment was created, or False
is returned.
| Is distribution `dist` acceptable for this environment? | def can_add(self, dist):
"""Is distribution `dist` acceptable for this environment?
The distribution must match the platform and python version
requirements specified when this environment was created, or False
is returned.
"""
py_compat = (
self.python is No... | [
"def",
"can_add",
"(",
"self",
",",
"dist",
")",
":",
"py_compat",
"=",
"(",
"self",
".",
"python",
"is",
"None",
"or",
"dist",
".",
"py_version",
"is",
"None",
"or",
"dist",
".",
"py_version",
"==",
"self",
".",
"python",
")",
"return",
"py_compat",
... | [
969,
4
] | [
981,
79
] | python | en | ['en', 'en', 'en'] | True |
Environment.remove | (self, dist) | Remove `dist` from the environment | Remove `dist` from the environment | def remove(self, dist):
"""Remove `dist` from the environment"""
self._distmap[dist.key].remove(dist) | [
"def",
"remove",
"(",
"self",
",",
"dist",
")",
":",
"self",
".",
"_distmap",
"[",
"dist",
".",
"key",
"]",
".",
"remove",
"(",
"dist",
")"
] | [
983,
4
] | [
985,
44
] | python | en | ['en', 'en', 'en'] | True |
Environment.scan | (self, search_path=None) | Scan `search_path` for distributions usable in this environment
Any distributions found are added to the environment.
`search_path` should be a sequence of ``sys.path`` items. If not
supplied, ``sys.path`` is used. Only distributions conforming to
the platform/python version defined a... | Scan `search_path` for distributions usable in this environment | def scan(self, search_path=None):
"""Scan `search_path` for distributions usable in this environment
Any distributions found are added to the environment.
`search_path` should be a sequence of ``sys.path`` items. If not
supplied, ``sys.path`` is used. Only distributions conforming to
... | [
"def",
"scan",
"(",
"self",
",",
"search_path",
"=",
"None",
")",
":",
"if",
"search_path",
"is",
"None",
":",
"search_path",
"=",
"sys",
".",
"path",
"for",
"item",
"in",
"search_path",
":",
"for",
"dist",
"in",
"find_distributions",
"(",
"item",
")",
... | [
987,
4
] | [
1000,
30
] | python | en | ['en', 'en', 'en'] | True |
Environment.__getitem__ | (self, project_name) | Return a newest-to-oldest list of distributions for `project_name`
Uses case-insensitive `project_name` comparison, assuming all the
project's distributions use their project's name converted to all
lowercase as their key.
| Return a newest-to-oldest list of distributions for `project_name` | def __getitem__(self, project_name):
"""Return a newest-to-oldest list of distributions for `project_name`
Uses case-insensitive `project_name` comparison, assuming all the
project's distributions use their project's name converted to all
lowercase as their key.
"""
dis... | [
"def",
"__getitem__",
"(",
"self",
",",
"project_name",
")",
":",
"distribution_key",
"=",
"project_name",
".",
"lower",
"(",
")",
"return",
"self",
".",
"_distmap",
".",
"get",
"(",
"distribution_key",
",",
"[",
"]",
")"
] | [
1002,
4
] | [
1011,
54
] | python | en | ['en', 'en', 'en'] | True |
Environment.add | (self, dist) | Add `dist` if we ``can_add()`` it and it has not already been added
| Add `dist` if we ``can_add()`` it and it has not already been added
| def add(self, dist):
"""Add `dist` if we ``can_add()`` it and it has not already been added
"""
if self.can_add(dist) and dist.has_version():
dists = self._distmap.setdefault(dist.key, [])
if dist not in dists:
dists.append(dist)
dists.sort... | [
"def",
"add",
"(",
"self",
",",
"dist",
")",
":",
"if",
"self",
".",
"can_add",
"(",
"dist",
")",
"and",
"dist",
".",
"has_version",
"(",
")",
":",
"dists",
"=",
"self",
".",
"_distmap",
".",
"setdefault",
"(",
"dist",
".",
"key",
",",
"[",
"]",
... | [
1013,
4
] | [
1020,
76
] | python | en | ['en', 'en', 'en'] | True |
Environment.best_match | (
self, req, working_set, installer=None, replace_conflicting=False) | Find distribution best matching `req` and usable on `working_set`
This calls the ``find(req)`` method of the `working_set` to see if a
suitable distribution is already active. (This may raise
``VersionConflict`` if an unsuitable version of the project is already
active in the specified... | Find distribution best matching `req` and usable on `working_set` | def best_match(
self, req, working_set, installer=None, replace_conflicting=False):
"""Find distribution best matching `req` and usable on `working_set`
This calls the ``find(req)`` method of the `working_set` to see if a
suitable distribution is already active. (This may raise
... | [
"def",
"best_match",
"(",
"self",
",",
"req",
",",
"working_set",
",",
"installer",
"=",
"None",
",",
"replace_conflicting",
"=",
"False",
")",
":",
"try",
":",
"dist",
"=",
"working_set",
".",
"find",
"(",
"req",
")",
"except",
"VersionConflict",
":",
"... | [
1022,
4
] | [
1048,
42
] | python | en | ['en', 'en', 'en'] | True |
Environment.obtain | (self, requirement, installer=None) | Obtain a distribution matching `requirement` (e.g. via download)
Obtain a distro that matches requirement (e.g. via download). In the
base ``Environment`` class, this routine just returns
``installer(requirement)``, unless `installer` is None, in which case
None is returned instead. T... | Obtain a distribution matching `requirement` (e.g. via download) | def obtain(self, requirement, installer=None):
"""Obtain a distribution matching `requirement` (e.g. via download)
Obtain a distro that matches requirement (e.g. via download). In the
base ``Environment`` class, this routine just returns
``installer(requirement)``, unless `installer` i... | [
"def",
"obtain",
"(",
"self",
",",
"requirement",
",",
"installer",
"=",
"None",
")",
":",
"if",
"installer",
"is",
"not",
"None",
":",
"return",
"installer",
"(",
"requirement",
")"
] | [
1050,
4
] | [
1060,
41
] | python | en | ['it', 'en', 'en'] | True |
Environment.__iter__ | (self) | Yield the unique project names of the available distributions | Yield the unique project names of the available distributions | def __iter__(self):
"""Yield the unique project names of the available distributions"""
for key in self._distmap.keys():
if self[key]:
yield key | [
"def",
"__iter__",
"(",
"self",
")",
":",
"for",
"key",
"in",
"self",
".",
"_distmap",
".",
"keys",
"(",
")",
":",
"if",
"self",
"[",
"key",
"]",
":",
"yield",
"key"
] | [
1062,
4
] | [
1066,
25
] | python | en | ['en', 'en', 'en'] | True |
Environment.__iadd__ | (self, other) | In-place addition of a distribution or environment | In-place addition of a distribution or environment | def __iadd__(self, other):
"""In-place addition of a distribution or environment"""
if isinstance(other, Distribution):
self.add(other)
elif isinstance(other, Environment):
for project in other:
for dist in other[project]:
self.add(dist... | [
"def",
"__iadd__",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"Distribution",
")",
":",
"self",
".",
"add",
"(",
"other",
")",
"elif",
"isinstance",
"(",
"other",
",",
"Environment",
")",
":",
"for",
"project",
"in",
... | [
1068,
4
] | [
1078,
19
] | python | en | ['en', 'en', 'en'] | True |
Environment.__add__ | (self, other) | Add an environment or distribution to an environment | Add an environment or distribution to an environment | def __add__(self, other):
"""Add an environment or distribution to an environment"""
new = self.__class__([], platform=None, python=None)
for env in self, other:
new += env
return new | [
"def",
"__add__",
"(",
"self",
",",
"other",
")",
":",
"new",
"=",
"self",
".",
"__class__",
"(",
"[",
"]",
",",
"platform",
"=",
"None",
",",
"python",
"=",
"None",
")",
"for",
"env",
"in",
"self",
",",
"other",
":",
"new",
"+=",
"env",
"return"... | [
1080,
4
] | [
1085,
18
] | python | en | ['en', 'en', 'en'] | True |
ResourceManager.resource_exists | (self, package_or_requirement, resource_name) | Does the named resource exist? | Does the named resource exist? | def resource_exists(self, package_or_requirement, resource_name):
"""Does the named resource exist?"""
return get_provider(package_or_requirement).has_resource(resource_name) | [
"def",
"resource_exists",
"(",
"self",
",",
"package_or_requirement",
",",
"resource_name",
")",
":",
"return",
"get_provider",
"(",
"package_or_requirement",
")",
".",
"has_resource",
"(",
"resource_name",
")"
] | [
1115,
4
] | [
1117,
79
] | python | en | ['en', 'en', 'en'] | True |
ResourceManager.resource_isdir | (self, package_or_requirement, resource_name) | Is the named resource an existing directory? | Is the named resource an existing directory? | def resource_isdir(self, package_or_requirement, resource_name):
"""Is the named resource an existing directory?"""
return get_provider(package_or_requirement).resource_isdir(
resource_name
) | [
"def",
"resource_isdir",
"(",
"self",
",",
"package_or_requirement",
",",
"resource_name",
")",
":",
"return",
"get_provider",
"(",
"package_or_requirement",
")",
".",
"resource_isdir",
"(",
"resource_name",
")"
] | [
1119,
4
] | [
1123,
9
] | python | en | ['en', 'en', 'en'] | True |
ResourceManager.resource_filename | (self, package_or_requirement, resource_name) | Return a true filesystem path for specified resource | Return a true filesystem path for specified resource | def resource_filename(self, package_or_requirement, resource_name):
"""Return a true filesystem path for specified resource"""
return get_provider(package_or_requirement).get_resource_filename(
self, resource_name
) | [
"def",
"resource_filename",
"(",
"self",
",",
"package_or_requirement",
",",
"resource_name",
")",
":",
"return",
"get_provider",
"(",
"package_or_requirement",
")",
".",
"get_resource_filename",
"(",
"self",
",",
"resource_name",
")"
] | [
1125,
4
] | [
1129,
9
] | python | en | ['en', 'en', 'en'] | True |
ResourceManager.resource_stream | (self, package_or_requirement, resource_name) | Return a readable file-like object for specified resource | Return a readable file-like object for specified resource | def resource_stream(self, package_or_requirement, resource_name):
"""Return a readable file-like object for specified resource"""
return get_provider(package_or_requirement).get_resource_stream(
self, resource_name
) | [
"def",
"resource_stream",
"(",
"self",
",",
"package_or_requirement",
",",
"resource_name",
")",
":",
"return",
"get_provider",
"(",
"package_or_requirement",
")",
".",
"get_resource_stream",
"(",
"self",
",",
"resource_name",
")"
] | [
1131,
4
] | [
1135,
9
] | python | en | ['en', 'en', 'en'] | True |
ResourceManager.resource_string | (self, package_or_requirement, resource_name) | Return specified resource as a string | Return specified resource as a string | def resource_string(self, package_or_requirement, resource_name):
"""Return specified resource as a string"""
return get_provider(package_or_requirement).get_resource_string(
self, resource_name
) | [
"def",
"resource_string",
"(",
"self",
",",
"package_or_requirement",
",",
"resource_name",
")",
":",
"return",
"get_provider",
"(",
"package_or_requirement",
")",
".",
"get_resource_string",
"(",
"self",
",",
"resource_name",
")"
] | [
1137,
4
] | [
1141,
9
] | python | en | ['en', 'en', 'en'] | True |
ResourceManager.resource_listdir | (self, package_or_requirement, resource_name) | List the contents of the named resource directory | List the contents of the named resource directory | def resource_listdir(self, package_or_requirement, resource_name):
"""List the contents of the named resource directory"""
return get_provider(package_or_requirement).resource_listdir(
resource_name
) | [
"def",
"resource_listdir",
"(",
"self",
",",
"package_or_requirement",
",",
"resource_name",
")",
":",
"return",
"get_provider",
"(",
"package_or_requirement",
")",
".",
"resource_listdir",
"(",
"resource_name",
")"
] | [
1143,
4
] | [
1147,
9
] | python | en | ['en', 'en', 'en'] | True |
ResourceManager.extraction_error | (self) | Give an error message for problems extracting file(s) | Give an error message for problems extracting file(s) | def extraction_error(self):
"""Give an error message for problems extracting file(s)"""
old_exc = sys.exc_info()[1]
cache_path = self.extraction_path or get_default_cache()
tmpl = textwrap.dedent("""
Can't extract file(s) to egg cache
The following error occurr... | [
"def",
"extraction_error",
"(",
"self",
")",
":",
"old_exc",
"=",
"sys",
".",
"exc_info",
"(",
")",
"[",
"1",
"]",
"cache_path",
"=",
"self",
".",
"extraction_path",
"or",
"get_default_cache",
"(",
")",
"tmpl",
"=",
"textwrap",
".",
"dedent",
"(",
"\"\"\... | [
1149,
4
] | [
1175,
17
] | python | en | ['en', 'en', 'en'] | True |
ResourceManager.get_cache_path | (self, archive_name, names=()) | Return absolute location in cache for `archive_name` and `names`
The parent directory of the resulting path will be created if it does
not already exist. `archive_name` should be the base filename of the
enclosing egg (which may not be the name of the enclosing zipfile!),
including its... | Return absolute location in cache for `archive_name` and `names` | def get_cache_path(self, archive_name, names=()):
"""Return absolute location in cache for `archive_name` and `names`
The parent directory of the resulting path will be created if it does
not already exist. `archive_name` should be the base filename of the
enclosing egg (which may not ... | [
"def",
"get_cache_path",
"(",
"self",
",",
"archive_name",
",",
"names",
"=",
"(",
")",
")",
":",
"extract_path",
"=",
"self",
".",
"extraction_path",
"or",
"get_default_cache",
"(",
")",
"target_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"extract_pa... | [
1177,
4
] | [
1200,
26
] | python | en | ['en', 'en', 'en'] | True |
ResourceManager._warn_unsafe_extraction_path | (path) |
If the default extraction path is overridden and set to an insecure
location, such as /tmp, it opens up an opportunity for an attacker to
replace an extracted file with an unauthorized payload. Warn the user
if a known insecure location is used.
See Distribute #375 for more det... |
If the default extraction path is overridden and set to an insecure
location, such as /tmp, it opens up an opportunity for an attacker to
replace an extracted file with an unauthorized payload. Warn the user
if a known insecure location is used. | def _warn_unsafe_extraction_path(path):
"""
If the default extraction path is overridden and set to an insecure
location, such as /tmp, it opens up an opportunity for an attacker to
replace an extracted file with an unauthorized payload. Warn the user
if a known insecure location... | [
"def",
"_warn_unsafe_extraction_path",
"(",
"path",
")",
":",
"if",
"os",
".",
"name",
"==",
"'nt'",
"and",
"not",
"path",
".",
"startswith",
"(",
"os",
".",
"environ",
"[",
"'windir'",
"]",
")",
":",
"# On Windows, permissions are generally restrictive by default... | [
1203,
4
] | [
1227,
43
] | python | en | ['en', 'error', 'th'] | False |
ResourceManager.postprocess | (self, tempname, filename) | Perform any platform-specific postprocessing of `tempname`
This is where Mac header rewrites should be done; other platforms don't
have anything special they should do.
Resource providers should call this method ONLY after successfully
extracting a compressed resource. They must NOT c... | Perform any platform-specific postprocessing of `tempname` | def postprocess(self, tempname, filename):
"""Perform any platform-specific postprocessing of `tempname`
This is where Mac header rewrites should be done; other platforms don't
have anything special they should do.
Resource providers should call this method ONLY after successfully
... | [
"def",
"postprocess",
"(",
"self",
",",
"tempname",
",",
"filename",
")",
":",
"if",
"os",
".",
"name",
"==",
"'posix'",
":",
"# Make the resource executable",
"mode",
"=",
"(",
"(",
"os",
".",
"stat",
"(",
"tempname",
")",
".",
"st_mode",
")",
"|",
"0... | [
1229,
4
] | [
1247,
36
] | python | en | ['en', 'en', 'en'] | True |
ResourceManager.set_extraction_path | (self, path) | Set the base path where resources will be extracted to, if needed.
If you do not call this routine before any extractions take place, the
path defaults to the return value of ``get_default_cache()``. (Which
is based on the ``PYTHON_EGG_CACHE`` environment variable, with various
platfor... | Set the base path where resources will be extracted to, if needed. | def set_extraction_path(self, path):
"""Set the base path where resources will be extracted to, if needed.
If you do not call this routine before any extractions take place, the
path defaults to the return value of ``get_default_cache()``. (Which
is based on the ``PYTHON_EGG_CACHE`` en... | [
"def",
"set_extraction_path",
"(",
"self",
",",
"path",
")",
":",
"if",
"self",
".",
"cached_files",
":",
"raise",
"ValueError",
"(",
"\"Can't change extraction path, files already extracted\"",
")",
"self",
".",
"extraction_path",
"=",
"path"
] | [
1249,
4
] | [
1273,
35
] | python | en | ['en', 'en', 'en'] | True |
ResourceManager.cleanup_resources | (self, force=False) |
Delete all extracted resource files and directories, returning a list
of the file and directory names that could not be successfully removed.
This function does not have any concurrency protection, so it should
generally only be called when the extraction path is a temporary
dir... |
Delete all extracted resource files and directories, returning a list
of the file and directory names that could not be successfully removed.
This function does not have any concurrency protection, so it should
generally only be called when the extraction path is a temporary
dir... | def cleanup_resources(self, force=False):
"""
Delete all extracted resource files and directories, returning a list
of the file and directory names that could not be successfully removed.
This function does not have any concurrency protection, so it should
generally only be calle... | [
"def",
"cleanup_resources",
"(",
"self",
",",
"force",
"=",
"False",
")",
":"
] | [
1275,
4
] | [
1285,
11
] | python | en | ['en', 'error', 'th'] | False |
NullProvider._validate_resource_path | (path) |
Validate the resource paths according to the docs.
https://setuptools.readthedocs.io/en/latest/pkg_resources.html#basic-resource-access
>>> warned = getfixture('recwarn')
>>> warnings.simplefilter('always')
>>> vrp = NullProvider._validate_resource_path
>>> vrp('foo/bar... |
Validate the resource paths according to the docs.
https://setuptools.readthedocs.io/en/latest/pkg_resources.html#basic-resource-access | def _validate_resource_path(path):
"""
Validate the resource paths according to the docs.
https://setuptools.readthedocs.io/en/latest/pkg_resources.html#basic-resource-access
>>> warned = getfixture('recwarn')
>>> warnings.simplefilter('always')
>>> vrp = NullProvider._v... | [
"def",
"_validate_resource_path",
"(",
"path",
")",
":",
"invalid",
"=",
"(",
"os",
".",
"path",
".",
"pardir",
"in",
"path",
".",
"split",
"(",
"posixpath",
".",
"sep",
")",
"or",
"posixpath",
".",
"isabs",
"(",
"path",
")",
"or",
"ntpath",
".",
"is... | [
1476,
4
] | [
1548,
9
] | python | en | ['en', 'error', 'th'] | False |
ZipManifests.build | (cls, path) |
Build a dictionary similar to the zipimport directory
caches, except instead of tuples, store ZipInfo objects.
Use a platform-specific path separator (os.sep) for the path keys
for compatibility with pypy on Windows.
|
Build a dictionary similar to the zipimport directory
caches, except instead of tuples, store ZipInfo objects. | def build(cls, path):
"""
Build a dictionary similar to the zipimport directory
caches, except instead of tuples, store ZipInfo objects.
Use a platform-specific path separator (os.sep) for the path keys
for compatibility with pypy on Windows.
"""
with zipfile.Zip... | [
"def",
"build",
"(",
"cls",
",",
"path",
")",
":",
"with",
"zipfile",
".",
"ZipFile",
"(",
"path",
")",
"as",
"zfile",
":",
"items",
"=",
"(",
"(",
"name",
".",
"replace",
"(",
"'/'",
",",
"os",
".",
"sep",
")",
",",
"zfile",
".",
"getinfo",
"(... | [
1648,
4
] | [
1664,
30
] | python | en | ['en', 'error', 'th'] | False |
MemoizedZipManifests.load | (self, path) |
Load a manifest at path or return a suitable manifest already loaded.
|
Load a manifest at path or return a suitable manifest already loaded.
| def load(self, path):
"""
Load a manifest at path or return a suitable manifest already loaded.
"""
path = os.path.normpath(path)
mtime = os.stat(path).st_mtime
if path not in self or self[path].mtime != mtime:
manifest = self.build(path)
self[pat... | [
"def",
"load",
"(",
"self",
",",
"path",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"normpath",
"(",
"path",
")",
"mtime",
"=",
"os",
".",
"stat",
"(",
"path",
")",
".",
"st_mtime",
"if",
"path",
"not",
"in",
"self",
"or",
"self",
"[",
"pat... | [
1675,
4
] | [
1686,
34
] | python | en | ['en', 'error', 'th'] | False |
ZipProvider._is_current | (self, file_path, zip_path) |
Return True if the file_path is current for this zip_path
|
Return True if the file_path is current for this zip_path
| def _is_current(self, file_path, zip_path):
"""
Return True if the file_path is current for this zip_path
"""
timestamp, size = self._get_date_and_size(self.zipinfo[zip_path])
if not os.path.isfile(file_path):
return False
stat = os.stat(file_path)
if ... | [
"def",
"_is_current",
"(",
"self",
",",
"file_path",
",",
"zip_path",
")",
":",
"timestamp",
",",
"size",
"=",
"self",
".",
"_get_date_and_size",
"(",
"self",
".",
"zipinfo",
"[",
"zip_path",
"]",
")",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"("... | [
1802,
4
] | [
1816,
44
] | python | en | ['en', 'error', 'th'] | False |
EggMetadata.__init__ | (self, importer) | Create a metadata provider from a zipimporter | Create a metadata provider from a zipimporter | def __init__(self, importer):
"""Create a metadata provider from a zipimporter"""
self.zip_pre = importer.archive + os.sep
self.loader = importer
if importer.prefix:
self.module_path = os.path.join(importer.archive, importer.prefix)
else:
self.module_path... | [
"def",
"__init__",
"(",
"self",
",",
"importer",
")",
":",
"self",
".",
"zip_pre",
"=",
"importer",
".",
"archive",
"+",
"os",
".",
"sep",
"self",
".",
"loader",
"=",
"importer",
"if",
"importer",
".",
"prefix",
":",
"self",
".",
"module_path",
"=",
... | [
1933,
4
] | [
1942,
28
] | python | en | ['en', 'en', 'en'] | True |
EntryPoint.load | (self, require=True, *args, **kwargs) |
Require packages for this EntryPoint, then resolve it.
|
Require packages for this EntryPoint, then resolve it.
| def load(self, require=True, *args, **kwargs):
"""
Require packages for this EntryPoint, then resolve it.
"""
if not require or args or kwargs:
warnings.warn(
"Parameters to load are deprecated. Call .resolve and "
".require separately.",
... | [
"def",
"load",
"(",
"self",
",",
"require",
"=",
"True",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"require",
"or",
"args",
"or",
"kwargs",
":",
"warnings",
".",
"warn",
"(",
"\"Parameters to load are deprecated. Call .resolve and \"... | [
2433,
4
] | [
2446,
29
] | python | en | ['en', 'error', 'th'] | False |
EntryPoint.resolve | (self) |
Resolve the entry point from its module and attrs.
|
Resolve the entry point from its module and attrs.
| def resolve(self):
"""
Resolve the entry point from its module and attrs.
"""
module = __import__(self.module_name, fromlist=['__name__'], level=0)
try:
return functools.reduce(getattr, self.attrs, module)
except AttributeError as exc:
raise Import... | [
"def",
"resolve",
"(",
"self",
")",
":",
"module",
"=",
"__import__",
"(",
"self",
".",
"module_name",
",",
"fromlist",
"=",
"[",
"'__name__'",
"]",
",",
"level",
"=",
"0",
")",
"try",
":",
"return",
"functools",
".",
"reduce",
"(",
"getattr",
",",
"... | [
2448,
4
] | [
2456,
48
] | python | en | ['en', 'error', 'th'] | False |
EntryPoint.parse | (cls, src, dist=None) | Parse a single entry point from string `src`
Entry point syntax follows the form::
name = some.module:some.attr [extra1, extra2]
The entry name and module name are required, but the ``:attrs`` and
``[extras]`` parts are optional
| Parse a single entry point from string `src` | def parse(cls, src, dist=None):
"""Parse a single entry point from string `src`
Entry point syntax follows the form::
name = some.module:some.attr [extra1, extra2]
The entry name and module name are required, but the ``:attrs`` and
``[extras]`` parts are optional
"... | [
"def",
"parse",
"(",
"cls",
",",
"src",
",",
"dist",
"=",
"None",
")",
":",
"m",
"=",
"cls",
".",
"pattern",
".",
"match",
"(",
"src",
")",
"if",
"not",
"m",
":",
"msg",
"=",
"\"EntryPoint must be in 'name=module:attrs [extras]' format\"",
"raise",
"ValueE... | [
2481,
4
] | [
2498,
67
] | python | en | ['en', 'en', 'en'] | True |
EntryPoint.parse_group | (cls, group, lines, dist=None) | Parse an entry point group | Parse an entry point group | def parse_group(cls, group, lines, dist=None):
"""Parse an entry point group"""
if not MODULE(group):
raise ValueError("Invalid group name", group)
this = {}
for line in yield_lines(lines):
ep = cls.parse(line, dist)
if ep.name in this:
... | [
"def",
"parse_group",
"(",
"cls",
",",
"group",
",",
"lines",
",",
"dist",
"=",
"None",
")",
":",
"if",
"not",
"MODULE",
"(",
"group",
")",
":",
"raise",
"ValueError",
"(",
"\"Invalid group name\"",
",",
"group",
")",
"this",
"=",
"{",
"}",
"for",
"l... | [
2510,
4
] | [
2520,
19
] | python | en | ['en', 'en', 'en'] | True |
EntryPoint.parse_map | (cls, data, dist=None) | Parse a map of entry point groups | Parse a map of entry point groups | def parse_map(cls, data, dist=None):
"""Parse a map of entry point groups"""
if isinstance(data, dict):
data = data.items()
else:
data = split_sections(data)
maps = {}
for group, lines in data:
if group is None:
if not lines:
... | [
"def",
"parse_map",
"(",
"cls",
",",
"data",
",",
"dist",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"dict",
")",
":",
"data",
"=",
"data",
".",
"items",
"(",
")",
"else",
":",
"data",
"=",
"split_sections",
"(",
"data",
")",
"m... | [
2523,
4
] | [
2539,
19
] | python | en | ['en', 'en', 'en'] | True |
Distribution._dep_map | (self) |
A map of extra to its list of (direct) requirements
for this distribution, including the null extra.
|
A map of extra to its list of (direct) requirements
for this distribution, including the null extra.
| def _dep_map(self):
"""
A map of extra to its list of (direct) requirements
for this distribution, including the null extra.
"""
try:
return self.__dep_map
except AttributeError:
self.__dep_map = self._filter_extras(self._build_dep_map())
r... | [
"def",
"_dep_map",
"(",
"self",
")",
":",
"try",
":",
"return",
"self",
".",
"__dep_map",
"except",
"AttributeError",
":",
"self",
".",
"__dep_map",
"=",
"self",
".",
"_filter_extras",
"(",
"self",
".",
"_build_dep_map",
"(",
")",
")",
"return",
"self",
... | [
2688,
4
] | [
2697,
29
] | python | en | ['en', 'error', 'th'] | False |
Distribution._filter_extras | (dm) |
Given a mapping of extras to dependencies, strip off
environment markers and filter out any dependencies
not matching the markers.
|
Given a mapping of extras to dependencies, strip off
environment markers and filter out any dependencies
not matching the markers.
| def _filter_extras(dm):
"""
Given a mapping of extras to dependencies, strip off
environment markers and filter out any dependencies
not matching the markers.
"""
for extra in list(filter(None, dm)):
new_extra = extra
reqs = dm.pop(extra)
... | [
"def",
"_filter_extras",
"(",
"dm",
")",
":",
"for",
"extra",
"in",
"list",
"(",
"filter",
"(",
"None",
",",
"dm",
")",
")",
":",
"new_extra",
"=",
"extra",
"reqs",
"=",
"dm",
".",
"pop",
"(",
"extra",
")",
"new_extra",
",",
"_",
",",
"marker",
"... | [
2700,
4
] | [
2719,
17
] | python | en | ['en', 'error', 'th'] | False |
Distribution.requires | (self, extras=()) | List of Requirements needed for this distro if `extras` are used | List of Requirements needed for this distro if `extras` are used | def requires(self, extras=()):
"""List of Requirements needed for this distro if `extras` are used"""
dm = self._dep_map
deps = []
deps.extend(dm.get(None, ()))
for ext in extras:
try:
deps.extend(dm[safe_extra(ext)])
except KeyError as e:
... | [
"def",
"requires",
"(",
"self",
",",
"extras",
"=",
"(",
")",
")",
":",
"dm",
"=",
"self",
".",
"_dep_map",
"deps",
"=",
"[",
"]",
"deps",
".",
"extend",
"(",
"dm",
".",
"get",
"(",
"None",
",",
"(",
")",
")",
")",
"for",
"ext",
"in",
"extras... | [
2728,
4
] | [
2740,
19
] | python | en | ['en', 'en', 'en'] | True |
Distribution._get_metadata_path_for_display | (self, name) |
Return the path to the given metadata file, if available.
|
Return the path to the given metadata file, if available.
| def _get_metadata_path_for_display(self, name):
"""
Return the path to the given metadata file, if available.
"""
try:
# We need to access _get_metadata_path() on the provider object
# directly rather than through this class's __getattr__()
# since _ge... | [
"def",
"_get_metadata_path_for_display",
"(",
"self",
",",
"name",
")",
":",
"try",
":",
"# We need to access _get_metadata_path() on the provider object",
"# directly rather than through this class's __getattr__()",
"# since _get_metadata_path() is marked private.",
"path",
"=",
"self... | [
2742,
4
] | [
2757,
19
] | python | en | ['en', 'error', 'th'] | False |
Distribution.activate | (self, path=None, replace=False) | Ensure distribution is importable on `path` (default=sys.path) | Ensure distribution is importable on `path` (default=sys.path) | def activate(self, path=None, replace=False):
"""Ensure distribution is importable on `path` (default=sys.path)"""
if path is None:
path = sys.path
self.insert_on(path, replace=replace)
if path is sys.path:
fixup_namespace_packages(self.location)
for p... | [
"def",
"activate",
"(",
"self",
",",
"path",
"=",
"None",
",",
"replace",
"=",
"False",
")",
":",
"if",
"path",
"is",
"None",
":",
"path",
"=",
"sys",
".",
"path",
"self",
".",
"insert_on",
"(",
"path",
",",
"replace",
"=",
"replace",
")",
"if",
... | [
2770,
4
] | [
2779,
42
] | python | en | ['en', 'en', 'en'] | True |
Distribution.egg_name | (self) | Return what this distribution's standard .egg filename should be | Return what this distribution's standard .egg filename should be | def egg_name(self):
"""Return what this distribution's standard .egg filename should be"""
filename = "%s-%s-py%s" % (
to_filename(self.project_name), to_filename(self.version),
self.py_version or PY_MAJOR
)
if self.platform:
filename += '-' + self.pl... | [
"def",
"egg_name",
"(",
"self",
")",
":",
"filename",
"=",
"\"%s-%s-py%s\"",
"%",
"(",
"to_filename",
"(",
"self",
".",
"project_name",
")",
",",
"to_filename",
"(",
"self",
".",
"version",
")",
",",
"self",
".",
"py_version",
"or",
"PY_MAJOR",
")",
"if"... | [
2781,
4
] | [
2790,
23
] | python | en | ['en', 'en', 'en'] | True |
Distribution.__getattr__ | (self, attr) | Delegate all unrecognized public attributes to .metadata provider | Delegate all unrecognized public attributes to .metadata provider | def __getattr__(self, attr):
"""Delegate all unrecognized public attributes to .metadata provider"""
if attr.startswith('_'):
raise AttributeError(attr)
return getattr(self._provider, attr) | [
"def",
"__getattr__",
"(",
"self",
",",
"attr",
")",
":",
"if",
"attr",
".",
"startswith",
"(",
"'_'",
")",
":",
"raise",
"AttributeError",
"(",
"attr",
")",
"return",
"getattr",
"(",
"self",
".",
"_provider",
",",
"attr",
")"
] | [
2806,
4
] | [
2810,
44
] | python | en | ['en', 'it', 'en'] | True |
Distribution.as_requirement | (self) | Return a ``Requirement`` that matches this distribution exactly | Return a ``Requirement`` that matches this distribution exactly | def as_requirement(self):
"""Return a ``Requirement`` that matches this distribution exactly"""
if isinstance(self.parsed_version, packaging.version.Version):
spec = "%s==%s" % (self.project_name, self.parsed_version)
else:
spec = "%s===%s" % (self.project_name, self.pars... | [
"def",
"as_requirement",
"(",
"self",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"parsed_version",
",",
"packaging",
".",
"version",
".",
"Version",
")",
":",
"spec",
"=",
"\"%s==%s\"",
"%",
"(",
"self",
".",
"project_name",
",",
"self",
".",
"parse... | [
2828,
4
] | [
2835,
38
] | python | en | ['en', 'en', 'en'] | True |
Distribution.load_entry_point | (self, group, name) | Return the `name` entry point of `group` or raise ImportError | Return the `name` entry point of `group` or raise ImportError | def load_entry_point(self, group, name):
"""Return the `name` entry point of `group` or raise ImportError"""
ep = self.get_entry_info(group, name)
if ep is None:
raise ImportError("Entry point %r not found" % ((group, name),))
return ep.load() | [
"def",
"load_entry_point",
"(",
"self",
",",
"group",
",",
"name",
")",
":",
"ep",
"=",
"self",
".",
"get_entry_info",
"(",
"group",
",",
"name",
")",
"if",
"ep",
"is",
"None",
":",
"raise",
"ImportError",
"(",
"\"Entry point %r not found\"",
"%",
"(",
"... | [
2837,
4
] | [
2842,
24
] | python | en | ['en', 'en', 'en'] | True |
Distribution.get_entry_map | (self, group=None) | Return the entry point map for `group`, or the full entry map | Return the entry point map for `group`, or the full entry map | def get_entry_map(self, group=None):
"""Return the entry point map for `group`, or the full entry map"""
try:
ep_map = self._ep_map
except AttributeError:
ep_map = self._ep_map = EntryPoint.parse_map(
self._get_metadata('entry_points.txt'), self
... | [
"def",
"get_entry_map",
"(",
"self",
",",
"group",
"=",
"None",
")",
":",
"try",
":",
"ep_map",
"=",
"self",
".",
"_ep_map",
"except",
"AttributeError",
":",
"ep_map",
"=",
"self",
".",
"_ep_map",
"=",
"EntryPoint",
".",
"parse_map",
"(",
"self",
".",
... | [
2844,
4
] | [
2854,
21
] | python | en | ['en', 'en', 'en'] | True |
Distribution.get_entry_info | (self, group, name) | Return the EntryPoint object for `group`+`name`, or ``None`` | Return the EntryPoint object for `group`+`name`, or ``None`` | def get_entry_info(self, group, name):
"""Return the EntryPoint object for `group`+`name`, or ``None``"""
return self.get_entry_map(group).get(name) | [
"def",
"get_entry_info",
"(",
"self",
",",
"group",
",",
"name",
")",
":",
"return",
"self",
".",
"get_entry_map",
"(",
"group",
")",
".",
"get",
"(",
"name",
")"
] | [
2856,
4
] | [
2858,
50
] | python | en | ['en', 'en', 'en'] | True |
Distribution.insert_on | (self, path, loc=None, replace=False) | Ensure self.location is on path
If replace=False (default):
- If location is already in path anywhere, do nothing.
- Else:
- If it's an egg and its parent directory is on path,
insert just ahead of the parent.
- Else: add to the end of path.
... | Ensure self.location is on path | def insert_on(self, path, loc=None, replace=False):
"""Ensure self.location is on path
If replace=False (default):
- If location is already in path anywhere, do nothing.
- Else:
- If it's an egg and its parent directory is on path,
insert just ahead... | [
"def",
"insert_on",
"(",
"self",
",",
"path",
",",
"loc",
"=",
"None",
",",
"replace",
"=",
"False",
")",
":",
"loc",
"=",
"loc",
"or",
"self",
".",
"location",
"if",
"not",
"loc",
":",
"return",
"nloc",
"=",
"_normalize_cached",
"(",
"loc",
")",
"... | [
2860,
4
] | [
2926,
14
] | python | en | ['en', 'en', 'en'] | True |
Distribution.clone | (self, **kw) | Copy this distribution, substituting in any changed keyword args | Copy this distribution, substituting in any changed keyword args | def clone(self, **kw):
"""Copy this distribution, substituting in any changed keyword args"""
names = 'project_name version py_version platform location precedence'
for attr in names.split():
kw.setdefault(attr, getattr(self, attr, None))
kw.setdefault('metadata', self._provi... | [
"def",
"clone",
"(",
"self",
",",
"*",
"*",
"kw",
")",
":",
"names",
"=",
"'project_name version py_version platform location precedence'",
"for",
"attr",
"in",
"names",
".",
"split",
"(",
")",
":",
"kw",
".",
"setdefault",
"(",
"attr",
",",
"getattr",
"(",
... | [
2958,
4
] | [
2964,
35
] | python | en | ['en', 'en', 'en'] | True |
EggInfoDistribution._reload_version | (self) |
Packages installed by distutils (e.g. numpy or scipy),
which uses an old safe_version, and so
their version numbers can get mangled when
converted to filenames (e.g., 1.11.0.dev0+2329eae to
1.11.0.dev0_2329eae). These distributions will not be
parsed properly
dow... |
Packages installed by distutils (e.g. numpy or scipy),
which uses an old safe_version, and so
their version numbers can get mangled when
converted to filenames (e.g., 1.11.0.dev0+2329eae to
1.11.0.dev0_2329eae). These distributions will not be
parsed properly
dow... | def _reload_version(self):
"""
Packages installed by distutils (e.g. numpy or scipy),
which uses an old safe_version, and so
their version numbers can get mangled when
converted to filenames (e.g., 1.11.0.dev0+2329eae to
1.11.0.dev0_2329eae). These distributions will not ... | [
"def",
"_reload_version",
"(",
"self",
")",
":",
"md_version",
"=",
"self",
".",
"_get_version",
"(",
")",
"if",
"md_version",
":",
"self",
".",
"_version",
"=",
"md_version",
"return",
"self"
] | [
2972,
4
] | [
2987,
19
] | python | en | ['en', 'error', 'th'] | False |
DefListIndentProcessor.create_item | (parent, block) | Create a new dd and parse the block with it as the parent. | Create a new dd and parse the block with it as the parent. | def create_item(parent, block):
""" Create a new dd and parse the block with it as the parent. """
dd = markdown.etree.SubElement(parent, 'dd')
self.parser.parseBlocks(dd, [block]) | [
"def",
"create_item",
"(",
"parent",
",",
"block",
")",
":",
"dd",
"=",
"markdown",
".",
"etree",
".",
"SubElement",
"(",
"parent",
",",
"'dd'",
")",
"self",
".",
"parser",
".",
"parseBlocks",
"(",
"dd",
",",
"[",
"block",
"]",
")"
] | [
81,
4
] | [
84,
44
] | python | en | ['en', 'en', 'en'] | True |
DefListExtension.extendMarkdown | (self, md, md_globals) | Add an instance of DefListProcessor to BlockParser. | Add an instance of DefListProcessor to BlockParser. | def extendMarkdown(self, md, md_globals):
""" Add an instance of DefListProcessor to BlockParser. """
md.parser.blockprocessors.add('defindent',
DefListIndentProcessor(md.parser),
'>indent')
md.parser.blockprocessors.add... | [
"def",
"extendMarkdown",
"(",
"self",
",",
"md",
",",
"md_globals",
")",
":",
"md",
".",
"parser",
".",
"blockprocessors",
".",
"add",
"(",
"'defindent'",
",",
"DefListIndentProcessor",
"(",
"md",
".",
"parser",
")",
",",
"'>indent'",
")",
"md",
".",
"pa... | [
91,
4
] | [
98,
47
] | python | en | ['en', 'de', 'en'] | True |
parse_file | (file) |
parse the file:
return sequence of (<location>, <article>, <word>) tuples
|
parse the file:
return sequence of (<location>, <article>, <word>) tuples
| def parse_file(file):
'''
parse the file:
return sequence of (<location>, <article>, <word>) tuples
'''
carry = ''
for i, line in enumerate(file, start=1):
cline = carry + line
carry = ''
for match in find_articles(cline):
art, word, eol_art = match.groups()
... | [
"def",
"parse_file",
"(",
"file",
")",
":",
"carry",
"=",
"''",
"for",
"i",
",",
"line",
"in",
"enumerate",
"(",
"file",
",",
"start",
"=",
"1",
")",
":",
"cline",
"=",
"carry",
"+",
"line",
"carry",
"=",
"''",
"for",
"match",
"in",
"find_articles"... | [
42,
0
] | [
58,
37
] | python | en | ['en', 'error', 'th'] | False |
aws_credentials | () | Mocked AWS Credentials for moto. | Mocked AWS Credentials for moto. | def aws_credentials():
"""Mocked AWS Credentials for moto."""
os.environ['AWS_ACCESS_KEY_ID'] = 'testing'
os.environ['AWS_SECRET_ACCESS_KEY'] = 'testing'
os.environ['AWS_SECURITY_TOKEN'] = 'testing'
os.environ['AWS_SESSION_TOKEN'] = 'testing' | [
"def",
"aws_credentials",
"(",
")",
":",
"os",
".",
"environ",
"[",
"'AWS_ACCESS_KEY_ID'",
"]",
"=",
"'testing'",
"os",
".",
"environ",
"[",
"'AWS_SECRET_ACCESS_KEY'",
"]",
"=",
"'testing'",
"os",
".",
"environ",
"[",
"'AWS_SECURITY_TOKEN'",
"]",
"=",
"'testin... | [
7,
0
] | [
12,
47
] | python | en | ['en', 'en', 'en'] | True |
test_create_dynamodb_table | (dynamodb) | Create Cloudwatch log group | Create Cloudwatch log group | def test_create_dynamodb_table(dynamodb):
"""Create Cloudwatch log group"""
pass | [
"def",
"test_create_dynamodb_table",
"(",
"dynamodb",
")",
":",
"pass"
] | [
21,
0
] | [
23,
8
] | python | en | ['en', 'tg', 'en'] | True |
Queue.is_closed | (self) | Not implemented. | Not implemented. | def is_closed(self):
"""Not implemented."""
return False | [
"def",
"is_closed",
"(",
"self",
")",
":",
"return",
"False"
] | [
16,
4
] | [
18,
20
] | python | en | ['en', 'en', 'en'] | False |
midi_file_to_melody | (midi_file, steps_per_quarter=4, qpm=None,
ignore_polyphonic_notes=True) | Loads a melody from a MIDI file.
Args:
midi_file: Absolute path to MIDI file.
steps_per_quarter: Quantization of Melody. For example, 4 = 16th notes.
qpm: Tempo in quarters per a minute. If not set, tries to use the first
tempo of the midi track and defaults to
note_seq.DEFAULT_QUARTERS_P... | Loads a melody from a MIDI file. | def midi_file_to_melody(midi_file, steps_per_quarter=4, qpm=None,
ignore_polyphonic_notes=True):
"""Loads a melody from a MIDI file.
Args:
midi_file: Absolute path to MIDI file.
steps_per_quarter: Quantization of Melody. For example, 4 = 16th notes.
qpm: Tempo in quarters per a ... | [
"def",
"midi_file_to_melody",
"(",
"midi_file",
",",
"steps_per_quarter",
"=",
"4",
",",
"qpm",
"=",
"None",
",",
"ignore_polyphonic_notes",
"=",
"True",
")",
":",
"sequence",
"=",
"midi_io",
".",
"midi_file_to_sequence_proto",
"(",
"midi_file",
")",
"if",
"qpm"... | [
524,
0
] | [
550,
15
] | python | en | ['en', 'en', 'en'] | True |
Melody.__init__ | (self, events=None, **kwargs) | Construct a Melody. | Construct a Melody. | def __init__(self, events=None, **kwargs):
"""Construct a Melody."""
if 'pad_event' in kwargs:
del kwargs['pad_event']
super(Melody, self).__init__(pad_event=MELODY_NO_EVENT,
events=events, **kwargs) | [
"def",
"__init__",
"(",
"self",
",",
"events",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'pad_event'",
"in",
"kwargs",
":",
"del",
"kwargs",
"[",
"'pad_event'",
"]",
"super",
"(",
"Melody",
",",
"self",
")",
".",
"__init__",
"(",
"pad_ev... | [
92,
2
] | [
97,
57
] | python | en | ['en', 'en', 'en'] | True |
Melody._from_event_list | (self, events, start_step=0,
steps_per_bar=DEFAULT_STEPS_PER_BAR,
steps_per_quarter=DEFAULT_STEPS_PER_QUARTER) | Initializes with a list of event values and sets attributes.
Args:
events: List of Melody events to set melody to.
start_step: The integer starting step offset.
steps_per_bar: The number of steps in a bar.
steps_per_quarter: The number of steps in a quarter note.
Raises:
ValueErr... | Initializes with a list of event values and sets attributes. | def _from_event_list(self, events, start_step=0,
steps_per_bar=DEFAULT_STEPS_PER_BAR,
steps_per_quarter=DEFAULT_STEPS_PER_QUARTER):
"""Initializes with a list of event values and sets attributes.
Args:
events: List of Melody events to set melody to.
sta... | [
"def",
"_from_event_list",
"(",
"self",
",",
"events",
",",
"start_step",
"=",
"0",
",",
"steps_per_bar",
"=",
"DEFAULT_STEPS_PER_BAR",
",",
"steps_per_quarter",
"=",
"DEFAULT_STEPS_PER_QUARTER",
")",
":",
"for",
"event",
"in",
"events",
":",
"if",
"not",
"MIN_M... | [
99,
2
] | [
125,
44
] | python | en | ['en', 'en', 'en'] | True |
Melody._add_note | (self, pitch, start_step, end_step) | Adds the given note to the `events` list.
`start_step` is set to the given pitch. `end_step` is set to NOTE_OFF.
Everything after `start_step` in `events` is deleted before the note is
added. `events`'s length will be changed so that the last event has index
`end_step`.
Args:
pitch: Midi pit... | Adds the given note to the `events` list. | def _add_note(self, pitch, start_step, end_step):
"""Adds the given note to the `events` list.
`start_step` is set to the given pitch. `end_step` is set to NOTE_OFF.
Everything after `start_step` in `events` is deleted before the note is
added. `events`'s length will be changed so that the last event h... | [
"def",
"_add_note",
"(",
"self",
",",
"pitch",
",",
"start_step",
",",
"end_step",
")",
":",
"if",
"start_step",
">=",
"end_step",
":",
"raise",
"BadNoteError",
"(",
"'Start step does not precede end step: start=%d, end=%d'",
"%",
"(",
"start_step",
",",
"end_step",... | [
127,
2
] | [
155,
39
] | python | en | ['en', 'en', 'en'] | True |
Melody._get_last_on_off_events | (self) | Returns indexes of the most recent pitch and NOTE_OFF events.
Returns:
A tuple (start_step, end_step) of the last note's on and off event
indices.
Raises:
ValueError: If `events` contains no NOTE_OFF or pitch events.
| Returns indexes of the most recent pitch and NOTE_OFF events. | def _get_last_on_off_events(self):
"""Returns indexes of the most recent pitch and NOTE_OFF events.
Returns:
A tuple (start_step, end_step) of the last note's on and off event
indices.
Raises:
ValueError: If `events` contains no NOTE_OFF or pitch events.
"""
last_off = len(se... | [
"def",
"_get_last_on_off_events",
"(",
"self",
")",
":",
"last_off",
"=",
"len",
"(",
"self",
")",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"self",
")",
"-",
"1",
",",
"-",
"1",
",",
"-",
"1",
")",
":",
"if",
"self",
".",
"_events",
"[",
"i"... | [
157,
2
] | [
173,
47
] | python | en | ['en', 'en', 'en'] | True |
Melody.get_note_histogram | (self) | Gets a histogram of the note occurrences in a melody.
Returns:
A list of 12 ints, one for each note value (C at index 0 through B at
index 11). Each int is the total number of times that note occurred in
the melody.
| Gets a histogram of the note occurrences in a melody. | def get_note_histogram(self):
"""Gets a histogram of the note occurrences in a melody.
Returns:
A list of 12 ints, one for each note value (C at index 0 through B at
index 11). Each int is the total number of times that note occurred in
the melody.
"""
np_melody = np.array(self._event... | [
"def",
"get_note_histogram",
"(",
"self",
")",
":",
"np_melody",
"=",
"np",
".",
"array",
"(",
"self",
".",
"_events",
",",
"dtype",
"=",
"int",
")",
"return",
"np",
".",
"bincount",
"(",
"np_melody",
"[",
"np_melody",
">=",
"MIN_MIDI_PITCH",
"]",
"%",
... | [
175,
2
] | [
186,
50
] | python | en | ['en', 'en', 'en'] | True |
Melody.get_major_key_histogram | (self) | Gets a histogram of the how many notes fit into each key.
Returns:
A list of 12 ints, one for each Major key (C Major at index 0 through
B Major at index 11). Each int is the total number of notes that could
fit into that key.
| Gets a histogram of the how many notes fit into each key. | def get_major_key_histogram(self):
"""Gets a histogram of the how many notes fit into each key.
Returns:
A list of 12 ints, one for each Major key (C Major at index 0 through
B Major at index 11). Each int is the total number of notes that could
fit into that key.
"""
note_histogram =... | [
"def",
"get_major_key_histogram",
"(",
"self",
")",
":",
"note_histogram",
"=",
"self",
".",
"get_note_histogram",
"(",
")",
"key_histogram",
"=",
"np",
".",
"zeros",
"(",
"NOTES_PER_OCTAVE",
")",
"for",
"note",
",",
"count",
"in",
"enumerate",
"(",
"note_hist... | [
188,
2
] | [
200,
24
] | python | en | ['en', 'en', 'en'] | True |
Melody.get_major_key | (self) | Finds the major key that this melody most likely belongs to.
If multiple keys match equally, the key with the lowest index is returned,
where the indexes of the keys are C Major = 0 through B Major = 11.
Returns:
An int for the most likely key (C Major = 0 through B Major = 11)
| Finds the major key that this melody most likely belongs to. | def get_major_key(self):
"""Finds the major key that this melody most likely belongs to.
If multiple keys match equally, the key with the lowest index is returned,
where the indexes of the keys are C Major = 0 through B Major = 11.
Returns:
An int for the most likely key (C Major = 0 through B M... | [
"def",
"get_major_key",
"(",
"self",
")",
":",
"key_histogram",
"=",
"self",
".",
"get_major_key_histogram",
"(",
")",
"return",
"key_histogram",
".",
"argmax",
"(",
")"
] | [
202,
2
] | [
212,
33
] | python | en | ['en', 'en', 'en'] | True |
Melody.append | (self, event) | Appends the event to the end of the melody and increments the end step.
An implicit NOTE_OFF at the end of the melody will not be respected by this
modification.
Args:
event: The integer Melody event to append to the end.
Raises:
ValueError: If `event` is not in the proper range.
| Appends the event to the end of the melody and increments the end step. | def append(self, event):
"""Appends the event to the end of the melody and increments the end step.
An implicit NOTE_OFF at the end of the melody will not be respected by this
modification.
Args:
event: The integer Melody event to append to the end.
Raises:
ValueError: If `event` is no... | [
"def",
"append",
"(",
"self",
",",
"event",
")",
":",
"if",
"not",
"MIN_MELODY_EVENT",
"<=",
"event",
"<=",
"MAX_MELODY_EVENT",
":",
"raise",
"ValueError",
"(",
"'Event out of range: %d'",
"%",
"event",
")",
"super",
"(",
"Melody",
",",
"self",
")",
".",
"... | [
214,
2
] | [
227,
37
] | python | en | ['en', 'en', 'en'] | True |
Melody.from_quantized_sequence | (self,
quantized_sequence,
search_start_step=0,
instrument=0,
gap_bars=1,
ignore_polyphonic_notes=False,
pad_end=False,
... | Populate self with a melody from the given quantized NoteSequence.
A monophonic melody is extracted from the given `instrument` starting at
`search_start_step`. `instrument` and `search_start_step` can be used to
drive extraction of multiple melodies from the same quantized sequence. The
end step of th... | Populate self with a melody from the given quantized NoteSequence. | def from_quantized_sequence(self,
quantized_sequence,
search_start_step=0,
instrument=0,
gap_bars=1,
ignore_polyphonic_notes=False,
pad_end=... | [
"def",
"from_quantized_sequence",
"(",
"self",
",",
"quantized_sequence",
",",
"search_start_step",
"=",
"0",
",",
"instrument",
"=",
"0",
",",
"gap_bars",
"=",
"1",
",",
"ignore_polyphonic_notes",
"=",
"False",
",",
"pad_end",
"=",
"False",
",",
"filter_drums",... | [
229,
2
] | [
361,
27
] | python | en | ['en', 'en', 'en'] | True |
Melody.to_sequence | (self,
velocity=100,
instrument=0,
program=0,
sequence_start_time=0.0,
qpm=120.0) | Converts the Melody to NoteSequence proto.
The end of the melody is treated as a NOTE_OFF event for any sustained
notes.
Args:
velocity: Midi velocity to give each note. Between 1 and 127 (inclusive).
instrument: Midi instrument to give each note.
program: Midi program to give each note.... | Converts the Melody to NoteSequence proto. | def to_sequence(self,
velocity=100,
instrument=0,
program=0,
sequence_start_time=0.0,
qpm=120.0):
"""Converts the Melody to NoteSequence proto.
The end of the melody is treated as a NOTE_OFF event for any sustained
no... | [
"def",
"to_sequence",
"(",
"self",
",",
"velocity",
"=",
"100",
",",
"instrument",
"=",
"0",
",",
"program",
"=",
"0",
",",
"sequence_start_time",
"=",
"0.0",
",",
"qpm",
"=",
"120.0",
")",
":",
"seconds_per_step",
"=",
"60.0",
"/",
"qpm",
"/",
"self",... | [
363,
2
] | [
424,
19
] | python | en | ['en', 'en', 'en'] | True |
Melody.transpose | (self, transpose_amount, min_note=0, max_note=128) | Transpose notes in this Melody.
All notes are transposed the specified amount. Additionally, all notes
are octave shifted to lie within the [min_note, max_note) range.
Args:
transpose_amount: The number of half steps to transpose this Melody.
Positive values transpose up. Negative values t... | Transpose notes in this Melody. | def transpose(self, transpose_amount, min_note=0, max_note=128):
"""Transpose notes in this Melody.
All notes are transposed the specified amount. Additionally, all notes
are octave shifted to lie within the [min_note, max_note) range.
Args:
transpose_amount: The number of half steps to transpos... | [
"def",
"transpose",
"(",
"self",
",",
"transpose_amount",
",",
"min_note",
"=",
"0",
",",
"max_note",
"=",
"128",
")",
":",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"self",
")",
")",
":",
"# Transpose MIDI pitches. Special events below MIN_MIDI_PITCH are not"... | [
426,
2
] | [
448,
77
] | python | en | ['en', 'en', 'en'] | True |
Melody.squash | (self, min_note, max_note, transpose_to_key=None) | Transpose and octave shift the notes in this Melody.
The key center of this melody is computed with a heuristic, and the notes
are transposed to be in the given key. The melody is also octave shifted
to be centered in the given range. Additionally, all notes are octave
shifted to lie within a given ran... | Transpose and octave shift the notes in this Melody. | def squash(self, min_note, max_note, transpose_to_key=None):
"""Transpose and octave shift the notes in this Melody.
The key center of this melody is computed with a heuristic, and the notes
are transposed to be in the given key. The melody is also octave shifted
to be centered in the given range. Addi... | [
"def",
"squash",
"(",
"self",
",",
"min_note",
",",
"max_note",
",",
"transpose_to_key",
"=",
"None",
")",
":",
"if",
"transpose_to_key",
"is",
"None",
":",
"transpose_amount",
"=",
"0",
"else",
":",
"melody_key",
"=",
"self",
".",
"get_major_key",
"(",
")... | [
450,
2
] | [
486,
27
] | python | en | ['en', 'en', 'en'] | True |
Melody.set_length | (self, steps, from_left=False) | Sets the length of the melody to the specified number of steps.
If the melody is not long enough, ends any sustained notes and adds NO_EVENT
steps for padding. If it is too long, it will be truncated to the requested
length.
Args:
steps: How many steps long the melody should be.
from_left:... | Sets the length of the melody to the specified number of steps. | def set_length(self, steps, from_left=False):
"""Sets the length of the melody to the specified number of steps.
If the melody is not long enough, ends any sustained notes and adds NO_EVENT
steps for padding. If it is too long, it will be truncated to the requested
length.
Args:
steps: How m... | [
"def",
"set_length",
"(",
"self",
",",
"steps",
",",
"from_left",
"=",
"False",
")",
":",
"old_len",
"=",
"len",
"(",
"self",
")",
"super",
"(",
"Melody",
",",
"self",
")",
".",
"set_length",
"(",
"steps",
",",
"from_left",
"=",
"from_left",
")",
"if... | [
488,
2
] | [
508,
15
] | python | en | ['en', 'en', 'en'] | True |
Melody.increase_resolution | (self, k) | Increase the resolution of a Melody.
Increases the resolution of a Melody object by a factor of `k`. This uses
MELODY_NO_EVENT to extend each event in the melody to be `k` steps long.
Args:
k: An integer, the factor by which to increase the resolution of the
melody.
| Increase the resolution of a Melody. | def increase_resolution(self, k):
"""Increase the resolution of a Melody.
Increases the resolution of a Melody object by a factor of `k`. This uses
MELODY_NO_EVENT to extend each event in the melody to be `k` steps long.
Args:
k: An integer, the factor by which to increase the resolution of the
... | [
"def",
"increase_resolution",
"(",
"self",
",",
"k",
")",
":",
"super",
"(",
"Melody",
",",
"self",
")",
".",
"increase_resolution",
"(",
"k",
",",
"fill_event",
"=",
"MELODY_NO_EVENT",
")"
] | [
510,
2
] | [
521,
38
] | python | en | ['en', 'en', 'en'] | True |
Ideone._transform_to_dict | (result) |
Transform the array from Ideone into a Python dictionary.
|
Transform the array from Ideone into a Python dictionary.
| def _transform_to_dict(result):
"""
Transform the array from Ideone into a Python dictionary.
"""
result_dict = {}
property_list = result.item
for item in property_list:
result_dict[item.key[0]] = item.value[0]
return result_dict | [
"def",
"_transform_to_dict",
"(",
"result",
")",
":",
"result_dict",
"=",
"{",
"}",
"property_list",
"=",
"result",
".",
"item",
"for",
"item",
"in",
"property_list",
":",
"result_dict",
"[",
"item",
".",
"key",
"[",
"0",
"]",
"]",
"=",
"item",
".",
"v... | [
38,
4
] | [
46,
26
] | python | en | ['en', 'error', 'th'] | False |
Ideone._handle_error | (result_dict) |
Raise an exception if the Ideone gave us an error.
|
Raise an exception if the Ideone gave us an error.
| def _handle_error(result_dict):
"""
Raise an exception if the Ideone gave us an error.
"""
error = result_dict['error']
if error == Ideone.ERROR_OK:
return
else:
raise IdeoneError(error) | [
"def",
"_handle_error",
"(",
"result_dict",
")",
":",
"error",
"=",
"result_dict",
"[",
"'error'",
"]",
"if",
"error",
"==",
"Ideone",
".",
"ERROR_OK",
":",
"return",
"else",
":",
"raise",
"IdeoneError",
"(",
"error",
")"
] | [
49,
4
] | [
57,
36
] | python | en | ['en', 'error', 'th'] | False |
Ideone._collapse_language_array | (language_array) |
Convert the Ideone language list into a Python dictionary.
|
Convert the Ideone language list into a Python dictionary.
| def _collapse_language_array(language_array):
"""
Convert the Ideone language list into a Python dictionary.
"""
language_dict = {}
for language in language_array.item:
key = language.key[0]
value = language.value[0]
language_dict[key] = value
... | [
"def",
"_collapse_language_array",
"(",
"language_array",
")",
":",
"language_dict",
"=",
"{",
"}",
"for",
"language",
"in",
"language_array",
".",
"item",
":",
"key",
"=",
"language",
".",
"key",
"[",
"0",
"]",
"value",
"=",
"language",
".",
"value",
"[",... | [
60,
4
] | [
70,
28
] | python | en | ['en', 'error', 'th'] | False |
Ideone._translate_language_name | (self, language_name) |
Translate a human readable langauge name into its Ideone
integer representation.
Keyword Arguments
-----------------
* langauge_name: a string of the language (e.g. "c++")
Returns
-------
An integer representation of the language.
Notes
... |
Translate a human readable langauge name into its Ideone
integer representation. | def _translate_language_name(self, language_name):
"""
Translate a human readable langauge name into its Ideone
integer representation.
Keyword Arguments
-----------------
* langauge_name: a string of the language (e.g. "c++")
Returns
-------
A... | [
"def",
"_translate_language_name",
"(",
"self",
",",
"language_name",
")",
":",
"languages",
"=",
"self",
".",
"languages",
"(",
")",
"language_id",
"=",
"None",
"# Check for exact match first including the whole version",
"# string",
"for",
"ideone_index",
",",
"ideone... | [
72,
4
] | [
135,
81
] | python | en | ['en', 'error', 'th'] | False |
Ideone.create_submission | (self, source_code, language_name=None, language_id=None,
std_input="", run=True, private=False) |
Create a submission and upload it to Ideone.
Keyword Arguments
-----------------
* source_code: a string of the programs source code
* language_name: the human readable language string (e.g. 'python')
* language_id: the ID of the programming language
* std_inpu... |
Create a submission and upload it to Ideone. | def create_submission(self, source_code, language_name=None, language_id=None,
std_input="", run=True, private=False):
"""
Create a submission and upload it to Ideone.
Keyword Arguments
-----------------
* source_code: a string of the programs source c... | [
"def",
"create_submission",
"(",
"self",
",",
"source_code",
",",
"language_name",
"=",
"None",
",",
"language_id",
"=",
"None",
",",
"std_input",
"=",
"\"\"",
",",
"run",
"=",
"True",
",",
"private",
"=",
"False",
")",
":",
"language_id",
"=",
"language_i... | [
139,
4
] | [
177,
26
] | python | en | ['en', 'error', 'th'] | False |
Ideone.submission_status | (self, link) |
Given the unique link of a submission, returns its current
status.
Keyword Arguments
-----------------
* link: the unique id string of a submission
Returns
-------
A dictionary of the error, the result code and the status
code.
Notes
... |
Given the unique link of a submission, returns its current
status. | def submission_status(self, link):
"""
Given the unique link of a submission, returns its current
status.
Keyword Arguments
-----------------
* link: the unique id string of a submission
Returns
-------
A dictionary of the error, the result cod... | [
"def",
"submission_status",
"(",
"self",
",",
"link",
")",
":",
"result",
"=",
"self",
".",
"client",
".",
"service",
".",
"getSubmissionStatus",
"(",
"self",
".",
"user",
",",
"self",
".",
"password",
",",
"link",
")",
"result_dict",
"=",
"Ideone",
".",... | [
179,
4
] | [
232,
26
] | python | en | ['en', 'error', 'th'] | False |
Ideone.submission_details | (self, link, with_source=True,
with_input=True, with_output=True,
with_stderr=True, with_compilation_info=True) |
Return a dictionary of requested details about a submission
with the id of link.
Keyword Arguments
-----------------
* link: the unique string ID of a submission
* with_source: should we request the source code
* with_input: request the program input
* ... |
Return a dictionary of requested details about a submission
with the id of link. | def submission_details(self, link, with_source=True,
with_input=True, with_output=True,
with_stderr=True, with_compilation_info=True):
"""
Return a dictionary of requested details about a submission
with the id of link.
Keywo... | [
"def",
"submission_details",
"(",
"self",
",",
"link",
",",
"with_source",
"=",
"True",
",",
"with_input",
"=",
"True",
",",
"with_output",
"=",
"True",
",",
"with_stderr",
"=",
"True",
",",
"with_compilation_info",
"=",
"True",
")",
":",
"result",
"=",
"s... | [
234,
4
] | [
281,
26
] | python | en | ['en', 'error', 'th'] | False |
Ideone.languages | (self) |
Get a list of supported languages and cache it.
Examples
--------
>>> ideone_object.languages()
{'error': 'OK',
'languages': {1: "C++ (gcc-4.3.4)",
2: "Pascal (gpc) (gpc 20070904)",
...
...
... |
Get a list of supported languages and cache it. | def languages(self):
"""
Get a list of supported languages and cache it.
Examples
--------
>>> ideone_object.languages()
{'error': 'OK',
'languages': {1: "C++ (gcc-4.3.4)",
2: "Pascal (gpc) (gpc 20070904)",
...
... | [
"def",
"languages",
"(",
"self",
")",
":",
"if",
"self",
".",
"_language_dict",
"is",
"None",
":",
"result",
"=",
"self",
".",
"client",
".",
"service",
".",
"getLanguages",
"(",
"self",
".",
"user",
",",
"self",
".",
"password",
")",
"result_dict",
"=... | [
283,
4
] | [
307,
34
] | python | en | ['en', 'error', 'th'] | False |
Ideone.test | (self) |
A test function that always returns the same thing.
>>> ideone_object = Ideone('username', 'password')
>>> ideone_object.test_function()
{'answerToLifeAndEverything': 42,
'error': "OK",
'moreHelp': "ideone.com",
'oOok': True,
'pi': 3.14}
|
A test function that always returns the same thing. | def test(self):
"""
A test function that always returns the same thing.
>>> ideone_object = Ideone('username', 'password')
>>> ideone_object.test_function()
{'answerToLifeAndEverything': 42,
'error': "OK",
'moreHelp': "ideone.com",
'oOok': True,
... | [
"def",
"test",
"(",
"self",
")",
":",
"result",
"=",
"self",
".",
"client",
".",
"service",
".",
"testFunction",
"(",
"self",
".",
"user",
",",
"self",
".",
"password",
")",
"result_dict",
"=",
"Ideone",
".",
"_transform_to_dict",
"(",
"result",
")",
"... | [
309,
4
] | [
325,
26
] | python | en | ['en', 'error', 'th'] | False |
_pythonlib_compat | () |
On Python 3.7 and earlier, distutils would include the Python
library. See pypa/distutils#9.
|
On Python 3.7 and earlier, distutils would include the Python
library. See pypa/distutils#9.
| def _pythonlib_compat():
"""
On Python 3.7 and earlier, distutils would include the Python
library. See pypa/distutils#9.
"""
from distutils import sysconfig
if not sysconfig.get_config_var('Py_ENABLED_SHARED'):
return
yield 'python{}.{}{}'.format(
sys.hexversion >> 24,
... | [
"def",
"_pythonlib_compat",
"(",
")",
":",
"from",
"distutils",
"import",
"sysconfig",
"if",
"not",
"sysconfig",
".",
"get_config_var",
"(",
"'Py_ENABLED_SHARED'",
")",
":",
"return",
"yield",
"'python{}.{}{}'",
".",
"format",
"(",
"sys",
".",
"hexversion",
">>"... | [
3,
0
] | [
16,
5
] | python | en | ['en', 'error', 'th'] | False |
to_native_string | (string, encoding='ascii') | Given a string object, regardless of type, returns a representation of
that string in the native string type, encoding and decoding where
necessary. This assumes ASCII unless told otherwise.
| Given a string object, regardless of type, returns a representation of
that string in the native string type, encoding and decoding where
necessary. This assumes ASCII unless told otherwise.
| def to_native_string(string, encoding='ascii'):
"""Given a string object, regardless of type, returns a representation of
that string in the native string type, encoding and decoding where
necessary. This assumes ASCII unless told otherwise.
"""
if isinstance(string, builtin_str):
out = stri... | [
"def",
"to_native_string",
"(",
"string",
",",
"encoding",
"=",
"'ascii'",
")",
":",
"if",
"isinstance",
"(",
"string",
",",
"builtin_str",
")",
":",
"out",
"=",
"string",
"else",
":",
"if",
"is_py2",
":",
"out",
"=",
"string",
".",
"encode",
"(",
"enc... | [
13,
0
] | [
26,
14
] | python | en | ['en', 'en', 'en'] | True |
unicode_is_ascii | (u_string) | Determine if unicode string only contains ASCII characters.
:param str u_string: unicode string to check. Must be unicode
and not Python 2 `str`.
:rtype: bool
| Determine if unicode string only contains ASCII characters. | def unicode_is_ascii(u_string):
"""Determine if unicode string only contains ASCII characters.
:param str u_string: unicode string to check. Must be unicode
and not Python 2 `str`.
:rtype: bool
"""
assert isinstance(u_string, str)
try:
u_string.encode('ascii')
return Tru... | [
"def",
"unicode_is_ascii",
"(",
"u_string",
")",
":",
"assert",
"isinstance",
"(",
"u_string",
",",
"str",
")",
"try",
":",
"u_string",
".",
"encode",
"(",
"'ascii'",
")",
"return",
"True",
"except",
"UnicodeEncodeError",
":",
"return",
"False"
] | [
29,
0
] | [
41,
20
] | python | en | ['en', 'en', 'en'] | True |
Vocab.__init__ | (self, counter, max_size=None, min_freq=1, specials=['<pad>'],
vectors=None, unk_init=None, vectors_cache=None) | Create a Vocab object from a collections.Counter.
Arguments:
counter: collections.Counter object holding the frequencies of
each value found in the data.
max_size: The maximum size of the vocabulary, or None for no
maximum. Default: None.
min_... | Create a Vocab object from a collections.Counter. | def __init__(self, counter, max_size=None, min_freq=1, specials=['<pad>'],
vectors=None, unk_init=None, vectors_cache=None):
"""Create a Vocab object from a collections.Counter.
Arguments:
counter: collections.Counter object holding the frequencies of
each v... | [
"def",
"__init__",
"(",
"self",
",",
"counter",
",",
"max_size",
"=",
"None",
",",
"min_freq",
"=",
"1",
",",
"specials",
"=",
"[",
"'<pad>'",
"]",
",",
"vectors",
"=",
"None",
",",
"unk_init",
"=",
"None",
",",
"vectors_cache",
"=",
"None",
")",
":"... | [
30,
4
] | [
81,
61
] | python | en | ['en', 'en', 'en'] | True |
Vocab.load_vectors | (self, vectors, **kwargs) |
Arguments:
vectors: one of or a list containing instantiations of the
GloVe, CharNGram, or Vectors classes. Alternatively, one
of or a list of available pretrained vectors:
charngram.100d
fasttext.en.300d
fasttext.simpl... |
Arguments:
vectors: one of or a list containing instantiations of the
GloVe, CharNGram, or Vectors classes. Alternatively, one
of or a list of available pretrained vectors:
charngram.100d
fasttext.en.300d
fasttext.simpl... | def load_vectors(self, vectors, **kwargs):
"""
Arguments:
vectors: one of or a list containing instantiations of the
GloVe, CharNGram, or Vectors classes. Alternatively, one
of or a list of available pretrained vectors:
charngram.100d
... | [
"def",
"load_vectors",
"(",
"self",
",",
"vectors",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"isinstance",
"(",
"vectors",
",",
"list",
")",
":",
"vectors",
"=",
"[",
"vectors",
"]",
"for",
"idx",
",",
"vector",
"in",
"enumerate",
"(",
"vector... | [
104,
4
] | [
152,
40
] | python | en | ['en', 'error', 'th'] | False |
Vocab.set_vectors | (self, stoi, vectors, dim, unk_init=torch.Tensor.zero_) |
Set the vectors for the Vocab instance from a collection of Tensors.
Arguments:
stoi: A dictionary of string to the index of the associated vector
in the `vectors` input argument.
vectors: An indexed iterable (or other structure supporting __getitem__) that
... |
Set the vectors for the Vocab instance from a collection of Tensors. | def set_vectors(self, stoi, vectors, dim, unk_init=torch.Tensor.zero_):
"""
Set the vectors for the Vocab instance from a collection of Tensors.
Arguments:
stoi: A dictionary of string to the index of the associated vector
in the `vectors` input argument.
... | [
"def",
"set_vectors",
"(",
"self",
",",
"stoi",
",",
"vectors",
",",
"dim",
",",
"unk_init",
"=",
"torch",
".",
"Tensor",
".",
"zero_",
")",
":",
"self",
".",
"vectors",
"=",
"torch",
".",
"Tensor",
"(",
"len",
"(",
"self",
")",
",",
"dim",
")",
... | [
154,
4
] | [
176,
59
] | python | en | ['en', 'error', 'th'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.