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
MirroredMessageUsersTest.test_zephyr_mirror_new_sender
(self, ignored: object)
Test mirror dummy user creation for sender when sending to stream
Test mirror dummy user creation for sender when sending to stream
def test_zephyr_mirror_new_sender(self, ignored: object) -> None: """Test mirror dummy user creation for sender when sending to stream""" client = get_client(name="zephyr_mirror") user = self.mit_user("starnine") sender_email = "new_sender@mit.edu" recipients = ["stream_name"] ...
[ "def", "test_zephyr_mirror_new_sender", "(", "self", ",", "ignored", ":", "object", ")", "->", "None", ":", "client", "=", "get_client", "(", "name", "=", "\"zephyr_mirror\"", ")", "user", "=", "self", ".", "mit_user", "(", "\"starnine\"", ")", "sender_email",...
[ 93, 4 ]
[ 110, 54 ]
python
en
['en', 'no', 'en']
True
set_collection_path_collation
(apps, schema_editor)
Treebeard's path comparison logic can fail on certain locales such as sk_SK, which sort numbers after letters. To avoid this, we explicitly set the collation for the 'path' column to the (non-locale-specific) 'C' collation. See: https://groups.google.com/d/msg/wagtail/q0leyuCnYWI/I9uDvVlyBAAJ
Treebeard's path comparison logic can fail on certain locales such as sk_SK, which sort numbers after letters. To avoid this, we explicitly set the collation for the 'path' column to the (non-locale-specific) 'C' collation.
def set_collection_path_collation(apps, schema_editor): """ Treebeard's path comparison logic can fail on certain locales such as sk_SK, which sort numbers after letters. To avoid this, we explicitly set the collation for the 'path' column to the (non-locale-specific) 'C' collation. See: https://gr...
[ "def", "set_collection_path_collation", "(", "apps", ",", "schema_editor", ")", ":", "if", "schema_editor", ".", "connection", ".", "vendor", "==", "'postgresql'", ":", "schema_editor", ".", "execute", "(", "\"\"\"\n ALTER TABLE wagtailcore_collection ALTER COLUM...
[ 4, 0 ]
[ 15, 12 ]
python
en
['en', 'error', 'th']
False
ManhattanDistance.distance
(self, x, y)
Computes the Manhattan distance between vectors x and y. Returns float.
Computes the Manhattan distance between vectors x and y. Returns float.
def distance(self, x, y): """ Computes the Manhattan distance between vectors x and y. Returns float. """ if scipy.sparse.issparse(x): return numpy.sum(numpy.absolute((x-y).toarray().ravel())) else: return numpy.sum(numpy.absolute(x-y))
[ "def", "distance", "(", "self", ",", "x", ",", "y", ")", ":", "if", "scipy", ".", "sparse", ".", "issparse", "(", "x", ")", ":", "return", "numpy", ".", "sum", "(", "numpy", ".", "absolute", "(", "(", "x", "-", "y", ")", ".", "toarray", "(", ...
[ 31, 4 ]
[ 38, 49 ]
python
en
['en', 'error', 'th']
False
name_to_smiles
(name)
Convert from chemical name to SMILES string using chemical identifier resolver. Parameters ---------- name : str Name or nickname of compound. Returns ---------- str SMILES string corresponding to chemical name.
Convert from chemical name to SMILES string using chemical identifier resolver. Parameters ---------- name : str Name or nickname of compound. Returns ---------- str SMILES string corresponding to chemical name.
def name_to_smiles(name): """Convert from chemical name to SMILES string using chemical identifier resolver. Parameters ---------- name : str Name or nickname of compound. Returns ---------- str SMILES string corresponding to chemical name. """ name =...
[ "def", "name_to_smiles", "(", "name", ")", ":", "name", "=", "name", ".", "replace", "(", "' '", ",", "'%20'", ")", "try", ":", "url", "=", "'http://cactus.nci.nih.gov/chemical/structure/'", "+", "name", "+", "'/smiles'", "smiles", "=", "urlopen", "(", "url"...
[ 19, 0 ]
[ 44, 23 ]
python
en
['en', 'en', 'en']
True
ChemDraw.__init__
(self, SMILES_list, row_size='auto', legends=None, ipython_svg=True)
Parameters ---------- SMILES_list : list List of SMILES strings to be visualized. row_size : 'auto', int Number of structures to include per row. legends : None, list Structure legends to include below representations. ipytho...
Parameters ---------- SMILES_list : list List of SMILES strings to be visualized. row_size : 'auto', int Number of structures to include per row. legends : None, list Structure legends to include below representations. ipytho...
def __init__(self, SMILES_list, row_size='auto', legends=None, ipython_svg=True): """ Parameters ---------- SMILES_list : list List of SMILES strings to be visualized. row_size : 'auto', int Number of structures to include per r...
[ "def", "__init__", "(", "self", ",", "SMILES_list", ",", "row_size", "=", "'auto'", ",", "legends", "=", "None", ",", "ipython_svg", "=", "True", ")", ":", "self", ".", "SMILES_list", "=", "list", "(", "SMILES_list", ")", "self", ".", "legends", "=", "...
[ 51, 4 ]
[ 81, 30 ]
python
en
['en', 'ja', 'th']
False
ChemDraw.show
(self)
Show 2D representation of SMILES strings. Returns ---------- image Visualization of chemical structures.
Show 2D representation of SMILES strings. Returns ---------- image Visualization of chemical structures.
def show(self): """Show 2D representation of SMILES strings. Returns ---------- image Visualization of chemical structures. """ img = Chem.Draw.MolsToGridImage(self.mols, molsPerRow=self.molsPerRow, ...
[ "def", "show", "(", "self", ")", ":", "img", "=", "Chem", ".", "Draw", ".", "MolsToGridImage", "(", "self", ".", "mols", ",", "molsPerRow", "=", "self", ".", "molsPerRow", ",", "subImgSize", "=", "(", "200", ",", "200", ")", ",", "legends", "=", "s...
[ 83, 4 ]
[ 100, 28 ]
python
en
['en', 'en', 'en']
True
ChemDraw.export
(self, path)
Export 2D representation of SMILES strings. Parameters ---------- path : 'str' Export a PNG image of chemical structures to path. Returns ---------- None
Export 2D representation of SMILES strings. Parameters ---------- path : 'str' Export a PNG image of chemical structures to path. Returns ---------- None
def export(self, path): """Export 2D representation of SMILES strings. Parameters ---------- path : 'str' Export a PNG image of chemical structures to path. Returns ---------- None """ img = Chem.Draw.MolsToGr...
[ "def", "export", "(", "self", ",", "path", ")", ":", "img", "=", "Chem", ".", "Draw", ".", "MolsToGridImage", "(", "self", ".", "mols", ",", "molsPerRow", "=", "self", ".", "molsPerRow", ",", "subImgSize", "=", "(", "500", ",", "500", ")", ",", "le...
[ 102, 4 ]
[ 123, 31 ]
python
en
['en', 'en', 'en']
True
connect_and_get_peer
(server_1: KaleServer, server_2: KaleServer)
Connect server_2 to server_1, and get return the connection in server_1.
Connect server_2 to server_1, and get return the connection in server_1.
async def connect_and_get_peer(server_1: KaleServer, server_2: KaleServer) -> WSKaleConnection: """ Connect server_2 to server_1, and get return the connection in server_1. """ await server_2.start_client(PeerInfo(self_hostname, uint16(server_1._port))) async def connected(): for node_id_c,...
[ "async", "def", "connect_and_get_peer", "(", "server_1", ":", "KaleServer", ",", "server_2", ":", "KaleServer", ")", "->", "WSKaleConnection", ":", "await", "server_2", ".", "start_client", "(", "PeerInfo", "(", "self_hostname", ",", "uint16", "(", "server_1", "...
[ 66, 0 ]
[ 82, 16 ]
python
en
['en', 'error', 'th']
False
test_jt_existing_values_are_nonsensitive
(job_template_with_ids, user_unit)
Assure that permission checks are not required if submitted data is identical to what the job template already has.
Assure that permission checks are not required if submitted data is identical to what the job template already has.
def test_jt_existing_values_are_nonsensitive(job_template_with_ids, user_unit): """Assure that permission checks are not required if submitted data is identical to what the job template already has.""" data = model_to_dict(job_template_with_ids, exclude=['unifiedjobtemplate_ptr']) access = JobTemplateA...
[ "def", "test_jt_existing_values_are_nonsensitive", "(", "job_template_with_ids", ",", "user_unit", ")", ":", "data", "=", "model_to_dict", "(", "job_template_with_ids", ",", "exclude", "=", "[", "'unifiedjobtemplate_ptr'", "]", ")", "access", "=", "JobTemplateAccess", "...
[ 152, 0 ]
[ 159, 72 ]
python
en
['en', 'en', 'en']
True
test_change_jt_sensitive_data
(job_template_with_ids, mocker, user_unit)
Assure that can_add is called with all ForeignKeys.
Assure that can_add is called with all ForeignKeys.
def test_change_jt_sensitive_data(job_template_with_ids, mocker, user_unit): """Assure that can_add is called with all ForeignKeys.""" class RoleReturnsTrue(Role): class Meta: proxy = True def __contains__(self, accessor): return True job_template_with_ids.admin_ro...
[ "def", "test_change_jt_sensitive_data", "(", "job_template_with_ids", ",", "mocker", ",", "user_unit", ")", ":", "class", "RoleReturnsTrue", "(", "Role", ")", ":", "class", "Meta", ":", "proxy", "=", "True", "def", "__contains__", "(", "self", ",", "accessor", ...
[ 162, 0 ]
[ 185, 57 ]
python
en
['en', 'en', 'en']
True
test_jt_can_add_bad_data
(user_unit)
Assure that no server errors are returned if we call JT can_add with bad data
Assure that no server errors are returned if we call JT can_add with bad data
def test_jt_can_add_bad_data(user_unit): "Assure that no server errors are returned if we call JT can_add with bad data" access = JobTemplateAccess(user_unit) assert not access.can_add({'asdf': 'asdf'})
[ "def", "test_jt_can_add_bad_data", "(", "user_unit", ")", ":", "access", "=", "JobTemplateAccess", "(", "user_unit", ")", "assert", "not", "access", ".", "can_add", "(", "{", "'asdf'", ":", "'asdf'", "}", ")" ]
[ 192, 0 ]
[ 195, 47 ]
python
en
['en', 'en', 'en']
True
test_user_capabilities_method
()
Unit test to verify that the user_capabilities method will defer to the appropriate sub-class methods of the access classes. Note that normal output is True/False, but a string is returned in these tests to establish uniqueness.
Unit test to verify that the user_capabilities method will defer to the appropriate sub-class methods of the access classes. Note that normal output is True/False, but a string is returned in these tests to establish uniqueness.
def test_user_capabilities_method(): """Unit test to verify that the user_capabilities method will defer to the appropriate sub-class methods of the access classes. Note that normal output is True/False, but a string is returned in these tests to establish uniqueness. """ class FooAccess(BaseAc...
[ "def", "test_user_capabilities_method", "(", ")", ":", "class", "FooAccess", "(", "BaseAccess", ")", ":", "def", "can_change", "(", "self", ",", "obj", ",", "data", ")", ":", "return", "'bar'", "def", "can_copy", "(", "self", ",", "obj", ")", ":", "retur...
[ 221, 0 ]
[ 239, 61 ]
python
en
['en', 'en', 'en']
True
TestRelatedFieldAccess.test_new_optional_fail
(self, access, resource_bad, mocker)
User tries to create a new resource, but lacks permission to the related resource they provided
User tries to create a new resource, but lacks permission to the related resource they provided
def test_new_optional_fail(self, access, resource_bad, mocker): """ User tries to create a new resource, but lacks permission to the related resource they provided """ data = {'related': resource_bad} assert not access.check_related('related', mocker.MagicMock, data)
[ "def", "test_new_optional_fail", "(", "self", ",", "access", ",", "resource_bad", ",", "mocker", ")", ":", "data", "=", "{", "'related'", ":", "resource_bad", "}", "assert", "not", "access", ".", "check_related", "(", "'related'", ",", "mocker", ".", "MagicM...
[ 39, 4 ]
[ 45, 74 ]
python
en
['en', 'error', 'th']
False
TestRelatedFieldAccess.test_existing_no_op
(self, access, resource_bad, mocker)
User edits a resource, but does not change related field lack of access to related field does not block action
User edits a resource, but does not change related field lack of access to related field does not block action
def test_existing_no_op(self, access, resource_bad, mocker): """ User edits a resource, but does not change related field lack of access to related field does not block action """ data = {'related': resource_bad.related} assert access.check_related('related', mocker.Magic...
[ "def", "test_existing_no_op", "(", "self", ",", "access", ",", "resource_bad", ",", "mocker", ")", ":", "data", "=", "{", "'related'", ":", "resource_bad", ".", "related", "}", "assert", "access", ".", "check_related", "(", "'related'", ",", "mocker", ".", ...
[ 57, 4 ]
[ 64, 86 ]
python
en
['en', 'error', 'th']
False
TestRelatedFieldAccess.test_existing_no_access_to_current
(self, access, resource_good, resource_bad, mocker)
User gives a valid related resource (like organization), but does not have access to _existing_ related resource, so deny action
User gives a valid related resource (like organization), but does not have access to _existing_ related resource, so deny action
def test_existing_no_access_to_current(self, access, resource_good, resource_bad, mocker): """ User gives a valid related resource (like organization), but does not have access to _existing_ related resource, so deny action """ data = {'related': resource_good} assert not...
[ "def", "test_existing_no_access_to_current", "(", "self", ",", "access", ",", "resource_good", ",", "resource_bad", ",", "mocker", ")", ":", "data", "=", "{", "'related'", ":", "resource_good", "}", "assert", "not", "access", ".", "check_related", "(", "'related...
[ 71, 4 ]
[ 77, 92 ]
python
en
['en', 'error', 'th']
False
TradeStore.add_trade_record
(self, record: TradeRecord, in_transaction)
Store TradeRecord into DB
Store TradeRecord into DB
async def add_trade_record(self, record: TradeRecord, in_transaction) -> None: """ Store TradeRecord into DB """ if not in_transaction: await self.db_wrapper.lock.acquire() try: cursor = await self.db_connection.execute( "INSERT OR REPLACE ...
[ "async", "def", "add_trade_record", "(", "self", ",", "record", ":", "TradeRecord", ",", "in_transaction", ")", "->", "None", ":", "if", "not", "in_transaction", ":", "await", "self", ".", "db_wrapper", ".", "lock", ".", "acquire", "(", ")", "try", ":", ...
[ 58, 4 ]
[ 80, 46 ]
python
en
['en', 'error', 'th']
False
TradeStore.set_status
(self, trade_id: bytes32, status: TradeStatus, in_transaction: bool, index: uint32 = uint32(0))
Updates the status of the trade
Updates the status of the trade
async def set_status(self, trade_id: bytes32, status: TradeStatus, in_transaction: bool, index: uint32 = uint32(0)): """ Updates the status of the trade """ current: Optional[TradeRecord] = await self.get_trade_record(trade_id) if current is None: return None ...
[ "async", "def", "set_status", "(", "self", ",", "trade_id", ":", "bytes32", ",", "status", ":", "TradeStatus", ",", "in_transaction", ":", "bool", ",", "index", ":", "uint32", "=", "uint32", "(", "0", ")", ")", ":", "current", ":", "Optional", "[", "Tr...
[ 82, 4 ]
[ 106, 55 ]
python
en
['en', 'error', 'th']
False
TradeStore.increment_sent
( self, id: bytes32, name: str, send_status: MempoolInclusionStatus, err: Optional[Err], )
Updates trade sent count (Full Node has received spend_bundle and sent ack).
Updates trade sent count (Full Node has received spend_bundle and sent ack).
async def increment_sent( self, id: bytes32, name: str, send_status: MempoolInclusionStatus, err: Optional[Err], ) -> bool: """ Updates trade sent count (Full Node has received spend_bundle and sent ack). """ current: Optional[TradeRecord] = a...
[ "async", "def", "increment_sent", "(", "self", ",", "id", ":", "bytes32", ",", "name", ":", "str", ",", "send_status", ":", "MempoolInclusionStatus", ",", "err", ":", "Optional", "[", "Err", "]", ",", ")", "->", "bool", ":", "current", ":", "Optional", ...
[ 108, 4 ]
[ 150, 19 ]
python
en
['en', 'error', 'th']
False
TradeStore.set_not_sent
(self, id: bytes32)
Updates trade sent count to 0.
Updates trade sent count to 0.
async def set_not_sent(self, id: bytes32): """ Updates trade sent count to 0. """ current: Optional[TradeRecord] = await self.get_trade_record(id) if current is None: return None tx: TradeRecord = TradeRecord( confirmed_at_index=current.confirmed...
[ "async", "def", "set_not_sent", "(", "self", ",", "id", ":", "bytes32", ")", ":", "current", ":", "Optional", "[", "TradeRecord", "]", "=", "await", "self", ".", "get_trade_record", "(", "id", ")", "if", "current", "is", "None", ":", "return", "None", ...
[ 152, 4 ]
[ 176, 46 ]
python
en
['en', 'error', 'th']
False
TradeStore.get_trade_record
(self, trade_id: bytes32)
Checks DB for TradeRecord with id: id and returns it.
Checks DB for TradeRecord with id: id and returns it.
async def get_trade_record(self, trade_id: bytes32) -> Optional[TradeRecord]: """ Checks DB for TradeRecord with id: id and returns it. """ cursor = await self.db_connection.execute("SELECT * from trade_records WHERE trade_id=?", (trade_id.hex(),)) row = await cursor.fetchone() ...
[ "async", "def", "get_trade_record", "(", "self", ",", "trade_id", ":", "bytes32", ")", "->", "Optional", "[", "TradeRecord", "]", ":", "cursor", "=", "await", "self", ".", "db_connection", ".", "execute", "(", "\"SELECT * from trade_records WHERE trade_id=?\"", ",...
[ 178, 4 ]
[ 188, 19 ]
python
en
['en', 'error', 'th']
False
TradeStore.get_trade_record_with_status
(self, status: TradeStatus)
Checks DB for TradeRecord with id: id and returns it.
Checks DB for TradeRecord with id: id and returns it.
async def get_trade_record_with_status(self, status: TradeStatus) -> List[TradeRecord]: """ Checks DB for TradeRecord with id: id and returns it. """ cursor = await self.db_connection.execute("SELECT * from trade_records WHERE status=?", (status.value,)) rows = await cursor.fetch...
[ "async", "def", "get_trade_record_with_status", "(", "self", ",", "status", ":", "TradeStatus", ")", "->", "List", "[", "TradeRecord", "]", ":", "cursor", "=", "await", "self", ".", "db_connection", ".", "execute", "(", "\"SELECT * from trade_records WHERE status=?\...
[ 190, 4 ]
[ 202, 22 ]
python
en
['en', 'error', 'th']
False
TradeStore.get_not_sent
(self)
Returns the list of trades that have not been received by full node yet.
Returns the list of trades that have not been received by full node yet.
async def get_not_sent(self) -> List[TradeRecord]: """ Returns the list of trades that have not been received by full node yet. """ cursor = await self.db_connection.execute( "SELECT * from trade_records WHERE sent<? and confirmed=?", ( 4, ...
[ "async", "def", "get_not_sent", "(", "self", ")", "->", "List", "[", "TradeRecord", "]", ":", "cursor", "=", "await", "self", ".", "db_connection", ".", "execute", "(", "\"SELECT * from trade_records WHERE sent<? and confirmed=?\"", ",", "(", "4", ",", "0", ",",...
[ 204, 4 ]
[ 223, 22 ]
python
en
['en', 'error', 'th']
False
TradeStore.get_all_unconfirmed
(self)
Returns the list of all trades that have not yet been confirmed.
Returns the list of all trades that have not yet been confirmed.
async def get_all_unconfirmed(self) -> List[TradeRecord]: """ Returns the list of all trades that have not yet been confirmed. """ cursor = await self.db_connection.execute("SELECT * from trade_records WHERE confirmed=?", (0,)) rows = await cursor.fetchall() await cursor...
[ "async", "def", "get_all_unconfirmed", "(", "self", ")", "->", "List", "[", "TradeRecord", "]", ":", "cursor", "=", "await", "self", ".", "db_connection", ".", "execute", "(", "\"SELECT * from trade_records WHERE confirmed=?\"", ",", "(", "0", ",", ")", ")", "...
[ 225, 4 ]
[ 239, 22 ]
python
en
['en', 'error', 'th']
False
TradeStore.get_all_trades
(self)
Returns all stored trades.
Returns all stored trades.
async def get_all_trades(self) -> List[TradeRecord]: """ Returns all stored trades. """ cursor = await self.db_connection.execute("SELECT * from trade_records") rows = await cursor.fetchall() await cursor.close() records = [] for row in rows: ...
[ "async", "def", "get_all_trades", "(", "self", ")", "->", "List", "[", "TradeRecord", "]", ":", "cursor", "=", "await", "self", ".", "db_connection", ".", "execute", "(", "\"SELECT * from trade_records\"", ")", "rows", "=", "await", "cursor", ".", "fetchall", ...
[ 241, 4 ]
[ 255, 22 ]
python
en
['en', 'error', 'th']
False
Worker.__init__
(self, age, ppid, sockets, app, timeout, cfg, log)
\ This is called pre-fork so it shouldn't do anything to the current process. If there's a need to make process wide changes you'll want to do that in ``self.init_process()``.
\ This is called pre-fork so it shouldn't do anything to the current process. If there's a need to make process wide changes you'll want to do that in ``self.init_process()``.
def __init__(self, age, ppid, sockets, app, timeout, cfg, log): """\ This is called pre-fork so it shouldn't do anything to the current process. If there's a need to make process wide changes you'll want to do that in ``self.init_process()``. """ self.age = age se...
[ "def", "__init__", "(", "self", ",", "age", ",", "ppid", ",", "sockets", ",", "app", ",", "timeout", ",", "cfg", ",", "log", ")", ":", "self", ".", "age", "=", "age", "self", ".", "pid", "=", "\"[booting]\"", "self", ".", "ppid", "=", "ppid", "se...
[ 35, 4 ]
[ 62, 33 ]
python
en
['en', 'ja', 'hi']
False
Worker.notify
(self)
\ Your worker subclass must arrange to have this method called once every ``self.timeout`` seconds. If you fail in accomplishing this task, the master process will murder your workers.
\ Your worker subclass must arrange to have this method called once every ``self.timeout`` seconds. If you fail in accomplishing this task, the master process will murder your workers.
def notify(self): """\ Your worker subclass must arrange to have this method called once every ``self.timeout`` seconds. If you fail in accomplishing this task, the master process will murder your workers. """ self.tmp.notify()
[ "def", "notify", "(", "self", ")", ":", "self", ".", "tmp", ".", "notify", "(", ")" ]
[ 67, 4 ]
[ 73, 25 ]
python
en
['en', 'ja', 'hi']
False
Worker.run
(self)
\ This is the mainloop of a worker process. You should override this method in a subclass to provide the intended behaviour for your particular evil schemes.
\ This is the mainloop of a worker process. You should override this method in a subclass to provide the intended behaviour for your particular evil schemes.
def run(self): """\ This is the mainloop of a worker process. You should override this method in a subclass to provide the intended behaviour for your particular evil schemes. """ raise NotImplementedError()
[ "def", "run", "(", "self", ")", ":", "raise", "NotImplementedError", "(", ")" ]
[ 75, 4 ]
[ 81, 35 ]
python
en
['en', 'ja', 'hi']
False
Worker.init_process
(self)
\ If you override this method in a subclass, the last statement in the function should be to call this method with super().init_process() so that the ``run()`` loop is initiated.
\ If you override this method in a subclass, the last statement in the function should be to call this method with super().init_process() so that the ``run()`` loop is initiated.
def init_process(self): """\ If you override this method in a subclass, the last statement in the function should be to call this method with super().init_process() so that the ``run()`` loop is initiated. """ # set environment' variables if self.cfg.env: ...
[ "def", "init_process", "(", "self", ")", ":", "# set environment' variables", "if", "self", ".", "cfg", ".", "env", ":", "for", "k", ",", "v", "in", "self", ".", "cfg", ".", "env", ".", "items", "(", ")", ":", "os", ".", "environ", "[", "k", "]", ...
[ 83, 4 ]
[ 139, 18 ]
python
en
['en', 'ja', 'hi']
False
TestPageUrlTags.test_pageurl_with_valid_url_string_fallback
(self)
`django.shortcuts.resolve_url` accepts strings containing '.' or '/' as they are.
`django.shortcuts.resolve_url` accepts strings containing '.' or '/' as they are.
def test_pageurl_with_valid_url_string_fallback(self): """ `django.shortcuts.resolve_url` accepts strings containing '.' or '/' as they are. """ tpl = template.Template( """ {% load wagtailcore_tags %} <a href="{% pageurl page fallback='.' %}">Same pag...
[ "def", "test_pageurl_with_valid_url_string_fallback", "(", "self", ")", ":", "tpl", "=", "template", ".", "Template", "(", "\"\"\"\n {% load wagtailcore_tags %}\n <a href=\"{% pageurl page fallback='.' %}\">Same page fallback</a>\n <a href=\"{% pageurl page f...
[ 43, 4 ]
[ 58, 71 ]
python
en
['en', 'error', 'th']
False
TestPageUrlTags.test_pageurl_with_invalid_url_string_fallback
(self)
Strings not containing '.' or '/', and not matching a named URL will error.
Strings not containing '.' or '/', and not matching a named URL will error.
def test_pageurl_with_invalid_url_string_fallback(self): """ Strings not containing '.' or '/', and not matching a named URL will error. """ tpl = template.Template( """{% load wagtailcore_tags %}<a href="{% pageurl page fallback='not-existing-endpoint' %}">Fallback</a>""" ...
[ "def", "test_pageurl_with_invalid_url_string_fallback", "(", "self", ")", ":", "tpl", "=", "template", ".", "Template", "(", "\"\"\"{% load wagtailcore_tags %}<a href=\"{% pageurl page fallback='not-existing-endpoint' %}\">Fallback</a>\"\"\"", ")", "with", "self", ".", "assertRaise...
[ 60, 4 ]
[ 68, 56 ]
python
en
['en', 'error', 'th']
False
TestSiteRootPathsCache.test_cache
(self)
This tests that the cache is populated when building URLs
This tests that the cache is populated when building URLs
def test_cache(self): """ This tests that the cache is populated when building URLs """ # Get homepage homepage = Page.objects.get(url_path='/home/') # Warm up the cache by getting the url _ = homepage.url # noqa # Check that the cache has been set corr...
[ "def", "test_cache", "(", "self", ")", ":", "# Get homepage", "homepage", "=", "Page", ".", "objects", ".", "get", "(", "url_path", "=", "'/home/'", ")", "# Warm up the cache by getting the url", "_", "=", "homepage", ".", "url", "# noqa", "# Check that the cache ...
[ 184, 4 ]
[ 195, 158 ]
python
en
['en', 'error', 'th']
False
TestSiteRootPathsCache.test_cache_clears_when_site_saved
(self)
This tests that the cache is cleared whenever a site is saved
This tests that the cache is cleared whenever a site is saved
def test_cache_clears_when_site_saved(self): """ This tests that the cache is cleared whenever a site is saved """ # Get homepage homepage = Page.objects.get(url_path='/home/') # Warm up the cache by getting the url _ = homepage.url # noqa # Check that ...
[ "def", "test_cache_clears_when_site_saved", "(", "self", ")", ":", "# Get homepage", "homepage", "=", "Page", ".", "objects", ".", "get", "(", "url_path", "=", "'/home/'", ")", "# Warm up the cache by getting the url", "_", "=", "homepage", ".", "url", "# noqa", "...
[ 197, 4 ]
[ 214, 62 ]
python
en
['en', 'error', 'th']
False
TestSiteRootPathsCache.test_cache_clears_when_site_deleted
(self)
This tests that the cache is cleared whenever a site is deleted
This tests that the cache is cleared whenever a site is deleted
def test_cache_clears_when_site_deleted(self): """ This tests that the cache is cleared whenever a site is deleted """ # Get homepage homepage = Page.objects.get(url_path='/home/') # Warm up the cache by getting the url _ = homepage.url # noqa # Check t...
[ "def", "test_cache_clears_when_site_deleted", "(", "self", ")", ":", "# Get homepage", "homepage", "=", "Page", ".", "objects", ".", "get", "(", "url_path", "=", "'/home/'", ")", "# Warm up the cache by getting the url", "_", "=", "homepage", ".", "url", "# noqa", ...
[ 216, 4 ]
[ 233, 62 ]
python
en
['en', 'error', 'th']
False
TestSiteRootPathsCache.test_cache_clears_when_site_root_moves
(self)
This tests for an issue where if a site root page was moved, all the page urls in that site would change to None. The issue was caused by the 'wagtail_site_root_paths' cache variable not being cleared when a site root page was moved. Which left all the child pages thinking that...
This tests for an issue where if a site root page was moved, all the page urls in that site would change to None.
def test_cache_clears_when_site_root_moves(self): """ This tests for an issue where if a site root page was moved, all the page urls in that site would change to None. The issue was caused by the 'wagtail_site_root_paths' cache variable not being cleared when a site root page wa...
[ "def", "test_cache_clears_when_site_root_moves", "(", "self", ")", ":", "# Get homepage, root page and site", "root_page", "=", "Page", ".", "objects", ".", "get", "(", "id", "=", "1", ")", "homepage", "=", "Page", ".", "objects", ".", "get", "(", "url_path", ...
[ 235, 4 ]
[ 271, 47 ]
python
en
['en', 'error', 'th']
False
TestSiteRootPathsCache.test_cache_clears_when_site_root_slug_changes
(self)
This tests for an issue where if a site root pages slug was changed, all the page urls in that site would change to None. The issue was caused by the 'wagtail_site_root_paths' cache variable not being cleared when a site root page was changed. Which left all the child pages thi...
This tests for an issue where if a site root pages slug was changed, all the page urls in that site would change to None.
def test_cache_clears_when_site_root_slug_changes(self): """ This tests for an issue where if a site root pages slug was changed, all the page urls in that site would change to None. The issue was caused by the 'wagtail_site_root_paths' cache variable not being cleared when a si...
[ "def", "test_cache_clears_when_site_root_slug_changes", "(", "self", ")", ":", "# Get homepage", "homepage", "=", "Page", ".", "objects", ".", "get", "(", "url_path", "=", "'/home/'", ")", "# Warm up the cache by getting the url", "_", "=", "homepage", ".", "url", "...
[ 273, 4 ]
[ 301, 43 ]
python
en
['en', 'error', 'th']
False
CollectionPermissionLookupMixin._get_permission_objects_for_actions
(self, actions)
Get a queryset of the Permission objects for the given actions
Get a queryset of the Permission objects for the given actions
def _get_permission_objects_for_actions(self, actions): """ Get a queryset of the Permission objects for the given actions """ permission_codenames = ['%s_%s' % (action, self.model_name) for action in actions] return Permission.objects.filter( content_type=self._conte...
[ "def", "_get_permission_objects_for_actions", "(", "self", ",", "actions", ")", ":", "permission_codenames", "=", "[", "'%s_%s'", "%", "(", "action", ",", "self", ".", "model_name", ")", "for", "action", "in", "actions", "]", "return", "Permission", ".", "obje...
[ 11, 4 ]
[ 19, 9 ]
python
en
['en', 'error', 'th']
False
CollectionPermissionLookupMixin._check_perm
(self, user, actions, collection=None)
Equivalent to user.has_perm(self._get_permission_name(action)) on all listed actions, but using GroupCollectionPermission rather than group.permissions. If collection is specified, only consider GroupCollectionPermission records that apply to that collection.
Equivalent to user.has_perm(self._get_permission_name(action)) on all listed actions, but using GroupCollectionPermission rather than group.permissions. If collection is specified, only consider GroupCollectionPermission records that apply to that collection.
def _check_perm(self, user, actions, collection=None): """ Equivalent to user.has_perm(self._get_permission_name(action)) on all listed actions, but using GroupCollectionPermission rather than group.permissions. If collection is specified, only consider GroupCollectionPermission records ...
[ "def", "_check_perm", "(", "self", ",", "user", ",", "actions", ",", "collection", "=", "None", ")", ":", "if", "not", "(", "user", ".", "is_active", "and", "user", ".", "is_authenticated", ")", ":", "return", "False", "if", "user", ".", "is_superuser", ...
[ 21, 4 ]
[ 44, 46 ]
python
en
['en', 'error', 'th']
False
CollectionPermissionLookupMixin._collections_with_perm
(self, user, actions)
Return a queryset of collections on which this user has a GroupCollectionPermission record for any of the given actions, either on the collection itself or an ancestor
Return a queryset of collections on which this user has a GroupCollectionPermission record for any of the given actions, either on the collection itself or an ancestor
def _collections_with_perm(self, user, actions): """ Return a queryset of collections on which this user has a GroupCollectionPermission record for any of the given actions, either on the collection itself or an ancestor """ # Get the permission objects corresponding to these act...
[ "def", "_collections_with_perm", "(", "self", ",", "user", ",", "actions", ")", ":", "# Get the permission objects corresponding to these actions", "permissions", "=", "self", ".", "_get_permission_objects_for_actions", "(", "actions", ")", "# Get the collections that have a Gr...
[ 46, 4 ]
[ 72, 44 ]
python
en
['en', 'error', 'th']
False
CollectionPermissionLookupMixin._users_with_perm_filter
(self, actions, collection=None)
Return a filter expression that will filter a user queryset to those with any permissions corresponding to 'actions', via either GroupCollectionPermission or superuser privileges. If collection is specified, only consider GroupCollectionPermission records that apply to that coll...
Return a filter expression that will filter a user queryset to those with any permissions corresponding to 'actions', via either GroupCollectionPermission or superuser privileges. If collection is specified, only consider GroupCollectionPermission records that apply to that coll...
def _users_with_perm_filter(self, actions, collection=None): """ Return a filter expression that will filter a user queryset to those with any permissions corresponding to 'actions', via either GroupCollectionPermission or superuser privileges. If collection is specified, only co...
[ "def", "_users_with_perm_filter", "(", "self", ",", "actions", ",", "collection", "=", "None", ")", ":", "permissions", "=", "self", ".", "_get_permission_objects_for_actions", "(", "actions", ")", "# Find all groups with GroupCollectionPermission records for", "# any of th...
[ 74, 4 ]
[ 96, 80 ]
python
en
['en', 'error', 'th']
False
CollectionPermissionLookupMixin._users_with_perm
(self, actions, collection=None)
Return a queryset of users with any permissions corresponding to 'actions', via either GroupCollectionPermission or superuser privileges. If collection is specified, only consider GroupCollectionPermission records that apply to that collection.
Return a queryset of users with any permissions corresponding to 'actions', via either GroupCollectionPermission or superuser privileges. If collection is specified, only consider GroupCollectionPermission records that apply to that collection.
def _users_with_perm(self, actions, collection=None): """ Return a queryset of users with any permissions corresponding to 'actions', via either GroupCollectionPermission or superuser privileges. If collection is specified, only consider GroupCollectionPermission records that app...
[ "def", "_users_with_perm", "(", "self", ",", "actions", ",", "collection", "=", "None", ")", ":", "return", "get_user_model", "(", ")", ".", "objects", ".", "filter", "(", "self", ".", "_users_with_perm_filter", "(", "actions", ",", "collection", "=", "colle...
[ 98, 4 ]
[ 107, 20 ]
python
en
['en', 'error', 'th']
False
CollectionPermissionLookupMixin.collections_user_has_permission_for
(self, user, action)
Return a queryset of all collections in which the given user has permission to perform the given action
Return a queryset of all collections in which the given user has permission to perform the given action
def collections_user_has_permission_for(self, user, action): """ Return a queryset of all collections in which the given user has permission to perform the given action """ return self.collections_user_has_any_permission_for(user, [action])
[ "def", "collections_user_has_permission_for", "(", "self", ",", "user", ",", "action", ")", ":", "return", "self", ".", "collections_user_has_any_permission_for", "(", "user", ",", "[", "action", "]", ")" ]
[ 109, 4 ]
[ 114, 75 ]
python
en
['en', 'error', 'th']
False
CollectionPermissionPolicy.user_has_permission
(self, user, action)
Return whether the given user has permission to perform the given action on some or all instances of this model
Return whether the given user has permission to perform the given action on some or all instances of this model
def user_has_permission(self, user, action): """ Return whether the given user has permission to perform the given action on some or all instances of this model """ return self._check_perm(user, [action])
[ "def", "user_has_permission", "(", "self", ",", "user", ",", "action", ")", ":", "return", "self", ".", "_check_perm", "(", "user", ",", "[", "action", "]", ")" ]
[ 124, 4 ]
[ 129, 47 ]
python
en
['en', 'error', 'th']
False
CollectionPermissionPolicy.user_has_any_permission
(self, user, actions)
Return whether the given user has permission to perform any of the given actions on some or all instances of this model
Return whether the given user has permission to perform any of the given actions on some or all instances of this model
def user_has_any_permission(self, user, actions): """ Return whether the given user has permission to perform any of the given actions on some or all instances of this model """ return self._check_perm(user, actions)
[ "def", "user_has_any_permission", "(", "self", ",", "user", ",", "actions", ")", ":", "return", "self", ".", "_check_perm", "(", "user", ",", "actions", ")" ]
[ 131, 4 ]
[ 136, 46 ]
python
en
['en', 'error', 'th']
False
CollectionPermissionPolicy.users_with_any_permission
(self, actions)
Return a queryset of users who have permission to perform any of the given actions on some or all instances of this model
Return a queryset of users who have permission to perform any of the given actions on some or all instances of this model
def users_with_any_permission(self, actions): """ Return a queryset of users who have permission to perform any of the given actions on some or all instances of this model """ return self._users_with_perm(actions)
[ "def", "users_with_any_permission", "(", "self", ",", "actions", ")", ":", "return", "self", ".", "_users_with_perm", "(", "actions", ")" ]
[ 138, 4 ]
[ 143, 45 ]
python
en
['en', 'error', 'th']
False
CollectionPermissionPolicy.user_has_permission_for_instance
(self, user, action, instance)
Return whether the given user has permission to perform the given action on the given model instance
Return whether the given user has permission to perform the given action on the given model instance
def user_has_permission_for_instance(self, user, action, instance): """ Return whether the given user has permission to perform the given action on the given model instance """ return self._check_perm(user, [action], collection=instance.collection)
[ "def", "user_has_permission_for_instance", "(", "self", ",", "user", ",", "action", ",", "instance", ")", ":", "return", "self", ".", "_check_perm", "(", "user", ",", "[", "action", "]", ",", "collection", "=", "instance", ".", "collection", ")" ]
[ 145, 4 ]
[ 150, 79 ]
python
en
['en', 'error', 'th']
False
CollectionPermissionPolicy.user_has_any_permission_for_instance
(self, user, actions, instance)
Return whether the given user has permission to perform any of the given actions on the given model instance
Return whether the given user has permission to perform any of the given actions on the given model instance
def user_has_any_permission_for_instance(self, user, actions, instance): """ Return whether the given user has permission to perform any of the given actions on the given model instance """ return self._check_perm(user, actions, collection=instance.collection)
[ "def", "user_has_any_permission_for_instance", "(", "self", ",", "user", ",", "actions", ",", "instance", ")", ":", "return", "self", ".", "_check_perm", "(", "user", ",", "actions", ",", "collection", "=", "instance", ".", "collection", ")" ]
[ 152, 4 ]
[ 157, 78 ]
python
en
['en', 'error', 'th']
False
CollectionPermissionPolicy.instances_user_has_any_permission_for
(self, user, actions)
Return a queryset of all instances of this model for which the given user has permission to perform any of the given actions
Return a queryset of all instances of this model for which the given user has permission to perform any of the given actions
def instances_user_has_any_permission_for(self, user, actions): """ Return a queryset of all instances of this model for which the given user has permission to perform any of the given actions """ if not (user.is_active and user.is_authenticated): return self.model.ob...
[ "def", "instances_user_has_any_permission_for", "(", "self", ",", "user", ",", "actions", ")", ":", "if", "not", "(", "user", ".", "is_active", "and", "user", ".", "is_authenticated", ")", ":", "return", "self", ".", "model", ".", "objects", ".", "none", "...
[ 159, 4 ]
[ 172, 13 ]
python
en
['en', 'error', 'th']
False
CollectionPermissionPolicy.users_with_any_permission_for_instance
(self, actions, instance)
Return a queryset of all users who have permission to perform any of the given actions on the given model instance
Return a queryset of all users who have permission to perform any of the given actions on the given model instance
def users_with_any_permission_for_instance(self, actions, instance): """ Return a queryset of all users who have permission to perform any of the given actions on the given model instance """ return self._users_with_perm(actions, collection=instance.collection)
[ "def", "users_with_any_permission_for_instance", "(", "self", ",", "actions", ",", "instance", ")", ":", "return", "self", ".", "_users_with_perm", "(", "actions", ",", "collection", "=", "instance", ".", "collection", ")" ]
[ 174, 4 ]
[ 179, 77 ]
python
en
['en', 'error', 'th']
False
CollectionPermissionPolicy.collections_user_has_any_permission_for
(self, user, actions)
Return a queryset of all collections in which the given user has permission to perform any of the given actions
Return a queryset of all collections in which the given user has permission to perform any of the given actions
def collections_user_has_any_permission_for(self, user, actions): """ Return a queryset of all collections in which the given user has permission to perform any of the given actions """ if user.is_active and user.is_superuser: # active superusers can perform any actio...
[ "def", "collections_user_has_any_permission_for", "(", "self", ",", "user", ",", "actions", ")", ":", "if", "user", ".", "is_active", "and", "user", ".", "is_superuser", ":", "# active superusers can perform any action (including unrecognised ones)", "# in any collection", ...
[ 181, 4 ]
[ 195, 61 ]
python
en
['en', 'error', 'th']
False
CollectionOwnershipPermissionPolicy.collections_user_has_any_permission_for
(self, user, actions)
Return a queryset of all collections in which the given user has permission to perform any of the given actions
Return a queryset of all collections in which the given user has permission to perform any of the given actions
def collections_user_has_any_permission_for(self, user, actions): """ Return a queryset of all collections in which the given user has permission to perform any of the given actions """ if user.is_active and user.is_superuser: # active superusers can perform any actio...
[ "def", "collections_user_has_any_permission_for", "(", "self", ",", "user", ",", "actions", ")", ":", "if", "user", ".", "is_active", "and", "user", ".", "is_superuser", ":", "# active superusers can perform any action (including unrecognised ones)", "# in any collection", ...
[ 341, 4 ]
[ 369, 44 ]
python
en
['en', 'error', 'th']
False
EmailBackend.send_messages
(self, messages)
Redirect messages to the dummy outbox
Redirect messages to the dummy outbox
def send_messages(self, messages): """Redirect messages to the dummy outbox""" msg_count = 0 for message in messages: # .message() triggers header validation message.message() mail.outbox.append(message) msg_count += 1 return msg_count
[ "def", "send_messages", "(", "self", ",", "messages", ")", ":", "msg_count", "=", "0", "for", "message", "in", "messages", ":", "# .message() triggers header validation", "message", ".", "message", "(", ")", "mail", ".", "outbox", ".", "append", "(", "message"...
[ 21, 4 ]
[ 28, 24 ]
python
en
['en', 'en', 'en']
True
GetIncludedBuildFiles
(build_file_path, aux_data, included=None)
Return a list of all build files included into build_file_path. The returned list will contain build_file_path as well as all other files that it included, either directly or indirectly. Note that the list may contain files that were included into a conditional section that evaluated to false and was not merg...
Return a list of all build files included into build_file_path.
def GetIncludedBuildFiles(build_file_path, aux_data, included=None): """Return a list of all build files included into build_file_path. The returned list will contain build_file_path as well as all other files that it included, either directly or indirectly. Note that the list may contain files that were in...
[ "def", "GetIncludedBuildFiles", "(", "build_file_path", ",", "aux_data", ",", "included", "=", "None", ")", ":", "if", "included", "is", "None", ":", "included", "=", "[", "]", "if", "build_file_path", "in", "included", ":", "return", "included", "included", ...
[ 141, 0 ]
[ 171, 19 ]
python
en
['en', 'en', 'en']
True
CheckedEval
(file_contents)
Return the eval of a gyp file. The gyp file is restricted to dictionaries and lists only, and repeated keys are not allowed. Note that this is slower than eval() is.
Return the eval of a gyp file. The gyp file is restricted to dictionaries and lists only, and repeated keys are not allowed. Note that this is slower than eval() is.
def CheckedEval(file_contents): """Return the eval of a gyp file. The gyp file is restricted to dictionaries and lists only, and repeated keys are not allowed. Note that this is slower than eval() is. """ syntax_tree = ast.parse(file_contents) assert isinstance(syntax_tree, ast.Module) c1 = syn...
[ "def", "CheckedEval", "(", "file_contents", ")", ":", "syntax_tree", "=", "ast", ".", "parse", "(", "file_contents", ")", "assert", "isinstance", "(", "syntax_tree", ",", "ast", ".", "Module", ")", "c1", "=", "syntax_tree", ".", "body", "assert", "len", "(...
[ 174, 0 ]
[ 187, 34 ]
python
en
['en', 'en', 'en']
True
CallLoadTargetBuildFile
( global_flags, build_file_path, variables, includes, depth, check, generator_input_info, )
Wrapper around LoadTargetBuildFile for parallel processing. This wrapper is used when LoadTargetBuildFile is executed in a worker process.
Wrapper around LoadTargetBuildFile for parallel processing.
def CallLoadTargetBuildFile( global_flags, build_file_path, variables, includes, depth, check, generator_input_info, ): """Wrapper around LoadTargetBuildFile for parallel processing. This wrapper is used when LoadTargetBuildFile is executed in a worker process. """ try:...
[ "def", "CallLoadTargetBuildFile", "(", "global_flags", ",", "build_file_path", ",", "variables", ",", "includes", ",", "depth", ",", "check", ",", "generator_input_info", ",", ")", ":", "try", ":", "signal", ".", "signal", "(", "signal", ".", "SIGINT", ",", ...
[ 510, 0 ]
[ 562, 19 ]
python
en
['en', 'en', 'en']
True
IsStrCanonicalInt
(string)
Returns True if |string| is in its canonical integer form. The canonical form is such that str(int(string)) == string.
Returns True if |string| is in its canonical integer form.
def IsStrCanonicalInt(string): """Returns True if |string| is in its canonical integer form. The canonical form is such that str(int(string)) == string. """ if type(string) is str: # This function is called a lot so for maximum performance, avoid # involving regexps which would otherwise ma...
[ "def", "IsStrCanonicalInt", "(", "string", ")", ":", "if", "type", "(", "string", ")", "is", "str", ":", "# This function is called a lot so for maximum performance, avoid", "# involving regexps which would otherwise make the code much", "# shorter. Regexps would need twice the time ...
[ 702, 0 ]
[ 721, 16 ]
python
en
['en', 'en', 'en']
True
EvalCondition
(condition, conditions_key, phase, variables, build_file)
Returns the dict that should be used or None if the result was that nothing should be used.
Returns the dict that should be used or None if the result was that nothing should be used.
def EvalCondition(condition, conditions_key, phase, variables, build_file): """Returns the dict that should be used or None if the result was that nothing should be used.""" if type(condition) is not list: raise GypError(conditions_key + " must be a list") if len(condition) < 2: # It's pos...
[ "def", "EvalCondition", "(", "condition", ",", "conditions_key", ",", "phase", ",", "variables", ",", "build_file", ")", ":", "if", "type", "(", "condition", ")", "is", "not", "list", ":", "raise", "GypError", "(", "conditions_key", "+", "\" must be a list\"",...
[ 1136, 0 ]
[ 1180, 17 ]
python
en
['en', 'en', 'en']
True
EvalSingleCondition
(cond_expr, true_dict, false_dict, phase, variables, build_file)
Returns true_dict if cond_expr evaluates to true, and false_dict otherwise.
Returns true_dict if cond_expr evaluates to true, and false_dict otherwise.
def EvalSingleCondition(cond_expr, true_dict, false_dict, phase, variables, build_file): """Returns true_dict if cond_expr evaluates to true, and false_dict otherwise.""" # Do expansions on the condition itself. Since the condition can naturally # contain variable references without needing to resort to ...
[ "def", "EvalSingleCondition", "(", "cond_expr", ",", "true_dict", ",", "false_dict", ",", "phase", ",", "variables", ",", "build_file", ")", ":", "# Do expansions on the condition itself. Since the condition can naturally", "# contain variable references without needing to resort ...
[ 1183, 0 ]
[ 1223, 25 ]
python
en
['en', 'pt', 'en']
True
ProcessVariablesAndConditionsInDict
( the_dict, phase, variables_in, build_file, the_dict_key=None )
Handle all variable and command expansion and conditional evaluation. This function is the public entry point for all variable expansions and conditional evaluations. The variables_in dictionary will not be modified by this function.
Handle all variable and command expansion and conditional evaluation.
def ProcessVariablesAndConditionsInDict( the_dict, phase, variables_in, build_file, the_dict_key=None ): """Handle all variable and command expansion and conditional evaluation. This function is the public entry point for all variable expansions and conditional evaluations. The variables_in dictionary wil...
[ "def", "ProcessVariablesAndConditionsInDict", "(", "the_dict", ",", "phase", ",", "variables_in", ",", "build_file", ",", "the_dict_key", "=", "None", ")", ":", "# Make a copy of the variables_in dict that can be modified during the", "# loading of automatics and the loading of the...
[ 1310, 0 ]
[ 1424, 87 ]
python
en
['en', 'en', 'en']
True
BuildTargetsDict
(data)
Builds a dict mapping fully-qualified target names to their target dicts. |data| is a dict mapping loaded build files by pathname relative to the current directory. Values in |data| are build file contents. For each |data| value with a "targets" key, the value of the "targets" key is taken as a list containi...
Builds a dict mapping fully-qualified target names to their target dicts.
def BuildTargetsDict(data): """Builds a dict mapping fully-qualified target names to their target dicts. |data| is a dict mapping loaded build files by pathname relative to the current directory. Values in |data| are build file contents. For each |data| value with a "targets" key, the value of the "targets...
[ "def", "BuildTargetsDict", "(", "data", ")", ":", "targets", "=", "{", "}", "for", "build_file", "in", "data", "[", "\"target_build_files\"", "]", ":", "for", "target", "in", "data", "[", "build_file", "]", ".", "get", "(", "\"targets\"", ",", "[", "]", ...
[ 1464, 0 ]
[ 1487, 18 ]
python
en
['en', 'en', 'en']
True
QualifyDependencies
(targets)
Make dependency links fully-qualified relative to the current directory. |targets| is a dict mapping fully-qualified target names to their target dicts. For each target in this dict, keys known to contain dependency links are examined, and any dependencies referenced will be rewritten so that they are fully-q...
Make dependency links fully-qualified relative to the current directory.
def QualifyDependencies(targets): """Make dependency links fully-qualified relative to the current directory. |targets| is a dict mapping fully-qualified target names to their target dicts. For each target in this dict, keys known to contain dependency links are examined, and any dependencies referenced wil...
[ "def", "QualifyDependencies", "(", "targets", ")", ":", "all_dependency_sections", "=", "[", "dep", "+", "op", "for", "dep", "in", "dependency_sections", "for", "op", "in", "(", "\"\"", ",", "\"!\"", ",", "\"/\"", ")", "]", "for", "target", ",", "target_di...
[ 1490, 0 ]
[ 1536, 21 ]
python
en
['en', 'en', 'en']
True
ExpandWildcardDependencies
(targets, data)
Expands dependencies specified as build_file:*. For each target in |targets|, examines sections containing links to other targets. If any such section contains a link of the form build_file:*, it is taken as a wildcard link, and is expanded to list each target in build_file. The |data| dict provides access t...
Expands dependencies specified as build_file:*.
def ExpandWildcardDependencies(targets, data): """Expands dependencies specified as build_file:*. For each target in |targets|, examines sections containing links to other targets. If any such section contains a link of the form build_file:*, it is taken as a wildcard link, and is expanded to list each targ...
[ "def", "ExpandWildcardDependencies", "(", "targets", ",", "data", ")", ":", "for", "target", ",", "target_dict", "in", "targets", ".", "items", "(", ")", ":", "target_build_file", "=", "gyp", ".", "common", ".", "BuildFile", "(", "target", ")", "for", "dep...
[ 1539, 0 ]
[ 1618, 33 ]
python
en
['en', 'en', 'en']
True
Unify
(items)
Removes duplicate elements from items, keeping the first element.
Removes duplicate elements from items, keeping the first element.
def Unify(items): """Removes duplicate elements from items, keeping the first element.""" seen = {} return [seen.setdefault(e, e) for e in items if e not in seen]
[ "def", "Unify", "(", "items", ")", ":", "seen", "=", "{", "}", "return", "[", "seen", ".", "setdefault", "(", "e", ",", "e", ")", "for", "e", "in", "items", "if", "e", "not", "in", "seen", "]" ]
[ 1621, 0 ]
[ 1624, 66 ]
python
en
['en', 'en', 'en']
True
RemoveDuplicateDependencies
(targets)
Makes sure every dependency appears only once in all targets's dependency lists.
Makes sure every dependency appears only once in all targets's dependency lists.
def RemoveDuplicateDependencies(targets): """Makes sure every dependency appears only once in all targets's dependency lists.""" for target_name, target_dict in targets.items(): for dependency_key in dependency_sections: dependencies = target_dict.get(dependency_key, []) if dep...
[ "def", "RemoveDuplicateDependencies", "(", "targets", ")", ":", "for", "target_name", ",", "target_dict", "in", "targets", ".", "items", "(", ")", ":", "for", "dependency_key", "in", "dependency_sections", ":", "dependencies", "=", "target_dict", ".", "get", "("...
[ 1627, 0 ]
[ 1634, 65 ]
python
en
['en', 'en', 'en']
True
Filter
(items, item)
Removes item from items.
Removes item from items.
def Filter(items, item): """Removes item from items.""" res = {} return [res.setdefault(e, e) for e in items if e != item]
[ "def", "Filter", "(", "items", ",", "item", ")", ":", "res", "=", "{", "}", "return", "[", "res", ".", "setdefault", "(", "e", ",", "e", ")", "for", "e", "in", "items", "if", "e", "!=", "item", "]" ]
[ 1637, 0 ]
[ 1640, 61 ]
python
en
['en', 'en', 'en']
True
RemoveSelfDependencies
(targets)
Remove self dependencies from targets that have the prune_self_dependency variable set.
Remove self dependencies from targets that have the prune_self_dependency variable set.
def RemoveSelfDependencies(targets): """Remove self dependencies from targets that have the prune_self_dependency variable set.""" for target_name, target_dict in targets.items(): for dependency_key in dependency_sections: dependencies = target_dict.get(dependency_key, []) if d...
[ "def", "RemoveSelfDependencies", "(", "targets", ")", ":", "for", "target_name", ",", "target_dict", "in", "targets", ".", "items", "(", ")", ":", "for", "dependency_key", "in", "dependency_sections", ":", "dependencies", "=", "target_dict", ".", "get", "(", "...
[ 1643, 0 ]
[ 1659, 29 ]
python
en
['en', 'en', 'en']
True
RemoveLinkDependenciesFromNoneTargets
(targets)
Remove dependencies having the 'link_dependency' attribute from the 'none' targets.
Remove dependencies having the 'link_dependency' attribute from the 'none' targets.
def RemoveLinkDependenciesFromNoneTargets(targets): """Remove dependencies having the 'link_dependency' attribute from the 'none' targets.""" for target_name, target_dict in targets.items(): for dependency_key in dependency_sections: dependencies = target_dict.get(dependency_key, []) ...
[ "def", "RemoveLinkDependenciesFromNoneTargets", "(", "targets", ")", ":", "for", "target_name", ",", "target_dict", "in", "targets", ".", "items", "(", ")", ":", "for", "dependency_key", "in", "dependency_sections", ":", "dependencies", "=", "target_dict", ".", "g...
[ 1662, 0 ]
[ 1674, 29 ]
python
en
['en', 'en', 'en']
True
ParallelState.LoadTargetBuildFileCallback
(self, result)
Handle the results of running LoadTargetBuildFile in another process.
Handle the results of running LoadTargetBuildFile in another process.
def LoadTargetBuildFileCallback(self, result): """Handle the results of running LoadTargetBuildFile in another process. """ self.condition.acquire() if not result: self.error = True self.condition.notify() self.condition.release() return ...
[ "def", "LoadTargetBuildFileCallback", "(", "self", ",", "result", ")", ":", "self", ".", "condition", ".", "acquire", "(", ")", "if", "not", "result", ":", "self", ".", "error", "=", "True", "self", ".", "condition", ".", "notify", "(", ")", "self", "....
[ 596, 4 ]
[ 614, 32 ]
python
en
['en', 'en', 'en']
True
DependencyGraphNode.FindCycles
(self)
Returns a list of cycles in the graph, where each cycle is its own list.
Returns a list of cycles in the graph, where each cycle is its own list.
def FindCycles(self): """ Returns a list of cycles in the graph, where each cycle is its own list. """ results = [] visited = set() def Visit(node, path): for child in node.dependents: if child in path: results.append([child] + pat...
[ "def", "FindCycles", "(", "self", ")", ":", "results", "=", "[", "]", "visited", "=", "set", "(", ")", "def", "Visit", "(", "node", ",", "path", ")", ":", "for", "child", "in", "node", ".", "dependents", ":", "if", "child", "in", "path", ":", "re...
[ 1748, 4 ]
[ 1766, 22 ]
python
en
['en', 'error', 'th']
False
DependencyGraphNode.DirectDependencies
(self, dependencies=None)
Returns a list of just direct dependencies.
Returns a list of just direct dependencies.
def DirectDependencies(self, dependencies=None): """Returns a list of just direct dependencies.""" if dependencies is None: dependencies = [] for dependency in self.dependencies: # Check for None, corresponding to the root node. if dependency.ref and dependen...
[ "def", "DirectDependencies", "(", "self", ",", "dependencies", "=", "None", ")", ":", "if", "dependencies", "is", "None", ":", "dependencies", "=", "[", "]", "for", "dependency", "in", "self", ".", "dependencies", ":", "# Check for None, corresponding to the root ...
[ 1768, 4 ]
[ 1778, 27 ]
python
en
['en', 'en', 'en']
True
DependencyGraphNode._AddImportedDependencies
(self, targets, dependencies=None)
Given a list of direct dependencies, adds indirect dependencies that other dependencies have declared to export their settings. This method does not operate on self. Rather, it operates on the list of dependencies in the |dependencies| argument. For each dependency in that list, if any declares that ...
Given a list of direct dependencies, adds indirect dependencies that other dependencies have declared to export their settings.
def _AddImportedDependencies(self, targets, dependencies=None): """Given a list of direct dependencies, adds indirect dependencies that other dependencies have declared to export their settings. This method does not operate on self. Rather, it operates on the list of dependencies in the |dependenc...
[ "def", "_AddImportedDependencies", "(", "self", ",", "targets", ",", "dependencies", "=", "None", ")", ":", "if", "dependencies", "is", "None", ":", "dependencies", "=", "[", "]", "index", "=", "0", "while", "index", "<", "len", "(", "dependencies", ")", ...
[ 1780, 4 ]
[ 1820, 27 ]
python
en
['en', 'en', 'en']
True
DependencyGraphNode.DirectAndImportedDependencies
(self, targets, dependencies=None)
Returns a list of a target's direct dependencies and all indirect dependencies that a dependency has advertised settings should be exported through the dependency for.
Returns a list of a target's direct dependencies and all indirect dependencies that a dependency has advertised settings should be exported through the dependency for.
def DirectAndImportedDependencies(self, targets, dependencies=None): """Returns a list of a target's direct dependencies and all indirect dependencies that a dependency has advertised settings should be exported through the dependency for. """ dependencies = self.DirectDependencies(dependen...
[ "def", "DirectAndImportedDependencies", "(", "self", ",", "targets", ",", "dependencies", "=", "None", ")", ":", "dependencies", "=", "self", ".", "DirectDependencies", "(", "dependencies", ")", "return", "self", ".", "_AddImportedDependencies", "(", "targets", ",...
[ 1822, 4 ]
[ 1829, 67 ]
python
en
['en', 'en', 'en']
True
DependencyGraphNode.DeepDependencies
(self, dependencies=None)
Returns an OrderedSet of all of a target's dependencies, recursively.
Returns an OrderedSet of all of a target's dependencies, recursively.
def DeepDependencies(self, dependencies=None): """Returns an OrderedSet of all of a target's dependencies, recursively.""" if dependencies is None: # Using a list to get ordered output and a set to do fast "is it # already added" checks. dependencies = OrderedSet() ...
[ "def", "DeepDependencies", "(", "self", ",", "dependencies", "=", "None", ")", ":", "if", "dependencies", "is", "None", ":", "# Using a list to get ordered output and a set to do fast \"is it", "# already added\" checks.", "dependencies", "=", "OrderedSet", "(", ")", "for...
[ 1831, 4 ]
[ 1846, 27 ]
python
en
['en', 'en', 'en']
True
DependencyGraphNode._LinkDependenciesInternal
( self, targets, include_shared_libraries, dependencies=None, initial=True )
Returns an OrderedSet of dependency targets that are linked into this target. This function has a split personality, depending on the setting of |initial|. Outside callers should always leave |initial| at its default setting. When adding a target to the list of dependencies, this function will ...
Returns an OrderedSet of dependency targets that are linked into this target.
def _LinkDependenciesInternal( self, targets, include_shared_libraries, dependencies=None, initial=True ): """Returns an OrderedSet of dependency targets that are linked into this target. This function has a split personality, depending on the setting of |initial|. Outside callers shou...
[ "def", "_LinkDependenciesInternal", "(", "self", ",", "targets", ",", "include_shared_libraries", ",", "dependencies", "=", "None", ",", "initial", "=", "True", ")", ":", "if", "dependencies", "is", "None", ":", "# Using a list to get ordered output and a set to do fast...
[ 1848, 4 ]
[ 1942, 27 ]
python
en
['en', 'en', 'en']
True
DependencyGraphNode.DependenciesForLinkSettings
(self, targets)
Returns a list of dependency targets whose link_settings should be merged into this target.
Returns a list of dependency targets whose link_settings should be merged into this target.
def DependenciesForLinkSettings(self, targets): """ Returns a list of dependency targets whose link_settings should be merged into this target. """ # TODO(sbaig) Currently, chrome depends on the bug that shared libraries' # link_settings are propagated. So for now, we will allow it...
[ "def", "DependenciesForLinkSettings", "(", "self", ",", "targets", ")", ":", "# TODO(sbaig) Currently, chrome depends on the bug that shared libraries'", "# link_settings are propagated. So for now, we will allow it, unless the", "# 'allow_sharedlib_linksettings_propagation' flag is explicitly ...
[ 1944, 4 ]
[ 1957, 80 ]
python
en
['en', 'error', 'th']
False
DependencyGraphNode.DependenciesToLinkAgainst
(self, targets)
Returns a list of dependency targets that are linked into this target.
Returns a list of dependency targets that are linked into this target.
def DependenciesToLinkAgainst(self, targets): """ Returns a list of dependency targets that are linked into this target. """ return self._LinkDependenciesInternal(targets, True)
[ "def", "DependenciesToLinkAgainst", "(", "self", ",", "targets", ")", ":", "return", "self", ".", "_LinkDependenciesInternal", "(", "targets", ",", "True", ")" ]
[ 1959, 4 ]
[ 1963, 60 ]
python
en
['en', 'error', 'th']
False
bdist_rpm._make_spec_file
(self)
Generate the text of an RPM spec file and return it as a list of strings (one per line).
Generate the text of an RPM spec file and return it as a list of strings (one per line).
def _make_spec_file(self): """Generate the text of an RPM spec file and return it as a list of strings (one per line). """ # definitions and headers spec_file = [ '%define name ' + self.distribution.get_name(), '%define version ' + self.distribution.get_ve...
[ "def", "_make_spec_file", "(", "self", ")", ":", "# definitions and headers", "spec_file", "=", "[", "'%define name '", "+", "self", ".", "distribution", ".", "get_name", "(", ")", ",", "'%define version '", "+", "self", ".", "distribution", ".", "get_version", ...
[ 390, 4 ]
[ 557, 24 ]
python
en
['en', 'en', 'en']
True
bdist_rpm._format_changelog
(self, changelog)
Format the changelog correctly and convert it to a list of strings
Format the changelog correctly and convert it to a list of strings
def _format_changelog(self, changelog): """Format the changelog correctly and convert it to a list of strings """ if not changelog: return changelog new_changelog = [] for line in changelog.strip().split('\n'): line = line.strip() if line[0] ==...
[ "def", "_format_changelog", "(", "self", ",", "changelog", ")", ":", "if", "not", "changelog", ":", "return", "changelog", "new_changelog", "=", "[", "]", "for", "line", "in", "changelog", ".", "strip", "(", ")", ".", "split", "(", "'\\n'", ")", ":", "...
[ 559, 4 ]
[ 578, 28 ]
python
en
['en', 'en', 'en']
True
move_rows
( base_model: Model, raw_query: Composable, *, src_db_table: Optional[str] = None, returning_id: bool = False, **kwargs: Composable, )
Core helper for bulk moving rows between a table and its archive table
Core helper for bulk moving rows between a table and its archive table
def move_rows( base_model: Model, raw_query: Composable, *, src_db_table: Optional[str] = None, returning_id: bool = False, **kwargs: Composable, ) -> List[int]: """Core helper for bulk moving rows between a table and its archive table""" if src_db_table is None: # Use base_model...
[ "def", "move_rows", "(", "base_model", ":", "Model", ",", "raw_query", ":", "Composable", ",", "*", ",", "src_db_table", ":", "Optional", "[", "str", "]", "=", "None", ",", "returning_id", ":", "bool", "=", "False", ",", "*", "*", "kwargs", ":", "Compo...
[ 92, 0 ]
[ 119, 21 ]
python
en
['en', 'en', 'en']
True
get_realms_and_streams_for_archiving
()
This function constructs a list of (realm, streams_of_the_realm) tuples where each realm is a Realm that requires calling the archiving functions on it, and streams_of_the_realm is a list of streams of the realm to call archive_stream_messages with. The purpose of this is performance - for servers wit...
This function constructs a list of (realm, streams_of_the_realm) tuples where each realm is a Realm that requires calling the archiving functions on it, and streams_of_the_realm is a list of streams of the realm to call archive_stream_messages with.
def get_realms_and_streams_for_archiving() -> List[Tuple[Realm, List[Stream]]]: """ This function constructs a list of (realm, streams_of_the_realm) tuples where each realm is a Realm that requires calling the archiving functions on it, and streams_of_the_realm is a list of streams of the realm to call ...
[ "def", "get_realms_and_streams_for_archiving", "(", ")", "->", "List", "[", "Tuple", "[", "Realm", ",", "List", "[", "Stream", "]", "]", "]", ":", "realm_id_to_realm", "=", "{", "}", "realm_id_to_streams_list", ":", "Dict", "[", "int", ",", "List", "[", "S...
[ 438, 0 ]
[ 485, 5 ]
python
en
['en', 'error', 'th']
False
restore_retention_policy_deletions_for_stream
(stream: Stream)
Utility function for calling in the Django shell if a stream's policy was set to something too aggressive and the administrator wants to restore the messages deleted as a result.
Utility function for calling in the Django shell if a stream's policy was set to something too aggressive and the administrator wants to restore the messages deleted as a result.
def restore_retention_policy_deletions_for_stream(stream: Stream) -> None: """ Utility function for calling in the Django shell if a stream's policy was set to something too aggressive and the administrator wants to restore the messages deleted as a result. """ relevant_transactions = ArchiveTra...
[ "def", "restore_retention_policy_deletions_for_stream", "(", "stream", ":", "Stream", ")", "->", "None", ":", "relevant_transactions", "=", "ArchiveTransaction", ".", "objects", ".", "filter", "(", "archivedmessage__recipient", "=", "stream", ".", "recipient", ",", "t...
[ 656, 0 ]
[ 666, 74 ]
python
en
['en', 'error', 'th']
False
trade_record_to_dict
(record: TradeRecord)
Convenience function to return only part of trade record we care about and show correct status to the ui
Convenience function to return only part of trade record we care about and show correct status to the ui
def trade_record_to_dict(record: TradeRecord) -> Dict: """ Convenience function to return only part of trade record we care about and show correct status to the ui""" result = {} result["trade_id"] = record.trade_id.hex() result["sent"] = record.sent result["my_offer"] = record.my_offer result["...
[ "def", "trade_record_to_dict", "(", "record", ":", "TradeRecord", ")", "->", "Dict", ":", "result", "=", "{", "}", "result", "[", "\"trade_id\"", "]", "=", "record", ".", "trade_id", ".", "hex", "(", ")", "result", "[", "\"sent\"", "]", "=", "record", ...
[ 26, 0 ]
[ 40, 17 ]
python
en
['en', 'en', 'en']
True
pack
(structure, data)
Pack data into hex string with little endian format.
Pack data into hex string with little endian format.
def pack(structure, data): """ Pack data into hex string with little endian format. """ return binascii.hexlify(struct.pack('<' + structure, *data)).upper()
[ "def", "pack", "(", "structure", ",", "data", ")", ":", "return", "binascii", ".", "hexlify", "(", "struct", ".", "pack", "(", "'<'", "+", "structure", ",", "*", "data", ")", ")", ".", "upper", "(", ")" ]
[ 11, 0 ]
[ 15, 72 ]
python
en
['en', 'error', 'th']
False
unpack
(structure, data)
Unpack little endian hexlified binary string into a list.
Unpack little endian hexlified binary string into a list.
def unpack(structure, data): """ Unpack little endian hexlified binary string into a list. """ return struct.unpack('<' + structure, binascii.unhexlify(data))
[ "def", "unpack", "(", "structure", ",", "data", ")", ":", "return", "struct", ".", "unpack", "(", "'<'", "+", "structure", ",", "binascii", ".", "unhexlify", "(", "data", ")", ")" ]
[ 18, 0 ]
[ 22, 67 ]
python
en
['en', 'error', 'th']
False
chunk
(data, index)
Split a string into two parts at the input index.
Split a string into two parts at the input index.
def chunk(data, index): """ Split a string into two parts at the input index. """ return data[:index], data[index:]
[ "def", "chunk", "(", "data", ",", "index", ")", ":", "return", "data", "[", ":", "index", "]", ",", "data", "[", "index", ":", "]" ]
[ 25, 0 ]
[ 29, 37 ]
python
en
['en', 'error', 'th']
False
get_pgraster_srid
(data)
Extract the SRID from a PostGIS raster string.
Extract the SRID from a PostGIS raster string.
def get_pgraster_srid(data): """ Extract the SRID from a PostGIS raster string. """ if data is None: return # The positional arguments here extract the hex-encoded srid from the # header of the PostGIS raster string. This can be understood through # the POSTGIS_HEADER_STRUCTURE const...
[ "def", "get_pgraster_srid", "(", "data", ")", ":", "if", "data", "is", "None", ":", "return", "# The positional arguments here extract the hex-encoded srid from the", "# header of the PostGIS raster string. This can be understood through", "# the POSTGIS_HEADER_STRUCTURE constant definit...
[ 32, 0 ]
[ 41, 40 ]
python
en
['en', 'error', 'th']
False
from_pgraster
(data)
Convert a PostGIS HEX String into a dictionary.
Convert a PostGIS HEX String into a dictionary.
def from_pgraster(data): """ Convert a PostGIS HEX String into a dictionary. """ if data is None: return # Split raster header from data header, data = chunk(data, 122) header = unpack(POSTGIS_HEADER_STRUCTURE, header) # Parse band data bands = [] pixeltypes = [] wh...
[ "def", "from_pgraster", "(", "data", ")", ":", "if", "data", "is", "None", ":", "return", "# Split raster header from data", "header", ",", "data", "=", "chunk", "(", "data", ",", "122", ")", "header", "=", "unpack", "(", "POSTGIS_HEADER_STRUCTURE", ",", "he...
[ 44, 0 ]
[ 107, 5 ]
python
en
['en', 'error', 'th']
False
to_pgraster
(rast)
Convert a GDALRaster into PostGIS Raster format.
Convert a GDALRaster into PostGIS Raster format.
def to_pgraster(rast): """ Convert a GDALRaster into PostGIS Raster format. """ # Return if the raster is null if rast is None or rast == '': return # Prepare the raster header data as a tuple. The first two numbers are # the endianness and the PostGIS Raster Version, both are fixed...
[ "def", "to_pgraster", "(", "rast", ")", ":", "# Return if the raster is null", "if", "rast", "is", "None", "or", "rast", "==", "''", ":", "return", "# Prepare the raster header data as a tuple. The first two numbers are", "# the endianness and the PostGIS Raster Version, both are...
[ 110, 0 ]
[ 160, 26 ]
python
en
['en', 'error', 'th']
False
i16le
(c, o=0)
Converts a 2-bytes (16 bits) string to an unsigned integer. :param c: string containing bytes to convert :param o: offset of bytes to convert in string
Converts a 2-bytes (16 bits) string to an unsigned integer.
def i16le(c, o=0): """ Converts a 2-bytes (16 bits) string to an unsigned integer. :param c: string containing bytes to convert :param o: offset of bytes to convert in string """ return unpack_from("<H", c, o)[0]
[ "def", "i16le", "(", "c", ",", "o", "=", "0", ")", ":", "return", "unpack_from", "(", "\"<H\"", ",", "c", ",", "o", ")", "[", "0", "]" ]
[ 29, 0 ]
[ 36, 37 ]
python
en
['en', 'error', 'th']
False
si16le
(c, o=0)
Converts a 2-bytes (16 bits) string to a signed integer. :param c: string containing bytes to convert :param o: offset of bytes to convert in string
Converts a 2-bytes (16 bits) string to a signed integer.
def si16le(c, o=0): """ Converts a 2-bytes (16 bits) string to a signed integer. :param c: string containing bytes to convert :param o: offset of bytes to convert in string """ return unpack_from("<h", c, o)[0]
[ "def", "si16le", "(", "c", ",", "o", "=", "0", ")", ":", "return", "unpack_from", "(", "\"<h\"", ",", "c", ",", "o", ")", "[", "0", "]" ]
[ 39, 0 ]
[ 46, 37 ]
python
en
['en', 'error', 'th']
False
i32le
(c, o=0)
Converts a 4-bytes (32 bits) string to an unsigned integer. :param c: string containing bytes to convert :param o: offset of bytes to convert in string
Converts a 4-bytes (32 bits) string to an unsigned integer.
def i32le(c, o=0): """ Converts a 4-bytes (32 bits) string to an unsigned integer. :param c: string containing bytes to convert :param o: offset of bytes to convert in string """ return unpack_from("<I", c, o)[0]
[ "def", "i32le", "(", "c", ",", "o", "=", "0", ")", ":", "return", "unpack_from", "(", "\"<I\"", ",", "c", ",", "o", ")", "[", "0", "]" ]
[ 49, 0 ]
[ 56, 37 ]
python
en
['en', 'error', 'th']
False
si32le
(c, o=0)
Converts a 4-bytes (32 bits) string to a signed integer. :param c: string containing bytes to convert :param o: offset of bytes to convert in string
Converts a 4-bytes (32 bits) string to a signed integer.
def si32le(c, o=0): """ Converts a 4-bytes (32 bits) string to a signed integer. :param c: string containing bytes to convert :param o: offset of bytes to convert in string """ return unpack_from("<i", c, o)[0]
[ "def", "si32le", "(", "c", ",", "o", "=", "0", ")", ":", "return", "unpack_from", "(", "\"<i\"", ",", "c", ",", "o", ")", "[", "0", "]" ]
[ 59, 0 ]
[ 66, 37 ]
python
en
['en', 'error', 'th']
False
user_groups_in_realm_serialized
(realm: Realm)
This function is used in do_events_register code path so this code should be performant. We need to do 2 database queries because Django's ORM doesn't properly support the left join between UserGroup and UserGroupMembership that we need.
This function is used in do_events_register code path so this code should be performant. We need to do 2 database queries because Django's ORM doesn't properly support the left join between UserGroup and UserGroupMembership that we need.
def user_groups_in_realm_serialized(realm: Realm) -> List[Dict[str, Any]]: """This function is used in do_events_register code path so this code should be performant. We need to do 2 database queries because Django's ORM doesn't properly support the left join between UserGroup and UserGroupMembership t...
[ "def", "user_groups_in_realm_serialized", "(", "realm", ":", "Realm", ")", "->", "List", "[", "Dict", "[", "str", ",", "Any", "]", "]", ":", "realm_groups", "=", "UserGroup", ".", "objects", ".", "filter", "(", "realm", "=", "realm", ")", "group_dicts", ...
[ 26, 0 ]
[ 50, 80 ]
python
en
['en', 'en', 'en']
True
deconv
(fmaj, fmin, fpa, cmaj, cmin, cpa)
Deconvolve a Gaussian "beam" from a Gaussian component. When we fit an elliptical Gaussian to a point in our image, we are actually fitting to a convolution of the physical shape of the source with the beam pattern of our instrument. This results in the fmaj/fmin/fpa arguments to this function. ...
Deconvolve a Gaussian "beam" from a Gaussian component.
def deconv(fmaj, fmin, fpa, cmaj, cmin, cpa): """ Deconvolve a Gaussian "beam" from a Gaussian component. When we fit an elliptical Gaussian to a point in our image, we are actually fitting to a convolution of the physical shape of the source with the beam pattern of our instrument. This results in...
[ "def", "deconv", "(", "fmaj", ",", "fmin", ",", "fpa", ",", "cmaj", ",", "cmin", ",", "cpa", ")", ":", "HALF_RAD", "=", "90.0", "/", "pi", "cmaj2", "=", "cmaj", "*", "cmaj", "cmin2", "=", "cmin", "*", "cmin", "fmaj2", "=", "fmaj", "*", "fmaj", ...
[ 6, 0 ]
[ 71, 32 ]
python
en
['en', 'error', 'th']
False
prepare_activation_url
( email: str, request: HttpRequest, realm_creation: bool = False, streams: Optional[List[Stream]] = None, invited_as: Optional[int] = None, )
Send an email with a confirmation link to the provided e-mail so the user can complete their registration.
Send an email with a confirmation link to the provided e-mail so the user can complete their registration.
def prepare_activation_url( email: str, request: HttpRequest, realm_creation: bool = False, streams: Optional[List[Stream]] = None, invited_as: Optional[int] = None, ) -> str: """ Send an email with a confirmation link to the provided e-mail so the user can complete their registration. ...
[ "def", "prepare_activation_url", "(", "email", ":", "str", ",", "request", ":", "HttpRequest", ",", "realm_creation", ":", "bool", "=", "False", ",", "streams", ":", "Optional", "[", "List", "[", "Stream", "]", "]", "=", "None", ",", "invited_as", ":", "...
[ 508, 0 ]
[ 535, 25 ]
python
en
['en', 'error', 'th']
False
parse_antennafile
(positions_file)
Parses an antenna file from the LOFAR system software repository. :param positions_file: a antenna file :returns: a dictionary with array as key and positions as values
Parses an antenna file from the LOFAR system software repository.
def parse_antennafile(positions_file): """ Parses an antenna file from the LOFAR system software repository. :param positions_file: a antenna file :returns: a dictionary with array as key and positions as values """ file_handler = open(positions_file, 'r') parsed = {} state = 0 arr...
[ "def", "parse_antennafile", "(", "positions_file", ")", ":", "file_handler", "=", "open", "(", "positions_file", ",", "'r'", ")", "parsed", "=", "{", "}", "state", "=", "0", "array", "=", "None", "position", "=", "None", "# where is the station relative to the c...
[ 175, 0 ]
[ 216, 17 ]
python
en
['en', 'error', 'th']
False
shortest_distances
(coordinates, full_array)
returns a list of distances for each antenna relative to its closest neighbour. :param coordinates: a list of 3 value tuples that represent x,y and z coordinates of a subset of the array :param full_array: a list of x,y,z coordinates of a full array :returns: a list of floa...
returns a list of distances for each antenna relative to its closest neighbour.
def shortest_distances(coordinates, full_array): """ returns a list of distances for each antenna relative to its closest neighbour. :param coordinates: a list of 3 value tuples that represent x,y and z coordinates of a subset of the array :param full_array: a list of x,y,z ...
[ "def", "shortest_distances", "(", "coordinates", ",", "full_array", ")", ":", "distances", "=", "[", "]", "for", "a", "in", "coordinates", ":", "shortest_distance", "=", "None", "for", "b", "in", "full_array", ":", "distance", "=", "pow", "(", "(", "a", ...
[ 219, 0 ]
[ 239, 44 ]
python
en
['en', 'error', 'th']
False
pretty_print
(file_)
Pretty prints a parsed antenna file. Use this function to generate copy paste code to be used in the top of this file. :param file_: a file location
Pretty prints a parsed antenna file. Use this function to generate copy paste code to be used in the top of this file.
def pretty_print(file_): """ Pretty prints a parsed antenna file. Use this function to generate copy paste code to be used in the top of this file. :param file_: a file location """ parsed = parse_antennafile(file_) print "{" for key, value in [x for x in parsed.items() if x[0].startswi...
[ "def", "pretty_print", "(", "file_", ")", ":", "parsed", "=", "parse_antennafile", "(", "file_", ")", "print", "\"{\"", "for", "key", ",", "value", "in", "[", "x", "for", "x", "in", "parsed", ".", "items", "(", ")", "if", "x", "[", "0", "]", ".", ...
[ 242, 0 ]
[ 257, 13 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseIntrospection.get_field_type
(self, data_type, description)
Hook for a database backend to use the cursor description to match a Django field type to a database column. For Oracle, the column data_type on its own is insufficient to distinguish between a FloatField and IntegerField, for example.
Hook for a database backend to use the cursor description to match a Django field type to a database column.
def get_field_type(self, data_type, description): """Hook for a database backend to use the cursor description to match a Django field type to a database column. For Oracle, the column data_type on its own is insufficient to distinguish between a FloatField and IntegerField, for example...
[ "def", "get_field_type", "(", "self", ",", "data_type", ",", "description", ")", ":", "return", "self", ".", "data_types_reverse", "[", "data_type", "]" ]
[ 18, 4 ]
[ 24, 49 ]
python
en
['en', 'en', 'en']
True
BaseDatabaseIntrospection.table_name_converter
(self, name)
Apply a conversion to the name for the purposes of comparison. The default table name converter is for case sensitive comparison.
Apply a conversion to the name for the purposes of comparison.
def table_name_converter(self, name): """Apply a conversion to the name for the purposes of comparison. The default table name converter is for case sensitive comparison. """ return name
[ "def", "table_name_converter", "(", "self", ",", "name", ")", ":", "return", "name" ]
[ 26, 4 ]
[ 31, 19 ]
python
en
['en', 'en', 'en']
True
BaseDatabaseIntrospection.column_name_converter
(self, name)
Apply a conversion to the column name for the purposes of comparison. Uses table_name_converter() by default.
Apply a conversion to the column name for the purposes of comparison.
def column_name_converter(self, name): """ Apply a conversion to the column name for the purposes of comparison. Uses table_name_converter() by default. """ return self.table_name_converter(name)
[ "def", "column_name_converter", "(", "self", ",", "name", ")", ":", "return", "self", ".", "table_name_converter", "(", "name", ")" ]
[ 33, 4 ]
[ 39, 46 ]
python
en
['en', 'error', 'th']
False