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
TestCompactBase.test_compact_multi_collections
(self, connect)
target: test compact works or not with multiple collections method: create 50 collections, add vectors into them and compact in turn expected: status ok
target: test compact works or not with multiple collections method: create 50 collections, add vectors into them and compact in turn expected: status ok
def test_compact_multi_collections(self, connect): ''' target: test compact works or not with multiple collections method: create 50 collections, add vectors into them and compact in turn expected: status ok ''' nq = 100 num_collections = 50 vectors = gen_...
[ "def", "test_compact_multi_collections", "(", "self", ",", "connect", ")", ":", "nq", "=", "100", "num_collections", "=", "50", "vectors", "=", "gen_vectors", "(", "nq", ",", "dim", ")", "collection_list", "=", "[", "]", "for", "i", "in", "range", "(", "...
[ 327, 4 ]
[ 350, 30 ]
python
en
['en', 'error', 'th']
False
TestCompactBase.test_add_vector_after_compact
(self, connect, collection)
target: test add vector after compact method: after compact operation, add vector expected: status ok, vector added
target: test add vector after compact method: after compact operation, add vector expected: status ok, vector added
def test_add_vector_after_compact(self, connect, collection): ''' target: test add vector after compact method: after compact operation, add vector expected: status ok, vector added ''' vectors = gen_vector(nb, dim) status, ids = connect.insert(collection, vector...
[ "def", "test_add_vector_after_compact", "(", "self", ",", "connect", ",", "collection", ")", ":", "vectors", "=", "gen_vector", "(", "nb", ",", "dim", ")", "status", ",", "ids", "=", "connect", ".", "insert", "(", "collection", ",", "vectors", ")", "assert...
[ 353, 4 ]
[ 377, 26 ]
python
en
['en', 'error', 'th']
False
TestCompactBase.test_index_creation_after_compact
(self, connect, collection, get_simple_index)
target: test index creation after compact method: after compact operation, create index expected: status ok, index description no change
target: test index creation after compact method: after compact operation, create index expected: status ok, index description no change
def test_index_creation_after_compact(self, connect, collection, get_simple_index): ''' target: test index creation after compact method: after compact operation, create index expected: status ok, index description no change ''' vectors = gen_vector(nb, dim) statu...
[ "def", "test_index_creation_after_compact", "(", "self", ",", "connect", ",", "collection", ",", "get_simple_index", ")", ":", "vectors", "=", "gen_vector", "(", "nb", ",", "dim", ")", "status", ",", "ids", "=", "connect", ".", "insert", "(", "collection", "...
[ 380, 4 ]
[ 403, 47 ]
python
en
['en', 'error', 'th']
False
TestCompactBase.test_delete_vectors_after_compact
(self, connect, collection)
target: test delete vectors after compact method: after compact operation, delete vectors expected: status ok, vectors deleted
target: test delete vectors after compact method: after compact operation, delete vectors expected: status ok, vectors deleted
def test_delete_vectors_after_compact(self, connect, collection): ''' target: test delete vectors after compact method: after compact operation, delete vectors expected: status ok, vectors deleted ''' vectors = gen_vector(nb, dim) status, ids = connect.insert(coll...
[ "def", "test_delete_vectors_after_compact", "(", "self", ",", "connect", ",", "collection", ")", ":", "vectors", "=", "gen_vector", "(", "nb", ",", "dim", ")", "status", ",", "ids", "=", "connect", ".", "insert", "(", "collection", ",", "vectors", ")", "as...
[ 406, 4 ]
[ 424, 26 ]
python
en
['en', 'error', 'th']
False
TestCompactBase.test_search_after_compact
(self, connect, collection)
target: test search after compact method: after compact operation, search vector expected: status ok
target: test search after compact method: after compact operation, search vector expected: status ok
def test_search_after_compact(self, connect, collection): ''' target: test search after compact method: after compact operation, search vector expected: status ok ''' vectors = gen_vector(nb, dim) status, ids = connect.insert(collection, vectors) assert st...
[ "def", "test_search_after_compact", "(", "self", ",", "connect", ",", "collection", ")", ":", "vectors", "=", "gen_vector", "(", "nb", ",", "dim", ")", "status", ",", "ids", "=", "connect", ".", "insert", "(", "collection", ",", "vectors", ")", "assert", ...
[ 427, 4 ]
[ 443, 26 ]
python
en
['en', 'error', 'th']
False
TestCompactBase._test_compact_server_crashed_recovery
(self, connect, collection)
target: test compact when server crashed unexpectedly and restarted method: add vectors, delete and compact collection; server stopped and restarted during compact expected: status ok, request recovered
target: test compact when server crashed unexpectedly and restarted method: add vectors, delete and compact collection; server stopped and restarted during compact expected: status ok, request recovered
def _test_compact_server_crashed_recovery(self, connect, collection): ''' target: test compact when server crashed unexpectedly and restarted method: add vectors, delete and compact collection; server stopped and restarted during compact expected: status ok, request recovered '''...
[ "def", "_test_compact_server_crashed_recovery", "(", "self", ",", "connect", ",", "collection", ")", ":", "vectors", "=", "gen_vector", "(", "nb", "*", "100", ",", "dim", ")", "status", ",", "ids", "=", "connect", ".", "insert", "(", "collection", ",", "ve...
[ 446, 4 ]
[ 470, 61 ]
python
en
['en', 'error', 'th']
False
TestCompactJAC.test_add_vector_and_compact
(self, connect, jac_collection)
target: test add vector and compact method: add vector and compact collection expected: status ok, vector added
target: test add vector and compact method: add vector and compact collection expected: status ok, vector added
def test_add_vector_and_compact(self, connect, jac_collection): ''' target: test add vector and compact method: add vector and compact collection expected: status ok, vector added ''' tmp, vector = gen_binary_vectors(1, dim) status, ids = connect.insert(jac_colle...
[ "def", "test_add_vector_and_compact", "(", "self", ",", "connect", ",", "jac_collection", ")", ":", "tmp", ",", "vector", "=", "gen_binary_vectors", "(", "1", ",", "dim", ")", "status", ",", "ids", "=", "connect", ".", "insert", "(", "jac_collection", ",", ...
[ 480, 4 ]
[ 501, 41 ]
python
en
['en', 'error', 'th']
False
TestCompactJAC.test_insert_and_compact
(self, connect, jac_collection)
target: test add vectors and compact method: add vectors and compact collection expected: status ok, vectors added
target: test add vectors and compact method: add vectors and compact collection expected: status ok, vectors added
def test_insert_and_compact(self, connect, jac_collection): ''' target: test add vectors and compact method: add vectors and compact collection expected: status ok, vectors added ''' tmp, vectors = gen_binary_vectors(nb, dim) status, ids = connect.insert(jac_coll...
[ "def", "test_insert_and_compact", "(", "self", ",", "connect", ",", "jac_collection", ")", ":", "tmp", ",", "vectors", "=", "gen_binary_vectors", "(", "nb", ",", "dim", ")", "status", ",", "ids", "=", "connect", ".", "insert", "(", "jac_collection", ",", "...
[ 504, 4 ]
[ 525, 41 ]
python
en
['en', 'error', 'th']
False
TestCompactJAC.test_insert_delete_part_and_compact
(self, connect, jac_collection)
target: test add vectors, delete part of them and compact method: add vectors, delete a few and compact collection expected: status ok, data size is smaller after compact
target: test add vectors, delete part of them and compact method: add vectors, delete a few and compact collection expected: status ok, data size is smaller after compact
def test_insert_delete_part_and_compact(self, connect, jac_collection): ''' target: test add vectors, delete part of them and compact method: add vectors, delete a few and compact collection expected: status ok, data size is smaller after compact ''' tmp, vectors = gen_b...
[ "def", "test_insert_delete_part_and_compact", "(", "self", ",", "connect", ",", "jac_collection", ")", ":", "tmp", ",", "vectors", "=", "gen_binary_vectors", "(", "nb", ",", "dim", ")", "status", ",", "ids", "=", "connect", ".", "insert", "(", "jac_collection"...
[ 528, 4 ]
[ 558, 41 ]
python
en
['en', 'error', 'th']
False
TestCompactJAC.test_insert_delete_all_and_compact
(self, connect, jac_collection)
target: test add vectors, delete them and compact method: add vectors, delete all and compact collection expected: status ok, no data size in collection info because collection is empty
target: test add vectors, delete them and compact method: add vectors, delete all and compact collection expected: status ok, no data size in collection info because collection is empty
def test_insert_delete_all_and_compact(self, connect, jac_collection): ''' target: test add vectors, delete them and compact method: add vectors, delete all and compact collection expected: status ok, no data size in collection info because collection is empty ''' tmp, v...
[ "def", "test_insert_delete_all_and_compact", "(", "self", ",", "connect", ",", "jac_collection", ")", ":", "tmp", ",", "vectors", "=", "gen_binary_vectors", "(", "nb", ",", "dim", ")", "status", ",", "ids", "=", "connect", ".", "insert", "(", "jac_collection",...
[ 561, 4 ]
[ 585, 52 ]
python
en
['en', 'error', 'th']
False
TestCompactJAC.test_add_vector_and_compact_twice
(self, connect, jac_collection)
target: test add vector and compact twice method: add vector and compact collection twice expected: status ok
target: test add vector and compact twice method: add vector and compact collection twice expected: status ok
def test_add_vector_and_compact_twice(self, connect, jac_collection): ''' target: test add vector and compact twice method: add vector and compact collection twice expected: status ok ''' tmp, vector = gen_binary_vectors(1, dim) status, ids = connect.insert(jac_co...
[ "def", "test_add_vector_and_compact_twice", "(", "self", ",", "connect", ",", "jac_collection", ")", ":", "tmp", ",", "vector", "=", "gen_binary_vectors", "(", "1", ",", "dim", ")", "status", ",", "ids", "=", "connect", ".", "insert", "(", "jac_collection", ...
[ 588, 4 ]
[ 616, 46 ]
python
en
['en', 'error', 'th']
False
TestCompactJAC.test_insert_delete_part_and_compact_twice
(self, connect, jac_collection)
target: test add vectors, delete part of them and compact twice method: add vectors, delete part and compact collection twice expected: status ok, data size smaller after first compact, no change after second
target: test add vectors, delete part of them and compact twice method: add vectors, delete part and compact collection twice expected: status ok, data size smaller after first compact, no change after second
def test_insert_delete_part_and_compact_twice(self, connect, jac_collection): ''' target: test add vectors, delete part of them and compact twice method: add vectors, delete part and compact collection twice expected: status ok, data size smaller after first compact, no change after seco...
[ "def", "test_insert_delete_part_and_compact_twice", "(", "self", ",", "connect", ",", "jac_collection", ")", ":", "tmp", ",", "vectors", "=", "gen_binary_vectors", "(", "nb", ",", "dim", ")", "status", ",", "ids", "=", "connect", ".", "insert", "(", "jac_colle...
[ 619, 4 ]
[ 652, 46 ]
python
en
['en', 'error', 'th']
False
TestCompactJAC.test_compact_multi_collections
(self, connect)
target: test compact works or not with multiple collections method: create 50 collections, add vectors into them and compact in turn expected: status ok
target: test compact works or not with multiple collections method: create 50 collections, add vectors into them and compact in turn expected: status ok
def test_compact_multi_collections(self, connect): ''' target: test compact works or not with multiple collections method: create 50 collections, add vectors into them and compact in turn expected: status ok ''' nq = 100 num_collections = 10 tmp, vectors =...
[ "def", "test_compact_multi_collections", "(", "self", ",", "connect", ")", ":", "nq", "=", "100", "num_collections", "=", "10", "tmp", ",", "vectors", "=", "gen_binary_vectors", "(", "nq", ",", "dim", ")", "collection_list", "=", "[", "]", "for", "i", "in"...
[ 655, 4 ]
[ 683, 30 ]
python
en
['en', 'error', 'th']
False
TestCompactJAC.test_add_vector_after_compact
(self, connect, jac_collection)
target: test add vector after compact method: after compact operation, add vector expected: status ok, vector added
target: test add vector after compact method: after compact operation, add vector expected: status ok, vector added
def test_add_vector_after_compact(self, connect, jac_collection): ''' target: test add vector after compact method: after compact operation, add vector expected: status ok, vector added ''' tmp, vectors = gen_binary_vectors(nb, dim) status, ids = connect.insert(j...
[ "def", "test_add_vector_after_compact", "(", "self", ",", "connect", ",", "jac_collection", ")", ":", "tmp", ",", "vectors", "=", "gen_binary_vectors", "(", "nb", ",", "dim", ")", "status", ",", "ids", "=", "connect", ".", "insert", "(", "jac_collection", ",...
[ 686, 4 ]
[ 710, 26 ]
python
en
['en', 'error', 'th']
False
TestCompactJAC.test_delete_vectors_after_compact
(self, connect, jac_collection)
target: test delete vectors after compact method: after compact operation, delete vectors expected: status ok, vectors deleted
target: test delete vectors after compact method: after compact operation, delete vectors expected: status ok, vectors deleted
def test_delete_vectors_after_compact(self, connect, jac_collection): ''' target: test delete vectors after compact method: after compact operation, delete vectors expected: status ok, vectors deleted ''' tmp, vectors = gen_binary_vectors(nb, dim) status, ids = co...
[ "def", "test_delete_vectors_after_compact", "(", "self", ",", "connect", ",", "jac_collection", ")", ":", "tmp", ",", "vectors", "=", "gen_binary_vectors", "(", "nb", ",", "dim", ")", "status", ",", "ids", "=", "connect", ".", "insert", "(", "jac_collection", ...
[ 713, 4 ]
[ 731, 26 ]
python
en
['en', 'error', 'th']
False
TestCompactJAC.test_search_after_compact
(self, connect, jac_collection)
target: test search after compact method: after compact operation, search vector expected: status ok
target: test search after compact method: after compact operation, search vector expected: status ok
def test_search_after_compact(self, connect, jac_collection): ''' target: test search after compact method: after compact operation, search vector expected: status ok ''' tmp, vectors = gen_binary_vectors(nb, dim) status, ids = connect.insert(jac_collection, vecto...
[ "def", "test_search_after_compact", "(", "self", ",", "connect", ",", "jac_collection", ")", ":", "tmp", ",", "vectors", "=", "gen_binary_vectors", "(", "nb", ",", "dim", ")", "status", ",", "ids", "=", "connect", ".", "insert", "(", "jac_collection", ",", ...
[ 734, 4 ]
[ 750, 26 ]
python
en
['en', 'error', 'th']
False
TestCompactIP.test_add_vector_and_compact
(self, connect, ip_collection)
target: test add vector and compact method: add vector and compact collection expected: status ok, vector added
target: test add vector and compact method: add vector and compact collection expected: status ok, vector added
def test_add_vector_and_compact(self, connect, ip_collection): ''' target: test add vector and compact method: add vector and compact collection expected: status ok, vector added ''' vector = gen_single_vector(dim) status, ids = connect.insert(ip_collection, vect...
[ "def", "test_add_vector_and_compact", "(", "self", ",", "connect", ",", "ip_collection", ")", ":", "vector", "=", "gen_single_vector", "(", "dim", ")", "status", ",", "ids", "=", "connect", ".", "insert", "(", "ip_collection", ",", "vector", ")", "assert", "...
[ 760, 4 ]
[ 783, 41 ]
python
en
['en', 'error', 'th']
False
TestCompactIP.test_insert_and_compact
(self, connect, ip_collection)
target: test add vectors and compact method: add vectors and compact collection expected: status ok, vectors added
target: test add vectors and compact method: add vectors and compact collection expected: status ok, vectors added
def test_insert_and_compact(self, connect, ip_collection): ''' target: test add vectors and compact method: add vectors and compact collection expected: status ok, vectors added ''' vectors = gen_vector(nb, dim) status, ids = connect.insert(ip_collection, vectors...
[ "def", "test_insert_and_compact", "(", "self", ",", "connect", ",", "ip_collection", ")", ":", "vectors", "=", "gen_vector", "(", "nb", ",", "dim", ")", "status", ",", "ids", "=", "connect", ".", "insert", "(", "ip_collection", ",", "vectors", ")", "assert...
[ 786, 4 ]
[ 807, 41 ]
python
en
['en', 'error', 'th']
False
TestCompactIP.test_insert_delete_part_and_compact
(self, connect, ip_collection)
target: test add vectors, delete part of them and compact method: add vectors, delete a few and compact collection expected: status ok, data size is smaller after compact
target: test add vectors, delete part of them and compact method: add vectors, delete a few and compact collection expected: status ok, data size is smaller after compact
def test_insert_delete_part_and_compact(self, connect, ip_collection): ''' target: test add vectors, delete part of them and compact method: add vectors, delete a few and compact collection expected: status ok, data size is smaller after compact ''' vectors = gen_vector(...
[ "def", "test_insert_delete_part_and_compact", "(", "self", ",", "connect", ",", "ip_collection", ")", ":", "vectors", "=", "gen_vector", "(", "nb", ",", "dim", ")", "status", ",", "ids", "=", "connect", ".", "insert", "(", "ip_collection", ",", "vectors", ")...
[ 810, 4 ]
[ 840, 41 ]
python
en
['en', 'error', 'th']
False
TestCompactIP.test_insert_delete_all_and_compact
(self, connect, ip_collection)
target: test add vectors, delete them and compact method: add vectors, delete all and compact collection expected: status ok, no data size in collection info because collection is empty
target: test add vectors, delete them and compact method: add vectors, delete all and compact collection expected: status ok, no data size in collection info because collection is empty
def test_insert_delete_all_and_compact(self, connect, ip_collection): ''' target: test add vectors, delete them and compact method: add vectors, delete all and compact collection expected: status ok, no data size in collection info because collection is empty ''' vectors...
[ "def", "test_insert_delete_all_and_compact", "(", "self", ",", "connect", ",", "ip_collection", ")", ":", "vectors", "=", "gen_vector", "(", "nb", ",", "dim", ")", "status", ",", "ids", "=", "connect", ".", "insert", "(", "ip_collection", ",", "vectors", ")"...
[ 843, 4 ]
[ 867, 52 ]
python
en
['en', 'error', 'th']
False
TestCompactIP.test_add_vector_and_compact_twice
(self, connect, ip_collection)
target: test add vector and compact twice method: add vector and compact collection twice expected: status ok
target: test add vector and compact twice method: add vector and compact collection twice expected: status ok
def test_add_vector_and_compact_twice(self, connect, ip_collection): ''' target: test add vector and compact twice method: add vector and compact collection twice expected: status ok ''' vector = gen_single_vector(dim) status, ids = connect.insert(ip_collection, v...
[ "def", "test_add_vector_and_compact_twice", "(", "self", ",", "connect", ",", "ip_collection", ")", ":", "vector", "=", "gen_single_vector", "(", "dim", ")", "status", ",", "ids", "=", "connect", ".", "insert", "(", "ip_collection", ",", "vector", ")", "assert...
[ 870, 4 ]
[ 898, 46 ]
python
en
['en', 'error', 'th']
False
TestCompactIP.test_insert_delete_part_and_compact_twice
(self, connect, ip_collection)
target: test add vectors, delete part of them and compact twice method: add vectors, delete part and compact collection twice expected: status ok, data size smaller after first compact, no change after second
target: test add vectors, delete part of them and compact twice method: add vectors, delete part and compact collection twice expected: status ok, data size smaller after first compact, no change after second
def test_insert_delete_part_and_compact_twice(self, connect, ip_collection): ''' target: test add vectors, delete part of them and compact twice method: add vectors, delete part and compact collection twice expected: status ok, data size smaller after first compact, no change after secon...
[ "def", "test_insert_delete_part_and_compact_twice", "(", "self", ",", "connect", ",", "ip_collection", ")", ":", "vectors", "=", "gen_vector", "(", "nb", ",", "dim", ")", "status", ",", "ids", "=", "connect", ".", "insert", "(", "ip_collection", ",", "vectors"...
[ 901, 4 ]
[ 938, 46 ]
python
en
['en', 'error', 'th']
False
TestCompactIP.test_compact_multi_collections
(self, connect)
target: test compact works or not with multiple collections method: create 50 collections, add vectors into them and compact in turn expected: status ok
target: test compact works or not with multiple collections method: create 50 collections, add vectors into them and compact in turn expected: status ok
def test_compact_multi_collections(self, connect): ''' target: test compact works or not with multiple collections method: create 50 collections, add vectors into them and compact in turn expected: status ok ''' nq = 100 num_collections = 50 vectors = gen_...
[ "def", "test_compact_multi_collections", "(", "self", ",", "connect", ")", ":", "nq", "=", "100", "num_collections", "=", "50", "vectors", "=", "gen_vectors", "(", "nq", ",", "dim", ")", "collection_list", "=", "[", "]", "for", "i", "in", "range", "(", "...
[ 941, 4 ]
[ 964, 30 ]
python
en
['en', 'error', 'th']
False
TestCompactIP.test_add_vector_after_compact
(self, connect, ip_collection)
target: test add vector after compact method: after compact operation, add vector expected: status ok, vector added
target: test add vector after compact method: after compact operation, add vector expected: status ok, vector added
def test_add_vector_after_compact(self, connect, ip_collection): ''' target: test add vector after compact method: after compact operation, add vector expected: status ok, vector added ''' vectors = gen_vector(nb, dim) status, ids = connect.insert(ip_collection, ...
[ "def", "test_add_vector_after_compact", "(", "self", ",", "connect", ",", "ip_collection", ")", ":", "vectors", "=", "gen_vector", "(", "nb", ",", "dim", ")", "status", ",", "ids", "=", "connect", ".", "insert", "(", "ip_collection", ",", "vectors", ")", "...
[ 967, 4 ]
[ 991, 26 ]
python
en
['en', 'error', 'th']
False
TestCompactIP.test_delete_vectors_after_compact
(self, connect, ip_collection)
target: test delete vectors after compact method: after compact operation, delete vectors expected: status ok, vectors deleted
target: test delete vectors after compact method: after compact operation, delete vectors expected: status ok, vectors deleted
def test_delete_vectors_after_compact(self, connect, ip_collection): ''' target: test delete vectors after compact method: after compact operation, delete vectors expected: status ok, vectors deleted ''' vectors = gen_vector(nb, dim) status, ids = connect.insert(i...
[ "def", "test_delete_vectors_after_compact", "(", "self", ",", "connect", ",", "ip_collection", ")", ":", "vectors", "=", "gen_vector", "(", "nb", ",", "dim", ")", "status", ",", "ids", "=", "connect", ".", "insert", "(", "ip_collection", ",", "vectors", ")",...
[ 994, 4 ]
[ 1010, 26 ]
python
en
['en', 'error', 'th']
False
TestCompactIP.test_search_after_compact
(self, connect, ip_collection)
target: test search after compact method: after compact operation, search vector expected: status ok
target: test search after compact method: after compact operation, search vector expected: status ok
def test_search_after_compact(self, connect, ip_collection): ''' target: test search after compact method: after compact operation, search vector expected: status ok ''' vectors = gen_vector(nb, dim) status, ids = connect.insert(ip_collection, vectors) ass...
[ "def", "test_search_after_compact", "(", "self", ",", "connect", ",", "ip_collection", ")", ":", "vectors", "=", "gen_vector", "(", "nb", ",", "dim", ")", "status", ",", "ids", "=", "connect", ".", "insert", "(", "ip_collection", ",", "vectors", ")", "asse...
[ 1013, 4 ]
[ 1029, 26 ]
python
en
['en', 'error', 'th']
False
connect
(path)
Create a HDF5Client for use with Ibis Parameters ---------- path: str or pathlib.Path Returns ------- HDF5Client
Create a HDF5Client for use with Ibis
def connect(path): """Create a HDF5Client for use with Ibis Parameters ---------- path: str or pathlib.Path Returns ------- HDF5Client """ return HDFClient(path)
[ "def", "connect", "(", "path", ")", ":", "return", "HDFClient", "(", "path", ")" ]
[ 7, 0 ]
[ 18, 26 ]
python
en
['en', 'en', 'en']
True
TestUserCreateView.test_create_with_password_validation
(self)
Test that the Django password validators are run when creating a user. Specifically test that the UserAttributeSimilarityValidator works, which requires a full-populated user model before the validation works.
Test that the Django password validators are run when creating a user. Specifically test that the UserAttributeSimilarityValidator works, which requires a full-populated user model before the validation works.
def test_create_with_password_validation(self): """ Test that the Django password validators are run when creating a user. Specifically test that the UserAttributeSimilarityValidator works, which requires a full-populated user model before the validation works. """ # Crea...
[ "def", "test_create_with_password_validation", "(", "self", ")", ":", "# Create a user with a password the same as their name", "response", "=", "self", ".", "post", "(", "{", "'username'", ":", "\"testuser\"", ",", "'email'", ":", "\"test@user.com\"", ",", "'first_name'"...
[ 273, 4 ]
[ 300, 42 ]
python
en
['en', 'error', 'th']
False
TestUserCreateView.test_create_with_missing_password
(self)
Password should be required by default
Password should be required by default
def test_create_with_missing_password(self): """Password should be required by default""" response = self.post({ 'username': "testuser", 'email': "test@user.com", 'first_name': "Test", 'last_name': "User", 'password1': "", 'password...
[ "def", "test_create_with_missing_password", "(", "self", ")", ":", "response", "=", "self", ".", "post", "(", "{", "'username'", ":", "\"testuser\"", ",", "'email'", ":", "\"test@user.com\"", ",", "'first_name'", ":", "\"Test\"", ",", "'last_name'", ":", "\"User...
[ 302, 4 ]
[ 321, 42 ]
python
en
['en', 'en', 'en']
True
TestUserCreateView.test_password_fields_exist_when_not_required
(self)
Password fields should still be shown if WAGTAILUSERS_PASSWORD_REQUIRED is False
Password fields should still be shown if WAGTAILUSERS_PASSWORD_REQUIRED is False
def test_password_fields_exist_when_not_required(self): """Password fields should still be shown if WAGTAILUSERS_PASSWORD_REQUIRED is False""" response = self.get() self.assertEqual(response.status_code, 200) self.assertTemplateUsed(response, 'wagtailusers/users/create.html') sel...
[ "def", "test_password_fields_exist_when_not_required", "(", "self", ")", ":", "response", "=", "self", ".", "get", "(", ")", "self", ".", "assertEqual", "(", "response", ".", "status_code", ",", "200", ")", "self", ".", "assertTemplateUsed", "(", "response", "...
[ 324, 4 ]
[ 330, 63 ]
python
en
['en', 'en', 'en']
True
TestUserCreateView.test_create_with_password_not_required
(self)
Password should not be required if WAGTAILUSERS_PASSWORD_REQUIRED is False
Password should not be required if WAGTAILUSERS_PASSWORD_REQUIRED is False
def test_create_with_password_not_required(self): """Password should not be required if WAGTAILUSERS_PASSWORD_REQUIRED is False""" response = self.post({ 'username': "testuser", 'email': "test@user.com", 'first_name': "Test", 'last_name': "User", ...
[ "def", "test_create_with_password_not_required", "(", "self", ")", ":", "response", "=", "self", ".", "post", "(", "{", "'username'", ":", "\"testuser\"", ",", "'email'", ":", "\"test@user.com\"", ",", "'first_name'", ":", "\"Test\"", ",", "'last_name'", ":", "\...
[ 333, 4 ]
[ 350, 52 ]
python
en
['en', 'en', 'en']
True
TestUserCreateView.test_optional_password_is_still_validated
(self)
When WAGTAILUSERS_PASSWORD_REQUIRED is False, password validation should still apply if a password _is_ supplied
When WAGTAILUSERS_PASSWORD_REQUIRED is False, password validation should still apply if a password _is_ supplied
def test_optional_password_is_still_validated(self): """When WAGTAILUSERS_PASSWORD_REQUIRED is False, password validation should still apply if a password _is_ supplied""" response = self.post({ 'username': "testuser", 'email': "test@user.com", 'first_name': "Test", ...
[ "def", "test_optional_password_is_still_validated", "(", "self", ")", ":", "response", "=", "self", ".", "post", "(", "{", "'username'", ":", "\"testuser\"", ",", "'email'", ":", "\"test@user.com\"", ",", "'first_name'", ":", "\"Test\"", ",", "'last_name'", ":", ...
[ 353, 4 ]
[ 372, 42 ]
python
en
['en', 'en', 'en']
True
TestUserCreateView.test_password_still_accepted_when_optional
(self)
When WAGTAILUSERS_PASSWORD_REQUIRED is False, we should still allow a password to be set
When WAGTAILUSERS_PASSWORD_REQUIRED is False, we should still allow a password to be set
def test_password_still_accepted_when_optional(self): """When WAGTAILUSERS_PASSWORD_REQUIRED is False, we should still allow a password to be set""" response = self.post({ 'username': "testuser", 'email': "test@user.com", 'first_name': "Test", 'last_name':...
[ "def", "test_password_still_accepted_when_optional", "(", "self", ")", ":", "response", "=", "self", ".", "post", "(", "{", "'username'", ":", "\"testuser\"", ",", "'email'", ":", "\"test@user.com\"", ",", "'first_name'", ":", "\"Test\"", ",", "'last_name'", ":", ...
[ 375, 4 ]
[ 392, 63 ]
python
en
['en', 'en', 'en']
True
TestUserCreateView.test_password_fields_not_shown_when_disabled
(self)
WAGTAILUSERS_PASSWORD_ENABLED=False should cause password fields to be removed
WAGTAILUSERS_PASSWORD_ENABLED=False should cause password fields to be removed
def test_password_fields_not_shown_when_disabled(self): """WAGTAILUSERS_PASSWORD_ENABLED=False should cause password fields to be removed""" response = self.get() self.assertEqual(response.status_code, 200) self.assertTemplateUsed(response, 'wagtailusers/users/create.html') self....
[ "def", "test_password_fields_not_shown_when_disabled", "(", "self", ")", ":", "response", "=", "self", ".", "get", "(", ")", "self", ".", "assertEqual", "(", "response", ".", "status_code", ",", "200", ")", "self", ".", "assertTemplateUsed", "(", "response", "...
[ 395, 4 ]
[ 401, 66 ]
python
en
['en', 'en', 'en']
True
TestUserCreateView.test_password_fields_ignored_when_disabled
(self)
When WAGTAILUSERS_PASSWORD_ENABLED is False, users should always be created without a usable password
When WAGTAILUSERS_PASSWORD_ENABLED is False, users should always be created without a usable password
def test_password_fields_ignored_when_disabled(self): """When WAGTAILUSERS_PASSWORD_ENABLED is False, users should always be created without a usable password""" response = self.post({ 'username': "testuser", 'email': "test@user.com", 'first_name': "Test", ...
[ "def", "test_password_fields_ignored_when_disabled", "(", "self", ")", ":", "response", "=", "self", ".", "post", "(", "{", "'username'", ":", "\"testuser\"", ",", "'email'", ":", "\"test@user.com\"", ",", "'first_name'", ":", "\"Test\"", ",", "'last_name'", ":", ...
[ 404, 4 ]
[ 421, 52 ]
python
en
['en', 'en', 'en']
True
TestUserEditView.test_password_optional
(self)
Leaving password fields blank should leave it unchanged
Leaving password fields blank should leave it unchanged
def test_password_optional(self): """Leaving password fields blank should leave it unchanged""" response = self.post({ 'username': "testuser", 'email': "test@user.com", 'first_name': "Edited", 'last_name': "User", 'password1': "", '...
[ "def", "test_password_optional", "(", "self", ")", ":", "response", "=", "self", ".", "post", "(", "{", "'username'", ":", "\"testuser\"", ",", "'email'", ":", "\"test@user.com\"", ",", "'first_name'", ":", "\"Edited\"", ",", "'last_name'", ":", "\"User\"", ",...
[ 682, 4 ]
[ 699, 56 ]
python
en
['en', 'fy', 'en']
True
TestUserEditView.test_passwords_match
(self)
Password fields should be validated if supplied
Password fields should be validated if supplied
def test_passwords_match(self): """Password fields should be validated if supplied""" response = self.post({ 'username': "testuser", 'email': "test@user.com", 'first_name': "Edited", 'last_name': "User", 'password1': "banana", 'pass...
[ "def", "test_passwords_match", "(", "self", ")", ":", "response", "=", "self", ".", "post", "(", "{", "'username'", ":", "\"testuser\"", ",", "'email'", ":", "\"test@user.com\"", ",", "'first_name'", ":", "\"Edited\"", ",", "'last_name'", ":", "\"User\"", ",",...
[ 701, 4 ]
[ 721, 56 ]
python
en
['en', 'en', 'en']
True
TestUserEditView.test_edit_with_password_validation
(self)
Test that the Django password validators are run when editing a user. Specifically test that the UserAttributeSimilarityValidator works, which requires a full-populated user model before the validation works.
Test that the Django password validators are run when editing a user. Specifically test that the UserAttributeSimilarityValidator works, which requires a full-populated user model before the validation works.
def test_edit_with_password_validation(self): """ Test that the Django password validators are run when editing a user. Specifically test that the UserAttributeSimilarityValidator works, which requires a full-populated user model before the validation works. """ # Create ...
[ "def", "test_edit_with_password_validation", "(", "self", ")", ":", "# Create a user with a password the same as their name", "response", "=", "self", ".", "post", "(", "{", "'username'", ":", "\"testuser\"", ",", "'email'", ":", "\"test@user.com\"", ",", "'first_name'", ...
[ 728, 4 ]
[ 756, 56 ]
python
en
['en', 'error', 'th']
False
TestUserEditView.test_cannot_demote_self
(self)
check that unsetting a user's own is_active or is_superuser flag has no effect
check that unsetting a user's own is_active or is_superuser flag has no effect
def test_cannot_demote_self(self): """ check that unsetting a user's own is_active or is_superuser flag has no effect """ response = self.post({ 'username': 'test@email.com', 'email': 'test@email.com', 'first_name': "Edited Myself", 'last_n...
[ "def", "test_cannot_demote_self", "(", "self", ")", ":", "response", "=", "self", ".", "post", "(", "{", "'username'", ":", "'test@email.com'", ",", "'email'", ":", "'test@email.com'", ",", "'first_name'", ":", "\"Edited Myself\"", ",", "'last_name'", ":", "\"Us...
[ 852, 4 ]
[ 880, 46 ]
python
en
['en', 'error', 'th']
False
TestUserEditView.test_password_fields_not_shown_when_disabled
(self)
WAGTAILUSERS_PASSWORD_ENABLED=False should cause password fields to be removed
WAGTAILUSERS_PASSWORD_ENABLED=False should cause password fields to be removed
def test_password_fields_not_shown_when_disabled(self): """WAGTAILUSERS_PASSWORD_ENABLED=False should cause password fields to be removed""" response = self.get() self.assertEqual(response.status_code, 200) self.assertTemplateUsed(response, 'wagtailusers/users/edit.html') self.as...
[ "def", "test_password_fields_not_shown_when_disabled", "(", "self", ")", ":", "response", "=", "self", ".", "get", "(", ")", "self", ".", "assertEqual", "(", "response", ".", "status_code", ",", "200", ")", "self", ".", "assertTemplateUsed", "(", "response", "...
[ 923, 4 ]
[ 929, 66 ]
python
en
['en', 'en', 'en']
True
TestUserEditView.test_password_fields_ignored_when_disabled
(self)
When WAGTAILUSERS_PASSWORD_REQUIRED is False, existing password should be left unchanged
When WAGTAILUSERS_PASSWORD_REQUIRED is False, existing password should be left unchanged
def test_password_fields_ignored_when_disabled(self): """When WAGTAILUSERS_PASSWORD_REQUIRED is False, existing password should be left unchanged""" response = self.post({ 'username': "testuser", 'email': "test@user.com", 'first_name': "Edited", 'last_name...
[ "def", "test_password_fields_ignored_when_disabled", "(", "self", ")", ":", "response", "=", "self", ".", "post", "(", "{", "'username'", ":", "\"testuser\"", ",", "'email'", ":", "\"test@user.com\"", ",", "'first_name'", ":", "\"Edited\"", ",", "'last_name'", ":"...
[ 932, 4 ]
[ 950, 56 ]
python
en
['en', 'en', 'en']
True
TestUserEditViewForNonSuperuser.test_user_cannot_escalate_privileges
(self)
Check that a non-superuser cannot edit their own is_active or is_superuser flag. (note: this doesn't necessarily guard against other routes to escalating privileges, such as creating a new user with is_superuser=True or adding oneself to a group with additional privileges - the latter w...
Check that a non-superuser cannot edit their own is_active or is_superuser flag. (note: this doesn't necessarily guard against other routes to escalating privileges, such as creating a new user with is_superuser=True or adding oneself to a group with additional privileges - the latter w...
def test_user_cannot_escalate_privileges(self): """ Check that a non-superuser cannot edit their own is_active or is_superuser flag. (note: this doesn't necessarily guard against other routes to escalating privileges, such as creating a new user with is_superuser=True or adding oneself t...
[ "def", "test_user_cannot_escalate_privileges", "(", "self", ")", ":", "editors_group", "=", "Group", ".", "objects", ".", "get", "(", "name", "=", "'User editors'", ")", "post_data", "=", "{", "'username'", ":", "\"editor\"", ",", "'email'", ":", "\"editor@email...
[ 1051, 4 ]
[ 1085, 50 ]
python
en
['en', 'error', 'th']
False
bulk_get_subscriber_peer_info
( realm: Realm, streams: List[Stream], )
Glossary: subscribed_ids: This shows the users who are actually subscribed to the stream, which we generally send to the person subscribing to the stream. private_peer_dict: These are the folks that need to know about a new subscriber. I...
Glossary:
def bulk_get_subscriber_peer_info( realm: Realm, streams: List[Stream], ) -> SubscriberPeerInfo: """ Glossary: subscribed_ids: This shows the users who are actually subscribed to the stream, which we generally send to the person subscribing to the stream. ...
[ "def", "bulk_get_subscriber_peer_info", "(", "realm", ":", "Realm", ",", "streams", ":", "List", "[", "Stream", "]", ",", ")", "->", "SubscriberPeerInfo", ":", "subscribed_ids", "=", "{", "}", "private_peer_dict", "=", "{", "}", "private_stream_ids", "=", "{",...
[ 147, 0 ]
[ 196, 5 ]
python
en
['en', 'error', 'th']
False
subscriber_ids_with_stream_history_access
(stream: Stream)
Returns the set of active user IDs who can access any message history on this stream (regardless of whether they have a UserMessage) based on the stream's configuration. 1. if !history_public_to_subscribers: History is not available to anyone 2. if history_public_to_subscribers: All...
Returns the set of active user IDs who can access any message history on this stream (regardless of whether they have a UserMessage) based on the stream's configuration.
def subscriber_ids_with_stream_history_access(stream: Stream) -> Set[int]: """Returns the set of active user IDs who can access any message history on this stream (regardless of whether they have a UserMessage) based on the stream's configuration. 1. if !history_public_to_subscribers: History...
[ "def", "subscriber_ids_with_stream_history_access", "(", "stream", ":", "Stream", ")", "->", "Set", "[", "int", "]", ":", "if", "not", "stream", ".", "is_history_public_to_subscribers", "(", ")", ":", "return", "set", "(", ")", "return", "set", "(", "get_activ...
[ 261, 0 ]
[ 283, 5 ]
python
en
['en', 'en', 'en']
True
get_subscriptions_for_send_message
( *, realm_id: int, stream_id: int, possible_wildcard_mention: bool, possibly_mentioned_user_ids: AbstractSet[int], )
This function optimizes an important use case for large streams. Open realms often have many long_term_idle users, which can result in 10,000s of long_term_idle recipients in default streams. do_send_messages has an optimization to avoid doing work for long_term_idle unless message flags or notification...
This function optimizes an important use case for large streams. Open realms often have many long_term_idle users, which can result in 10,000s of long_term_idle recipients in default streams. do_send_messages has an optimization to avoid doing work for long_term_idle unless message flags or notification...
def get_subscriptions_for_send_message( *, realm_id: int, stream_id: int, possible_wildcard_mention: bool, possibly_mentioned_user_ids: AbstractSet[int], ) -> QuerySet: """This function optimizes an important use case for large streams. Open realms often have many long_term_idle users, which...
[ "def", "get_subscriptions_for_send_message", "(", "*", ",", "realm_id", ":", "int", ",", "stream_id", ":", "int", ",", "possible_wildcard_mention", ":", "bool", ",", "possibly_mentioned_user_ids", ":", "AbstractSet", "[", "int", "]", ",", ")", "->", "QuerySet", ...
[ 286, 0 ]
[ 342, 16 ]
python
en
['en', 'en', 'en']
True
record_is_blocked
(record)
Given a log record, return True if it is considered to be blocked, return False if not
Given a log record, return True if it is considered to be blocked, return False if not
def record_is_blocked(record): """Given a log record, return True if it is considered to be blocked, return False if not """ for logger_name in LOGGER_BLOCKLIST: if record.name.startswith(logger_name): return True return False
[ "def", "record_is_blocked", "(", "record", ")", ":", "for", "logger_name", "in", "LOGGER_BLOCKLIST", ":", "if", "record", ".", "name", ".", "startswith", "(", "logger_name", ")", ":", "return", "True", "return", "False" ]
[ 54, 0 ]
[ 61, 16 ]
python
en
['en', 'en', 'en']
True
ExternalLoggerEnabled.filter
(self, record)
Filters out all log records if LOG_AGGREGATOR_ENABLED is False or if the particular logger is not in LOG_AGGREGATOR_LOGGERS should only be used for the external logger False - should not be logged True - should be logged
Filters out all log records if LOG_AGGREGATOR_ENABLED is False or if the particular logger is not in LOG_AGGREGATOR_LOGGERS should only be used for the external logger
def filter(self, record): """Filters out all log records if LOG_AGGREGATOR_ENABLED is False or if the particular logger is not in LOG_AGGREGATOR_LOGGERS should only be used for the external logger False - should not be logged True - should be logged """ # Do not ...
[ "def", "filter", "(", "self", ",", "record", ")", ":", "# Do not send exceptions to external logger", "if", "record_is_blocked", "(", "record", ")", ":", "return", "False", "# General enablement", "if", "not", "self", ".", "enabled_flag", ":", "return", "False", "...
[ 78, 4 ]
[ 105, 45 ]
python
en
['en', 'en', 'en']
True
DynamicLevelFilter.filter
(self, record)
Filters out logs that have a level below the threshold defined by the databse setting LOG_AGGREGATOR_LEVEL
Filters out logs that have a level below the threshold defined by the databse setting LOG_AGGREGATOR_LEVEL
def filter(self, record): """Filters out logs that have a level below the threshold defined by the databse setting LOG_AGGREGATOR_LEVEL """ if record_is_blocked(record): # Fine to write denied loggers to file, apply default filtering level cutoff_level = logging.W...
[ "def", "filter", "(", "self", ",", "record", ")", ":", "if", "record_is_blocked", "(", "record", ")", ":", "# Fine to write denied loggers to file, apply default filtering level", "cutoff_level", "=", "logging", ".", "WARNING", "else", ":", "try", ":", "cutoff_level",...
[ 109, 4 ]
[ 122, 51 ]
python
en
['en', 'en', 'en']
True
SmartFilter.query_from_string
(cls, filter_string)
TODO: * handle values with " via: a.b.c.d="hello\"world" * handle keys with " via: a.\"b.c="yeah" * handle key with __ in it
TODO: * handle values with " via: a.b.c.d="hello\"world" * handle keys with " via: a.\"b.c="yeah" * handle key with __ in it
def query_from_string(cls, filter_string): """ TODO: * handle values with " via: a.b.c.d="hello\"world" * handle keys with " via: a.\"b.c="yeah" * handle key with __ in it """ filter_string_raw = filter_string filter_string = str(filter_string) u...
[ "def", "query_from_string", "(", "cls", ",", "filter_string", ")", ":", "filter_string_raw", "=", "filter_string", "filter_string", "=", "str", "(", "filter_string", ")", "unicode_spaces", "=", "list", "(", "set", "(", "str", "(", "c", ")", "for", "c", "in",...
[ 328, 4 ]
[ 365, 94 ]
python
en
['en', 'error', 'th']
False
parse
(version)
Parse the given version string and return either a :class:`Version` object or a :class:`LegacyVersion` object depending on if the given version is a valid PEP 440 version or a legacy version.
Parse the given version string and return either a :class:`Version` object or a :class:`LegacyVersion` object depending on if the given version is a valid PEP 440 version or a legacy version.
def parse(version): # type: (str) -> Union[LegacyVersion, Version] """ Parse the given version string and return either a :class:`Version` object or a :class:`LegacyVersion` object depending on if the given version is a valid PEP 440 version or a legacy version. """ try: return Versi...
[ "def", "parse", "(", "version", ")", ":", "# type: (str) -> Union[LegacyVersion, Version]", "try", ":", "return", "Version", "(", "version", ")", "except", "InvalidVersion", ":", "return", "LegacyVersion", "(", "version", ")" ]
[ 47, 0 ]
[ 57, 37 ]
python
en
['en', 'error', 'th']
False
_parse_local_version
(local)
Takes a string like abc.1.twelve and turns it into ("abc", 1, "twelve").
Takes a string like abc.1.twelve and turns it into ("abc", 1, "twelve").
def _parse_local_version(local): # type: (str) -> Optional[LocalType] """ Takes a string like abc.1.twelve and turns it into ("abc", 1, "twelve"). """ if local is not None: return tuple( part.lower() if not part.isdigit() else int(part) for part in _local_version_sepa...
[ "def", "_parse_local_version", "(", "local", ")", ":", "# type: (str) -> Optional[LocalType]", "if", "local", "is", "not", "None", ":", "return", "tuple", "(", "part", ".", "lower", "(", ")", "if", "not", "part", ".", "isdigit", "(", ")", "else", "int", "(...
[ 460, 0 ]
[ 470, 15 ]
python
en
['en', 'error', 'th']
False
with_cleanup
(func)
Decorator for common logic related to managing temporary directories.
Decorator for common logic related to managing temporary directories.
def with_cleanup(func): # type: (Any) -> Any """Decorator for common logic related to managing temporary directories. """ def configure_tempdir_registry(registry): # type: (TempDirectoryTypeRegistry) -> None for t in KEEPABLE_TEMPDIR_TYPES: registry.set_delete(t, False) ...
[ "def", "with_cleanup", "(", "func", ")", ":", "# type: (Any) -> Any", "def", "configure_tempdir_registry", "(", "registry", ")", ":", "# type: (TempDirectoryTypeRegistry) -> None", "for", "t", "in", "KEEPABLE_TEMPDIR_TYPES", ":", "registry", ".", "set_delete", "(", "t",...
[ 162, 0 ]
[ 187, 18 ]
python
en
['en', 'en', 'en']
True
SessionCommandMixin._get_index_urls
(cls, options)
Return a list of index urls from user-provided options.
Return a list of index urls from user-provided options.
def _get_index_urls(cls, options): # type: (Values) -> Optional[List[str]] """Return a list of index urls from user-provided options.""" index_urls = [] if not getattr(options, "no_index", False): url = getattr(options, "index_url", None) if url: i...
[ "def", "_get_index_urls", "(", "cls", ",", "options", ")", ":", "# type: (Values) -> Optional[List[str]]", "index_urls", "=", "[", "]", "if", "not", "getattr", "(", "options", ",", "\"no_index\"", ",", "False", ")", ":", "url", "=", "getattr", "(", "options", ...
[ 59, 4 ]
[ 71, 33 ]
python
en
['en', 'en', 'en']
True
SessionCommandMixin.get_default_session
(self, options)
Get a default-managed session.
Get a default-managed session.
def get_default_session(self, options): # type: (Values) -> PipSession """Get a default-managed session.""" if self._session is None: self._session = self.enter_context(self._build_session(options)) # there's no type annotation on requests.Session, so it's # a...
[ "def", "get_default_session", "(", "self", ",", "options", ")", ":", "# type: (Values) -> PipSession", "if", "self", ".", "_session", "is", "None", ":", "self", ".", "_session", "=", "self", ".", "enter_context", "(", "self", ".", "_build_session", "(", "optio...
[ 73, 4 ]
[ 82, 28 ]
python
en
['en', 'da', 'en']
True
IndexGroupCommand.handle_pip_version_check
(self, options)
Do the pip version check if not disabled. This overrides the default behavior of not doing the check.
Do the pip version check if not disabled.
def handle_pip_version_check(self, options): # type: (Values) -> None """ Do the pip version check if not disabled. This overrides the default behavior of not doing the check. """ # Make sure the index_group options are present. assert hasattr(options, 'no_index'...
[ "def", "handle_pip_version_check", "(", "self", ",", "options", ")", ":", "# type: (Values) -> None", "# Make sure the index_group options are present.", "assert", "hasattr", "(", "options", ",", "'no_index'", ")", "if", "options", ".", "disable_pip_version_check", "or", ...
[ 132, 4 ]
[ 152, 52 ]
python
en
['en', 'error', 'th']
False
RequirementCommand.determine_resolver_variant
(options)
Determines which resolver should be used, based on the given options.
Determines which resolver should be used, based on the given options.
def determine_resolver_variant(options): # type: (Values) -> str """Determines which resolver should be used, based on the given options.""" # We didn't want to change things for Python 2, since it's nearly done with # and we're using performance improvements that only work on Python 3. ...
[ "def", "determine_resolver_variant", "(", "options", ")", ":", "# type: (Values) -> str", "# We didn't want to change things for Python 2, since it's nearly done with", "# and we're using performance improvements that only work on Python 3.", "if", "PY2", ":", "if", "'2020-resolver'", "i...
[ 199, 4 ]
[ 213, 30 ]
python
en
['en', 'en', 'en']
True
RequirementCommand.make_requirement_preparer
( cls, temp_build_dir, # type: TempDirectory options, # type: Values req_tracker, # type: RequirementTracker session, # type: PipSession finder, # type: PackageFinder use_user_site, ...
Create a RequirementPreparer instance for the given parameters.
Create a RequirementPreparer instance for the given parameters.
def make_requirement_preparer( cls, temp_build_dir, # type: TempDirectory options, # type: Values req_tracker, # type: RequirementTracker session, # type: PipSession finder, # type: PackageFinder ...
[ "def", "make_requirement_preparer", "(", "cls", ",", "temp_build_dir", ",", "# type: TempDirectory", "options", ",", "# type: Values", "req_tracker", ",", "# type: RequirementTracker", "session", ",", "# type: PipSession", "finder", ",", "# type: PackageFinder", "use_user_sit...
[ 216, 4 ]
[ 263, 9 ]
python
en
['en', 'error', 'th']
False
RequirementCommand.make_resolver
( cls, preparer, # type: RequirementPreparer finder, # type: PackageFinder options, # type: Values wheel_cache=None, # type: Optional[WheelCache] use_user_site=False, ...
Create a Resolver instance for the given parameters.
Create a Resolver instance for the given parameters.
def make_resolver( cls, preparer, # type: RequirementPreparer finder, # type: PackageFinder options, # type: Values wheel_cache=None, # type: Optional[WheelCache] use_us...
[ "def", "make_resolver", "(", "cls", ",", "preparer", ",", "# type: RequirementPreparer", "finder", ",", "# type: PackageFinder", "options", ",", "# type: Values", "wheel_cache", "=", "None", ",", "# type: Optional[WheelCache]", "use_user_site", "=", "False", ",", "# typ...
[ 266, 4 ]
[ 322, 9 ]
python
en
['en', 'error', 'th']
False
RequirementCommand.get_requirements
( self, args, # type: List[str] options, # type: Values finder, # type: PackageFinder session, # type: PipSession )
Parse command-line arguments into the corresponding requirements.
Parse command-line arguments into the corresponding requirements.
def get_requirements( self, args, # type: List[str] options, # type: Values finder, # type: PackageFinder session, # type: PipSession ): # type: (...) -> List[InstallRequirement] """ Parse command-line arguments ...
[ "def", "get_requirements", "(", "self", ",", "args", ",", "# type: List[str]", "options", ",", "# type: Values", "finder", ",", "# type: PackageFinder", "session", ",", "# type: PipSession", ")", ":", "# type: (...) -> List[InstallRequirement]", "requirements", "=", "[", ...
[ 324, 4 ]
[ 394, 27 ]
python
en
['en', 'error', 'th']
False
RequirementCommand.trace_basic_info
(finder)
Trace basic information about the provided objects.
Trace basic information about the provided objects.
def trace_basic_info(finder): # type: (PackageFinder) -> None """ Trace basic information about the provided objects. """ # Display where finder is looking for packages search_scope = finder.search_scope locations = search_scope.get_formatted_locations() i...
[ "def", "trace_basic_info", "(", "finder", ")", ":", "# type: (PackageFinder) -> None", "# Display where finder is looking for packages", "search_scope", "=", "finder", ".", "search_scope", "locations", "=", "search_scope", ".", "get_formatted_locations", "(", ")", "if", "lo...
[ 397, 4 ]
[ 406, 34 ]
python
en
['en', 'error', 'th']
False
RequirementCommand._build_package_finder
( self, options, # type: Values session, # type: PipSession target_python=None, # type: Optional[TargetPython] ignore_requires_python=None, # type: Optional[bool] )
Create a package finder appropriate to this requirement command. :param ignore_requires_python: Whether to ignore incompatible "Requires-Python" values in links. Defaults to False.
Create a package finder appropriate to this requirement command.
def _build_package_finder( self, options, # type: Values session, # type: PipSession target_python=None, # type: Optional[TargetPython] ignore_requires_python=None, # type: Optional[bool] ): # type: (...) -> PackageFinder """ ...
[ "def", "_build_package_finder", "(", "self", ",", "options", ",", "# type: Values", "session", ",", "# type: PipSession", "target_python", "=", "None", ",", "# type: Optional[TargetPython]", "ignore_requires_python", "=", "None", ",", "# type: Optional[bool]", ")", ":", ...
[ 408, 4 ]
[ 435, 9 ]
python
en
['en', 'error', 'th']
False
Container.kv_file
(self)
Get the name of the kv file, a lowercase version of the class name.
Get the name of the kv file, a lowercase version of the class name.
def kv_file(self): '''Get the name of the kv file, a lowercase version of the class name. ''' return os.path.join(CONTAINER_KVS, self.__class__.__name__ + '.kv')
[ "def", "kv_file", "(", "self", ")", ":", "return", "os", ".", "path", ".", "join", "(", "CONTAINER_KVS", ",", "self", ".", "__class__", ".", "__name__", "+", "'.kv'", ")" ]
[ 65, 4 ]
[ 69, 75 ]
python
en
['en', 'en', 'en']
True
Catalog.show_kv
(self, instance, value)
Called when an a item is selected, we need to show the .kv language file associated with the newly revealed container.
Called when an a item is selected, we need to show the .kv language file associated with the newly revealed container.
def show_kv(self, instance, value): '''Called when an a item is selected, we need to show the .kv language file associated with the newly revealed container.''' self.screen_manager.current = value child = self.screen_manager.current_screen.children[0] with open(child.kv_file, '...
[ "def", "show_kv", "(", "self", ",", "instance", ",", "value", ")", ":", "self", ".", "screen_manager", ".", "current", "=", "value", "child", "=", "self", ".", "screen_manager", ".", "current_screen", ".", "children", "[", "0", "]", "with", "open", "(", ...
[ 124, 4 ]
[ 137, 38 ]
python
en
['en', 'en', 'en']
True
Catalog.change_kv
(self, *largs)
Called when the update button is clicked. Needs to update the interface for the currently active kv widget, if there is one based on the kv file the user entered. If there is an error in their kv syntax, show a nice popup.
Called when the update button is clicked. Needs to update the interface for the currently active kv widget, if there is one based on the kv file the user entered. If there is an error in their kv syntax, show a nice popup.
def change_kv(self, *largs): '''Called when the update button is clicked. Needs to update the interface for the currently active kv widget, if there is one based on the kv file the user entered. If there is an error in their kv syntax, show a nice popup.''' txt = self.language_b...
[ "def", "change_kv", "(", "self", ",", "*", "largs", ")", ":", "txt", "=", "self", ".", "language_box", ".", "text", "kv_container", "=", "self", ".", "screen_manager", ".", "current_screen", ".", "children", "[", "0", "]", "try", ":", "parser", "=", "P...
[ 152, 4 ]
[ 169, 30 ]
python
en
['en', 'en', 'en']
True
CifarModel.__init__
(self, args)
TODO: Write Comment
TODO: Write Comment
def __init__(self, args): """ TODO: Write Comment """ self.input_shape = (32, 32, 3) Model.__init__(self, args)
[ "def", "__init__", "(", "self", ",", "args", ")", ":", "self", ".", "input_shape", "=", "(", "32", ",", "32", ",", "3", ")", "Model", ".", "__init__", "(", "self", ",", "args", ")" ]
[ 10, 4 ]
[ 16, 34 ]
python
en
['en', 'error', 'th']
False
CifarModel.dataset
(self)
TODO: Write Comment
TODO: Write Comment
def dataset(self): """ TODO: Write Comment """ from tensorflow.keras import datasets, utils import numpy as np self.num_images = {'train': 50000, 'test': 10000} if self.USE_DATASET == 0: self.num_classes = 10 self.data...
[ "def", "dataset", "(", "self", ")", ":", "from", "tensorflow", ".", "keras", "import", "datasets", ",", "utils", "import", "numpy", "as", "np", "self", ".", "num_images", "=", "{", "'train'", ":", "50000", ",", "'test'", ":", "10000", "}", "if", "self"...
[ 18, 4 ]
[ 70, 81 ]
python
en
['en', 'error', 'th']
False
BaseEngine.__init__
(self, params)
Initializes the template engine. Receives the configuration settings as a dict.
Initializes the template engine.
def __init__(self, params): """ Initializes the template engine. Receives the configuration settings as a dict. """ params = params.copy() self.name = params.pop('NAME') self.dirs = list(params.pop('DIRS')) self.app_dirs = bool(params.pop('APP_DIRS')) ...
[ "def", "__init__", "(", "self", ",", "params", ")", ":", "params", "=", "params", ".", "copy", "(", ")", "self", ".", "name", "=", "params", ".", "pop", "(", "'NAME'", ")", "self", ".", "dirs", "=", "list", "(", "params", ".", "pop", "(", "'DIRS'...
[ 16, 4 ]
[ 28, 67 ]
python
en
['en', 'error', 'th']
False
BaseEngine.from_string
(self, template_code)
Creates and returns a template for the given source code. This method is optional.
Creates and returns a template for the given source code.
def from_string(self, template_code): """ Creates and returns a template for the given source code. This method is optional. """ raise NotImplementedError( "subclasses of BaseEngine should provide " "a from_string() method")
[ "def", "from_string", "(", "self", ",", "template_code", ")", ":", "raise", "NotImplementedError", "(", "\"subclasses of BaseEngine should provide \"", "\"a from_string() method\"", ")" ]
[ 36, 4 ]
[ 44, 37 ]
python
en
['en', 'error', 'th']
False
BaseEngine.get_template
(self, template_name)
Loads and returns a template for the given name. Raises TemplateDoesNotExist if no such template exists.
Loads and returns a template for the given name.
def get_template(self, template_name): """ Loads and returns a template for the given name. Raises TemplateDoesNotExist if no such template exists. """ raise NotImplementedError( "subclasses of BaseEngine must provide " "a get_template() method")
[ "def", "get_template", "(", "self", ",", "template_name", ")", ":", "raise", "NotImplementedError", "(", "\"subclasses of BaseEngine must provide \"", "\"a get_template() method\"", ")" ]
[ 46, 4 ]
[ 54, 38 ]
python
en
['en', 'error', 'th']
False
BaseEngine.template_dirs
(self)
Returns a list of directories to search for templates.
Returns a list of directories to search for templates.
def template_dirs(self): """ Returns a list of directories to search for templates. """ # Immutable return value because it's cached and shared by callers. template_dirs = tuple(self.dirs) if self.app_dirs: template_dirs += get_app_template_dirs(self.app_dirna...
[ "def", "template_dirs", "(", "self", ")", ":", "# Immutable return value because it's cached and shared by callers.", "template_dirs", "=", "tuple", "(", "self", ".", "dirs", ")", "if", "self", ".", "app_dirs", ":", "template_dirs", "+=", "get_app_template_dirs", "(", ...
[ 60, 4 ]
[ 68, 28 ]
python
en
['en', 'error', 'th']
False
BaseEngine.iter_template_filenames
(self, template_name)
Iterates over candidate files for template_name. Ignores files that don't lie inside configured template dirs to avoid directory traversal attacks.
Iterates over candidate files for template_name.
def iter_template_filenames(self, template_name): """ Iterates over candidate files for template_name. Ignores files that don't lie inside configured template dirs to avoid directory traversal attacks. """ for template_dir in self.template_dirs: try: ...
[ "def", "iter_template_filenames", "(", "self", ",", "template_name", ")", ":", "for", "template_dir", "in", "self", ".", "template_dirs", ":", "try", ":", "yield", "safe_join", "(", "template_dir", ",", "template_name", ")", "except", "SuspiciousFileOperation", ":...
[ 70, 4 ]
[ 83, 20 ]
python
en
['en', 'error', 'th']
False
TestBackendConfiguration.test_http
(self)
Test that `HTTPBackend.purge` works when urlopen succeeds
Test that `HTTPBackend.purge` works when urlopen succeeds
def test_http(self): """Test that `HTTPBackend.purge` works when urlopen succeeds""" self._test_http_with_side_effect(urlopen_side_effect=None)
[ "def", "test_http", "(", "self", ")", ":", "self", ".", "_test_http_with_side_effect", "(", "urlopen_side_effect", "=", "None", ")" ]
[ 71, 4 ]
[ 73, 66 ]
python
en
['en', 'de', 'en']
True
TestBackendConfiguration.test_http_httperror
(self)
Test that `HTTPBackend.purge` can handle `HTTPError`
Test that `HTTPBackend.purge` can handle `HTTPError`
def test_http_httperror(self): """Test that `HTTPBackend.purge` can handle `HTTPError`""" http_error = HTTPError( url='http://localhost:8000/home/events/christmas/', code=500, msg='Internal Server Error', hdrs={}, fp=None ) with...
[ "def", "test_http_httperror", "(", "self", ")", ":", "http_error", "=", "HTTPError", "(", "url", "=", "'http://localhost:8000/home/events/christmas/'", ",", "code", "=", "500", ",", "msg", "=", "'Internal Server Error'", ",", "hdrs", "=", "{", "}", ",", "fp", ...
[ 75, 4 ]
[ 90, 9 ]
python
en
['en', 'en', 'en']
True
TestBackendConfiguration.test_http_urlerror
(self)
Test that `HTTPBackend.purge` can handle `URLError`
Test that `HTTPBackend.purge` can handle `URLError`
def test_http_urlerror(self): """Test that `HTTPBackend.purge` can handle `URLError`""" url_error = URLError(reason='just for tests') with self.assertLogs(level='ERROR') as log_output: self._test_http_with_side_effect(urlopen_side_effect=url_error) self.assertIn( ...
[ "def", "test_http_urlerror", "(", "self", ")", ":", "url_error", "=", "URLError", "(", "reason", "=", "'just for tests'", ")", "with", "self", ".", "assertLogs", "(", "level", "=", "'ERROR'", ")", "as", "log_output", ":", "self", ".", "_test_http_with_side_eff...
[ 92, 4 ]
[ 100, 9 ]
python
en
['en', 'de', 'en']
True
IntegrityChecker.__init__
(self, log_file)
Instantiate the sanity checker. Check files under the current directory. Write a report of issues to log_file.
Instantiate the sanity checker. Check files under the current directory. Write a report of issues to log_file.
def __init__(self, log_file): """Instantiate the sanity checker. Check files under the current directory. Write a report of issues to log_file.""" self.check_repo_path() self.logger = None self.setup_logger(log_file) self.files_to_check = ( ".c", ".h",...
[ "def", "__init__", "(", "self", ",", "log_file", ")", ":", "self", ".", "check_repo_path", "(", ")", "self", ".", "logger", "=", "None", "self", ".", "setup_logger", "(", "log_file", ")", "self", ".", "files_to_check", "=", "(", "\".c\"", ",", "\".h\"", ...
[ 189, 4 ]
[ 214, 9 ]
python
en
['en', 'en', 'en']
True
parse_marker
(marker_string)
Parse a marker string and return a dictionary containing a marker expression. The dictionary will contain keys "op", "lhs" and "rhs" for non-terminals in the expression grammar, or strings. A string contained in quotes is to be interpreted as a literal string, and a string not contained in quotes is a...
Parse a marker string and return a dictionary containing a marker expression.
def parse_marker(marker_string): """ Parse a marker string and return a dictionary containing a marker expression. The dictionary will contain keys "op", "lhs" and "rhs" for non-terminals in the expression grammar, or strings. A string contained in quotes is to be interpreted as a literal string, a...
[ "def", "parse_marker", "(", "marker_string", ")", ":", "def", "marker_var", "(", "remaining", ")", ":", "# either identifier, or literal string", "m", "=", "IDENTIFIER", ".", "match", "(", "remaining", ")", "if", "m", ":", "result", "=", "m", ".", "groups", ...
[ 55, 0 ]
[ 141, 32 ]
python
en
['en', 'error', 'th']
False
parse_requirement
(req)
Parse a requirement passed in as a string. Return a Container whose attributes contain the various parts of the requirement.
Parse a requirement passed in as a string. Return a Container whose attributes contain the various parts of the requirement.
def parse_requirement(req): """ Parse a requirement passed in as a string. Return a Container whose attributes contain the various parts of the requirement. """ remaining = req.strip() if not remaining or remaining.startswith('#'): return None m = IDENTIFIER.match(remaining) if n...
[ "def", "parse_requirement", "(", "req", ")", ":", "remaining", "=", "req", ".", "strip", "(", ")", "if", "not", "remaining", "or", "remaining", ".", "startswith", "(", "'#'", ")", ":", "return", "None", "m", "=", "IDENTIFIER", ".", "match", "(", "remai...
[ 144, 0 ]
[ 262, 63 ]
python
en
['en', 'error', 'th']
False
get_resources_dests
(resources_root, rules)
Find destinations for resources files
Find destinations for resources files
def get_resources_dests(resources_root, rules): """Find destinations for resources files""" def get_rel_path(root, path): # normalizes and returns a lstripped-/-separated path root = root.replace(os.path.sep, '/') path = path.replace(os.path.sep, '/') assert path.startswith(root...
[ "def", "get_resources_dests", "(", "resources_root", ",", "rules", ")", ":", "def", "get_rel_path", "(", "root", ",", "path", ")", ":", "# normalizes and returns a lstripped-/-separated path", "root", "=", "root", ".", "replace", "(", "os", ".", "path", ".", "se...
[ 265, 0 ]
[ 288, 23 ]
python
en
['en', 'en', 'en']
True
convert_path
(pathname)
Return 'pathname' as a name that will work on the native filesystem. The path is split on '/' and put back together again using the current directory separator. Needed because filenames in the setup script are always supplied in Unix style, and have to be converted to the local convention before we ca...
Return 'pathname' as a name that will work on the native filesystem.
def convert_path(pathname): """Return 'pathname' as a name that will work on the native filesystem. The path is split on '/' and put back together again using the current directory separator. Needed because filenames in the setup script are always supplied in Unix style, and have to be converted to th...
[ "def", "convert_path", "(", "pathname", ")", ":", "if", "os", ".", "sep", "==", "'/'", ":", "return", "pathname", "if", "not", "pathname", ":", "return", "pathname", "if", "pathname", "[", "0", "]", "==", "'/'", ":", "raise", "ValueError", "(", "\"path...
[ 450, 0 ]
[ 474, 31 ]
python
en
['en', 'en', 'en']
True
get_cache_base
(suffix=None)
Return the default base location for distlib caches. If the directory does not exist, it is created. Use the suffix provided for the base directory, and default to '.distlib' if it isn't provided. On Windows, if LOCALAPPDATA is defined in the environment, then it is assumed to be a directory, and ...
Return the default base location for distlib caches. If the directory does not exist, it is created. Use the suffix provided for the base directory, and default to '.distlib' if it isn't provided.
def get_cache_base(suffix=None): """ Return the default base location for distlib caches. If the directory does not exist, it is created. Use the suffix provided for the base directory, and default to '.distlib' if it isn't provided. On Windows, if LOCALAPPDATA is defined in the environment, then i...
[ "def", "get_cache_base", "(", "suffix", "=", "None", ")", ":", "if", "suffix", "is", "None", ":", "suffix", "=", "'.distlib'", "if", "os", ".", "name", "==", "'nt'", "and", "'LOCALAPPDATA'", "in", "os", ".", "environ", ":", "result", "=", "os", ".", ...
[ 739, 0 ]
[ 777, 39 ]
python
en
['en', 'error', 'th']
False
path_to_cache_dir
(path)
Convert an absolute path to a directory name for use in a cache. The algorithm used is: #. On Windows, any ``':'`` in the drive is replaced with ``'---'``. #. Any occurrence of ``os.sep`` is replaced with ``'--'``. #. ``'.cache'`` is appended.
Convert an absolute path to a directory name for use in a cache.
def path_to_cache_dir(path): """ Convert an absolute path to a directory name for use in a cache. The algorithm used is: #. On Windows, any ``':'`` in the drive is replaced with ``'---'``. #. Any occurrence of ``os.sep`` is replaced with ``'--'``. #. ``'.cache'`` is appended. """ d, p ...
[ "def", "path_to_cache_dir", "(", "path", ")", ":", "d", ",", "p", "=", "os", ".", "path", ".", "splitdrive", "(", "os", ".", "path", ".", "abspath", "(", "path", ")", ")", "if", "d", ":", "d", "=", "d", ".", "replace", "(", "':'", ",", "'---'",...
[ 780, 0 ]
[ 794, 27 ]
python
en
['en', 'error', 'th']
False
split_filename
(filename, project_name=None)
Extract name, version, python version from a filename (no extension) Return name, version, pyver or None
Extract name, version, python version from a filename (no extension)
def split_filename(filename, project_name=None): """ Extract name, version, python version from a filename (no extension) Return name, version, pyver or None """ result = None pyver = None filename = unquote(filename).replace(' ', '-') m = PYTHON_VERSION.search(filename) if m: ...
[ "def", "split_filename", "(", "filename", ",", "project_name", "=", "None", ")", ":", "result", "=", "None", "pyver", "=", "None", "filename", "=", "unquote", "(", "filename", ")", ".", "replace", "(", "' '", ",", "'-'", ")", "m", "=", "PYTHON_VERSION", ...
[ 838, 0 ]
[ 860, 17 ]
python
en
['en', 'error', 'th']
False
parse_name_and_version
(p)
A utility method used to get name and version from a string. From e.g. a Provides-Dist value. :param p: A value in a form 'foo (1.0)' :return: The name and version as a tuple.
A utility method used to get name and version from a string.
def parse_name_and_version(p): """ A utility method used to get name and version from a string. From e.g. a Provides-Dist value. :param p: A value in a form 'foo (1.0)' :return: The name and version as a tuple. """ m = NAME_VERSION_RE.match(p) if not m: raise DistlibException('...
[ "def", "parse_name_and_version", "(", "p", ")", ":", "m", "=", "NAME_VERSION_RE", ".", "match", "(", "p", ")", "if", "not", "m", ":", "raise", "DistlibException", "(", "'Ill-formed name/version string: \\'%s\\''", "%", "p", ")", "d", "=", "m", ".", "groupdic...
[ 866, 0 ]
[ 879, 46 ]
python
en
['en', 'error', 'th']
False
zip_dir
(directory)
zip a directory tree into a BytesIO object
zip a directory tree into a BytesIO object
def zip_dir(directory): """zip a directory tree into a BytesIO object""" result = io.BytesIO() dlen = len(directory) with ZipFile(result, "w") as zf: for root, dirs, files in os.walk(directory): for name in files: full = os.path.join(root, name) rel = ...
[ "def", "zip_dir", "(", "directory", ")", ":", "result", "=", "io", ".", "BytesIO", "(", ")", "dlen", "=", "len", "(", "directory", ")", "with", "ZipFile", "(", "result", ",", "\"w\"", ")", "as", "zf", ":", "for", "root", ",", "dirs", ",", "files", ...
[ 1252, 0 ]
[ 1263, 17 ]
python
en
['en', 'en', 'en']
True
iglob
(path_glob)
Extended globbing function that supports ** and {opt1,opt2,opt3}.
Extended globbing function that supports ** and {opt1,opt2,opt3}.
def iglob(path_glob): """Extended globbing function that supports ** and {opt1,opt2,opt3}.""" if _CHECK_RECURSIVE_GLOB.search(path_glob): msg = """invalid glob %r: recursive glob "**" must be used alone""" raise ValueError(msg % path_glob) if _CHECK_MISMATCH_SET.search(path_glob): ms...
[ "def", "iglob", "(", "path_glob", ")", ":", "if", "_CHECK_RECURSIVE_GLOB", ".", "search", "(", "path_glob", ")", ":", "msg", "=", "\"\"\"invalid glob %r: recursive glob \"**\" must be used alone\"\"\"", "raise", "ValueError", "(", "msg", "%", "path_glob", ")", "if", ...
[ 1370, 0 ]
[ 1378, 28 ]
python
en
['en', 'en', 'en']
True
normalize_name
(name)
Normalize a python package name a la PEP 503
Normalize a python package name a la PEP 503
def normalize_name(name): """Normalize a python package name a la PEP 503""" # https://www.python.org/dev/peps/pep-0503/#normalized-names return re.sub('[-_.]+', '-', name).lower()
[ "def", "normalize_name", "(", "name", ")", ":", "# https://www.python.org/dev/peps/pep-0503/#normalized-names", "return", "re", ".", "sub", "(", "'[-_.]+'", ",", "'-'", ",", "name", ")", ".", "lower", "(", ")" ]
[ 1757, 0 ]
[ 1760, 46 ]
python
en
['es', 'en', 'en']
True
FileOperator.newer
(self, source, target)
Tell if the target is newer than the source. Returns true if 'source' exists and is more recently modified than 'target', or if 'source' exists and 'target' doesn't. Returns false if both exist and 'target' is the same age or younger than 'source'. Raise PackagingFileError if 'source' ...
Tell if the target is newer than the source.
def newer(self, source, target): """Tell if the target is newer than the source. Returns true if 'source' exists and is more recently modified than 'target', or if 'source' exists and 'target' doesn't. Returns false if both exist and 'target' is the same age or younger than 'so...
[ "def", "newer", "(", "self", ",", "source", ",", "target", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "source", ")", ":", "raise", "DistlibException", "(", "\"file '%r' does not exist\"", "%", "os", ".", "path", ".", "abspath", "(", ...
[ 492, 4 ]
[ 510, 66 ]
python
en
['en', 'en', 'en']
True
FileOperator.copy_file
(self, infile, outfile, check=True)
Copy a file respecting dry-run and force flags.
Copy a file respecting dry-run and force flags.
def copy_file(self, infile, outfile, check=True): """Copy a file respecting dry-run and force flags. """ self.ensure_dir(os.path.dirname(outfile)) logger.info('Copying %s to %s', infile, outfile) if not self.dry_run: msg = None if check: if...
[ "def", "copy_file", "(", "self", ",", "infile", ",", "outfile", ",", "check", "=", "True", ")", ":", "self", ".", "ensure_dir", "(", "os", ".", "path", ".", "dirname", "(", "outfile", ")", ")", "logger", ".", "info", "(", "'Copying %s to %s'", ",", "...
[ 512, 4 ]
[ 527, 39 ]
python
en
['en', 'en', 'en']
True
FileOperator.commit
(self)
Commit recorded changes, turn off recording, return changes.
Commit recorded changes, turn off recording, return changes.
def commit(self): """ Commit recorded changes, turn off recording, return changes. """ assert self.record result = self.files_written, self.dirs_created self._init_record() return result
[ "def", "commit", "(", "self", ")", ":", "assert", "self", ".", "record", "result", "=", "self", ".", "files_written", ",", "self", ".", "dirs_created", "self", ".", "_init_record", "(", ")", "return", "result" ]
[ 632, 4 ]
[ 640, 21 ]
python
en
['en', 'error', 'th']
False
Cache.__init__
(self, base)
Initialise an instance. :param base: The base directory where the cache should be located.
Initialise an instance.
def __init__(self, base): """ Initialise an instance. :param base: The base directory where the cache should be located. """ # we use 'isdir' instead of 'exists', because we want to # fail if there's a file with that name if not os.path.isdir(base): # pragma: no...
[ "def", "__init__", "(", "self", ",", "base", ")", ":", "# we use 'isdir' instead of 'exists', because we want to", "# fail if there's a file with that name", "if", "not", "os", ".", "path", ".", "isdir", "(", "base", ")", ":", "# pragma: no cover", "os", ".", "makedir...
[ 947, 4 ]
[ 959, 59 ]
python
en
['en', 'error', 'th']
False
Cache.prefix_to_dir
(self, prefix)
Converts a resource prefix to a directory name in the cache.
Converts a resource prefix to a directory name in the cache.
def prefix_to_dir(self, prefix): """ Converts a resource prefix to a directory name in the cache. """ return path_to_cache_dir(prefix)
[ "def", "prefix_to_dir", "(", "self", ",", "prefix", ")", ":", "return", "path_to_cache_dir", "(", "prefix", ")" ]
[ 961, 4 ]
[ 965, 40 ]
python
en
['en', 'error', 'th']
False
Cache.clear
(self)
Clear the cache.
Clear the cache.
def clear(self): """ Clear the cache. """ not_removed = [] for fn in os.listdir(self.base): fn = os.path.join(self.base, fn) try: if os.path.islink(fn) or os.path.isfile(fn): os.remove(fn) elif os.path.is...
[ "def", "clear", "(", "self", ")", ":", "not_removed", "=", "[", "]", "for", "fn", "in", "os", ".", "listdir", "(", "self", ".", "base", ")", ":", "fn", "=", "os", ".", "path", ".", "join", "(", "self", ".", "base", ",", "fn", ")", "try", ":",...
[ 967, 4 ]
[ 981, 26 ]
python
en
['en', 'error', 'th']
False
EventMixin.add
(self, event, subscriber, append=True)
Add a subscriber for an event. :param event: The name of an event. :param subscriber: The subscriber to be added (and called when the event is published). :param append: Whether to append or prepend the subscriber to an existing subscri...
Add a subscriber for an event.
def add(self, event, subscriber, append=True): """ Add a subscriber for an event. :param event: The name of an event. :param subscriber: The subscriber to be added (and called when the event is published). :param append: Whether to append or prepend th...
[ "def", "add", "(", "self", ",", "event", ",", "subscriber", ",", "append", "=", "True", ")", ":", "subs", "=", "self", ".", "_subscribers", "if", "event", "not", "in", "subs", ":", "subs", "[", "event", "]", "=", "deque", "(", "[", "subscriber", "]...
[ 991, 4 ]
[ 1009, 41 ]
python
en
['en', 'error', 'th']
False
EventMixin.remove
(self, event, subscriber)
Remove a subscriber for an event. :param event: The name of an event. :param subscriber: The subscriber to be removed.
Remove a subscriber for an event.
def remove(self, event, subscriber): """ Remove a subscriber for an event. :param event: The name of an event. :param subscriber: The subscriber to be removed. """ subs = self._subscribers if event not in subs: raise ValueError('No subscribers: %r' % ...
[ "def", "remove", "(", "self", ",", "event", ",", "subscriber", ")", ":", "subs", "=", "self", ".", "_subscribers", "if", "event", "not", "in", "subs", ":", "raise", "ValueError", "(", "'No subscribers: %r'", "%", "event", ")", "subs", "[", "event", "]", ...
[ 1011, 4 ]
[ 1021, 38 ]
python
en
['en', 'error', 'th']
False
EventMixin.get_subscribers
(self, event)
Return an iterator for the subscribers for an event. :param event: The event to return subscribers for.
Return an iterator for the subscribers for an event. :param event: The event to return subscribers for.
def get_subscribers(self, event): """ Return an iterator for the subscribers for an event. :param event: The event to return subscribers for. """ return iter(self._subscribers.get(event, ()))
[ "def", "get_subscribers", "(", "self", ",", "event", ")", ":", "return", "iter", "(", "self", ".", "_subscribers", ".", "get", "(", "event", ",", "(", ")", ")", ")" ]
[ 1023, 4 ]
[ 1028, 53 ]
python
en
['en', 'error', 'th']
False
EventMixin.publish
(self, event, *args, **kwargs)
Publish a event and return a list of values returned by its subscribers. :param event: The event to publish. :param args: The positional arguments to pass to the event's subscribers. :param kwargs: The keyword arguments to pass to the event's ...
Publish a event and return a list of values returned by its subscribers.
def publish(self, event, *args, **kwargs): """ Publish a event and return a list of values returned by its subscribers. :param event: The event to publish. :param args: The positional arguments to pass to the event's subscribers. :param kwargs: The k...
[ "def", "publish", "(", "self", ",", "event", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "result", "=", "[", "]", "for", "subscriber", "in", "self", ".", "get_subscribers", "(", "event", ")", ":", "try", ":", "value", "=", "subscriber", "(...
[ 1030, 4 ]
[ 1051, 21 ]
python
en
['en', 'error', 'th']
False
Configurator.inc_convert
(self, value)
Default converter for the inc:// protocol.
Default converter for the inc:// protocol.
def inc_convert(self, value): """Default converter for the inc:// protocol.""" if not os.path.isabs(value): value = os.path.join(self.base, value) with codecs.open(value, 'r', encoding='utf-8') as f: result = json.load(f) return result
[ "def", "inc_convert", "(", "self", ",", "value", ")", ":", "if", "not", "os", ".", "path", ".", "isabs", "(", "value", ")", ":", "value", "=", "os", ".", "path", ".", "join", "(", "self", ".", "base", ",", "value", ")", "with", "codecs", ".", "...
[ 1702, 4 ]
[ 1708, 21 ]
python
en
['en', 'en', 'en']
True
SubprocessMixin.reader
(self, stream, context)
Read lines from a subprocess' output stream and either pass to a progress callable (if specified) or write progress information to sys.stderr.
Read lines from a subprocess' output stream and either pass to a progress callable (if specified) or write progress information to sys.stderr.
def reader(self, stream, context): """ Read lines from a subprocess' output stream and either pass to a progress callable (if specified) or write progress information to sys.stderr. """ progress = self.progress verbose = self.verbose while True: s = st...
[ "def", "reader", "(", "self", ",", "stream", ",", "context", ")", ":", "progress", "=", "self", ".", "progress", "verbose", "=", "self", ".", "verbose", "while", "True", ":", "s", "=", "stream", ".", "readline", "(", ")", "if", "not", "s", ":", "br...
[ 1719, 4 ]
[ 1738, 22 ]
python
en
['en', 'error', 'th']
False
OracleOperations.geo_db_type
(self, f)
Returns the geometry database type for Oracle. Unlike other spatial backends, no stored procedure is necessary and it's the same for all geometry types.
Returns the geometry database type for Oracle. Unlike other spatial backends, no stored procedure is necessary and it's the same for all geometry types.
def geo_db_type(self, f): """ Returns the geometry database type for Oracle. Unlike other spatial backends, no stored procedure is necessary and it's the same for all geometry types. """ return 'MDSYS.SDO_GEOMETRY'
[ "def", "geo_db_type", "(", "self", ",", "f", ")", ":", "return", "'MDSYS.SDO_GEOMETRY'" ]
[ 192, 4 ]
[ 198, 35 ]
python
en
['en', 'error', 'th']
False
OracleOperations.get_distance
(self, f, value, lookup_type, **kwargs)
Returns the distance parameters given the value and the lookup type. On Oracle, geometry columns with a geodetic coordinate system behave implicitly like a geography column, and thus meters will be used as the distance parameter on them.
Returns the distance parameters given the value and the lookup type. On Oracle, geometry columns with a geodetic coordinate system behave implicitly like a geography column, and thus meters will be used as the distance parameter on them.
def get_distance(self, f, value, lookup_type, **kwargs): """ Returns the distance parameters given the value and the lookup type. On Oracle, geometry columns with a geodetic coordinate system behave implicitly like a geography column, and thus meters will be used as the distance ...
[ "def", "get_distance", "(", "self", ",", "f", ",", "value", ",", "lookup_type", ",", "*", "*", "kwargs", ")", ":", "if", "not", "value", ":", "return", "[", "]", "value", "=", "value", "[", "0", "]", "if", "isinstance", "(", "value", ",", "Distance...
[ 200, 4 ]
[ 223, 27 ]
python
en
['en', 'error', 'th']
False