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
BaseDatabaseIntrospection.table_names
(self, cursor=None, include_views=False)
Returns a list of names of all tables that exist in the database. The returned table list is sorted by Python's default sorting. We do NOT use database's ORDER BY here to avoid subtle differences in sorting order between databases.
Returns a list of names of all tables that exist in the database. The returned table list is sorted by Python's default sorting. We do NOT use database's ORDER BY here to avoid subtle differences in sorting order between databases.
def table_names(self, cursor=None, include_views=False): """ Returns a list of names of all tables that exist in the database. The returned table list is sorted by Python's default sorting. We do NOT use database's ORDER BY here to avoid subtle differences in sorting order betwee...
[ "def", "table_names", "(", "self", ",", "cursor", "=", "None", ",", "include_views", "=", "False", ")", ":", "def", "get_names", "(", "cursor", ")", ":", "return", "sorted", "(", "ti", ".", "name", "for", "ti", "in", "self", ".", "get_table_list", "(",...
[ 41, 4 ]
[ 54, 32 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseIntrospection.get_table_list
(self, cursor)
Returns an unsorted list of TableInfo named tuples of all tables and views that exist in the database.
Returns an unsorted list of TableInfo named tuples of all tables and views that exist in the database.
def get_table_list(self, cursor): """ Returns an unsorted list of TableInfo named tuples of all tables and views that exist in the database. """ raise NotImplementedError('subclasses of BaseDatabaseIntrospection may require a get_table_list() method')
[ "def", "get_table_list", "(", "self", ",", "cursor", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of BaseDatabaseIntrospection may require a get_table_list() method'", ")" ]
[ 56, 4 ]
[ 61, 114 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseIntrospection.django_table_names
(self, only_existing=False, include_views=True)
Returns a list of all table names that have associated Django models and are in INSTALLED_APPS. If only_existing is True, the resulting list will only include the tables that actually exist in the database.
Returns a list of all table names that have associated Django models and are in INSTALLED_APPS.
def django_table_names(self, only_existing=False, include_views=True): """ Returns a list of all table names that have associated Django models and are in INSTALLED_APPS. If only_existing is True, the resulting list will only include the tables that actually exist in the databas...
[ "def", "django_table_names", "(", "self", ",", "only_existing", "=", "False", ",", "include_views", "=", "True", ")", ":", "from", "django", ".", "apps", "import", "apps", "from", "django", ".", "db", "import", "router", "tables", "=", "set", "(", ")", "...
[ 63, 4 ]
[ 91, 21 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseIntrospection.installed_models
(self, tables)
Returns a set of all models represented by the provided list of table names.
Returns a set of all models represented by the provided list of table names.
def installed_models(self, tables): "Returns a set of all models represented by the provided list of table names." from django.apps import apps from django.db import router all_models = [] for app_config in apps.get_app_configs(): all_models.extend(router.get_migratab...
[ "def", "installed_models", "(", "self", ",", "tables", ")", ":", "from", "django", ".", "apps", "import", "apps", "from", "django", ".", "db", "import", "router", "all_models", "=", "[", "]", "for", "app_config", "in", "apps", ".", "get_app_configs", "(", ...
[ 93, 4 ]
[ 104, 9 ]
python
en
['en', 'en', 'en']
True
BaseDatabaseIntrospection.sequence_list
(self)
Returns a list of information about all DB sequences for all models in all apps.
Returns a list of information about all DB sequences for all models in all apps.
def sequence_list(self): "Returns a list of information about all DB sequences for all models in all apps." from django.apps import apps from django.db import models, router sequence_list = [] for app_config in apps.get_app_configs(): for model in router.get_migrata...
[ "def", "sequence_list", "(", "self", ")", ":", "from", "django", ".", "apps", "import", "apps", "from", "django", ".", "db", "import", "models", ",", "router", "sequence_list", "=", "[", "]", "for", "app_config", "in", "apps", ".", "get_app_configs", "(", ...
[ 106, 4 ]
[ 130, 28 ]
python
en
['en', 'en', 'en']
True
BaseDatabaseIntrospection.get_key_columns
(self, cursor, table_name)
Backends can override this to return a list of (column_name, referenced_table_name, referenced_column_name) for all key columns in given table.
Backends can override this to return a list of (column_name, referenced_table_name, referenced_column_name) for all key columns in given table.
def get_key_columns(self, cursor, table_name): """ Backends can override this to return a list of (column_name, referenced_table_name, referenced_column_name) for all key columns in given table. """ raise NotImplementedError('subclasses of BaseDatabaseIntrospection may require a ...
[ "def", "get_key_columns", "(", "self", ",", "cursor", ",", "table_name", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of BaseDatabaseIntrospection may require a get_key_columns() method'", ")" ]
[ 132, 4 ]
[ 137, 115 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseIntrospection.get_primary_key_column
(self, cursor, table_name)
Returns the name of the primary key column for the given table.
Returns the name of the primary key column for the given table.
def get_primary_key_column(self, cursor, table_name): """ Returns the name of the primary key column for the given table. """ for constraint in self.get_constraints(cursor, table_name).values(): if constraint['primary_key']: return constraint['columns'][0] ...
[ "def", "get_primary_key_column", "(", "self", ",", "cursor", ",", "table_name", ")", ":", "for", "constraint", "in", "self", ".", "get_constraints", "(", "cursor", ",", "table_name", ")", ".", "values", "(", ")", ":", "if", "constraint", "[", "'primary_key'"...
[ 139, 4 ]
[ 146, 19 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseIntrospection.get_indexes
(self, cursor, table_name)
Deprecated in Django 1.11, use get_constraints instead. Returns a dictionary of indexed fieldname -> infodict for the given table, where each infodict is in the format: {'primary_key': boolean representing whether it's the primary key, 'unique': boolean representing whe...
Deprecated in Django 1.11, use get_constraints instead. Returns a dictionary of indexed fieldname -> infodict for the given table, where each infodict is in the format: {'primary_key': boolean representing whether it's the primary key, 'unique': boolean representing whe...
def get_indexes(self, cursor, table_name): """ Deprecated in Django 1.11, use get_constraints instead. Returns a dictionary of indexed fieldname -> infodict for the given table, where each infodict is in the format: {'primary_key': boolean representing whether it's the primar...
[ "def", "get_indexes", "(", "self", ",", "cursor", ",", "table_name", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of BaseDatabaseIntrospection may require a get_indexes() method'", ")" ]
[ 148, 4 ]
[ 158, 111 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseIntrospection.get_constraints
(self, cursor, table_name)
Retrieves any constraints or keys (unique, pk, fk, check, index) across one or more columns. Returns a dict mapping constraint names to their attributes, where attributes is a dict with keys: * columns: List of columns this covers * primary_key: True if primary key, F...
Retrieves any constraints or keys (unique, pk, fk, check, index) across one or more columns.
def get_constraints(self, cursor, table_name): """ Retrieves any constraints or keys (unique, pk, fk, check, index) across one or more columns. Returns a dict mapping constraint names to their attributes, where attributes is a dict with keys: * columns: List of columns ...
[ "def", "get_constraints", "(", "self", ",", "cursor", ",", "table_name", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of BaseDatabaseIntrospection may require a get_constraints() method'", ")" ]
[ 160, 4 ]
[ 179, 115 ]
python
en
['en', 'error', 'th']
False
BaseReporter.starting
(self)
Called before the resolution actually starts.
Called before the resolution actually starts.
def starting(self): """Called before the resolution actually starts."""
[ "def", "starting", "(", "self", ")", ":" ]
[ 3, 4 ]
[ 4, 59 ]
python
en
['en', 'en', 'en']
True
BaseReporter.starting_round
(self, index)
Called before each round of resolution starts. The index is zero-based.
Called before each round of resolution starts.
def starting_round(self, index): """Called before each round of resolution starts. The index is zero-based. """
[ "def", "starting_round", "(", "self", ",", "index", ")", ":" ]
[ 6, 4 ]
[ 10, 11 ]
python
en
['en', 'en', 'en']
True
BaseReporter.ending_round
(self, index, state)
Called before each round of resolution ends. This is NOT called if the resolution ends at this round. Use `ending` if you want to report finalization. The index is zero-based.
Called before each round of resolution ends.
def ending_round(self, index, state): """Called before each round of resolution ends. This is NOT called if the resolution ends at this round. Use `ending` if you want to report finalization. The index is zero-based. """
[ "def", "ending_round", "(", "self", ",", "index", ",", "state", ")", ":" ]
[ 12, 4 ]
[ 17, 11 ]
python
en
['en', 'en', 'en']
True
BaseReporter.ending
(self, state)
Called before the resolution ends successfully.
Called before the resolution ends successfully.
def ending(self, state): """Called before the resolution ends successfully."""
[ "def", "ending", "(", "self", ",", "state", ")", ":" ]
[ 19, 4 ]
[ 20, 61 ]
python
en
['en', 'en', 'en']
True
BaseReporter.adding_requirement
(self, requirement, parent)
Called when adding a new requirement into the resolve criteria. :param requirement: The additional requirement to be applied to filter the available candidaites. :param parent: The candidate that requires ``requirement`` as a dependency, or None if ``requirement`` is one of the ...
Called when adding a new requirement into the resolve criteria.
def adding_requirement(self, requirement, parent): """Called when adding a new requirement into the resolve criteria. :param requirement: The additional requirement to be applied to filter the available candidaites. :param parent: The candidate that requires ``requirement`` as a ...
[ "def", "adding_requirement", "(", "self", ",", "requirement", ",", "parent", ")", ":" ]
[ 22, 4 ]
[ 30, 11 ]
python
en
['en', 'en', 'en']
True
BaseReporter.backtracking
(self, candidate)
Called when rejecting a candidate during backtracking.
Called when rejecting a candidate during backtracking.
def backtracking(self, candidate): """Called when rejecting a candidate during backtracking."""
[ "def", "backtracking", "(", "self", ",", "candidate", ")", ":" ]
[ 32, 4 ]
[ 33, 68 ]
python
en
['en', 'en', 'en']
True
BaseReporter.pinning
(self, candidate)
Called when adding a candidate to the potential solution.
Called when adding a candidate to the potential solution.
def pinning(self, candidate): """Called when adding a candidate to the potential solution."""
[ "def", "pinning", "(", "self", ",", "candidate", ")", ":" ]
[ 35, 4 ]
[ 36, 71 ]
python
en
['en', 'en', 'en']
True
NoneMetadataError.__init__
(self, dist, metadata_name)
:param dist: A Distribution object. :param metadata_name: The name of the metadata being accessed (can be "METADATA" or "PKG-INFO").
:param dist: A Distribution object. :param metadata_name: The name of the metadata being accessed (can be "METADATA" or "PKG-INFO").
def __init__(self, dist, metadata_name): # type: (Distribution, str) -> None """ :param dist: A Distribution object. :param metadata_name: The name of the metadata being accessed (can be "METADATA" or "PKG-INFO"). """ self.dist = dist self.metadata_nam...
[ "def", "__init__", "(", "self", ",", "dist", ",", "metadata_name", ")", ":", "# type: (Distribution, str) -> None", "self", ".", "dist", "=", "dist", "self", ".", "metadata_name", "=", "metadata_name" ]
[ 51, 4 ]
[ 59, 42 ]
python
en
['en', 'error', 'th']
False
NetworkConnectionError.__init__
(self, error_msg, response=None, request=None)
Initialize NetworkConnectionError with `request` and `response` objects.
Initialize NetworkConnectionError with `request` and `response` objects.
def __init__(self, error_msg, response=None, request=None): # type: (Text, Response, Request) -> None """ Initialize NetworkConnectionError with `request` and `response` objects. """ self.response = response self.request = request self.error_msg = error_m...
[ "def", "__init__", "(", "self", ",", "error_msg", ",", "response", "=", "None", ",", "request", "=", "None", ")", ":", "# type: (Text, Response, Request) -> None", "self", ".", "response", "=", "response", "self", ".", "request", "=", "request", "self", ".", ...
[ 105, 4 ]
[ 118, 41 ]
python
en
['en', 'error', 'th']
False
HashError.body
(self)
Return a summary of me for display under the heading. This default implementation simply prints a description of the triggering requirement. :param req: The InstallRequirement that provoked this error, with its link already populated by the resolver's _populate_link().
Return a summary of me for display under the heading.
def body(self): # type: () -> str """Return a summary of me for display under the heading. This default implementation simply prints a description of the triggering requirement. :param req: The InstallRequirement that provoked this error, with its link already popul...
[ "def", "body", "(", "self", ")", ":", "# type: () -> str", "return", "' {}'", ".", "format", "(", "self", ".", "_requirement_name", "(", ")", ")" ]
[ 204, 4 ]
[ 215, 56 ]
python
en
['en', 'en', 'en']
True
HashError._requirement_name
(self)
Return a description of the requirement that triggered me. This default implementation returns long description of the req, with line numbers
Return a description of the requirement that triggered me.
def _requirement_name(self): # type: () -> str """Return a description of the requirement that triggered me. This default implementation returns long description of the req, with line numbers """ return str(self.req) if self.req else 'unknown package'
[ "def", "_requirement_name", "(", "self", ")", ":", "# type: () -> str", "return", "str", "(", "self", ".", "req", ")", "if", "self", ".", "req", "else", "'unknown package'" ]
[ 221, 4 ]
[ 229, 63 ]
python
en
['en', 'en', 'en']
True
HashMissing.__init__
(self, gotten_hash)
:param gotten_hash: The hash of the (possibly malicious) archive we just downloaded
:param gotten_hash: The hash of the (possibly malicious) archive we just downloaded
def __init__(self, gotten_hash): # type: (str) -> None """ :param gotten_hash: The hash of the (possibly malicious) archive we just downloaded """ self.gotten_hash = gotten_hash
[ "def", "__init__", "(", "self", ",", "gotten_hash", ")", ":", "# type: (str) -> None", "self", ".", "gotten_hash", "=", "gotten_hash" ]
[ 262, 4 ]
[ 268, 38 ]
python
en
['en', 'error', 'th']
False
HashMismatch.__init__
(self, allowed, gots)
:param allowed: A dict of algorithm names pointing to lists of allowed hex digests :param gots: A dict of algorithm names pointing to hashes we actually got from the files under suspicion
:param allowed: A dict of algorithm names pointing to lists of allowed hex digests :param gots: A dict of algorithm names pointing to hashes we actually got from the files under suspicion
def __init__(self, allowed, gots): # type: (Dict[str, List[str]], Dict[str, _Hash]) -> None """ :param allowed: A dict of algorithm names pointing to lists of allowed hex digests :param gots: A dict of algorithm names pointing to hashes we actually got from the fi...
[ "def", "__init__", "(", "self", ",", "allowed", ",", "gots", ")", ":", "# type: (Dict[str, List[str]], Dict[str, _Hash]) -> None", "self", ".", "allowed", "=", "allowed", "self", ".", "gots", "=", "gots" ]
[ 313, 4 ]
[ 322, 24 ]
python
en
['en', 'error', 'th']
False
HashMismatch._hash_comparison
(self)
Return a comparison of actual and expected hash values. Example:: Expected sha256 abcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcde or 123451234512345123451234512345123451234512345 Got bcdefbcdefbcdefbcdefbcdefbcdefbcdefbcdefbcdef ...
Return a comparison of actual and expected hash values.
def _hash_comparison(self): # type: () -> str """ Return a comparison of actual and expected hash values. Example:: Expected sha256 abcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcde or 123451234512345123451234512345123451234512345 ...
[ "def", "_hash_comparison", "(", "self", ")", ":", "# type: () -> str", "def", "hash_then_or", "(", "hash_name", ")", ":", "# type: (str) -> chain[str]", "# For now, all the decent hashes have 6-char names, so we can get", "# away with hard-coding space literals.", "return", "chain"...
[ 329, 4 ]
[ 354, 31 ]
python
en
['en', 'error', 'th']
False
set_page_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_page_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.g...
[ "def", "set_page_path_collation", "(", "apps", ",", "schema_editor", ")", ":", "if", "schema_editor", ".", "connection", ".", "vendor", "==", "'postgresql'", ":", "schema_editor", ".", "execute", "(", "\"\"\"\n ALTER TABLE wagtailcore_page ALTER COLUMN path TYPE ...
[ 7, 0 ]
[ 18, 12 ]
python
en
['en', 'error', 'th']
False
_get_gid
(name)
Returns a gid, given a group name.
Returns a gid, given a group name.
def _get_gid(name): """Returns a gid, given a group name.""" if getgrnam is None or name is None: return None try: result = getgrnam(name) except KeyError: result = None if result is not None: return result[2] return None
[ "def", "_get_gid", "(", "name", ")", ":", "if", "getgrnam", "is", "None", "or", "name", "is", "None", ":", "return", "None", "try", ":", "result", "=", "getgrnam", "(", "name", ")", "except", "KeyError", ":", "result", "=", "None", "if", "result", "i...
[ 30, 0 ]
[ 40, 15 ]
python
en
['en', 'en', 'en']
True
_get_uid
(name)
Returns an uid, given a user name.
Returns an uid, given a user name.
def _get_uid(name): """Returns an uid, given a user name.""" if getpwnam is None or name is None: return None try: result = getpwnam(name) except KeyError: result = None if result is not None: return result[2] return None
[ "def", "_get_uid", "(", "name", ")", ":", "if", "getpwnam", "is", "None", "or", "name", "is", "None", ":", "return", "None", "try", ":", "result", "=", "getpwnam", "(", "name", ")", "except", "KeyError", ":", "result", "=", "None", "if", "result", "i...
[ 42, 0 ]
[ 52, 15 ]
python
en
['en', 'en', 'en']
True
make_tarball
(base_name, base_dir, compress="gzip", verbose=0, dry_run=0, owner=None, group=None)
Create a (possibly compressed) tar file from all the files under 'base_dir'. 'compress' must be "gzip" (the default), "bzip2", "xz", "compress", or None. ("compress" will be deprecated in Python 3.2) 'owner' and 'group' can be used to define an owner and a group for the archive that is being buil...
Create a (possibly compressed) tar file from all the files under 'base_dir'.
def make_tarball(base_name, base_dir, compress="gzip", verbose=0, dry_run=0, owner=None, group=None): """Create a (possibly compressed) tar file from all the files under 'base_dir'. 'compress' must be "gzip" (the default), "bzip2", "xz", "compress", or None. ("compress" will be deprec...
[ "def", "make_tarball", "(", "base_name", ",", "base_dir", ",", "compress", "=", "\"gzip\"", ",", "verbose", "=", "0", ",", "dry_run", "=", "0", ",", "owner", "=", "None", ",", "group", "=", "None", ")", ":", "tar_compression", "=", "{", "'gzip'", ":", ...
[ 54, 0 ]
[ 124, 23 ]
python
en
['en', 'en', 'en']
True
make_zipfile
(base_name, base_dir, verbose=0, dry_run=0)
Create a zip file from all the files under 'base_dir'. The output zip file will be named 'base_name' + ".zip". Uses either the "zipfile" Python module (if available) or the InfoZIP "zip" utility (if installed and found on the default search path). If neither tool is available, raises DistutilsExecErr...
Create a zip file from all the files under 'base_dir'.
def make_zipfile(base_name, base_dir, verbose=0, dry_run=0): """Create a zip file from all the files under 'base_dir'. The output zip file will be named 'base_name' + ".zip". Uses either the "zipfile" Python module (if available) or the InfoZIP "zip" utility (if installed and found on the default sear...
[ "def", "make_zipfile", "(", "base_name", ",", "base_dir", ",", "verbose", "=", "0", ",", "dry_run", "=", "0", ")", ":", "zip_filename", "=", "base_name", "+", "\".zip\"", "mkpath", "(", "os", ".", "path", ".", "dirname", "(", "zip_filename", ")", ",", ...
[ 126, 0 ]
[ 184, 23 ]
python
en
['en', 'en', 'en']
True
check_archive_formats
(formats)
Returns the first format from the 'format' list that is unknown. If all formats are known, returns None
Returns the first format from the 'format' list that is unknown.
def check_archive_formats(formats): """Returns the first format from the 'format' list that is unknown. If all formats are known, returns None """ for format in formats: if format not in ARCHIVE_FORMATS: return format return None
[ "def", "check_archive_formats", "(", "formats", ")", ":", "for", "format", "in", "formats", ":", "if", "format", "not", "in", "ARCHIVE_FORMATS", ":", "return", "format", "return", "None" ]
[ 195, 0 ]
[ 203, 15 ]
python
en
['en', 'en', 'en']
True
make_archive
(base_name, format, root_dir=None, base_dir=None, verbose=0, dry_run=0, owner=None, group=None)
Create an archive file (eg. zip or tar). 'base_name' is the name of the file to create, minus any format-specific extension; 'format' is the archive format: one of "zip", "tar", "gztar", "bztar", "xztar", or "ztar". 'root_dir' is a directory that will be the root directory of the archive; ie. we t...
Create an archive file (eg. zip or tar).
def make_archive(base_name, format, root_dir=None, base_dir=None, verbose=0, dry_run=0, owner=None, group=None): """Create an archive file (eg. zip or tar). 'base_name' is the name of the file to create, minus any format-specific extension; 'format' is the archive format: one of "zip", "ta...
[ "def", "make_archive", "(", "base_name", ",", "format", ",", "root_dir", "=", "None", ",", "base_dir", "=", "None", ",", "verbose", "=", "0", ",", "dry_run", "=", "0", ",", "owner", "=", "None", ",", "group", "=", "None", ")", ":", "save_cwd", "=", ...
[ 205, 0 ]
[ 255, 19 ]
python
en
['en', 'gd', 'en']
True
TestNumpySubroutines.testBoxSlicing
(self)
Tests a routine to return a window on an image. Previous implementation returned correct sized box, but central pixel was often offset unnecessarily. This method always returns a centred chunk.
Tests a routine to return a window on an image.
def testBoxSlicing(self): """ Tests a routine to return a window on an image. Previous implementation returned correct sized box, but central pixel was often offset unnecessarily. This method always returns a centred chunk. """ a = np.arange(1,101) a= a....
[ "def", "testBoxSlicing", "(", "self", ")", ":", "a", "=", "np", ".", "arange", "(", "1", ",", "101", ")", "a", "=", "a", ".", "reshape", "(", "10", ",", "10", ")", "x", ",", "y", "=", "3", ",", "3", "central_value", "=", "a", "[", "y", ",",...
[ 20, 4 ]
[ 44, 31 ]
python
en
['en', 'error', 'th']
False
TestFitFixedPositions.setUp
(self)
NB the required image has been committed to the tkp/data subversion repository. (See tkp/data/unittests/tkp_lib for a full copy of all the unittest data). Source positions / background positions were simply picked out by eye in DS9
NB the required image has been committed to the tkp/data subversion repository.
def setUp(self): """ NB the required image has been committed to the tkp/data subversion repository. (See tkp/data/unittests/tkp_lib for a full copy of all the unittest data). Source positions / background positions were simply picked out by eye in DS9 """ self.image = ...
[ "def", "setUp", "(", "self", ")", ":", "self", ".", "image", "=", "accessors", ".", "sourcefinder_image_from_accessor", "(", "accessors", ".", "open", "(", "os", ".", "path", ".", "join", "(", "DATAPATH", ",", "'sourcefinder/NCP_sample_image_1.fits'", ")", ")"...
[ 63, 4 ]
[ 83, 53 ]
python
en
['en', 'error', 'th']
False
TestFitFixedPositions.testLowFitThreshold
(self)
Low fit threshold is equivalent to zero threshold If we supply an extremely low threshold do we get a similar result to a zero threshold, for a bright source?
Low fit threshold is equivalent to zero threshold
def testLowFitThreshold(self): """ Low fit threshold is equivalent to zero threshold If we supply an extremely low threshold do we get a similar result to a zero threshold, for a bright source? """ posn = self.bright_src_posn img=self.image low_thresh_res...
[ "def", "testLowFitThreshold", "(", "self", ")", ":", "posn", "=", "self", ".", "bright_src_posn", "img", "=", "self", ".", "image", "low_thresh_results", "=", "self", ".", "image", ".", "fit_fixed_positions", "(", "positions", "=", "[", "posn", "]", ",", "...
[ 98, 4 ]
[ 115, 44 ]
python
en
['en', 'error', 'th']
False
TestFitFixedPositions.testHighFitThreshold
(self)
High fit threshold throws error If we supply an extremely high threshold, we expect to get back a fitting error since all pixels should be masked out.
High fit threshold throws error
def testHighFitThreshold(self): """ High fit threshold throws error If we supply an extremely high threshold, we expect to get back a fitting error since all pixels should be masked out. """ posn = self.bright_src_posn img=self.image with self.assertRaise...
[ "def", "testHighFitThreshold", "(", "self", ")", ":", "posn", "=", "self", ".", "bright_src_posn", "img", "=", "self", ".", "image", "with", "self", ".", "assertRaises", "(", "ValueError", ")", ":", "results", "=", "self", ".", "image", ".", "fit_fixed_pos...
[ 117, 4 ]
[ 129, 56 ]
python
en
['en', 'error', 'th']
False
TestFitFixedPositions.testBackgroundAtGivenPosition
(self)
No source at given position (but still in the image frame) Note, if we request zero threshold, then the region will be unfittable, since it is largely below that thresh. Rather than pick an arbitrarily low threshold, we set it to None.
No source at given position (but still in the image frame)
def testBackgroundAtGivenPosition(self): """ No source at given position (but still in the image frame) Note, if we request zero threshold, then the region will be unfittable, since it is largely below that thresh. Rather than pick an arbitrarily low threshold, we set it to Non...
[ "def", "testBackgroundAtGivenPosition", "(", "self", ")", ":", "img", "=", "self", ".", "image", "results", "=", "self", ".", "image", ".", "fit_fixed_positions", "(", "positions", "=", "[", "self", ".", "background_posn", "]", ",", "boxsize", "=", "BOX_IN_B...
[ 131, 4 ]
[ 148, 62 ]
python
en
['en', 'error', 'th']
False
TestFitFixedPositions.testGivenPositionOutsideImage
(self)
If given position is outside image then result should be NoneType
If given position is outside image then result should be NoneType
def testGivenPositionOutsideImage(self): """If given position is outside image then result should be NoneType""" img = self.image # Generate a position halfway up the y-axis, but at negative x-position. pixel_posn_negative_x = (-50, img.data.shape[1]/2.0) # and halfway up the y-...
[ "def", "testGivenPositionOutsideImage", "(", "self", ")", ":", "img", "=", "self", ".", "image", "# Generate a position halfway up the y-axis, but at negative x-position.", "pixel_posn_negative_x", "=", "(", "-", "50", ",", "img", ".", "data", ".", "shape", "[", "1", ...
[ 150, 4 ]
[ 165, 41 ]
python
en
['en', 'en', 'en']
True
TestFitFixedPositions.testTooCloseToEdgePosition
(self)
Same if right on the edge -- too few pixels to fit
Same if right on the edge -- too few pixels to fit
def testTooCloseToEdgePosition(self): """Same if right on the edge -- too few pixels to fit""" img = self.image boxsize = BOX_IN_BEAMPIX*max(img.beam[0], img.beam[1]) edge_posn = img.wcs.p2s((0 + boxsize/2 -2, img.data.shape[1]/2.0)) results = self.image.fit_fixed_positions( ...
[ "def", "testTooCloseToEdgePosition", "(", "self", ")", ":", "img", "=", "self", ".", "image", "boxsize", "=", "BOX_IN_BEAMPIX", "*", "max", "(", "img", ".", "beam", "[", "0", "]", ",", "img", ".", "beam", "[", "1", "]", ")", "edge_posn", "=", "img", ...
[ 167, 4 ]
[ 177, 41 ]
python
en
['en', 'en', 'en']
True
TestFitFixedPositions.testErrorBoxOverlapsEdge
(self)
Error box overflows image Sometimes when fitting at a fixed position, we get extremely large uncertainty values. These create an error box on position which extends outside the image, causing errors when we try to calculate the RA / Dec uncertainties. This test ensures we han...
Error box overflows image
def testErrorBoxOverlapsEdge(self): """ Error box overflows image Sometimes when fitting at a fixed position, we get extremely large uncertainty values. These create an error box on position which extends outside the image, causing errors when we try to calculate the RA...
[ "def", "testErrorBoxOverlapsEdge", "(", "self", ")", ":", "img", "=", "self", ".", "image", "fake_params", "=", "tkp", ".", "sourcefinder", ".", "extract", ".", "ParamSet", "(", ")", "fake_params", ".", "values", ".", "update", "(", "{", "'peak'", ":", "...
[ 179, 4 ]
[ 206, 53 ]
python
en
['en', 'error', 'th']
False
TestFitFixedPositions.testForcedFitAtNans
(self)
Should not return a fit if the position was largely masked due to NaNs
Should not return a fit if the position was largely masked due to NaNs
def testForcedFitAtNans(self): """ Should not return a fit if the position was largely masked due to NaNs """ forcedfit_sky_posn = self.bright_src_posn forcedfit_pixel_posn = self.image.wcs.s2p(forcedfit_sky_posn) fitting_boxsize = BOX_IN_BEAMPIX*max(self.image.beam[0],...
[ "def", "testForcedFitAtNans", "(", "self", ")", ":", "forcedfit_sky_posn", "=", "self", ".", "bright_src_posn", "forcedfit_pixel_posn", "=", "self", ".", "image", ".", "wcs", ".", "s2p", "(", "forcedfit_sky_posn", ")", "fitting_boxsize", "=", "BOX_IN_BEAMPIX", "*"...
[ 208, 4 ]
[ 250, 33 ]
python
en
['en', 'error', 'th']
False
TestSimpleImageSourceFind.testSingleSourceExtraction
(self)
Single source extaction From visual inspection we only expect a single source in the image, at around 5 or 6 sigma detection level.
Single source extaction
def testSingleSourceExtraction(self): """ Single source extaction From visual inspection we only expect a single source in the image, at around 5 or 6 sigma detection level.""" ew_sys_err, ns_sys_err = 0.0, 0.0 known_result = ( 136.89603241069054, 14.0221847...
[ "def", "testSingleSourceExtraction", "(", "self", ")", ":", "ew_sys_err", ",", "ns_sys_err", "=", "0.0", ",", "0.0", "known_result", "=", "(", "136.89603241069054", ",", "14.022184792492785", ",", "# RA, DEC", "0.0005341819139061954", ",", "0.0013428186757078464", ","...
[ 256, 4 ]
[ 286, 67 ]
python
en
['en', 'error', 'th']
False
TestSimpleImageSourceFind.testForceSourceShape
(self)
Force source shape to beam This image contains a single source (with parameters as listed under testSingleSourceExtraction(), above). Here we force the lengths of the major/minor axes to be held constant when fitting.
Force source shape to beam
def testForceSourceShape(self): """ Force source shape to beam This image contains a single source (with parameters as listed under testSingleSourceExtraction(), above). Here we force the lengths of the major/minor axes to be held constant when fitting. """ self....
[ "def", "testForceSourceShape", "(", "self", ")", ":", "self", ".", "image", "=", "accessors", ".", "sourcefinder_image_from_accessor", "(", "accessors", ".", "FitsImage", "(", "GRB120422A", ")", ")", "results", "=", "self", ".", "image", ".", "extract", "(", ...
[ 289, 4 ]
[ 301, 67 ]
python
en
['en', 'error', 'th']
False
TestSimpleImageSourceFind.testWcsConversionConsistency
(self)
Check that extracting a source from FITS and CASA versions of the same dataset gives the same results (especially, RA and Dec).
Check that extracting a source from FITS and CASA versions of the same dataset gives the same results (especially, RA and Dec).
def testWcsConversionConsistency(self): """ Check that extracting a source from FITS and CASA versions of the same dataset gives the same results (especially, RA and Dec). """ fits_image = accessors.sourcefinder_image_from_accessor( accessors.FitsImage(os....
[ "def", "testWcsConversionConsistency", "(", "self", ")", ":", "fits_image", "=", "accessors", ".", "sourcefinder_image_from_accessor", "(", "accessors", ".", "FitsImage", "(", "os", ".", "path", ".", "join", "(", "DATAPATH", ",", "'sourcefinder/GRB130828A/SWIFT_554620...
[ 305, 4 ]
[ 333, 74 ]
python
en
['en', 'error', 'th']
False
TestSimpleImageSourceFind.testNoLabelledIslandsCase
(self)
If an image is in fact very boring and flat/empty, then we may not even locate any labelled islands, if the analysis threshold is set high enough. (We reproduce this test case, even though GRB120422A-120429 has a source in the image, just by setting the thresholds very high - t...
If an image is in fact very boring and flat/empty, then we may not even locate any labelled islands, if the analysis threshold is set high enough.
def testNoLabelledIslandsCase(self): """ If an image is in fact very boring and flat/empty, then we may not even locate any labelled islands, if the analysis threshold is set high enough. (We reproduce this test case, even though GRB120422A-120429 has a source in the image, just...
[ "def", "testNoLabelledIslandsCase", "(", "self", ")", ":", "self", ".", "image", "=", "accessors", ".", "sourcefinder_image_from_accessor", "(", "accessors", ".", "FitsImage", "(", "GRB120422A", ")", ")", "results", "=", "self", ".", "image", ".", "extract", "...
[ 336, 4 ]
[ 349, 41 ]
python
en
['en', 'error', 'th']
False
TestMaskedSource.testWholeSourceMasked
(self)
Source in masked region
Source in masked region
def testWholeSourceMasked(self): """ Source in masked region """ self.image = accessors.sourcefinder_image_from_accessor( accessors.FitsImage(GRB120422A)) self.image.data[250:280, 250:280] = np.ma.masked results = self.image.extract(det=5, anl=3) self...
[ "def", "testWholeSourceMasked", "(", "self", ")", ":", "self", ".", "image", "=", "accessors", ".", "sourcefinder_image_from_accessor", "(", "accessors", ".", "FitsImage", "(", "GRB120422A", ")", ")", "self", ".", "image", ".", "data", "[", "250", ":", "280"...
[ 361, 4 ]
[ 370, 33 ]
python
en
['en', 'error', 'th']
False
TestMaskedSource.testWholeSourceMasked
(self)
Part of source masked Tip of major axis is around 267, 264
Part of source masked
def testWholeSourceMasked(self): """ Part of source masked Tip of major axis is around 267, 264 """ self.image = accessors.sourcefinder_image_from_accessor( accessors.FitsImage(GRB120422A)) self.image.data[266:269, 263:266] = np.ma.masked results = s...
[ "def", "testWholeSourceMasked", "(", "self", ")", ":", "self", ".", "image", "=", "accessors", ".", "sourcefinder_image_from_accessor", "(", "accessors", ".", "FitsImage", "(", "GRB120422A", ")", ")", "self", ".", "image", ".", "data", "[", "266", ":", "269"...
[ 373, 4 ]
[ 384, 33 ]
python
en
['en', 'error', 'th']
False
TestMaskedBackground.testMaskedBackgroundForcedFit
(self)
Background at forced fit is masked
Background at forced fit is masked
def testMaskedBackgroundForcedFit(self): """ Background at forced fit is masked """ self.image = accessors.sourcefinder_image_from_accessor( accessors.open(fits_file), radius=1.0) result = self.image.fit_to_point(256, 256, 10, 0, None) self.assertFalse(result)
[ "def", "testMaskedBackgroundForcedFit", "(", "self", ")", ":", "self", ".", "image", "=", "accessors", ".", "sourcefinder_image_from_accessor", "(", "accessors", ".", "open", "(", "fits_file", ")", ",", "radius", "=", "1.0", ")", "result", "=", "self", ".", ...
[ 390, 4 ]
[ 397, 32 ]
python
en
['en', 'error', 'th']
False
Engine.__init__
(self, dim, lshashes=None, distance=None, fetch_vector_filters=None, vector_filters=None, storage=None)
Keeps the configuration.
Keeps the configuration.
def __init__(self, dim, lshashes=None, distance=None, fetch_vector_filters=None, vector_filters=None, storage=None): """ Keeps the configuration. """ if lshashes is None: lshashes = [RandomBinaryProjections('default', 10)] self....
[ "def", "__init__", "(", "self", ",", "dim", ",", "lshashes", "=", "None", ",", "distance", "=", "None", ",", "fetch_vector_filters", "=", "None", ",", "vector_filters", "=", "None", ",", "storage", "=", "None", ")", ":", "if", "lshashes", "is", "None", ...
[ 62, 4 ]
[ 81, 29 ]
python
en
['en', 'en', 'en']
True
Engine.store_vector
(self, v, data=None)
Hashes vector v and stores it in all matching buckets in the storage. The data argument must be JSON-serializable. It is stored with the vector and will be returned in search results.
Hashes vector v and stores it in all matching buckets in the storage. The data argument must be JSON-serializable. It is stored with the vector and will be returned in search results.
def store_vector(self, v, data=None): """ Hashes vector v and stores it in all matching buckets in the storage. The data argument must be JSON-serializable. It is stored with the vector and will be returned in search results. """ # We will store the normalized vector (use...
[ "def", "store_vector", "(", "self", ",", "v", ",", "data", "=", "None", ")", ":", "# We will store the normalized vector (used during retrieval)", "nv", "=", "unitvec", "(", "v", ")", "# Store vector in each bucket of all hashes", "for", "lshash", "in", "self", ".", ...
[ 83, 4 ]
[ 96, 51 ]
python
en
['en', 'error', 'th']
False
Engine.store_many_vectors
(self, vs, data=None)
Store a batch of vectors. Hashes vector vs and stores them in all matching buckets in the storage. The data argument must be either None or a list of JSON-serializable object. It is stored with the vector and will be returned in search results.
Store a batch of vectors. Hashes vector vs and stores them in all matching buckets in the storage. The data argument must be either None or a list of JSON-serializable object. It is stored with the vector and will be returned in search results.
def store_many_vectors(self, vs, data=None): """ Store a batch of vectors. Hashes vector vs and stores them in all matching buckets in the storage. The data argument must be either None or a list of JSON-serializable object. It is stored with the vector and will be returned in se...
[ "def", "store_many_vectors", "(", "self", ",", "vs", ",", "data", "=", "None", ")", ":", "# We will store the normalized vector (used during retrieval)", "nvs", "=", "[", "unitvec", "(", "i", ")", "for", "i", "in", "vs", "]", "# Store vector in each bucket of all ha...
[ 98, 4 ]
[ 112, 54 ]
python
en
['en', 'error', 'th']
False
Engine.delete_vector
(self, data, v=None)
Deletes vector v and his id (data) in all matching buckets in the storage. The data argument must be JSON-serializable.
Deletes vector v and his id (data) in all matching buckets in the storage. The data argument must be JSON-serializable.
def delete_vector(self, data, v=None): """ Deletes vector v and his id (data) in all matching buckets in the storage. The data argument must be JSON-serializable. """ # Delete data id in each hashes for lshash in self.lshashes: if v is None: k...
[ "def", "delete_vector", "(", "self", ",", "data", ",", "v", "=", "None", ")", ":", "# Delete data id in each hashes", "for", "lshash", "in", "self", ".", "lshashes", ":", "if", "v", "is", "None", ":", "keys", "=", "self", ".", "storage", ".", "get_all_bu...
[ 114, 4 ]
[ 126, 68 ]
python
en
['en', 'error', 'th']
False
Engine.candidate_count
(self, v)
Returns candidate count for nearest neighbour search for specified vector. The candidate count is the count of vectors taken from all buckets the specified vector is projected onto. Use this method to check if your hashes are configured good. High candidate counts makes queryin...
Returns candidate count for nearest neighbour search for specified vector. The candidate count is the count of vectors taken from all buckets the specified vector is projected onto.
def candidate_count(self, v): """ Returns candidate count for nearest neighbour search for specified vector. The candidate count is the count of vectors taken from all buckets the specified vector is projected onto. Use this method to check if your hashes are configured good. Hi...
[ "def", "candidate_count", "(", "self", ",", "v", ")", ":", "# Collect candidates from all buckets from all hashes", "candidates", "=", "self", ".", "_get_candidates", "(", "v", ")", "return", "len", "(", "candidates", ")" ]
[ 128, 4 ]
[ 143, 30 ]
python
en
['en', 'error', 'th']
False
Engine.neighbours
(self, v, distance=None, fetch_vector_filters=None, vector_filters=None)
Hashes vector v, collects all candidate vectors from the matching buckets in storage, applys the (optional) distance function and finally the (optional) filter function to construct the returned list of either (vector, data, distance) tuples or (vector, data) tuples.
Hashes vector v, collects all candidate vectors from the matching buckets in storage, applys the (optional) distance function and finally the (optional) filter function to construct the returned list of either (vector, data, distance) tuples or (vector, data) tuples.
def neighbours(self, v, distance=None, fetch_vector_filters=None, vector_filters=None): """ Hashes vector v, collects all candidate vectors from the matching buckets in storage, applys the (optional) distance function and finally t...
[ "def", "neighbours", "(", "self", ",", "v", ",", "distance", "=", "None", ",", "fetch_vector_filters", "=", "None", ",", "vector_filters", "=", "None", ")", ":", "# Collect candidates from all buckets from all hashes", "candidates", "=", "self", ".", "_get_candidate...
[ 145, 4 ]
[ 176, 25 ]
python
en
['en', 'error', 'th']
False
Engine._get_candidates
(self, v)
Collect candidates from all buckets from all hashes
Collect candidates from all buckets from all hashes
def _get_candidates(self, v): """ Collect candidates from all buckets from all hashes """ candidates = [] for lshash in self.lshashes: for bucket_key in lshash.hash_vector(v, querying=True): bucket_content = self.storage.get_bucket( lshash.hash_nam...
[ "def", "_get_candidates", "(", "self", ",", "v", ")", ":", "candidates", "=", "[", "]", "for", "lshash", "in", "self", ".", "lshashes", ":", "for", "bucket_key", "in", "lshash", ".", "hash_vector", "(", "v", ",", "querying", "=", "True", ")", ":", "b...
[ 179, 4 ]
[ 190, 25 ]
python
en
['en', 'en', 'en']
True
Engine._apply_filter
(self, filters, candidates)
Apply vector filters if specified and return filtered list
Apply vector filters if specified and return filtered list
def _apply_filter(self, filters, candidates): """ Apply vector filters if specified and return filtered list """ if filters: filter_input = candidates for fetch_vector_filter in filters: filter_input = fetch_vector_filter.filter_vectors(filter_input) ...
[ "def", "_apply_filter", "(", "self", ",", "filters", ",", "candidates", ")", ":", "if", "filters", ":", "filter_input", "=", "candidates", "for", "fetch_vector_filter", "in", "filters", ":", "filter_input", "=", "fetch_vector_filter", ".", "filter_vectors", "(", ...
[ 193, 4 ]
[ 202, 29 ]
python
en
['en', 'en', 'en']
True
Engine._append_distances
(self, v, distance, candidates)
Apply distance implementation if specified
Apply distance implementation if specified
def _append_distances(self, v, distance, candidates): """ Apply distance implementation if specified """ if distance: # Normalize vector (stored vectors are normalized) nv = unitvec(v) candidates = [(x[0], x[1], self.distance.distance(x[0], nv)) for x ...
[ "def", "_append_distances", "(", "self", ",", "v", ",", "distance", ",", "candidates", ")", ":", "if", "distance", ":", "# Normalize vector (stored vectors are normalized)", "nv", "=", "unitvec", "(", "v", ")", "candidates", "=", "[", "(", "x", "[", "0", "]"...
[ 204, 4 ]
[ 212, 25 ]
python
en
['en', 'en', 'en']
True
Engine.clean_all_buckets
(self)
Clears buckets in storage (removes all vectors and their data).
Clears buckets in storage (removes all vectors and their data).
def clean_all_buckets(self): """ Clears buckets in storage (removes all vectors and their data). """ self.storage.clean_all_buckets()
[ "def", "clean_all_buckets", "(", "self", ")", ":", "self", ".", "storage", ".", "clean_all_buckets", "(", ")" ]
[ 214, 4 ]
[ 216, 40 ]
python
en
['en', 'en', 'en']
True
Engine.clean_buckets
(self, hash_name)
Clears buckets in storage (removes all vectors and their data).
Clears buckets in storage (removes all vectors and their data).
def clean_buckets(self, hash_name): """ Clears buckets in storage (removes all vectors and their data). """ self.storage.clean_buckets(hash_name)
[ "def", "clean_buckets", "(", "self", ",", "hash_name", ")", ":", "self", ".", "storage", ".", "clean_buckets", "(", "hash_name", ")" ]
[ 218, 4 ]
[ 220, 45 ]
python
en
['en', 'en', 'en']
True
MempoolManager.create_bundle_from_mempool
( self, last_tb_header_hash: bytes32 )
Returns aggregated spendbundle that can be used for creating new block, additions and removals in that spend_bundle
Returns aggregated spendbundle that can be used for creating new block, additions and removals in that spend_bundle
async def create_bundle_from_mempool( self, last_tb_header_hash: bytes32 ) -> Optional[Tuple[SpendBundle, List[Coin], List[Coin]]]: """ Returns aggregated spendbundle that can be used for creating new block, additions and removals in that spend_bundle """ if ( ...
[ "async", "def", "create_bundle_from_mempool", "(", "self", ",", "last_tb_header_hash", ":", "bytes32", ")", "->", "Optional", "[", "Tuple", "[", "SpendBundle", ",", "List", "[", "Coin", "]", ",", "List", "[", "Coin", "]", "]", "]", ":", "if", "(", "self"...
[ 78, 4 ]
[ 126, 23 ]
python
en
['en', 'error', 'th']
False
MempoolManager.is_fee_enough
(self, fees: uint64, cost: uint64)
Determines whether any of the pools can accept a transaction with a given fees and cost.
Determines whether any of the pools can accept a transaction with a given fees and cost.
def is_fee_enough(self, fees: uint64, cost: uint64) -> bool: """ Determines whether any of the pools can accept a transaction with a given fees and cost. """ if cost == 0: return False fees_per_cost = fees / cost if not self.mempool.at_full_capacity(co...
[ "def", "is_fee_enough", "(", "self", ",", "fees", ":", "uint64", ",", "cost", ":", "uint64", ")", "->", "bool", ":", "if", "cost", "==", "0", ":", "return", "False", "fees_per_cost", "=", "fees", "/", "cost", "if", "not", "self", ".", "mempool", ".",...
[ 139, 4 ]
[ 151, 20 ]
python
en
['en', 'error', 'th']
False
MempoolManager.seen
(self, bundle_hash: bytes32)
Return true if we saw this spendbundle recently
Return true if we saw this spendbundle recently
def seen(self, bundle_hash: bytes32) -> bool: """Return true if we saw this spendbundle recently""" return bundle_hash in self.seen_bundle_hashes
[ "def", "seen", "(", "self", ",", "bundle_hash", ":", "bytes32", ")", "->", "bool", ":", "return", "bundle_hash", "in", "self", ".", "seen_bundle_hashes" ]
[ 159, 4 ]
[ 161, 53 ]
python
en
['en', 'en', 'en']
True
MempoolManager.pre_validate_spendbundle
(self, new_spend: SpendBundle)
Errors are included within the cached_result. This runs in another process so we don't block the main thread
Errors are included within the cached_result. This runs in another process so we don't block the main thread
async def pre_validate_spendbundle(self, new_spend: SpendBundle) -> NPCResult: """ Errors are included within the cached_result. This runs in another process so we don't block the main thread """ start_time = time.time() cached_result_bytes = await asyncio.get_running_loo...
[ "async", "def", "pre_validate_spendbundle", "(", "self", ",", "new_spend", ":", "SpendBundle", ")", "->", "NPCResult", ":", "start_time", "=", "time", ".", "time", "(", ")", "cached_result_bytes", "=", "await", "asyncio", ".", "get_running_loop", "(", ")", "."...
[ 210, 4 ]
[ 221, 56 ]
python
en
['en', 'error', 'th']
False
MempoolManager.add_spendbundle
( self, new_spend: SpendBundle, npc_result: NPCResult, spend_name: bytes32, validate_signature=True, program: Optional[SerializedProgram] = None, )
Tries to add spend bundle to the mempool Returns the cost (if SUCCESS), the result (MempoolInclusion status), and an optional error
Tries to add spend bundle to the mempool Returns the cost (if SUCCESS), the result (MempoolInclusion status), and an optional error
async def add_spendbundle( self, new_spend: SpendBundle, npc_result: NPCResult, spend_name: bytes32, validate_signature=True, program: Optional[SerializedProgram] = None, ) -> Tuple[Optional[uint64], MempoolInclusionStatus, Optional[Err]]: """ Tries to...
[ "async", "def", "add_spendbundle", "(", "self", ",", "new_spend", ":", "SpendBundle", ",", "npc_result", ":", "NPCResult", ",", "spend_name", ":", "bytes32", ",", "validate_signature", "=", "True", ",", "program", ":", "Optional", "[", "SerializedProgram", "]", ...
[ 223, 4 ]
[ 438, 65 ]
python
en
['en', 'error', 'th']
False
MempoolManager.check_removals
(self, removals: Dict[bytes32, CoinRecord])
This function checks for double spends, unknown spends and conflicting transactions in mempool. Returns Error (if any), dictionary of Unspents, list of coins with conflict errors (if any any). Note that additions are not checked for duplicates, because having duplicate additions requires also ...
This function checks for double spends, unknown spends and conflicting transactions in mempool. Returns Error (if any), dictionary of Unspents, list of coins with conflict errors (if any any). Note that additions are not checked for duplicates, because having duplicate additions requires also ...
async def check_removals(self, removals: Dict[bytes32, CoinRecord]) -> Tuple[Optional[Err], List[Coin]]: """ This function checks for double spends, unknown spends and conflicting transactions in mempool. Returns Error (if any), dictionary of Unspents, list of coins with conflict errors (if any ...
[ "async", "def", "check_removals", "(", "self", ",", "removals", ":", "Dict", "[", "bytes32", ",", "CoinRecord", "]", ")", "->", "Tuple", "[", "Optional", "[", "Err", "]", ",", "List", "[", "Coin", "]", "]", ":", "assert", "self", ".", "peak", "is", ...
[ 440, 4 ]
[ 462, 23 ]
python
en
['en', 'error', 'th']
False
MempoolManager.add_to_potential_tx_set
(self, item: MempoolItem)
Adds SpendBundles that have failed to be added to the pool in potential tx set. This is later used to retry to add them.
Adds SpendBundles that have failed to be added to the pool in potential tx set. This is later used to retry to add them.
def add_to_potential_tx_set(self, item: MempoolItem): """ Adds SpendBundles that have failed to be added to the pool in potential tx set. This is later used to retry to add them. """ if item.spend_bundle_name in self.potential_txs: return None self.potential_...
[ "def", "add_to_potential_tx_set", "(", "self", ",", "item", ":", "MempoolItem", ")", ":", "if", "item", ".", "spend_bundle_name", "in", "self", ".", "potential_txs", ":", "return", "None", "self", ".", "potential_txs", "[", "item", ".", "spend_bundle_name", "]...
[ 464, 4 ]
[ 478, 44 ]
python
en
['en', 'error', 'th']
False
MempoolManager.get_spendbundle
(self, bundle_hash: bytes32)
Returns a full SpendBundle if it's inside one the mempools
Returns a full SpendBundle if it's inside one the mempools
def get_spendbundle(self, bundle_hash: bytes32) -> Optional[SpendBundle]: """Returns a full SpendBundle if it's inside one the mempools""" if bundle_hash in self.mempool.spends: return self.mempool.spends[bundle_hash].spend_bundle return None
[ "def", "get_spendbundle", "(", "self", ",", "bundle_hash", ":", "bytes32", ")", "->", "Optional", "[", "SpendBundle", "]", ":", "if", "bundle_hash", "in", "self", ".", "mempool", ".", "spends", ":", "return", "self", ".", "mempool", ".", "spends", "[", "...
[ 480, 4 ]
[ 484, 19 ]
python
en
['en', 'en', 'en']
True
MempoolManager.get_mempool_item
(self, bundle_hash: bytes32)
Returns a MempoolItem if it's inside one the mempools
Returns a MempoolItem if it's inside one the mempools
def get_mempool_item(self, bundle_hash: bytes32) -> Optional[MempoolItem]: """Returns a MempoolItem if it's inside one the mempools""" if bundle_hash in self.mempool.spends: return self.mempool.spends[bundle_hash] return None
[ "def", "get_mempool_item", "(", "self", ",", "bundle_hash", ":", "bytes32", ")", "->", "Optional", "[", "MempoolItem", "]", ":", "if", "bundle_hash", "in", "self", ".", "mempool", ".", "spends", ":", "return", "self", ".", "mempool", ".", "spends", "[", ...
[ 486, 4 ]
[ 490, 19 ]
python
en
['en', 'en', 'en']
True
MempoolManager.new_peak
(self, new_peak: Optional[BlockRecord])
Called when a new peak is available, we try to recreate a mempool for the new tip.
Called when a new peak is available, we try to recreate a mempool for the new tip.
async def new_peak(self, new_peak: Optional[BlockRecord]) -> List[Tuple[SpendBundle, NPCResult, bytes32]]: """ Called when a new peak is available, we try to recreate a mempool for the new tip. """ if new_peak is None: return [] if new_peak.is_transaction_block is Fal...
[ "async", "def", "new_peak", "(", "self", ",", "new_peak", ":", "Optional", "[", "BlockRecord", "]", ")", "->", "List", "[", "Tuple", "[", "SpendBundle", ",", "NPCResult", ",", "bytes32", "]", "]", ":", "if", "new_peak", "is", "None", ":", "return", "["...
[ 492, 4 ]
[ 535, 24 ]
python
en
['en', 'error', 'th']
False
extract_cookies_to_jar
(jar, request, response)
Extract the cookies from the response into a CookieJar. :param jar: cookielib.CookieJar (not necessarily a RequestsCookieJar) :param request: our own requests.Request object :param response: urllib3.HTTPResponse object
Extract the cookies from the response into a CookieJar.
def extract_cookies_to_jar(jar, request, response): """Extract the cookies from the response into a CookieJar. :param jar: cookielib.CookieJar (not necessarily a RequestsCookieJar) :param request: our own requests.Request object :param response: urllib3.HTTPResponse object """ if not (hasattr(r...
[ "def", "extract_cookies_to_jar", "(", "jar", ",", "request", ",", "response", ")", ":", "if", "not", "(", "hasattr", "(", "response", ",", "'_original_response'", ")", "and", "response", ".", "_original_response", ")", ":", "return", "# the _original_response fiel...
[ 117, 0 ]
[ 131, 33 ]
python
en
['en', 'en', 'en']
True
get_cookie_header
(jar, request)
Produce an appropriate Cookie header string to be sent with `request`, or None. :rtype: str
Produce an appropriate Cookie header string to be sent with `request`, or None.
def get_cookie_header(jar, request): """ Produce an appropriate Cookie header string to be sent with `request`, or None. :rtype: str """ r = MockRequest(request) jar.add_cookie_header(r) return r.get_new_headers().get('Cookie')
[ "def", "get_cookie_header", "(", "jar", ",", "request", ")", ":", "r", "=", "MockRequest", "(", "request", ")", "jar", ".", "add_cookie_header", "(", "r", ")", "return", "r", ".", "get_new_headers", "(", ")", ".", "get", "(", "'Cookie'", ")" ]
[ 134, 0 ]
[ 142, 44 ]
python
en
['en', 'error', 'th']
False
remove_cookie_by_name
(cookiejar, name, domain=None, path=None)
Unsets a cookie by name, by default over all domains and paths. Wraps CookieJar.clear(), is O(n).
Unsets a cookie by name, by default over all domains and paths.
def remove_cookie_by_name(cookiejar, name, domain=None, path=None): """Unsets a cookie by name, by default over all domains and paths. Wraps CookieJar.clear(), is O(n). """ clearables = [] for cookie in cookiejar: if cookie.name != name: continue if domain is not None an...
[ "def", "remove_cookie_by_name", "(", "cookiejar", ",", "name", ",", "domain", "=", "None", ",", "path", "=", "None", ")", ":", "clearables", "=", "[", "]", "for", "cookie", "in", "cookiejar", ":", "if", "cookie", ".", "name", "!=", "name", ":", "contin...
[ 145, 0 ]
[ 161, 43 ]
python
en
['en', 'en', 'en']
True
create_cookie
(name, value, **kwargs)
Make a cookie from underspecified parameters. By default, the pair of `name` and `value` will be set for the domain '' and sent on every request (this is sometimes called a "supercookie").
Make a cookie from underspecified parameters.
def create_cookie(name, value, **kwargs): """Make a cookie from underspecified parameters. By default, the pair of `name` and `value` will be set for the domain '' and sent on every request (this is sometimes called a "supercookie"). """ result = { 'version': 0, 'name': name, ...
[ "def", "create_cookie", "(", "name", ",", "value", ",", "*", "*", "kwargs", ")", ":", "result", "=", "{", "'version'", ":", "0", ",", "'name'", ":", "name", ",", "'value'", ":", "value", ",", "'port'", ":", "None", ",", "'domain'", ":", "''", ",", ...
[ 440, 0 ]
[ 473, 37 ]
python
en
['en', 'en', 'en']
True
morsel_to_cookie
(morsel)
Convert a Morsel object into a Cookie containing the one k/v pair.
Convert a Morsel object into a Cookie containing the one k/v pair.
def morsel_to_cookie(morsel): """Convert a Morsel object into a Cookie containing the one k/v pair.""" expires = None if morsel['max-age']: try: expires = int(time.time() + int(morsel['max-age'])) except ValueError: raise TypeError('max-age: %s must be integer' % mor...
[ "def", "morsel_to_cookie", "(", "morsel", ")", ":", "expires", "=", "None", "if", "morsel", "[", "'max-age'", "]", ":", "try", ":", "expires", "=", "int", "(", "time", ".", "time", "(", ")", "+", "int", "(", "morsel", "[", "'max-age'", "]", ")", ")...
[ 476, 0 ]
[ 504, 5 ]
python
en
['en', 'en', 'en']
True
cookiejar_from_dict
(cookie_dict, cookiejar=None, overwrite=True)
Returns a CookieJar from a key/value dictionary. :param cookie_dict: Dict of key/values to insert into CookieJar. :param cookiejar: (optional) A cookiejar to add the cookies to. :param overwrite: (optional) If False, will not replace cookies already in the jar with new ones. :rtype: CookieJar ...
Returns a CookieJar from a key/value dictionary.
def cookiejar_from_dict(cookie_dict, cookiejar=None, overwrite=True): """Returns a CookieJar from a key/value dictionary. :param cookie_dict: Dict of key/values to insert into CookieJar. :param cookiejar: (optional) A cookiejar to add the cookies to. :param overwrite: (optional) If False, will not repl...
[ "def", "cookiejar_from_dict", "(", "cookie_dict", ",", "cookiejar", "=", "None", ",", "overwrite", "=", "True", ")", ":", "if", "cookiejar", "is", "None", ":", "cookiejar", "=", "RequestsCookieJar", "(", ")", "if", "cookie_dict", "is", "not", "None", ":", ...
[ 507, 0 ]
[ 525, 20 ]
python
en
['en', 'en', 'en']
True
merge_cookies
(cookiejar, cookies)
Add cookies to cookiejar and returns a merged CookieJar. :param cookiejar: CookieJar object to add the cookies to. :param cookies: Dictionary or CookieJar object to be added. :rtype: CookieJar
Add cookies to cookiejar and returns a merged CookieJar.
def merge_cookies(cookiejar, cookies): """Add cookies to cookiejar and returns a merged CookieJar. :param cookiejar: CookieJar object to add the cookies to. :param cookies: Dictionary or CookieJar object to be added. :rtype: CookieJar """ if not isinstance(cookiejar, cookielib.CookieJar): ...
[ "def", "merge_cookies", "(", "cookiejar", ",", "cookies", ")", ":", "if", "not", "isinstance", "(", "cookiejar", ",", "cookielib", ".", "CookieJar", ")", ":", "raise", "ValueError", "(", "'You can only merge into CookieJar'", ")", "if", "isinstance", "(", "cooki...
[ 528, 0 ]
[ 548, 20 ]
python
en
['en', 'af', 'en']
True
MockRequest.add_header
(self, key, val)
cookielib has no legitimate use for this method; add it back if you find one.
cookielib has no legitimate use for this method; add it back if you find one.
def add_header(self, key, val): """cookielib has no legitimate use for this method; add it back if you find one.""" raise NotImplementedError("Cookie headers should be added with add_unredirected_header()")
[ "def", "add_header", "(", "self", ",", "key", ",", "val", ")", ":", "raise", "NotImplementedError", "(", "\"Cookie headers should be added with add_unredirected_header()\"", ")" ]
[ 73, 4 ]
[ 75, 98 ]
python
en
['en', 'en', 'en']
True
MockResponse.__init__
(self, headers)
Make a MockResponse for `cookielib` to read. :param headers: a httplib.HTTPMessage or analogous carrying the headers
Make a MockResponse for `cookielib` to read.
def __init__(self, headers): """Make a MockResponse for `cookielib` to read. :param headers: a httplib.HTTPMessage or analogous carrying the headers """ self._headers = headers
[ "def", "__init__", "(", "self", ",", "headers", ")", ":", "self", ".", "_headers", "=", "headers" ]
[ 103, 4 ]
[ 108, 31 ]
python
en
['en', 'en', 'en']
True
RequestsCookieJar.get
(self, name, default=None, domain=None, path=None)
Dict-like get() that also supports optional domain and path args in order to resolve naming collisions from using one cookie jar over multiple domains. .. warning:: operation is O(n), not O(1).
Dict-like get() that also supports optional domain and path args in order to resolve naming collisions from using one cookie jar over multiple domains.
def get(self, name, default=None, domain=None, path=None): """Dict-like get() that also supports optional domain and path args in order to resolve naming collisions from using one cookie jar over multiple domains. .. warning:: operation is O(n), not O(1). """ try: ...
[ "def", "get", "(", "self", ",", "name", ",", "default", "=", "None", ",", "domain", "=", "None", ",", "path", "=", "None", ")", ":", "try", ":", "return", "self", ".", "_find_no_duplicates", "(", "name", ",", "domain", ",", "path", ")", "except", "...
[ 188, 4 ]
[ 198, 26 ]
python
en
['en', 'en', 'en']
True
RequestsCookieJar.set
(self, name, value, **kwargs)
Dict-like set() that also supports optional domain and path args in order to resolve naming collisions from using one cookie jar over multiple domains.
Dict-like set() that also supports optional domain and path args in order to resolve naming collisions from using one cookie jar over multiple domains.
def set(self, name, value, **kwargs): """Dict-like set() that also supports optional domain and path args in order to resolve naming collisions from using one cookie jar over multiple domains. """ # support client code that unsets cookies by assignment of a None value: if...
[ "def", "set", "(", "self", ",", "name", ",", "value", ",", "*", "*", "kwargs", ")", ":", "# support client code that unsets cookies by assignment of a None value:", "if", "value", "is", "None", ":", "remove_cookie_by_name", "(", "self", ",", "name", ",", "domain",...
[ 200, 4 ]
[ 215, 16 ]
python
en
['en', 'en', 'en']
True
RequestsCookieJar.iterkeys
(self)
Dict-like iterkeys() that returns an iterator of names of cookies from the jar. .. seealso:: itervalues() and iteritems().
Dict-like iterkeys() that returns an iterator of names of cookies from the jar.
def iterkeys(self): """Dict-like iterkeys() that returns an iterator of names of cookies from the jar. .. seealso:: itervalues() and iteritems(). """ for cookie in iter(self): yield cookie.name
[ "def", "iterkeys", "(", "self", ")", ":", "for", "cookie", "in", "iter", "(", "self", ")", ":", "yield", "cookie", ".", "name" ]
[ 217, 4 ]
[ 224, 29 ]
python
en
['en', 'en', 'en']
True
RequestsCookieJar.keys
(self)
Dict-like keys() that returns a list of names of cookies from the jar. .. seealso:: values() and items().
Dict-like keys() that returns a list of names of cookies from the jar.
def keys(self): """Dict-like keys() that returns a list of names of cookies from the jar. .. seealso:: values() and items(). """ return list(self.iterkeys())
[ "def", "keys", "(", "self", ")", ":", "return", "list", "(", "self", ".", "iterkeys", "(", ")", ")" ]
[ 226, 4 ]
[ 232, 36 ]
python
en
['en', 'en', 'en']
True
RequestsCookieJar.itervalues
(self)
Dict-like itervalues() that returns an iterator of values of cookies from the jar. .. seealso:: iterkeys() and iteritems().
Dict-like itervalues() that returns an iterator of values of cookies from the jar.
def itervalues(self): """Dict-like itervalues() that returns an iterator of values of cookies from the jar. .. seealso:: iterkeys() and iteritems(). """ for cookie in iter(self): yield cookie.value
[ "def", "itervalues", "(", "self", ")", ":", "for", "cookie", "in", "iter", "(", "self", ")", ":", "yield", "cookie", ".", "value" ]
[ 234, 4 ]
[ 241, 30 ]
python
en
['en', 'en', 'en']
True
RequestsCookieJar.values
(self)
Dict-like values() that returns a list of values of cookies from the jar. .. seealso:: keys() and items().
Dict-like values() that returns a list of values of cookies from the jar.
def values(self): """Dict-like values() that returns a list of values of cookies from the jar. .. seealso:: keys() and items(). """ return list(self.itervalues())
[ "def", "values", "(", "self", ")", ":", "return", "list", "(", "self", ".", "itervalues", "(", ")", ")" ]
[ 243, 4 ]
[ 249, 38 ]
python
en
['en', 'en', 'en']
True
RequestsCookieJar.iteritems
(self)
Dict-like iteritems() that returns an iterator of name-value tuples from the jar. .. seealso:: iterkeys() and itervalues().
Dict-like iteritems() that returns an iterator of name-value tuples from the jar.
def iteritems(self): """Dict-like iteritems() that returns an iterator of name-value tuples from the jar. .. seealso:: iterkeys() and itervalues(). """ for cookie in iter(self): yield cookie.name, cookie.value
[ "def", "iteritems", "(", "self", ")", ":", "for", "cookie", "in", "iter", "(", "self", ")", ":", "yield", "cookie", ".", "name", ",", "cookie", ".", "value" ]
[ 251, 4 ]
[ 258, 43 ]
python
en
['en', 'en', 'en']
True
RequestsCookieJar.items
(self)
Dict-like items() that returns a list of name-value tuples from the jar. Allows client-code to call ``dict(RequestsCookieJar)`` and get a vanilla python dict of key value pairs. .. seealso:: keys() and values().
Dict-like items() that returns a list of name-value tuples from the jar. Allows client-code to call ``dict(RequestsCookieJar)`` and get a vanilla python dict of key value pairs.
def items(self): """Dict-like items() that returns a list of name-value tuples from the jar. Allows client-code to call ``dict(RequestsCookieJar)`` and get a vanilla python dict of key value pairs. .. seealso:: keys() and values(). """ return list(self.iteritems())
[ "def", "items", "(", "self", ")", ":", "return", "list", "(", "self", ".", "iteritems", "(", ")", ")" ]
[ 260, 4 ]
[ 267, 37 ]
python
en
['en', 'en', 'en']
True
RequestsCookieJar.list_domains
(self)
Utility method to list all the domains in the jar.
Utility method to list all the domains in the jar.
def list_domains(self): """Utility method to list all the domains in the jar.""" domains = [] for cookie in iter(self): if cookie.domain not in domains: domains.append(cookie.domain) return domains
[ "def", "list_domains", "(", "self", ")", ":", "domains", "=", "[", "]", "for", "cookie", "in", "iter", "(", "self", ")", ":", "if", "cookie", ".", "domain", "not", "in", "domains", ":", "domains", ".", "append", "(", "cookie", ".", "domain", ")", "...
[ 269, 4 ]
[ 275, 22 ]
python
en
['en', 'en', 'en']
True
RequestsCookieJar.list_paths
(self)
Utility method to list all the paths in the jar.
Utility method to list all the paths in the jar.
def list_paths(self): """Utility method to list all the paths in the jar.""" paths = [] for cookie in iter(self): if cookie.path not in paths: paths.append(cookie.path) return paths
[ "def", "list_paths", "(", "self", ")", ":", "paths", "=", "[", "]", "for", "cookie", "in", "iter", "(", "self", ")", ":", "if", "cookie", ".", "path", "not", "in", "paths", ":", "paths", ".", "append", "(", "cookie", ".", "path", ")", "return", "...
[ 277, 4 ]
[ 283, 20 ]
python
en
['en', 'en', 'en']
True
RequestsCookieJar.multiple_domains
(self)
Returns True if there are multiple domains in the jar. Returns False otherwise. :rtype: bool
Returns True if there are multiple domains in the jar. Returns False otherwise.
def multiple_domains(self): """Returns True if there are multiple domains in the jar. Returns False otherwise. :rtype: bool """ domains = [] for cookie in iter(self): if cookie.domain is not None and cookie.domain in domains: return True ...
[ "def", "multiple_domains", "(", "self", ")", ":", "domains", "=", "[", "]", "for", "cookie", "in", "iter", "(", "self", ")", ":", "if", "cookie", ".", "domain", "is", "not", "None", "and", "cookie", ".", "domain", "in", "domains", ":", "return", "Tru...
[ 285, 4 ]
[ 296, 20 ]
python
en
['en', 'en', 'en']
True
RequestsCookieJar.get_dict
(self, domain=None, path=None)
Takes as an argument an optional domain and path and returns a plain old Python dict of name-value pairs of cookies that meet the requirements. :rtype: dict
Takes as an argument an optional domain and path and returns a plain old Python dict of name-value pairs of cookies that meet the requirements.
def get_dict(self, domain=None, path=None): """Takes as an argument an optional domain and path and returns a plain old Python dict of name-value pairs of cookies that meet the requirements. :rtype: dict """ dictionary = {} for cookie in iter(self): i...
[ "def", "get_dict", "(", "self", ",", "domain", "=", "None", ",", "path", "=", "None", ")", ":", "dictionary", "=", "{", "}", "for", "cookie", "in", "iter", "(", "self", ")", ":", "if", "(", "(", "domain", "is", "None", "or", "cookie", ".", "domai...
[ 298, 4 ]
[ 312, 25 ]
python
en
['en', 'en', 'en']
True
RequestsCookieJar.__getitem__
(self, name)
Dict-like __getitem__() for compatibility with client code. Throws exception if there are more than one cookie with name. In that case, use the more explicit get() method instead. .. warning:: operation is O(n), not O(1).
Dict-like __getitem__() for compatibility with client code. Throws exception if there are more than one cookie with name. In that case, use the more explicit get() method instead.
def __getitem__(self, name): """Dict-like __getitem__() for compatibility with client code. Throws exception if there are more than one cookie with name. In that case, use the more explicit get() method instead. .. warning:: operation is O(n), not O(1). """ return self._...
[ "def", "__getitem__", "(", "self", ",", "name", ")", ":", "return", "self", ".", "_find_no_duplicates", "(", "name", ")" ]
[ 320, 4 ]
[ 327, 45 ]
python
en
['en', 'en', 'en']
True
RequestsCookieJar.__setitem__
(self, name, value)
Dict-like __setitem__ for compatibility with client code. Throws exception if there is already a cookie of that name in the jar. In that case, use the more explicit set() method instead.
Dict-like __setitem__ for compatibility with client code. Throws exception if there is already a cookie of that name in the jar. In that case, use the more explicit set() method instead.
def __setitem__(self, name, value): """Dict-like __setitem__ for compatibility with client code. Throws exception if there is already a cookie of that name in the jar. In that case, use the more explicit set() method instead. """ self.set(name, value)
[ "def", "__setitem__", "(", "self", ",", "name", ",", "value", ")", ":", "self", ".", "set", "(", "name", ",", "value", ")" ]
[ 329, 4 ]
[ 334, 29 ]
python
en
['en', 'en', 'en']
True
RequestsCookieJar.__delitem__
(self, name)
Deletes a cookie given a name. Wraps ``cookielib.CookieJar``'s ``remove_cookie_by_name()``.
Deletes a cookie given a name. Wraps ``cookielib.CookieJar``'s ``remove_cookie_by_name()``.
def __delitem__(self, name): """Deletes a cookie given a name. Wraps ``cookielib.CookieJar``'s ``remove_cookie_by_name()``. """ remove_cookie_by_name(self, name)
[ "def", "__delitem__", "(", "self", ",", "name", ")", ":", "remove_cookie_by_name", "(", "self", ",", "name", ")" ]
[ 336, 4 ]
[ 340, 41 ]
python
en
['en', 'en', 'en']
True
RequestsCookieJar.update
(self, other)
Updates this jar with cookies from another CookieJar or dict-like
Updates this jar with cookies from another CookieJar or dict-like
def update(self, other): """Updates this jar with cookies from another CookieJar or dict-like""" if isinstance(other, cookielib.CookieJar): for cookie in other: self.set_cookie(copy.copy(cookie)) else: super(RequestsCookieJar, self).update(other)
[ "def", "update", "(", "self", ",", "other", ")", ":", "if", "isinstance", "(", "other", ",", "cookielib", ".", "CookieJar", ")", ":", "for", "cookie", "in", "other", ":", "self", ".", "set_cookie", "(", "copy", ".", "copy", "(", "cookie", ")", ")", ...
[ 347, 4 ]
[ 353, 56 ]
python
en
['en', 'en', 'en']
True
RequestsCookieJar._find
(self, name, domain=None, path=None)
Requests uses this method internally to get cookie values. If there are conflicting cookies, _find arbitrarily chooses one. See _find_no_duplicates if you want an exception thrown if there are conflicting cookies. :param name: a string containing name of cookie :param domain: (...
Requests uses this method internally to get cookie values.
def _find(self, name, domain=None, path=None): """Requests uses this method internally to get cookie values. If there are conflicting cookies, _find arbitrarily chooses one. See _find_no_duplicates if you want an exception thrown if there are conflicting cookies. :param name: a...
[ "def", "_find", "(", "self", ",", "name", ",", "domain", "=", "None", ",", "path", "=", "None", ")", ":", "for", "cookie", "in", "iter", "(", "self", ")", ":", "if", "cookie", ".", "name", "==", "name", ":", "if", "domain", "is", "None", "or", ...
[ 355, 4 ]
[ 373, 76 ]
python
en
['en', 'en', 'en']
True
RequestsCookieJar._find_no_duplicates
(self, name, domain=None, path=None)
Both ``__get_item__`` and ``get`` call this function: it's never used elsewhere in Requests. :param name: a string containing name of cookie :param domain: (optional) string containing domain of cookie :param path: (optional) string containing path of cookie :raises KeyError: if...
Both ``__get_item__`` and ``get`` call this function: it's never used elsewhere in Requests.
def _find_no_duplicates(self, name, domain=None, path=None): """Both ``__get_item__`` and ``get`` call this function: it's never used elsewhere in Requests. :param name: a string containing name of cookie :param domain: (optional) string containing domain of cookie :param path: ...
[ "def", "_find_no_duplicates", "(", "self", ",", "name", ",", "domain", "=", "None", ",", "path", "=", "None", ")", ":", "toReturn", "=", "None", "for", "cookie", "in", "iter", "(", "self", ")", ":", "if", "cookie", ".", "name", "==", "name", ":", "...
[ 375, 4 ]
[ 398, 76 ]
python
en
['en', 'en', 'en']
True
RequestsCookieJar.__getstate__
(self)
Unlike a normal CookieJar, this class is pickleable.
Unlike a normal CookieJar, this class is pickleable.
def __getstate__(self): """Unlike a normal CookieJar, this class is pickleable.""" state = self.__dict__.copy() # remove the unpickleable RLock object state.pop('_cookies_lock') return state
[ "def", "__getstate__", "(", "self", ")", ":", "state", "=", "self", ".", "__dict__", ".", "copy", "(", ")", "# remove the unpickleable RLock object", "state", ".", "pop", "(", "'_cookies_lock'", ")", "return", "state" ]
[ 400, 4 ]
[ 405, 20 ]
python
en
['en', 'en', 'en']
True
RequestsCookieJar.__setstate__
(self, state)
Unlike a normal CookieJar, this class is pickleable.
Unlike a normal CookieJar, this class is pickleable.
def __setstate__(self, state): """Unlike a normal CookieJar, this class is pickleable.""" self.__dict__.update(state) if '_cookies_lock' not in self.__dict__: self._cookies_lock = threading.RLock()
[ "def", "__setstate__", "(", "self", ",", "state", ")", ":", "self", ".", "__dict__", ".", "update", "(", "state", ")", "if", "'_cookies_lock'", "not", "in", "self", ".", "__dict__", ":", "self", ".", "_cookies_lock", "=", "threading", ".", "RLock", "(", ...
[ 407, 4 ]
[ 411, 50 ]
python
en
['en', 'en', 'en']
True
RequestsCookieJar.copy
(self)
Return a copy of this RequestsCookieJar.
Return a copy of this RequestsCookieJar.
def copy(self): """Return a copy of this RequestsCookieJar.""" new_cj = RequestsCookieJar() new_cj.set_policy(self.get_policy()) new_cj.update(self) return new_cj
[ "def", "copy", "(", "self", ")", ":", "new_cj", "=", "RequestsCookieJar", "(", ")", "new_cj", ".", "set_policy", "(", "self", ".", "get_policy", "(", ")", ")", "new_cj", ".", "update", "(", "self", ")", "return", "new_cj" ]
[ 413, 4 ]
[ 418, 21 ]
python
en
['en', 'en', 'en']
True
RequestsCookieJar.get_policy
(self)
Return the CookiePolicy instance used.
Return the CookiePolicy instance used.
def get_policy(self): """Return the CookiePolicy instance used.""" return self._policy
[ "def", "get_policy", "(", "self", ")", ":", "return", "self", ".", "_policy" ]
[ 420, 4 ]
[ 422, 27 ]
python
en
['en', 'en', 'en']
True
generate_metadata
(build_env, backend)
Generate metadata using mechanisms described in PEP 517. Returns the generated metadata directory.
Generate metadata using mechanisms described in PEP 517.
def generate_metadata(build_env, backend): # type: (BuildEnvironment, Pep517HookCaller) -> str """Generate metadata using mechanisms described in PEP 517. Returns the generated metadata directory. """ metadata_tmpdir = TempDirectory( kind="modern-metadata", globally_managed=True ) ...
[ "def", "generate_metadata", "(", "build_env", ",", "backend", ")", ":", "# type: (BuildEnvironment, Pep517HookCaller) -> str", "metadata_tmpdir", "=", "TempDirectory", "(", "kind", "=", "\"modern-metadata\"", ",", "globally_managed", "=", "True", ")", "metadata_dir", "=",...
[ 15, 0 ]
[ 37, 51 ]
python
en
['en', 'nl', 'en']
True
ping_google
(sitemap_url=None, ping_url=PING_URL)
Alerts Google that the sitemap for the current site has been updated. If sitemap_url is provided, it should be an absolute path to the sitemap for this site -- e.g., '/sitemap.xml'. If sitemap_url is not provided, this function will attempt to deduce it by using urls.reverse().
Alerts Google that the sitemap for the current site has been updated. If sitemap_url is provided, it should be an absolute path to the sitemap for this site -- e.g., '/sitemap.xml'. If sitemap_url is not provided, this function will attempt to deduce it by using urls.reverse().
def ping_google(sitemap_url=None, ping_url=PING_URL): """ Alerts Google that the sitemap for the current site has been updated. If sitemap_url is provided, it should be an absolute path to the sitemap for this site -- e.g., '/sitemap.xml'. If sitemap_url is not provided, this function will attempt t...
[ "def", "ping_google", "(", "sitemap_url", "=", "None", ",", "ping_url", "=", "PING_URL", ")", ":", "sitemap_full_url", "=", "_get_sitemap_full_url", "(", "sitemap_url", ")", "params", "=", "urlencode", "(", "{", "'sitemap'", ":", "sitemap_full_url", "}", ")", ...
[ 16, 0 ]
[ 25, 41 ]
python
en
['en', 'error', 'th']
False