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
with_metaclass
(meta, *bases)
Create a base class with a metaclass.
Create a base class with a metaclass.
def with_metaclass(meta, *bases): """ Create a base class with a metaclass. """ # This requires a bit of explanation: the basic idea is to make a dummy # metaclass for one level of class instantiation that replaces itself with # the actual metaclass. class metaclass(meta): def __new_...
[ "def", "with_metaclass", "(", "meta", ",", "*", "bases", ")", ":", "# This requires a bit of explanation: the basic idea is to make a dummy", "# metaclass for one level of class instantiation that replaces itself with", "# the actual metaclass.", "class", "metaclass", "(", "meta", ")...
[ 19, 0 ]
[ 29, 61 ]
python
en
['en', 'error', 'th']
False
MavWebRTCSignalServer.recv_msg_ping
(self, ws, raddr)
Wait for a message forever, and send a regular ping to prevent bad routers from closing the connection.
Wait for a message forever, and send a regular ping to prevent bad routers from closing the connection.
async def recv_msg_ping(self, ws, raddr): ''' Wait for a message forever, and send a regular ping to prevent bad routers from closing the connection. ''' msg = None while msg is None: try: msg = await asyncio.wait_for(ws.recv(), self.keepalive_...
[ "async", "def", "recv_msg_ping", "(", "self", ",", "ws", ",", "raddr", ")", ":", "msg", "=", "None", "while", "msg", "is", "None", ":", "try", ":", "msg", "=", "await", "asyncio", ".", "wait_for", "(", "ws", ".", "recv", "(", ")", ",", "self", "....
[ 139, 4 ]
[ 151, 18 ]
python
en
['en', 'error', 'th']
False
MavWebRTCSignalServer.disconnect
(self, ws, peer_id)
Remove @peer_id from the list of sessions and close our connection to it. This informs the peer that the session and all calls have ended, and it must reconnect.
Remove
async def disconnect(self, ws, peer_id): ''' Remove @peer_id from the list of sessions and close our connection to it. This informs the peer that the session and all calls have ended, and it must reconnect. ''' if peer_id in self.sessions: del self.sessions[pe...
[ "async", "def", "disconnect", "(", "self", ",", "ws", ",", "peer_id", ")", ":", "if", "peer_id", "in", "self", ".", "sessions", ":", "del", "self", ".", "sessions", "[", "peer_id", "]", "# Close connection", "if", "ws", "and", "ws", ".", "open", ":", ...
[ 153, 4 ]
[ 164, 60 ]
python
en
['en', 'error', 'th']
False
MavWebRTCSignalServer.hello_peer
(self, ws)
Exchange hello, register peer
Exchange hello, register peer
async def hello_peer(self, ws): ''' Exchange hello, register peer ''' raddr = ws.remote_address hello = await ws.recv() hello, uid = hello.split(maxsplit=1) if hello != 'HELLO': await ws.close(code=1002, reason='invalid protocol') raise Exc...
[ "async", "def", "hello_peer", "(", "self", ",", "ws", ")", ":", "raddr", "=", "ws", ".", "remote_address", "hello", "=", "await", "ws", ".", "recv", "(", ")", "hello", ",", "uid", "=", "hello", ".", "split", "(", "maxsplit", "=", "1", ")", "if", ...
[ 301, 4 ]
[ 316, 18 ]
python
en
['en', 'error', 'th']
False
MavWebRTCSignalServer.handler
(self, ws, path)
All incoming messages are handled here. @path is unused.
All incoming messages are handled here.
async def handler(self, ws, path): ''' All incoming messages are handled here. @path is unused. ''' raddr = ws.remote_address self.logger.info("Connected to {!r}".format(raddr)) peer_id = await self.hello_peer(ws) try: await self.connection_handler(ws,...
[ "async", "def", "handler", "(", "self", ",", "ws", ",", "path", ")", ":", "raddr", "=", "ws", ".", "remote_address", "self", ".", "logger", ".", "info", "(", "\"Connected to {!r}\"", ".", "format", "(", "raddr", ")", ")", "peer_id", "=", "await", "self...
[ 318, 4 ]
[ 330, 43 ]
python
en
['en', 'error', 'th']
False
Contacts.populate_database
(self)
Creates a sample database to work with
Creates a sample database to work with
def populate_database(self): "Creates a sample database to work with" addresses = ( ("Max Demian", "60329", "Frankfurt", "Gutleutstraße 214", "069 741 382", "0176 241 332", "mikar@gmx.net"), ("Mathias Hoover", "54340", "Schleich", "Güntzelstr. 12", "0650...
[ "def", "populate_database", "(", "self", ")", ":", "addresses", "=", "(", "(", "\"Max Demian\"", ",", "\"60329\"", ",", "\"Frankfurt\"", ",", "\"Gutleutstraße 214\",", "", "\"069 741 382\"", ",", "\"0176 241 332\"", ",", "\"mikar@gmx.net\"", ")", ",", "(", "\"Math...
[ 18, 4 ]
[ 38, 66 ]
python
en
['en', 'en', 'en']
True
Contacts.insert
(self, name="", zipcode="", city="", street="", phone="", mobile="", email="", table=None)
Insert a new entry into the database in the selected table
Insert a new entry into the database in the selected table
def insert(self, name="", zipcode="", city="", street="", phone="", mobile="", email="", table=None): "Insert a new entry into the database in the selected table" if table is None: table = self.table with self.db: cur = self.db.cursor() cur.exec...
[ "def", "insert", "(", "self", ",", "name", "=", "\"\"", ",", "zipcode", "=", "\"\"", ",", "city", "=", "\"\"", ",", "street", "=", "\"\"", ",", "phone", "=", "\"\"", ",", "mobile", "=", "\"\"", ",", "email", "=", "\"\"", ",", "table", "=", "None"...
[ 40, 4 ]
[ 49, 69 ]
python
en
['en', 'en', 'en']
True
Contacts.show_all
(self, table=None)
Print out all contacts of the currently selected table
Print out all contacts of the currently selected table
def show_all(self, table=None): "Print out all contacts of the currently selected table" if table is None: table = self.table # FIXME: SQLite wants to use ASCII here so we abide, for now. with self.db: cur = self.db.cursor() self.db.text_factory = str ...
[ "def", "show_all", "(", "self", ",", "table", "=", "None", ")", ":", "if", "table", "is", "None", ":", "table", "=", "self", ".", "table", "# FIXME: SQLite wants to use ASCII here so we abide, for now.", "with", "self", ".", "db", ":", "cur", "=", "self", "....
[ 51, 4 ]
[ 63, 74 ]
python
en
['en', 'en', 'en']
True
BaseEngine.__init__
(self, params)
Initialize the template engine. `params` is a dict of configuration settings.
Initialize the template engine.
def __init__(self, params): """ Initialize the template engine. `params` is a dict of configuration settings. """ params = params.copy() self.name = params.pop('NAME') self.dirs = list(params.pop('DIRS')) self.app_dirs = params.pop('APP_DIRS') if ...
[ "def", "__init__", "(", "self", ",", "params", ")", ":", "params", "=", "params", ".", "copy", "(", ")", "self", ".", "name", "=", "params", ".", "pop", "(", "'NAME'", ")", "self", ".", "dirs", "=", "list", "(", "params", ".", "pop", "(", "'DIRS'...
[ 13, 4 ]
[ 25, 67 ]
python
en
['en', 'error', 'th']
False
BaseEngine.from_string
(self, template_code)
Create and return a template for the given source code. This method is optional.
Create and return a template for the given source code.
def from_string(self, template_code): """ Create and return 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\"", ")" ]
[ 33, 4 ]
[ 41, 37 ]
python
en
['en', 'error', 'th']
False
BaseEngine.get_template
(self, template_name)
Load and return a template for the given name. Raise TemplateDoesNotExist if no such template exists.
Load and return a template for the given name.
def get_template(self, template_name): """ Load and return a template for the given name. Raise 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\"", ")" ]
[ 43, 4 ]
[ 51, 38 ]
python
en
['en', 'error', 'th']
False
BaseEngine.template_dirs
(self)
Return a list of directories to search for templates.
Return a list of directories to search for templates.
def template_dirs(self): """ Return 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_dirnam...
[ "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", "(", ...
[ 57, 4 ]
[ 65, 28 ]
python
en
['en', 'error', 'th']
False
BaseEngine.iter_template_filenames
(self, template_name)
Iterate over candidate files for template_name. Ignore files that don't lie inside configured template dirs to avoid directory traversal attacks.
Iterate over candidate files for template_name.
def iter_template_filenames(self, template_name): """ Iterate over candidate files for template_name. Ignore 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", ":...
[ 67, 4 ]
[ 80, 20 ]
python
en
['en', 'error', 'th']
False
_constant_time_compare
(val1, val2)
Return ``True`` if the two strings are equal, ``False`` otherwise. The time taken is independent of the number of characters that match. Do not use this function for anything else than comparision with known length targets. This is should be implemented in C in order to get it completely right...
Return ``True`` if the two strings are equal, ``False`` otherwise.
def _constant_time_compare(val1, val2): """Return ``True`` if the two strings are equal, ``False`` otherwise. The time taken is independent of the number of characters that match. Do not use this function for anything else than comparision with known length targets. This is should be implement...
[ "def", "_constant_time_compare", "(", "val1", ",", "val2", ")", ":", "len_eq", "=", "len", "(", "val1", ")", "==", "len", "(", "val2", ")", "if", "len_eq", ":", "result", "=", "0", "left", "=", "val1", "else", ":", "result", "=", "1", "left", "=", ...
[ 18, 0 ]
[ 40, 22 ]
python
en
['en', 'en', 'en']
True
process
()
Process messages with information about S3 objects
Process messages with information about S3 objects
def process(): """Process messages with information about S3 objects""" message = request.get_json().get('inputMessage', '') # add other processing as needed # for example, add event to PubSub topic or # download object using presigned URL, save in Cloud Storage, invoke ML APIs return jsonify({...
[ "def", "process", "(", ")", ":", "message", "=", "request", ".", "get_json", "(", ")", ".", "get", "(", "'inputMessage'", ",", "''", ")", "# add other processing as needed", "# for example, add event to PubSub topic or ", "# download object using presigned URL, save in Clou...
[ 39, 0 ]
[ 45, 75 ]
python
en
['en', 'en', 'en']
True
unexpected_error
(e)
Handle exceptions by returning swagger-compliant json.
Handle exceptions by returning swagger-compliant json.
def unexpected_error(e): """Handle exceptions by returning swagger-compliant json.""" logging.exception('An error occured while processing the request.') response = jsonify({ 'code': http_client.INTERNAL_SERVER_ERROR, 'message': 'Exception: {}'.format(e)}) response.status_code = http_cli...
[ "def", "unexpected_error", "(", "e", ")", ":", "logging", ".", "exception", "(", "'An error occured while processing the request.'", ")", "response", "=", "jsonify", "(", "{", "'code'", ":", "http_client", ".", "INTERNAL_SERVER_ERROR", ",", "'message'", ":", "'Excep...
[ 49, 0 ]
[ 56, 19 ]
python
en
['en', 'en', 'en']
True
hello_monkey
()
Respond and greet the caller by name.
Respond and greet the caller by name.
def hello_monkey(): """Respond and greet the caller by name.""" # Try adding your own number to this list! callers = { "+14158675308": "Curious George", "+12349013030": "Boots", "+12348134522": "Virgil", } from_number = request.values.get('From', None) name = callers[from...
[ "def", "hello_monkey", "(", ")", ":", "# Try adding your own number to this list!", "callers", "=", "{", "\"+14158675308\"", ":", "\"Curious George\"", ",", "\"+12349013030\"", ":", "\"Boots\"", ",", "\"+12348134522\"", ":", "\"Virgil\"", ",", "}", "from_number", "=", ...
[ 8, 0 ]
[ 23, 20 ]
python
en
['en', 'en', 'en']
True
pbkdf2_hex
( data, salt, iterations=DEFAULT_PBKDF2_ITERATIONS, keylen=None, hashfunc=None )
Like :func:`pbkdf2_bin`, but returns a hex-encoded string. .. versionadded:: 0.9 :param data: the data to derive. :param salt: the salt for the derivation. :param iterations: the number of iterations. :param keylen: the length of the resulting key. If not provided, the digest s...
Like :func:`pbkdf2_bin`, but returns a hex-encoded string.
def pbkdf2_hex( data, salt, iterations=DEFAULT_PBKDF2_ITERATIONS, keylen=None, hashfunc=None ): """Like :func:`pbkdf2_bin`, but returns a hex-encoded string. .. versionadded:: 0.9 :param data: the data to derive. :param salt: the salt for the derivation. :param iterations: the number of iterat...
[ "def", "pbkdf2_hex", "(", "data", ",", "salt", ",", "iterations", "=", "DEFAULT_PBKDF2_ITERATIONS", ",", "keylen", "=", "None", ",", "hashfunc", "=", "None", ")", ":", "rv", "=", "pbkdf2_bin", "(", "data", ",", "salt", ",", "iterations", ",", "keylen", "...
[ 36, 0 ]
[ 53, 52 ]
python
en
['en', 'hmn', 'en']
True
pbkdf2_bin
( data, salt, iterations=DEFAULT_PBKDF2_ITERATIONS, keylen=None, hashfunc=None )
Returns a binary digest for the PBKDF2 hash algorithm of `data` with the given `salt`. It iterates `iterations` times and produces a key of `keylen` bytes. By default, SHA-256 is used as hash function; a different hashlib `hashfunc` can be provided. .. versionadded:: 0.9 :param data: the data to d...
Returns a binary digest for the PBKDF2 hash algorithm of `data` with the given `salt`. It iterates `iterations` times and produces a key of `keylen` bytes. By default, SHA-256 is used as hash function; a different hashlib `hashfunc` can be provided.
def pbkdf2_bin( data, salt, iterations=DEFAULT_PBKDF2_ITERATIONS, keylen=None, hashfunc=None ): """Returns a binary digest for the PBKDF2 hash algorithm of `data` with the given `salt`. It iterates `iterations` times and produces a key of `keylen` bytes. By default, SHA-256 is used as hash function; ...
[ "def", "pbkdf2_bin", "(", "data", ",", "salt", ",", "iterations", "=", "DEFAULT_PBKDF2_ITERATIONS", ",", "keylen", "=", "None", ",", "hashfunc", "=", "None", ")", ":", "if", "not", "hashfunc", ":", "hashfunc", "=", "\"sha256\"", "data", "=", "to_bytes", "(...
[ 56, 0 ]
[ 86, 73 ]
python
en
['en', 'en', 'en']
True
safe_str_cmp
(a, b)
This function compares strings in somewhat constant time. This requires that the length of at least one string is known in advance. Returns `True` if the two strings are equal, or `False` if they are not. .. versionadded:: 0.7
This function compares strings in somewhat constant time. This requires that the length of at least one string is known in advance.
def safe_str_cmp(a, b): """This function compares strings in somewhat constant time. This requires that the length of at least one string is known in advance. Returns `True` if the two strings are equal, or `False` if they are not. .. versionadded:: 0.7 """ if isinstance(a, text_type): ...
[ "def", "safe_str_cmp", "(", "a", ",", "b", ")", ":", "if", "isinstance", "(", "a", ",", "text_type", ")", ":", "a", "=", "a", ".", "encode", "(", "\"utf-8\"", ")", "if", "isinstance", "(", "b", ",", "text_type", ")", ":", "b", "=", "b", ".", "e...
[ 89, 0 ]
[ 116, 18 ]
python
en
['en', 'en', 'en']
True
gen_salt
(length)
Generate a random string of SALT_CHARS with specified ``length``.
Generate a random string of SALT_CHARS with specified ``length``.
def gen_salt(length): """Generate a random string of SALT_CHARS with specified ``length``.""" if length <= 0: raise ValueError("Salt length must be positive") return "".join(_sys_rng.choice(SALT_CHARS) for _ in range_type(length))
[ "def", "gen_salt", "(", "length", ")", ":", "if", "length", "<=", "0", ":", "raise", "ValueError", "(", "\"Salt length must be positive\"", ")", "return", "\"\"", ".", "join", "(", "_sys_rng", ".", "choice", "(", "SALT_CHARS", ")", "for", "_", "in", "range...
[ 119, 0 ]
[ 123, 75 ]
python
en
['en', 'en', 'en']
True
_hash_internal
(method, salt, password)
Internal password hash helper. Supports plaintext without salt, unsalted and salted passwords. In case salted passwords are used hmac is used.
Internal password hash helper. Supports plaintext without salt, unsalted and salted passwords. In case salted passwords are used hmac is used.
def _hash_internal(method, salt, password): """Internal password hash helper. Supports plaintext without salt, unsalted and salted passwords. In case salted passwords are used hmac is used. """ if method == "plain": return password, method if isinstance(password, text_type): p...
[ "def", "_hash_internal", "(", "method", ",", "salt", ",", "password", ")", ":", "if", "method", "==", "\"plain\"", ":", "return", "password", ",", "method", "if", "isinstance", "(", "password", ",", "text_type", ")", ":", "password", "=", "password", ".", ...
[ 126, 0 ]
[ 160, 28 ]
python
en
['en', 'lb', 'en']
True
generate_password_hash
(password, method="pbkdf2:sha256", salt_length=8)
Hash a password with the given method and salt with a string of the given length. The format of the string returned includes the method that was used so that :func:`check_password_hash` can check the hash. The format for the hashed string looks like this:: method$salt$hash This method can **n...
Hash a password with the given method and salt with a string of the given length. The format of the string returned includes the method that was used so that :func:`check_password_hash` can check the hash.
def generate_password_hash(password, method="pbkdf2:sha256", salt_length=8): """Hash a password with the given method and salt with a string of the given length. The format of the string returned includes the method that was used so that :func:`check_password_hash` can check the hash. The format for th...
[ "def", "generate_password_hash", "(", "password", ",", "method", "=", "\"pbkdf2:sha256\"", ",", "salt_length", "=", "8", ")", ":", "salt", "=", "gen_salt", "(", "salt_length", ")", "if", "method", "!=", "\"plain\"", "else", "\"\"", "h", ",", "actual_method", ...
[ 176, 0 ]
[ 203, 48 ]
python
en
['en', 'en', 'en']
True
check_password_hash
(pwhash, password)
check a password against a given salted and hashed password value. In order to support unsalted legacy passwords this method supports plain text passwords, md5 and sha1 hashes (both salted and unsalted). Returns `True` if the password matched, `False` otherwise. :param pwhash: a hashed string like ret...
check a password against a given salted and hashed password value. In order to support unsalted legacy passwords this method supports plain text passwords, md5 and sha1 hashes (both salted and unsalted).
def check_password_hash(pwhash, password): """check a password against a given salted and hashed password value. In order to support unsalted legacy passwords this method supports plain text passwords, md5 and sha1 hashes (both salted and unsalted). Returns `True` if the password matched, `False` other...
[ "def", "check_password_hash", "(", "pwhash", ",", "password", ")", ":", "if", "pwhash", ".", "count", "(", "\"$\"", ")", "<", "2", ":", "return", "False", "method", ",", "salt", ",", "hashval", "=", "pwhash", ".", "split", "(", "\"$\"", ",", "2", ")"...
[ 206, 0 ]
[ 220, 75 ]
python
en
['en', 'en', 'en']
True
safe_join
(directory, *pathnames)
Safely join zero or more untrusted path components to a base directory to avoid escaping the base directory. :param directory: The trusted base directory. :param pathnames: The untrusted path components relative to the base directory. :return: A safe path, otherwise ``None``.
Safely join zero or more untrusted path components to a base directory to avoid escaping the base directory.
def safe_join(directory, *pathnames): """Safely join zero or more untrusted path components to a base directory to avoid escaping the base directory. :param directory: The trusted base directory. :param pathnames: The untrusted path components relative to the base directory. :return: A safe...
[ "def", "safe_join", "(", "directory", ",", "*", "pathnames", ")", ":", "parts", "=", "[", "directory", "]", "for", "filename", "in", "pathnames", ":", "if", "filename", "!=", "\"\"", ":", "filename", "=", "posixpath", ".", "normpath", "(", "filename", ")...
[ 223, 0 ]
[ 248, 33 ]
python
en
['en', 'en', 'en']
True
StatisticalAnalysis.__init__
(self, sample1, sample2, method='ttest')
Class for statical analyse. This class compares 2 list of sample and generate a statical analyse :param sample1: List of results of a recommender 1 in K folds (list with len K) :type sample1: list :param sample2: List of results of a recommender 2 in K folds (list with len K) ...
Class for statical analyse. This class compares 2 list of sample and generate a statical analyse
def __init__(self, sample1, sample2, method='ttest'): """ Class for statical analyse. This class compares 2 list of sample and generate a statical analyse :param sample1: List of results of a recommender 1 in K folds (list with len K) :type sample1: list :param sample2: List of...
[ "def", "__init__", "(", "self", ",", "sample1", ",", "sample2", ",", "method", "=", "'ttest'", ")", ":", "self", ".", "sample1", "=", "np", ".", "array", "(", "sample1", ")", "self", ".", "sample2", "=", "np", ".", "array", "(", "sample2", ")", "se...
[ 18, 4 ]
[ 34, 28 ]
python
en
['en', 'error', 'th']
False
StatisticalAnalysis.general_analysis
(self)
Analyzing the difference Instead you might compute the difference and apply some common measure like the sum of absolute differences (SAD), the sum of squared differences (SSD) or the correlation coefficient:
Analyzing the difference
def general_analysis(self): """ Analyzing the difference Instead you might compute the difference and apply some common measure like the sum of absolute differences (SAD), the sum of squared differences (SSD) or the correlation coefficient: """ print("=== Information A...
[ "def", "general_analysis", "(", "self", ")", ":", "print", "(", "\"=== Information About Samples ===\"", ")", "print", "(", "\"Standard Deviation Sample1: \"", "+", "str", "(", "np", ".", "std", "(", "self", ".", "sample1", ")", ")", ")", "print", "(", "\"Stan...
[ 36, 4 ]
[ 50, 101 ]
python
en
['en', 'error', 'th']
False
StatisticalAnalysis.ttest
(self)
T-student Calculates the T-test for the means of TWO INDEPENDENT samples of scores. This is a two-sided test for the null hypothesis that 2 independent samples have identical average (expected) values This test assumes that the populations have identical variance...
T-student Calculates the T-test for the means of TWO INDEPENDENT samples of scores. This is a two-sided test for the null hypothesis that 2 independent samples have identical average (expected) values This test assumes that the populations have identical variance...
def ttest(self): """ T-student Calculates the T-test for the means of TWO INDEPENDENT samples of scores. This is a two-sided test for the null hypothesis that 2 independent samples have identical average (expected) values This test assumes that the populat...
[ "def", "ttest", "(", "self", ")", ":", "t", ",", "p", "=", "ttest_ind", "(", "self", ".", "sample1", ",", "self", ".", "sample2", ")", "print", "(", "\"=== T- Student Analysis ===\"", ")", "print", "(", "\"The calculated t-statistic: \"", "+", "str", "(", ...
[ 52, 4 ]
[ 67, 57 ]
python
en
['en', 'error', 'th']
False
StatisticalAnalysis.wilcoxon
(self)
Wilcoxon The Wilcoxon signed-rank test tests the null hypothesis that two related paired samples come from the same distribution. In particular, it tests whether the distribution of the differences x - y is symmetric about zero. It is a non-parametric version of the paired T-...
Wilcoxon The Wilcoxon signed-rank test tests the null hypothesis that two related paired samples come from the same distribution. In particular, it tests whether the distribution of the differences x - y is symmetric about zero. It is a non-parametric version of the paired T-...
def wilcoxon(self): """ Wilcoxon The Wilcoxon signed-rank test tests the null hypothesis that two related paired samples come from the same distribution. In particular, it tests whether the distribution of the differences x - y is symmetric about zero. It is a non-para...
[ "def", "wilcoxon", "(", "self", ")", ":", "t", ",", "p", "=", "ranksums", "(", "self", ".", "sample1", ",", "self", ".", "sample2", ")", "print", "(", "\"=== Wilcoxon Analysis ===\"", ")", "print", "(", "\"The calculated t-statistic: \"", "+", "str", "(", ...
[ 69, 4 ]
[ 81, 57 ]
python
en
['en', 'error', 'th']
False
Engine.get_default
()
Return the first DjangoTemplates backend that's configured, or raise ImproperlyConfigured if none are configured. This is required for preserving historical APIs that rely on a globally available, implicitly configured engine such as: >>> from django.template import Context, T...
Return the first DjangoTemplates backend that's configured, or raise ImproperlyConfigured if none are configured.
def get_default(): """ Return the first DjangoTemplates backend that's configured, or raise ImproperlyConfigured if none are configured. This is required for preserving historical APIs that rely on a globally available, implicitly configured engine such as: >>> from dja...
[ "def", "get_default", "(", ")", ":", "# Since Engine is imported in django.template and since", "# DjangoTemplates is a wrapper around this Engine class,", "# local imports are required to avoid import loops.", "from", "django", ".", "template", "import", "engines", "from", "django", ...
[ 56, 4 ]
[ 78, 79 ]
python
en
['en', 'error', 'th']
False
Engine.from_string
(self, template_code)
Return a compiled Template object for the given template code, handling template inheritance recursively.
Return a compiled Template object for the given template code, handling template inheritance recursively.
def from_string(self, template_code): """ Return a compiled Template object for the given template code, handling template inheritance recursively. """ return Template(template_code, engine=self)
[ "def", "from_string", "(", "self", ",", "template_code", ")", ":", "return", "Template", "(", "template_code", ",", "engine", "=", "self", ")" ]
[ 130, 4 ]
[ 135, 51 ]
python
en
['en', 'error', 'th']
False
Engine.get_template
(self, template_name)
Return a compiled Template object for the given template name, handling template inheritance recursively.
Return a compiled Template object for the given template name, handling template inheritance recursively.
def get_template(self, template_name): """ Return a compiled Template object for the given template name, handling template inheritance recursively. """ template, origin = self.find_template(template_name) if not hasattr(template, 'render'): # template needs t...
[ "def", "get_template", "(", "self", ",", "template_name", ")", ":", "template", ",", "origin", "=", "self", ".", "find_template", "(", "template_name", ")", "if", "not", "hasattr", "(", "template", ",", "'render'", ")", ":", "# template needs to be compiled", ...
[ 137, 4 ]
[ 146, 23 ]
python
en
['en', 'error', 'th']
False
Engine.render_to_string
(self, template_name, context=None)
Render the template specified by template_name with the given context. For use in Django's test suite.
Render the template specified by template_name with the given context. For use in Django's test suite.
def render_to_string(self, template_name, context=None): """ Render the template specified by template_name with the given context. For use in Django's test suite. """ if isinstance(template_name, (list, tuple)): t = self.select_template(template_name) else: ...
[ "def", "render_to_string", "(", "self", ",", "template_name", ",", "context", "=", "None", ")", ":", "if", "isinstance", "(", "template_name", ",", "(", "list", ",", "tuple", ")", ")", ":", "t", "=", "self", ".", "select_template", "(", "template_name", ...
[ 148, 4 ]
[ 162, 73 ]
python
en
['en', 'error', 'th']
False
Engine.select_template
(self, template_name_list)
Given a list of template names, return the first that can be loaded.
Given a list of template names, return the first that can be loaded.
def select_template(self, template_name_list): """ Given a list of template names, return the first that can be loaded. """ if not template_name_list: raise TemplateDoesNotExist("No template names provided") not_found = [] for template_name in template_name_li...
[ "def", "select_template", "(", "self", ",", "template_name_list", ")", ":", "if", "not", "template_name_list", ":", "raise", "TemplateDoesNotExist", "(", "\"No template names provided\"", ")", "not_found", "=", "[", "]", "for", "template_name", "in", "template_name_li...
[ 164, 4 ]
[ 179, 56 ]
python
en
['en', 'error', 'th']
False
print_error
(input_str)
Print given text in red color for Error text :param input_str:
Print given text in red color for Error text :param input_str:
def print_error(input_str): ''' Print given text in red color for Error text :param input_str: ''' print("\033[1;31;40m" + input_str + "\033[0m")
[ "def", "print_error", "(", "input_str", ")", ":", "print", "(", "\"\\033[1;31;40m\"", "+", "input_str", "+", "\"\\033[0m\"", ")" ]
[ 51, 0 ]
[ 56, 50 ]
python
en
['en', 'error', 'th']
False
print_ok
(input_str)
Print given text in green color for Ok text :param input_str:
Print given text in green color for Ok text :param input_str:
def print_ok(input_str): ''' Print given text in green color for Ok text :param input_str: ''' print("\033[1;32;40m" + input_str + "\033[0m")
[ "def", "print_ok", "(", "input_str", ")", ":", "print", "(", "\"\\033[1;32;40m\"", "+", "input_str", "+", "\"\\033[0m\"", ")" ]
[ 59, 0 ]
[ 64, 50 ]
python
en
['en', 'error', 'th']
False
print_warning
(input_str)
Print given text in yellow color for warning text :param input_str:
Print given text in yellow color for warning text :param input_str:
def print_warning(input_str): ''' Print given text in yellow color for warning text :param input_str: ''' print("\033[1;33;40m" + input_str + "\033[0m")
[ "def", "print_warning", "(", "input_str", ")", ":", "print", "(", "\"\\033[1;33;40m\"", "+", "input_str", "+", "\"\\033[0m\"", ")" ]
[ 67, 0 ]
[ 72, 50 ]
python
en
['en', 'error', 'th']
False
print_notice
(input_str)
Print given text in white background :param input_str:
Print given text in white background :param input_str:
def print_notice(input_str): ''' Print given text in white background :param input_str: ''' print("\033[0;30;47m" + input_str + "\033[0m")
[ "def", "print_notice", "(", "input_str", ")", ":", "print", "(", "\"\\033[0;30;47m\"", "+", "input_str", "+", "\"\\033[0m\"", ")" ]
[ 75, 0 ]
[ 80, 50 ]
python
en
['en', 'error', 'th']
False
print_command_response
(input_str)
Print given text in green color for Ok text :param input_str:
Print given text in green color for Ok text :param input_str:
def print_command_response(input_str): ''' Print given text in green color for Ok text :param input_str: ''' print("\033[1;34;40m" + input_str + "\033[0m")
[ "def", "print_command_response", "(", "input_str", ")", ":", "print", "(", "\"\\033[1;34;40m\"", "+", "input_str", "+", "\"\\033[0m\"", ")" ]
[ 83, 0 ]
[ 88, 50 ]
python
en
['en', 'error', 'th']
False
download_omsagent
()
Download omsagent this downloaded file would be installed :return: True if downloaded successfully
Download omsagent this downloaded file would be installed :return: True if downloaded successfully
def download_omsagent(): ''' Download omsagent this downloaded file would be installed :return: True if downloaded successfully ''' print("Trying to download the omsagent.") print_notice("wget " + oms_agent_url) download_command = subprocess.Popen(["wget", oms_agent_url], stdout=subprocess.P...
[ "def", "download_omsagent", "(", ")", ":", "print", "(", "\"Trying to download the omsagent.\"", ")", "print_notice", "(", "\"wget \"", "+", "oms_agent_url", ")", "download_command", "=", "subprocess", ".", "Popen", "(", "[", "\"wget\"", ",", "oms_agent_url", "]", ...
[ 91, 0 ]
[ 105, 15 ]
python
en
['en', 'error', 'th']
False
install_omsagent
(workspace_id, primary_key, oms_agent_install_url)
Installing the downloaded omsagent :param workspace_id: :param primary_key: :return:
Installing the downloaded omsagent :param workspace_id: :param primary_key: :return:
def install_omsagent(workspace_id, primary_key, oms_agent_install_url): ''' Installing the downloaded omsagent :param workspace_id: :param primary_key: :return: ''' print("Installing omsagent") command_tokens = ["sh", omsagent_file_name, "-w", workspace_id, "-s", primary_key, "-d", oms_a...
[ "def", "install_omsagent", "(", "workspace_id", ",", "primary_key", ",", "oms_agent_install_url", ")", ":", "print", "(", "\"Installing omsagent\"", ")", "command_tokens", "=", "[", "\"sh\"", ",", "omsagent_file_name", ",", "\"-w\"", ",", "workspace_id", ",", "\"-s\...
[ 115, 0 ]
[ 132, 15 ]
python
en
['en', 'error', 'th']
False
process_check
(process_name)
function who check using the ps -ef command if the 'process_name' is running :param process_name: :return: True if the process is running else False
function who check using the ps -ef command if the 'process_name' is running :param process_name: :return: True if the process is running else False
def process_check(process_name): ''' function who check using the ps -ef command if the 'process_name' is running :param process_name: :return: True if the process is running else False ''' p1 = subprocess.Popen(["ps", "-ef"], stdout=subprocess.PIPE) p2 = subprocess.Popen(["grep", "-i", proc...
[ "def", "process_check", "(", "process_name", ")", ":", "p1", "=", "subprocess", ".", "Popen", "(", "[", "\"ps\"", ",", "\"-ef\"", "]", ",", "stdout", "=", "subprocess", ".", "PIPE", ")", "p2", "=", "subprocess", ".", "Popen", "(", "[", "\"grep\"", ",",...
[ 135, 0 ]
[ 146, 22 ]
python
en
['en', 'error', 'th']
False
create_daemon_forwarding_configuration
(omsagent_incoming_port, daemon_configuration_path, daemon_name)
Create the daemon configuration to forward messages over TCP to the oms agent :param omsagent_incoming_port: port for communication between the omsagent the the daemon :param daemon_configuration_path: path of the configuration file :param daemon_name: name of the daemon :return:
Create the daemon configuration to forward messages over TCP to the oms agent :param omsagent_incoming_port: port for communication between the omsagent the the daemon :param daemon_configuration_path: path of the configuration file :param daemon_name: name of the daemon :return:
def create_daemon_forwarding_configuration(omsagent_incoming_port, daemon_configuration_path, daemon_name): ''' Create the daemon configuration to forward messages over TCP to the oms agent :param omsagent_incoming_port: port for communication between the omsagent the the daemon :param daemon_config...
[ "def", "create_daemon_forwarding_configuration", "(", "omsagent_incoming_port", ",", "daemon_configuration_path", ",", "daemon_name", ")", ":", "print", "(", "\"Creating \"", "+", "daemon_name", "+", "\" daemon configuration.\"", ")", "print", "(", "\"Configuration is changed...
[ 149, 0 ]
[ 166, 15 ]
python
en
['en', 'error', 'th']
False
set_omsagent_configuration
(workspace_id, omsagent_incoming_port)
Download the omsagent configuration and then change the omsagent incoming port if required and change the protocol if required :param workspace_id: :param omsagent_incoming_port: :param tcp: :param udp: :return:
Download the omsagent configuration and then change the omsagent incoming port if required and change the protocol if required :param workspace_id: :param omsagent_incoming_port: :param tcp: :param udp: :return:
def set_omsagent_configuration(workspace_id, omsagent_incoming_port): ''' Download the omsagent configuration and then change the omsagent incoming port if required and change the protocol if required :param workspace_id: :param omsagent_incoming_port: :param tcp: :param udp: :return: ...
[ "def", "set_omsagent_configuration", "(", "workspace_id", ",", "omsagent_incoming_port", ")", ":", "configuration_path", "=", "\"/etc/opt/microsoft/omsagent/\"", "+", "workspace_id", "+", "\"/conf/omsagent.d/security_events.conf\"", "print", "(", "\"Creating omsagent configuration ...
[ 169, 0 ]
[ 203, 20 ]
python
en
['en', 'error', 'th']
False
set_rsyslog_configuration
()
Set the configuration for rsyslog we support from version 7 and above :return:
Set the configuration for rsyslog we support from version 7 and above :return:
def set_rsyslog_configuration(): ''' Set the configuration for rsyslog we support from version 7 and above :return: ''' if is_rsyslog_new_configuration(): set_rsyslog_new_configuration() else: set_rsyslog_old_configuration()
[ "def", "set_rsyslog_configuration", "(", ")", ":", "if", "is_rsyslog_new_configuration", "(", ")", ":", "set_rsyslog_new_configuration", "(", ")", "else", ":", "set_rsyslog_old_configuration", "(", ")" ]
[ 263, 0 ]
[ 272, 39 ]
python
en
['en', 'error', 'th']
False
change_omsagent_protocol
(configuration_path)
Changing the omsagent protocol, since the protocol type is set on the omsagent configuration file :param configuration_path:
Changing the omsagent protocol, since the protocol type is set on the omsagent configuration file :param configuration_path:
def change_omsagent_protocol(configuration_path): ''' Changing the omsagent protocol, since the protocol type is set on the omsagent configuration file :param configuration_path: ''' try: # if opening this file failed the installation of the oms-agent has failed fin = open(config...
[ "def", "change_omsagent_protocol", "(", "configuration_path", ")", ":", "try", ":", "# if opening this file failed the installation of the oms-agent has failed", "fin", "=", "open", "(", "configuration_path", ",", "\"rt\"", ")", "with", "open", "(", "\"tmp.txt\"", ",", "\...
[ 275, 0 ]
[ 303, 15 ]
python
en
['en', 'error', 'th']
False
change_omsagent_configuration_port
(omsagent_incoming_port, configuration_path)
Changing the omsagent configuration port if required :param omsagent_incoming_port: :param configuration_path:
Changing the omsagent configuration port if required :param omsagent_incoming_port: :param configuration_path:
def change_omsagent_configuration_port(omsagent_incoming_port, configuration_path): ''' Changing the omsagent configuration port if required :param omsagent_incoming_port: :param configuration_path: ''' with open(configuration_path, "rt") as fin: with open("tmp.txt", "wt") as fout: ...
[ "def", "change_omsagent_configuration_port", "(", "omsagent_incoming_port", ",", "configuration_path", ")", ":", "with", "open", "(", "configuration_path", ",", "\"rt\"", ")", "as", "fin", ":", "with", "open", "(", "\"tmp.txt\"", ",", "\"wt\"", ")", "as", "fout", ...
[ 306, 0 ]
[ 324, 15 ]
python
en
['en', 'error', 'th']
False
restart_rsyslog
()
Restart the Rsyslog daemon
Restart the Rsyslog daemon
def restart_rsyslog(): ''' Restart the Rsyslog daemon ''' print("Restarting rsyslog daemon.") command_tokens = ["sudo", "service", "rsyslog", "restart"] print_notice(" ".join(command_tokens)) restart_rsyslog_command = subprocess.Popen(command_tokens, stdout=subprocess.PIPE) time.sleep(3)...
[ "def", "restart_rsyslog", "(", ")", ":", "print", "(", "\"Restarting rsyslog daemon.\"", ")", "command_tokens", "=", "[", "\"sudo\"", ",", "\"service\"", ",", "\"rsyslog\"", ",", "\"restart\"", "]", "print_notice", "(", "\" \"", ".", "join", "(", "command_tokens",...
[ 327, 0 ]
[ 341, 15 ]
python
en
['en', 'error', 'th']
False
restart_syslog_ng
()
Restart the syslog-ng daemon
Restart the syslog-ng daemon
def restart_syslog_ng(): ''' Restart the syslog-ng daemon ''' print("Restarting syslog-ng daemon.") command_tokens = ["sudo", "service", "syslog-ng", "restart"] print_notice(" ".join(command_tokens)) restart_rsyslog_command = subprocess.Popen(command_tokens, stdout=subprocess.PIPE) time....
[ "def", "restart_syslog_ng", "(", ")", ":", "print", "(", "\"Restarting syslog-ng daemon.\"", ")", "command_tokens", "=", "[", "\"sudo\"", ",", "\"service\"", ",", "\"syslog-ng\"", ",", "\"restart\"", "]", "print_notice", "(", "\" \"", ".", "join", "(", "command_to...
[ 344, 0 ]
[ 358, 15 ]
python
en
['en', 'error', 'th']
False
restart_omsagent
(workspace_id)
Restart the omsagent :param workspace_id:
Restart the omsagent :param workspace_id:
def restart_omsagent(workspace_id): ''' Restart the omsagent :param workspace_id: ''' print("Trying to restart omsagent") command_tokens = ["sudo", "/opt/microsoft/omsagent/bin/service_control", "restart", workspace_id] print_notice(" ".join(command_tokens)) restart_omsagent_command = su...
[ "def", "restart_omsagent", "(", "workspace_id", ")", ":", "print", "(", "\"Trying to restart omsagent\"", ")", "command_tokens", "=", "[", "\"sudo\"", ",", "\"/opt/microsoft/omsagent/bin/service_control\"", ",", "\"restart\"", ",", "workspace_id", "]", "print_notice", "("...
[ 361, 0 ]
[ 376, 15 ]
python
en
['en', 'error', 'th']
False
get_daemon_configuration_content
(daemon_name, omsagent_incoming_port)
Return the correct configuration according to the daemon name :param daemon_name: :param omsagent_incoming_port: :return:
Return the correct configuration according to the daemon name :param daemon_name: :param omsagent_incoming_port: :return:
def get_daemon_configuration_content(daemon_name, omsagent_incoming_port): ''' Return the correct configuration according to the daemon name :param daemon_name: :param omsagent_incoming_port: :return: ''' if daemon_name is rsyslog_daemon_name: return get_rsyslog_daemon_configuration_...
[ "def", "get_daemon_configuration_content", "(", "daemon_name", ",", "omsagent_incoming_port", ")", ":", "if", "daemon_name", "is", "rsyslog_daemon_name", ":", "return", "get_rsyslog_daemon_configuration_content", "(", "omsagent_incoming_port", ")", "elif", "daemon_name", "is"...
[ 379, 0 ]
[ 392, 20 ]
python
en
['en', 'error', 'th']
False
get_rsyslog_daemon_configuration_content
(omsagent_incoming_port)
Rsyslog accept every message containing CEF or ASA(for Cisco ASA
Rsyslog accept every message containing CEF or ASA(for Cisco ASA
def get_rsyslog_daemon_configuration_content(omsagent_incoming_port): '''Rsyslog accept every message containing CEF or ASA(for Cisco ASA''' rsyslog_daemon_configuration_content = ":rawmsg, regex, \"CEF\"|\"ASA\" \n*.* @@127.0.0.1:"+ omsagent_incoming_port print("Rsyslog daemon configuration content:") ...
[ "def", "get_rsyslog_daemon_configuration_content", "(", "omsagent_incoming_port", ")", ":", "rsyslog_daemon_configuration_content", "=", "\":rawmsg, regex, \\\"CEF\\\"|\\\"ASA\\\" \\n*.* @@127.0.0.1:\"", "+", "omsagent_incoming_port", "print", "(", "\"Rsyslog daemon configuration content:\...
[ 395, 0 ]
[ 401, 18 ]
python
en
['en', 'gl', 'en']
True
is_rsyslog
()
Returns True if the daemon is 'Rsyslog'
Returns True if the daemon is 'Rsyslog'
def is_rsyslog(): ''' Returns True if the daemon is 'Rsyslog' ''' # Meaning ps -ef | grep "daemon name" has returned more then the grep result return process_check(rsyslog_daemon_name) > 1
[ "def", "is_rsyslog", "(", ")", ":", "# Meaning ps -ef | grep \"daemon name\" has returned more then the grep result", "return", "process_check", "(", "rsyslog_daemon_name", ")", ">", "1" ]
[ 415, 0 ]
[ 420, 49 ]
python
en
['en', 'error', 'th']
False
is_syslog_ng
()
Returns True if the daemon is 'Syslogng'
Returns True if the daemon is 'Syslogng'
def is_syslog_ng(): ''' Returns True if the daemon is 'Syslogng' ''' # Meaning ps -ef | grep "daemon name" has returned more then the grep result return process_check(syslog_ng_daemon_name) > 1
[ "def", "is_syslog_ng", "(", ")", ":", "# Meaning ps -ef | grep \"daemon name\" has returned more then the grep result", "return", "process_check", "(", "syslog_ng_daemon_name", ")", ">", "1" ]
[ 423, 0 ]
[ 428, 51 ]
python
en
['en', 'error', 'th']
False
set_syslog_ng_configuration
()
syslog ng have a default configuration which enables the incoming ports and define the source pipe to the daemon this will verify it is configured correctly :return:
syslog ng have a default configuration which enables the incoming ports and define the source pipe to the daemon this will verify it is configured correctly :return:
def set_syslog_ng_configuration(): ''' syslog ng have a default configuration which enables the incoming ports and define the source pipe to the daemon this will verify it is configured correctly :return: ''' comment_line = False snet_found = False with open(syslog_ng_conf_path, "rt") as...
[ "def", "set_syslog_ng_configuration", "(", ")", ":", "comment_line", "=", "False", "snet_found", "=", "False", "with", "open", "(", "syslog_ng_conf_path", ",", "\"rt\"", ")", "as", "fin", ":", "with", "open", "(", "\"tmp.txt\"", ",", "\"wt\"", ")", "as", "fo...
[ 431, 0 ]
[ 464, 15 ]
python
en
['en', 'error', 'th']
False
async_unsafe
(message)
Decorator to mark functions as async-unsafe. Someone trying to access the function while in an async context will get an error message.
Decorator to mark functions as async-unsafe. Someone trying to access the function while in an async context will get an error message.
def async_unsafe(message): """ Decorator to mark functions as async-unsafe. Someone trying to access the function while in an async context will get an error message. """ def decorator(func): @functools.wraps(func) def inner(*args, **kwargs): if not os.environ.get('DJANGO...
[ "def", "async_unsafe", "(", "message", ")", ":", "def", "decorator", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "inner", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "os", ".", "environ", ...
[ 7, 0 ]
[ 33, 24 ]
python
en
['en', 'error', 'th']
False
_get_prepared_distribution
( req, # type: InstallRequirement req_tracker, # type: RequirementTracker finder, # type: PackageFinder build_isolation, # type: bool )
Prepare a distribution for installation.
Prepare a distribution for installation.
def _get_prepared_distribution( req, # type: InstallRequirement req_tracker, # type: RequirementTracker finder, # type: PackageFinder build_isolation, # type: bool ): # type: (...) -> Distribution """Prepare a distribution for installation.""" abstract_dist = make_distribution_for_instal...
[ "def", "_get_prepared_distribution", "(", "req", ",", "# type: InstallRequirement", "req_tracker", ",", "# type: RequirementTracker", "finder", ",", "# type: PackageFinder", "build_isolation", ",", "# type: bool", ")", ":", "# type: (...) -> Distribution", "abstract_dist", "=",...
[ 49, 0 ]
[ 60, 57 ]
python
it
['it', 'it', 'en']
True
_copy2_ignoring_special_files
(src, dest)
Copying special files is not supported, but as a convenience to users we skip errors copying them. This supports tools that may create e.g. socket files in the project source directory.
Copying special files is not supported, but as a convenience to users we skip errors copying them. This supports tools that may create e.g. socket files in the project source directory.
def _copy2_ignoring_special_files(src, dest): # type: (str, str) -> None """Copying special files is not supported, but as a convenience to users we skip errors copying them. This supports tools that may create e.g. socket files in the project source directory. """ try: copy2_fixed(src, ...
[ "def", "_copy2_ignoring_special_files", "(", "src", ",", "dest", ")", ":", "# type: (str, str) -> None", "try", ":", "copy2_fixed", "(", "src", ",", "dest", ")", "except", "shutil", ".", "SpecialFileError", "as", "e", ":", "# SpecialFileError may be raised due to eith...
[ 108, 0 ]
[ 126, 9 ]
python
en
['en', 'en', 'en']
True
get_file_url
( link, # type: Link download_dir=None, # type: Optional[str] hashes=None # type: Optional[Hashes] )
Get file and optionally check its hash.
Get file and optionally check its hash.
def get_file_url( link, # type: Link download_dir=None, # type: Optional[str] hashes=None # type: Optional[Hashes] ): # type: (...) -> File """Get file and optionally check its hash. """ # If a download dir is specified, is the file already there and valid? already_downloaded_path = N...
[ "def", "get_file_url", "(", "link", ",", "# type: Link", "download_dir", "=", "None", ",", "# type: Optional[str]", "hashes", "=", "None", "# type: Optional[Hashes]", ")", ":", "# type: (...) -> File", "# If a download dir is specified, is the file already there and valid?", "a...
[ 160, 0 ]
[ 187, 32 ]
python
en
['en', 'en', 'en']
True
unpack_url
( link, # type: Link location, # type: str download, # type: Downloader download_dir=None, # type: Optional[str] hashes=None, # type: Optional[Hashes] )
Unpack link into location, downloading if required. :param hashes: A Hashes object, one of whose embedded hashes must match, or HashMismatch will be raised. If the Hashes is empty, no matches are required, and unhashable types of requirements (like VCS ones, which would ordinarily raise Has...
Unpack link into location, downloading if required.
def unpack_url( link, # type: Link location, # type: str download, # type: Downloader download_dir=None, # type: Optional[str] hashes=None, # type: Optional[Hashes] ): # type: (...) -> Optional[File] """Unpack link into location, downloading if required. :param hashes: A Hashes obj...
[ "def", "unpack_url", "(", "link", ",", "# type: Link", "location", ",", "# type: str", "download", ",", "# type: Downloader", "download_dir", "=", "None", ",", "# type: Optional[str]", "hashes", "=", "None", ",", "# type: Optional[Hashes]", ")", ":", "# type: (...) ->...
[ 190, 0 ]
[ 250, 15 ]
python
en
['it', 'en', 'en']
True
_check_download_dir
(link, download_dir, hashes)
Check download_dir for previously downloaded file with correct hash If a correct file is found return its path else None
Check download_dir for previously downloaded file with correct hash If a correct file is found return its path else None
def _check_download_dir(link, download_dir, hashes): # type: (Link, str, Optional[Hashes]) -> Optional[str] """ Check download_dir for previously downloaded file with correct hash If a correct file is found return its path else None """ download_path = os.path.join(download_dir, link.filename) ...
[ "def", "_check_download_dir", "(", "link", ",", "download_dir", ",", "hashes", ")", ":", "# type: (Link, str, Optional[Hashes]) -> Optional[str]", "download_path", "=", "os", ".", "path", ".", "join", "(", "download_dir", ",", "link", ".", "filename", ")", "if", "...
[ 253, 0 ]
[ 276, 24 ]
python
en
['en', 'en', 'en']
True
RequirementPreparer._log_preparing_link
(self, req)
Provide context for the requirement being prepared.
Provide context for the requirement being prepared.
def _log_preparing_link(self, req): # type: (InstallRequirement) -> None """Provide context for the requirement being prepared.""" if req.link.is_file and not req.original_link_is_in_wheel_cache: message = "Processing %s" information = str(display_path(req.link.file_path)...
[ "def", "_log_preparing_link", "(", "self", ",", "req", ")", ":", "# type: (InstallRequirement) -> None", "if", "req", ".", "link", ".", "is_file", "and", "not", "req", ".", "original_link_is_in_wheel_cache", ":", "message", "=", "\"Processing %s\"", "information", "...
[ 334, 4 ]
[ 350, 65 ]
python
en
['en', 'en', 'en']
True
RequirementPreparer._ensure_link_req_src_dir
(self, req, parallel_builds)
Ensure source_dir of a linked InstallRequirement.
Ensure source_dir of a linked InstallRequirement.
def _ensure_link_req_src_dir(self, req, parallel_builds): # type: (InstallRequirement, bool) -> None """Ensure source_dir of a linked InstallRequirement.""" # Since source_dir is only set for editable requirements. if req.link.is_wheel: # We don't need to unpack wheels, so no...
[ "def", "_ensure_link_req_src_dir", "(", "self", ",", "req", ",", "parallel_builds", ")", ":", "# type: (InstallRequirement, bool) -> None", "# Since source_dir is only set for editable requirements.", "if", "req", ".", "link", ".", "is_wheel", ":", "# We don't need to unpack wh...
[ 352, 4 ]
[ 385, 13 ]
python
en
['en', 'en', 'en']
True
RequirementPreparer._fetch_metadata_using_lazy_wheel
(self, link)
Fetch metadata using lazy wheel, if possible.
Fetch metadata using lazy wheel, if possible.
def _fetch_metadata_using_lazy_wheel(self, link): # type: (Link) -> Optional[Distribution] """Fetch metadata using lazy wheel, if possible.""" if not self.use_lazy_wheel: return None if self.require_hashes: logger.debug('Lazy wheel is not used as hash checking is ...
[ "def", "_fetch_metadata_using_lazy_wheel", "(", "self", ",", "link", ")", ":", "# type: (Link) -> Optional[Distribution]", "if", "not", "self", ".", "use_lazy_wheel", ":", "return", "None", "if", "self", ".", "require_hashes", ":", "logger", ".", "debug", "(", "'L...
[ 420, 4 ]
[ 447, 23 ]
python
en
['en', 'en', 'en']
True
RequirementPreparer._complete_partial_requirements
( self, partially_downloaded_reqs, # type: Iterable[InstallRequirement] parallel_builds=False, # type: bool )
Download any requirements which were only fetched by metadata.
Download any requirements which were only fetched by metadata.
def _complete_partial_requirements( self, partially_downloaded_reqs, # type: Iterable[InstallRequirement] parallel_builds=False, # type: bool ): # type: (...) -> None """Download any requirements which were only fetched by metadata.""" # Download to a temporary ...
[ "def", "_complete_partial_requirements", "(", "self", ",", "partially_downloaded_reqs", ",", "# type: Iterable[InstallRequirement]", "parallel_builds", "=", "False", ",", "# type: bool", ")", ":", "# type: (...) -> None", "# Download to a temporary directory. These will be copied ove...
[ 449, 4 ]
[ 480, 66 ]
python
en
['en', 'en', 'en']
True
RequirementPreparer.prepare_linked_requirement
(self, req, parallel_builds=False)
Prepare a requirement to be obtained from req.link.
Prepare a requirement to be obtained from req.link.
def prepare_linked_requirement(self, req, parallel_builds=False): # type: (InstallRequirement, bool) -> Distribution """Prepare a requirement to be obtained from req.link.""" assert req.link link = req.link self._log_preparing_link(req) with indent_log(): # Ch...
[ "def", "prepare_linked_requirement", "(", "self", ",", "req", ",", "parallel_builds", "=", "False", ")", ":", "# type: (InstallRequirement, bool) -> Distribution", "assert", "req", ".", "link", "link", "=", "req", ".", "link", "self", ".", "_log_preparing_link", "("...
[ 482, 4 ]
[ 507, 73 ]
python
en
['en', 'en', 'en']
True
RequirementPreparer.prepare_linked_requirements_more
(self, reqs, parallel_builds=False)
Prepare linked requirements more, if needed.
Prepare linked requirements more, if needed.
def prepare_linked_requirements_more(self, reqs, parallel_builds=False): # type: (Iterable[InstallRequirement], bool) -> None """Prepare linked requirements more, if needed.""" reqs = [req for req in reqs if req.needs_more_preparation] for req in reqs: # Determine if any of t...
[ "def", "prepare_linked_requirements_more", "(", "self", ",", "reqs", ",", "parallel_builds", "=", "False", ")", ":", "# type: (Iterable[InstallRequirement], bool) -> None", "reqs", "=", "[", "req", "for", "req", "in", "reqs", "if", "req", ".", "needs_more_preparation"...
[ 509, 4 ]
[ 535, 9 ]
python
en
['en', 'en', 'en']
True
RequirementPreparer.prepare_editable_requirement
( self, req, # type: InstallRequirement )
Prepare an editable requirement
Prepare an editable requirement
def prepare_editable_requirement( self, req, # type: InstallRequirement ): # type: (...) -> Distribution """Prepare an editable requirement """ assert req.editable, "cannot prepare a non-editable req as editable" logger.info('Obtaining %s', req) wit...
[ "def", "prepare_editable_requirement", "(", "self", ",", "req", ",", "# type: InstallRequirement", ")", ":", "# type: (...) -> Distribution", "assert", "req", ".", "editable", ",", "\"cannot prepare a non-editable req as editable\"", "logger", ".", "info", "(", "'Obtaining ...
[ 600, 4 ]
[ 627, 19 ]
python
en
['en', 'en', 'en']
True
RequirementPreparer.prepare_installed_requirement
( self, req, # type: InstallRequirement skip_reason # type: str )
Prepare an already-installed requirement
Prepare an already-installed requirement
def prepare_installed_requirement( self, req, # type: InstallRequirement skip_reason # type: str ): # type: (...) -> Distribution """Prepare an already-installed requirement """ assert req.satisfied_by, "req should have been satisfied but isn't" asse...
[ "def", "prepare_installed_requirement", "(", "self", ",", "req", ",", "# type: InstallRequirement", "skip_reason", "# type: str", ")", ":", "# type: (...) -> Distribution", "assert", "req", ".", "satisfied_by", ",", "\"req should have been satisfied but isn't\"", "assert", "s...
[ 629, 4 ]
[ 654, 78 ]
python
en
['en', 'en', 'en']
True
get_template
(template_name, using=None)
Load and return a template for the given name. Raise TemplateDoesNotExist if no such template exists.
Load and return a template for the given name.
def get_template(template_name, using=None): """ Load and return a template for the given name. Raise TemplateDoesNotExist if no such template exists. """ chain = [] engines = _engine_list(using) for engine in engines: try: return engine.get_template(template_name) ...
[ "def", "get_template", "(", "template_name", ",", "using", "=", "None", ")", ":", "chain", "=", "[", "]", "engines", "=", "_engine_list", "(", "using", ")", "for", "engine", "in", "engines", ":", "try", ":", "return", "engine", ".", "get_template", "(", ...
[ 4, 0 ]
[ 18, 58 ]
python
en
['en', 'error', 'th']
False
select_template
(template_name_list, using=None)
Load and return a template for one of the given names. Try names in order and return the first template found. Raise TemplateDoesNotExist if no such template exists.
Load and return a template for one of the given names.
def select_template(template_name_list, using=None): """ Load and return a template for one of the given names. Try names in order and return the first template found. Raise TemplateDoesNotExist if no such template exists. """ if isinstance(template_name_list, str): raise TypeError( ...
[ "def", "select_template", "(", "template_name_list", ",", "using", "=", "None", ")", ":", "if", "isinstance", "(", "template_name_list", ",", "str", ")", ":", "raise", "TypeError", "(", "'select_template() takes an iterable of template names but got a '", "'string: %r. Us...
[ 21, 0 ]
[ 48, 64 ]
python
en
['en', 'error', 'th']
False
render_to_string
(template_name, context=None, request=None, using=None)
Load a template and render it with a context. Return a string. template_name may be a string or a list of strings.
Load a template and render it with a context. Return a string.
def render_to_string(template_name, context=None, request=None, using=None): """ Load a template and render it with a context. Return a string. template_name may be a string or a list of strings. """ if isinstance(template_name, (list, tuple)): template = select_template(template_name, usin...
[ "def", "render_to_string", "(", "template_name", ",", "context", "=", "None", ",", "request", "=", "None", ",", "using", "=", "None", ")", ":", "if", "isinstance", "(", "template_name", ",", "(", "list", ",", "tuple", ")", ")", ":", "template", "=", "s...
[ 51, 0 ]
[ 61, 44 ]
python
en
['en', 'error', 'th']
False
dist_from_wheel_url
(name: str, url: str, session: PipSession)
Return a pkg_resources.Distribution from the given wheel URL. This uses HTTP range requests to only fetch the potion of the wheel containing metadata, just enough for the object to be constructed. If such requests are not supported, HTTPRangeRequestUnsupported is raised.
Return a pkg_resources.Distribution from the given wheel URL.
def dist_from_wheel_url(name: str, url: str, session: PipSession) -> Distribution: """Return a pkg_resources.Distribution from the given wheel URL. This uses HTTP range requests to only fetch the potion of the wheel containing metadata, just enough for the object to be constructed. If such requests are...
[ "def", "dist_from_wheel_url", "(", "name", ":", "str", ",", "url", ":", "str", ",", "session", ":", "PipSession", ")", "->", "Distribution", ":", "with", "LazyZipOverHTTP", "(", "url", ",", "session", ")", "as", "wheel", ":", "# For read-only ZIP files, ZipFil...
[ 22, 0 ]
[ 36, 79 ]
python
en
['en', 'en', 'en']
True
LazyZipOverHTTP.mode
(self)
Opening mode, which is always rb.
Opening mode, which is always rb.
def mode(self) -> str: """Opening mode, which is always rb.""" return "rb"
[ "def", "mode", "(", "self", ")", "->", "str", ":", "return", "\"rb\"" ]
[ 65, 4 ]
[ 67, 19 ]
python
en
['en', 'en', 'en']
True
LazyZipOverHTTP.name
(self)
Path to the underlying file.
Path to the underlying file.
def name(self) -> str: """Path to the underlying file.""" return self._file.name
[ "def", "name", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_file", ".", "name" ]
[ 70, 4 ]
[ 72, 30 ]
python
en
['en', 'en', 'en']
True
LazyZipOverHTTP.seekable
(self)
Return whether random access is supported, which is True.
Return whether random access is supported, which is True.
def seekable(self) -> bool: """Return whether random access is supported, which is True.""" return True
[ "def", "seekable", "(", "self", ")", "->", "bool", ":", "return", "True" ]
[ 74, 4 ]
[ 76, 19 ]
python
en
['en', 'en', 'en']
True
LazyZipOverHTTP.close
(self)
Close the file.
Close the file.
def close(self) -> None: """Close the file.""" self._file.close()
[ "def", "close", "(", "self", ")", "->", "None", ":", "self", ".", "_file", ".", "close", "(", ")" ]
[ 78, 4 ]
[ 80, 26 ]
python
en
['en', 'it', 'en']
True
LazyZipOverHTTP.closed
(self)
Whether the file is closed.
Whether the file is closed.
def closed(self) -> bool: """Whether the file is closed.""" return self._file.closed
[ "def", "closed", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "_file", ".", "closed" ]
[ 83, 4 ]
[ 85, 32 ]
python
en
['en', 'en', 'en']
True
LazyZipOverHTTP.read
(self, size: int = -1)
Read up to size bytes from the object and return them. As a convenience, if size is unspecified or -1, all bytes until EOF are returned. Fewer than size bytes may be returned if EOF is reached.
Read up to size bytes from the object and return them.
def read(self, size: int = -1) -> bytes: """Read up to size bytes from the object and return them. As a convenience, if size is unspecified or -1, all bytes until EOF are returned. Fewer than size bytes may be returned if EOF is reached. """ download_size = max(size, se...
[ "def", "read", "(", "self", ",", "size", ":", "int", "=", "-", "1", ")", "->", "bytes", ":", "download_size", "=", "max", "(", "size", ",", "self", ".", "_chunk_size", ")", "start", ",", "length", "=", "self", ".", "tell", "(", ")", ",", "self", ...
[ 87, 4 ]
[ 99, 36 ]
python
en
['en', 'en', 'en']
True
LazyZipOverHTTP.readable
(self)
Return whether the file is readable, which is True.
Return whether the file is readable, which is True.
def readable(self) -> bool: """Return whether the file is readable, which is True.""" return True
[ "def", "readable", "(", "self", ")", "->", "bool", ":", "return", "True" ]
[ 101, 4 ]
[ 103, 19 ]
python
en
['en', 'en', 'en']
True
LazyZipOverHTTP.seek
(self, offset: int, whence: int = 0)
Change stream position and return the new absolute position. Seek to offset relative position indicated by whence: * 0: Start of stream (the default). pos should be >= 0; * 1: Current position - pos may be negative; * 2: End of stream - pos usually negative.
Change stream position and return the new absolute position.
def seek(self, offset: int, whence: int = 0) -> int: """Change stream position and return the new absolute position. Seek to offset relative position indicated by whence: * 0: Start of stream (the default). pos should be >= 0; * 1: Current position - pos may be negative; * 2: E...
[ "def", "seek", "(", "self", ",", "offset", ":", "int", ",", "whence", ":", "int", "=", "0", ")", "->", "int", ":", "return", "self", ".", "_file", ".", "seek", "(", "offset", ",", "whence", ")" ]
[ 105, 4 ]
[ 113, 46 ]
python
en
['en', 'en', 'en']
True
LazyZipOverHTTP.tell
(self)
Return the current position.
Return the current position.
def tell(self) -> int: """Return the current position.""" return self._file.tell()
[ "def", "tell", "(", "self", ")", "->", "int", ":", "return", "self", ".", "_file", ".", "tell", "(", ")" ]
[ 115, 4 ]
[ 117, 32 ]
python
en
['en', 'en', 'en']
True
LazyZipOverHTTP.truncate
(self, size: Optional[int] = None)
Resize the stream to the given size in bytes. If size is unspecified resize to the current position. The current stream position isn't changed. Return the new file size.
Resize the stream to the given size in bytes.
def truncate(self, size: Optional[int] = None) -> int: """Resize the stream to the given size in bytes. If size is unspecified resize to the current position. The current stream position isn't changed. Return the new file size. """ return self._file.truncate(size)
[ "def", "truncate", "(", "self", ",", "size", ":", "Optional", "[", "int", "]", "=", "None", ")", "->", "int", ":", "return", "self", ".", "_file", ".", "truncate", "(", "size", ")" ]
[ 119, 4 ]
[ 127, 40 ]
python
en
['en', 'en', 'en']
True
LazyZipOverHTTP.writable
(self)
Return False.
Return False.
def writable(self) -> bool: """Return False.""" return False
[ "def", "writable", "(", "self", ")", "->", "bool", ":", "return", "False" ]
[ 129, 4 ]
[ 131, 20 ]
python
en
['en', 'ms', 'en']
False
LazyZipOverHTTP._stay
(self)
Return a context manager keeping the position. At the end of the block, seek back to original position.
Return a context manager keeping the position.
def _stay(self) -> Iterator[None]: """Return a context manager keeping the position. At the end of the block, seek back to original position. """ pos = self.tell() try: yield finally: self.seek(pos)
[ "def", "_stay", "(", "self", ")", "->", "Iterator", "[", "None", "]", ":", "pos", "=", "self", ".", "tell", "(", ")", "try", ":", "yield", "finally", ":", "self", ".", "seek", "(", "pos", ")" ]
[ 141, 4 ]
[ 150, 26 ]
python
en
['en', 'en', 'en']
True
LazyZipOverHTTP._check_zip
(self)
Check and download until the file is a valid ZIP.
Check and download until the file is a valid ZIP.
def _check_zip(self) -> None: """Check and download until the file is a valid ZIP.""" end = self._length - 1 for start in reversed(range(0, end, self._chunk_size)): self._download(start, end) with self._stay(): try: # For read-only ZIP ...
[ "def", "_check_zip", "(", "self", ")", "->", "None", ":", "end", "=", "self", ".", "_length", "-", "1", "for", "start", "in", "reversed", "(", "range", "(", "0", ",", "end", ",", "self", ".", "_chunk_size", ")", ")", ":", "self", ".", "_download", ...
[ 152, 4 ]
[ 165, 25 ]
python
en
['en', 'en', 'en']
True
LazyZipOverHTTP._stream_response
( self, start: int, end: int, base_headers: Dict[str, str] = HEADERS )
Return HTTP response to a range request from start to end.
Return HTTP response to a range request from start to end.
def _stream_response( self, start: int, end: int, base_headers: Dict[str, str] = HEADERS ) -> Response: """Return HTTP response to a range request from start to end.""" headers = base_headers.copy() headers["Range"] = f"bytes={start}-{end}" # TODO: Get range requests to be co...
[ "def", "_stream_response", "(", "self", ",", "start", ":", "int", ",", "end", ":", "int", ",", "base_headers", ":", "Dict", "[", "str", ",", "str", "]", "=", "HEADERS", ")", "->", "Response", ":", "headers", "=", "base_headers", ".", "copy", "(", ")"...
[ 167, 4 ]
[ 175, 73 ]
python
en
['en', 'en', 'en']
True
LazyZipOverHTTP._merge
( self, start: int, end: int, left: int, right: int )
Return an iterator of intervals to be fetched. Args: start (int): Start of needed interval end (int): End of needed interval left (int): Index of first overlapping downloaded data right (int): Index after last overlapping downloaded data
Return an iterator of intervals to be fetched.
def _merge( self, start: int, end: int, left: int, right: int ) -> Iterator[Tuple[int, int]]: """Return an iterator of intervals to be fetched. Args: start (int): Start of needed interval end (int): End of needed interval left (int): Index of first overla...
[ "def", "_merge", "(", "self", ",", "start", ":", "int", ",", "end", ":", "int", ",", "left", ":", "int", ",", "right", ":", "int", ")", "->", "Iterator", "[", "Tuple", "[", "int", ",", "int", "]", "]", ":", "lslice", ",", "rslice", "=", "self",...
[ 177, 4 ]
[ 197, 72 ]
python
en
['en', 'en', 'en']
True
LazyZipOverHTTP._download
(self, start: int, end: int)
Download bytes from start to end inclusively.
Download bytes from start to end inclusively.
def _download(self, start: int, end: int) -> None: """Download bytes from start to end inclusively.""" with self._stay(): left = bisect_left(self._right, start) right = bisect_right(self._left, end) for start, end in self._merge(start, end, left, right): ...
[ "def", "_download", "(", "self", ",", "start", ":", "int", ",", "end", ":", "int", ")", "->", "None", ":", "with", "self", ".", "_stay", "(", ")", ":", "left", "=", "bisect_left", "(", "self", ".", "_right", ",", "start", ")", "right", "=", "bise...
[ 199, 4 ]
[ 209, 43 ]
python
en
['en', 'en', 'en']
True
SearchScope.create
( cls, find_links: List[str], index_urls: List[str], )
Create a SearchScope object after normalizing the `find_links`.
Create a SearchScope object after normalizing the `find_links`.
def create( cls, find_links: List[str], index_urls: List[str], ) -> "SearchScope": """ Create a SearchScope object after normalizing the `find_links`. """ # Build find_links. If an argument starts with ~, it may be # a local file relative to a home dir...
[ "def", "create", "(", "cls", ",", "find_links", ":", "List", "[", "str", "]", ",", "index_urls", ":", "List", "[", "str", "]", ",", ")", "->", "\"SearchScope\"", ":", "# Build find_links. If an argument starts with ~, it may be", "# a local file relative to a home dir...
[ 25, 4 ]
[ 62, 9 ]
python
en
['en', 'error', 'th']
False
SearchScope.get_index_urls_locations
(self, project_name: str)
Returns the locations found via self.index_urls Checks the url_name on the main (first in the list) index and use this url_name to produce all locations
Returns the locations found via self.index_urls
def get_index_urls_locations(self, project_name: str) -> List[str]: """Returns the locations found via self.index_urls Checks the url_name on the main (first in the list) index and use this url_name to produce all locations """ def mkurl_pypi_url(url: str) -> str: l...
[ "def", "get_index_urls_locations", "(", "self", ",", "project_name", ":", "str", ")", "->", "List", "[", "str", "]", ":", "def", "mkurl_pypi_url", "(", "url", ":", "str", ")", "->", "str", ":", "loc", "=", "posixpath", ".", "join", "(", "url", ",", "...
[ 105, 4 ]
[ 125, 63 ]
python
en
['en', 'la', 'en']
True
make_headers
( keep_alive=None, accept_encoding=None, user_agent=None, basic_auth=None, proxy_basic_auth=None, disable_cache=None, )
Shortcuts for generating request headers. :param keep_alive: If ``True``, adds 'connection: keep-alive' header. :param accept_encoding: Can be a boolean, list, or string. ``True`` translates to 'gzip,deflate'. List will get joined by comma. String will be used as p...
Shortcuts for generating request headers.
def make_headers( keep_alive=None, accept_encoding=None, user_agent=None, basic_auth=None, proxy_basic_auth=None, disable_cache=None, ): """ Shortcuts for generating request headers. :param keep_alive: If ``True``, adds 'connection: keep-alive' header. :param accept_enc...
[ "def", "make_headers", "(", "keep_alive", "=", "None", ",", "accept_encoding", "=", "None", ",", "user_agent", "=", "None", ",", "basic_auth", "=", "None", ",", "proxy_basic_auth", "=", "None", ",", "disable_cache", "=", "None", ",", ")", ":", "headers", "...
[ 25, 0 ]
[ 94, 18 ]
python
en
['en', 'error', 'th']
False
set_file_position
(body, pos)
If a position is provided, move file to that point. Otherwise, we'll attempt to record a position for future use.
If a position is provided, move file to that point. Otherwise, we'll attempt to record a position for future use.
def set_file_position(body, pos): """ If a position is provided, move file to that point. Otherwise, we'll attempt to record a position for future use. """ if pos is not None: rewind_body(body, pos) elif getattr(body, "tell", None) is not None: try: pos = body.tell() ...
[ "def", "set_file_position", "(", "body", ",", "pos", ")", ":", "if", "pos", "is", "not", "None", ":", "rewind_body", "(", "body", ",", "pos", ")", "elif", "getattr", "(", "body", ",", "\"tell\"", ",", "None", ")", "is", "not", "None", ":", "try", "...
[ 97, 0 ]
[ 112, 14 ]
python
en
['en', 'error', 'th']
False
rewind_body
(body, body_pos)
Attempt to rewind body to a certain position. Primarily used for request redirects and retries. :param body: File-like object that supports seek. :param int pos: Position to seek to in file.
Attempt to rewind body to a certain position. Primarily used for request redirects and retries.
def rewind_body(body, body_pos): """ Attempt to rewind body to a certain position. Primarily used for request redirects and retries. :param body: File-like object that supports seek. :param int pos: Position to seek to in file. """ body_seek = getattr(body, "seek", None) ...
[ "def", "rewind_body", "(", "body", ",", "body_pos", ")", ":", "body_seek", "=", "getattr", "(", "body", ",", "\"seek\"", ",", "None", ")", "if", "body_seek", "is", "not", "None", "and", "isinstance", "(", "body_pos", ",", "integer_types", ")", ":", "try"...
[ 115, 0 ]
[ 142, 9 ]
python
en
['en', 'error', 'th']
False
DictSorted.__setitem__
(self, key, value)
self[key] = value syntax
self[key] = value syntax
def __setitem__(self, key, value): '''self[key] = value syntax''' if key not in self.ordered_keys: self.ordered_keys.append(key) super(DictSorted, self).__setitem__(key, value)
[ "def", "__setitem__", "(", "self", ",", "key", ",", "value", ")", ":", "if", "key", "not", "in", "self", ".", "ordered_keys", ":", "self", ".", "ordered_keys", ".", "append", "(", "key", ")", "super", "(", "DictSorted", ",", "self", ")", ".", "__seti...
[ 137, 4 ]
[ 141, 55 ]
python
cy
['es', 'cy', 'en']
False
DictSorted.__iter__
(self)
for x in self syntax
for x in self syntax
def __iter__(self): '''for x in self syntax''' return self.ordered_keys.__iter__()
[ "def", "__iter__", "(", "self", ")", ":", "return", "self", ".", "ordered_keys", ".", "__iter__", "(", ")" ]
[ 157, 4 ]
[ 159, 43 ]
python
en
['en', 'en', 'en']
True
i18n_patterns
(*urls, prefix_default_language=True)
Add the language code prefix to every URL pattern within this function. This may only be used in the root URLconf, not in an included URLconf.
Add the language code prefix to every URL pattern within this function. This may only be used in the root URLconf, not in an included URLconf.
def i18n_patterns(*urls, prefix_default_language=True): """ Add the language code prefix to every URL pattern within this function. This may only be used in the root URLconf, not in an included URLconf. """ if not settings.USE_I18N: return list(urls) return [ URLResolver( ...
[ "def", "i18n_patterns", "(", "*", "urls", ",", "prefix_default_language", "=", "True", ")", ":", "if", "not", "settings", ".", "USE_I18N", ":", "return", "list", "(", "urls", ")", "return", "[", "URLResolver", "(", "LocalePrefixPattern", "(", "prefix_default_l...
[ 7, 0 ]
[ 19, 5 ]
python
en
['en', 'error', 'th']
False
is_language_prefix_patterns_used
(urlconf)
Return a tuple of two booleans: ( `True` if i18n_patterns() (LocalePrefixPattern) is used in the URLconf, `True` if the default language should be prefixed )
Return a tuple of two booleans: ( `True` if i18n_patterns() (LocalePrefixPattern) is used in the URLconf, `True` if the default language should be prefixed )
def is_language_prefix_patterns_used(urlconf): """ Return a tuple of two booleans: ( `True` if i18n_patterns() (LocalePrefixPattern) is used in the URLconf, `True` if the default language should be prefixed ) """ for url_pattern in get_resolver(urlconf).url_patterns: if isins...
[ "def", "is_language_prefix_patterns_used", "(", "urlconf", ")", ":", "for", "url_pattern", "in", "get_resolver", "(", "urlconf", ")", ".", "url_patterns", ":", "if", "isinstance", "(", "url_pattern", ".", "pattern", ",", "LocalePrefixPattern", ")", ":", "return", ...
[ 23, 0 ]
[ 33, 23 ]
python
en
['en', 'error', 'th']
False
std_call
(func)
Return the correct STDCALL function for certain OSR routines on Win32 platforms.
Return the correct STDCALL function for certain OSR routines on Win32 platforms.
def std_call(func): """ Return the correct STDCALL function for certain OSR routines on Win32 platforms. """ if os.name == 'nt': return lwingdal[func] else: return lgdal[func]
[ "def", "std_call", "(", "func", ")", ":", "if", "os", ".", "name", "==", "'nt'", ":", "return", "lwingdal", "[", "func", "]", "else", ":", "return", "lgdal", "[", "func", "]" ]
[ 63, 0 ]
[ 71, 26 ]
python
en
['en', 'error', 'th']
False
gdal_version
()
Return only the GDAL version number information.
Return only the GDAL version number information.
def gdal_version(): "Return only the GDAL version number information." return _version_info(b'RELEASE_NAME')
[ "def", "gdal_version", "(", ")", ":", "return", "_version_info", "(", "b'RELEASE_NAME'", ")" ]
[ 82, 0 ]
[ 84, 41 ]
python
en
['en', 'da', 'en']
True