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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
WaitTask.__await__ | (self) | Make this class **awaitable**. | Make this class **awaitable**. | def __await__(self) -> Generator:
"""Make this class **awaitable**."""
result = yield from self.promise
if isinstance(result, Exception):
raise result
return result | [
"def",
"__await__",
"(",
"self",
")",
"->",
"Generator",
":",
"result",
"=",
"yield",
"from",
"self",
".",
"promise",
"if",
"isinstance",
"(",
"result",
",",
"Exception",
")",
":",
"raise",
"result",
"return",
"result"
] | [
850,
4
] | [
855,
21
] | python | en | ['en', 'ceb', 'en'] | True |
WaitTask.terminate | (self, error: Exception) | Terminate this task. | Terminate this task. | def terminate(self, error: Exception) -> None:
"""Terminate this task."""
self._terminated = True
if not self.promise.done():
self.promise.set_result(error)
self._cleanup() | [
"def",
"terminate",
"(",
"self",
",",
"error",
":",
"Exception",
")",
"->",
"None",
":",
"self",
".",
"_terminated",
"=",
"True",
"if",
"not",
"self",
".",
"promise",
".",
"done",
"(",
")",
":",
"self",
".",
"promise",
".",
"set_result",
"(",
"error"... | [
857,
4
] | [
862,
23
] | python | en | ['en', 'la', 'en'] | True |
WaitTask.rerun | (self) | Start polling. | Start polling. | async def rerun(self) -> None: # noqa: C901
"""Start polling."""
runCount = self._runCount = self._runCount + 1
success: Optional[JSHandle] = None
error = None
try:
context = await self._frame.executionContext()
if context is None:
raise ... | [
"async",
"def",
"rerun",
"(",
"self",
")",
"->",
"None",
":",
"# noqa: C901",
"runCount",
"=",
"self",
".",
"_runCount",
"=",
"self",
".",
"_runCount",
"+",
"1",
"success",
":",
"Optional",
"[",
"JSHandle",
"]",
"=",
"None",
"error",
"=",
"None",
"try"... | [
864,
4
] | [
919,
23
] | python | en | ['en', 'jv', 'en'] | False |
get_fixed_timezone | (offset) |
Returns a tzinfo instance with a fixed offset from UTC.
|
Returns a tzinfo instance with a fixed offset from UTC.
| def get_fixed_timezone(offset):
"""
Returns a tzinfo instance with a fixed offset from UTC.
"""
if isinstance(offset, timedelta):
offset = offset.seconds // 60
sign = '-' if offset < 0 else '+'
hhmm = '%02d%02d' % divmod(abs(offset), 60)
name = sign + hhmm
return FixedOffset(offs... | [
"def",
"get_fixed_timezone",
"(",
"offset",
")",
":",
"if",
"isinstance",
"(",
"offset",
",",
"timedelta",
")",
":",
"offset",
"=",
"offset",
".",
"seconds",
"//",
"60",
"sign",
"=",
"'-'",
"if",
"offset",
"<",
"0",
"else",
"'+'",
"hhmm",
"=",
"'%02d%0... | [
57,
0
] | [
66,
36
] | python | en | ['en', 'error', 'th'] | False |
get_default_timezone | () |
Returns the default time zone as a tzinfo instance.
This is the time zone defined by settings.TIME_ZONE.
|
Returns the default time zone as a tzinfo instance. | def get_default_timezone():
"""
Returns the default time zone as a tzinfo instance.
This is the time zone defined by settings.TIME_ZONE.
"""
return pytz.timezone(settings.TIME_ZONE) | [
"def",
"get_default_timezone",
"(",
")",
":",
"return",
"pytz",
".",
"timezone",
"(",
"settings",
".",
"TIME_ZONE",
")"
] | [
72,
0
] | [
78,
44
] | python | en | ['en', 'error', 'th'] | False |
get_default_timezone_name | () |
Returns the name of the default time zone.
|
Returns the name of the default time zone.
| def get_default_timezone_name():
"""
Returns the name of the default time zone.
"""
return _get_timezone_name(get_default_timezone()) | [
"def",
"get_default_timezone_name",
"(",
")",
":",
"return",
"_get_timezone_name",
"(",
"get_default_timezone",
"(",
")",
")"
] | [
82,
0
] | [
86,
53
] | python | en | ['en', 'error', 'th'] | False |
get_current_timezone | () |
Returns the currently active time zone as a tzinfo instance.
|
Returns the currently active time zone as a tzinfo instance.
| def get_current_timezone():
"""
Returns the currently active time zone as a tzinfo instance.
"""
return getattr(_active, "value", get_default_timezone()) | [
"def",
"get_current_timezone",
"(",
")",
":",
"return",
"getattr",
"(",
"_active",
",",
"\"value\"",
",",
"get_default_timezone",
"(",
")",
")"
] | [
92,
0
] | [
96,
60
] | python | en | ['en', 'error', 'th'] | False |
get_current_timezone_name | () |
Returns the name of the currently active time zone.
|
Returns the name of the currently active time zone.
| def get_current_timezone_name():
"""
Returns the name of the currently active time zone.
"""
return _get_timezone_name(get_current_timezone()) | [
"def",
"get_current_timezone_name",
"(",
")",
":",
"return",
"_get_timezone_name",
"(",
"get_current_timezone",
"(",
")",
")"
] | [
99,
0
] | [
103,
53
] | python | en | ['en', 'error', 'th'] | False |
_get_timezone_name | (timezone) |
Returns the name of ``timezone``.
|
Returns the name of ``timezone``.
| def _get_timezone_name(timezone):
"""
Returns the name of ``timezone``.
"""
try:
# for pytz timezones
return timezone.zone
except AttributeError:
# for regular tzinfo objects
return timezone.tzname(None) | [
"def",
"_get_timezone_name",
"(",
"timezone",
")",
":",
"try",
":",
"# for pytz timezones",
"return",
"timezone",
".",
"zone",
"except",
"AttributeError",
":",
"# for regular tzinfo objects",
"return",
"timezone",
".",
"tzname",
"(",
"None",
")"
] | [
106,
0
] | [
115,
36
] | python | en | ['en', 'error', 'th'] | False |
activate | (timezone) |
Sets the time zone for the current thread.
The ``timezone`` argument must be an instance of a tzinfo subclass or a
time zone name.
|
Sets the time zone for the current thread. | def activate(timezone):
"""
Sets the time zone for the current thread.
The ``timezone`` argument must be an instance of a tzinfo subclass or a
time zone name.
"""
if isinstance(timezone, tzinfo):
_active.value = timezone
elif isinstance(timezone, six.string_types):
_active.v... | [
"def",
"activate",
"(",
"timezone",
")",
":",
"if",
"isinstance",
"(",
"timezone",
",",
"tzinfo",
")",
":",
"_active",
".",
"value",
"=",
"timezone",
"elif",
"isinstance",
"(",
"timezone",
",",
"six",
".",
"string_types",
")",
":",
"_active",
".",
"value... | [
123,
0
] | [
135,
59
] | python | en | ['en', 'error', 'th'] | False |
deactivate | () |
Unsets the time zone for the current thread.
Django will then use the time zone defined by settings.TIME_ZONE.
|
Unsets the time zone for the current thread. | def deactivate():
"""
Unsets the time zone for the current thread.
Django will then use the time zone defined by settings.TIME_ZONE.
"""
if hasattr(_active, "value"):
del _active.value | [
"def",
"deactivate",
"(",
")",
":",
"if",
"hasattr",
"(",
"_active",
",",
"\"value\"",
")",
":",
"del",
"_active",
".",
"value"
] | [
138,
0
] | [
145,
25
] | python | en | ['en', 'error', 'th'] | False |
template_localtime | (value, use_tz=None) |
Checks if value is a datetime and converts it to local time if necessary.
If use_tz is provided and is not None, that will force the value to
be converted (or not), overriding the value of settings.USE_TZ.
This function is designed for use by the template engine.
|
Checks if value is a datetime and converts it to local time if necessary. | def template_localtime(value, use_tz=None):
"""
Checks if value is a datetime and converts it to local time if necessary.
If use_tz is provided and is not None, that will force the value to
be converted (or not), overriding the value of settings.USE_TZ.
This function is designed for use by the tem... | [
"def",
"template_localtime",
"(",
"value",
",",
"use_tz",
"=",
"None",
")",
":",
"should_convert",
"=",
"(",
"isinstance",
"(",
"value",
",",
"datetime",
")",
"and",
"(",
"settings",
".",
"USE_TZ",
"if",
"use_tz",
"is",
"None",
"else",
"use_tz",
")",
"an... | [
179,
0
] | [
194,
56
] | python | en | ['en', 'error', 'th'] | False |
localtime | (value=None, timezone=None) |
Converts an aware datetime.datetime to local time.
Only aware datetimes are allowed. When value is omitted, it defaults to
now().
Local time is defined by the current time zone, unless another time zone
is specified.
|
Converts an aware datetime.datetime to local time. | def localtime(value=None, timezone=None):
"""
Converts an aware datetime.datetime to local time.
Only aware datetimes are allowed. When value is omitted, it defaults to
now().
Local time is defined by the current time zone, unless another time zone
is specified.
"""
if value is None:
... | [
"def",
"localtime",
"(",
"value",
"=",
"None",
",",
"timezone",
"=",
"None",
")",
":",
"if",
"value",
"is",
"None",
":",
"value",
"=",
"now",
"(",
")",
"if",
"timezone",
"is",
"None",
":",
"timezone",
"=",
"get_current_timezone",
"(",
")",
"# Emulate t... | [
199,
0
] | [
220,
16
] | python | en | ['en', 'error', 'th'] | False |
localdate | (value=None, timezone=None) |
Convert an aware datetime to local time and return the value's date.
Only aware datetimes are allowed. When value is omitted, it defaults to
now().
Local time is defined by the current time zone, unless another time zone is
specified.
|
Convert an aware datetime to local time and return the value's date. | def localdate(value=None, timezone=None):
"""
Convert an aware datetime to local time and return the value's date.
Only aware datetimes are allowed. When value is omitted, it defaults to
now().
Local time is defined by the current time zone, unless another time zone is
specified.
"""
r... | [
"def",
"localdate",
"(",
"value",
"=",
"None",
",",
"timezone",
"=",
"None",
")",
":",
"return",
"localtime",
"(",
"value",
",",
"timezone",
")",
".",
"date",
"(",
")"
] | [
223,
0
] | [
233,
44
] | python | en | ['en', 'error', 'th'] | False |
now | () |
Returns an aware or naive datetime.datetime, depending on settings.USE_TZ.
|
Returns an aware or naive datetime.datetime, depending on settings.USE_TZ.
| def now():
"""
Returns an aware or naive datetime.datetime, depending on settings.USE_TZ.
"""
if settings.USE_TZ:
# timeit shows that datetime.now(tz=utc) is 24% slower
return datetime.utcnow().replace(tzinfo=utc)
else:
return datetime.now() | [
"def",
"now",
"(",
")",
":",
"if",
"settings",
".",
"USE_TZ",
":",
"# timeit shows that datetime.now(tz=utc) is 24% slower",
"return",
"datetime",
".",
"utcnow",
"(",
")",
".",
"replace",
"(",
"tzinfo",
"=",
"utc",
")",
"else",
":",
"return",
"datetime",
".",
... | [
236,
0
] | [
244,
29
] | python | en | ['en', 'error', 'th'] | False |
is_aware | (value) |
Determines if a given datetime.datetime is aware.
The concept is defined in Python's docs:
http://docs.python.org/library/datetime.html#datetime.tzinfo
Assuming value.tzinfo is either None or a proper datetime.tzinfo,
value.utcoffset() implements the appropriate logic.
|
Determines if a given datetime.datetime is aware. | def is_aware(value):
"""
Determines if a given datetime.datetime is aware.
The concept is defined in Python's docs:
http://docs.python.org/library/datetime.html#datetime.tzinfo
Assuming value.tzinfo is either None or a proper datetime.tzinfo,
value.utcoffset() implements the appropriate logic.... | [
"def",
"is_aware",
"(",
"value",
")",
":",
"return",
"value",
".",
"utcoffset",
"(",
")",
"is",
"not",
"None"
] | [
250,
0
] | [
260,
40
] | python | en | ['en', 'error', 'th'] | False |
is_naive | (value) |
Determines if a given datetime.datetime is naive.
The concept is defined in Python's docs:
http://docs.python.org/library/datetime.html#datetime.tzinfo
Assuming value.tzinfo is either None or a proper datetime.tzinfo,
value.utcoffset() implements the appropriate logic.
|
Determines if a given datetime.datetime is naive. | def is_naive(value):
"""
Determines if a given datetime.datetime is naive.
The concept is defined in Python's docs:
http://docs.python.org/library/datetime.html#datetime.tzinfo
Assuming value.tzinfo is either None or a proper datetime.tzinfo,
value.utcoffset() implements the appropriate logic.... | [
"def",
"is_naive",
"(",
"value",
")",
":",
"return",
"value",
".",
"utcoffset",
"(",
")",
"is",
"None"
] | [
263,
0
] | [
273,
36
] | python | en | ['en', 'error', 'th'] | False |
make_aware | (value, timezone=None, is_dst=None) |
Makes a naive datetime.datetime in a given time zone aware.
|
Makes a naive datetime.datetime in a given time zone aware.
| def make_aware(value, timezone=None, is_dst=None):
"""
Makes a naive datetime.datetime in a given time zone aware.
"""
if timezone is None:
timezone = get_current_timezone()
if hasattr(timezone, 'localize'):
# This method is available for pytz time zones.
return timezone.loca... | [
"def",
"make_aware",
"(",
"value",
",",
"timezone",
"=",
"None",
",",
"is_dst",
"=",
"None",
")",
":",
"if",
"timezone",
"is",
"None",
":",
"timezone",
"=",
"get_current_timezone",
"(",
")",
"if",
"hasattr",
"(",
"timezone",
",",
"'localize'",
")",
":",
... | [
276,
0
] | [
291,
45
] | python | en | ['en', 'error', 'th'] | False |
make_naive | (value, timezone=None) |
Makes an aware datetime.datetime naive in a given time zone.
|
Makes an aware datetime.datetime naive in a given time zone.
| def make_naive(value, timezone=None):
"""
Makes an aware datetime.datetime naive in a given time zone.
"""
if timezone is None:
timezone = get_current_timezone()
# Emulate the behavior of astimezone() on Python < 3.6.
if is_naive(value):
raise ValueError("make_naive() cannot be a... | [
"def",
"make_naive",
"(",
"value",
",",
"timezone",
"=",
"None",
")",
":",
"if",
"timezone",
"is",
"None",
":",
"timezone",
"=",
"get_current_timezone",
"(",
")",
"# Emulate the behavior of astimezone() on Python < 3.6.",
"if",
"is_naive",
"(",
"value",
")",
":",
... | [
294,
0
] | [
307,
37
] | python | en | ['en', 'error', 'th'] | False |
once | (__init__) |
Decorate the __init__ method of a class if you don't want to init a class twice when using a singleton
The class have to embed a class variable named _init by default at False
:param __init__:
:return:
|
Decorate the __init__ method of a class if you don't want to init a class twice when using a singleton
The class have to embed a class variable named _init by default at False
:param __init__:
:return:
| def once(__init__):
"""
Decorate the __init__ method of a class if you don't want to init a class twice when using a singleton
The class have to embed a class variable named _init by default at False
:param __init__:
:return:
"""
def wrapper(*args, **kwargs):
self = args[0]
... | [
"def",
"once",
"(",
"__init__",
")",
":",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
"=",
"args",
"[",
"0",
"]",
"if",
"self",
".",
"_init",
"is",
"True",
":",
"return",
"__init__",
"(",
"*",
"args",
",",
"*"... | [
9,
0
] | [
25,
18
] | python | en | ['en', 'error', 'th'] | False |
extract_exception_name | (exc_info=None) |
Function to get the exception name and module
:param exc_info:
:return:
|
Function to get the exception name and module
:param exc_info:
:return:
| def extract_exception_name(exc_info=None):
"""
Function to get the exception name and module
:param exc_info:
:return:
"""
if not exc_info:
exc_info = sys.exc_info()
return '{}.{}'.format(exc_info[0].__module__, exc_info[0].__name__) | [
"def",
"extract_exception_name",
"(",
"exc_info",
"=",
"None",
")",
":",
"if",
"not",
"exc_info",
":",
"exc_info",
"=",
"sys",
".",
"exc_info",
"(",
")",
"return",
"'{}.{}'",
".",
"format",
"(",
"exc_info",
"[",
"0",
"]",
".",
"__module__",
",",
"exc_inf... | [
68,
0
] | [
76,
71
] | python | en | ['en', 'error', 'th'] | False |
monitor_flask | (app: Flask) |
Add components to monitor each route with prometheus
The monitoring is available at /metrics
:param app: Flask application
:return:
|
Add components to monitor each route with prometheus
The monitoring is available at /metrics
:param app: Flask application
:return:
| def monitor_flask(app: Flask):
"""
Add components to monitor each route with prometheus
The monitoring is available at /metrics
:param app: Flask application
:return:
"""
metrics = CollectorRegistry()
def collect():
registry = CollectorRegistry()
multiprocess.MultiProces... | [
"def",
"monitor_flask",
"(",
"app",
":",
"Flask",
")",
":",
"metrics",
"=",
"CollectorRegistry",
"(",
")",
"def",
"collect",
"(",
")",
":",
"registry",
"=",
"CollectorRegistry",
"(",
")",
"multiprocess",
".",
"MultiProcessCollector",
"(",
"registry",
")",
"d... | [
79,
0
] | [
145,
37
] | python | en | ['en', 'error', 'th'] | False |
DatabaseMonitoring.observe_transaction | (self, caller: str) |
Wrapper to call around transaction against a database
:param caller:
:return:
|
Wrapper to call around transaction against a database
:param caller:
:return:
| def observe_transaction(self, caller: str):
"""
Wrapper to call around transaction against a database
:param caller:
:return:
"""
start = time.time()
try:
yield
except Exception as e:
self.exception_count.labels(caller, type(e).__na... | [
"def",
"observe_transaction",
"(",
"self",
",",
"caller",
":",
"str",
")",
":",
"start",
"=",
"time",
".",
"time",
"(",
")",
"try",
":",
"yield",
"except",
"Exception",
"as",
"e",
":",
"self",
".",
"exception_count",
".",
"labels",
"(",
"caller",
",",
... | [
50,
4
] | [
65,
51
] | python | en | ['en', 'error', 'th'] | False |
GenericParser._get_image | (self) |
Finding a first image after the h1 header.
Presumably it will be the main image.
|
Finding a first image after the h1 header.
Presumably it will be the main image.
| def _get_image(self) -> Optional[str]:
"""
Finding a first image after the h1 header.
Presumably it will be the main image.
"""
soup = self._soup
first_h1 = soup.find("h1")
if first_h1:
first_image = first_h1.find_next_sibling("img", src=True)
... | [
"def",
"_get_image",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"soup",
"=",
"self",
".",
"_soup",
"first_h1",
"=",
"soup",
".",
"find",
"(",
"\"h1\"",
")",
"if",
"first_h1",
":",
"first_image",
"=",
"first_h1",
".",
"find_next_sibling",
... | [
36,
4
] | [
47,
19
] | python | en | ['en', 'error', 'th'] | False |
is_iterable | (x) | A implementation independent way of checking for iterables | A implementation independent way of checking for iterables | def is_iterable(x):
"A implementation independent way of checking for iterables"
try:
iter(x)
except TypeError:
return False
else:
return True | [
"def",
"is_iterable",
"(",
"x",
")",
":",
"try",
":",
"iter",
"(",
"x",
")",
"except",
"TypeError",
":",
"return",
"False",
"else",
":",
"return",
"True"
] | [
7,
0
] | [
14,
19
] | python | en | ['en', 'en', 'en'] | True |
TestSnippetListView.test_ordering | (self) |
Listing should be ordered by PK if no ordering has been set on the model
|
Listing should be ordered by PK if no ordering has been set on the model
| def test_ordering(self):
"""
Listing should be ordered by PK if no ordering has been set on the model
"""
for i in range(10, 0, -1):
Advert.objects.create(pk=i, text="advert %d" % i)
response = self.get()
self.assertEqual(response.status_code, 200)
sel... | [
"def",
"test_ordering",
"(",
"self",
")",
":",
"for",
"i",
"in",
"range",
"(",
"10",
",",
"0",
",",
"-",
"1",
")",
":",
"Advert",
".",
"objects",
".",
"create",
"(",
"pk",
"=",
"i",
",",
"text",
"=",
"\"advert %d\"",
"%",
"i",
")",
"response",
... | [
91,
4
] | [
99,
71
] | python | en | ['en', 'error', 'th'] | False |
TestSnippetChoose.test_ordering | (self) |
Listing should be ordered by PK if no ordering has been set on the model
|
Listing should be ordered by PK if no ordering has been set on the model
| def test_ordering(self):
"""
Listing should be ordered by PK if no ordering has been set on the model
"""
Advert.objects.all().delete()
for i in range(10, 0, -1):
Advert.objects.create(pk=i, text="advert %d" % i)
response = self.get()
self.assertEqual(... | [
"def",
"test_ordering",
"(",
"self",
")",
":",
"Advert",
".",
"objects",
".",
"all",
"(",
")",
".",
"delete",
"(",
")",
"for",
"i",
"in",
"range",
"(",
"10",
",",
"0",
",",
"-",
"1",
")",
":",
"Advert",
".",
"objects",
".",
"create",
"(",
"pk",... | [
1067,
4
] | [
1076,
71
] | python | en | ['en', 'error', 'th'] | False |
TestSnippetChooserBlock.test_serialize | (self) | The value of a SnippetChooserBlock (a snippet instance) should serialize to an ID | The value of a SnippetChooserBlock (a snippet instance) should serialize to an ID | def test_serialize(self):
"""The value of a SnippetChooserBlock (a snippet instance) should serialize to an ID"""
block = SnippetChooserBlock(Advert)
test_advert = Advert.objects.get(text='test_advert')
self.assertEqual(block.get_prep_value(test_advert), test_advert.id)
# None ... | [
"def",
"test_serialize",
"(",
"self",
")",
":",
"block",
"=",
"SnippetChooserBlock",
"(",
"Advert",
")",
"test_advert",
"=",
"Advert",
".",
"objects",
".",
"get",
"(",
"text",
"=",
"'test_advert'",
")",
"self",
".",
"assertEqual",
"(",
"block",
".",
"get_p... | [
1363,
4
] | [
1371,
58
] | python | en | ['en', 'en', 'en'] | True |
TestSnippetChooserBlock.test_deserialize | (self) | The serialized value of a SnippetChooserBlock (an ID) should deserialize to a snippet instance | The serialized value of a SnippetChooserBlock (an ID) should deserialize to a snippet instance | def test_deserialize(self):
"""The serialized value of a SnippetChooserBlock (an ID) should deserialize to a snippet instance"""
block = SnippetChooserBlock(Advert)
test_advert = Advert.objects.get(text='test_advert')
self.assertEqual(block.to_python(test_advert.id), test_advert)
... | [
"def",
"test_deserialize",
"(",
"self",
")",
":",
"block",
"=",
"SnippetChooserBlock",
"(",
"Advert",
")",
"test_advert",
"=",
"Advert",
".",
"objects",
".",
"get",
"(",
"text",
"=",
"'test_advert'",
")",
"self",
".",
"assertEqual",
"(",
"block",
".",
"to_... | [
1373,
4
] | [
1381,
53
] | python | en | ['en', 'en', 'en'] | True |
TestSnippetChooserBlockWithCustomPrimaryKey.test_serialize | (self) | The value of a SnippetChooserBlock (a snippet instance) should serialize to an ID | The value of a SnippetChooserBlock (a snippet instance) should serialize to an ID | def test_serialize(self):
"""The value of a SnippetChooserBlock (a snippet instance) should serialize to an ID"""
block = SnippetChooserBlock(AdvertWithCustomPrimaryKey)
test_advert = AdvertWithCustomPrimaryKey.objects.get(pk='advert/01')
self.assertEqual(block.get_prep_value(test_adver... | [
"def",
"test_serialize",
"(",
"self",
")",
":",
"block",
"=",
"SnippetChooserBlock",
"(",
"AdvertWithCustomPrimaryKey",
")",
"test_advert",
"=",
"AdvertWithCustomPrimaryKey",
".",
"objects",
".",
"get",
"(",
"pk",
"=",
"'advert/01'",
")",
"self",
".",
"assertEqual... | [
1546,
4
] | [
1554,
58
] | python | en | ['en', 'en', 'en'] | True |
TestSnippetChooserBlockWithCustomPrimaryKey.test_deserialize | (self) | The serialized value of a SnippetChooserBlock (an ID) should deserialize to a snippet instance | The serialized value of a SnippetChooserBlock (an ID) should deserialize to a snippet instance | def test_deserialize(self):
"""The serialized value of a SnippetChooserBlock (an ID) should deserialize to a snippet instance"""
block = SnippetChooserBlock(AdvertWithCustomPrimaryKey)
test_advert = AdvertWithCustomPrimaryKey.objects.get(pk='advert/01')
self.assertEqual(block.to_python(... | [
"def",
"test_deserialize",
"(",
"self",
")",
":",
"block",
"=",
"SnippetChooserBlock",
"(",
"AdvertWithCustomPrimaryKey",
")",
"test_advert",
"=",
"AdvertWithCustomPrimaryKey",
".",
"objects",
".",
"get",
"(",
"pk",
"=",
"'advert/01'",
")",
"self",
".",
"assertEqu... | [
1556,
4
] | [
1564,
53
] | python | en | ['en', 'en', 'en'] | True |
TestSnippetChooseWithCustomPrimaryKey.test_ordering | (self) |
Listing should be ordered by PK if no ordering has been set on the model
|
Listing should be ordered by PK if no ordering has been set on the model
| def test_ordering(self):
"""
Listing should be ordered by PK if no ordering has been set on the model
"""
AdvertWithCustomPrimaryKey.objects.all().delete()
for i in range(10, 0, -1):
AdvertWithCustomPrimaryKey.objects.create(pk=i, text="advert %d" % i)
respons... | [
"def",
"test_ordering",
"(",
"self",
")",
":",
"AdvertWithCustomPrimaryKey",
".",
"objects",
".",
"all",
"(",
")",
".",
"delete",
"(",
")",
"for",
"i",
"in",
"range",
"(",
"10",
",",
"0",
",",
"-",
"1",
")",
":",
"AdvertWithCustomPrimaryKey",
".",
"obj... | [
1685,
4
] | [
1694,
71
] | python | en | ['en', 'error', 'th'] | False |
ParserTest.test_validate_vanilla_html | (self) |
Verify that validate() does not raise errors for
well-formed HTML.
|
Verify that validate() does not raise errors for
well-formed HTML.
| def test_validate_vanilla_html(self) -> None:
"""
Verify that validate() does not raise errors for
well-formed HTML.
"""
my_html = """
<table>
<tr>
<td>foo</td>
</tr>
</table>"""
validate(text=my_html... | [
"def",
"test_validate_vanilla_html",
"(",
"self",
")",
"->",
"None",
":",
"my_html",
"=",
"\"\"\"\n <table>\n <tr>\n <td>foo</td>\n </tr>\n </table>\"\"\"",
"validate",
"(",
"text",
"=",
"my_html",
")"
] | [
31,
4
] | [
42,
30
] | python | en | ['en', 'error', 'th'] | False |
print_class | (class_name) | Read this file and print the section with the class name specified.) | Read this file and print the section with the class name specified.) | def print_class(class_name):
""" Read this file and print the section with the class name specified.)"""
filename = sys.argv[0]
with open(filename) as f:
data = f.read()
regex = "^(class " + class_name + "\\b.*?)^\\S"
match = re.search(regex, data, flags=re.MULTILINE | re.DOTALL)
... | [
"def",
"print_class",
"(",
"class_name",
")",
":",
"filename",
"=",
"sys",
".",
"argv",
"[",
"0",
"]",
"with",
"open",
"(",
"filename",
")",
"as",
"f",
":",
"data",
"=",
"f",
".",
"read",
"(",
")",
"regex",
"=",
"\"^(class \"",
"+",
"class_name",
"... | [
95,
0
] | [
103,
33
] | python | en | ['en', 'en', 'en'] | True |
TestBuildApp.build | (self) | Build called by kivy when an App is started.
Called after trying to load a .kv file.
Returns a new Button as a root widget.
| Build called by kivy when an App is started.
Called after trying to load a .kv file.
Returns a new Button as a root widget.
| def build(self):
""" Build called by kivy when an App is started.
Called after trying to load a .kv file.
Returns a new Button as a root widget.
"""
print("** inside build()")
return Button(text='hello from TestBuildApp') | [
"def",
"build",
"(",
"self",
")",
":",
"print",
"(",
"\"** inside build()\"",
")",
"return",
"Button",
"(",
"text",
"=",
"'hello from TestBuildApp'",
")"
] | [
34,
4
] | [
40,
53
] | python | en | ['en', 'en', 'en'] | True |
TestKVStringApp.build | (self) | Called by kivy run(). | Called by kivy run(). | def build(self):
""" Called by kivy run(). """
print("** inside build()")
widget = Builder.load_string(
"Button:\n text: 'hello from TestKVStringApp'")
print("** widget built")
return widget | [
"def",
"build",
"(",
"self",
")",
":",
"print",
"(",
"\"** inside build()\"",
")",
"widget",
"=",
"Builder",
".",
"load_string",
"(",
"\"Button:\\n text: 'hello from TestKVStringApp'\"",
")",
"print",
"(",
"\"** widget built\"",
")",
"return",
"widget"
] | [
68,
4
] | [
74,
21
] | python | en | ['en', 'fil', 'en'] | True |
TestPrebuiltApp.build | (self) | called, returns instance matching tag . | called, returns instance matching tag . | def build(self):
""" called, returns instance matching tag . """
return self.Prebuilt() | [
"def",
"build",
"(",
"self",
")",
":",
"return",
"self",
".",
"Prebuilt",
"(",
")"
] | [
90,
4
] | [
92,
30
] | python | en | ['en', 'en', 'en'] | True |
handle_event_payload | (event: Dict[str, Any]) | Handle either an exception type event or a message type event payload. | Handle either an exception type event or a message type event payload. | def handle_event_payload(event: Dict[str, Any]) -> Tuple[str, str]:
"""Handle either an exception type event or a message type event payload."""
# We shouldn't support the officially deprecated Raven series of SDKs.
if int(event["version"]) < 7:
raise UnsupportedWebhookEventType("Raven SDK")
su... | [
"def",
"handle_event_payload",
"(",
"event",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"Tuple",
"[",
"str",
",",
"str",
"]",
":",
"# We shouldn't support the officially deprecated Raven series of SDKs.",
"if",
"int",
"(",
"event",
"[",
"\"version\"",
... | [
93,
0
] | [
163,
26
] | python | en | ['en', 'en', 'en'] | True |
handle_issue_payload | (
action: str, issue: Dict[str, Any], actor: Dict[str, Any]
) | Handle either an issue type event. | Handle either an issue type event. | def handle_issue_payload(
action: str, issue: Dict[str, Any], actor: Dict[str, Any]
) -> Tuple[str, str]:
"""Handle either an issue type event."""
subject = issue["title"]
datetime = issue["lastSeen"].split(".")[0].replace("T", " ")
if issue["assignedTo"]:
if issue["assignedTo"]["type"] == ... | [
"def",
"handle_issue_payload",
"(",
"action",
":",
"str",
",",
"issue",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"actor",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"Tuple",
"[",
"str",
",",
"str",
"]",
":",
"subject",
"=",
"issue... | [
166,
0
] | [
215,
26
] | python | en | ['en', 'en', 'en'] | True |
transform_webhook_payload | (payload: Dict[str, Any]) | Attempt to use webhook payload for the notification.
When the integration is configured as a webhook, instead of being added as
an internal integration, the payload is slightly different, but has all the
required information for sending a notification. We transform this payload to
look like the payload... | Attempt to use webhook payload for the notification. | def transform_webhook_payload(payload: Dict[str, Any]) -> Optional[Dict[str, Any]]:
"""Attempt to use webhook payload for the notification.
When the integration is configured as a webhook, instead of being added as
an internal integration, the payload is slightly different, but has all the
required inf... | [
"def",
"transform_webhook_payload",
"(",
"payload",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"Optional",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
":",
"event",
"=",
"payload",
".",
"get",
"(",
"\"event\"",
",",
"{",
"}",
")",
"# d... | [
228,
0
] | [
246,
18
] | python | en | ['en', 'en', 'en'] | True |
MemoryStorage.store_vector | (self, hash_name, bucket_key, v, data) |
Stores vector and JSON-serializable data in bucket with specified key.
|
Stores vector and JSON-serializable data in bucket with specified key.
| def store_vector(self, hash_name, bucket_key, v, data):
"""
Stores vector and JSON-serializable data in bucket with specified key.
"""
if not hash_name in self.buckets:
self.buckets[hash_name] = {}
if not bucket_key in self.buckets[hash_name]:
self.bucke... | [
"def",
"store_vector",
"(",
"self",
",",
"hash_name",
",",
"bucket_key",
",",
"v",
",",
"data",
")",
":",
"if",
"not",
"hash_name",
"in",
"self",
".",
"buckets",
":",
"self",
".",
"buckets",
"[",
"hash_name",
"]",
"=",
"{",
"}",
"if",
"not",
"bucket_... | [
42,
4
] | [
52,
61
] | python | en | ['en', 'error', 'th'] | False |
MemoryStorage.store_many_vectors | (self, hash_name, bucket_keys, vs, data) |
Store a batch of vectors.
Stores vector and JSON-serializable data in bucket with specified key.
|
Store a batch of vectors.
Stores vector and JSON-serializable data in bucket with specified key.
| def store_many_vectors(self, hash_name, bucket_keys, vs, data):
"""
Store a batch of vectors.
Stores vector and JSON-serializable data in bucket with specified key.
"""
if data is None:
data = itertools.repeat(data)
for v, k, d in zip(vs, bucket_keys, data):
... | [
"def",
"store_many_vectors",
"(",
"self",
",",
"hash_name",
",",
"bucket_keys",
",",
"vs",
",",
"data",
")",
":",
"if",
"data",
"is",
"None",
":",
"data",
"=",
"itertools",
".",
"repeat",
"(",
"data",
")",
"for",
"v",
",",
"k",
",",
"d",
"in",
"zip... | [
54,
4
] | [
62,
49
] | python | en | ['en', 'error', 'th'] | False |
MemoryStorage.delete_vector | (self, hash_name, bucket_keys, data) |
Deletes vector and JSON-serializable data in buckets with specified keys.
|
Deletes vector and JSON-serializable data in buckets with specified keys.
| def delete_vector(self, hash_name, bucket_keys, data):
"""
Deletes vector and JSON-serializable data in buckets with specified keys.
"""
for key in bucket_keys:
bucket = self.get_bucket(hash_name, key)
bucket[:] = [(v, id_data) for v, id_data
... | [
"def",
"delete_vector",
"(",
"self",
",",
"hash_name",
",",
"bucket_keys",
",",
"data",
")",
":",
"for",
"key",
"in",
"bucket_keys",
":",
"bucket",
"=",
"self",
".",
"get_bucket",
"(",
"hash_name",
",",
"key",
")",
"bucket",
"[",
":",
"]",
"=",
"[",
... | [
67,
4
] | [
74,
54
] | python | en | ['en', 'error', 'th'] | False |
MemoryStorage.get_bucket | (self, hash_name, bucket_key) |
Returns bucket content as list of tuples (vector, data).
|
Returns bucket content as list of tuples (vector, data).
| def get_bucket(self, hash_name, bucket_key):
"""
Returns bucket content as list of tuples (vector, data).
"""
if hash_name in self.buckets:
if bucket_key in self.buckets[hash_name]:
return self.buckets[hash_name][bucket_key]
return [] | [
"def",
"get_bucket",
"(",
"self",
",",
"hash_name",
",",
"bucket_key",
")",
":",
"if",
"hash_name",
"in",
"self",
".",
"buckets",
":",
"if",
"bucket_key",
"in",
"self",
".",
"buckets",
"[",
"hash_name",
"]",
":",
"return",
"self",
".",
"buckets",
"[",
... | [
76,
4
] | [
83,
17
] | python | en | ['en', 'error', 'th'] | False |
MemoryStorage.clean_buckets | (self, hash_name) |
Removes all buckets and their content for specified hash.
|
Removes all buckets and their content for specified hash.
| def clean_buckets(self, hash_name):
"""
Removes all buckets and their content for specified hash.
"""
self.buckets[hash_name] = {} | [
"def",
"clean_buckets",
"(",
"self",
",",
"hash_name",
")",
":",
"self",
".",
"buckets",
"[",
"hash_name",
"]",
"=",
"{",
"}"
] | [
85,
4
] | [
89,
36
] | python | en | ['en', 'error', 'th'] | False |
MemoryStorage.clean_all_buckets | (self) |
Removes all buckets from all hashes and their content.
|
Removes all buckets from all hashes and their content.
| def clean_all_buckets(self):
"""
Removes all buckets from all hashes and their content.
"""
self.buckets = {} | [
"def",
"clean_all_buckets",
"(",
"self",
")",
":",
"self",
".",
"buckets",
"=",
"{",
"}"
] | [
91,
4
] | [
95,
25
] | python | en | ['en', 'error', 'th'] | False |
MemoryStorage.store_hash_configuration | (self, lshash) |
Stores hash configuration
|
Stores hash configuration
| def store_hash_configuration(self, lshash):
"""
Stores hash configuration
"""
self.hash_configs[lshash.hash_name] = lshash.get_config() | [
"def",
"store_hash_configuration",
"(",
"self",
",",
"lshash",
")",
":",
"self",
".",
"hash_configs",
"[",
"lshash",
".",
"hash_name",
"]",
"=",
"lshash",
".",
"get_config",
"(",
")"
] | [
97,
4
] | [
101,
65
] | python | en | ['en', 'error', 'th'] | False |
MemoryStorage.load_hash_configuration | (self, hash_name) |
Loads and returns hash configuration
|
Loads and returns hash configuration
| def load_hash_configuration(self, hash_name):
"""
Loads and returns hash configuration
"""
return self.hash_configs.get(hash_name) | [
"def",
"load_hash_configuration",
"(",
"self",
",",
"hash_name",
")",
":",
"return",
"self",
".",
"hash_configs",
".",
"get",
"(",
"hash_name",
")"
] | [
103,
4
] | [
107,
47
] | python | en | ['en', 'error', 'th'] | False |
MUSCLSuperBeeModel.__init__ | (self, flowlines, mb_model=None, y0=0., glen_a=None, fs=None,
fixed_dt=None, min_dt=SEC_IN_DAY, max_dt=31*SEC_IN_DAY,
inplace=False, **kwargs) | Instantiate.
Parameters
----------
| Instantiate. | def __init__(self, flowlines, mb_model=None, y0=0., glen_a=None, fs=None,
fixed_dt=None, min_dt=SEC_IN_DAY, max_dt=31*SEC_IN_DAY,
inplace=False, **kwargs):
""" Instantiate.
Parameters
----------
"""
if len(flowlines) > 1:
raise Valu... | [
"def",
"__init__",
"(",
"self",
",",
"flowlines",
",",
"mb_model",
"=",
"None",
",",
"y0",
"=",
"0.",
",",
"glen_a",
"=",
"None",
",",
"fs",
"=",
"None",
",",
"fixed_dt",
"=",
"None",
",",
"min_dt",
"=",
"SEC_IN_DAY",
",",
"max_dt",
"=",
"31",
"*",... | [
23,
4
] | [
43,
28
] | python | en | ['en', 'nl', 'en'] | False |
MUSCLSuperBeeModel.phi | (self, r) | a definition of the limiting scheme to use | a definition of the limiting scheme to use | def phi(self, r):
""" a definition of the limiting scheme to use"""
# minmod limiter Eq. 28
# val_phi = numpy.maximum(0,numpy.minimum(1,r))
# superbee limiter Eq. 29
val_phi = np.maximum(0, np.minimum(2*r, 1), np.minimum(r, 2))
return val_phi | [
"def",
"phi",
"(",
"self",
",",
"r",
")",
":",
"# minmod limiter Eq. 28",
"# val_phi = numpy.maximum(0,numpy.minimum(1,r))",
"# superbee limiter Eq. 29",
"val_phi",
"=",
"np",
".",
"maximum",
"(",
"0",
",",
"np",
".",
"minimum",
"(",
"2",
"*",
"r",
",",
"1",
"... | [
45,
4
] | [
53,
22
] | python | en | ['en', 'en', 'en'] | True |
MUSCLSuperBeeModel.step | (self, dt) | Advance one step. | Advance one step. | def step(self, dt):
"""Advance one step."""
# Just a check to avoid useless computations
if dt <= 0:
raise InvalidParamsError('dt needs to be strictly positive')
# Guarantee a precise arrival on a specific date if asked
min_dt = dt if dt < self.min_dt else self.min_... | [
"def",
"step",
"(",
"self",
",",
"dt",
")",
":",
"# Just a check to avoid useless computations",
"if",
"dt",
"<=",
"0",
":",
"raise",
"InvalidParamsError",
"(",
"'dt needs to be strictly positive'",
")",
"# Guarantee a precise arrival on a specific date if asked",
"min_dt",
... | [
55,
4
] | [
180,
20
] | python | en | ['en', 'ig', 'en'] | True |
BaseCommandEvent.get_event_display | (self) |
Needed for __unicode__
|
Needed for __unicode__
| def get_event_display(self):
"""
Needed for __unicode__
"""
return self.event | [
"def",
"get_event_display",
"(",
"self",
")",
":",
"return",
"self",
".",
"event"
] | [
726,
4
] | [
730,
25
] | python | en | ['en', 'error', 'th'] | False |
BaseAction.verify_action | (
self,
action: Callable[[], object],
*,
event_types: Optional[List[str]] = None,
include_subscribers: bool = True,
state_change_expected: bool = True,
notification_settings_null: bool = False,
client_gravatar: bool = True,
user_avatar_url_field_op... |
Make sure we have a clean slate of client descriptors for these tests.
If we don't do this, then certain failures will only manifest when you
run multiple tests within a single test function.
See also https://zulip.readthedocs.io/en/latest/subsystems/events-system.html#testing
... |
Make sure we have a clean slate of client descriptors for these tests.
If we don't do this, then certain failures will only manifest when you
run multiple tests within a single test function. | def verify_action(
self,
action: Callable[[], object],
*,
event_types: Optional[List[str]] = None,
include_subscribers: bool = True,
state_change_expected: bool = True,
notification_settings_null: bool = False,
client_gravatar: bool = True,
user_av... | [
"def",
"verify_action",
"(",
"self",
",",
"action",
":",
"Callable",
"[",
"[",
"]",
",",
"object",
"]",
",",
"*",
",",
"event_types",
":",
"Optional",
"[",
"List",
"[",
"str",
"]",
"]",
"=",
"None",
",",
"include_subscribers",
":",
"bool",
"=",
"True... | [
222,
4
] | [
334,
21
] | python | en | ['en', 'error', 'th'] | False |
NormalActionsTest.test_do_delete_message_stream_legacy | (self) |
Test for legacy method of deleting messages which
sends an event per message to delete to the client.
|
Test for legacy method of deleting messages which
sends an event per message to delete to the client.
| def test_do_delete_message_stream_legacy(self) -> None:
"""
Test for legacy method of deleting messages which
sends an event per message to delete to the client.
"""
hamlet = self.example_user("hamlet")
msg_id = self.send_stream_message(hamlet, "Verona")
msg_id_2 ... | [
"def",
"test_do_delete_message_stream_legacy",
"(",
"self",
")",
"->",
"None",
":",
"hamlet",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"msg_id",
"=",
"self",
".",
"send_stream_message",
"(",
"hamlet",
",",
"\"Verona\"",
")",
"msg_id_2",
"=",
"... | [
1759,
4
] | [
1780,
9
] | python | en | ['en', 'error', 'th'] | False |
UserDisplayActionTest.do_set_user_display_settings_test | (self, setting_name: str) | Test updating each setting in UserProfile.property_types dict. | Test updating each setting in UserProfile.property_types dict. | def do_set_user_display_settings_test(self, setting_name: str) -> None:
"""Test updating each setting in UserProfile.property_types dict."""
test_changes: Dict[str, Any] = dict(
emojiset=["twitter"],
default_language=["es", "de", "en"],
default_view=["all_messages", ... | [
"def",
"do_set_user_display_settings_test",
"(",
"self",
",",
"setting_name",
":",
"str",
")",
"->",
"None",
":",
"test_changes",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
"=",
"dict",
"(",
"emojiset",
"=",
"[",
"\"twitter\"",
"]",
",",
"default_language",
... | [
2070,
4
] | [
2106,
75
] | python | en | ['en', 'en', 'en'] | True |
parse_anchor_value | (anchor_val: Optional[str], use_first_unread_anchor: bool) | Given the anchor and use_first_unread_anchor parameters passed by
the client, computes what anchor value the client requested,
handling backwards-compatibility and the various string-valued
fields. We encode use_first_unread_anchor as anchor=None.
| Given the anchor and use_first_unread_anchor parameters passed by
the client, computes what anchor value the client requested,
handling backwards-compatibility and the various string-valued
fields. We encode use_first_unread_anchor as anchor=None.
| def parse_anchor_value(anchor_val: Optional[str], use_first_unread_anchor: bool) -> Optional[int]:
"""Given the anchor and use_first_unread_anchor parameters passed by
the client, computes what anchor value the client requested,
handling backwards-compatibility and the various string-valued
fields. We ... | [
"def",
"parse_anchor_value",
"(",
"anchor_val",
":",
"Optional",
"[",
"str",
"]",
",",
"use_first_unread_anchor",
":",
"bool",
")",
"->",
"Optional",
"[",
"int",
"]",
":",
"if",
"use_first_unread_anchor",
":",
"# Backwards-compatibility: Before we added support for the"... | [
894,
0
] | [
929,
48
] | python | en | ['en', 'en', 'en'] | True |
limit_query_to_range | (
query: Select,
num_before: int,
num_after: int,
anchor: int,
anchored_to_left: bool,
anchored_to_right: bool,
id_col: "ColumnElement[int]",
first_visible_message_id: int,
) |
This code is actually generic enough that we could move it to a
library, but our only caller for now is message search.
|
This code is actually generic enough that we could move it to a
library, but our only caller for now is message search.
| def limit_query_to_range(
query: Select,
num_before: int,
num_after: int,
anchor: int,
anchored_to_left: bool,
anchored_to_right: bool,
id_col: "ColumnElement[int]",
first_visible_message_id: int,
) -> FromClause:
"""
This code is actually generic enough that we could move it to ... | [
"def",
"limit_query_to_range",
"(",
"query",
":",
"Select",
",",
"num_before",
":",
"int",
",",
"num_after",
":",
"int",
",",
"anchor",
":",
"int",
",",
"anchored_to_left",
":",
"bool",
",",
"anchored_to_right",
":",
"bool",
",",
"id_col",
":",
"\"ColumnElem... | [
1160,
0
] | [
1238,
44
] | python | en | ['en', 'error', 'th'] | False |
NarrowBuilder.add_term | (self, query: Select, term: Dict[str, Any]) |
Extend the given query to one narrowed by the given term, and return the result.
This method satisfies an important security property: the returned
query never includes a message that the given query didn't. In
particular, if the given query will only find messages that a given
... |
Extend the given query to one narrowed by the given term, and return the result. | def add_term(self, query: Select, term: Dict[str, Any]) -> Select:
"""
Extend the given query to one narrowed by the given term, and return the result.
This method satisfies an important security property: the returned
query never includes a message that the given query didn't. In
... | [
"def",
"add_term",
"(",
"self",
",",
"query",
":",
"Select",
",",
"term",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"Select",
":",
"# To maintain the security property, we hold all the `by_*`",
"# methods to the same criterion. See the class's block comment",
... | [
161,
4
] | [
192,
51
] | python | en | ['en', 'error', 'th'] | False |
NarrowBuilder._pg_re_escape | (self, pattern: str) |
Escape user input to place in a regex
Python's re.escape escapes Unicode characters in a way which PostgreSQL
fails on, '\u03bb' to '\\\u03bb'. This function will correctly escape
them for PostgreSQL, '\u03bb' to '\\u03bb'.
|
Escape user input to place in a regex | def _pg_re_escape(self, pattern: str) -> str:
"""
Escape user input to place in a regex
Python's re.escape escapes Unicode characters in a way which PostgreSQL
fails on, '\u03bb' to '\\\u03bb'. This function will correctly escape
them for PostgreSQL, '\u03bb' to '\\u03bb'.
... | [
"def",
"_pg_re_escape",
"(",
"self",
",",
"pattern",
":",
"str",
")",
"->",
"str",
":",
"s",
"=",
"list",
"(",
"pattern",
")",
"for",
"i",
",",
"c",
"in",
"enumerate",
"(",
"s",
")",
":",
"if",
"c",
"not",
"in",
"self",
".",
"_alphanum",
":",
"... | [
240,
4
] | [
257,
25
] | python | en | ['en', 'error', 'th'] | False |
make_graph | (dists, scheme='default') | Makes a dependency graph from the given distributions.
:parameter dists: a list of distributions
:type dists: list of :class:`distutils2.database.InstalledDistribution` and
:class:`distutils2.database.EggInfoDistribution` instances
:rtype: a :class:`DependencyGraph` instance
| Makes a dependency graph from the given distributions. | def make_graph(dists, scheme='default'):
"""Makes a dependency graph from the given distributions.
:parameter dists: a list of distributions
:type dists: list of :class:`distutils2.database.InstalledDistribution` and
:class:`distutils2.database.EggInfoDistribution` instances
:rtype: a ... | [
"def",
"make_graph",
"(",
"dists",
",",
"scheme",
"=",
"'default'",
")",
":",
"scheme",
"=",
"get_scheme",
"(",
"scheme",
")",
"graph",
"=",
"DependencyGraph",
"(",
")",
"provided",
"=",
"{",
"}",
"# maps names to lists of (version, dist) tuples",
"# first, build ... | [
1224,
0
] | [
1275,
16
] | python | en | ['en', 'en', 'en'] | True |
get_dependent_dists | (dists, dist) | Recursively generate a list of distributions from *dists* that are
dependent on *dist*.
:param dists: a list of distributions
:param dist: a distribution, member of *dists* for which we are interested
| Recursively generate a list of distributions from *dists* that are
dependent on *dist*. | def get_dependent_dists(dists, dist):
"""Recursively generate a list of distributions from *dists* that are
dependent on *dist*.
:param dists: a list of distributions
:param dist: a distribution, member of *dists* for which we are interested
"""
if dist not in dists:
raise DistlibExcept... | [
"def",
"get_dependent_dists",
"(",
"dists",
",",
"dist",
")",
":",
"if",
"dist",
"not",
"in",
"dists",
":",
"raise",
"DistlibException",
"(",
"'given distribution %r is not a member '",
"'of the list'",
"%",
"dist",
".",
"name",
")",
"graph",
"=",
"make_graph",
... | [
1278,
0
] | [
1301,
14
] | python | en | ['en', 'en', 'en'] | True |
get_required_dists | (dists, dist) | Recursively generate a list of distributions from *dists* that are
required by *dist*.
:param dists: a list of distributions
:param dist: a distribution, member of *dists* for which we are interested
| Recursively generate a list of distributions from *dists* that are
required by *dist*. | def get_required_dists(dists, dist):
"""Recursively generate a list of distributions from *dists* that are
required by *dist*.
:param dists: a list of distributions
:param dist: a distribution, member of *dists* for which we are interested
"""
if dist not in dists:
raise DistlibExceptio... | [
"def",
"get_required_dists",
"(",
"dists",
",",
"dist",
")",
":",
"if",
"dist",
"not",
"in",
"dists",
":",
"raise",
"DistlibException",
"(",
"'given distribution %r is not a member '",
"'of the list'",
"%",
"dist",
".",
"name",
")",
"graph",
"=",
"make_graph",
"... | [
1304,
0
] | [
1326,
14
] | python | en | ['en', 'en', 'en'] | True |
make_dist | (name, version, **kwargs) |
A convenience method for making a dist given just a name and version.
|
A convenience method for making a dist given just a name and version.
| def make_dist(name, version, **kwargs):
"""
A convenience method for making a dist given just a name and version.
"""
summary = kwargs.pop('summary', 'Placeholder for summary')
md = Metadata(**kwargs)
md.name = name
md.version = version
md.summary = summary or 'Placeholder for summary'
... | [
"def",
"make_dist",
"(",
"name",
",",
"version",
",",
"*",
"*",
"kwargs",
")",
":",
"summary",
"=",
"kwargs",
".",
"pop",
"(",
"'summary'",
",",
"'Placeholder for summary'",
")",
"md",
"=",
"Metadata",
"(",
"*",
"*",
"kwargs",
")",
"md",
".",
"name",
... | [
1329,
0
] | [
1338,
27
] | python | en | ['en', 'error', 'th'] | False |
_Cache.__init__ | (self) |
Initialise an instance. There is normally one for each DistributionPath.
|
Initialise an instance. There is normally one for each DistributionPath.
| def __init__(self):
"""
Initialise an instance. There is normally one for each DistributionPath.
"""
self.name = {}
self.path = {}
self.generated = False | [
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"name",
"=",
"{",
"}",
"self",
".",
"path",
"=",
"{",
"}",
"self",
".",
"generated",
"=",
"False"
] | [
48,
4
] | [
54,
30
] | python | en | ['en', 'error', 'th'] | False |
_Cache.clear | (self) |
Clear the cache, setting it to its initial state.
|
Clear the cache, setting it to its initial state.
| def clear(self):
"""
Clear the cache, setting it to its initial state.
"""
self.name.clear()
self.path.clear()
self.generated = False | [
"def",
"clear",
"(",
"self",
")",
":",
"self",
".",
"name",
".",
"clear",
"(",
")",
"self",
".",
"path",
".",
"clear",
"(",
")",
"self",
".",
"generated",
"=",
"False"
] | [
56,
4
] | [
62,
30
] | python | en | ['en', 'error', 'th'] | False |
_Cache.add | (self, dist) |
Add a distribution to the cache.
:param dist: The distribution to add.
|
Add a distribution to the cache.
:param dist: The distribution to add.
| def add(self, dist):
"""
Add a distribution to the cache.
:param dist: The distribution to add.
"""
if dist.path not in self.path:
self.path[dist.path] = dist
self.name.setdefault(dist.key, []).append(dist) | [
"def",
"add",
"(",
"self",
",",
"dist",
")",
":",
"if",
"dist",
".",
"path",
"not",
"in",
"self",
".",
"path",
":",
"self",
".",
"path",
"[",
"dist",
".",
"path",
"]",
"=",
"dist",
"self",
".",
"name",
".",
"setdefault",
"(",
"dist",
".",
"key"... | [
64,
4
] | [
71,
59
] | python | en | ['en', 'error', 'th'] | False |
DistributionPath.__init__ | (self, path=None, include_egg=False) |
Create an instance from a path, optionally including legacy (distutils/
setuptools/distribute) distributions.
:param path: The path to use, as a list of directories. If not specified,
sys.path is used.
:param include_egg: If True, this instance will look for and ret... |
Create an instance from a path, optionally including legacy (distutils/
setuptools/distribute) distributions.
:param path: The path to use, as a list of directories. If not specified,
sys.path is used.
:param include_egg: If True, this instance will look for and ret... | def __init__(self, path=None, include_egg=False):
"""
Create an instance from a path, optionally including legacy (distutils/
setuptools/distribute) distributions.
:param path: The path to use, as a list of directories. If not specified,
sys.path is used.
:pa... | [
"def",
"__init__",
"(",
"self",
",",
"path",
"=",
"None",
",",
"include_egg",
"=",
"False",
")",
":",
"if",
"path",
"is",
"None",
":",
"path",
"=",
"sys",
".",
"path",
"self",
".",
"path",
"=",
"path",
"self",
".",
"_include_dist",
"=",
"True",
"se... | [
78,
4
] | [
96,
44
] | python | en | ['en', 'error', 'th'] | False |
DistributionPath.clear_cache | (self) |
Clears the internal cache.
|
Clears the internal cache.
| def clear_cache(self):
"""
Clears the internal cache.
"""
self._cache.clear()
self._cache_egg.clear() | [
"def",
"clear_cache",
"(",
"self",
")",
":",
"self",
".",
"_cache",
".",
"clear",
"(",
")",
"self",
".",
"_cache_egg",
".",
"clear",
"(",
")"
] | [
106,
4
] | [
111,
31
] | python | en | ['en', 'error', 'th'] | False |
DistributionPath._yield_distributions | (self) |
Yield .dist-info and/or .egg(-info) distributions.
|
Yield .dist-info and/or .egg(-info) distributions.
| def _yield_distributions(self):
"""
Yield .dist-info and/or .egg(-info) distributions.
"""
# We need to check if we've seen some resources already, because on
# some Linux systems (e.g. some Debian/Ubuntu variants) there are
# symlinks which alias other files in the envir... | [
"def",
"_yield_distributions",
"(",
"self",
")",
":",
"# We need to check if we've seen some resources already, because on",
"# some Linux systems (e.g. some Debian/Ubuntu variants) there are",
"# symlinks which alias other files in the environment.",
"seen",
"=",
"set",
"(",
")",
"for",... | [
114,
4
] | [
156,
54
] | python | en | ['en', 'error', 'th'] | False |
DistributionPath._generate_cache | (self) |
Scan the path for distributions and populate the cache with
those that are found.
|
Scan the path for distributions and populate the cache with
those that are found.
| def _generate_cache(self):
"""
Scan the path for distributions and populate the cache with
those that are found.
"""
gen_dist = not self._cache.generated
gen_egg = self._include_egg and not self._cache_egg.generated
if gen_dist or gen_egg:
for dist in ... | [
"def",
"_generate_cache",
"(",
"self",
")",
":",
"gen_dist",
"=",
"not",
"self",
".",
"_cache",
".",
"generated",
"gen_egg",
"=",
"self",
".",
"_include_egg",
"and",
"not",
"self",
".",
"_cache_egg",
".",
"generated",
"if",
"gen_dist",
"or",
"gen_egg",
":"... | [
158,
4
] | [
175,
48
] | python | en | ['en', 'error', 'th'] | False |
DistributionPath.distinfo_dirname | (cls, name, version) |
The *name* and *version* parameters are converted into their
filename-escaped form, i.e. any ``'-'`` characters are replaced
with ``'_'`` other than the one in ``'dist-info'`` and the one
separating the name from the version number.
:parameter name: is converted to a standard d... |
The *name* and *version* parameters are converted into their
filename-escaped form, i.e. any ``'-'`` characters are replaced
with ``'_'`` other than the one in ``'dist-info'`` and the one
separating the name from the version number. | def distinfo_dirname(cls, name, version):
"""
The *name* and *version* parameters are converted into their
filename-escaped form, i.e. any ``'-'`` characters are replaced
with ``'_'`` other than the one in ``'dist-info'`` and the one
separating the name from the version number.
... | [
"def",
"distinfo_dirname",
"(",
"cls",
",",
"name",
",",
"version",
")",
":",
"name",
"=",
"name",
".",
"replace",
"(",
"'-'",
",",
"'_'",
")",
"return",
"'-'",
".",
"join",
"(",
"[",
"name",
",",
"version",
"]",
")",
"+",
"DISTINFO_EXT"
] | [
178,
4
] | [
197,
55
] | python | en | ['en', 'error', 'th'] | False |
DistributionPath.get_distributions | (self) |
Provides an iterator that looks for distributions and returns
:class:`InstalledDistribution` or
:class:`EggInfoDistribution` instances for each one of them.
:rtype: iterator of :class:`InstalledDistribution` and
:class:`EggInfoDistribution` instances
|
Provides an iterator that looks for distributions and returns
:class:`InstalledDistribution` or
:class:`EggInfoDistribution` instances for each one of them. | def get_distributions(self):
"""
Provides an iterator that looks for distributions and returns
:class:`InstalledDistribution` or
:class:`EggInfoDistribution` instances for each one of them.
:rtype: iterator of :class:`InstalledDistribution` and
:class:`EggInfoDis... | [
"def",
"get_distributions",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_cache_enabled",
":",
"for",
"dist",
"in",
"self",
".",
"_yield_distributions",
"(",
")",
":",
"yield",
"dist",
"else",
":",
"self",
".",
"_generate_cache",
"(",
")",
"for",
"d... | [
199,
4
] | [
219,
30
] | python | en | ['en', 'error', 'th'] | False |
DistributionPath.get_distribution | (self, name) |
Looks for a named distribution on the path.
This function only returns the first result found, as no more than one
value is expected. If nothing is found, ``None`` is returned.
:rtype: :class:`InstalledDistribution`, :class:`EggInfoDistribution`
or ``None``
|
Looks for a named distribution on the path. | def get_distribution(self, name):
"""
Looks for a named distribution on the path.
This function only returns the first result found, as no more than one
value is expected. If nothing is found, ``None`` is returned.
:rtype: :class:`InstalledDistribution`, :class:`EggInfoDistribu... | [
"def",
"get_distribution",
"(",
"self",
",",
"name",
")",
":",
"result",
"=",
"None",
"name",
"=",
"name",
".",
"lower",
"(",
")",
"if",
"not",
"self",
".",
"_cache_enabled",
":",
"for",
"dist",
"in",
"self",
".",
"_yield_distributions",
"(",
")",
":",... | [
221,
4
] | [
245,
21
] | python | en | ['en', 'error', 'th'] | False |
DistributionPath.provides_distribution | (self, name, version=None) |
Iterates over all distributions to find which distributions provide *name*.
If a *version* is provided, it will be used to filter the results.
This function only returns the first result found, since no more than
one values are expected. If the directory is not found, returns ``None``.... |
Iterates over all distributions to find which distributions provide *name*.
If a *version* is provided, it will be used to filter the results. | def provides_distribution(self, name, version=None):
"""
Iterates over all distributions to find which distributions provide *name*.
If a *version* is provided, it will be used to filter the results.
This function only returns the first result found, since no more than
one value... | [
"def",
"provides_distribution",
"(",
"self",
",",
"name",
",",
"version",
"=",
"None",
")",
":",
"matcher",
"=",
"None",
"if",
"version",
"is",
"not",
"None",
":",
"try",
":",
"matcher",
"=",
"self",
".",
"_scheme",
".",
"matcher",
"(",
"'%s (%s)'",
"%... | [
247,
4
] | [
286,
33
] | python | en | ['en', 'error', 'th'] | False |
DistributionPath.get_file_path | (self, name, relative_path) |
Return the path to a resource file.
|
Return the path to a resource file.
| def get_file_path(self, name, relative_path):
"""
Return the path to a resource file.
"""
dist = self.get_distribution(name)
if dist is None:
raise LookupError('no distribution named %r found' % name)
return dist.get_resource_path(relative_path) | [
"def",
"get_file_path",
"(",
"self",
",",
"name",
",",
"relative_path",
")",
":",
"dist",
"=",
"self",
".",
"get_distribution",
"(",
"name",
")",
"if",
"dist",
"is",
"None",
":",
"raise",
"LookupError",
"(",
"'no distribution named %r found'",
"%",
"name",
"... | [
288,
4
] | [
295,
52
] | python | en | ['en', 'error', 'th'] | False |
DistributionPath.get_exported_entries | (self, category, name=None) |
Return all of the exported entries in a particular category.
:param category: The category to search for entries.
:param name: If specified, only entries with that name are returned.
|
Return all of the exported entries in a particular category. | def get_exported_entries(self, category, name=None):
"""
Return all of the exported entries in a particular category.
:param category: The category to search for entries.
:param name: If specified, only entries with that name are returned.
"""
for dist in self.get_distri... | [
"def",
"get_exported_entries",
"(",
"self",
",",
"category",
",",
"name",
"=",
"None",
")",
":",
"for",
"dist",
"in",
"self",
".",
"get_distributions",
"(",
")",
":",
"r",
"=",
"dist",
".",
"exports",
"if",
"category",
"in",
"r",
":",
"d",
"=",
"r",
... | [
297,
4
] | [
313,
31
] | python | en | ['en', 'error', 'th'] | False |
Distribution.__init__ | (self, metadata) |
Initialise an instance.
:param metadata: The instance of :class:`Metadata` describing this
distribution.
|
Initialise an instance.
:param metadata: The instance of :class:`Metadata` describing this
distribution.
| def __init__(self, metadata):
"""
Initialise an instance.
:param metadata: The instance of :class:`Metadata` describing this
distribution.
"""
self.metadata = metadata
self.name = metadata.name
self.key = self.name.lower() # for case-insensitive compari... | [
"def",
"__init__",
"(",
"self",
",",
"metadata",
")",
":",
"self",
".",
"metadata",
"=",
"metadata",
"self",
".",
"name",
"=",
"metadata",
".",
"name",
"self",
".",
"key",
"=",
"self",
".",
"name",
".",
"lower",
"(",
")",
"# for case-insensitive comparis... | [
334,
4
] | [
349,
25
] | python | en | ['en', 'error', 'th'] | False |
Distribution.source_url | (self) |
The source archive download URL for this distribution.
|
The source archive download URL for this distribution.
| def source_url(self):
"""
The source archive download URL for this distribution.
"""
return self.metadata.source_url | [
"def",
"source_url",
"(",
"self",
")",
":",
"return",
"self",
".",
"metadata",
".",
"source_url"
] | [
352,
4
] | [
356,
39
] | python | en | ['en', 'error', 'th'] | False |
Distribution.name_and_version | (self) |
A utility property which displays the name and version in parentheses.
|
A utility property which displays the name and version in parentheses.
| def name_and_version(self):
"""
A utility property which displays the name and version in parentheses.
"""
return '%s (%s)' % (self.name, self.version) | [
"def",
"name_and_version",
"(",
"self",
")",
":",
"return",
"'%s (%s)'",
"%",
"(",
"self",
".",
"name",
",",
"self",
".",
"version",
")"
] | [
361,
4
] | [
365,
52
] | python | en | ['en', 'error', 'th'] | False |
Distribution.provides | (self) |
A set of distribution names and versions provided by this distribution.
:return: A set of "name (version)" strings.
|
A set of distribution names and versions provided by this distribution.
:return: A set of "name (version)" strings.
| def provides(self):
"""
A set of distribution names and versions provided by this distribution.
:return: A set of "name (version)" strings.
"""
plist = self.metadata.provides
s = '%s (%s)' % (self.name, self.version)
if s not in plist:
plist.append(s)
... | [
"def",
"provides",
"(",
"self",
")",
":",
"plist",
"=",
"self",
".",
"metadata",
".",
"provides",
"s",
"=",
"'%s (%s)'",
"%",
"(",
"self",
".",
"name",
",",
"self",
".",
"version",
")",
"if",
"s",
"not",
"in",
"plist",
":",
"plist",
".",
"append",
... | [
368,
4
] | [
377,
20
] | python | en | ['en', 'error', 'th'] | False |
Distribution.matches_requirement | (self, req) |
Say if this instance matches (fulfills) a requirement.
:param req: The requirement to match.
:rtype req: str
:return: True if it matches, else False.
|
Say if this instance matches (fulfills) a requirement.
:param req: The requirement to match.
:rtype req: str
:return: True if it matches, else False.
| def matches_requirement(self, req):
"""
Say if this instance matches (fulfills) a requirement.
:param req: The requirement to match.
:rtype req: str
:return: True if it matches, else False.
"""
# Requirement may contain extras - parse to lose those
# from ... | [
"def",
"matches_requirement",
"(",
"self",
",",
"req",
")",
":",
"# Requirement may contain extras - parse to lose those",
"# from what's passed to the matcher",
"r",
"=",
"parse_requirement",
"(",
"req",
")",
"scheme",
"=",
"get_scheme",
"(",
"self",
".",
"metadata",
"... | [
406,
4
] | [
438,
21
] | python | en | ['en', 'error', 'th'] | False |
Distribution.__repr__ | (self) |
Return a textual representation of this instance,
|
Return a textual representation of this instance,
| def __repr__(self):
"""
Return a textual representation of this instance,
"""
if self.source_url:
suffix = ' [%s]' % self.source_url
else:
suffix = ''
return '<Distribution %s (%s)%s>' % (self.name, self.version, suffix) | [
"def",
"__repr__",
"(",
"self",
")",
":",
"if",
"self",
".",
"source_url",
":",
"suffix",
"=",
"' [%s]'",
"%",
"self",
".",
"source_url",
"else",
":",
"suffix",
"=",
"''",
"return",
"'<Distribution %s (%s)%s>'",
"%",
"(",
"self",
".",
"name",
",",
"self"... | [
440,
4
] | [
448,
77
] | python | en | ['en', 'error', 'th'] | False |
Distribution.__eq__ | (self, other) |
See if this distribution is the same as another.
:param other: The distribution to compare with. To be equal to one
another. distributions must have the same type, name,
version and source_url.
:return: True if it is the same, else False.
|
See if this distribution is the same as another.
:param other: The distribution to compare with. To be equal to one
another. distributions must have the same type, name,
version and source_url.
:return: True if it is the same, else False.
| def __eq__(self, other):
"""
See if this distribution is the same as another.
:param other: The distribution to compare with. To be equal to one
another. distributions must have the same type, name,
version and source_url.
:return: True if it i... | [
"def",
"__eq__",
"(",
"self",
",",
"other",
")",
":",
"if",
"type",
"(",
"other",
")",
"is",
"not",
"type",
"(",
"self",
")",
":",
"result",
"=",
"False",
"else",
":",
"result",
"=",
"(",
"self",
".",
"name",
"==",
"other",
".",
"name",
"and",
... | [
450,
4
] | [
464,
21
] | python | en | ['en', 'error', 'th'] | False |
Distribution.__hash__ | (self) |
Compute hash in a way which matches the equality test.
|
Compute hash in a way which matches the equality test.
| def __hash__(self):
"""
Compute hash in a way which matches the equality test.
"""
return hash(self.name) + hash(self.version) + hash(self.source_url) | [
"def",
"__hash__",
"(",
"self",
")",
":",
"return",
"hash",
"(",
"self",
".",
"name",
")",
"+",
"hash",
"(",
"self",
".",
"version",
")",
"+",
"hash",
"(",
"self",
".",
"source_url",
")"
] | [
466,
4
] | [
470,
75
] | python | en | ['en', 'error', 'th'] | False |
BaseInstalledDistribution.__init__ | (self, metadata, path, env=None) |
Initialise an instance.
:param metadata: An instance of :class:`Metadata` which describes the
distribution. This will normally have been initialised
from a metadata file in the ``path``.
:param path: The path of the ``.dist-info`` or ``.egg-... |
Initialise an instance.
:param metadata: An instance of :class:`Metadata` which describes the
distribution. This will normally have been initialised
from a metadata file in the ``path``.
:param path: The path of the ``.dist-info`` or ``.egg-... | def __init__(self, metadata, path, env=None):
"""
Initialise an instance.
:param metadata: An instance of :class:`Metadata` which describes the
distribution. This will normally have been initialised
from a metadata file in the ``path``.
:... | [
"def",
"__init__",
"(",
"self",
",",
"metadata",
",",
"path",
",",
"env",
"=",
"None",
")",
":",
"super",
"(",
"BaseInstalledDistribution",
",",
"self",
")",
".",
"__init__",
"(",
"metadata",
")",
"self",
".",
"path",
"=",
"path",
"self",
".",
"dist_pa... | [
481,
4
] | [
494,
28
] | python | en | ['en', 'error', 'th'] | False |
BaseInstalledDistribution.get_hash | (self, data, hasher=None) |
Get the hash of some data, using a particular hash algorithm, if
specified.
:param data: The data to be hashed.
:type data: bytes
:param hasher: The name of a hash implementation, supported by hashlib,
or ``None``. Examples of valid values are ``'sha1'``,... |
Get the hash of some data, using a particular hash algorithm, if
specified. | def get_hash(self, data, hasher=None):
"""
Get the hash of some data, using a particular hash algorithm, if
specified.
:param data: The data to be hashed.
:type data: bytes
:param hasher: The name of a hash implementation, supported by hashlib,
or ... | [
"def",
"get_hash",
"(",
"self",
",",
"data",
",",
"hasher",
"=",
"None",
")",
":",
"if",
"hasher",
"is",
"None",
":",
"hasher",
"=",
"self",
".",
"hasher",
"if",
"hasher",
"is",
"None",
":",
"hasher",
"=",
"hashlib",
".",
"md5",
"prefix",
"=",
"''"... | [
496,
4
] | [
525,
40
] | python | en | ['en', 'error', 'th'] | False |
InstalledDistribution._get_records | (self) |
Get the list of installed files for the distribution
:return: A list of tuples of path, hash and size. Note that hash and
size might be ``None`` for some entries. The path is exactly
as stored in the file (which is as in PEP 376).
|
Get the list of installed files for the distribution
:return: A list of tuples of path, hash and size. Note that hash and
size might be ``None`` for some entries. The path is exactly
as stored in the file (which is as in PEP 376).
| def _get_records(self):
"""
Get the list of installed files for the distribution
:return: A list of tuples of path, hash and size. Note that hash and
size might be ``None`` for some entries. The path is exactly
as stored in the file (which is as in PEP 376).
... | [
"def",
"_get_records",
"(",
"self",
")",
":",
"results",
"=",
"[",
"]",
"r",
"=",
"self",
".",
"get_distinfo_resource",
"(",
"'RECORD'",
")",
"with",
"contextlib",
".",
"closing",
"(",
"r",
".",
"as_stream",
"(",
")",
")",
"as",
"stream",
":",
"with",
... | [
579,
4
] | [
600,
22
] | python | en | ['en', 'error', 'th'] | False |
InstalledDistribution.exports | (self) |
Return the information exported by this distribution.
:return: A dictionary of exports, mapping an export category to a dict
of :class:`ExportEntry` instances describing the individual
export entries, and keyed by name.
|
Return the information exported by this distribution.
:return: A dictionary of exports, mapping an export category to a dict
of :class:`ExportEntry` instances describing the individual
export entries, and keyed by name.
| def exports(self):
"""
Return the information exported by this distribution.
:return: A dictionary of exports, mapping an export category to a dict
of :class:`ExportEntry` instances describing the individual
export entries, and keyed by name.
"""
... | [
"def",
"exports",
"(",
"self",
")",
":",
"result",
"=",
"{",
"}",
"r",
"=",
"self",
".",
"get_distinfo_resource",
"(",
"EXPORTS_FILENAME",
")",
"if",
"r",
":",
"result",
"=",
"self",
".",
"read_exports",
"(",
")",
"return",
"result"
] | [
603,
4
] | [
614,
21
] | python | en | ['en', 'error', 'th'] | False |
InstalledDistribution.read_exports | (self) |
Read exports data from a file in .ini format.
:return: A dictionary of exports, mapping an export category to a list
of :class:`ExportEntry` instances describing the individual
export entries.
|
Read exports data from a file in .ini format. | def read_exports(self):
"""
Read exports data from a file in .ini format.
:return: A dictionary of exports, mapping an export category to a list
of :class:`ExportEntry` instances describing the individual
export entries.
"""
result = {}
... | [
"def",
"read_exports",
"(",
"self",
")",
":",
"result",
"=",
"{",
"}",
"r",
"=",
"self",
".",
"get_distinfo_resource",
"(",
"EXPORTS_FILENAME",
")",
"if",
"r",
":",
"with",
"contextlib",
".",
"closing",
"(",
"r",
".",
"as_stream",
"(",
")",
")",
"as",
... | [
616,
4
] | [
629,
21
] | python | en | ['en', 'error', 'th'] | False |
InstalledDistribution.write_exports | (self, exports) |
Write a dictionary of exports to a file in .ini format.
:param exports: A dictionary of exports, mapping an export category to
a list of :class:`ExportEntry` instances describing the
individual export entries.
|
Write a dictionary of exports to a file in .ini format.
:param exports: A dictionary of exports, mapping an export category to
a list of :class:`ExportEntry` instances describing the
individual export entries.
| def write_exports(self, exports):
"""
Write a dictionary of exports to a file in .ini format.
:param exports: A dictionary of exports, mapping an export category to
a list of :class:`ExportEntry` instances describing the
individual export entries.
... | [
"def",
"write_exports",
"(",
"self",
",",
"exports",
")",
":",
"rf",
"=",
"self",
".",
"get_distinfo_file",
"(",
"EXPORTS_FILENAME",
")",
"with",
"open",
"(",
"rf",
",",
"'w'",
")",
"as",
"f",
":",
"write_exports",
"(",
"exports",
",",
"f",
")"
] | [
631,
4
] | [
640,
37
] | python | en | ['en', 'error', 'th'] | False |
InstalledDistribution.get_resource_path | (self, relative_path) |
NOTE: This API may change in the future.
Return the absolute path to a resource file with the given relative
path.
:param relative_path: The path, relative to .dist-info, of the resource
of interest.
:return: The absolute path where the resource i... |
NOTE: This API may change in the future. | def get_resource_path(self, relative_path):
"""
NOTE: This API may change in the future.
Return the absolute path to a resource file with the given relative
path.
:param relative_path: The path, relative to .dist-info, of the resource
of interest.
... | [
"def",
"get_resource_path",
"(",
"self",
",",
"relative_path",
")",
":",
"r",
"=",
"self",
".",
"get_distinfo_resource",
"(",
"'RESOURCES'",
")",
"with",
"contextlib",
".",
"closing",
"(",
"r",
".",
"as_stream",
"(",
")",
")",
"as",
"stream",
":",
"with",
... | [
642,
4
] | [
660,
54
] | python | en | ['en', 'error', 'th'] | False |
InstalledDistribution.list_installed_files | (self) |
Iterates over the ``RECORD`` entries and returns a tuple
``(path, hash, size)`` for each line.
:returns: iterator of (path, hash, size)
|
Iterates over the ``RECORD`` entries and returns a tuple
``(path, hash, size)`` for each line. | def list_installed_files(self):
"""
Iterates over the ``RECORD`` entries and returns a tuple
``(path, hash, size)`` for each line.
:returns: iterator of (path, hash, size)
"""
for result in self._get_records():
yield result | [
"def",
"list_installed_files",
"(",
"self",
")",
":",
"for",
"result",
"in",
"self",
".",
"_get_records",
"(",
")",
":",
"yield",
"result"
] | [
662,
4
] | [
670,
24
] | python | en | ['en', 'error', 'th'] | False |
InstalledDistribution.write_installed_files | (self, paths, prefix, dry_run=False) |
Writes the ``RECORD`` file, using the ``paths`` iterable passed in. Any
existing ``RECORD`` file is silently overwritten.
prefix is used to determine when to write absolute paths.
|
Writes the ``RECORD`` file, using the ``paths`` iterable passed in. Any
existing ``RECORD`` file is silently overwritten. | def write_installed_files(self, paths, prefix, dry_run=False):
"""
Writes the ``RECORD`` file, using the ``paths`` iterable passed in. Any
existing ``RECORD`` file is silently overwritten.
prefix is used to determine when to write absolute paths.
"""
prefix = os.path.joi... | [
"def",
"write_installed_files",
"(",
"self",
",",
"paths",
",",
"prefix",
",",
"dry_run",
"=",
"False",
")",
":",
"prefix",
"=",
"os",
".",
"path",
".",
"join",
"(",
"prefix",
",",
"''",
")",
"base",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"se... | [
672,
4
] | [
705,
26
] | python | en | ['en', 'error', 'th'] | False |
InstalledDistribution.check_installed_files | (self) |
Checks that the hashes and sizes of the files in ``RECORD`` are
matched by the files themselves. Returns a (possibly empty) list of
mismatches. Each entry in the mismatch list will be a tuple consisting
of the path, 'exists', 'size' or 'hash' according to what didn't match
(exis... |
Checks that the hashes and sizes of the files in ``RECORD`` are
matched by the files themselves. Returns a (possibly empty) list of
mismatches. Each entry in the mismatch list will be a tuple consisting
of the path, 'exists', 'size' or 'hash' according to what didn't match
(exis... | def check_installed_files(self):
"""
Checks that the hashes and sizes of the files in ``RECORD`` are
matched by the files themselves. Returns a (possibly empty) list of
mismatches. Each entry in the mismatch list will be a tuple consisting
of the path, 'exists', 'size' or 'hash' ... | [
"def",
"check_installed_files",
"(",
"self",
")",
":",
"mismatches",
"=",
"[",
"]",
"base",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"self",
".",
"path",
")",
"record_path",
"=",
"self",
".",
"get_distinfo_file",
"(",
"'RECORD'",
")",
"for",
"path",
... | [
707,
4
] | [
740,
25
] | python | en | ['en', 'error', 'th'] | False |
InstalledDistribution.shared_locations | (self) |
A dictionary of shared locations whose keys are in the set 'prefix',
'purelib', 'platlib', 'scripts', 'headers', 'data' and 'namespace'.
The corresponding value is the absolute path of that category for
this distribution, and takes into account any paths selected by the
user at ... |
A dictionary of shared locations whose keys are in the set 'prefix',
'purelib', 'platlib', 'scripts', 'headers', 'data' and 'namespace'.
The corresponding value is the absolute path of that category for
this distribution, and takes into account any paths selected by the
user at ... | def shared_locations(self):
"""
A dictionary of shared locations whose keys are in the set 'prefix',
'purelib', 'platlib', 'scripts', 'headers', 'data' and 'namespace'.
The corresponding value is the absolute path of that category for
this distribution, and takes into account any... | [
"def",
"shared_locations",
"(",
"self",
")",
":",
"result",
"=",
"{",
"}",
"shared_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"path",
",",
"'SHARED'",
")",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"shared_path",
")",
":",
"wi... | [
743,
4
] | [
767,
21
] | python | en | ['en', 'error', 'th'] | False |
InstalledDistribution.write_shared_locations | (self, paths, dry_run=False) |
Write shared location information to the SHARED file in .dist-info.
:param paths: A dictionary as described in the documentation for
:meth:`shared_locations`.
:param dry_run: If True, the action is logged but no file is actually
written.
:return: The path... |
Write shared location information to the SHARED file in .dist-info.
:param paths: A dictionary as described in the documentation for
:meth:`shared_locations`.
:param dry_run: If True, the action is logged but no file is actually
written.
:return: The path... | def write_shared_locations(self, paths, dry_run=False):
"""
Write shared location information to the SHARED file in .dist-info.
:param paths: A dictionary as described in the documentation for
:meth:`shared_locations`.
:param dry_run: If True, the action is logged but no file is ... | [
"def",
"write_shared_locations",
"(",
"self",
",",
"paths",
",",
"dry_run",
"=",
"False",
")",
":",
"shared_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"path",
",",
"'SHARED'",
")",
"logger",
".",
"info",
"(",
"'creating %s'",
",",
"s... | [
769,
4
] | [
792,
26
] | python | en | ['en', 'error', 'th'] | False |
InstalledDistribution.get_distinfo_file | (self, path) |
Returns a path located under the ``.dist-info`` directory. Returns a
string representing the path.
:parameter path: a ``'/'``-separated path relative to the
``.dist-info`` directory or an absolute path;
If *path* is an absolute path and doesn't... |
Returns a path located under the ``.dist-info`` directory. Returns a
string representing the path. | def get_distinfo_file(self, path):
"""
Returns a path located under the ``.dist-info`` directory. Returns a
string representing the path.
:parameter path: a ``'/'``-separated path relative to the
``.dist-info`` directory or an absolute path;
... | [
"def",
"get_distinfo_file",
"(",
"self",
",",
"path",
")",
":",
"# Check if it is an absolute path # XXX use relpath, add tests",
"if",
"path",
".",
"find",
"(",
"os",
".",
"sep",
")",
">=",
"0",
":",
"# it's an absolute path?",
"distinfo_dirname",
",",
"path",
"="... | [
803,
4
] | [
830,
44
] | python | en | ['en', 'error', 'th'] | False |
InstalledDistribution.list_distinfo_files | (self) |
Iterates over the ``RECORD`` entries and returns paths for each line if
the path is pointing to a file located in the ``.dist-info`` directory
or one of its subdirectories.
:returns: iterator of paths
|
Iterates over the ``RECORD`` entries and returns paths for each line if
the path is pointing to a file located in the ``.dist-info`` directory
or one of its subdirectories. | def list_distinfo_files(self):
"""
Iterates over the ``RECORD`` entries and returns paths for each line if
the path is pointing to a file located in the ``.dist-info`` directory
or one of its subdirectories.
:returns: iterator of paths
"""
base = os.path.dirname(... | [
"def",
"list_distinfo_files",
"(",
"self",
")",
":",
"base",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"self",
".",
"path",
")",
"for",
"path",
",",
"checksum",
",",
"size",
"in",
"self",
".",
"_get_records",
"(",
")",
":",
"# XXX add separator or use... | [
832,
4
] | [
846,
26
] | python | en | ['en', 'error', 'th'] | False |
EggInfoDistribution.check_installed_files | (self) |
Checks that the hashes and sizes of the files in ``RECORD`` are
matched by the files themselves. Returns a (possibly empty) list of
mismatches. Each entry in the mismatch list will be a tuple consisting
of the path, 'exists', 'size' or 'hash' according to what didn't match
(exis... |
Checks that the hashes and sizes of the files in ``RECORD`` are
matched by the files themselves. Returns a (possibly empty) list of
mismatches. Each entry in the mismatch list will be a tuple consisting
of the path, 'exists', 'size' or 'hash' according to what didn't match
(exis... | def check_installed_files(self):
"""
Checks that the hashes and sizes of the files in ``RECORD`` are
matched by the files themselves. Returns a (possibly empty) list of
mismatches. Each entry in the mismatch list will be a tuple consisting
of the path, 'exists', 'size' or 'hash' ... | [
"def",
"check_installed_files",
"(",
"self",
")",
":",
"mismatches",
"=",
"[",
"]",
"record_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"path",
",",
"'installed-files.txt'",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"record_path... | [
983,
4
] | [
1000,
25
] | python | en | ['en', 'error', 'th'] | False |
EggInfoDistribution.list_installed_files | (self) |
Iterates over the ``installed-files.txt`` entries and returns a tuple
``(path, hash, size)`` for each line.
:returns: a list of (path, hash, size)
|
Iterates over the ``installed-files.txt`` entries and returns a tuple
``(path, hash, size)`` for each line. | def list_installed_files(self):
"""
Iterates over the ``installed-files.txt`` entries and returns a tuple
``(path, hash, size)`` for each line.
:returns: a list of (path, hash, size)
"""
def _md5(path):
f = open(path, 'rb')
try:
c... | [
"def",
"list_installed_files",
"(",
"self",
")",
":",
"def",
"_md5",
"(",
"path",
")",
":",
"f",
"=",
"open",
"(",
"path",
",",
"'rb'",
")",
"try",
":",
"content",
"=",
"f",
".",
"read",
"(",
")",
"finally",
":",
"f",
".",
"close",
"(",
")",
"r... | [
1002,
4
] | [
1038,
21
] | 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.