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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
TestClientModel.test_client_stringification | (self) |
This test is designed to cover __str__ method for Client.
|
This test is designed to cover __str__ method for Client.
| def test_client_stringification(self) -> None:
"""
This test is designed to cover __str__ method for Client.
"""
client = make_client("some_client")
self.assertEqual(str(client), "<Client: some_client>") | [
"def",
"test_client_stringification",
"(",
"self",
")",
"->",
"None",
":",
"client",
"=",
"make_client",
"(",
"\"some_client\"",
")",
"self",
".",
"assertEqual",
"(",
"str",
"(",
"client",
")",
",",
"\"<Client: some_client>\"",
")"
] | [
72,
4
] | [
77,
62
] | python | en | ['en', 'error', 'th'] | False |
UserPresenceTests.test_new_user_input | (self, unused_mock: mock.Mock) | Mostly a test for UserActivityInterval | Mostly a test for UserActivityInterval | def test_new_user_input(self, unused_mock: mock.Mock) -> None:
"""Mostly a test for UserActivityInterval"""
user_profile = self.example_user("hamlet")
self.login("hamlet")
self.assertEqual(UserActivityInterval.objects.filter(user_profile=user_profile).count(), 0)
time_zero = time... | [
"def",
"test_new_user_input",
"(",
"self",
",",
"unused_mock",
":",
"mock",
".",
"Mock",
")",
"->",
"None",
":",
"user_profile",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"self",
".",
"login",
"(",
"\"hamlet\"",
")",
"self",
".",
"assertEqu... | [
252,
4
] | [
340,
49
] | python | en | ['en', 'en', 'en'] | True |
UserPresenceTests.test_no_mit | (self) | Zephyr mirror realms such as MIT never get a list of users | Zephyr mirror realms such as MIT never get a list of users | def test_no_mit(self) -> None:
"""Zephyr mirror realms such as MIT never get a list of users"""
user = self.mit_user("espuser")
self.login_user(user)
result = self.client_post("/json/users/me/presence", {"status": "idle"}, subdomain="zephyr")
self.assert_json_success(result)
... | [
"def",
"test_no_mit",
"(",
"self",
")",
"->",
"None",
":",
"user",
"=",
"self",
".",
"mit_user",
"(",
"\"espuser\"",
")",
"self",
".",
"login_user",
"(",
"user",
")",
"result",
"=",
"self",
".",
"client_post",
"(",
"\"/json/users/me/presence\"",
",",
"{",
... | [
361,
4
] | [
367,
56
] | python | en | ['en', 'en', 'en'] | True |
UserPresenceTests.test_mirror_presence | (self) | Zephyr mirror realms find out the status of their mirror bot | Zephyr mirror realms find out the status of their mirror bot | def test_mirror_presence(self) -> None:
"""Zephyr mirror realms find out the status of their mirror bot"""
user_profile = self.mit_user("espuser")
self.login_user(user_profile)
def post_presence() -> Dict[str, Any]:
result = self.client_post(
"/json/users/me/... | [
"def",
"test_mirror_presence",
"(",
"self",
")",
"->",
"None",
":",
"user_profile",
"=",
"self",
".",
"mit_user",
"(",
"\"espuser\"",
")",
"self",
".",
"login_user",
"(",
"user_profile",
")",
"def",
"post_presence",
"(",
")",
"->",
"Dict",
"[",
"str",
",",... | [
369,
4
] | [
387,
60
] | python | en | ['en', 'en', 'en'] | True |
WorkerTest.test_push_notifications_worker | (self) |
The push notifications system has its own comprehensive test suite,
so we can limit ourselves to simple unit testing the queue processor,
without going deeper into the system - by mocking the handle_push_notification
functions to immediately produce the effect we want, to test its handl... |
The push notifications system has its own comprehensive test suite,
so we can limit ourselves to simple unit testing the queue processor,
without going deeper into the system - by mocking the handle_push_notification
functions to immediately produce the effect we want, to test its handl... | def test_push_notifications_worker(self) -> None:
"""
The push notifications system has its own comprehensive test suite,
so we can limit ourselves to simple unit testing the queue processor,
without going deeper into the system - by mocking the handle_push_notification
functions... | [
"def",
"test_push_notifications_worker",
"(",
"self",
")",
"->",
"None",
":",
"fake_client",
"=",
"self",
".",
"FakeClient",
"(",
")",
"def",
"fake_publish",
"(",
"queue_name",
":",
"str",
",",
"event",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"pro... | [
227,
4
] | [
299,
17
] | python | en | ['en', 'error', 'th'] | False |
WorkerTest.test_email_sending_worker_retries | (self) | Tests the retry_send_email_failures decorator to make sure it
retries sending the email 3 times and then gives up. | Tests the retry_send_email_failures decorator to make sure it
retries sending the email 3 times and then gives up. | def test_email_sending_worker_retries(self) -> None:
"""Tests the retry_send_email_failures decorator to make sure it
retries sending the email 3 times and then gives up."""
fake_client = self.FakeClient()
data = {
"template_prefix": "zerver/emails/confirm_new_email",
... | [
"def",
"test_email_sending_worker_retries",
"(",
"self",
")",
"->",
"None",
":",
"fake_client",
"=",
"self",
".",
"FakeClient",
"(",
")",
"data",
"=",
"{",
"\"template_prefix\"",
":",
"\"zerver/emails/confirm_new_email\"",
",",
"\"to_emails\"",
":",
"[",
"self",
"... | [
399,
4
] | [
431,
71
] | python | en | ['en', 'en', 'en'] | True |
CelerySentryClient.send | (self, **kwargs) | Errors through celery | Errors through celery | def send(self, **kwargs):
"Errors through celery"
tasks.send.delay(kwargs) | [
"def",
"send",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"tasks",
".",
"send",
".",
"delay",
"(",
"kwargs",
")"
] | [
4,
4
] | [
6,
32
] | python | en | ['en', 'sr', 'en'] | True |
backport_makefile | (
self, mode="r", buffering=None, encoding=None, errors=None, newline=None
) |
Backport of ``socket.makefile`` from Python 3.5.
|
Backport of ``socket.makefile`` from Python 3.5.
| def backport_makefile(
self, mode="r", buffering=None, encoding=None, errors=None, newline=None
):
"""
Backport of ``socket.makefile`` from Python 3.5.
"""
if not set(mode) <= {"r", "w", "b"}:
raise ValueError("invalid mode %r (only r, w, b allowed)" % (mode,))
writing = "w" in mode
... | [
"def",
"backport_makefile",
"(",
"self",
",",
"mode",
"=",
"\"r\"",
",",
"buffering",
"=",
"None",
",",
"encoding",
"=",
"None",
",",
"errors",
"=",
"None",
",",
"newline",
"=",
"None",
")",
":",
"if",
"not",
"set",
"(",
"mode",
")",
"<=",
"{",
"\"... | [
13,
0
] | [
51,
15
] | python | en | ['en', 'error', 'th'] | False |
test_pytest_fail_notrace_non_ascii | (testdir, str_prefix) | Fix pytest.fail with pytrace=False with non-ascii characters (#1178).
This tests with native and unicode strings containing non-ascii chars.
| Fix pytest.fail with pytrace=False with non-ascii characters (#1178). | def test_pytest_fail_notrace_non_ascii(testdir, str_prefix):
"""Fix pytest.fail with pytrace=False with non-ascii characters (#1178).
This tests with native and unicode strings containing non-ascii chars.
"""
testdir.makepyfile(u"""
# coding: utf-8
import pytest
def test_hello(... | [
"def",
"test_pytest_fail_notrace_non_ascii",
"(",
"testdir",
",",
"str_prefix",
")",
":",
"testdir",
".",
"makepyfile",
"(",
"u\"\"\"\n # coding: utf-8\n import pytest\n\n def test_hello():\n pytest.fail(%s'oh oh: ☺', pytrace=False)\n \"\"\"",
"%",
"str... | [
524,
0
] | [
541,
54
] | python | en | ['en', 'en', 'en'] | True |
test_importorskip_module_level | (testdir) | importorskip must be able to skip entire modules when used at module level | importorskip must be able to skip entire modules when used at module level | def test_importorskip_module_level(testdir):
"""importorskip must be able to skip entire modules when used at module level"""
testdir.makepyfile('''
import pytest
foobarbaz = pytest.importorskip("foobarbaz")
def test_foo():
pass
''')
result = testdir.runpytest()
... | [
"def",
"test_importorskip_module_level",
"(",
"testdir",
")",
":",
"testdir",
".",
"makepyfile",
"(",
"'''\n import pytest\n foobarbaz = pytest.importorskip(\"foobarbaz\")\n\n def test_foo():\n pass\n '''",
")",
"result",
"=",
"testdir",
".",
"runpy... | [
623,
0
] | [
633,
68
] | python | en | ['en', 'en', 'en'] | True |
test_makereport_getsource_dynamic_code | (testdir, monkeypatch) | Test that exception in dynamically generated code doesn't break getting the source line. | Test that exception in dynamically generated code doesn't break getting the source line. | def test_makereport_getsource_dynamic_code(testdir, monkeypatch):
"""Test that exception in dynamically generated code doesn't break getting the source line."""
import inspect
original_findsource = inspect.findsource
def findsource(obj, *args, **kwargs):
# Can be triggered by dynamically create... | [
"def",
"test_makereport_getsource_dynamic_code",
"(",
"testdir",
",",
"monkeypatch",
")",
":",
"import",
"inspect",
"original_findsource",
"=",
"inspect",
".",
"findsource",
"def",
"findsource",
"(",
"obj",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
... | [
693,
0
] | [
718,
80
] | python | en | ['en', 'en', 'en'] | True |
test_store_except_info_on_eror | () | Test that upon test failure, the exception info is stored on
sys.last_traceback and friends.
| Test that upon test failure, the exception info is stored on
sys.last_traceback and friends.
| def test_store_except_info_on_eror():
""" Test that upon test failure, the exception info is stored on
sys.last_traceback and friends.
"""
# Simulate item that raises a specific exception
class ItemThatRaises(object):
nodeid = 'item_that_raises'
def runtest(self):
raise ... | [
"def",
"test_store_except_info_on_eror",
"(",
")",
":",
"# Simulate item that raises a specific exception",
"class",
"ItemThatRaises",
"(",
"object",
")",
":",
"nodeid",
"=",
"'item_that_raises'",
"def",
"runtest",
"(",
"self",
")",
":",
"raise",
"IndexError",
"(",
"'... | [
721,
0
] | [
738,
29
] | python | en | ['en', 'en', 'en'] | True |
BaseFunctionalTests.test_exact_teardown_issue1206 | (self, testdir) | issue shadowing error with wrong number of arguments on teardown_method. | issue shadowing error with wrong number of arguments on teardown_method. | def test_exact_teardown_issue1206(self, testdir):
"""issue shadowing error with wrong number of arguments on teardown_method."""
rec = testdir.inline_runsource("""
import pytest
class TestClass(object):
def teardown_method(self, x, y, z):
pass... | [
"def",
"test_exact_teardown_issue1206",
"(",
"self",
",",
"testdir",
")",
":",
"rec",
"=",
"testdir",
".",
"inline_runsource",
"(",
"\"\"\"\n import pytest\n\n class TestClass(object):\n def teardown_method(self, x, y, z):\n pass\n\... | [
256,
4
] | [
288,
9
] | python | en | ['en', 'en', 'en'] | True |
TestVolumesBasic.test_volume_create_edit_delete | (self) | This test case checks create, edit, delete volume functionality:
Steps:
1. Login to Horizon Dashboard
2. Navigate to Project -> Compute -> Volumes page
3. Create new volume
4. Check that the volume is in the list
5. Check that no Error messages present
6. Edit th... | This test case checks create, edit, delete volume functionality: | def test_volume_create_edit_delete(self):
"""This test case checks create, edit, delete volume functionality:
Steps:
1. Login to Horizon Dashboard
2. Navigate to Project -> Compute -> Volumes page
3. Create new volume
4. Check that the volume is in the list
5. Ch... | [
"def",
"test_volume_create_edit_delete",
"(",
"self",
")",
":",
"volumes_page",
"=",
"self",
".",
"home_pg",
".",
"go_to_project_volumes_volumespage",
"(",
")",
"volumes_page",
".",
"create_volume",
"(",
"self",
".",
"VOLUME_NAME",
")",
"self",
".",
"assertTrue",
... | [
28,
4
] | [
78,
25
] | python | en | ['en', 'en', 'en'] | True |
TestVolumesBasic.test_volumes_pagination | (self) | This test checks volumes pagination
Steps:
1) Login to Horizon Dashboard
2) Go to Project -> Volumes -> Volumes tab and create
three volumes
3) Navigate to user settings page
4) Change 'Items Per Page' value to 1
5) Go to Project -> Volumes -> Volumes tab or
... | This test checks volumes pagination | def test_volumes_pagination(self):
"""This test checks volumes pagination
Steps:
1) Login to Horizon Dashboard
2) Go to Project -> Volumes -> Volumes tab and create
three volumes
3) Navigate to user settings page
4) Change 'Items Per Page' value to 1
5) G... | [
"def",
"test_volumes_pagination",
"(",
"self",
")",
":",
"volumes_page",
"=",
"self",
".",
"home_pg",
".",
"go_to_project_volumes_volumespage",
"(",
")",
"count",
"=",
"3",
"items_per_page",
"=",
"1",
"volumes_names",
"=",
"[",
"\"{0}_{1}\"",
".",
"format",
"(",... | [
81,
4
] | [
148,
72
] | python | en | ['en', 'en', 'en'] | True |
TestVolumesAdvanced.test_manage_volume_attachments | (self) | This test case checks attach/detach actions for volume
Steps:
1. Login to Horizon Dashboard as horizon user
2. Navigate to Project -> Compute -> Instances, create instance
3. Navigate to Project -> Volumes -> Volumes, create volume
4. Attach volume to instance from step2
... | This test case checks attach/detach actions for volume | def test_manage_volume_attachments(self):
"""This test case checks attach/detach actions for volume
Steps:
1. Login to Horizon Dashboard as horizon user
2. Navigate to Project -> Compute -> Instances, create instance
3. Navigate to Project -> Volumes -> Volumes, create volume
... | [
"def",
"test_manage_volume_attachments",
"(",
"self",
")",
":",
"instance_name",
"=",
"helpers",
".",
"gen_random_resource_name",
"(",
"'instance'",
")",
"instances_page",
"=",
"self",
".",
"home_pg",
".",
"go_to_project_compute_instancespage",
"(",
")",
"instances_page... | [
171,
4
] | [
225,
74
] | python | en | ['en', 'en', 'en'] | True |
TestVolumesActions.test_volume_extend | (self) | This test case checks extend volume functionality:
Steps:
1. Check current volume size
2. Extend volume
3. Check that no Error messages present
4. Check that the volume is still in the list
5. Check that the volume size is changed
| This test case checks extend volume functionality: | def test_volume_extend(self):
"""This test case checks extend volume functionality:
Steps:
1. Check current volume size
2. Extend volume
3. Check that no Error messages present
4. Check that the volume is still in the list
5. Check that the volume size is changed... | [
"def",
"test_volume_extend",
"(",
"self",
")",
":",
"volumes_page",
"=",
"self",
".",
"volumes_page",
"orig_size",
"=",
"volumes_page",
".",
"get_size",
"(",
"self",
".",
"VOLUME_NAME",
")",
"volumes_page",
".",
"extend_volume",
"(",
"self",
".",
"VOLUME_NAME",
... | [
262,
4
] | [
282,
44
] | python | en | ['en', 'en', 'en'] | True |
TestVolumesActions.test_volume_upload_to_image | (self) | This test case checks upload volume to image functionality:
Steps:
1. Upload volume to image with some disk format
2. Check that image is created
3. Check that no Error messages present
4. Delete the image
5. Repeat actions for all disk formats
| This test case checks upload volume to image functionality: | def test_volume_upload_to_image(self):
"""This test case checks upload volume to image functionality:
Steps:
1. Upload volume to image with some disk format
2. Check that image is created
3. Check that no Error messages present
4. Delete the image
5. Repeat actio... | [
"def",
"test_volume_upload_to_image",
"(",
"self",
")",
":",
"self",
".",
"volumes_page",
"=",
"self",
".",
"home_pg",
".",
"go_to_project_volumes_volumespage",
"(",
")",
"all_formats",
"=",
"{",
"\"qcow2\"",
":",
"u'QCOW2'",
",",
"\"raw\"",
":",
"u'Raw'",
",",
... | [
285,
4
] | [
318,
64
] | python | en | ['en', 'en', 'en'] | True |
TestVolumesActions.test_volume_launch_as_instance | (self) | This test case checks launch volume as instance functionality:
Steps:
1. Launch volume as instance
2. Check that instance is created
3. Check that no Error messages present
4. Check that instance status is 'active'
5. Check that volume status is 'in use'
6. Delet... | This test case checks launch volume as instance functionality: | def test_volume_launch_as_instance(self):
"""This test case checks launch volume as instance functionality:
Steps:
1. Launch volume as instance
2. Check that instance is created
3. Check that no Error messages present
4. Check that instance status is 'active'
5. ... | [
"def",
"test_volume_launch_as_instance",
"(",
"self",
")",
":",
"self",
".",
"volumes_page",
".",
"launch_instance",
"(",
"self",
".",
"VOLUME_NAME",
",",
"self",
".",
"INSTANCE_NAME",
")",
"self",
".",
"assertTrue",
"(",
"self",
".",
"volumes_page",
".",
"fin... | [
321,
4
] | [
351,
76
] | python | en | ['en', 'en', 'en'] | True |
get_supported_platform | () | Return this platform's maximum compatible version.
distutils.util.get_platform() normally reports the minimum version
of Mac OS X that would be required to *use* extensions produced by
distutils. But what we want when checking compatibility is to know the
version of Mac OS X that we are *running*. To... | Return this platform's maximum compatible version. | def get_supported_platform():
"""Return this platform's maximum compatible version.
distutils.util.get_platform() normally reports the minimum version
of Mac OS X that would be required to *use* extensions produced by
distutils. But what we want when checking compatibility is to know the
version o... | [
"def",
"get_supported_platform",
"(",
")",
":",
"plat",
"=",
"get_build_platform",
"(",
")",
"m",
"=",
"macosVersionString",
".",
"match",
"(",
"plat",
")",
"if",
"m",
"is",
"not",
"None",
"and",
"sys",
".",
"platform",
"==",
"\"darwin\"",
":",
"try",
":... | [
176,
0
] | [
197,
15
] | python | en | ['en', 'la', 'en'] | True |
register_loader_type | (loader_type, provider_factory) | Register `provider_factory` to make providers for `loader_type`
`loader_type` is the type or class of a PEP 302 ``module.__loader__``,
and `provider_factory` is a function that, passed a *module* object,
returns an ``IResourceProvider`` for that module.
| Register `provider_factory` to make providers for `loader_type` | def register_loader_type(loader_type, provider_factory):
"""Register `provider_factory` to make providers for `loader_type`
`loader_type` is the type or class of a PEP 302 ``module.__loader__``,
and `provider_factory` is a function that, passed a *module* object,
returns an ``IResourceProvider`` for th... | [
"def",
"register_loader_type",
"(",
"loader_type",
",",
"provider_factory",
")",
":",
"_provider_factories",
"[",
"loader_type",
"]",
"=",
"provider_factory"
] | [
343,
0
] | [
350,
55
] | python | en | ['en', 'no', 'en'] | True |
get_provider | (moduleOrReq) | Return an IResourceProvider for the named module or requirement | Return an IResourceProvider for the named module or requirement | def get_provider(moduleOrReq):
"""Return an IResourceProvider for the named module or requirement"""
if isinstance(moduleOrReq, Requirement):
return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
try:
module = sys.modules[moduleOrReq]
except KeyError:
__import__(mo... | [
"def",
"get_provider",
"(",
"moduleOrReq",
")",
":",
"if",
"isinstance",
"(",
"moduleOrReq",
",",
"Requirement",
")",
":",
"return",
"working_set",
".",
"find",
"(",
"moduleOrReq",
")",
"or",
"require",
"(",
"str",
"(",
"moduleOrReq",
")",
")",
"[",
"0",
... | [
353,
0
] | [
363,
61
] | python | en | ['en', 'en', 'en'] | True |
get_build_platform | () | Return this platform's string for platform-specific distributions
XXX Currently this is the same as ``distutils.util.get_platform()``, but it
needs some hacks for Linux and Mac OS X.
| Return this platform's string for platform-specific distributions | def get_build_platform():
"""Return this platform's string for platform-specific distributions
XXX Currently this is the same as ``distutils.util.get_platform()``, but it
needs some hacks for Linux and Mac OS X.
"""
from sysconfig import get_platform
plat = get_platform()
if sys.platform =... | [
"def",
"get_build_platform",
"(",
")",
":",
"from",
"sysconfig",
"import",
"get_platform",
"plat",
"=",
"get_platform",
"(",
")",
"if",
"sys",
".",
"platform",
"==",
"\"darwin\"",
"and",
"not",
"plat",
".",
"startswith",
"(",
"'macosx-'",
")",
":",
"try",
... | [
386,
0
] | [
407,
15
] | python | en | ['en', 'da', 'en'] | True |
compatible_platforms | (provided, required) | Can code for the `provided` platform run on the `required` platform?
Returns true if either platform is ``None``, or the platforms are equal.
XXX Needs compatibility checks for Linux and other unixy OSes.
| Can code for the `provided` platform run on the `required` platform? | def compatible_platforms(provided, required):
"""Can code for the `provided` platform run on the `required` platform?
Returns true if either platform is ``None``, or the platforms are equal.
XXX Needs compatibility checks for Linux and other unixy OSes.
"""
if provided is None or required is None ... | [
"def",
"compatible_platforms",
"(",
"provided",
",",
"required",
")",
":",
"if",
"provided",
"is",
"None",
"or",
"required",
"is",
"None",
"or",
"provided",
"==",
"required",
":",
"# easy case",
"return",
"True",
"# Mac OS X special cases",
"reqMac",
"=",
"macos... | [
416,
0
] | [
459,
16
] | python | en | ['en', 'en', 'en'] | True |
run_script | (dist_spec, script_name) | Locate distribution `dist_spec` and run its `script_name` script | Locate distribution `dist_spec` and run its `script_name` script | def run_script(dist_spec, script_name):
"""Locate distribution `dist_spec` and run its `script_name` script"""
ns = sys._getframe(1).f_globals
name = ns['__name__']
ns.clear()
ns['__name__'] = name
require(dist_spec)[0].run_script(script_name, ns) | [
"def",
"run_script",
"(",
"dist_spec",
",",
"script_name",
")",
":",
"ns",
"=",
"sys",
".",
"_getframe",
"(",
"1",
")",
".",
"f_globals",
"name",
"=",
"ns",
"[",
"'__name__'",
"]",
"ns",
".",
"clear",
"(",
")",
"ns",
"[",
"'__name__'",
"]",
"=",
"n... | [
462,
0
] | [
468,
53
] | python | en | ['en', 'co', 'en'] | True |
get_distribution | (dist) | Return a current distribution object for a Requirement or string | Return a current distribution object for a Requirement or string | def get_distribution(dist):
"""Return a current distribution object for a Requirement or string"""
if isinstance(dist, six.string_types):
dist = Requirement.parse(dist)
if isinstance(dist, Requirement):
dist = get_provider(dist)
if not isinstance(dist, Distribution):
raise TypeEr... | [
"def",
"get_distribution",
"(",
"dist",
")",
":",
"if",
"isinstance",
"(",
"dist",
",",
"six",
".",
"string_types",
")",
":",
"dist",
"=",
"Requirement",
".",
"parse",
"(",
"dist",
")",
"if",
"isinstance",
"(",
"dist",
",",
"Requirement",
")",
":",
"di... | [
475,
0
] | [
483,
15
] | python | en | ['en', 'en', 'en'] | True |
load_entry_point | (dist, group, name) | Return `name` entry point of `group` for `dist` or raise ImportError | Return `name` entry point of `group` for `dist` or raise ImportError | def load_entry_point(dist, group, name):
"""Return `name` entry point of `group` for `dist` or raise ImportError"""
return get_distribution(dist).load_entry_point(group, name) | [
"def",
"load_entry_point",
"(",
"dist",
",",
"group",
",",
"name",
")",
":",
"return",
"get_distribution",
"(",
"dist",
")",
".",
"load_entry_point",
"(",
"group",
",",
"name",
")"
] | [
486,
0
] | [
488,
63
] | python | en | ['en', 'en', 'en'] | True |
get_entry_map | (dist, 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(dist, group=None):
"""Return the entry point map for `group`, or the full entry map"""
return get_distribution(dist).get_entry_map(group) | [
"def",
"get_entry_map",
"(",
"dist",
",",
"group",
"=",
"None",
")",
":",
"return",
"get_distribution",
"(",
"dist",
")",
".",
"get_entry_map",
"(",
"group",
")"
] | [
491,
0
] | [
493,
54
] | python | en | ['en', 'en', 'en'] | True |
get_entry_info | (dist, group, name) | Return the EntryPoint object for `group`+`name`, or ``None`` | Return the EntryPoint object for `group`+`name`, or ``None`` | def get_entry_info(dist, group, name):
"""Return the EntryPoint object for `group`+`name`, or ``None``"""
return get_distribution(dist).get_entry_info(group, name) | [
"def",
"get_entry_info",
"(",
"dist",
",",
"group",
",",
"name",
")",
":",
"return",
"get_distribution",
"(",
"dist",
")",
".",
"get_entry_info",
"(",
"group",
",",
"name",
")"
] | [
496,
0
] | [
498,
61
] | python | en | ['en', 'en', 'en'] | True |
get_default_cache | () |
Return the ``PYTHON_EGG_CACHE`` environment variable
or a platform-relevant user cache dir for an app
named "Python-Eggs".
|
Return the ``PYTHON_EGG_CACHE`` environment variable
or a platform-relevant user cache dir for an app
named "Python-Eggs".
| def get_default_cache():
"""
Return the ``PYTHON_EGG_CACHE`` environment variable
or a platform-relevant user cache dir for an app
named "Python-Eggs".
"""
return (
os.environ.get('PYTHON_EGG_CACHE')
or appdirs.user_cache_dir(appname='Python-Eggs')
) | [
"def",
"get_default_cache",
"(",
")",
":",
"return",
"(",
"os",
".",
"environ",
".",
"get",
"(",
"'PYTHON_EGG_CACHE'",
")",
"or",
"appdirs",
".",
"user_cache_dir",
"(",
"appname",
"=",
"'Python-Eggs'",
")",
")"
] | [
1304,
0
] | [
1313,
5
] | python | en | ['en', 'error', 'th'] | False |
safe_name | (name) | Convert an arbitrary string to a standard distribution name
Any runs of non-alphanumeric/. characters are replaced with a single '-'.
| Convert an arbitrary string to a standard distribution name | def safe_name(name):
"""Convert an arbitrary string to a standard distribution name
Any runs of non-alphanumeric/. characters are replaced with a single '-'.
"""
return re.sub('[^A-Za-z0-9.]+', '-', name) | [
"def",
"safe_name",
"(",
"name",
")",
":",
"return",
"re",
".",
"sub",
"(",
"'[^A-Za-z0-9.]+'",
",",
"'-'",
",",
"name",
")"
] | [
1316,
0
] | [
1321,
46
] | python | en | ['en', 'en', 'en'] | True |
safe_version | (version) |
Convert an arbitrary string to a standard version string
|
Convert an arbitrary string to a standard version string
| def safe_version(version):
"""
Convert an arbitrary string to a standard version string
"""
try:
# normalize the version
return str(packaging.version.Version(version))
except packaging.version.InvalidVersion:
version = version.replace(' ', '.')
return re.sub('[^A-Za-z... | [
"def",
"safe_version",
"(",
"version",
")",
":",
"try",
":",
"# normalize the version",
"return",
"str",
"(",
"packaging",
".",
"version",
".",
"Version",
"(",
"version",
")",
")",
"except",
"packaging",
".",
"version",
".",
"InvalidVersion",
":",
"version",
... | [
1324,
0
] | [
1333,
53
] | python | en | ['en', 'error', 'th'] | False |
safe_extra | (extra) | Convert an arbitrary string to a standard 'extra' name
Any runs of non-alphanumeric characters are replaced with a single '_',
and the result is always lowercased.
| Convert an arbitrary string to a standard 'extra' name | def safe_extra(extra):
"""Convert an arbitrary string to a standard 'extra' name
Any runs of non-alphanumeric characters are replaced with a single '_',
and the result is always lowercased.
"""
return re.sub('[^A-Za-z0-9.-]+', '_', extra).lower() | [
"def",
"safe_extra",
"(",
"extra",
")",
":",
"return",
"re",
".",
"sub",
"(",
"'[^A-Za-z0-9.-]+'",
",",
"'_'",
",",
"extra",
")",
".",
"lower",
"(",
")"
] | [
1336,
0
] | [
1342,
56
] | python | en | ['en', 'en', 'en'] | True |
to_filename | (name) | Convert a project or version name to its filename-escaped form
Any '-' characters are currently replaced with '_'.
| Convert a project or version name to its filename-escaped form | def to_filename(name):
"""Convert a project or version name to its filename-escaped form
Any '-' characters are currently replaced with '_'.
"""
return name.replace('-', '_') | [
"def",
"to_filename",
"(",
"name",
")",
":",
"return",
"name",
".",
"replace",
"(",
"'-'",
",",
"'_'",
")"
] | [
1345,
0
] | [
1350,
33
] | python | en | ['en', 'en', 'en'] | True |
invalid_marker | (text) |
Validate text as a PEP 508 environment marker; return an exception
if invalid or False otherwise.
|
Validate text as a PEP 508 environment marker; return an exception
if invalid or False otherwise.
| def invalid_marker(text):
"""
Validate text as a PEP 508 environment marker; return an exception
if invalid or False otherwise.
"""
try:
evaluate_marker(text)
except SyntaxError as e:
e.filename = None
e.lineno = None
return e
return False | [
"def",
"invalid_marker",
"(",
"text",
")",
":",
"try",
":",
"evaluate_marker",
"(",
"text",
")",
"except",
"SyntaxError",
"as",
"e",
":",
"e",
".",
"filename",
"=",
"None",
"e",
".",
"lineno",
"=",
"None",
"return",
"e",
"return",
"False"
] | [
1353,
0
] | [
1364,
16
] | python | en | ['en', 'error', 'th'] | False |
evaluate_marker | (text, extra=None) |
Evaluate a PEP 508 environment marker.
Return a boolean indicating the marker result in this environment.
Raise SyntaxError if marker is invalid.
This implementation uses the 'pyparsing' module.
|
Evaluate a PEP 508 environment marker.
Return a boolean indicating the marker result in this environment.
Raise SyntaxError if marker is invalid. | def evaluate_marker(text, extra=None):
"""
Evaluate a PEP 508 environment marker.
Return a boolean indicating the marker result in this environment.
Raise SyntaxError if marker is invalid.
This implementation uses the 'pyparsing' module.
"""
try:
marker = packaging.markers.Marker(te... | [
"def",
"evaluate_marker",
"(",
"text",
",",
"extra",
"=",
"None",
")",
":",
"try",
":",
"marker",
"=",
"packaging",
".",
"markers",
".",
"Marker",
"(",
"text",
")",
"return",
"marker",
".",
"evaluate",
"(",
")",
"except",
"packaging",
".",
"markers",
"... | [
1367,
0
] | [
1379,
28
] | python | en | ['en', 'error', 'th'] | False |
register_finder | (importer_type, distribution_finder) | Register `distribution_finder` to find distributions in sys.path items
`importer_type` is the type or class of a PEP 302 "Importer" (sys.path item
handler), and `distribution_finder` is a callable that, passed a path
item and the importer instance, yields ``Distribution`` instances found on
that path i... | Register `distribution_finder` to find distributions in sys.path items | def register_finder(importer_type, distribution_finder):
"""Register `distribution_finder` to find distributions in sys.path items
`importer_type` is the type or class of a PEP 302 "Importer" (sys.path item
handler), and `distribution_finder` is a callable that, passed a path
item and the importer inst... | [
"def",
"register_finder",
"(",
"importer_type",
",",
"distribution_finder",
")",
":",
"_distribution_finders",
"[",
"importer_type",
"]",
"=",
"distribution_finder"
] | [
1956,
0
] | [
1963,
62
] | python | en | ['en', 'en', 'en'] | True |
find_distributions | (path_item, only=False) | Yield distributions accessible via `path_item` | Yield distributions accessible via `path_item` | def find_distributions(path_item, only=False):
"""Yield distributions accessible via `path_item`"""
importer = get_importer(path_item)
finder = _find_adapter(_distribution_finders, importer)
return finder(importer, path_item, only) | [
"def",
"find_distributions",
"(",
"path_item",
",",
"only",
"=",
"False",
")",
":",
"importer",
"=",
"get_importer",
"(",
"path_item",
")",
"finder",
"=",
"_find_adapter",
"(",
"_distribution_finders",
",",
"importer",
")",
"return",
"finder",
"(",
"importer",
... | [
1966,
0
] | [
1970,
44
] | python | en | ['en', 'en', 'en'] | True |
find_eggs_in_zip | (importer, path_item, only=False) |
Find eggs in zip files; possibly multiple nested eggs.
|
Find eggs in zip files; possibly multiple nested eggs.
| def find_eggs_in_zip(importer, path_item, only=False):
"""
Find eggs in zip files; possibly multiple nested eggs.
"""
if importer.archive.endswith('.whl'):
# wheels are not supported with this finder
# they don't have PKG-INFO metadata, and won't ever contain eggs
return
meta... | [
"def",
"find_eggs_in_zip",
"(",
"importer",
",",
"path_item",
",",
"only",
"=",
"False",
")",
":",
"if",
"importer",
".",
"archive",
".",
"endswith",
"(",
"'.whl'",
")",
":",
"# wheels are not supported with this finder",
"# they don't have PKG-INFO metadata, and won't ... | [
1973,
0
] | [
1997,
73
] | python | en | ['en', 'error', 'th'] | False |
_by_version_descending | (names) |
Given a list of filenames, return them in descending order
by version number.
>>> names = 'bar', 'foo', 'Python-2.7.10.egg', 'Python-2.7.2.egg'
>>> _by_version_descending(names)
['Python-2.7.10.egg', 'Python-2.7.2.egg', 'foo', 'bar']
>>> names = 'Setuptools-1.2.3b1.egg', 'Setuptools-1.2.3.egg'... |
Given a list of filenames, return them in descending order
by version number. | def _by_version_descending(names):
"""
Given a list of filenames, return them in descending order
by version number.
>>> names = 'bar', 'foo', 'Python-2.7.10.egg', 'Python-2.7.2.egg'
>>> _by_version_descending(names)
['Python-2.7.10.egg', 'Python-2.7.2.egg', 'foo', 'bar']
>>> names = 'Setup... | [
"def",
"_by_version_descending",
"(",
"names",
")",
":",
"def",
"_by_version",
"(",
"name",
")",
":",
"\"\"\"\n Parse each component of the filename\n \"\"\"",
"name",
",",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"name",
")",
"parts",
"=... | [
2010,
0
] | [
2033,
55
] | python | en | ['en', 'error', 'th'] | False |
find_on_path | (importer, path_item, only=False) | Yield distributions accessible on a sys.path directory | Yield distributions accessible on a sys.path directory | def find_on_path(importer, path_item, only=False):
"""Yield distributions accessible on a sys.path directory"""
path_item = _normalize_cached(path_item)
if _is_unpacked_egg(path_item):
yield Distribution.from_filename(
path_item, metadata=PathMetadata(
path_item, os.path... | [
"def",
"find_on_path",
"(",
"importer",
",",
"path_item",
",",
"only",
"=",
"False",
")",
":",
"path_item",
"=",
"_normalize_cached",
"(",
"path_item",
")",
"if",
"_is_unpacked_egg",
"(",
"path_item",
")",
":",
"yield",
"Distribution",
".",
"from_filename",
"(... | [
2036,
0
] | [
2065,
22
] | python | en | ['en', 'en', 'en'] | True |
dist_factory | (path_item, entry, only) |
Return a dist_factory for a path_item and entry
|
Return a dist_factory for a path_item and entry
| def dist_factory(path_item, entry, only):
"""
Return a dist_factory for a path_item and entry
"""
lower = entry.lower()
is_meta = any(map(lower.endswith, ('.egg-info', '.dist-info')))
return (
distributions_from_metadata
if is_meta else
find_distributions
if not o... | [
"def",
"dist_factory",
"(",
"path_item",
",",
"entry",
",",
"only",
")",
":",
"lower",
"=",
"entry",
".",
"lower",
"(",
")",
"is_meta",
"=",
"any",
"(",
"map",
"(",
"lower",
".",
"endswith",
",",
"(",
"'.egg-info'",
",",
"'.dist-info'",
")",
")",
")"... | [
2068,
0
] | [
2082,
5
] | python | en | ['en', 'error', 'th'] | False |
safe_listdir | (path) |
Attempt to list contents of path, but suppress some exceptions.
|
Attempt to list contents of path, but suppress some exceptions.
| def safe_listdir(path):
"""
Attempt to list contents of path, but suppress some exceptions.
"""
try:
return os.listdir(path)
except (PermissionError, NotADirectoryError):
pass
except OSError as e:
# Ignore the directory if does not exist, not a directory or
# perm... | [
"def",
"safe_listdir",
"(",
"path",
")",
":",
"try",
":",
"return",
"os",
".",
"listdir",
"(",
"path",
")",
"except",
"(",
"PermissionError",
",",
"NotADirectoryError",
")",
":",
"pass",
"except",
"OSError",
"as",
"e",
":",
"# Ignore the directory if does not ... | [
2102,
0
] | [
2120,
13
] | python | en | ['en', 'error', 'th'] | False |
non_empty_lines | (path) |
Yield non-empty lines from file at path
|
Yield non-empty lines from file at path
| def non_empty_lines(path):
"""
Yield non-empty lines from file at path
"""
with open(path) as f:
for line in f:
line = line.strip()
if line:
yield line | [
"def",
"non_empty_lines",
"(",
"path",
")",
":",
"with",
"open",
"(",
"path",
")",
"as",
"f",
":",
"for",
"line",
"in",
"f",
":",
"line",
"=",
"line",
".",
"strip",
"(",
")",
"if",
"line",
":",
"yield",
"line"
] | [
2138,
0
] | [
2146,
26
] | python | en | ['en', 'error', 'th'] | False |
resolve_egg_link | (path) |
Given a path to an .egg-link, resolve distributions
present in the referenced path.
|
Given a path to an .egg-link, resolve distributions
present in the referenced path.
| def resolve_egg_link(path):
"""
Given a path to an .egg-link, resolve distributions
present in the referenced path.
"""
referenced_paths = non_empty_lines(path)
resolved_paths = (
os.path.join(os.path.dirname(path), ref)
for ref in referenced_paths
)
dist_groups = map(fin... | [
"def",
"resolve_egg_link",
"(",
"path",
")",
":",
"referenced_paths",
"=",
"non_empty_lines",
"(",
"path",
")",
"resolved_paths",
"=",
"(",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"path",
")",
",",
"ref",
")",
"for"... | [
2149,
0
] | [
2160,
32
] | python | en | ['en', 'error', 'th'] | False |
register_namespace_handler | (importer_type, namespace_handler) | Register `namespace_handler` to declare namespace packages
`importer_type` is the type or class of a PEP 302 "Importer" (sys.path item
handler), and `namespace_handler` is a callable like this::
def namespace_handler(importer, path_entry, moduleName, module):
# return a path_entry to use f... | Register `namespace_handler` to declare namespace packages | def register_namespace_handler(importer_type, namespace_handler):
"""Register `namespace_handler` to declare namespace packages
`importer_type` is the type or class of a PEP 302 "Importer" (sys.path item
handler), and `namespace_handler` is a callable like this::
def namespace_handler(importer, pa... | [
"def",
"register_namespace_handler",
"(",
"importer_type",
",",
"namespace_handler",
")",
":",
"_namespace_handlers",
"[",
"importer_type",
"]",
"=",
"namespace_handler"
] | [
2172,
0
] | [
2187,
58
] | python | en | ['it', 'en', 'en'] | True |
_handle_ns | (packageName, path_item) | Ensure that named package includes a subpath of path_item (if needed) | Ensure that named package includes a subpath of path_item (if needed) | def _handle_ns(packageName, path_item):
"""Ensure that named package includes a subpath of path_item (if needed)"""
importer = get_importer(path_item)
if importer is None:
return None
# capture warnings due to #1111
with warnings.catch_warnings():
warnings.simplefilter("ignore")
... | [
"def",
"_handle_ns",
"(",
"packageName",
",",
"path_item",
")",
":",
"importer",
"=",
"get_importer",
"(",
"path_item",
")",
"if",
"importer",
"is",
"None",
":",
"return",
"None",
"# capture warnings due to #1111",
"with",
"warnings",
".",
"catch_warnings",
"(",
... | [
2190,
0
] | [
2218,
18
] | python | en | ['en', 'en', 'en'] | True |
_rebuild_mod_path | (orig_path, package_name, module) |
Rebuild module.__path__ ensuring that all entries are ordered
corresponding to their sys.path order
|
Rebuild module.__path__ ensuring that all entries are ordered
corresponding to their sys.path order
| def _rebuild_mod_path(orig_path, package_name, module):
"""
Rebuild module.__path__ ensuring that all entries are ordered
corresponding to their sys.path order
"""
sys_path = [_normalize_cached(p) for p in sys.path]
def safe_sys_path_index(entry):
"""
Workaround for #520 and #51... | [
"def",
"_rebuild_mod_path",
"(",
"orig_path",
",",
"package_name",
",",
"module",
")",
":",
"sys_path",
"=",
"[",
"_normalize_cached",
"(",
"p",
")",
"for",
"p",
"in",
"sys",
".",
"path",
"]",
"def",
"safe_sys_path_index",
"(",
"entry",
")",
":",
"\"\"\"\n... | [
2221,
0
] | [
2252,
34
] | python | en | ['en', 'error', 'th'] | False |
declare_namespace | (packageName) | Declare that package 'packageName' is a namespace package | Declare that package 'packageName' is a namespace package | def declare_namespace(packageName):
"""Declare that package 'packageName' is a namespace package"""
_imp.acquire_lock()
try:
if packageName in _namespace_packages:
return
path = sys.path
parent, _, _ = packageName.rpartition('.')
if parent:
declare_... | [
"def",
"declare_namespace",
"(",
"packageName",
")",
":",
"_imp",
".",
"acquire_lock",
"(",
")",
"try",
":",
"if",
"packageName",
"in",
"_namespace_packages",
":",
"return",
"path",
"=",
"sys",
".",
"path",
"parent",
",",
"_",
",",
"_",
"=",
"packageName",... | [
2255,
0
] | [
2286,
27
] | python | en | ['en', 'en', 'en'] | True |
fixup_namespace_packages | (path_item, parent=None) | Ensure that previously-declared namespace packages include path_item | Ensure that previously-declared namespace packages include path_item | def fixup_namespace_packages(path_item, parent=None):
"""Ensure that previously-declared namespace packages include path_item"""
_imp.acquire_lock()
try:
for package in _namespace_packages.get(parent, ()):
subpath = _handle_ns(package, path_item)
if subpath:
f... | [
"def",
"fixup_namespace_packages",
"(",
"path_item",
",",
"parent",
"=",
"None",
")",
":",
"_imp",
".",
"acquire_lock",
"(",
")",
"try",
":",
"for",
"package",
"in",
"_namespace_packages",
".",
"get",
"(",
"parent",
",",
"(",
")",
")",
":",
"subpath",
"=... | [
2289,
0
] | [
2298,
27
] | python | en | ['en', 'en', 'en'] | True |
file_ns_handler | (importer, path_item, packageName, module) | Compute an ns-package subpath for a filesystem or zipfile importer | Compute an ns-package subpath for a filesystem or zipfile importer | def file_ns_handler(importer, path_item, packageName, module):
"""Compute an ns-package subpath for a filesystem or zipfile importer"""
subpath = os.path.join(path_item, packageName.split('.')[-1])
normalized = _normalize_cached(subpath)
for item in module.__path__:
if _normalize_cached(item) =... | [
"def",
"file_ns_handler",
"(",
"importer",
",",
"path_item",
",",
"packageName",
",",
"module",
")",
":",
"subpath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"path_item",
",",
"packageName",
".",
"split",
"(",
"'.'",
")",
"[",
"-",
"1",
"]",
")",
"n... | [
2301,
0
] | [
2311,
22
] | python | en | ['en', 'en', 'en'] | True |
normalize_path | (filename) | Normalize a file/dir name for comparison purposes | Normalize a file/dir name for comparison purposes | def normalize_path(filename):
"""Normalize a file/dir name for comparison purposes"""
return os.path.normcase(os.path.realpath(os.path.normpath(_cygwin_patch(filename)))) | [
"def",
"normalize_path",
"(",
"filename",
")",
":",
"return",
"os",
".",
"path",
".",
"normcase",
"(",
"os",
".",
"path",
".",
"realpath",
"(",
"os",
".",
"path",
".",
"normpath",
"(",
"_cygwin_patch",
"(",
"filename",
")",
")",
")",
")"
] | [
2328,
0
] | [
2330,
88
] | python | en | ['en', 'it', 'en'] | True |
_cygwin_patch | (filename) |
Contrary to POSIX 2008, on Cygwin, getcwd (3) contains
symlink components. Using
os.path.abspath() works around this limitation. A fix in os.getcwd()
would probably better, in Cygwin even more so, except
that this seems to be by design...
|
Contrary to POSIX 2008, on Cygwin, getcwd (3) contains
symlink components. Using
os.path.abspath() works around this limitation. A fix in os.getcwd()
would probably better, in Cygwin even more so, except
that this seems to be by design...
| def _cygwin_patch(filename): # pragma: nocover
"""
Contrary to POSIX 2008, on Cygwin, getcwd (3) contains
symlink components. Using
os.path.abspath() works around this limitation. A fix in os.getcwd()
would probably better, in Cygwin even more so, except
that this seems to be by design...
"... | [
"def",
"_cygwin_patch",
"(",
"filename",
")",
":",
"# pragma: nocover",
"return",
"os",
".",
"path",
".",
"abspath",
"(",
"filename",
")",
"if",
"sys",
".",
"platform",
"==",
"'cygwin'",
"else",
"filename"
] | [
2333,
0
] | [
2341,
78
] | python | en | ['en', 'error', 'th'] | False |
_is_egg_path | (path) |
Determine if given path appears to be an egg.
|
Determine if given path appears to be an egg.
| def _is_egg_path(path):
"""
Determine if given path appears to be an egg.
"""
return path.lower().endswith('.egg') | [
"def",
"_is_egg_path",
"(",
"path",
")",
":",
"return",
"path",
".",
"lower",
"(",
")",
".",
"endswith",
"(",
"'.egg'",
")"
] | [
2352,
0
] | [
2356,
40
] | python | en | ['en', 'error', 'th'] | False |
_is_unpacked_egg | (path) |
Determine if given path appears to be an unpacked egg.
|
Determine if given path appears to be an unpacked egg.
| def _is_unpacked_egg(path):
"""
Determine if given path appears to be an unpacked egg.
"""
return (
_is_egg_path(path) and
os.path.isfile(os.path.join(path, 'EGG-INFO', 'PKG-INFO'))
) | [
"def",
"_is_unpacked_egg",
"(",
"path",
")",
":",
"return",
"(",
"_is_egg_path",
"(",
"path",
")",
"and",
"os",
".",
"path",
".",
"isfile",
"(",
"os",
".",
"path",
".",
"join",
"(",
"path",
",",
"'EGG-INFO'",
",",
"'PKG-INFO'",
")",
")",
")"
] | [
2359,
0
] | [
2366,
5
] | python | en | ['en', 'error', 'th'] | False |
yield_lines | (strs) | Yield non-empty/non-comment lines of a string or sequence | Yield non-empty/non-comment lines of a string or sequence | def yield_lines(strs):
"""Yield non-empty/non-comment lines of a string or sequence"""
if isinstance(strs, six.string_types):
for s in strs.splitlines():
s = s.strip()
# skip blank lines/comments
if s and not s.startswith('#'):
yield s
else:
... | [
"def",
"yield_lines",
"(",
"strs",
")",
":",
"if",
"isinstance",
"(",
"strs",
",",
"six",
".",
"string_types",
")",
":",
"for",
"s",
"in",
"strs",
".",
"splitlines",
"(",
")",
":",
"s",
"=",
"s",
".",
"strip",
"(",
")",
"# skip blank lines/comments",
... | [
2377,
0
] | [
2388,
23
] | python | en | ['en', 'en', 'en'] | True |
_version_from_file | (lines) |
Given an iterable of lines from a Metadata file, return
the value of the Version field, if present, or None otherwise.
|
Given an iterable of lines from a Metadata file, return
the value of the Version field, if present, or None otherwise.
| def _version_from_file(lines):
"""
Given an iterable of lines from a Metadata file, return
the value of the Version field, if present, or None otherwise.
"""
def is_version_line(line):
return line.lower().startswith('version:')
version_lines = filter(is_version_line, lines)
line = ne... | [
"def",
"_version_from_file",
"(",
"lines",
")",
":",
"def",
"is_version_line",
"(",
"line",
")",
":",
"return",
"line",
".",
"lower",
"(",
")",
".",
"startswith",
"(",
"'version:'",
")",
"version_lines",
"=",
"filter",
"(",
"is_version_line",
",",
"lines",
... | [
2547,
0
] | [
2557,
46
] | python | en | ['en', 'error', 'th'] | False |
VersionConflict.with_context | (self, required_by) |
If required_by is non-empty, return a version of self that is a
ContextualVersionConflict.
|
If required_by is non-empty, return a version of self that is a
ContextualVersionConflict.
| def with_context(self, required_by):
"""
If required_by is non-empty, return a version of self that is a
ContextualVersionConflict.
"""
if not required_by:
return self
args = self.args + (required_by,)
return ContextualVersionConflict(*args) | [
"def",
"with_context",
"(",
"self",
",",
"required_by",
")",
":",
"if",
"not",
"required_by",
":",
"return",
"self",
"args",
"=",
"self",
".",
"args",
"+",
"(",
"required_by",
",",
")",
"return",
"ContextualVersionConflict",
"(",
"*",
"args",
")"
] | [
278,
4
] | [
286,
47
] | python | en | ['en', 'error', 'th'] | False |
IMetadataProvider.has_metadata | (name) | Does the package's distribution contain the named metadata? | Does the package's distribution contain the named metadata? | def has_metadata(name):
"""Does the package's distribution contain the named metadata?""" | [
"def",
"has_metadata",
"(",
"name",
")",
":"
] | [
502,
4
] | [
503,
73
] | python | en | ['en', 'en', 'en'] | True |
IMetadataProvider.get_metadata | (name) | The named metadata resource as a string | The named metadata resource as a string | def get_metadata(name):
"""The named metadata resource as a string""" | [
"def",
"get_metadata",
"(",
"name",
")",
":"
] | [
505,
4
] | [
506,
53
] | python | en | ['en', 'en', 'en'] | True |
IMetadataProvider.get_metadata_lines | (name) | Yield named metadata resource as list of non-blank non-comment lines
Leading and trailing whitespace is stripped from each line, and lines
with ``#`` as the first non-blank character are omitted. | Yield named metadata resource as list of non-blank non-comment lines | def get_metadata_lines(name):
"""Yield named metadata resource as list of non-blank non-comment lines
Leading and trailing whitespace is stripped from each line, and lines
with ``#`` as the first non-blank character are omitted.""" | [
"def",
"get_metadata_lines",
"(",
"name",
")",
":"
] | [
508,
4
] | [
512,
66
] | python | en | ['en', 'en', 'en'] | True |
IMetadataProvider.metadata_isdir | (name) | Is the named metadata a directory? (like ``os.path.isdir()``) | Is the named metadata a directory? (like ``os.path.isdir()``) | def metadata_isdir(name):
"""Is the named metadata a directory? (like ``os.path.isdir()``)""" | [
"def",
"metadata_isdir",
"(",
"name",
")",
":"
] | [
514,
4
] | [
515,
76
] | python | en | ['en', 'en', 'en'] | True |
IMetadataProvider.metadata_listdir | (name) | List of metadata names in the directory (like ``os.listdir()``) | List of metadata names in the directory (like ``os.listdir()``) | def metadata_listdir(name):
"""List of metadata names in the directory (like ``os.listdir()``)""" | [
"def",
"metadata_listdir",
"(",
"name",
")",
":"
] | [
517,
4
] | [
518,
77
] | python | en | ['en', 'en', 'en'] | True |
IMetadataProvider.run_script | (script_name, namespace) | Execute the named script in the supplied namespace dictionary | Execute the named script in the supplied namespace dictionary | def run_script(script_name, namespace):
"""Execute the named script in the supplied namespace dictionary""" | [
"def",
"run_script",
"(",
"script_name",
",",
"namespace",
")",
":"
] | [
520,
4
] | [
521,
75
] | python | en | ['en', 'en', 'en'] | True |
IResourceProvider.get_resource_filename | (manager, resource_name) | Return a true filesystem path for `resource_name`
`manager` must be an ``IResourceManager`` | Return a true filesystem path for `resource_name` | def get_resource_filename(manager, resource_name):
"""Return a true filesystem path for `resource_name`
`manager` must be an ``IResourceManager``""" | [
"def",
"get_resource_filename",
"(",
"manager",
",",
"resource_name",
")",
":"
] | [
527,
4
] | [
530,
52
] | python | en | ['en', 'en', 'en'] | True |
IResourceProvider.get_resource_stream | (manager, resource_name) | Return a readable file-like object for `resource_name`
`manager` must be an ``IResourceManager`` | Return a readable file-like object for `resource_name` | def get_resource_stream(manager, resource_name):
"""Return a readable file-like object for `resource_name`
`manager` must be an ``IResourceManager``""" | [
"def",
"get_resource_stream",
"(",
"manager",
",",
"resource_name",
")",
":"
] | [
532,
4
] | [
535,
52
] | python | en | ['en', 'en', 'en'] | True |
IResourceProvider.get_resource_string | (manager, resource_name) | Return a string containing the contents of `resource_name`
`manager` must be an ``IResourceManager`` | Return a string containing the contents of `resource_name` | def get_resource_string(manager, resource_name):
"""Return a string containing the contents of `resource_name`
`manager` must be an ``IResourceManager``""" | [
"def",
"get_resource_string",
"(",
"manager",
",",
"resource_name",
")",
":"
] | [
537,
4
] | [
540,
52
] | python | en | ['en', 'en', 'en'] | True |
IResourceProvider.has_resource | (resource_name) | Does the package contain the named resource? | Does the package contain the named resource? | def has_resource(resource_name):
"""Does the package contain the named resource?""" | [
"def",
"has_resource",
"(",
"resource_name",
")",
":"
] | [
542,
4
] | [
543,
58
] | python | en | ['en', 'en', 'en'] | True |
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",
")",
":"
] | [
545,
4
] | [
546,
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",
")",
":"
] | [
548,
4
] | [
549,
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"... | [
555,
4
] | [
566,
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",
... | [
569,
4
] | [
586,
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",
"=",
... | [
589,
4
] | [
608,
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",
... | [
610,
4
] | [
623,
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"
] | [
625,
4
] | [
627,
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... | [
629,
4
] | [
643,
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... | [
645,
4
] | [
657,
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__'",
... | [
659,
4
] | [
665,
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... | [
667,
4
] | [
682,
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",
"=",
... | [
684,
4
] | [
712,
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"... | [
714,
4
] | [
804,
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... | [
806,
4
] | [
888,
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... | [
890,
4
] | [
904,
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... | [
906,
4
] | [
918,
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",... | [
943,
4
] | [
955,
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",... | [
961,
4
] | [
983,
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",
... | [
985,
4
] | [
997,
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",
")"
] | [
999,
4
] | [
1001,
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",
")",
... | [
1003,
4
] | [
1016,
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",
",",
"[",
"]",
")"
] | [
1018,
4
] | [
1027,
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",
",",
"[",
"]",
... | [
1029,
4
] | [
1036,
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",
":",
"... | [
1038,
4
] | [
1064,
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",
")"
] | [
1066,
4
] | [
1076,
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"
] | [
1078,
4
] | [
1082,
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",
... | [
1084,
4
] | [
1094,
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"... | [
1096,
4
] | [
1101,
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",
")"
] | [
1131,
4
] | [
1133,
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",
")"
] | [
1135,
4
] | [
1139,
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",
")"
] | [
1141,
4
] | [
1145,
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",
")"
] | [
1147,
4
] | [
1151,
9
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.