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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
GenericRelationsTests.test_generic_get_or_create_when_exists | (self) |
Should be able to use get_or_create from the generic related manager
to get a tag. Refs #23611.
|
Should be able to use get_or_create from the generic related manager
to get a tag. Refs #23611.
| def test_generic_get_or_create_when_exists(self):
"""
Should be able to use get_or_create from the generic related manager
to get a tag. Refs #23611.
"""
count = self.bacon.tags.count()
tag = self.bacon.tags.create(tag="stinky")
self.assertEqual(count + 1, self.ba... | [
"def",
"test_generic_get_or_create_when_exists",
"(",
"self",
")",
":",
"count",
"=",
"self",
".",
"bacon",
".",
"tags",
".",
"count",
"(",
")",
"tag",
"=",
"self",
".",
"bacon",
".",
"tags",
".",
"create",
"(",
"tag",
"=",
"\"stinky\"",
")",
"self",
"... | [
70,
4
] | [
82,
43
] | python | en | ['en', 'error', 'th'] | False |
GenericRelationsTests.test_generic_relations_m2m_mimic | (self) |
Objects with declared GenericRelations can be tagged directly -- the
API mimics the many-to-many API.
|
Objects with declared GenericRelations can be tagged directly -- the
API mimics the many-to-many API.
| def test_generic_relations_m2m_mimic(self):
"""
Objects with declared GenericRelations can be tagged directly -- the
API mimics the many-to-many API.
"""
self.assertQuerysetEqual(self.lion.tags.all(), [
"<TaggedItem: hairy>",
"<TaggedItem: yellow>"
... | [
"def",
"test_generic_relations_m2m_mimic",
"(",
"self",
")",
":",
"self",
".",
"assertQuerysetEqual",
"(",
"self",
".",
"lion",
".",
"tags",
".",
"all",
"(",
")",
",",
"[",
"\"<TaggedItem: hairy>\"",
",",
"\"<TaggedItem: yellow>\"",
"]",
")",
"self",
".",
"ass... | [
84,
4
] | [
96,
10
] | python | en | ['en', 'error', 'th'] | False |
GenericRelationsTests.test_access_content_object | (self) |
Test accessing the content object like a foreign key.
|
Test accessing the content object like a foreign key.
| def test_access_content_object(self):
"""
Test accessing the content object like a foreign key.
"""
tagged_item = TaggedItem.objects.get(tag="salty")
self.assertEqual(tagged_item.content_object, self.bacon) | [
"def",
"test_access_content_object",
"(",
"self",
")",
":",
"tagged_item",
"=",
"TaggedItem",
".",
"objects",
".",
"get",
"(",
"tag",
"=",
"\"salty\"",
")",
"self",
".",
"assertEqual",
"(",
"tagged_item",
".",
"content_object",
",",
"self",
".",
"bacon",
")"... | [
98,
4
] | [
103,
64
] | python | en | ['en', 'error', 'th'] | False |
GenericRelationsTests.test_exclude_generic_relations | (self) |
Test lookups over an object without GenericRelations.
|
Test lookups over an object without GenericRelations.
| def test_exclude_generic_relations(self):
"""
Test lookups over an object without GenericRelations.
"""
# Recall that the Mineral class doesn't have an explicit GenericRelation
# defined. That's OK, because you can create TaggedItems explicitly.
# However, excluding Gener... | [
"def",
"test_exclude_generic_relations",
"(",
"self",
")",
":",
"# Recall that the Mineral class doesn't have an explicit GenericRelation",
"# defined. That's OK, because you can create TaggedItems explicitly.",
"# However, excluding GenericRelations means your lookups have to be a",
"# bit more e... | [
119,
4
] | [
137,
10
] | python | en | ['en', 'error', 'th'] | False |
GenericRelationsTests.test_access_via_content_type | (self) |
Test lookups through content type.
|
Test lookups through content type.
| def test_access_via_content_type(self):
"""
Test lookups through content type.
"""
self.lion.delete()
self.platypus.tags.create(tag="fatty")
ctype = ContentType.objects.get_for_model(self.platypus)
self.assertQuerysetEqual(
Animal.objects.filter(tags... | [
"def",
"test_access_via_content_type",
"(",
"self",
")",
":",
"self",
".",
"lion",
".",
"delete",
"(",
")",
"self",
".",
"platypus",
".",
"tags",
".",
"create",
"(",
"tag",
"=",
"\"fatty\"",
")",
"ctype",
"=",
"ContentType",
".",
"objects",
".",
"get_for... | [
139,
4
] | [
150,
35
] | python | en | ['en', 'error', 'th'] | False |
GenericRelationsTests.test_set_foreign_key | (self) |
You can set a generic foreign key in the way you'd expect.
|
You can set a generic foreign key in the way you'd expect.
| def test_set_foreign_key(self):
"""
You can set a generic foreign key in the way you'd expect.
"""
tag1 = TaggedItem.objects.create(content_object=self.quartz, tag="shiny")
tag1.content_object = self.platypus
tag1.save()
self.assertQuerysetEqual(
self... | [
"def",
"test_set_foreign_key",
"(",
"self",
")",
":",
"tag1",
"=",
"TaggedItem",
".",
"objects",
".",
"create",
"(",
"content_object",
"=",
"self",
".",
"quartz",
",",
"tag",
"=",
"\"shiny\"",
")",
"tag1",
".",
"content_object",
"=",
"self",
".",
"platypus... | [
152,
4
] | [
162,
36
] | python | en | ['en', 'error', 'th'] | False |
GenericRelationsTests.test_queries_across_generic_relations | (self) |
Queries across generic relations respect the content types. Even though
there are two TaggedItems with a tag of "fatty", this query only pulls
out the one with the content type related to Animals.
|
Queries across generic relations respect the content types. Even though
there are two TaggedItems with a tag of "fatty", this query only pulls
out the one with the content type related to Animals.
| def test_queries_across_generic_relations(self):
"""
Queries across generic relations respect the content types. Even though
there are two TaggedItems with a tag of "fatty", this query only pulls
out the one with the content type related to Animals.
"""
self.assertQueryse... | [
"def",
"test_queries_across_generic_relations",
"(",
"self",
")",
":",
"self",
".",
"assertQuerysetEqual",
"(",
"Animal",
".",
"objects",
".",
"order_by",
"(",
"'common_name'",
")",
",",
"[",
"\"<Animal: Lion>\"",
",",
"\"<Animal: Platypus>\"",
"]",
")"
] | [
164,
4
] | [
173,
10
] | python | en | ['en', 'error', 'th'] | False |
GenericRelationsTests.test_queries_content_type_restriction | (self) |
Create another fatty tagged instance with different PK to ensure there
is a content type restriction in the generated queries below.
|
Create another fatty tagged instance with different PK to ensure there
is a content type restriction in the generated queries below.
| def test_queries_content_type_restriction(self):
"""
Create another fatty tagged instance with different PK to ensure there
is a content type restriction in the generated queries below.
"""
mpk = ManualPK.objects.create(id=self.lion.pk)
mpk.tags.create(tag="fatty")
... | [
"def",
"test_queries_content_type_restriction",
"(",
"self",
")",
":",
"mpk",
"=",
"ManualPK",
".",
"objects",
".",
"create",
"(",
"id",
"=",
"self",
".",
"lion",
".",
"pk",
")",
"mpk",
".",
"tags",
".",
"create",
"(",
"tag",
"=",
"\"fatty\"",
")",
"se... | [
175,
4
] | [
187,
74
] | python | en | ['en', 'error', 'th'] | False |
GenericRelationsTests.test_object_deletion_with_generic_relation | (self) |
If you delete an object with an explicit Generic relation, the related
objects are deleted when the source object is deleted.
|
If you delete an object with an explicit Generic relation, the related
objects are deleted when the source object is deleted.
| def test_object_deletion_with_generic_relation(self):
"""
If you delete an object with an explicit Generic relation, the related
objects are deleted when the source object is deleted.
"""
self.assertQuerysetEqual(TaggedItem.objects.all(), [
('fatty', Vegetable, self.b... | [
"def",
"test_object_deletion_with_generic_relation",
"(",
"self",
")",
":",
"self",
".",
"assertQuerysetEqual",
"(",
"TaggedItem",
".",
"objects",
".",
"all",
"(",
")",
",",
"[",
"(",
"'fatty'",
",",
"Vegetable",
",",
"self",
".",
"bacon",
".",
"pk",
")",
... | [
189,
4
] | [
209,
9
] | python | en | ['en', 'error', 'th'] | False |
GenericRelationsTests.test_object_deletion_without_generic_relation | (self) |
If Generic Relation is not explicitly defined, any related objects
remain after deletion of the source object.
|
If Generic Relation is not explicitly defined, any related objects
remain after deletion of the source object.
| def test_object_deletion_without_generic_relation(self):
"""
If Generic Relation is not explicitly defined, any related objects
remain after deletion of the source object.
"""
TaggedItem.objects.create(content_object=self.quartz, tag="clearish")
quartz_pk = self.quartz.pk... | [
"def",
"test_object_deletion_without_generic_relation",
"(",
"self",
")",
":",
"TaggedItem",
".",
"objects",
".",
"create",
"(",
"content_object",
"=",
"self",
".",
"quartz",
",",
"tag",
"=",
"\"clearish\"",
")",
"quartz_pk",
"=",
"self",
".",
"quartz",
".",
"... | [
211,
4
] | [
227,
9
] | python | en | ['en', 'error', 'th'] | False |
GenericRelationsTests.test_tag_deletion_related_objects_unaffected | (self) |
If you delete a tag, the objects using the tag are unaffected (other
than losing a tag).
|
If you delete a tag, the objects using the tag are unaffected (other
than losing a tag).
| def test_tag_deletion_related_objects_unaffected(self):
"""
If you delete a tag, the objects using the tag are unaffected (other
than losing a tag).
"""
ctype = ContentType.objects.get_for_model(self.lion)
tag = TaggedItem.objects.get(
content_type__pk=ctype.i... | [
"def",
"test_tag_deletion_related_objects_unaffected",
"(",
"self",
")",
":",
"ctype",
"=",
"ContentType",
".",
"objects",
".",
"get_for_model",
"(",
"self",
".",
"lion",
")",
"tag",
"=",
"TaggedItem",
".",
"objects",
".",
"get",
"(",
"content_type__pk",
"=",
... | [
229,
4
] | [
246,
9
] | python | en | ['en', 'error', 'th'] | False |
GenericRelationsTests.test_subclasses_with_gen_rel | (self) |
Test that concrete model subclasses with generic relations work
correctly (ticket 11263).
|
Test that concrete model subclasses with generic relations work
correctly (ticket 11263).
| def test_subclasses_with_gen_rel(self):
"""
Test that concrete model subclasses with generic relations work
correctly (ticket 11263).
"""
granite = Rock.objects.create(name='granite', hardness=5)
TaggedItem.objects.create(content_object=granite, tag="countertop")
... | [
"def",
"test_subclasses_with_gen_rel",
"(",
"self",
")",
":",
"granite",
"=",
"Rock",
".",
"objects",
".",
"create",
"(",
"name",
"=",
"'granite'",
",",
"hardness",
"=",
"5",
")",
"TaggedItem",
".",
"objects",
".",
"create",
"(",
"content_object",
"=",
"gr... | [
356,
4
] | [
363,
80
] | python | en | ['en', 'error', 'th'] | False |
GenericRelationsTests.test_generic_inline_formsets_initial | (self) |
Test for #17927 Initial values support for BaseGenericInlineFormSet.
|
Test for #17927 Initial values support for BaseGenericInlineFormSet.
| def test_generic_inline_formsets_initial(self):
"""
Test for #17927 Initial values support for BaseGenericInlineFormSet.
"""
quartz = Mineral.objects.create(name="Quartz", hardness=7)
GenericFormSet = generic_inlineformset_factory(TaggedItem, extra=1)
ctype = ContentType... | [
"def",
"test_generic_inline_formsets_initial",
"(",
"self",
")",
":",
"quartz",
"=",
"Mineral",
".",
"objects",
".",
"create",
"(",
"name",
"=",
"\"Quartz\"",
",",
"hardness",
"=",
"7",
")",
"GenericFormSet",
"=",
"generic_inlineformset_factory",
"(",
"TaggedItem"... | [
365,
4
] | [
379,
67
] | python | en | ['en', 'error', 'th'] | False |
GenericInlineFormsetTest.test_generic_inlineformset_factory | (self) |
Regression for #14572: Using base forms with widgets
defined in Meta should not raise errors.
|
Regression for #14572: Using base forms with widgets
defined in Meta should not raise errors.
| def test_generic_inlineformset_factory(self):
"""
Regression for #14572: Using base forms with widgets
defined in Meta should not raise errors.
"""
Formset = generic_inlineformset_factory(TaggedItem, TaggedItemForm)
form = Formset().forms[0]
self.assertIsInstance(... | [
"def",
"test_generic_inlineformset_factory",
"(",
"self",
")",
":",
"Formset",
"=",
"generic_inlineformset_factory",
"(",
"TaggedItem",
",",
"TaggedItemForm",
")",
"form",
"=",
"Formset",
"(",
")",
".",
"forms",
"[",
"0",
"]",
"self",
".",
"assertIsInstance",
"(... | [
421,
4
] | [
428,
69
] | python | en | ['en', 'error', 'th'] | False |
GenericInlineFormsetTest.test_save_new_uses_form_save | (self) |
Regression for #16260: save_new should call form.save()
|
Regression for #16260: save_new should call form.save()
| def test_save_new_uses_form_save(self):
"""
Regression for #16260: save_new should call form.save()
"""
class SaveTestForm(forms.ModelForm):
def save(self, *args, **kwargs):
self.instance.saved_by = "custom method"
return super(SaveTestForm, se... | [
"def",
"test_save_new_uses_form_save",
"(",
"self",
")",
":",
"class",
"SaveTestForm",
"(",
"forms",
".",
"ModelForm",
")",
":",
"def",
"save",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"instance",
".",
"saved_by",
... | [
430,
4
] | [
454,
59
] | python | en | ['en', 'error', 'th'] | False |
ProxyRelatedModelTest.test_default_behavior | (self) |
The default for for_concrete_model should be True
|
The default for for_concrete_model should be True
| def test_default_behavior(self):
"""
The default for for_concrete_model should be True
"""
base = ForConcreteModelModel()
base.obj = rel = ProxyRelatedModel.objects.create()
base.save()
base = ForConcreteModelModel.objects.get(pk=base.pk)
rel = ConcreteRe... | [
"def",
"test_default_behavior",
"(",
"self",
")",
":",
"base",
"=",
"ForConcreteModelModel",
"(",
")",
"base",
".",
"obj",
"=",
"rel",
"=",
"ProxyRelatedModel",
".",
"objects",
".",
"create",
"(",
")",
"base",
".",
"save",
"(",
")",
"base",
"=",
"ForConc... | [
496,
4
] | [
506,
39
] | python | en | ['en', 'error', 'th'] | False |
ProxyRelatedModelTest.test_works_normally | (self) |
When for_concrete_model is False, we should still be able to get
an instance of the concrete class.
|
When for_concrete_model is False, we should still be able to get
an instance of the concrete class.
| def test_works_normally(self):
"""
When for_concrete_model is False, we should still be able to get
an instance of the concrete class.
"""
base = ForProxyModelModel()
base.obj = rel = ConcreteRelatedModel.objects.create()
base.save()
base = ForProxyModelM... | [
"def",
"test_works_normally",
"(",
"self",
")",
":",
"base",
"=",
"ForProxyModelModel",
"(",
")",
"base",
".",
"obj",
"=",
"rel",
"=",
"ConcreteRelatedModel",
".",
"objects",
".",
"create",
"(",
")",
"base",
".",
"save",
"(",
")",
"base",
"=",
"ForProxyM... | [
508,
4
] | [
518,
39
] | python | en | ['en', 'error', 'th'] | False |
ProxyRelatedModelTest.test_proxy_is_returned | (self) |
Instances of the proxy should be returned when
for_concrete_model is False.
|
Instances of the proxy should be returned when
for_concrete_model is False.
| def test_proxy_is_returned(self):
"""
Instances of the proxy should be returned when
for_concrete_model is False.
"""
base = ForProxyModelModel()
base.obj = ProxyRelatedModel.objects.create()
base.save()
base = ForProxyModelModel.objects.get(pk=base.pk)
... | [
"def",
"test_proxy_is_returned",
"(",
"self",
")",
":",
"base",
"=",
"ForProxyModelModel",
"(",
")",
"base",
".",
"obj",
"=",
"ProxyRelatedModel",
".",
"objects",
".",
"create",
"(",
")",
"base",
".",
"save",
"(",
")",
"base",
"=",
"ForProxyModelModel",
".... | [
520,
4
] | [
530,
58
] | python | en | ['en', 'error', 'th'] | False |
HttpResponseTests.test_charset_detection | (self) | HttpResponse should parse charset from content_type. | HttpResponse should parse charset from content_type. | def test_charset_detection(self):
""" HttpResponse should parse charset from content_type."""
response = HttpResponse('ok')
self.assertEqual(response.charset, settings.DEFAULT_CHARSET)
response = HttpResponse(charset=ISO88591)
self.assertEqual(response.charset, ISO88591)
... | [
"def",
"test_charset_detection",
"(",
"self",
")",
":",
"response",
"=",
"HttpResponse",
"(",
"'ok'",
")",
"self",
".",
"assertEqual",
"(",
"response",
".",
"charset",
",",
"settings",
".",
"DEFAULT_CHARSET",
")",
"response",
"=",
"HttpResponse",
"(",
"charset... | [
25,
4
] | [
47,
68
] | python | en | ['en', 'en', 'en'] | True |
HttpResponseTests.test_response_content_charset | (self) | HttpResponse should encode based on charset. | HttpResponse should encode based on charset. | def test_response_content_charset(self):
"""HttpResponse should encode based on charset."""
content = "Café :)"
utf8_content = content.encode(UTF8)
iso_content = content.encode(ISO88591)
response = HttpResponse(utf8_content)
self.assertContains(response, utf8_content)
... | [
"def",
"test_response_content_charset",
"(",
"self",
")",
":",
"content",
"=",
"\"Café :)\"",
"utf8_content",
"=",
"content",
".",
"encode",
"(",
"UTF8",
")",
"iso_content",
"=",
"content",
".",
"encode",
"(",
"ISO88591",
")",
"response",
"=",
"HttpResponse",
... | [
49,
4
] | [
65,
50
] | python | en | ['en', 'zu', 'en'] | True |
read_pkg_file | (self, file) | Reads the metadata values from a file object. | Reads the metadata values from a file object. | def read_pkg_file(self, file):
"""Reads the metadata values from a file object."""
msg = message_from_file(file)
def _read_field(name):
value = msg[name]
if value == 'UNKNOWN':
return None
return value
def _read_list(name):
values = msg.get_all(name, None)
... | [
"def",
"read_pkg_file",
"(",
"self",
",",
"file",
")",
":",
"msg",
"=",
"message_from_file",
"(",
"file",
")",
"def",
"_read_field",
"(",
"name",
")",
":",
"value",
"=",
"msg",
"[",
"name",
"]",
"if",
"value",
"==",
"'UNKNOWN'",
":",
"return",
"None",
... | [
69,
0
] | [
119,
29
] | python | en | ['en', 'en', 'en'] | True |
write_pkg_file | (self, file) | Write the PKG-INFO format data to a file object.
| Write the PKG-INFO format data to a file object.
| def write_pkg_file(self, file):
"""Write the PKG-INFO format data to a file object.
"""
version = self.get_metadata_version()
if six.PY2:
def write_field(key, value):
file.write("%s: %s\n" % (key, self._encode_field(value)))
else:
def write_field(key, value):
... | [
"def",
"write_pkg_file",
"(",
"self",
",",
"file",
")",
":",
"version",
"=",
"self",
".",
"get_metadata_version",
"(",
")",
"if",
"six",
".",
"PY2",
":",
"def",
"write_field",
"(",
"key",
",",
"value",
")",
":",
"file",
".",
"write",
"(",
"\"%s: %s\\n\... | [
123,
0
] | [
196,
48
] | python | en | ['en', 'en', 'en'] | True |
assert_string_list | (dist, attr, value) | Verify that value is a string list | Verify that value is a string list | def assert_string_list(dist, attr, value):
"""Verify that value is a string list"""
try:
# verify that value is a list or tuple to exclude unordered
# or single-use iterables
assert isinstance(value, (list, tuple))
# verify that elements of value are strings
assert ''.joi... | [
"def",
"assert_string_list",
"(",
"dist",
",",
"attr",
",",
"value",
")",
":",
"try",
":",
"# verify that value is a list or tuple to exclude unordered",
"# or single-use iterables",
"assert",
"isinstance",
"(",
"value",
",",
"(",
"list",
",",
"tuple",
")",
")",
"# ... | [
213,
0
] | [
224,
16
] | python | en | ['en', 'en', 'en'] | True |
check_nsp | (dist, attr, value) | Verify that namespace packages are valid | Verify that namespace packages are valid | def check_nsp(dist, attr, value):
"""Verify that namespace packages are valid"""
ns_packages = value
assert_string_list(dist, attr, ns_packages)
for nsp in ns_packages:
if not dist.has_contents_for(nsp):
raise DistutilsSetupError(
"Distribution contains no modules or ... | [
"def",
"check_nsp",
"(",
"dist",
",",
"attr",
",",
"value",
")",
":",
"ns_packages",
"=",
"value",
"assert_string_list",
"(",
"dist",
",",
"attr",
",",
"ns_packages",
")",
"for",
"nsp",
"in",
"ns_packages",
":",
"if",
"not",
"dist",
".",
"has_contents_for"... | [
227,
0
] | [
242,
13
] | python | en | ['en', 'en', 'en'] | True |
check_extras | (dist, attr, value) | Verify that extras_require mapping is valid | Verify that extras_require mapping is valid | def check_extras(dist, attr, value):
"""Verify that extras_require mapping is valid"""
try:
list(itertools.starmap(_check_extra, value.items()))
except (TypeError, ValueError, AttributeError) as e:
raise DistutilsSetupError(
"'extras_require' must be a dictionary whose values are... | [
"def",
"check_extras",
"(",
"dist",
",",
"attr",
",",
"value",
")",
":",
"try",
":",
"list",
"(",
"itertools",
".",
"starmap",
"(",
"_check_extra",
",",
"value",
".",
"items",
"(",
")",
")",
")",
"except",
"(",
"TypeError",
",",
"ValueError",
",",
"A... | [
245,
0
] | [
254,
16
] | python | en | ['en', 'en', 'en'] | True |
assert_bool | (dist, attr, value) | Verify that value is True, False, 0, or 1 | Verify that value is True, False, 0, or 1 | def assert_bool(dist, attr, value):
"""Verify that value is True, False, 0, or 1"""
if bool(value) != value:
tmpl = "{attr!r} must be a boolean value (got {value!r})"
raise DistutilsSetupError(tmpl.format(attr=attr, value=value)) | [
"def",
"assert_bool",
"(",
"dist",
",",
"attr",
",",
"value",
")",
":",
"if",
"bool",
"(",
"value",
")",
"!=",
"value",
":",
"tmpl",
"=",
"\"{attr!r} must be a boolean value (got {value!r})\"",
"raise",
"DistutilsSetupError",
"(",
"tmpl",
".",
"format",
"(",
"... | [
264,
0
] | [
268,
70
] | python | en | ['en', 'en', 'en'] | True |
check_requirements | (dist, attr, value) | Verify that install_requires is a valid requirements list | Verify that install_requires is a valid requirements list | def check_requirements(dist, attr, value):
"""Verify that install_requires is a valid requirements list"""
try:
list(pkg_resources.parse_requirements(value))
if isinstance(value, (dict, set)):
raise TypeError("Unordered types are not allowed")
except (TypeError, ValueError) as er... | [
"def",
"check_requirements",
"(",
"dist",
",",
"attr",
",",
"value",
")",
":",
"try",
":",
"list",
"(",
"pkg_resources",
".",
"parse_requirements",
"(",
"value",
")",
")",
"if",
"isinstance",
"(",
"value",
",",
"(",
"dict",
",",
"set",
")",
")",
":",
... | [
271,
0
] | [
284,
20
] | python | en | ['en', 'en', 'en'] | True |
check_specifier | (dist, attr, value) | Verify that value is a valid version specifier | Verify that value is a valid version specifier | def check_specifier(dist, attr, value):
"""Verify that value is a valid version specifier"""
try:
packaging.specifiers.SpecifierSet(value)
except packaging.specifiers.InvalidSpecifier as error:
tmpl = (
"{attr!r} must be a string "
"containing valid version specifiers... | [
"def",
"check_specifier",
"(",
"dist",
",",
"attr",
",",
"value",
")",
":",
"try",
":",
"packaging",
".",
"specifiers",
".",
"SpecifierSet",
"(",
"value",
")",
"except",
"packaging",
".",
"specifiers",
".",
"InvalidSpecifier",
"as",
"error",
":",
"tmpl",
"... | [
287,
0
] | [
298,
20
] | python | en | ['en', 'en', 'en'] | True |
check_entry_points | (dist, attr, value) | Verify that entry_points map is parseable | Verify that entry_points map is parseable | def check_entry_points(dist, attr, value):
"""Verify that entry_points map is parseable"""
try:
pkg_resources.EntryPoint.parse_map(value)
except ValueError as e:
raise DistutilsSetupError(e) from e | [
"def",
"check_entry_points",
"(",
"dist",
",",
"attr",
",",
"value",
")",
":",
"try",
":",
"pkg_resources",
".",
"EntryPoint",
".",
"parse_map",
"(",
"value",
")",
"except",
"ValueError",
"as",
"e",
":",
"raise",
"DistutilsSetupError",
"(",
"e",
")",
"from... | [
301,
0
] | [
306,
43
] | python | en | ['en', 'en', 'en'] | True |
check_package_data | (dist, attr, value) | Verify that value is a dictionary of package names to glob lists | Verify that value is a dictionary of package names to glob lists | def check_package_data(dist, attr, value):
"""Verify that value is a dictionary of package names to glob lists"""
if not isinstance(value, dict):
raise DistutilsSetupError(
"{!r} must be a dictionary mapping package names to lists of "
"string wildcard patterns".format(attr))
... | [
"def",
"check_package_data",
"(",
"dist",
",",
"attr",
",",
"value",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"dict",
")",
":",
"raise",
"DistutilsSetupError",
"(",
"\"{!r} must be a dictionary mapping package names to lists of \"",
"\"string wildcard pat... | [
314,
0
] | [
326,
71
] | python | en | ['en', 'en', 'en'] | True |
Distribution._finalize_requires | (self) |
Set `metadata.python_requires` and fix environment markers
in `install_requires` and `extras_require`.
|
Set `metadata.python_requires` and fix environment markers
in `install_requires` and `extras_require`.
| def _finalize_requires(self):
"""
Set `metadata.python_requires` and fix environment markers
in `install_requires` and `extras_require`.
"""
if getattr(self, 'python_requires', None):
self.metadata.python_requires = self.python_requires
if getattr(self, 'extr... | [
"def",
"_finalize_requires",
"(",
"self",
")",
":",
"if",
"getattr",
"(",
"self",
",",
"'python_requires'",
",",
"None",
")",
":",
"self",
".",
"metadata",
".",
"python_requires",
"=",
"self",
".",
"python_requires",
"if",
"getattr",
"(",
"self",
",",
"'ex... | [
480,
4
] | [
498,
49
] | python | en | ['en', 'error', 'th'] | False |
Distribution._convert_extras_requirements | (self) |
Convert requirements in `extras_require` of the form
`"extra": ["barbazquux; {marker}"]` to
`"extra:{marker}": ["barbazquux"]`.
|
Convert requirements in `extras_require` of the form
`"extra": ["barbazquux; {marker}"]` to
`"extra:{marker}": ["barbazquux"]`.
| def _convert_extras_requirements(self):
"""
Convert requirements in `extras_require` of the form
`"extra": ["barbazquux; {marker}"]` to
`"extra:{marker}": ["barbazquux"]`.
"""
spec_ext_reqs = getattr(self, 'extras_require', None) or {}
self._tmp_extras_require = d... | [
"def",
"_convert_extras_requirements",
"(",
"self",
")",
":",
"spec_ext_reqs",
"=",
"getattr",
"(",
"self",
",",
"'extras_require'",
",",
"None",
")",
"or",
"{",
"}",
"self",
".",
"_tmp_extras_require",
"=",
"defaultdict",
"(",
"list",
")",
"for",
"section",
... | [
500,
4
] | [
513,
68
] | python | en | ['en', 'error', 'th'] | False |
Distribution._suffix_for | (req) |
For a requirement, return the 'extras_require' suffix for
that requirement.
|
For a requirement, return the 'extras_require' suffix for
that requirement.
| def _suffix_for(req):
"""
For a requirement, return the 'extras_require' suffix for
that requirement.
"""
return ':' + str(req.marker) if req.marker else '' | [
"def",
"_suffix_for",
"(",
"req",
")",
":",
"return",
"':'",
"+",
"str",
"(",
"req",
".",
"marker",
")",
"if",
"req",
".",
"marker",
"else",
"''"
] | [
516,
4
] | [
521,
58
] | python | en | ['en', 'error', 'th'] | False |
Distribution._move_install_requirements_markers | (self) |
Move requirements in `install_requires` that are using environment
markers `extras_require`.
|
Move requirements in `install_requires` that are using environment
markers `extras_require`.
| def _move_install_requirements_markers(self):
"""
Move requirements in `install_requires` that are using environment
markers `extras_require`.
"""
# divide the install_requires into two sets, simple ones still
# handled by install_requires and more complex ones handled
... | [
"def",
"_move_install_requirements_markers",
"(",
"self",
")",
":",
"# divide the install_requires into two sets, simple ones still",
"# handled by install_requires and more complex ones handled",
"# by extras_require.",
"def",
"is_simple_req",
"(",
"req",
")",
":",
"return",
"not",
... | [
523,
4
] | [
547,
9
] | python | en | ['en', 'error', 'th'] | False |
Distribution._clean_req | (self, req) |
Given a Requirement, remove environment markers and return it.
|
Given a Requirement, remove environment markers and return it.
| def _clean_req(self, req):
"""
Given a Requirement, remove environment markers and return it.
"""
req.marker = None
return req | [
"def",
"_clean_req",
"(",
"self",
",",
"req",
")",
":",
"req",
".",
"marker",
"=",
"None",
"return",
"req"
] | [
549,
4
] | [
554,
18
] | python | en | ['en', 'error', 'th'] | False |
Distribution._parse_config_files | (self, filenames=None) |
Adapted from distutils.dist.Distribution.parse_config_files,
this method provides the same functionality in subtly-improved
ways.
|
Adapted from distutils.dist.Distribution.parse_config_files,
this method provides the same functionality in subtly-improved
ways.
| def _parse_config_files(self, filenames=None):
"""
Adapted from distutils.dist.Distribution.parse_config_files,
this method provides the same functionality in subtly-improved
ways.
"""
from setuptools.extern.six.moves.configparser import ConfigParser
# Ignore ins... | [
"def",
"_parse_config_files",
"(",
"self",
",",
"filenames",
"=",
"None",
")",
":",
"from",
"setuptools",
".",
"extern",
".",
"six",
".",
"moves",
".",
"configparser",
"import",
"ConfigParser",
"# Ignore install directory options if we have a venv",
"if",
"not",
"si... | [
556,
4
] | [
616,
56
] | python | en | ['en', 'error', 'th'] | False |
Distribution._try_str | (val) |
On Python 2, much of distutils relies on string values being of
type 'str' (bytes) and not unicode text. If the value can be safely
encoded to bytes using the default encoding, prefer that.
Why the default encoding? Because that value can be implicitly
decoded back to text if n... |
On Python 2, much of distutils relies on string values being of
type 'str' (bytes) and not unicode text. If the value can be safely
encoded to bytes using the default encoding, prefer that. | def _try_str(val):
"""
On Python 2, much of distutils relies on string values being of
type 'str' (bytes) and not unicode text. If the value can be safely
encoded to bytes using the default encoding, prefer that.
Why the default encoding? Because that value can be implicitly
... | [
"def",
"_try_str",
"(",
"val",
")",
":",
"if",
"not",
"six",
".",
"PY2",
":",
"return",
"val",
"try",
":",
"return",
"val",
".",
"encode",
"(",
")",
"except",
"UnicodeEncodeError",
":",
"pass",
"return",
"val"
] | [
619,
4
] | [
636,
18
] | python | en | ['en', 'error', 'th'] | False |
Distribution._set_command_options | (self, command_obj, option_dict=None) |
Set the options for 'command_obj' from 'option_dict'. Basically
this means copying elements of a dictionary ('option_dict') to
attributes of an instance ('command').
'command_obj' must be a Command instance. If 'option_dict' is not
supplied, uses the standard option dictionar... |
Set the options for 'command_obj' from 'option_dict'. Basically
this means copying elements of a dictionary ('option_dict') to
attributes of an instance ('command'). | def _set_command_options(self, command_obj, option_dict=None):
"""
Set the options for 'command_obj' from 'option_dict'. Basically
this means copying elements of a dictionary ('option_dict') to
attributes of an instance ('command').
'command_obj' must be a Command instance. If... | [
"def",
"_set_command_options",
"(",
"self",
",",
"command_obj",
",",
"option_dict",
"=",
"None",
")",
":",
"command_name",
"=",
"command_obj",
".",
"get_command_name",
"(",
")",
"if",
"option_dict",
"is",
"None",
":",
"option_dict",
"=",
"self",
".",
"get_opti... | [
638,
4
] | [
683,
52
] | python | en | ['en', 'error', 'th'] | False |
Distribution.parse_config_files | (self, filenames=None, ignore_option_errors=False) | Parses configuration files from various levels
and loads configuration.
| Parses configuration files from various levels
and loads configuration. | def parse_config_files(self, filenames=None, ignore_option_errors=False):
"""Parses configuration files from various levels
and loads configuration.
"""
self._parse_config_files(filenames=filenames)
parse_configuration(self, self.command_options,
ign... | [
"def",
"parse_config_files",
"(",
"self",
",",
"filenames",
"=",
"None",
",",
"ignore_option_errors",
"=",
"False",
")",
":",
"self",
".",
"_parse_config_files",
"(",
"filenames",
"=",
"filenames",
")",
"parse_configuration",
"(",
"self",
",",
"self",
".",
"co... | [
685,
4
] | [
694,
33
] | python | en | ['en', 'en', 'en'] | True |
Distribution.fetch_build_eggs | (self, requires) | Resolve pre-setup requirements | Resolve pre-setup requirements | def fetch_build_eggs(self, requires):
"""Resolve pre-setup requirements"""
resolved_dists = pkg_resources.working_set.resolve(
pkg_resources.parse_requirements(requires),
installer=self.fetch_build_egg,
replace_conflicting=True,
)
for dist in resolved_... | [
"def",
"fetch_build_eggs",
"(",
"self",
",",
"requires",
")",
":",
"resolved_dists",
"=",
"pkg_resources",
".",
"working_set",
".",
"resolve",
"(",
"pkg_resources",
".",
"parse_requirements",
"(",
"requires",
")",
",",
"installer",
"=",
"self",
".",
"fetch_build... | [
696,
4
] | [
705,
29
] | python | en | ['en', 'en', 'en'] | True |
Distribution.finalize_options | (self) |
Allow plugins to apply arbitrary operations to the
distribution. Each hook may optionally define a 'order'
to influence the order of execution. Smaller numbers
go first and the default is 0.
|
Allow plugins to apply arbitrary operations to the
distribution. Each hook may optionally define a 'order'
to influence the order of execution. Smaller numbers
go first and the default is 0.
| def finalize_options(self):
"""
Allow plugins to apply arbitrary operations to the
distribution. Each hook may optionally define a 'order'
to influence the order of execution. Smaller numbers
go first and the default is 0.
"""
group = 'setuptools.finalize_distribu... | [
"def",
"finalize_options",
"(",
"self",
")",
":",
"group",
"=",
"'setuptools.finalize_distribution_options'",
"def",
"by_order",
"(",
"hook",
")",
":",
"return",
"getattr",
"(",
"hook",
",",
"'order'",
",",
"0",
")",
"eps",
"=",
"map",
"(",
"lambda",
"e",
... | [
707,
4
] | [
720,
20
] | python | en | ['en', 'error', 'th'] | False |
Distribution.fetch_build_egg | (self, req) | Fetch an egg needed for building | Fetch an egg needed for building | def fetch_build_egg(self, req):
"""Fetch an egg needed for building"""
from setuptools.installer import fetch_build_egg
return fetch_build_egg(self, req) | [
"def",
"fetch_build_egg",
"(",
"self",
",",
"req",
")",
":",
"from",
"setuptools",
".",
"installer",
"import",
"fetch_build_egg",
"return",
"fetch_build_egg",
"(",
"self",
",",
"req",
")"
] | [
754,
4
] | [
757,
41
] | python | en | ['en', 'en', 'en'] | True |
Distribution.get_command_class | (self, command) | Pluggable version of get_command_class() | Pluggable version of get_command_class() | def get_command_class(self, command):
"""Pluggable version of get_command_class()"""
if command in self.cmdclass:
return self.cmdclass[command]
eps = pkg_resources.iter_entry_points('distutils.commands', command)
for ep in eps:
ep.require(installer=self.fetch_bui... | [
"def",
"get_command_class",
"(",
"self",
",",
"command",
")",
":",
"if",
"command",
"in",
"self",
".",
"cmdclass",
":",
"return",
"self",
".",
"cmdclass",
"[",
"command",
"]",
"eps",
"=",
"pkg_resources",
".",
"iter_entry_points",
"(",
"'distutils.commands'",
... | [
759,
4
] | [
770,
65
] | python | en | ['en', 'en', 'en'] | True |
Distribution.include | (self, **attrs) | Add items to distribution that are named in keyword arguments
For example, 'dist.include(py_modules=["x"])' would add 'x' to
the distribution's 'py_modules' attribute, if it was not already
there.
Currently, this method only supports inclusion for attributes that are
lists or t... | Add items to distribution that are named in keyword arguments | def include(self, **attrs):
"""Add items to distribution that are named in keyword arguments
For example, 'dist.include(py_modules=["x"])' would add 'x' to
the distribution's 'py_modules' attribute, if it was not already
there.
Currently, this method only supports inclusion for... | [
"def",
"include",
"(",
"self",
",",
"*",
"*",
"attrs",
")",
":",
"for",
"k",
",",
"v",
"in",
"attrs",
".",
"items",
"(",
")",
":",
"include",
"=",
"getattr",
"(",
"self",
",",
"'_include_'",
"+",
"k",
",",
"None",
")",
"if",
"include",
":",
"in... | [
788,
4
] | [
808,
40
] | python | en | ['en', 'en', 'en'] | True |
Distribution.exclude_package | (self, package) | Remove packages, modules, and extensions in named package | Remove packages, modules, and extensions in named package | def exclude_package(self, package):
"""Remove packages, modules, and extensions in named package"""
pfx = package + '.'
if self.packages:
self.packages = [
p for p in self.packages
if p != package and not p.startswith(pfx)
]
if se... | [
"def",
"exclude_package",
"(",
"self",
",",
"package",
")",
":",
"pfx",
"=",
"package",
"+",
"'.'",
"if",
"self",
".",
"packages",
":",
"self",
".",
"packages",
"=",
"[",
"p",
"for",
"p",
"in",
"self",
".",
"packages",
"if",
"p",
"!=",
"package",
"... | [
810,
4
] | [
830,
13
] | python | en | ['en', 'en', 'en'] | True |
Distribution.has_contents_for | (self, package) | Return true if 'exclude_package(package)' would do something | Return true if 'exclude_package(package)' would do something | def has_contents_for(self, package):
"""Return true if 'exclude_package(package)' would do something"""
pfx = package + '.'
for p in self.iter_distribution_names():
if p == package or p.startswith(pfx):
return True | [
"def",
"has_contents_for",
"(",
"self",
",",
"package",
")",
":",
"pfx",
"=",
"package",
"+",
"'.'",
"for",
"p",
"in",
"self",
".",
"iter_distribution_names",
"(",
")",
":",
"if",
"p",
"==",
"package",
"or",
"p",
".",
"startswith",
"(",
"pfx",
")",
"... | [
832,
4
] | [
839,
27
] | python | en | ['en', 'en', 'en'] | True |
Distribution._exclude_misc | (self, name, value) | Handle 'exclude()' for list/tuple attrs without a special handler | Handle 'exclude()' for list/tuple attrs without a special handler | def _exclude_misc(self, name, value):
"""Handle 'exclude()' for list/tuple attrs without a special handler"""
if not isinstance(value, sequence):
raise DistutilsSetupError(
"%s: setting must be a list or tuple (%r)" % (name, value)
)
try:
old =... | [
"def",
"_exclude_misc",
"(",
"self",
",",
"name",
",",
"value",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"sequence",
")",
":",
"raise",
"DistutilsSetupError",
"(",
"\"%s: setting must be a list or tuple (%r)\"",
"%",
"(",
"name",
",",
"value",
"... | [
841,
4
] | [
858,
76
] | python | en | ['en', 'en', 'en'] | True |
Distribution._include_misc | (self, name, value) | Handle 'include()' for list/tuple attrs without a special handler | Handle 'include()' for list/tuple attrs without a special handler | def _include_misc(self, name, value):
"""Handle 'include()' for list/tuple attrs without a special handler"""
if not isinstance(value, sequence):
raise DistutilsSetupError(
"%s: setting must be a list (%r)" % (name, value)
)
try:
old = getattr... | [
"def",
"_include_misc",
"(",
"self",
",",
"name",
",",
"value",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"sequence",
")",
":",
"raise",
"DistutilsSetupError",
"(",
"\"%s: setting must be a list (%r)\"",
"%",
"(",
"name",
",",
"value",
")",
")"... | [
860,
4
] | [
881,
42
] | python | en | ['en', 'en', 'en'] | True |
Distribution.exclude | (self, **attrs) | Remove items from distribution that are named in keyword arguments
For example, 'dist.exclude(py_modules=["x"])' would remove 'x' from
the distribution's 'py_modules' attribute. Excluding packages uses
the 'exclude_package()' method, so all of the package's contained
packages, modules,... | Remove items from distribution that are named in keyword arguments | def exclude(self, **attrs):
"""Remove items from distribution that are named in keyword arguments
For example, 'dist.exclude(py_modules=["x"])' would remove 'x' from
the distribution's 'py_modules' attribute. Excluding packages uses
the 'exclude_package()' method, so all of the package... | [
"def",
"exclude",
"(",
"self",
",",
"*",
"*",
"attrs",
")",
":",
"for",
"k",
",",
"v",
"in",
"attrs",
".",
"items",
"(",
")",
":",
"exclude",
"=",
"getattr",
"(",
"self",
",",
"'_exclude_'",
"+",
"k",
",",
"None",
")",
"if",
"exclude",
":",
"ex... | [
883,
4
] | [
904,
40
] | python | en | ['en', 'en', 'en'] | True |
Distribution.get_cmdline_options | (self) | Return a '{cmd: {opt:val}}' map of all command-line options
Option names are all long, but do not include the leading '--', and
contain dashes rather than underscores. If the option doesn't take
an argument (e.g. '--quiet'), the 'val' is 'None'.
Note that options provided by config fi... | Return a '{cmd: {opt:val}}' map of all command-line options | def get_cmdline_options(self):
"""Return a '{cmd: {opt:val}}' map of all command-line options
Option names are all long, but do not include the leading '--', and
contain dashes rather than underscores. If the option doesn't take
an argument (e.g. '--quiet'), the 'val' is 'None'.
... | [
"def",
"get_cmdline_options",
"(",
"self",
")",
":",
"d",
"=",
"{",
"}",
"for",
"cmd",
",",
"opts",
"in",
"self",
".",
"command_options",
".",
"items",
"(",
")",
":",
"for",
"opt",
",",
"(",
"src",
",",
"val",
")",
"in",
"opts",
".",
"items",
"("... | [
939,
4
] | [
977,
16
] | python | en | ['en', 'en', 'en'] | True |
Distribution.iter_distribution_names | (self) | Yield all packages, modules, and extension names in distribution | Yield all packages, modules, and extension names in distribution | def iter_distribution_names(self):
"""Yield all packages, modules, and extension names in distribution"""
for pkg in self.packages or ():
yield pkg
for module in self.py_modules or ():
yield module
for ext in self.ext_modules or ():
if isinstance(ex... | [
"def",
"iter_distribution_names",
"(",
"self",
")",
":",
"for",
"pkg",
"in",
"self",
".",
"packages",
"or",
"(",
")",
":",
"yield",
"pkg",
"for",
"module",
"in",
"self",
".",
"py_modules",
"or",
"(",
")",
":",
"yield",
"module",
"for",
"ext",
"in",
"... | [
979,
4
] | [
995,
22
] | python | en | ['en', 'en', 'en'] | True |
Distribution.handle_display_options | (self, option_order) | If there were any non-global "display-only" options
(--help-commands or the metadata display options) on the command
line, display the requested info and return true; else return
false.
| If there were any non-global "display-only" options
(--help-commands or the metadata display options) on the command
line, display the requested info and return true; else return
false.
| def handle_display_options(self, option_order):
"""If there were any non-global "display-only" options
(--help-commands or the metadata display options) on the command
line, display the requested info and return true; else return
false.
"""
import sys
if six.PY2 ... | [
"def",
"handle_display_options",
"(",
"self",
",",
"option_order",
")",
":",
"import",
"sys",
"if",
"six",
".",
"PY2",
"or",
"self",
".",
"help_commands",
":",
"return",
"_Distribution",
".",
"handle_display_options",
"(",
"self",
",",
"option_order",
")",
"# ... | [
997,
4
] | [
1029,
79
] | python | en | ['en', 'en', 'en'] | True |
create_egg | (name, resources) |
Creates a mock egg with a list of resources.
name: The name of the module.
resources: A dictionary of resources. Keys are the names and values the data.
|
Creates a mock egg with a list of resources. | def create_egg(name, resources):
"""
Creates a mock egg with a list of resources.
name: The name of the module.
resources: A dictionary of resources. Keys are the names and values the data.
"""
egg = types.ModuleType(name)
egg.__loader__ = MockLoader()
egg.__path__ = ['/some/bogus/path/... | [
"def",
"create_egg",
"(",
"name",
",",
"resources",
")",
":",
"egg",
"=",
"types",
".",
"ModuleType",
"(",
"name",
")",
"egg",
".",
"__loader__",
"=",
"MockLoader",
"(",
")",
"egg",
".",
"__path__",
"=",
"[",
"'/some/bogus/path/'",
"]",
"egg",
".",
"__... | [
36,
0
] | [
48,
27
] | python | en | ['en', 'error', 'th'] | False |
CheckRegistry.register | (self, *tags, **kwargs) |
Decorator. Register given function `f` labeled with given `tags`. The
function should receive **kwargs and return list of Errors and
Warnings.
Example::
registry = CheckRegistry()
@registry.register('mytag', 'anothertag')
def my_check(apps, **kwargs... |
Decorator. Register given function `f` labeled with given `tags`. The
function should receive **kwargs and return list of Errors and
Warnings. | def register(self, *tags, **kwargs):
"""
Decorator. Register given function `f` labeled with given `tags`. The
function should receive **kwargs and return list of Errors and
Warnings.
Example::
registry = CheckRegistry()
@registry.register('mytag', 'anot... | [
"def",
"register",
"(",
"self",
",",
"*",
"tags",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"setdefault",
"(",
"'deploy'",
",",
"False",
")",
"def",
"inner",
"(",
"check",
")",
":",
"check",
".",
"tags",
"=",
"tags",
"if",
"kwargs",
"[",
... | [
25,
4
] | [
51,
20
] | python | en | ['en', 'error', 'th'] | False |
CheckRegistry.run_checks | (self, app_configs=None, tags=None, include_deployment_checks=False) | Run all registered checks and return list of Errors and Warnings.
| Run all registered checks and return list of Errors and Warnings.
| def run_checks(self, app_configs=None, tags=None, include_deployment_checks=False):
""" Run all registered checks and return list of Errors and Warnings.
"""
errors = []
checks = self.get_checks(include_deployment_checks)
if tags is not None:
checks = [check for chec... | [
"def",
"run_checks",
"(",
"self",
",",
"app_configs",
"=",
"None",
",",
"tags",
"=",
"None",
",",
"include_deployment_checks",
"=",
"False",
")",
":",
"errors",
"=",
"[",
"]",
"checks",
"=",
"self",
".",
"get_checks",
"(",
"include_deployment_checks",
")",
... | [
53,
4
] | [
69,
21
] | python | en | ['en', 'en', 'en'] | True |
_check_permissions_dict | (api_client, resource, is_admin, is_manager, is_viewer, can_make_reservations,
can_ignore_opening_hours, can_bypass_payment) |
Check that user permissions returned from resource endpoint contain correct values
for given user and resource. api_client should have the user authenticated.
|
Check that user permissions returned from resource endpoint contain correct values
for given user and resource. api_client should have the user authenticated.
| def _check_permissions_dict(api_client, resource, is_admin, is_manager, is_viewer, can_make_reservations,
can_ignore_opening_hours, can_bypass_payment):
"""
Check that user permissions returned from resource endpoint contain correct values
for given user and resource. api_client ... | [
"def",
"_check_permissions_dict",
"(",
"api_client",
",",
"resource",
",",
"is_admin",
",",
"is_manager",
",",
"is_viewer",
",",
"can_make_reservations",
",",
"can_ignore_opening_hours",
",",
"can_bypass_payment",
")",
":",
"url",
"=",
"reverse",
"(",
"'resource-detai... | [
30,
0
] | [
48,
66
] | python | en | ['en', 'error', 'th'] | False |
test_disallowed_methods | (all_user_types_api_client, list_url, detail_url) |
Tests that only safe methods are allowed to unit list and detail endpoints.
|
Tests that only safe methods are allowed to unit list and detail endpoints.
| def test_disallowed_methods(all_user_types_api_client, list_url, detail_url):
"""
Tests that only safe methods are allowed to unit list and detail endpoints.
"""
check_only_safe_methods_allowed(all_user_types_api_client, (list_url, detail_url)) | [
"def",
"test_disallowed_methods",
"(",
"all_user_types_api_client",
",",
"list_url",
",",
"detail_url",
")",
":",
"check_only_safe_methods_allowed",
"(",
"all_user_types_api_client",
",",
"(",
"list_url",
",",
"detail_url",
")",
")"
] | [
52,
0
] | [
56,
86
] | python | en | ['en', 'error', 'th'] | False |
test_user_permissions_in_resource_endpoint | (api_client, resource_in_unit, user, group) |
Tests that resource endpoint returns a permissions dict with correct values.
|
Tests that resource endpoint returns a permissions dict with correct values.
| def test_user_permissions_in_resource_endpoint(api_client, resource_in_unit, user, group):
"""
Tests that resource endpoint returns a permissions dict with correct values.
"""
api_client.force_authenticate(user=user)
# normal user, reservable = True
_check_permissions_dict(api_client, resource_... | [
"def",
"test_user_permissions_in_resource_endpoint",
"(",
"api_client",
",",
"resource_in_unit",
",",
"user",
",",
"group",
")",
":",
"api_client",
".",
"force_authenticate",
"(",
"user",
"=",
"user",
")",
"# normal user, reservable = True",
"_check_permissions_dict",
"("... | [
60,
0
] | [
157,
53
] | python | en | ['en', 'error', 'th'] | False |
test_non_public_resource_visibility | (api_client, resource_in_unit, user, staff_user) |
Tests that non-public resources are not returned for non-staff.
|
Tests that non-public resources are not returned for non-staff.
| def test_non_public_resource_visibility(api_client, resource_in_unit, user, staff_user):
"""
Tests that non-public resources are not returned for non-staff.
"""
resource_in_unit.public = False
resource_in_unit.save()
url = reverse('resource-detail', kwargs={'pk': resource_in_unit.pk})
resp... | [
"def",
"test_non_public_resource_visibility",
"(",
"api_client",
",",
"resource_in_unit",
",",
"user",
",",
"staff_user",
")",
":",
"resource_in_unit",
".",
"public",
"=",
"False",
"resource_in_unit",
".",
"save",
"(",
")",
"url",
"=",
"reverse",
"(",
"'resource-d... | [
161,
0
] | [
244,
111
] | python | en | ['en', 'error', 'th'] | False |
test_order_by_accessibility_no_viewpoint | (list_url, api_client, resource_with_accessibility_data,
resource_with_accessibility_data2) | Ordering by accessibility requires that the desired accessibility viewpoint for ordering
is provided
| Ordering by accessibility requires that the desired accessibility viewpoint for ordering
is provided
| def test_order_by_accessibility_no_viewpoint(list_url, api_client, resource_with_accessibility_data,
resource_with_accessibility_data2):
""" Ordering by accessibility requires that the desired accessibility viewpoint for ordering
is provided
"""
response = ap... | [
"def",
"test_order_by_accessibility_no_viewpoint",
"(",
"list_url",
",",
"api_client",
",",
"resource_with_accessibility_data",
",",
"resource_with_accessibility_data2",
")",
":",
"response",
"=",
"api_client",
".",
"get",
"(",
"'%s?order_by=accessibility'",
"%",
"list_url",
... | [
1009,
0
] | [
1015,
38
] | python | en | ['en', 'en', 'en'] | True |
test_order_by_accessibility | (list_url, api_client, resource_with_accessibility_data,
resource_with_accessibility_data2, accessibility_viewpoint_wheelchair,
accessibility_viewpoint_hearing) | resource_with_accessibility_data should rank higher in wheelchair accessibility
resource_with_accessibility_data2 should rank higher in hearing accessibility
| resource_with_accessibility_data should rank higher in wheelchair accessibility
resource_with_accessibility_data2 should rank higher in hearing accessibility
| def test_order_by_accessibility(list_url, api_client, resource_with_accessibility_data,
resource_with_accessibility_data2, accessibility_viewpoint_wheelchair,
accessibility_viewpoint_hearing):
""" resource_with_accessibility_data should rank higher in ... | [
"def",
"test_order_by_accessibility",
"(",
"list_url",
",",
"api_client",
",",
"resource_with_accessibility_data",
",",
"resource_with_accessibility_data2",
",",
"accessibility_viewpoint_wheelchair",
",",
"accessibility_viewpoint_hearing",
")",
":",
"response",
"=",
"api_client",... | [
1019,
0
] | [
1041,
96
] | python | en | ['en', 'en', 'en'] | True |
test_order_by_accessibility_multiple_viewpoints | (
list_url, api_client, resource_with_accessibility_data,
resource_with_accessibility_data4, accessibility_viewpoint_wheelchair,
accessibility_viewpoint_hearing) | resource_with_accessibility_data4 should rank higher as it is accessible from both viewpoints
| resource_with_accessibility_data4 should rank higher as it is accessible from both viewpoints
| def test_order_by_accessibility_multiple_viewpoints(
list_url, api_client, resource_with_accessibility_data,
resource_with_accessibility_data4, accessibility_viewpoint_wheelchair,
accessibility_viewpoint_hearing):
""" resource_with_accessibility_data4 should rank higher as it is accessible f... | [
"def",
"test_order_by_accessibility_multiple_viewpoints",
"(",
"list_url",
",",
"api_client",
",",
"resource_with_accessibility_data",
",",
"resource_with_accessibility_data4",
",",
"accessibility_viewpoint_wheelchair",
",",
"accessibility_viewpoint_hearing",
")",
":",
"response",
... | [
1045,
0
] | [
1083,
97
] | python | en | ['en', 'en', 'en'] | True |
test_order_by_accessibility_inaccessible_unit | (list_url, api_client, resource_with_accessibility_data,
resource_with_accessibility_data3,
accessibility_viewpoint_wheelchair) | resource_with_accessibility_data should rank higher in wheelchair accessibility.
resource_with_accessibility_data3 is wheelchair accessible, but
resource_with_accessibility_data3.unit is not wheelchair accessible
| resource_with_accessibility_data should rank higher in wheelchair accessibility.
resource_with_accessibility_data3 is wheelchair accessible, but
resource_with_accessibility_data3.unit is not wheelchair accessible
| def test_order_by_accessibility_inaccessible_unit(list_url, api_client, resource_with_accessibility_data,
resource_with_accessibility_data3,
accessibility_viewpoint_wheelchair):
""" resource_with_accessibility_data s... | [
"def",
"test_order_by_accessibility_inaccessible_unit",
"(",
"list_url",
",",
"api_client",
",",
"resource_with_accessibility_data",
",",
"resource_with_accessibility_data3",
",",
"accessibility_viewpoint_wheelchair",
")",
":",
"response",
"=",
"api_client",
".",
"get",
"(",
... | [
1087,
0
] | [
1101,
97
] | python | en | ['en', 'en', 'en'] | True |
test_resource_with_accessibility_data_no_include | (api_client, resource_with_accessibility_data, detail_url) | Resource endpoint should not include accessibility data when not explicitly included | Resource endpoint should not include accessibility data when not explicitly included | def test_resource_with_accessibility_data_no_include(api_client, resource_with_accessibility_data, detail_url):
""" Resource endpoint should not include accessibility data when not explicitly included """
response = api_client.get(detail_url)
assert response.status_code == 200
assert 'accessibility_summ... | [
"def",
"test_resource_with_accessibility_data_no_include",
"(",
"api_client",
",",
"resource_with_accessibility_data",
",",
"detail_url",
")",
":",
"response",
"=",
"api_client",
".",
"get",
"(",
"detail_url",
")",
"assert",
"response",
".",
"status_code",
"==",
"200",
... | [
1105,
0
] | [
1109,
57
] | python | en | ['en', 'en', 'en'] | True |
test_resource_with_accessibility_data | (api_client, resource_with_accessibility_data, detail_url) | Resource endpoint should include accessibility data when include-parameter is used | Resource endpoint should include accessibility data when include-parameter is used | def test_resource_with_accessibility_data(api_client, resource_with_accessibility_data, detail_url):
""" Resource endpoint should include accessibility data when include-parameter is used """
url = "{}?include=accessibility_summaries".format(detail_url)
response = api_client.get(url)
assert response.sta... | [
"def",
"test_resource_with_accessibility_data",
"(",
"api_client",
",",
"resource_with_accessibility_data",
",",
"detail_url",
")",
":",
"url",
"=",
"\"{}?include=accessibility_summaries\"",
".",
"format",
"(",
"detail_url",
")",
"response",
"=",
"api_client",
".",
"get",... | [
1113,
0
] | [
1122,
53
] | python | en | ['en', 'en', 'en'] | True |
test_query_counts | (user_api_client, staff_api_client, list_url, django_assert_max_num_queries) |
Test that DB query count is less than allowed
|
Test that DB query count is less than allowed
| def test_query_counts(user_api_client, staff_api_client, list_url, django_assert_max_num_queries):
"""
Test that DB query count is less than allowed
"""
with django_assert_max_num_queries(MAX_QUERIES):
user_api_client.get(list_url)
with django_assert_max_num_queries(MAX_QUERIES):
st... | [
"def",
"test_query_counts",
"(",
"user_api_client",
",",
"staff_api_client",
",",
"list_url",
",",
"django_assert_max_num_queries",
")",
":",
"with",
"django_assert_max_num_queries",
"(",
"MAX_QUERIES",
")",
":",
"user_api_client",
".",
"get",
"(",
"list_url",
")",
"w... | [
1126,
0
] | [
1134,
38
] | python | en | ['en', 'error', 'th'] | False |
always_want | (msg_type: str) |
This function is used as a helper in
fetch_initial_state_data, when the user passes
in None for event_types, and we want to fetch
info for every event type. Defining this at module
level makes it easier to mock.
|
This function is used as a helper in
fetch_initial_state_data, when the user passes
in None for event_types, and we want to fetch
info for every event type. Defining this at module
level makes it easier to mock.
| def always_want(msg_type: str) -> bool:
"""
This function is used as a helper in
fetch_initial_state_data, when the user passes
in None for event_types, and we want to fetch
info for every event type. Defining this at module
level makes it easier to mock.
"""
return True | [
"def",
"always_want",
"(",
"msg_type",
":",
"str",
")",
"->",
"bool",
":",
"return",
"True"
] | [
76,
0
] | [
84,
15
] | python | en | ['en', 'error', 'th'] | False |
fetch_initial_state_data | (
user_profile: Optional[UserProfile],
*,
realm: Optional[Realm] = None,
event_types: Optional[Iterable[str]] = None,
queue_id: Optional[str] = "",
client_gravatar: bool = False,
user_avatar_url_field_optional: bool = False,
slim_presence: bool = False,
include_subscribers: bool = Tr... | When `event_types` is None, fetches the core data powering the
webapp's `page_params` and `/api/v1/register` (for mobile/terminal
apps). Can also fetch a subset as determined by `event_types`.
The user_profile=None code path is used for logged-out public
access to streams with is_web_public=True.
... | When `event_types` is None, fetches the core data powering the
webapp's `page_params` and `/api/v1/register` (for mobile/terminal
apps). Can also fetch a subset as determined by `event_types`. | def fetch_initial_state_data(
user_profile: Optional[UserProfile],
*,
realm: Optional[Realm] = None,
event_types: Optional[Iterable[str]] = None,
queue_id: Optional[str] = "",
client_gravatar: bool = False,
user_avatar_url_field_optional: bool = False,
slim_presence: bool = False,
in... | [
"def",
"fetch_initial_state_data",
"(",
"user_profile",
":",
"Optional",
"[",
"UserProfile",
"]",
",",
"*",
",",
"realm",
":",
"Optional",
"[",
"Realm",
"]",
"=",
"None",
",",
"event_types",
":",
"Optional",
"[",
"Iterable",
"[",
"str",
"]",
"]",
"=",
"N... | [
87,
0
] | [
469,
16
] | python | en | ['en', 'en', 'en'] | True |
post_process_state | (
user_profile: Optional[UserProfile], ret: Dict[str, Any], notification_settings_null: bool
) |
NOTE:
Below is an example of post-processing initial state data AFTER we
apply events. For large payloads like `unread_msgs`, it's helpful
to have an intermediate data structure that is easy to manipulate
with O(1)-type operations as we apply events.
Then, only at the end, we put it in the f... |
NOTE: | def post_process_state(
user_profile: Optional[UserProfile], ret: Dict[str, Any], notification_settings_null: bool
) -> None:
"""
NOTE:
Below is an example of post-processing initial state data AFTER we
apply events. For large payloads like `unread_msgs`, it's helpful
to have an intermediate d... | [
"def",
"post_process_state",
"(",
"user_profile",
":",
"Optional",
"[",
"UserProfile",
"]",
",",
"ret",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"notification_settings_null",
":",
"bool",
")",
"->",
"None",
":",
"if",
"\"raw_unread_msgs\"",
"in",
"ret"... | [
1147,
0
] | [
1207,
13
] | python | en | ['en', 'error', 'th'] | False |
_check_link_requires_python | (
link, # type: Link
version_info, # type: Tuple[int, int, int]
ignore_requires_python=False, # type: bool
) |
Return whether the given Python version is compatible with a link's
"Requires-Python" value.
:param version_info: A 3-tuple of ints representing the Python
major-minor-micro version to check.
:param ignore_requires_python: Whether to ignore the "Requires-Python"
value if the given Pyth... |
Return whether the given Python version is compatible with a link's
"Requires-Python" value. | def _check_link_requires_python(
link, # type: Link
version_info, # type: Tuple[int, int, int]
ignore_requires_python=False, # type: bool
):
# type: (...) -> bool
"""
Return whether the given Python version is compatible with a link's
"Requires-Python" value.
:param version_info: A 3... | [
"def",
"_check_link_requires_python",
"(",
"link",
",",
"# type: Link",
"version_info",
",",
"# type: Tuple[int, int, int]",
"ignore_requires_python",
"=",
"False",
",",
"# type: bool",
")",
":",
"# type: (...) -> bool",
"try",
":",
"is_compatible",
"=",
"check_requires_pyt... | [
60,
0
] | [
100,
15
] | python | en | ['en', 'error', 'th'] | False |
filter_unallowed_hashes | (
candidates, # type: List[InstallationCandidate]
hashes, # type: Hashes
project_name, # type: str
) |
Filter out candidates whose hashes aren't allowed, and return a new
list of candidates.
If at least one candidate has an allowed hash, then all candidates with
either an allowed hash or no hash specified are returned. Otherwise,
the given candidates are returned.
Including the candidates wit... |
Filter out candidates whose hashes aren't allowed, and return a new
list of candidates. | def filter_unallowed_hashes(
candidates, # type: List[InstallationCandidate]
hashes, # type: Hashes
project_name, # type: str
):
# type: (...) -> List[InstallationCandidate]
"""
Filter out candidates whose hashes aren't allowed, and return a new
list of candidates.
If at leas... | [
"def",
"filter_unallowed_hashes",
"(",
"candidates",
",",
"# type: List[InstallationCandidate]",
"hashes",
",",
"# type: Hashes",
"project_name",
",",
"# type: str",
")",
":",
"# type: (...) -> List[InstallationCandidate]",
"if",
"not",
"hashes",
":",
"logger",
".",
"debug"... | [
244,
0
] | [
316,
19
] | python | en | ['en', 'error', 'th'] | False |
_find_name_version_sep | (fragment, canonical_name) | Find the separator's index based on the package's canonical name.
:param fragment: A <package>+<version> filename "fragment" (stem) or
egg fragment.
:param canonical_name: The package's canonical name.
This function is needed since the canonicalized name does not necessarily
have the same leng... | Find the separator's index based on the package's canonical name. | def _find_name_version_sep(fragment, canonical_name):
# type: (str, str) -> int
"""Find the separator's index based on the package's canonical name.
:param fragment: A <package>+<version> filename "fragment" (stem) or
egg fragment.
:param canonical_name: The package's canonical name.
This ... | [
"def",
"_find_name_version_sep",
"(",
"fragment",
",",
"canonical_name",
")",
":",
"# type: (str, str) -> int",
"# Project name and version must be separated by one single dash. Find all",
"# occurrences of dashes; if the string in front of it matches the canonical",
"# name, this is the one s... | [
972,
0
] | [
996,
77
] | python | en | ['en', 'en', 'en'] | True |
_extract_version_from_fragment | (fragment, canonical_name) | Parse the version string from a <package>+<version> filename
"fragment" (stem) or egg fragment.
:param fragment: The string to parse. E.g. foo-2.1
:param canonical_name: The canonicalized name of the package this
belongs to.
| Parse the version string from a <package>+<version> filename
"fragment" (stem) or egg fragment. | def _extract_version_from_fragment(fragment, canonical_name):
# type: (str, str) -> Optional[str]
"""Parse the version string from a <package>+<version> filename
"fragment" (stem) or egg fragment.
:param fragment: The string to parse. E.g. foo-2.1
:param canonical_name: The canonicalized name of th... | [
"def",
"_extract_version_from_fragment",
"(",
"fragment",
",",
"canonical_name",
")",
":",
"# type: (str, str) -> Optional[str]",
"try",
":",
"version_start",
"=",
"_find_name_version_sep",
"(",
"fragment",
",",
"canonical_name",
")",
"+",
"1",
"except",
"ValueError",
"... | [
999,
0
] | [
1015,
18
] | python | en | ['en', 'en', 'en'] | True |
LinkEvaluator.__init__ | (
self,
project_name, # type: str
canonical_name, # type: str
formats, # type: FrozenSet[str]
target_python, # type: TargetPython
allow_yanked, # type: bool
ignore_requires_python=None, # type: Optional[bool]
) |
:param project_name: The user supplied package name.
:param canonical_name: The canonical package name.
:param formats: The formats allowed for this package. Should be a set
with 'binary' or 'source' or both in it.
:param target_python: The target Python interpreter to use w... |
:param project_name: The user supplied package name.
:param canonical_name: The canonical package name.
:param formats: The formats allowed for this package. Should be a set
with 'binary' or 'source' or both in it.
:param target_python: The target Python interpreter to use w... | def __init__(
self,
project_name, # type: str
canonical_name, # type: str
formats, # type: FrozenSet[str]
target_python, # type: TargetPython
allow_yanked, # type: bool
ignore_requires_python=None, # type: Optional[bool]
):
# type: (.... | [
"def",
"__init__",
"(",
"self",
",",
"project_name",
",",
"# type: str",
"canonical_name",
",",
"# type: str",
"formats",
",",
"# type: FrozenSet[str]",
"target_python",
",",
"# type: TargetPython",
"allow_yanked",
",",
"# type: bool",
"ignore_requires_python",
"=",
"None... | [
115,
4
] | [
151,
40
] | python | en | ['en', 'error', 'th'] | False |
LinkEvaluator.evaluate_link | (self, link) |
Determine whether a link is a candidate for installation.
:return: A tuple (is_candidate, result), where `result` is (1) a
version string if `is_candidate` is True, and (2) if
`is_candidate` is False, an optional string to log the reason
the link fails to qualify.
... |
Determine whether a link is a candidate for installation. | def evaluate_link(self, link):
# type: (Link) -> Tuple[bool, Optional[Text]]
"""
Determine whether a link is a candidate for installation.
:return: A tuple (is_candidate, result), where `result` is (1) a
version string if `is_candidate` is True, and (2) if
`is_ca... | [
"def",
"evaluate_link",
"(",
"self",
",",
"link",
")",
":",
"# type: (Link) -> Tuple[bool, Optional[Text]]",
"version",
"=",
"None",
"if",
"link",
".",
"is_yanked",
"and",
"not",
"self",
".",
"_allow_yanked",
":",
"reason",
"=",
"link",
".",
"yanked_reason",
"or... | [
153,
4
] | [
241,
30
] | python | en | ['en', 'error', 'th'] | False |
CandidatePreferences.__init__ | (
self,
prefer_binary=False, # type: bool
allow_all_prereleases=False, # type: bool
) |
:param allow_all_prereleases: Whether to allow all pre-releases.
|
:param allow_all_prereleases: Whether to allow all pre-releases.
| def __init__(
self,
prefer_binary=False, # type: bool
allow_all_prereleases=False, # type: bool
):
# type: (...) -> None
"""
:param allow_all_prereleases: Whether to allow all pre-releases.
"""
self.allow_all_prereleases = allow_all_prereleases
... | [
"def",
"__init__",
"(",
"self",
",",
"prefer_binary",
"=",
"False",
",",
"# type: bool",
"allow_all_prereleases",
"=",
"False",
",",
"# type: bool",
")",
":",
"# type: (...) -> None",
"self",
".",
"allow_all_prereleases",
"=",
"allow_all_prereleases",
"self",
".",
"... | [
326,
4
] | [
336,
42
] | python | en | ['en', 'error', 'th'] | False |
BestCandidateResult.__init__ | (
self,
candidates, # type: List[InstallationCandidate]
applicable_candidates, # type: List[InstallationCandidate]
best_candidate, # type: Optional[InstallationCandidate]
) |
:param candidates: A sequence of all available candidates found.
:param applicable_candidates: The applicable candidates.
:param best_candidate: The most preferred candidate found, or None
if no applicable candidates were found.
|
:param candidates: A sequence of all available candidates found.
:param applicable_candidates: The applicable candidates.
:param best_candidate: The most preferred candidate found, or None
if no applicable candidates were found.
| def __init__(
self,
candidates, # type: List[InstallationCandidate]
applicable_candidates, # type: List[InstallationCandidate]
best_candidate, # type: Optional[InstallationCandidate]
):
# type: (...) -> None
"""
:param candidates: A sequen... | [
"def",
"__init__",
"(",
"self",
",",
"candidates",
",",
"# type: List[InstallationCandidate]",
"applicable_candidates",
",",
"# type: List[InstallationCandidate]",
"best_candidate",
",",
"# type: Optional[InstallationCandidate]",
")",
":",
"# type: (...) -> None",
"assert",
"set"... | [
346,
4
] | [
369,
44
] | python | en | ['en', 'error', 'th'] | False |
BestCandidateResult.iter_all | (self) | Iterate through all candidates.
| Iterate through all candidates.
| def iter_all(self):
# type: () -> Iterable[InstallationCandidate]
"""Iterate through all candidates.
"""
return iter(self._candidates) | [
"def",
"iter_all",
"(",
"self",
")",
":",
"# type: () -> Iterable[InstallationCandidate]",
"return",
"iter",
"(",
"self",
".",
"_candidates",
")"
] | [
371,
4
] | [
375,
37
] | python | en | ['en', 'en', 'en'] | True |
BestCandidateResult.iter_applicable | (self) | Iterate through the applicable candidates.
| Iterate through the applicable candidates.
| def iter_applicable(self):
# type: () -> Iterable[InstallationCandidate]
"""Iterate through the applicable candidates.
"""
return iter(self._applicable_candidates) | [
"def",
"iter_applicable",
"(",
"self",
")",
":",
"# type: () -> Iterable[InstallationCandidate]",
"return",
"iter",
"(",
"self",
".",
"_applicable_candidates",
")"
] | [
377,
4
] | [
381,
48
] | python | en | ['en', 'en', 'en'] | True |
CandidateEvaluator.create | (
cls,
project_name, # type: str
target_python=None, # type: Optional[TargetPython]
prefer_binary=False, # type: bool
allow_all_prereleases=False, # type: bool
specifier=None, # type: Optional[specifiers.BaseSpecifier]
hashes=None, # typ... | Create a CandidateEvaluator object.
:param target_python: The target Python interpreter to use when
checking compatibility. If None (the default), a TargetPython
object will be constructed from the running Python.
:param specifier: An optional object implementing `filter`
... | Create a CandidateEvaluator object. | def create(
cls,
project_name, # type: str
target_python=None, # type: Optional[TargetPython]
prefer_binary=False, # type: bool
allow_all_prereleases=False, # type: bool
specifier=None, # type: Optional[specifiers.BaseSpecifier]
hashes=None, ... | [
"def",
"create",
"(",
"cls",
",",
"project_name",
",",
"# type: str",
"target_python",
"=",
"None",
",",
"# type: Optional[TargetPython]",
"prefer_binary",
"=",
"False",
",",
"# type: bool",
"allow_all_prereleases",
"=",
"False",
",",
"# type: bool",
"specifier",
"=",... | [
392,
4
] | [
426,
9
] | python | en | ['pt', 'en', 'en'] | True |
CandidateEvaluator.__init__ | (
self,
project_name, # type: str
supported_tags, # type: List[Tag]
specifier, # type: specifiers.BaseSpecifier
prefer_binary=False, # type: bool
allow_all_prereleases=False, # type: bool
hashes=None, # type: Optional[Ha... |
:param supported_tags: The PEP 425 tags supported by the target
Python in order of preference (most preferred first).
|
:param supported_tags: The PEP 425 tags supported by the target
Python in order of preference (most preferred first).
| def __init__(
self,
project_name, # type: str
supported_tags, # type: List[Tag]
specifier, # type: specifiers.BaseSpecifier
prefer_binary=False, # type: bool
allow_all_prereleases=False, # type: bool
hashes=None, # type:... | [
"def",
"__init__",
"(",
"self",
",",
"project_name",
",",
"# type: str",
"supported_tags",
",",
"# type: List[Tag]",
"specifier",
",",
"# type: specifiers.BaseSpecifier",
"prefer_binary",
"=",
"False",
",",
"# type: bool",
"allow_all_prereleases",
"=",
"False",
",",
"# ... | [
428,
4
] | [
447,
45
] | python | en | ['en', 'error', 'th'] | False |
CandidateEvaluator.get_applicable_candidates | (
self,
candidates, # type: List[InstallationCandidate]
) |
Return the applicable candidates from a list of candidates.
|
Return the applicable candidates from a list of candidates.
| def get_applicable_candidates(
self,
candidates, # type: List[InstallationCandidate]
):
# type: (...) -> List[InstallationCandidate]
"""
Return the applicable candidates from a list of candidates.
"""
# Using None infers from the specifier instead.
al... | [
"def",
"get_applicable_candidates",
"(",
"self",
",",
"candidates",
",",
"# type: List[InstallationCandidate]",
")",
":",
"# type: (...) -> List[InstallationCandidate]",
"# Using None infers from the specifier instead.",
"allow_prereleases",
"=",
"self",
".",
"_allow_all_prereleases"... | [
449,
4
] | [
485,
73
] | python | en | ['en', 'error', 'th'] | False |
CandidateEvaluator._sort_key | (self, candidate) |
Function to pass as the `key` argument to a call to sorted() to sort
InstallationCandidates by preference.
Returns a tuple such that tuples sorting as greater using Python's
default comparison operator are more preferred.
The preference is as follows:
First and foremo... |
Function to pass as the `key` argument to a call to sorted() to sort
InstallationCandidates by preference. | def _sort_key(self, candidate):
# type: (InstallationCandidate) -> CandidateSortingKey
"""
Function to pass as the `key` argument to a call to sorted() to sort
InstallationCandidates by preference.
Returns a tuple such that tuples sorting as greater using Python's
defaul... | [
"def",
"_sort_key",
"(",
"self",
",",
"candidate",
")",
":",
"# type: (InstallationCandidate) -> CandidateSortingKey",
"valid_tags",
"=",
"self",
".",
"_supported_tags",
"support_num",
"=",
"len",
"(",
"valid_tags",
")",
"build_tag",
"=",
"(",
")",
"# type: BuildTag",... | [
487,
4
] | [
545,
9
] | python | en | ['en', 'error', 'th'] | False |
CandidateEvaluator.sort_best_candidate | (
self,
candidates, # type: List[InstallationCandidate]
) |
Return the best candidate per the instance's sort order, or None if
no candidate is acceptable.
|
Return the best candidate per the instance's sort order, or None if
no candidate is acceptable.
| def sort_best_candidate(
self,
candidates, # type: List[InstallationCandidate]
):
# type: (...) -> Optional[InstallationCandidate]
"""
Return the best candidate per the instance's sort order, or None if
no candidate is acceptable.
"""
if not candida... | [
"def",
"sort_best_candidate",
"(",
"self",
",",
"candidates",
",",
"# type: List[InstallationCandidate]",
")",
":",
"# type: (...) -> Optional[InstallationCandidate]",
"if",
"not",
"candidates",
":",
"return",
"None",
"best_candidate",
"=",
"max",
"(",
"candidates",
",",
... | [
547,
4
] | [
575,
29
] | python | en | ['en', 'error', 'th'] | False |
CandidateEvaluator.compute_best_candidate | (
self,
candidates, # type: List[InstallationCandidate]
) |
Compute and return a `BestCandidateResult` instance.
|
Compute and return a `BestCandidateResult` instance.
| def compute_best_candidate(
self,
candidates, # type: List[InstallationCandidate]
):
# type: (...) -> BestCandidateResult
"""
Compute and return a `BestCandidateResult` instance.
"""
applicable_candidates = self.get_applicable_candidates(candidates)
... | [
"def",
"compute_best_candidate",
"(",
"self",
",",
"candidates",
",",
"# type: List[InstallationCandidate]",
")",
":",
"# type: (...) -> BestCandidateResult",
"applicable_candidates",
"=",
"self",
".",
"get_applicable_candidates",
"(",
"candidates",
")",
"best_candidate",
"="... | [
577,
4
] | [
593,
9
] | python | en | ['en', 'error', 'th'] | False |
PackageFinder.__init__ | (
self,
link_collector, # type: LinkCollector
target_python, # type: TargetPython
allow_yanked, # type: bool
format_control=None, # type: Optional[FormatControl]
candidate_prefs=None, # type: CandidatePreferences
ignore_requires_pytho... |
This constructor is primarily meant to be used by the create() class
method and from tests.
:param format_control: A FormatControl object, used to control
the selection of source packages / binary packages when consulting
the index and links.
:param candidate_pr... |
This constructor is primarily meant to be used by the create() class
method and from tests. | def __init__(
self,
link_collector, # type: LinkCollector
target_python, # type: TargetPython
allow_yanked, # type: bool
format_control=None, # type: Optional[FormatControl]
candidate_prefs=None, # type: CandidatePreferences
ignore_re... | [
"def",
"__init__",
"(",
"self",
",",
"link_collector",
",",
"# type: LinkCollector",
"target_python",
",",
"# type: TargetPython",
"allow_yanked",
",",
"# type: bool",
"format_control",
"=",
"None",
",",
"# type: Optional[FormatControl]",
"candidate_prefs",
"=",
"None",
"... | [
603,
4
] | [
637,
34
] | python | en | ['en', 'error', 'th'] | False |
PackageFinder.create | (
cls,
link_collector, # type: LinkCollector
selection_prefs, # type: SelectionPreferences
target_python=None, # type: Optional[TargetPython]
) | Create a PackageFinder.
:param selection_prefs: The candidate selection preferences, as a
SelectionPreferences object.
:param target_python: The target Python interpreter to use when
checking compatibility. If None (the default), a TargetPython
object will be constru... | Create a PackageFinder. | def create(
cls,
link_collector, # type: LinkCollector
selection_prefs, # type: SelectionPreferences
target_python=None, # type: Optional[TargetPython]
):
# type: (...) -> PackageFinder
"""Create a PackageFinder.
:param selection_prefs: The candidat... | [
"def",
"create",
"(",
"cls",
",",
"link_collector",
",",
"# type: LinkCollector",
"selection_prefs",
",",
"# type: SelectionPreferences",
"target_python",
"=",
"None",
",",
"# type: Optional[TargetPython]",
")",
":",
"# type: (...) -> PackageFinder",
"if",
"target_python",
... | [
644,
4
] | [
674,
9
] | python | en | ['en', 'af', 'en'] | True |
PackageFinder._sort_links | (self, links) |
Returns elements of links in order, non-egg links first, egg links
second, while eliminating duplicates
|
Returns elements of links in order, non-egg links first, egg links
second, while eliminating duplicates
| def _sort_links(self, links):
# type: (Iterable[Link]) -> List[Link]
"""
Returns elements of links in order, non-egg links first, egg links
second, while eliminating duplicates
"""
eggs, no_eggs = [], []
seen = set() # type: Set[Link]
for link in links:
... | [
"def",
"_sort_links",
"(",
"self",
",",
"links",
")",
":",
"# type: (Iterable[Link]) -> List[Link]",
"eggs",
",",
"no_eggs",
"=",
"[",
"]",
",",
"[",
"]",
"seen",
"=",
"set",
"(",
")",
"# type: Set[Link]",
"for",
"link",
"in",
"links",
":",
"if",
"link",
... | [
725,
4
] | [
740,
29
] | python | en | ['en', 'error', 'th'] | False |
PackageFinder.get_install_candidate | (self, link_evaluator, link) |
If the link is a candidate for install, convert it to an
InstallationCandidate and return it. Otherwise, return None.
|
If the link is a candidate for install, convert it to an
InstallationCandidate and return it. Otherwise, return None.
| def get_install_candidate(self, link_evaluator, link):
# type: (LinkEvaluator, Link) -> Optional[InstallationCandidate]
"""
If the link is a candidate for install, convert it to an
InstallationCandidate and return it. Otherwise, return None.
"""
is_candidate, result = lin... | [
"def",
"get_install_candidate",
"(",
"self",
",",
"link_evaluator",
",",
"link",
")",
":",
"# type: (LinkEvaluator, Link) -> Optional[InstallationCandidate]",
"is_candidate",
",",
"result",
"=",
"link_evaluator",
".",
"evaluate_link",
"(",
"link",
")",
"if",
"not",
"is_... | [
753,
4
] | [
771,
9
] | python | en | ['en', 'error', 'th'] | False |
PackageFinder.evaluate_links | (self, link_evaluator, links) |
Convert links that are candidates to InstallationCandidate objects.
|
Convert links that are candidates to InstallationCandidate objects.
| def evaluate_links(self, link_evaluator, links):
# type: (LinkEvaluator, Iterable[Link]) -> List[InstallationCandidate]
"""
Convert links that are candidates to InstallationCandidate objects.
"""
candidates = []
for link in self._sort_links(links):
candidate =... | [
"def",
"evaluate_links",
"(",
"self",
",",
"link_evaluator",
",",
"links",
")",
":",
"# type: (LinkEvaluator, Iterable[Link]) -> List[InstallationCandidate]",
"candidates",
"=",
"[",
"]",
"for",
"link",
"in",
"self",
".",
"_sort_links",
"(",
"links",
")",
":",
"cand... | [
773,
4
] | [
784,
25
] | python | en | ['en', 'error', 'th'] | False |
PackageFinder.find_all_candidates | (self, project_name) | Find all available InstallationCandidate for project_name
This checks index_urls and find_links.
All versions found are returned as an InstallationCandidate list.
See LinkEvaluator.evaluate_link() for details on which files
are accepted.
| Find all available InstallationCandidate for project_name | def find_all_candidates(self, project_name):
# type: (str) -> List[InstallationCandidate]
"""Find all available InstallationCandidate for project_name
This checks index_urls and find_links.
All versions found are returned as an InstallationCandidate list.
See LinkEvaluator.eval... | [
"def",
"find_all_candidates",
"(",
"self",
",",
"project_name",
")",
":",
"# type: (str) -> List[InstallationCandidate]",
"collected_links",
"=",
"self",
".",
"_link_collector",
".",
"collect_links",
"(",
"project_name",
")",
"link_evaluator",
"=",
"self",
".",
"make_li... | [
805,
4
] | [
846,
66
] | python | en | ['en', 'en', 'en'] | True |
PackageFinder.make_candidate_evaluator | (
self,
project_name, # type: str
specifier=None, # type: Optional[specifiers.BaseSpecifier]
hashes=None, # type: Optional[Hashes]
) | Create a CandidateEvaluator object to use.
| Create a CandidateEvaluator object to use.
| def make_candidate_evaluator(
self,
project_name, # type: str
specifier=None, # type: Optional[specifiers.BaseSpecifier]
hashes=None, # type: Optional[Hashes]
):
# type: (...) -> CandidateEvaluator
"""Create a CandidateEvaluator object to use.
"""
... | [
"def",
"make_candidate_evaluator",
"(",
"self",
",",
"project_name",
",",
"# type: str",
"specifier",
"=",
"None",
",",
"# type: Optional[specifiers.BaseSpecifier]",
"hashes",
"=",
"None",
",",
"# type: Optional[Hashes]",
")",
":",
"# type: (...) -> CandidateEvaluator",
"ca... | [
848,
4
] | [
865,
9
] | python | en | ['en', 'en', 'en'] | True |
PackageFinder.find_best_candidate | (
self,
project_name, # type: str
specifier=None, # type: Optional[specifiers.BaseSpecifier]
hashes=None, # type: Optional[Hashes]
) | Find matches for the given project and specifier.
:param specifier: An optional object implementing `filter`
(e.g. `packaging.specifiers.SpecifierSet`) to filter applicable
versions.
:return: A `BestCandidateResult` instance.
| Find matches for the given project and specifier. | def find_best_candidate(
self,
project_name, # type: str
specifier=None, # type: Optional[specifiers.BaseSpecifier]
hashes=None, # type: Optional[Hashes]
):
# type: (...) -> BestCandidateResult
"""Find matches for the given project and specifier.
... | [
"def",
"find_best_candidate",
"(",
"self",
",",
"project_name",
",",
"# type: str",
"specifier",
"=",
"None",
",",
"# type: Optional[specifiers.BaseSpecifier]",
"hashes",
"=",
"None",
",",
"# type: Optional[Hashes]",
")",
":",
"# type: (...) -> BestCandidateResult",
"candid... | [
867,
4
] | [
888,
69
] | python | en | ['en', 'en', 'en'] | True |
PackageFinder.find_requirement | (self, req, upgrade) | Try to find a Link matching req
Expects req, an InstallRequirement and upgrade, a boolean
Returns a Link if found,
Raises DistributionNotFound or BestVersionAlreadyInstalled otherwise
| Try to find a Link matching req | def find_requirement(self, req, upgrade):
# type: (InstallRequirement, bool) -> Optional[Link]
"""Try to find a Link matching req
Expects req, an InstallRequirement and upgrade, a boolean
Returns a Link if found,
Raises DistributionNotFound or BestVersionAlreadyInstalled otherwi... | [
"def",
"find_requirement",
"(",
"self",
",",
"req",
",",
"upgrade",
")",
":",
"# type: (InstallRequirement, bool) -> Optional[Link]",
"hashes",
"=",
"req",
".",
"hashes",
"(",
"trust_internet",
"=",
"False",
")",
"best_candidate_result",
"=",
"self",
".",
"find_best... | [
890,
4
] | [
969,
34
] | python | en | ['en', 'en', 'en'] | True |
property_name | (property: str, index: int) | The Freshdesk API is currently pretty broken: statuses are customizable
but the API will only tell you the number associated with the status, not
the name. While we engage the Freshdesk developers about exposing this
information through the API, since only FlightCar uses this integration,
hardcode their... | The Freshdesk API is currently pretty broken: statuses are customizable
but the API will only tell you the number associated with the status, not
the name. While we engage the Freshdesk developers about exposing this
information through the API, since only FlightCar uses this integration,
hardcode their... | def property_name(property: str, index: int) -> str:
"""The Freshdesk API is currently pretty broken: statuses are customizable
but the API will only tell you the number associated with the status, not
the name. While we engage the Freshdesk developers about exposing this
information through the API, si... | [
"def",
"property_name",
"(",
"property",
":",
"str",
",",
"index",
":",
"int",
")",
"->",
"str",
":",
"statuses",
"=",
"[",
"\"\"",
",",
"\"\"",
",",
"\"Open\"",
",",
"\"Pending\"",
",",
"\"Resolved\"",
",",
"\"Closed\"",
",",
"\"Waiting on Customer\"",
",... | [
44,
0
] | [
70,
15
] | python | en | ['en', 'en', 'en'] | True |
parse_freshdesk_event | (event_string: str) | These are always of the form "{ticket_action:created}" or
"{status:{from:4,to:6}}". Note the lack of string quoting: this isn't
valid JSON so we have to parse it ourselves.
| These are always of the form "{ticket_action:created}" or
"{status:{from:4,to:6}}". Note the lack of string quoting: this isn't
valid JSON so we have to parse it ourselves.
| def parse_freshdesk_event(event_string: str) -> List[str]:
"""These are always of the form "{ticket_action:created}" or
"{status:{from:4,to:6}}". Note the lack of string quoting: this isn't
valid JSON so we have to parse it ourselves.
"""
data = event_string.replace("{", "").replace("}", "").replace... | [
"def",
"parse_freshdesk_event",
"(",
"event_string",
":",
"str",
")",
"->",
"List",
"[",
"str",
"]",
":",
"data",
"=",
"event_string",
".",
"replace",
"(",
"\"{\"",
",",
"\"\"",
")",
".",
"replace",
"(",
"\"}\"",
",",
"\"\"",
")",
".",
"replace",
"(",
... | [
73,
0
] | [
92,
9
] | python | en | ['en', 'en', 'en'] | True |
format_freshdesk_note_message | (ticket: TicketDict, event_info: List[str]) | There are public (visible to customers) and private note types. | There are public (visible to customers) and private note types. | def format_freshdesk_note_message(ticket: TicketDict, event_info: List[str]) -> str:
"""There are public (visible to customers) and private note types."""
note_type = event_info[1]
content = NOTE_TEMPLATE.format(
name=ticket.requester_name,
email=ticket.requester_email,
note_type=not... | [
"def",
"format_freshdesk_note_message",
"(",
"ticket",
":",
"TicketDict",
",",
"event_info",
":",
"List",
"[",
"str",
"]",
")",
"->",
"str",
":",
"note_type",
"=",
"event_info",
"[",
"1",
"]",
"content",
"=",
"NOTE_TEMPLATE",
".",
"format",
"(",
"name",
"=... | [
95,
0
] | [
106,
18
] | python | en | ['en', 'en', 'en'] | True |
format_freshdesk_property_change_message | (ticket: TicketDict, event_info: List[str]) | Freshdesk will only tell us the first event to match our webhook
configuration, so if we change multiple properties, we only get the before
and after data for the first one.
| Freshdesk will only tell us the first event to match our webhook
configuration, so if we change multiple properties, we only get the before
and after data for the first one.
| def format_freshdesk_property_change_message(ticket: TicketDict, event_info: List[str]) -> str:
"""Freshdesk will only tell us the first event to match our webhook
configuration, so if we change multiple properties, we only get the before
and after data for the first one.
"""
content = PROPERTY_CHAN... | [
"def",
"format_freshdesk_property_change_message",
"(",
"ticket",
":",
"TicketDict",
",",
"event_info",
":",
"List",
"[",
"str",
"]",
")",
"->",
"str",
":",
"content",
"=",
"PROPERTY_CHANGE_TEMPLATE",
".",
"format",
"(",
"name",
"=",
"ticket",
".",
"requester_na... | [
109,
0
] | [
124,
18
] | python | en | ['en', 'en', 'en'] | True |
format_freshdesk_ticket_creation_message | (ticket: TicketDict) | They send us the description as HTML. | They send us the description as HTML. | def format_freshdesk_ticket_creation_message(ticket: TicketDict) -> str:
"""They send us the description as HTML."""
cleaned_description = convert_html_to_markdown(ticket.description)
content = TICKET_CREATION_TEMPLATE.format(
name=ticket.requester_name,
email=ticket.requester_email,
... | [
"def",
"format_freshdesk_ticket_creation_message",
"(",
"ticket",
":",
"TicketDict",
")",
"->",
"str",
":",
"cleaned_description",
"=",
"convert_html_to_markdown",
"(",
"ticket",
".",
"description",
")",
"content",
"=",
"TICKET_CREATION_TEMPLATE",
".",
"format",
"(",
... | [
127,
0
] | [
141,
18
] | python | en | ['en', 'en', 'en'] | True |
merge_setting | (request_setting, session_setting, dict_class=OrderedDict) | Determines appropriate setting for a given request, taking into account
the explicit setting on that request, and the setting in the session. If a
setting is a dictionary, they will be merged together using `dict_class`
| Determines appropriate setting for a given request, taking into account
the explicit setting on that request, and the setting in the session. If a
setting is a dictionary, they will be merged together using `dict_class`
| def merge_setting(request_setting, session_setting, dict_class=OrderedDict):
"""Determines appropriate setting for a given request, taking into account
the explicit setting on that request, and the setting in the session. If a
setting is a dictionary, they will be merged together using `dict_class`
"""
... | [
"def",
"merge_setting",
"(",
"request_setting",
",",
"session_setting",
",",
"dict_class",
"=",
"OrderedDict",
")",
":",
"if",
"session_setting",
"is",
"None",
":",
"return",
"request_setting",
"if",
"request_setting",
"is",
"None",
":",
"return",
"session_setting",... | [
49,
0
] | [
77,
25
] | 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.