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
MessagePOSTTest.test_personal_message
(self)
Sending a personal message to a valid username is successful.
Sending a personal message to a valid username is successful.
def test_personal_message(self) -> None: """ Sending a personal message to a valid username is successful. """ user_profile = self.example_user("hamlet") self.login_user(user_profile) othello = self.example_user("othello") result = self.client_post( "/...
[ "def", "test_personal_message", "(", "self", ")", "->", "None", ":", "user_profile", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "self", ".", "login_user", "(", "user_profile", ")", "othello", "=", "self", ".", "example_user", "(", "\"othello\"",...
[ 504, 4 ]
[ 554, 80 ]
python
en
['en', 'error', 'th']
False
MessagePOSTTest.test_personal_message_by_id
(self)
Sending a personal message to a valid user ID is successful.
Sending a personal message to a valid user ID is successful.
def test_personal_message_by_id(self) -> None: """ Sending a personal message to a valid user ID is successful. """ self.login("hamlet") result = self.client_post( "/json/messages", { "type": "private", "content": "Test mess...
[ "def", "test_personal_message_by_id", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "result", "=", "self", ".", "client_post", "(", "\"/json/messages\"", ",", "{", "\"type\"", ":", "\"private\"", ",", "\"content\"", ":", ...
[ 556, 4 ]
[ 574, 85 ]
python
en
['en', 'error', 'th']
False
MessagePOSTTest.test_group_personal_message_by_id
(self)
Sending a personal message to a valid user ID is successful.
Sending a personal message to a valid user ID is successful.
def test_group_personal_message_by_id(self) -> None: """ Sending a personal message to a valid user ID is successful. """ self.login("hamlet") result = self.client_post( "/json/messages", { "type": "private", "content": "Tes...
[ "def", "test_group_personal_message_by_id", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "result", "=", "self", ".", "client_post", "(", "\"/json/messages\"", ",", "{", "\"type\"", ":", "\"private\"", ",", "\"content\"", "...
[ 576, 4 ]
[ 605, 9 ]
python
en
['en', 'error', 'th']
False
MessagePOSTTest.test_personal_message_copying_self
(self)
Sending a personal message to yourself plus another user is successful, and counts as a message just to that user.
Sending a personal message to yourself plus another user is successful, and counts as a message just to that user.
def test_personal_message_copying_self(self) -> None: """ Sending a personal message to yourself plus another user is successful, and counts as a message just to that user. """ hamlet = self.example_user("hamlet") othello = self.example_user("othello") self.login_...
[ "def", "test_personal_message_copying_self", "(", "self", ")", "->", "None", ":", "hamlet", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "othello", "=", "self", ".", "example_user", "(", "\"othello\"", ")", "self", ".", "login_user", "(", "hamlet"...
[ 607, 4 ]
[ 627, 54 ]
python
en
['en', 'error', 'th']
False
MessagePOSTTest.test_personal_message_to_nonexistent_user
(self)
Sending a personal message to an invalid email returns error JSON.
Sending a personal message to an invalid email returns error JSON.
def test_personal_message_to_nonexistent_user(self) -> None: """ Sending a personal message to an invalid email returns error JSON. """ self.login("hamlet") result = self.client_post( "/json/messages", { "type": "private", "...
[ "def", "test_personal_message_to_nonexistent_user", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "result", "=", "self", ".", "client_post", "(", "\"/json/messages\"", ",", "{", "\"type\"", ":", "\"private\"", ",", "\"content...
[ 629, 4 ]
[ 643, 69 ]
python
en
['en', 'error', 'th']
False
MessagePOSTTest.test_personal_message_to_deactivated_user
(self)
Sending a personal message to a deactivated user returns error JSON.
Sending a personal message to a deactivated user returns error JSON.
def test_personal_message_to_deactivated_user(self) -> None: """ Sending a personal message to a deactivated user returns error JSON. """ othello = self.example_user("othello") cordelia = self.example_user("cordelia") do_deactivate_user(othello, acting_user=None) ...
[ "def", "test_personal_message_to_deactivated_user", "(", "self", ")", "->", "None", ":", "othello", "=", "self", ".", "example_user", "(", "\"othello\"", ")", "cordelia", "=", "self", ".", "example_user", "(", "\"cordelia\"", ")", "do_deactivate_user", "(", "othel...
[ 645, 4 ]
[ 674, 86 ]
python
en
['en', 'error', 'th']
False
MessagePOSTTest.test_invalid_type
(self)
Sending a message of unknown type returns error JSON.
Sending a message of unknown type returns error JSON.
def test_invalid_type(self) -> None: """ Sending a message of unknown type returns error JSON. """ self.login("hamlet") othello = self.example_user("othello") result = self.client_post( "/json/messages", { "type": "invalid type", ...
[ "def", "test_invalid_type", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "othello", "=", "self", ".", "example_user", "(", "\"othello\"", ")", "result", "=", "self", ".", "client_post", "(", "\"/json/messages\"", ",", ...
[ 676, 4 ]
[ 691, 62 ]
python
en
['en', 'error', 'th']
False
MessagePOSTTest.test_empty_message
(self)
Sending a message that is empty or only whitespace should fail
Sending a message that is empty or only whitespace should fail
def test_empty_message(self) -> None: """ Sending a message that is empty or only whitespace should fail """ self.login("hamlet") othello = self.example_user("othello") result = self.client_post( "/json/messages", {"type": "private", "content": " "...
[ "def", "test_empty_message", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "othello", "=", "self", ".", "example_user", "(", "\"othello\"", ")", "result", "=", "self", ".", "client_post", "(", "\"/json/messages\"", ",", ...
[ 693, 4 ]
[ 703, 67 ]
python
en
['en', 'error', 'th']
False
MessagePOSTTest.test_empty_string_topic
(self)
Sending a message that has empty string topic should fail
Sending a message that has empty string topic should fail
def test_empty_string_topic(self) -> None: """ Sending a message that has empty string topic should fail """ self.login("hamlet") result = self.client_post( "/json/messages", { "type": "stream", "to": "Verona", ...
[ "def", "test_empty_string_topic", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "result", "=", "self", ".", "client_post", "(", "\"/json/messages\"", ",", "{", "\"type\"", ":", "\"stream\"", ",", "\"to\"", ":", "\"Verona\...
[ 705, 4 ]
[ 720, 62 ]
python
en
['en', 'error', 'th']
False
MessagePOSTTest.test_missing_topic
(self)
Sending a message without topic should fail
Sending a message without topic should fail
def test_missing_topic(self) -> None: """ Sending a message without topic should fail """ self.login("hamlet") result = self.client_post( "/json/messages", {"type": "stream", "to": "Verona", "client": "test suite", "content": "Test message"}, ) ...
[ "def", "test_missing_topic", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "result", "=", "self", ".", "client_post", "(", "\"/json/messages\"", ",", "{", "\"type\"", ":", "\"stream\"", ",", "\"to\"", ":", "\"Verona\"", ...
[ 722, 4 ]
[ 731, 55 ]
python
en
['en', 'error', 'th']
False
MessagePOSTTest.test_invalid_message_type
(self)
Messages other than the type of "private" or "stream" are considered as invalid
Messages other than the type of "private" or "stream" are considered as invalid
def test_invalid_message_type(self) -> None: """ Messages other than the type of "private" or "stream" are considered as invalid """ self.login("hamlet") result = self.client_post( "/json/messages", { "type": "invalid", "to"...
[ "def", "test_invalid_message_type", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "result", "=", "self", ".", "client_post", "(", "\"/json/messages\"", ",", "{", "\"type\"", ":", "\"invalid\"", ",", "\"to\"", ":", "\"Vero...
[ 733, 4 ]
[ 748, 62 ]
python
en
['en', 'error', 'th']
False
MessagePOSTTest.test_private_message_without_recipients
(self)
Sending private message without recipients should fail
Sending private message without recipients should fail
def test_private_message_without_recipients(self) -> None: """ Sending private message without recipients should fail """ self.login("hamlet") result = self.client_post( "/json/messages", {"type": "private", "content": "Test content", "client": "test suite...
[ "def", "test_private_message_without_recipients", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "result", "=", "self", ".", "client_post", "(", "\"/json/messages\"", ",", "{", "\"type\"", ":", "\"private\"", ",", "\"content\"...
[ 750, 4 ]
[ 759, 70 ]
python
en
['en', 'error', 'th']
False
MessagePOSTTest.test_mirrored_huddle
(self)
Sending a mirrored huddle message works
Sending a mirrored huddle message works
def test_mirrored_huddle(self) -> None: """ Sending a mirrored huddle message works """ result = self.api_post( self.mit_user("starnine"), "/json/messages", { "type": "private", "sender": self.mit_email("sipbtest"), ...
[ "def", "test_mirrored_huddle", "(", "self", ")", "->", "None", ":", "result", "=", "self", ".", "api_post", "(", "self", ".", "mit_user", "(", "\"starnine\"", ")", ",", "\"/json/messages\"", ",", "{", "\"type\"", ":", "\"private\"", ",", "\"sender\"", ":", ...
[ 761, 4 ]
[ 779, 40 ]
python
en
['en', 'error', 'th']
False
MessagePOSTTest.test_mirrored_personal
(self)
Sending a mirrored personal message works
Sending a mirrored personal message works
def test_mirrored_personal(self) -> None: """ Sending a mirrored personal message works """ result = self.api_post( self.mit_user("starnine"), "/json/messages", { "type": "private", "sender": self.mit_email("sipbtest"), ...
[ "def", "test_mirrored_personal", "(", "self", ")", "->", "None", ":", "result", "=", "self", ".", "api_post", "(", "self", ".", "mit_user", "(", "\"starnine\"", ")", ",", "\"/json/messages\"", ",", "{", "\"type\"", ":", "\"private\"", ",", "\"sender\"", ":",...
[ 781, 4 ]
[ 797, 40 ]
python
en
['en', 'error', 'th']
False
MessagePOSTTest.test_mirrored_personal_browser
(self)
Sending a mirrored personal message via the browser should not work.
Sending a mirrored personal message via the browser should not work.
def test_mirrored_personal_browser(self) -> None: """ Sending a mirrored personal message via the browser should not work. """ user = self.mit_user("starnine") self.login_user(user) result = self.client_post( "/json/messages", { "ty...
[ "def", "test_mirrored_personal_browser", "(", "self", ")", "->", "None", ":", "user", "=", "self", ".", "mit_user", "(", "\"starnine\"", ")", "self", ".", "login_user", "(", "user", ")", "result", "=", "self", ".", "client_post", "(", "\"/json/messages\"", "...
[ 799, 4 ]
[ 816, 66 ]
python
en
['en', 'error', 'th']
False
MessagePOSTTest.test_mirrored_personal_to_someone_else
(self)
Sending a mirrored personal message to someone else is not allowed.
Sending a mirrored personal message to someone else is not allowed.
def test_mirrored_personal_to_someone_else(self) -> None: """ Sending a mirrored personal message to someone else is not allowed. """ result = self.api_post( self.mit_user("starnine"), "/api/v1/messages", { "type": "private", ...
[ "def", "test_mirrored_personal_to_someone_else", "(", "self", ")", "->", "None", ":", "result", "=", "self", ".", "api_post", "(", "self", ".", "mit_user", "(", "\"starnine\"", ")", ",", "\"/api/v1/messages\"", ",", "{", "\"type\"", ":", "\"private\"", ",", "\...
[ 818, 4 ]
[ 834, 76 ]
python
en
['en', 'error', 'th']
False
MessagePOSTTest.test_duplicated_mirrored_huddle
(self)
Sending two mirrored huddles in the row return the same ID
Sending two mirrored huddles in the row return the same ID
def test_duplicated_mirrored_huddle(self) -> None: """ Sending two mirrored huddles in the row return the same ID """ msg = { "type": "private", "sender": self.mit_email("sipbtest"), "content": "Test message", "client": "zephyr_mirror", ...
[ "def", "test_duplicated_mirrored_huddle", "(", "self", ")", "->", "None", ":", "msg", "=", "{", "\"type\"", ":", "\"private\"", ",", "\"sender\"", ":", "self", ".", "mit_email", "(", "\"sipbtest\"", ")", ",", "\"content\"", ":", "\"Test message\"", ",", "\"cli...
[ 836, 4 ]
[ 868, 98 ]
python
en
['en', 'error', 'th']
False
MessagePOSTTest.test_message_with_null_bytes
(self)
A message with null bytes in it is handled.
A message with null bytes in it is handled.
def test_message_with_null_bytes(self) -> None: """ A message with null bytes in it is handled. """ self.login("hamlet") post_data = { "type": "stream", "to": "Verona", "client": "test suite", "content": " I like null bytes \x00 in...
[ "def", "test_message_with_null_bytes", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "post_data", "=", "{", "\"type\"", ":", "\"stream\"", ",", "\"to\"", ":", "\"Verona\"", ",", "\"client\"", ":", "\"test suite\"", ",", "...
[ 870, 4 ]
[ 883, 77 ]
python
en
['en', 'error', 'th']
False
MessagePOSTTest.test_strip_message
(self)
A message with mixed whitespace at the end is cleaned up.
A message with mixed whitespace at the end is cleaned up.
def test_strip_message(self) -> None: """ A message with mixed whitespace at the end is cleaned up. """ self.login("hamlet") post_data = { "type": "stream", "to": "Verona", "client": "test suite", "content": " I like whitespace at ...
[ "def", "test_strip_message", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "post_data", "=", "{", "\"type\"", ":", "\"stream\"", ",", "\"to\"", ":", "\"Verona\"", ",", "\"client\"", ":", "\"test suite\"", ",", "\"content\...
[ 885, 4 ]
[ 900, 81 ]
python
en
['en', 'error', 'th']
False
MessagePOSTTest.test_long_message
(self)
Sending a message longer than the maximum message length succeeds but is truncated.
Sending a message longer than the maximum message length succeeds but is truncated.
def test_long_message(self) -> None: """ Sending a message longer than the maximum message length succeeds but is truncated. """ self.login("hamlet") long_message = "A" * (MAX_MESSAGE_LENGTH + 1) post_data = { "type": "stream", "to": "Veron...
[ "def", "test_long_message", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "long_message", "=", "\"A\"", "*", "(", "MAX_MESSAGE_LENGTH", "+", "1", ")", "post_data", "=", "{", "\"type\"", ":", "\"stream\"", ",", "\"to\"",...
[ 902, 4 ]
[ 922, 9 ]
python
en
['en', 'error', 'th']
False
MessagePOSTTest.test_long_topic
(self)
Sending a message with a topic longer than the maximum topic length succeeds, but the topic is truncated.
Sending a message with a topic longer than the maximum topic length succeeds, but the topic is truncated.
def test_long_topic(self) -> None: """ Sending a message with a topic longer than the maximum topic length succeeds, but the topic is truncated. """ self.login("hamlet") long_topic = "A" * (MAX_TOPIC_NAME_LENGTH + 1) post_data = { "type": "stream", ...
[ "def", "test_long_topic", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "long_topic", "=", "\"A\"", "*", "(", "MAX_TOPIC_NAME_LENGTH", "+", "1", ")", "post_data", "=", "{", "\"type\"", ":", "\"stream\"", ",", "\"to\"", ...
[ 924, 4 ]
[ 942, 94 ]
python
en
['en', 'error', 'th']
False
MessagePOSTTest.test_send_message_forging_message_to_another_realm
(self)
Test for a specific vulnerability that allowed a .can_forge_sender user to forge a message as a cross-realm bot to a stream in another realm, by setting up an appropriate RealmDomain and specifying JabberMirror as client to cause the vulnerable codepath to be executed.
Test for a specific vulnerability that allowed a .can_forge_sender user to forge a message as a cross-realm bot to a stream in another realm, by setting up an appropriate RealmDomain and specifying JabberMirror as client to cause the vulnerable codepath to be executed.
def test_send_message_forging_message_to_another_realm(self) -> None: """ Test for a specific vulnerability that allowed a .can_forge_sender user to forge a message as a cross-realm bot to a stream in another realm, by setting up an appropriate RealmDomain and specifying JabberMirror as ...
[ "def", "test_send_message_forging_message_to_another_realm", "(", "self", ")", "->", "None", ":", "user", "=", "self", ".", "example_user", "(", "\"default_bot\"", ")", "do_change_can_forge_sender", "(", "user", ",", "True", ")", "zephyr_realm", "=", "get_realm", "(...
[ 1008, 4 ]
[ 1035, 76 ]
python
en
['en', 'error', 'th']
False
StreamMessagesTest.assert_stream_message
( self, stream_name: str, topic_name: str = "test topic", content: str = "test content" )
Check that messages sent to a stream reach all subscribers to that stream.
Check that messages sent to a stream reach all subscribers to that stream.
def assert_stream_message( self, stream_name: str, topic_name: str = "test topic", content: str = "test content" ) -> None: """ Check that messages sent to a stream reach all subscribers to that stream. """ realm = get_realm("zulip") subscribers = self.users_subscribe...
[ "def", "assert_stream_message", "(", "self", ",", "stream_name", ":", "str", ",", "topic_name", ":", "str", "=", "\"test topic\"", ",", "content", ":", "str", "=", "\"test content\"", ")", "->", "None", ":", "realm", "=", "get_realm", "(", "\"zulip\"", ")", ...
[ 1459, 4 ]
[ 1506, 95 ]
python
en
['en', 'error', 'th']
False
StreamMessagesTest.test_performance
(self)
This test is part of the automated test suite, but it is more intended as an aid to measuring the performance of do_send_messages() with consistent data setup across different commits. You can modify the values below and run just this test, and then comment out the prin...
This test is part of the automated test suite, but it is more intended as an aid to measuring the performance of do_send_messages() with consistent data setup across different commits. You can modify the values below and run just this test, and then comment out the prin...
def test_performance(self) -> None: """ This test is part of the automated test suite, but it is more intended as an aid to measuring the performance of do_send_messages() with consistent data setup across different commits. You can modify the values below and run just t...
[ "def", "test_performance", "(", "self", ")", "->", "None", ":", "num_messages", "=", "2", "num_extra_users", "=", "10", "sender", "=", "self", ".", "example_user", "(", "\"cordelia\"", ")", "realm", "=", "sender", ".", "realm", "message_content", "=", "\"wha...
[ 1508, 4 ]
[ 1566, 72 ]
python
en
['en', 'error', 'th']
False
StreamMessagesTest.test_message_to_stream
(self)
If you send a message to a stream, everyone subscribed to the stream receives the messages.
If you send a message to a stream, everyone subscribed to the stream receives the messages.
def test_message_to_stream(self) -> None: """ If you send a message to a stream, everyone subscribed to the stream receives the messages. """ self.assert_stream_message("Scotland")
[ "def", "test_message_to_stream", "(", "self", ")", "->", "None", ":", "self", ".", "assert_stream_message", "(", "\"Scotland\"", ")" ]
[ 1904, 4 ]
[ 1909, 46 ]
python
en
['en', 'error', 'th']
False
StreamMessagesTest.test_non_ascii_stream_message
(self)
Sending a stream message containing non-ASCII characters in the stream name, topic, or message body succeeds.
Sending a stream message containing non-ASCII characters in the stream name, topic, or message body succeeds.
def test_non_ascii_stream_message(self) -> None: """ Sending a stream message containing non-ASCII characters in the stream name, topic, or message body succeeds. """ self.login("hamlet") # Subscribe everyone to a stream with non-ASCII characters. non_ascii_strea...
[ "def", "test_non_ascii_stream_message", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "# Subscribe everyone to a stream with non-ASCII characters.", "non_ascii_stream_name", "=", "\"hümbüǵ\"", "realm", "=", "get_realm", "(", "\"zulip\"...
[ 1911, 4 ]
[ 1927, 102 ]
python
en
['en', 'error', 'th']
False
PersonalMessageSendTest.test_personal_to_self
(self)
If you send a personal to yourself, only you see it.
If you send a personal to yourself, only you see it.
def test_personal_to_self(self) -> None: """ If you send a personal to yourself, only you see it. """ old_user_profiles = list(UserProfile.objects.all()) test_email = self.nonreg_email("test1") self.register(test_email, "test1") old_messages = [] for user...
[ "def", "test_personal_to_self", "(", "self", ")", "->", "None", ":", "old_user_profiles", "=", "list", "(", "UserProfile", ".", "objects", ".", "all", "(", ")", ")", "test_email", "=", "self", ".", "nonreg_email", "(", "\"test1\"", ")", "self", ".", "regis...
[ 1960, 4 ]
[ 1983, 80 ]
python
en
['en', 'error', 'th']
False
PersonalMessageSendTest.assert_personal
( self, sender: UserProfile, receiver: UserProfile, content: str = "testcontent" )
Send a private message from `sender_email` to `receiver_email` and check that only those two parties actually received the message.
Send a private message from `sender_email` to `receiver_email` and check that only those two parties actually received the message.
def assert_personal( self, sender: UserProfile, receiver: UserProfile, content: str = "testcontent" ) -> None: """ Send a private message from `sender_email` to `receiver_email` and check that only those two parties actually received the message. """ sender_messages =...
[ "def", "assert_personal", "(", "self", ",", "sender", ":", "UserProfile", ",", "receiver", ":", "UserProfile", ",", "content", ":", "str", "=", "\"testcontent\"", ")", "->", "None", ":", "sender_messages", "=", "message_stream_count", "(", "sender", ")", "rece...
[ 1985, 4 ]
[ 2015, 76 ]
python
en
['en', 'error', 'th']
False
PersonalMessageSendTest.test_personal
(self)
If you send a personal, only you and the recipient see it.
If you send a personal, only you and the recipient see it.
def test_personal(self) -> None: """ If you send a personal, only you and the recipient see it. """ self.login("hamlet") self.assert_personal( sender=self.example_user("hamlet"), receiver=self.example_user("othello"), )
[ "def", "test_personal", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "self", ".", "assert_personal", "(", "sender", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", ",", "receiver", "=", "self", ".", "exampl...
[ 2017, 4 ]
[ 2025, 9 ]
python
en
['en', 'error', 'th']
False
PersonalMessageSendTest.test_private_message_policy
(self)
Tests that PRIVATE_MESSAGE_POLICY_DISABLED works correctly.
Tests that PRIVATE_MESSAGE_POLICY_DISABLED works correctly.
def test_private_message_policy(self) -> None: """ Tests that PRIVATE_MESSAGE_POLICY_DISABLED works correctly. """ user_profile = self.example_user("hamlet") self.login_user(user_profile) do_set_realm_property( user_profile.realm, "private_message_...
[ "def", "test_private_message_policy", "(", "self", ")", "->", "None", ":", "user_profile", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "self", ".", "login_user", "(", "user_profile", ")", "do_set_realm_property", "(", "user_profile", ".", "realm", ...
[ 2027, 4 ]
[ 2045, 61 ]
python
en
['en', 'error', 'th']
False
PersonalMessageSendTest.test_non_ascii_personal
(self)
Sending a PM containing non-ASCII characters succeeds.
Sending a PM containing non-ASCII characters succeeds.
def test_non_ascii_personal(self) -> None: """ Sending a PM containing non-ASCII characters succeeds. """ self.login("hamlet") self.assert_personal( sender=self.example_user("hamlet"), receiver=self.example_user("othello"), content="hümbüǵ", ...
[ "def", "test_non_ascii_personal", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "self", ".", "assert_personal", "(", "sender", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", ",", "receiver", "=", "self", ".",...
[ 2047, 4 ]
[ 2056, 9 ]
python
en
['en', 'error', 'th']
False
CheckMessageTest.test_check_message_cant_forge_message_as_other_realm_user
(self)
Verifies that the .can_forge_sender permission doesn't allow forging another realm's user as sender of a message to a stream in the forwarder's realm.
Verifies that the .can_forge_sender permission doesn't allow forging another realm's user as sender of a message to a stream in the forwarder's realm.
def test_check_message_cant_forge_message_as_other_realm_user(self) -> None: """ Verifies that the .can_forge_sender permission doesn't allow forging another realm's user as sender of a message to a stream in the forwarder's realm. """ forwarder_user_profile = self.exampl...
[ "def", "test_check_message_cant_forge_message_as_other_realm_user", "(", "self", ")", "->", "None", ":", "forwarder_user_profile", "=", "self", ".", "example_user", "(", "\"othello\"", ")", "do_change_can_forge_sender", "(", "forwarder_user_profile", ",", "True", ")", "mi...
[ 2492, 4 ]
[ 2527, 13 ]
python
en
['en', 'error', 'th']
False
CheckMessageTest.test_check_message_cant_forge_message_to_stream_in_different_realm
(self)
Verifies that the .can_forge_sender permission doesn't allow forging another realm's user as sender of a message to a stream in the forged user's realm..
Verifies that the .can_forge_sender permission doesn't allow forging another realm's user as sender of a message to a stream in the forged user's realm..
def test_check_message_cant_forge_message_to_stream_in_different_realm(self) -> None: """ Verifies that the .can_forge_sender permission doesn't allow forging another realm's user as sender of a message to a stream in the forged user's realm.. """ forwarder_user_profile =...
[ "def", "test_check_message_cant_forge_message_to_stream_in_different_realm", "(", "self", ")", "->", "None", ":", "forwarder_user_profile", "=", "self", ".", "example_user", "(", "\"othello\"", ")", "do_change_can_forge_sender", "(", "forwarder_user_profile", ",", "True", "...
[ 2529, 4 ]
[ 2581, 13 ]
python
en
['en', 'error', 'th']
False
CheckMessageTest.test_bot_pm_feature
(self)
We send a PM to a bot's owner if their bot sends a message to an unsubscribed stream
We send a PM to a bot's owner if their bot sends a message to an unsubscribed stream
def test_bot_pm_feature(self) -> None: """We send a PM to a bot's owner if their bot sends a message to an unsubscribed stream""" parent = self.example_user("othello") bot = do_create_user( email="othello-bot@zulip.com", password="", realm=parent.realm...
[ "def", "test_bot_pm_feature", "(", "self", ")", "->", "None", ":", "parent", "=", "self", ".", "example_user", "(", "\"othello\"", ")", "bot", "=", "do_create_user", "(", "email", "=", "\"othello-bot@zulip.com\"", ",", "password", "=", "\"\"", ",", "realm", ...
[ 2602, 4 ]
[ 2632, 89 ]
python
en
['en', 'en', 'en']
True
qualify
(ref, resolvers, defns=Namespace.default)
Get a reference that is I{qualified} by namespace. @param ref: A referenced schema type name. @type ref: str @param resolvers: A list of objects to be used to resolve types. @type resolvers: [L{sax.element.Element},] @param defns: An optional target namespace used to qualify references ...
Get a reference that is I{qualified} by namespace.
def qualify(ref, resolvers, defns=Namespace.default): """ Get a reference that is I{qualified} by namespace. @param ref: A referenced schema type name. @type ref: str @param resolvers: A list of objects to be used to resolve types. @type resolvers: [L{sax.element.Element},] @param defns: An ...
[ "def", "qualify", "(", "ref", ",", "resolvers", ",", "defns", "=", "Namespace", ".", "default", ")", ":", "ns", "=", "None", "p", ",", "n", "=", "splitPrefix", "(", "ref", ")", "if", "p", "is", "not", "None", ":", "if", "not", "isinstance", "(", ...
[ 31, 0 ]
[ 58, 21 ]
python
en
['en', 'error', 'th']
False
isqref
(object)
Get whether the object is a I{qualified reference}. @param object: An object to be tested. @type object: I{any} @rtype: boolean @see: L{qualify}
Get whether the object is a I{qualified reference}.
def isqref(object): """ Get whether the object is a I{qualified reference}. @param object: An object to be tested. @type object: I{any} @rtype: boolean @see: L{qualify} """ return (\ isinstance(object, tuple) and \ len(object) == 2 and \ isinstance(object[0], base...
[ "def", "isqref", "(", "object", ")", ":", "return", "(", "isinstance", "(", "object", ",", "tuple", ")", "and", "len", "(", "object", ")", "==", "2", "and", "isinstance", "(", "object", "[", "0", "]", ",", "basestring", ")", "and", "isinstance", "(",...
[ 60, 0 ]
[ 72, 42 ]
python
en
['en', 'error', 'th']
False
to_torch_dtype
(numpy_dtype)
from_numpy automatically infers type, so we leverage that.
from_numpy automatically infers type, so we leverage that.
def to_torch_dtype(numpy_dtype): """from_numpy automatically infers type, so we leverage that.""" x = np.zeros([1], dtype=numpy_dtype) t = torch.from_numpy(x) return t.dtype
[ "def", "to_torch_dtype", "(", "numpy_dtype", ")", ":", "x", "=", "np", ".", "zeros", "(", "[", "1", "]", ",", "dtype", "=", "numpy_dtype", ")", "t", "=", "torch", ".", "from_numpy", "(", "x", ")", "return", "t", ".", "dtype" ]
[ 12, 0 ]
[ 16, 18 ]
python
en
['en', 'en', 'en']
True
ensure_memory_shared
(*tensors)
To prevent programming errors, ensure all tensors are in shared memory.
To prevent programming errors, ensure all tensors are in shared memory.
def ensure_memory_shared(*tensors): """To prevent programming errors, ensure all tensors are in shared memory.""" for tensor_dict in tensors: for _, _, t in iterate_recursively(tensor_dict): assert t.is_shared()
[ "def", "ensure_memory_shared", "(", "*", "tensors", ")", ":", "for", "tensor_dict", "in", "tensors", ":", "for", "_", ",", "_", ",", "t", "in", "iterate_recursively", "(", "tensor_dict", ")", ":", "assert", "t", ".", "is_shared", "(", ")" ]
[ 35, 0 ]
[ 39, 32 ]
python
en
['en', 'en', 'en']
True
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
PushBouncerNotificationTest.test_push_bouncer_api
(self, mock_request: Any)
This is a variant of the below test_push_api, but using the full push notification bouncer flow
This is a variant of the below test_push_api, but using the full push notification bouncer flow
def test_push_bouncer_api(self, mock_request: Any) -> None: """This is a variant of the below test_push_api, but using the full push notification bouncer flow """ mock_request.side_effect = self.bounce_request user = self.example_user("cordelia") self.login_user(user) ...
[ "def", "test_push_bouncer_api", "(", "self", ",", "mock_request", ":", "Any", ")", "->", "None", ":", "mock_request", ".", "side_effect", "=", "self", ".", "bounce_request", "user", "=", "self", ".", "example_user", "(", "\"cordelia\"", ")", "self", ".", "lo...
[ 300, 4 ]
[ 416, 40 ]
python
en
['en', 'en', 'en']
True
AnalyticsBouncerTest.test_analytics_api
(self, mock_request: Any)
This is a variant of the below test_push_api, but using the full push notification bouncer flow
This is a variant of the below test_push_api, but using the full push notification bouncer flow
def test_analytics_api(self, mock_request: Any) -> None: """This is a variant of the below test_push_api, but using the full push notification bouncer flow """ mock_request.side_effect = self.bounce_request user = self.example_user("hamlet") end_time = self.TIME_ZERO ...
[ "def", "test_analytics_api", "(", "self", ",", "mock_request", ":", "Any", ")", "->", "None", ":", "mock_request", ".", "side_effect", "=", "self", ".", "bounce_request", "user", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "end_time", "=", "sel...
[ 424, 4 ]
[ 584, 13 ]
python
en
['en', 'en', 'en']
True
AnalyticsBouncerTest.test_analytics_api_invalid
(self, mock_request: Any)
This is a variant of the below test_push_api, but using the full push notification bouncer flow
This is a variant of the below test_push_api, but using the full push notification bouncer flow
def test_analytics_api_invalid(self, mock_request: Any) -> None: """This is a variant of the below test_push_api, but using the full push notification bouncer flow """ mock_request.side_effect = self.bounce_request user = self.example_user("hamlet") end_time = self.TIME_Z...
[ "def", "test_analytics_api_invalid", "(", "self", ",", "mock_request", ":", "Any", ")", "->", "None", ":", "mock_request", ".", "side_effect", "=", "self", ".", "bounce_request", "user", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "end_time", "="...
[ 588, 4 ]
[ 607, 61 ]
python
en
['en', 'en', 'en']
True
HandlePushNotificationTest.bounce_request
(self, *args: Any, **kwargs: Any)
This method is used to carry out the push notification bouncer requests using the Django test browser, rather than python-requests.
This method is used to carry out the push notification bouncer requests using the Django test browser, rather than python-requests.
def bounce_request(self, *args: Any, **kwargs: Any) -> HttpResponse: """This method is used to carry out the push notification bouncer requests using the Django test browser, rather than python-requests. """ # args[0] is method, args[1] is URL. local_url = args[1].replace(setting...
[ "def", "bounce_request", "(", "self", ",", "*", "args", ":", "Any", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "HttpResponse", ":", "# args[0] is method, args[1] is URL.", "local_url", "=", "args", "[", "1", "]", ".", "replace", "(", "settings", ".", ...
[ 773, 4 ]
[ 785, 21 ]
python
en
['en', 'en', 'en']
True
HandlePushNotificationTest.test_deleted_message
(self)
Simulates the race where message is deleted before handlingx push notifications
Simulates the race where message is deleted before handlingx push notifications
def test_deleted_message(self) -> None: """Simulates the race where message is deleted before handlingx push notifications""" user_profile = self.example_user("hamlet") message = self.get_message(Recipient.PERSONAL, type_id=1) UserMessage.objects.create( user_profile=user_pro...
[ "def", "test_deleted_message", "(", "self", ")", "->", "None", ":", "user_profile", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "message", "=", "self", ".", "get_message", "(", "Recipient", ".", "PERSONAL", ",", "type_id", "=", "1", ")", "Use...
[ 934, 4 ]
[ 961, 50 ]
python
en
['en', 'en', 'en']
True
HandlePushNotificationTest.test_missing_message
(self)
Simulates the race where message is missing when handling push notifications
Simulates the race where message is missing when handling push notifications
def test_missing_message(self) -> None: """Simulates the race where message is missing when handling push notifications""" user_profile = self.example_user("hamlet") message = self.get_message(Recipient.PERSONAL, type_id=1) UserMessage.objects.create( user_profile=user_profil...
[ "def", "test_missing_message", "(", "self", ")", "->", "None", ":", "user_profile", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "message", "=", "self", ".", "get_message", "(", "Recipient", ".", "PERSONAL", ",", "type_id", "=", "1", ")", "Use...
[ 963, 4 ]
[ 994, 13 ]
python
en
['en', 'en', 'en']
True
HandlePushNotificationTest.test_user_message_does_not_exist
(self)
This simulates a condition that should only be an error if the user is not long-term idle; we fake it, though, in the sense that the user should not have received the message in the first place
This simulates a condition that should only be an error if the user is not long-term idle; we fake it, though, in the sense that the user should not have received the message in the first place
def test_user_message_does_not_exist(self) -> None: """This simulates a condition that should only be an error if the user is not long-term idle; we fake it, though, in the sense that the user should not have received the message in the first place""" self.make_stream("public_stream") ...
[ "def", "test_user_message_does_not_exist", "(", "self", ")", "->", "None", ":", "self", ".", "make_stream", "(", "\"public_stream\"", ")", "sender", "=", "self", ".", "example_user", "(", "\"iago\"", ")", "message_id", "=", "self", ".", "send_stream_message", "(...
[ 1162, 4 ]
[ 1180, 56 ]
python
en
['en', 'en', 'en']
True
HandlePushNotificationTest.test_user_message_soft_deactivated
(self)
This simulates a condition that should only be an error if the user is not long-term idle; we fake it, though, in the sense that the user should not have received the message in the first place
This simulates a condition that should only be an error if the user is not long-term idle; we fake it, though, in the sense that the user should not have received the message in the first place
def test_user_message_soft_deactivated(self) -> None: """This simulates a condition that should only be an error if the user is not long-term idle; we fake it, though, in the sense that the user should not have received the message in the first place""" self.setup_apns_tokens() s...
[ "def", "test_user_message_soft_deactivated", "(", "self", ")", "->", "None", ":", "self", ".", "setup_apns_tokens", "(", ")", "self", ".", "setup_gcm_tokens", "(", ")", "self", ".", "make_stream", "(", "\"public_stream\"", ")", "self", ".", "subscribe", "(", "...
[ 1182, 4 ]
[ 1233, 56 ]
python
en
['en', 'en', 'en']
True
TestAPNs.test_get_apns_client
(self)
This test is pretty hacky, and needs to carefully reset the state it modifies in order to avoid leaking state that can lead to nondeterministic results for other tests.
This test is pretty hacky, and needs to carefully reset the state it modifies in order to avoid leaking state that can lead to nondeterministic results for other tests.
def test_get_apns_client(self) -> None: """This test is pretty hacky, and needs to carefully reset the state it modifies in order to avoid leaking state that can lead to nondeterministic results for other tests. """ import zerver.lib.push_notifications zerver.lib.push_no...
[ "def", "test_get_apns_client", "(", "self", ")", "->", "None", ":", "import", "zerver", ".", "lib", ".", "push_notifications", "zerver", ".", "lib", ".", "push_notifications", ".", "_apns_client_initialized", "=", "False", "try", ":", "with", "self", ".", "set...
[ 1271, 4 ]
[ 1289, 61 ]
python
en
['en', 'en', 'en']
True
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
FunctionToolsConfig.ready
(self)
На момент готовности приложения, необходимо добавить зарегистрированные стратегии в модель-перечисление ImplementationStrategy
На момент готовности приложения, необходимо добавить зарегистрированные стратегии в модель-перечисление ImplementationStrategy
def ready(self): """ На момент готовности приложения, необходимо добавить зарегистрированные стратегии в модель-перечисление ImplementationStrategy """ from function_tools.models import ( ImplementationStrategy, ) strategy_storage = ImplementationStrat...
[ "def", "ready", "(", "self", ")", ":", "from", "function_tools", ".", "models", "import", "(", "ImplementationStrategy", ",", ")", "strategy_storage", "=", "ImplementationStrategyStorage", "(", ")", "for", "strategy", "in", "strategy_storage", ".", "implementation_s...
[ 13, 4 ]
[ 28, 17 ]
python
en
['en', 'error', 'th']
False
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
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
EggInfoDistribution.list_distinfo_files
(self, absolute=False)
Iterates over the ``installed-files.txt`` entries and returns paths for each line if the path is pointing to a file located in the ``.egg-info`` directory or one of its subdirectories. :parameter absolute: If *absolute* is ``True``, each returned path is trans...
Iterates over the ``installed-files.txt`` entries and returns paths for each line if the path is pointing to a file located in the ``.egg-info`` directory or one of its subdirectories.
def list_distinfo_files(self, absolute=False): """ Iterates over the ``installed-files.txt`` entries and returns paths for each line if the path is pointing to a file located in the ``.egg-info`` directory or one of its subdirectories. :parameter absolute: If *absolute* is ``Tru...
[ "def", "list_distinfo_files", "(", "self", ",", "absolute", "=", "False", ")", ":", "record_path", "=", "os", ".", "path", ".", "join", "(", "self", ".", "path", ",", "'installed-files.txt'", ")", "if", "os", ".", "path", ".", "exists", "(", "record_path...
[ 1040, 4 ]
[ 1067, 42 ]
python
en
['en', 'error', 'th']
False
DependencyGraph.add_distribution
(self, distribution)
Add the *distribution* to the graph. :type distribution: :class:`distutils2.database.InstalledDistribution` or :class:`distutils2.database.EggInfoDistribution`
Add the *distribution* to the graph.
def add_distribution(self, distribution): """Add the *distribution* to the graph. :type distribution: :class:`distutils2.database.InstalledDistribution` or :class:`distutils2.database.EggInfoDistribution` """ self.adjacency_list[distribution] = [] sel...
[ "def", "add_distribution", "(", "self", ",", "distribution", ")", ":", "self", ".", "adjacency_list", "[", "distribution", "]", "=", "[", "]", "self", ".", "reverse_list", "[", "distribution", "]", "=", "[", "]" ]
[ 1101, 4 ]
[ 1108, 44 ]
python
en
['en', 'en', 'en']
True
DependencyGraph.add_edge
(self, x, y, label=None)
Add an edge from distribution *x* to distribution *y* with the given *label*. :type x: :class:`distutils2.database.InstalledDistribution` or :class:`distutils2.database.EggInfoDistribution` :type y: :class:`distutils2.database.InstalledDistribution` or :class:`...
Add an edge from distribution *x* to distribution *y* with the given *label*.
def add_edge(self, x, y, label=None): """Add an edge from distribution *x* to distribution *y* with the given *label*. :type x: :class:`distutils2.database.InstalledDistribution` or :class:`distutils2.database.EggInfoDistribution` :type y: :class:`distutils2.database.In...
[ "def", "add_edge", "(", "self", ",", "x", ",", "y", ",", "label", "=", "None", ")", ":", "self", ".", "adjacency_list", "[", "x", "]", ".", "append", "(", "(", "y", ",", "label", ")", ")", "# multiple edges are allowed, so be careful", "if", "x", "not"...
[ 1111, 4 ]
[ 1124, 42 ]
python
en
['en', 'en', 'en']
True
DependencyGraph.add_missing
(self, distribution, requirement)
Add a missing *requirement* for the given *distribution*. :type distribution: :class:`distutils2.database.InstalledDistribution` or :class:`distutils2.database.EggInfoDistribution` :type requirement: ``str``
Add a missing *requirement* for the given *distribution*.
def add_missing(self, distribution, requirement): """ Add a missing *requirement* for the given *distribution*. :type distribution: :class:`distutils2.database.InstalledDistribution` or :class:`distutils2.database.EggInfoDistribution` :type requirement: ``str...
[ "def", "add_missing", "(", "self", ",", "distribution", ",", "requirement", ")", ":", "logger", ".", "debug", "(", "'%s missing %r'", ",", "distribution", ",", "requirement", ")", "self", ".", "missing", ".", "setdefault", "(", "distribution", ",", "[", "]",...
[ 1126, 4 ]
[ 1135, 69 ]
python
en
['en', 'error', 'th']
False
DependencyGraph.repr_node
(self, dist, level=1)
Prints only a subgraph
Prints only a subgraph
def repr_node(self, dist, level=1): """Prints only a subgraph""" output = [self._repr_dist(dist)] for other, label in self.adjacency_list[dist]: dist = self._repr_dist(other) if label is not None: dist = '%s [%s]' % (dist, label) output.append(...
[ "def", "repr_node", "(", "self", ",", "dist", ",", "level", "=", "1", ")", ":", "output", "=", "[", "self", ".", "_repr_dist", "(", "dist", ")", "]", "for", "other", ",", "label", "in", "self", ".", "adjacency_list", "[", "dist", "]", ":", "dist", ...
[ 1140, 4 ]
[ 1151, 32 ]
python
en
['en', 'en', 'en']
True
DependencyGraph.to_dot
(self, f, skip_disconnected=True)
Writes a DOT output for the graph to the provided file *f*. If *skip_disconnected* is set to ``True``, then all distributions that are not dependent on any other distribution are skipped. :type f: has to support ``file``-like operations :type skip_disconnected: ``bool``
Writes a DOT output for the graph to the provided file *f*.
def to_dot(self, f, skip_disconnected=True): """Writes a DOT output for the graph to the provided file *f*. If *skip_disconnected* is set to ``True``, then all distributions that are not dependent on any other distribution are skipped. :type f: has to support ``file``-like operations ...
[ "def", "to_dot", "(", "self", ",", "f", ",", "skip_disconnected", "=", "True", ")", ":", "disconnected", "=", "[", "]", "f", ".", "write", "(", "\"digraph dependencies {\\n\"", ")", "for", "dist", ",", "adjs", "in", "self", ".", "adjacency_list", ".", "i...
[ 1153, 4 ]
[ 1183, 22 ]
python
en
['en', 'en', 'en']
True