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
ConfigHandler._parse_file
(cls, value)
Represents value as a string, allowing including text from nearest files using `file:` directive. Directive is sandboxed and won't reach anything outside directory with setup.py. Examples: file: README.rst, CHANGELOG.md, src/file.txt :param str value: :rtyp...
Represents value as a string, allowing including text from nearest files using `file:` directive.
def _parse_file(cls, value): """Represents value as a string, allowing including text from nearest files using `file:` directive. Directive is sandboxed and won't reach anything outside directory with setup.py. Examples: file: README.rst, CHANGELOG.md, src/file.txt ...
[ "def", "_parse_file", "(", "cls", ",", "value", ")", ":", "include_directive", "=", "'file:'", "if", "not", "isinstance", "(", "value", ",", "str", ")", ":", "return", "value", "if", "not", "value", ".", "startswith", "(", "include_directive", ")", ":", ...
[ 306, 4 ]
[ 334, 9 ]
python
en
['en', 'en', 'en']
True
ConfigHandler._parse_attr
(cls, value, package_dir=None)
Represents value as a module attribute. Examples: attr: package.attr attr: package.module.attr :param str value: :rtype: str
Represents value as a module attribute.
def _parse_attr(cls, value, package_dir=None): """Represents value as a module attribute. Examples: attr: package.attr attr: package.module.attr :param str value: :rtype: str """ attr_directive = 'attr:' if not value.startswith(attr_direc...
[ "def", "_parse_attr", "(", "cls", ",", "value", ",", "package_dir", "=", "None", ")", ":", "attr_directive", "=", "'attr:'", "if", "not", "value", ".", "startswith", "(", "attr_directive", ")", ":", "return", "value", "attrs_path", "=", "value", ".", "repl...
[ 348, 4 ]
[ 391, 41 ]
python
en
['en', 'en', 'en']
True
ConfigHandler._get_parser_compound
(cls, *parse_methods)
Returns parser function to represents value as a list. Parses a value applying given methods one after another. :param parse_methods: :rtype: callable
Returns parser function to represents value as a list.
def _get_parser_compound(cls, *parse_methods): """Returns parser function to represents value as a list. Parses a value applying given methods one after another. :param parse_methods: :rtype: callable """ def parse(value): parsed = value for met...
[ "def", "_get_parser_compound", "(", "cls", ",", "*", "parse_methods", ")", ":", "def", "parse", "(", "value", ")", ":", "parsed", "=", "value", "for", "method", "in", "parse_methods", ":", "parsed", "=", "method", "(", "parsed", ")", "return", "parsed", ...
[ 394, 4 ]
[ 410, 20 ]
python
en
['en', 'en', 'en']
True
ConfigHandler._parse_section_to_dict
(cls, section_options, values_parser=None)
Parses section options into a dictionary. Optionally applies a given parser to values. :param dict section_options: :param callable values_parser: :rtype: dict
Parses section options into a dictionary.
def _parse_section_to_dict(cls, section_options, values_parser=None): """Parses section options into a dictionary. Optionally applies a given parser to values. :param dict section_options: :param callable values_parser: :rtype: dict """ value = {} values...
[ "def", "_parse_section_to_dict", "(", "cls", ",", "section_options", ",", "values_parser", "=", "None", ")", ":", "value", "=", "{", "}", "values_parser", "=", "values_parser", "or", "(", "lambda", "val", ":", "val", ")", "for", "key", ",", "(", "_", ","...
[ 413, 4 ]
[ 426, 20 ]
python
en
['en', 'en', 'en']
True
ConfigHandler.parse_section
(self, section_options)
Parses configuration file section. :param dict section_options:
Parses configuration file section.
def parse_section(self, section_options): """Parses configuration file section. :param dict section_options: """ for (name, (_, value)) in section_options.items(): try: self[name] = value except KeyError: pass
[ "def", "parse_section", "(", "self", ",", "section_options", ")", ":", "for", "(", "name", ",", "(", "_", ",", "value", ")", ")", "in", "section_options", ".", "items", "(", ")", ":", "try", ":", "self", "[", "name", "]", "=", "value", "except", "K...
[ 428, 4 ]
[ 438, 20 ]
python
en
['en', 'en', 'en']
True
ConfigHandler.parse
(self)
Parses configuration file items from one or more related sections.
Parses configuration file items from one or more related sections.
def parse(self): """Parses configuration file items from one or more related sections. """ for section_name, section_options in self.sections.items(): method_postfix = '' if section_name: # [section.option] variant method_postfix = '_%s' % secti...
[ "def", "parse", "(", "self", ")", ":", "for", "section_name", ",", "section_options", "in", "self", ".", "sections", ".", "items", "(", ")", ":", "method_postfix", "=", "''", "if", "section_name", ":", "# [section.option] variant", "method_postfix", "=", "'_%s...
[ 440, 4 ]
[ 462, 50 ]
python
en
['en', 'en', 'en']
True
ConfigHandler._deprecated_config_handler
(self, func, msg, warning_class)
this function will wrap around parameters that are deprecated :param msg: deprecation message :param warning_class: class of warning exception to be raised :param func: function to be wrapped around
this function will wrap around parameters that are deprecated
def _deprecated_config_handler(self, func, msg, warning_class): """ this function will wrap around parameters that are deprecated :param msg: deprecation message :param warning_class: class of warning exception to be raised :param func: function to be wrapped around """ ...
[ "def", "_deprecated_config_handler", "(", "self", ",", "func", ",", "msg", ",", "warning_class", ")", ":", "@", "wraps", "(", "func", ")", "def", "config_handler", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "warnings", ".", "warn", "(", "msg"...
[ 464, 4 ]
[ 476, 29 ]
python
en
['en', 'en', 'en']
True
ConfigMetadataHandler.parsers
(self)
Metadata item name to parser function mapping.
Metadata item name to parser function mapping.
def parsers(self): """Metadata item name to parser function mapping.""" parse_list = self._parse_list parse_file = self._parse_file parse_dict = self._parse_dict exclude_files_parser = self._exclude_files_parser return { 'platforms': parse_list, '...
[ "def", "parsers", "(", "self", ")", ":", "parse_list", "=", "self", ".", "_parse_list", "parse_file", "=", "self", ".", "_parse_file", "parse_dict", "=", "self", ".", "_parse_dict", "exclude_files_parser", "=", "self", ".", "_exclude_files_parser", "return", "{"...
[ 503, 4 ]
[ 527, 9 ]
python
en
['en', 'jv', 'en']
True
ConfigMetadataHandler._parse_version
(self, value)
Parses `version` option value. :param value: :rtype: str
Parses `version` option value.
def _parse_version(self, value): """Parses `version` option value. :param value: :rtype: str """ version = self._parse_file(value) if version != value: version = version.strip() # Be strict about versions loaded from file because it's easy to ...
[ "def", "_parse_version", "(", "self", ",", "value", ")", ":", "version", "=", "self", ".", "_parse_file", "(", "value", ")", "if", "version", "!=", "value", ":", "version", "=", "version", ".", "strip", "(", ")", "# Be strict about versions loaded from file be...
[ 529, 4 ]
[ 562, 22 ]
python
en
['en', 'fr', 'en']
True
ConfigOptionsHandler.parsers
(self)
Metadata item name to parser function mapping.
Metadata item name to parser function mapping.
def parsers(self): """Metadata item name to parser function mapping.""" parse_list = self._parse_list parse_list_semicolon = partial(self._parse_list, separator=';') parse_bool = self._parse_bool parse_dict = self._parse_dict return { 'zip_safe': parse_bool, ...
[ "def", "parsers", "(", "self", ")", ":", "parse_list", "=", "self", ".", "_parse_list", "parse_list_semicolon", "=", "partial", "(", "self", ".", "_parse_list", ",", "separator", "=", "';'", ")", "parse_bool", "=", "self", ".", "_parse_bool", "parse_dict", "...
[ 570, 4 ]
[ 596, 9 ]
python
en
['en', 'jv', 'en']
True
ConfigOptionsHandler._parse_packages
(self, value)
Parses `packages` option value. :param value: :rtype: list
Parses `packages` option value.
def _parse_packages(self, value): """Parses `packages` option value. :param value: :rtype: list """ find_directives = ['find:', 'find_namespace:'] trimmed_value = value.strip() if trimmed_value not in find_directives: return self._parse_list(value) ...
[ "def", "_parse_packages", "(", "self", ",", "value", ")", ":", "find_directives", "=", "[", "'find:'", ",", "'find_namespace:'", "]", "trimmed_value", "=", "value", ".", "strip", "(", ")", "if", "trimmed_value", "not", "in", "find_directives", ":", "return", ...
[ 598, 4 ]
[ 621, 43 ]
python
en
['en', 'en', 'en']
True
ConfigOptionsHandler.parse_section_packages__find
(self, section_options)
Parses `packages.find` configuration file section. To be used in conjunction with _parse_packages(). :param dict section_options:
Parses `packages.find` configuration file section.
def parse_section_packages__find(self, section_options): """Parses `packages.find` configuration file section. To be used in conjunction with _parse_packages(). :param dict section_options: """ section_data = self._parse_section_to_dict( section_options, self._parse...
[ "def", "parse_section_packages__find", "(", "self", ",", "section_options", ")", ":", "section_data", "=", "self", ".", "_parse_section_to_dict", "(", "section_options", ",", "self", ".", "_parse_list", ")", "valid_keys", "=", "[", "'where'", ",", "'include'", ","...
[ 623, 4 ]
[ 642, 26 ]
python
en
['en', 'en', 'en']
True
ConfigOptionsHandler.parse_section_entry_points
(self, section_options)
Parses `entry_points` configuration file section. :param dict section_options:
Parses `entry_points` configuration file section.
def parse_section_entry_points(self, section_options): """Parses `entry_points` configuration file section. :param dict section_options: """ parsed = self._parse_section_to_dict(section_options, self._parse_list) self['entry_points'] = parsed
[ "def", "parse_section_entry_points", "(", "self", ",", "section_options", ")", ":", "parsed", "=", "self", ".", "_parse_section_to_dict", "(", "section_options", ",", "self", ".", "_parse_list", ")", "self", "[", "'entry_points'", "]", "=", "parsed" ]
[ 644, 4 ]
[ 650, 37 ]
python
en
['en', 'en', 'en']
True
ConfigOptionsHandler.parse_section_package_data
(self, section_options)
Parses `package_data` configuration file section. :param dict section_options:
Parses `package_data` configuration file section.
def parse_section_package_data(self, section_options): """Parses `package_data` configuration file section. :param dict section_options: """ self['package_data'] = self._parse_package_data(section_options)
[ "def", "parse_section_package_data", "(", "self", ",", "section_options", ")", ":", "self", "[", "'package_data'", "]", "=", "self", ".", "_parse_package_data", "(", "section_options", ")" ]
[ 662, 4 ]
[ 667, 72 ]
python
en
['en', 'en', 'en']
True
ConfigOptionsHandler.parse_section_exclude_package_data
(self, section_options)
Parses `exclude_package_data` configuration file section. :param dict section_options:
Parses `exclude_package_data` configuration file section.
def parse_section_exclude_package_data(self, section_options): """Parses `exclude_package_data` configuration file section. :param dict section_options: """ self['exclude_package_data'] = self._parse_package_data( section_options)
[ "def", "parse_section_exclude_package_data", "(", "self", ",", "section_options", ")", ":", "self", "[", "'exclude_package_data'", "]", "=", "self", ".", "_parse_package_data", "(", "section_options", ")" ]
[ 669, 4 ]
[ 675, 28 ]
python
en
['en', 'en', 'en']
True
ConfigOptionsHandler.parse_section_extras_require
(self, section_options)
Parses `extras_require` configuration file section. :param dict section_options:
Parses `extras_require` configuration file section.
def parse_section_extras_require(self, section_options): """Parses `extras_require` configuration file section. :param dict section_options: """ parse_list = partial(self._parse_list, separator=';') self['extras_require'] = self._parse_section_to_dict( section_option...
[ "def", "parse_section_extras_require", "(", "self", ",", "section_options", ")", ":", "parse_list", "=", "partial", "(", "self", ".", "_parse_list", ",", "separator", "=", "';'", ")", "self", "[", "'extras_require'", "]", "=", "self", ".", "_parse_section_to_dic...
[ 677, 4 ]
[ 684, 40 ]
python
en
['es', 'en', 'en']
True
ConfigOptionsHandler.parse_section_data_files
(self, section_options)
Parses `data_files` configuration file section. :param dict section_options:
Parses `data_files` configuration file section.
def parse_section_data_files(self, section_options): """Parses `data_files` configuration file section. :param dict section_options: """ parsed = self._parse_section_to_dict(section_options, self._parse_list) self['data_files'] = [(k, v) for k, v in parsed.items()]
[ "def", "parse_section_data_files", "(", "self", ",", "section_options", ")", ":", "parsed", "=", "self", ".", "_parse_section_to_dict", "(", "section_options", ",", "self", ".", "_parse_list", ")", "self", "[", "'data_files'", "]", "=", "[", "(", "k", ",", "...
[ 686, 4 ]
[ 692, 64 ]
python
en
['en', 'en', 'en']
True
get_display_recipient_remote_cache
( recipient_id: int, recipient_type: int, recipient_type_id: Optional[int] )
returns: an appropriate object describing the recipient. For a stream this will be the stream name as a string. For a huddle or personal, it will be an array of dicts about each recipient.
returns: an appropriate object describing the recipient. For a stream this will be the stream name as a string. For a huddle or personal, it will be an array of dicts about each recipient.
def get_display_recipient_remote_cache( recipient_id: int, recipient_type: int, recipient_type_id: Optional[int] ) -> DisplayRecipientT: """ returns: an appropriate object describing the recipient. For a stream this will be the stream name as a string. For a huddle or personal, it will be an array...
[ "def", "get_display_recipient_remote_cache", "(", "recipient_id", ":", "int", ",", "recipient_type", ":", "int", ",", "recipient_type_id", ":", "Optional", "[", "int", "]", ")", "->", "DisplayRecipientT", ":", "if", "recipient_type", "==", "Recipient", ".", "STREA...
[ 28, 0 ]
[ 51, 34 ]
python
en
['en', 'error', 'th']
False
bulk_fetch_display_recipients
( recipient_tuples: Set[Tuple[int, int, int]], )
Takes set of tuples of the form (recipient_id, recipient_type, recipient_type_id) Returns dict mapping recipient_id to corresponding display_recipient
Takes set of tuples of the form (recipient_id, recipient_type, recipient_type_id) Returns dict mapping recipient_id to corresponding display_recipient
def bulk_fetch_display_recipients( recipient_tuples: Set[Tuple[int, int, int]], ) -> Dict[int, DisplayRecipientT]: """ Takes set of tuples of the form (recipient_id, recipient_type, recipient_type_id) Returns dict mapping recipient_id to corresponding display_recipient """ # Build dict mapping ...
[ "def", "bulk_fetch_display_recipients", "(", "recipient_tuples", ":", "Set", "[", "Tuple", "[", "int", ",", "int", ",", "int", "]", "]", ",", ")", "->", "Dict", "[", "int", ",", "DisplayRecipientT", "]", ":", "# Build dict mapping recipient id to (type, type_id) o...
[ 72, 0 ]
[ 201, 82 ]
python
en
['en', 'error', 'th']
False
adapter
(js_constructor, base=Adapter)
Allows a class to implement its adapting logic with a `js_args()` method on the class itself. This just helps reduce the amount of code you have to write. For example: @adapter('wagtail.mywidget') class MyWidget(): ... def js_args(self): return [ ...
Allows a class to implement its adapting logic with a `js_args()` method on the class itself. This just helps reduce the amount of code you have to write.
def adapter(js_constructor, base=Adapter): """ Allows a class to implement its adapting logic with a `js_args()` method on the class itself. This just helps reduce the amount of code you have to write. For example: @adapter('wagtail.mywidget') class MyWidget(): ... ...
[ "def", "adapter", "(", "js_constructor", ",", "base", "=", "Adapter", ")", ":", "def", "_wrapper", "(", "cls", ")", ":", "ClassAdapter", "=", "type", "(", "cls", ".", "__name__", "+", "'Adapter'", ",", "(", "base", ",", ")", ",", "{", "'js_constructor'...
[ 26, 0 ]
[ 66, 19 ]
python
en
['en', 'error', 'th']
False
create_reverse_many_to_one_manager
(superclass, rel)
Create a manager for the reverse side of a many-to-one relation. This manager subclasses another manager, generally the default manager of the related model, and adds behaviors specific to many-to-one relations.
Create a manager for the reverse side of a many-to-one relation.
def create_reverse_many_to_one_manager(superclass, rel): """ Create a manager for the reverse side of a many-to-one relation. This manager subclasses another manager, generally the default manager of the related model, and adds behaviors specific to many-to-one relations. """ class RelatedMana...
[ "def", "create_reverse_many_to_one_manager", "(", "superclass", ",", "rel", ")", ":", "class", "RelatedManager", "(", "superclass", ")", ":", "def", "__init__", "(", "self", ",", "instance", ")", ":", "super", "(", "RelatedManager", ",", "self", ")", ".", "_...
[ 536, 0 ]
[ 731, 25 ]
python
en
['en', 'error', 'th']
False
create_forward_many_to_many_manager
(superclass, rel, reverse)
Create a manager for the either side of a many-to-many relation. This manager subclasses another manager, generally the default manager of the related model, and adds behaviors specific to many-to-many relations.
Create a manager for the either side of a many-to-many relation.
def create_forward_many_to_many_manager(superclass, rel, reverse): """ Create a manager for the either side of a many-to-many relation. This manager subclasses another manager, generally the default manager of the related model, and adds behaviors specific to many-to-many relations. """ class ...
[ "def", "create_forward_many_to_many_manager", "(", "superclass", ",", "rel", ",", "reverse", ")", ":", "class", "ManyRelatedManager", "(", "superclass", ")", ":", "def", "__init__", "(", "self", ",", "instance", "=", "None", ")", ":", "super", "(", "ManyRelate...
[ 780, 0 ]
[ 1150, 29 ]
python
en
['en', 'error', 'th']
False
ForwardManyToOneDescriptor.__get__
(self, instance, cls=None)
Get the related instance through the forward relation. With the example above, when getting ``child.parent``: - ``self`` is the descriptor managing the ``parent`` attribute - ``instance`` is the ``child`` instance - ``cls`` is the ``Child`` class (we don't need it)
Get the related instance through the forward relation.
def __get__(self, instance, cls=None): """ Get the related instance through the forward relation. With the example above, when getting ``child.parent``: - ``self`` is the descriptor managing the ``parent`` attribute - ``instance`` is the ``child`` instance - ``cls`` is ...
[ "def", "__get__", "(", "self", ",", "instance", ",", "cls", "=", "None", ")", ":", "if", "instance", "is", "None", ":", "return", "self", "# The related instance is loaded from the database and then cached in", "# the attribute defined in self.cache_name. It can also be pre-c...
[ 160, 4 ]
[ 196, 26 ]
python
en
['en', 'error', 'th']
False
ForwardManyToOneDescriptor.__set__
(self, instance, value)
Set the related instance through the forward relation. With the example above, when setting ``child.parent = parent``: - ``self`` is the descriptor managing the ``parent`` attribute - ``instance`` is the ``child`` instance - ``value`` is the ``parent`` instance on the right of...
Set the related instance through the forward relation.
def __set__(self, instance, value): """ Set the related instance through the forward relation. With the example above, when setting ``child.parent = parent``: - ``self`` is the descriptor managing the ``parent`` attribute - ``instance`` is the ``child`` instance - ``val...
[ "def", "__set__", "(", "self", ",", "instance", ",", "value", ")", ":", "# An object must be an instance of the related class.", "if", "value", "is", "not", "None", "and", "not", "isinstance", "(", "value", ",", "self", ".", "field", ".", "remote_field", ".", ...
[ 198, 4 ]
[ 262, 78 ]
python
en
['en', 'error', 'th']
False
ReverseOneToOneDescriptor.__get__
(self, instance, cls=None)
Get the related instance through the reverse relation. With the example above, when getting ``place.restaurant``: - ``self`` is the descriptor managing the ``restaurant`` attribute - ``instance`` is the ``place`` instance - ``cls`` is the ``Place`` class (unused) Keep...
Get the related instance through the reverse relation.
def __get__(self, instance, cls=None): """ Get the related instance through the reverse relation. With the example above, when getting ``place.restaurant``: - ``self`` is the descriptor managing the ``restaurant`` attribute - ``instance`` is the ``place`` instance - ``c...
[ "def", "__get__", "(", "self", ",", "instance", ",", "cls", "=", "None", ")", ":", "if", "instance", "is", "None", ":", "return", "self", "# The related instance is loaded from the database and then cached in", "# the attribute defined in self.cache_name. It can also be pre-c...
[ 362, 4 ]
[ 407, 26 ]
python
en
['en', 'error', 'th']
False
ReverseOneToOneDescriptor.__set__
(self, instance, value)
Set the related instance through the reverse relation. With the example above, when setting ``place.restaurant = restaurant``: - ``self`` is the descriptor managing the ``restaurant`` attribute - ``instance`` is the ``place`` instance - ``value`` is the ``restaurant`` instance...
Set the related instance through the reverse relation.
def __set__(self, instance, value): """ Set the related instance through the reverse relation. With the example above, when setting ``place.restaurant = restaurant``: - ``self`` is the descriptor managing the ``restaurant`` attribute - ``instance`` is the ``place`` instance ...
[ "def", "__set__", "(", "self", ",", "instance", ",", "value", ")", ":", "# The similarity of the code below to the code in", "# ForwardManyToOneDescriptor is annoying, but there's a bunch", "# of small differences that would make a common base class convoluted.", "if", "value", "is", ...
[ 409, 4 ]
[ 464, 73 ]
python
en
['en', 'error', 'th']
False
ReverseManyToOneDescriptor.__get__
(self, instance, cls=None)
Get the related objects through the reverse relation. With the example above, when getting ``parent.children``: - ``self`` is the descriptor managing the ``children`` attribute - ``instance`` is the ``parent`` instance - ``cls`` is the ``Parent`` class (unused)
Get the related objects through the reverse relation.
def __get__(self, instance, cls=None): """ Get the related objects through the reverse relation. With the example above, when getting ``parent.children``: - ``self`` is the descriptor managing the ``children`` attribute - ``instance`` is the ``parent`` instance - ``cls`...
[ "def", "__get__", "(", "self", ",", "instance", ",", "cls", "=", "None", ")", ":", "if", "instance", "is", "None", ":", "return", "self", "return", "self", ".", "related_manager_cls", "(", "instance", ")" ]
[ 496, 4 ]
[ 509, 49 ]
python
en
['en', 'error', 'th']
False
ReverseManyToOneDescriptor.__set__
(self, instance, value)
Set the related objects through the reverse relation. With the example above, when setting ``parent.children = children``: - ``self`` is the descriptor managing the ``children`` attribute - ``instance`` is the ``parent`` instance - ``value`` is the ``children`` sequence on the...
Set the related objects through the reverse relation.
def __set__(self, instance, value): """ Set the related objects through the reverse relation. With the example above, when setting ``parent.children = children``: - ``self`` is the descriptor managing the ``children`` attribute - ``instance`` is the ``parent`` instance ...
[ "def", "__set__", "(", "self", ",", "instance", ",", "value", ")", ":", "warnings", ".", "warn", "(", "'Direct assignment to the %s is deprecated due to the implicit '", "'save() that happens. Use %s.set() instead.'", "%", "self", ".", "_get_set_deprecation_msg_params", "(", ...
[ 517, 4 ]
[ 533, 26 ]
python
en
['en', 'error', 'th']
False
AdaMod.step
(self, closure: OptLossClosure = None)
Performs a single optimization step. Arguments: closure: A closure that reevaluates the model and returns the loss.
Performs a single optimization step.
def step(self, closure: OptLossClosure = None) -> OptFloat: """Performs a single optimization step. Arguments: closure: A closure that reevaluates the model and returns the loss. """ loss = None if closure is not None: loss = closure() for group ...
[ "def", "step", "(", "self", ",", "closure", ":", "OptLossClosure", "=", "None", ")", "->", "OptFloat", ":", "loss", "=", "None", "if", "closure", "is", "not", "None", ":", "loss", "=", "closure", "(", ")", "for", "group", "in", "self", ".", "param_gr...
[ 73, 4 ]
[ 143, 19 ]
python
en
['en', 'en', 'en']
True
contains_nan
(array)
Efficiently checks if a numpy array contains a NaN value. cf. http://stackoverflow.com/questions/6736590/fast-check-for-nan-in-numpy A NaN values may indicate a calibration error. The source finder doesn't know how to interpret a NaN value so we reject such an image. args: array: a Numpy...
Efficiently checks if a numpy array contains a NaN value.
def contains_nan(array): """ Efficiently checks if a numpy array contains a NaN value. cf. http://stackoverflow.com/questions/6736590/fast-check-for-nan-in-numpy A NaN values may indicate a calibration error. The source finder doesn't know how to interpret a NaN value so we reject such an image. ...
[ "def", "contains_nan", "(", "array", ")", ":", "# summing an array containing NaN will result in NaN", "if", "np", ".", "isnan", "(", "np", ".", "sum", "(", "array", ")", ")", ":", "return", "\"Image data contains NaN value\"", "else", ":", "return", "False" ]
[ 3, 0 ]
[ 22, 20 ]
python
en
['en', 'error', 'th']
False
JobNotificationMixin.context_stub
(cls)
Returns a stub context that can be used for validating notification messages. Context has the same structure as the context that will actually be used to render a notification message.
Returns a stub context that can be used for validating notification messages. Context has the same structure as the context that will actually be used to render a notification message.
def context_stub(cls): """Returns a stub context that can be used for validating notification messages. Context has the same structure as the context that will actually be used to render a notification message.""" context = { 'job': { 'allow_simultaneous': Fal...
[ "def", "context_stub", "(", "cls", ")", ":", "context", "=", "{", "'job'", ":", "{", "'allow_simultaneous'", ":", "False", ",", "'artifacts'", ":", "{", "}", ",", "'controller_node'", ":", "'foo_controller'", ",", "'created'", ":", "datetime", ".", "datetime...
[ 318, 4 ]
[ 416, 22 ]
python
en
['en', 'en', 'en']
True
JobNotificationMixin.context
(self, serialized_job)
Returns a dictionary that can be used for rendering notification messages. The context will contain allowed content retrieved from a serialized job object (see JobNotificationMixin.JOB_FIELDS_ALLOWED_LIST the job's friendly name, and a url to the job run.
Returns a dictionary that can be used for rendering notification messages. The context will contain allowed content retrieved from a serialized job object (see JobNotificationMixin.JOB_FIELDS_ALLOWED_LIST the job's friendly name, and a url to the job run.
def context(self, serialized_job): """Returns a dictionary that can be used for rendering notification messages. The context will contain allowed content retrieved from a serialized job object (see JobNotificationMixin.JOB_FIELDS_ALLOWED_LIST the job's friendly name, and a url to the job...
[ "def", "context", "(", "self", ",", "serialized_job", ")", ":", "job_context", "=", "{", "'host_status_counts'", ":", "{", "}", "}", "summary", "=", "None", "try", ":", "has_event_property", "=", "any", "(", "[", "f", "for", "f", "in", "self", ".", "ev...
[ 418, 4 ]
[ 461, 22 ]
python
en
['en', 'en', 'en']
True
PingdomHookTests.test_pingdom_from_up_to_down_http_check_message
(self)
Tests if pingdom http check from up to down is handled correctly
Tests if pingdom http check from up to down is handled correctly
def test_pingdom_from_up_to_down_http_check_message(self) -> None: """ Tests if pingdom http check from up to down is handled correctly """ expected_message = "Service someurl.com changed its HTTP status from UP to DOWN:\n\n``` quote\nNon-recoverable failure in name resolution\n```" ...
[ "def", "test_pingdom_from_up_to_down_http_check_message", "(", "self", ")", "->", "None", ":", "expected_message", "=", "\"Service someurl.com changed its HTTP status from UP to DOWN:\\n\\n``` quote\\nNon-recoverable failure in name resolution\\n```\"", "self", ".", "check_webhook", "(",...
[ 8, 4 ]
[ 13, 85 ]
python
en
['en', 'error', 'th']
False
PingdomHookTests.test_pingdom_from_up_to_down_smtp_check_message
(self)
Tests if pingdom smtp check from up to down is handled correctly
Tests if pingdom smtp check from up to down is handled correctly
def test_pingdom_from_up_to_down_smtp_check_message(self) -> None: """ Tests if pingdom smtp check from up to down is handled correctly """ expected_message = "Service smtp.someurl.com changed its SMTP status from UP to DOWN:\n\n``` quote\nConnection refused\n```" self.check_webh...
[ "def", "test_pingdom_from_up_to_down_smtp_check_message", "(", "self", ")", "->", "None", ":", "expected_message", "=", "\"Service smtp.someurl.com changed its SMTP status from UP to DOWN:\\n\\n``` quote\\nConnection refused\\n```\"", "self", ".", "check_webhook", "(", "\"smtp_up_to_do...
[ 15, 4 ]
[ 20, 85 ]
python
en
['en', 'error', 'th']
False
PingdomHookTests.test_pingdom_from_up_to_down_imap_check_message
(self)
Tests if pingdom imap check from up to down is handled correctly
Tests if pingdom imap check from up to down is handled correctly
def test_pingdom_from_up_to_down_imap_check_message(self) -> None: """ Tests if pingdom imap check from up to down is handled correctly """ expected_message = "Service imap.someurl.com changed its IMAP status from UP to DOWN:\n\n``` quote\nInvalid hostname, address or socket\n```" ...
[ "def", "test_pingdom_from_up_to_down_imap_check_message", "(", "self", ")", "->", "None", ":", "expected_message", "=", "\"Service imap.someurl.com changed its IMAP status from UP to DOWN:\\n\\n``` quote\\nInvalid hostname, address or socket\\n```\"", "self", ".", "check_webhook", "(", ...
[ 22, 4 ]
[ 27, 85 ]
python
en
['en', 'error', 'th']
False
PingdomHookTests.test_pingdom_from_down_to_up_imap_check_message
(self)
Tests if pingdom imap check from down to up is handled correctly
Tests if pingdom imap check from down to up is handled correctly
def test_pingdom_from_down_to_up_imap_check_message(self) -> None: """ Tests if pingdom imap check from down to up is handled correctly """ expected_message = "Service imap.someurl.com changed its IMAP status from DOWN to UP." self.check_webhook("imap_down_to_up", "IMAP check sta...
[ "def", "test_pingdom_from_down_to_up_imap_check_message", "(", "self", ")", "->", "None", ":", "expected_message", "=", "\"Service imap.someurl.com changed its IMAP status from DOWN to UP.\"", "self", ".", "check_webhook", "(", "\"imap_down_to_up\"", ",", "\"IMAP check status.\"", ...
[ 29, 4 ]
[ 34, 85 ]
python
en
['en', 'error', 'th']
False
copy_exception
(exc, backend=None)
Create a new TemplateDoesNotExist. Preserve its declared attributes and template debug data but discard __traceback__, __context__, and __cause__ to make this object suitable for keeping around (in a cache, for example).
Create a new TemplateDoesNotExist. Preserve its declared attributes and template debug data but discard __traceback__, __context__, and __cause__ to make this object suitable for keeping around (in a cache, for example).
def copy_exception(exc, backend=None): """ Create a new TemplateDoesNotExist. Preserve its declared attributes and template debug data but discard __traceback__, __context__, and __cause__ to make this object suitable for keeping around (in a cache, for example). """ backend = backend or exc.bac...
[ "def", "copy_exception", "(", "exc", ",", "backend", "=", "None", ")", ":", "backend", "=", "backend", "or", "exc", ".", "backend", "new", "=", "exc", ".", "__class__", "(", "*", "exc", ".", "args", ",", "tried", "=", "exc", ".", "tried", ",", "bac...
[ 70, 0 ]
[ 80, 14 ]
python
en
['en', 'error', 'th']
False
reraise
(exc, backend)
Reraise TemplateDoesNotExist while maintaining template debug information.
Reraise TemplateDoesNotExist while maintaining template debug information.
def reraise(exc, backend): """ Reraise TemplateDoesNotExist while maintaining template debug information. """ new = copy_exception(exc, backend) six.reraise(exc.__class__, new, sys.exc_info()[2])
[ "def", "reraise", "(", "exc", ",", "backend", ")", ":", "new", "=", "copy_exception", "(", "exc", ",", "backend", ")", "six", ".", "reraise", "(", "exc", ".", "__class__", ",", "new", ",", "sys", ".", "exc_info", "(", ")", "[", "2", "]", ")" ]
[ 83, 0 ]
[ 88, 54 ]
python
en
['en', 'error', 'th']
False
get_installed_libraries
()
Return the built-in template tag libraries and those from installed applications. Libraries are stored in a dictionary where keys are the individual module names, not the full module paths. Example: django.templatetags.i18n is stored as i18n.
Return the built-in template tag libraries and those from installed applications. Libraries are stored in a dictionary where keys are the individual module names, not the full module paths. Example: django.templatetags.i18n is stored as i18n.
def get_installed_libraries(): """ Return the built-in template tag libraries and those from installed applications. Libraries are stored in a dictionary where keys are the individual module names, not the full module paths. Example: django.templatetags.i18n is stored as i18n. """ libraries ...
[ "def", "get_installed_libraries", "(", ")", ":", "libraries", "=", "{", "}", "candidates", "=", "[", "'django.templatetags'", "]", "candidates", ".", "extend", "(", "'%s.templatetags'", "%", "app_config", ".", "name", "for", "app_config", "in", "apps", ".", "g...
[ 91, 0 ]
[ 115, 20 ]
python
en
['en', 'error', 'th']
False
get_package_libraries
(pkg)
Recursively yield template tag libraries defined in submodules of a package.
Recursively yield template tag libraries defined in submodules of a package.
def get_package_libraries(pkg): """ Recursively yield template tag libraries defined in submodules of a package. """ for entry in walk_packages(pkg.__path__, pkg.__name__ + '.'): try: module = import_module(entry[1]) except ImportError as e: raise InvalidTempl...
[ "def", "get_package_libraries", "(", "pkg", ")", ":", "for", "entry", "in", "walk_packages", "(", "pkg", ".", "__path__", ",", "pkg", ".", "__name__", "+", "'.'", ")", ":", "try", ":", "module", "=", "import_module", "(", "entry", "[", "1", "]", ")", ...
[ 118, 0 ]
[ 133, 26 ]
python
en
['en', 'error', 'th']
False
DjangoTemplates.get_templatetag_libraries
(self, custom_libraries)
Return a collation of template tag libraries from installed applications and the supplied custom_libraries argument.
Return a collation of template tag libraries from installed applications and the supplied custom_libraries argument.
def get_templatetag_libraries(self, custom_libraries): """ Return a collation of template tag libraries from installed applications and the supplied custom_libraries argument. """ libraries = get_installed_libraries() libraries.update(custom_libraries) return libr...
[ "def", "get_templatetag_libraries", "(", "self", ",", "custom_libraries", ")", ":", "libraries", "=", "get_installed_libraries", "(", ")", "libraries", ".", "update", "(", "custom_libraries", ")", "return", "libraries" ]
[ 42, 4 ]
[ 49, 24 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseSchemaEditor.execute
(self, sql, params=())
Executes the given SQL statement, with optional parameters.
Executes the given SQL statement, with optional parameters.
def execute(self, sql, params=()): """ Executes the given SQL statement, with optional parameters. """ # Don't perform the transactional DDL check if SQL is being collected # as it's not going to be executed anyway. if not self.collect_sql and self.connection.in_atomic_bl...
[ "def", "execute", "(", "self", ",", "sql", ",", "params", "=", "(", ")", ")", ":", "# Don't perform the transactional DDL check if SQL is being collected", "# as it's not going to be executed anyway.", "if", "not", "self", ".", "collect_sql", "and", "self", ".", "connec...
[ 97, 4 ]
[ 118, 43 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseSchemaEditor._digest
(cls, *args)
Generates a 32-bit digest of a set of arguments that can be used to shorten identifying names.
Generates a 32-bit digest of a set of arguments that can be used to shorten identifying names.
def _digest(cls, *args): """ Generates a 32-bit digest of a set of arguments that can be used to shorten identifying names. """ h = hashlib.md5() for arg in args: h.update(force_bytes(arg)) return h.hexdigest()[:8]
[ "def", "_digest", "(", "cls", ",", "*", "args", ")", ":", "h", "=", "hashlib", ".", "md5", "(", ")", "for", "arg", "in", "args", ":", "h", ".", "update", "(", "force_bytes", "(", "arg", ")", ")", "return", "h", ".", "hexdigest", "(", ")", "[", ...
[ 124, 4 ]
[ 132, 32 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseSchemaEditor.column_sql
(self, model, field, include_default=False)
Takes a field and returns its column definition. The field must already have had set_attributes_from_name called.
Takes a field and returns its column definition. The field must already have had set_attributes_from_name called.
def column_sql(self, model, field, include_default=False): """ Takes a field and returns its column definition. The field must already have had set_attributes_from_name called. """ # Get the column's type and use that as the basis of the SQL db_params = field.db_parameter...
[ "def", "column_sql", "(", "self", ",", "model", ",", "field", ",", "include_default", "=", "False", ")", ":", "# Get the column's type and use that as the basis of the SQL", "db_params", "=", "field", ".", "db_parameters", "(", "connection", "=", "self", ".", "conne...
[ 136, 4 ]
[ 182, 26 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseSchemaEditor.skip_default
(self, field)
Some backends don't accept default values for certain columns types (i.e. MySQL longtext and longblob).
Some backends don't accept default values for certain columns types (i.e. MySQL longtext and longblob).
def skip_default(self, field): """ Some backends don't accept default values for certain columns types (i.e. MySQL longtext and longblob). """ return False
[ "def", "skip_default", "(", "self", ",", "field", ")", ":", "return", "False" ]
[ 184, 4 ]
[ 189, 20 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseSchemaEditor.prepare_default
(self, value)
Only used for backends which have requires_literal_defaults feature
Only used for backends which have requires_literal_defaults feature
def prepare_default(self, value): """ Only used for backends which have requires_literal_defaults feature """ raise NotImplementedError( 'subclasses of BaseDatabaseSchemaEditor for backends which have ' 'requires_literal_defaults must provide a prepare_default() m...
[ "def", "prepare_default", "(", "self", ",", "value", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of BaseDatabaseSchemaEditor for backends which have '", "'requires_literal_defaults must provide a prepare_default() method'", ")" ]
[ 191, 4 ]
[ 198, 9 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseSchemaEditor.effective_default
(self, field)
Returns a field's effective database default value
Returns a field's effective database default value
def effective_default(self, field): """ Returns a field's effective database default value """ if field.has_default(): default = field.get_default() elif not field.null and field.blank and field.empty_strings_allowed: if field.get_internal_type() == "Binar...
[ "def", "effective_default", "(", "self", ",", "field", ")", ":", "if", "field", ".", "has_default", "(", ")", ":", "default", "=", "field", ".", "get_default", "(", ")", "elif", "not", "field", ".", "null", "and", "field", ".", "blank", "and", "field",...
[ 200, 4 ]
[ 228, 22 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseSchemaEditor.quote_value
(self, value)
Returns a quoted version of the value so it's safe to use in an SQL string. This is not safe against injection from user code; it is intended only for use in making SQL scripts or preparing default values for particularly tricky backends (defaults are not user-defined, though, s...
Returns a quoted version of the value so it's safe to use in an SQL string. This is not safe against injection from user code; it is intended only for use in making SQL scripts or preparing default values for particularly tricky backends (defaults are not user-defined, though, s...
def quote_value(self, value): """ Returns a quoted version of the value so it's safe to use in an SQL string. This is not safe against injection from user code; it is intended only for use in making SQL scripts or preparing default values for particularly tricky backends (default...
[ "def", "quote_value", "(", "self", ",", "value", ")", ":", "raise", "NotImplementedError", "(", ")" ]
[ 230, 4 ]
[ 238, 35 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseSchemaEditor.create_model
(self, model)
Takes a model and creates a table for it in the database. Will also create any accompanying indexes or unique constraints.
Takes a model and creates a table for it in the database. Will also create any accompanying indexes or unique constraints.
def create_model(self, model): """ Takes a model and creates a table for it in the database. Will also create any accompanying indexes or unique constraints. """ # Create column SQL, add FK deferreds if needed column_sqls = [] params = [] for field in mode...
[ "def", "create_model", "(", "self", ",", "model", ")", ":", "# Create column SQL, add FK deferreds if needed", "column_sqls", "=", "[", "]", "params", "=", "[", "]", "for", "field", "in", "model", ".", "_meta", ".", "local_fields", ":", "# SQL", "definition", ...
[ 242, 4 ]
[ 309, 61 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseSchemaEditor.delete_model
(self, model)
Deletes a model from the database.
Deletes a model from the database.
def delete_model(self, model): """ Deletes a model from the database. """ # Handle auto-created intermediary models for field in model._meta.local_many_to_many: if field.remote_field.through._meta.auto_created: self.delete_model(field.remote_field.thro...
[ "def", "delete_model", "(", "self", ",", "model", ")", ":", "# Handle auto-created intermediary models", "for", "field", "in", "model", ".", "_meta", ".", "local_many_to_many", ":", "if", "field", ".", "remote_field", ".", "through", ".", "_meta", ".", "auto_cre...
[ 311, 4 ]
[ 323, 10 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseSchemaEditor.add_index
(self, model, index)
Add an index on a model.
Add an index on a model.
def add_index(self, model, index): """ Add an index on a model. """ self.execute(index.create_sql(model, self))
[ "def", "add_index", "(", "self", ",", "model", ",", "index", ")", ":", "self", ".", "execute", "(", "index", ".", "create_sql", "(", "model", ",", "self", ")", ")" ]
[ 325, 4 ]
[ 329, 51 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseSchemaEditor.remove_index
(self, model, index)
Remove an index from a model.
Remove an index from a model.
def remove_index(self, model, index): """ Remove an index from a model. """ self.execute(index.remove_sql(model, self))
[ "def", "remove_index", "(", "self", ",", "model", ",", "index", ")", ":", "self", ".", "execute", "(", "index", ".", "remove_sql", "(", "model", ",", "self", ")", ")" ]
[ 331, 4 ]
[ 335, 51 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseSchemaEditor.alter_unique_together
(self, model, old_unique_together, new_unique_together)
Deals with a model changing its unique_together. Note: The input unique_togethers must be doubly-nested, not the single- nested ["foo", "bar"] format.
Deals with a model changing its unique_together. Note: The input unique_togethers must be doubly-nested, not the single- nested ["foo", "bar"] format.
def alter_unique_together(self, model, old_unique_together, new_unique_together): """ Deals with a model changing its unique_together. Note: The input unique_togethers must be doubly-nested, not the single- nested ["foo", "bar"] format. """ olds = set(tuple(fields) for fi...
[ "def", "alter_unique_together", "(", "self", ",", "model", ",", "old_unique_together", ",", "new_unique_together", ")", ":", "olds", "=", "set", "(", "tuple", "(", "fields", ")", "for", "fields", "in", "old_unique_together", ")", "news", "=", "set", "(", "tu...
[ 337, 4 ]
[ 351, 65 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseSchemaEditor.alter_index_together
(self, model, old_index_together, new_index_together)
Deals with a model changing its index_together. Note: The input index_togethers must be doubly-nested, not the single- nested ["foo", "bar"] format.
Deals with a model changing its index_together. Note: The input index_togethers must be doubly-nested, not the single- nested ["foo", "bar"] format.
def alter_index_together(self, model, old_index_together, new_index_together): """ Deals with a model changing its index_together. Note: The input index_togethers must be doubly-nested, not the single- nested ["foo", "bar"] format. """ olds = set(tuple(fields) for fields ...
[ "def", "alter_index_together", "(", "self", ",", "model", ",", "old_index_together", ",", "new_index_together", ")", ":", "olds", "=", "set", "(", "tuple", "(", "fields", ")", "for", "fields", "in", "old_index_together", ")", "news", "=", "set", "(", "tuple"...
[ 353, 4 ]
[ 367, 78 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseSchemaEditor.alter_db_table
(self, model, old_db_table, new_db_table)
Renames the table a model points to.
Renames the table a model points to.
def alter_db_table(self, model, old_db_table, new_db_table): """ Renames the table a model points to. """ if (old_db_table == new_db_table or (self.connection.features.ignores_table_name_case and old_db_table.lower() == new_db_table.lower())): retu...
[ "def", "alter_db_table", "(", "self", ",", "model", ",", "old_db_table", ",", "new_db_table", ")", ":", "if", "(", "old_db_table", "==", "new_db_table", "or", "(", "self", ".", "connection", ".", "features", ".", "ignores_table_name_case", "and", "old_db_table",...
[ 380, 4 ]
[ 391, 10 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseSchemaEditor.alter_db_tablespace
(self, model, old_db_tablespace, new_db_tablespace)
Moves a model's table between tablespaces
Moves a model's table between tablespaces
def alter_db_tablespace(self, model, old_db_tablespace, new_db_tablespace): """ Moves a model's table between tablespaces """ self.execute(self.sql_retablespace_table % { "table": self.quote_name(model._meta.db_table), "old_tablespace": self.quote_name(old_db_tabl...
[ "def", "alter_db_tablespace", "(", "self", ",", "model", ",", "old_db_tablespace", ",", "new_db_tablespace", ")", ":", "self", ".", "execute", "(", "self", ".", "sql_retablespace_table", "%", "{", "\"table\"", ":", "self", ".", "quote_name", "(", "model", ".",...
[ 393, 4 ]
[ 401, 10 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseSchemaEditor.add_field
(self, model, field)
Creates a field on a model. Usually involves adding a column, but may involve adding a table instead (for M2M fields)
Creates a field on a model. Usually involves adding a column, but may involve adding a table instead (for M2M fields)
def add_field(self, model, field): """ Creates a field on a model. Usually involves adding a column, but may involve adding a table instead (for M2M fields) """ # Special-case implicit M2M tables if field.many_to_many and field.remote_field.through._meta.auto_crea...
[ "def", "add_field", "(", "self", ",", "model", ",", "field", ")", ":", "# Special-case implicit M2M tables", "if", "field", ".", "many_to_many", "and", "field", ".", "remote_field", ".", "through", ".", "_meta", ".", "auto_created", ":", "return", "self", ".",...
[ 403, 4 ]
[ 445, 35 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseSchemaEditor.remove_field
(self, model, field)
Removes a field from a model. Usually involves deleting a column, but for M2Ms may involve deleting a table.
Removes a field from a model. Usually involves deleting a column, but for M2Ms may involve deleting a table.
def remove_field(self, model, field): """ Removes a field from a model. Usually involves deleting a column, but for M2Ms may involve deleting a table. """ # Special-case implicit M2M tables if field.many_to_many and field.remote_field.through._meta.auto_created: ...
[ "def", "remove_field", "(", "self", ",", "model", ",", "field", ")", ":", "# Special-case implicit M2M tables", "if", "field", ".", "many_to_many", "and", "field", ".", "remote_field", ".", "through", ".", "_meta", ".", "auto_created", ":", "return", "self", "...
[ 447, 4 ]
[ 471, 35 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseSchemaEditor.alter_field
(self, model, old_field, new_field, strict=False)
Allows a field's type, uniqueness, nullability, default, column, constraints etc. to be modified. Requires a copy of the old field as well so we can only perform changes that are required. If strict is true, raises errors if the old column does not match old_field precisely. ...
Allows a field's type, uniqueness, nullability, default, column, constraints etc. to be modified. Requires a copy of the old field as well so we can only perform changes that are required. If strict is true, raises errors if the old column does not match old_field precisely. ...
def alter_field(self, model, old_field, new_field, strict=False): """ Allows a field's type, uniqueness, nullability, default, column, constraints etc. to be modified. Requires a copy of the old field as well so we can only perform changes that are required. If strict is ...
[ "def", "alter_field", "(", "self", ",", "model", ",", "old_field", ",", "new_field", ",", "strict", "=", "False", ")", ":", "# Ensure this field is even column-based", "old_db_params", "=", "old_field", ".", "db_parameters", "(", "connection", "=", "self", ".", ...
[ 473, 4 ]
[ 512, 63 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseSchemaEditor._alter_field
(self, model, old_field, new_field, old_type, new_type, old_db_params, new_db_params, strict=False)
Actually perform a "physical" (non-ManyToMany) field update.
Actually perform a "physical" (non-ManyToMany) field update.
def _alter_field(self, model, old_field, new_field, old_type, new_type, old_db_params, new_db_params, strict=False): """Actually perform a "physical" (non-ManyToMany) field update.""" # Drop any FK constraints, we'll remake them later fks_dropped = set() if old_fiel...
[ "def", "_alter_field", "(", "self", ",", "model", ",", "old_field", ",", "new_field", ",", "old_type", ",", "new_type", ",", "old_db_params", ",", "new_db_params", ",", "strict", "=", "False", ")", ":", "# Drop any FK constraints, we'll remake them later", "fks_drop...
[ 514, 4 ]
[ 791, 35 ]
python
en
['en', 'en', 'en']
True
BaseDatabaseSchemaEditor._alter_column_type_sql
(self, table, old_field, new_field, new_type)
Hook to specialize column type alteration for different backends, for cases when a creation type is different to an alteration type (e.g. SERIAL in PostgreSQL, PostGIS fields). Should return two things; an SQL fragment of (sql, params) to insert into an ALTER TABLE statement, a...
Hook to specialize column type alteration for different backends, for cases when a creation type is different to an alteration type (e.g. SERIAL in PostgreSQL, PostGIS fields).
def _alter_column_type_sql(self, table, old_field, new_field, new_type): """ Hook to specialize column type alteration for different backends, for cases when a creation type is different to an alteration type (e.g. SERIAL in PostgreSQL, PostGIS fields). Should return two things;...
[ "def", "_alter_column_type_sql", "(", "self", ",", "table", ",", "old_field", ",", "new_field", ",", "new_type", ")", ":", "return", "(", "(", "self", ".", "sql_alter_column_type", "%", "{", "\"column\"", ":", "self", ".", "quote_name", "(", "new_field", "."...
[ 793, 4 ]
[ 812, 9 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseSchemaEditor._alter_many_to_many
(self, model, old_field, new_field, strict)
Alters M2Ms to repoint their to= endpoints.
Alters M2Ms to repoint their to= endpoints.
def _alter_many_to_many(self, model, old_field, new_field, strict): """ Alters M2Ms to repoint their to= endpoints. """ # Rename the through table if old_field.remote_field.through._meta.db_table != new_field.remote_field.through._meta.db_table: self.alter_db_table(ol...
[ "def", "_alter_many_to_many", "(", "self", ",", "model", ",", "old_field", ",", "new_field", ",", "strict", ")", ":", "# Rename the through table", "if", "old_field", ".", "remote_field", ".", "through", ".", "_meta", ".", "db_table", "!=", "new_field", ".", "...
[ 814, 4 ]
[ 835, 9 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseSchemaEditor._create_index_name
(self, model, column_names, suffix="")
Generates a unique name for an index/unique constraint. The name is divided into 3 parts: the table name, the column names, and a unique digest and suffix.
Generates a unique name for an index/unique constraint.
def _create_index_name(self, model, column_names, suffix=""): """ Generates a unique name for an index/unique constraint. The name is divided into 3 parts: the table name, the column names, and a unique digest and suffix. """ table_name = strip_quotes(model._meta.db_tabl...
[ "def", "_create_index_name", "(", "self", ",", "model", ",", "column_names", ",", "suffix", "=", "\"\"", ")", ":", "table_name", "=", "strip_quotes", "(", "model", ".", "_meta", ".", "db_table", ")", "hash_data", "=", "[", "table_name", "]", "+", "list", ...
[ 837, 4 ]
[ 865, 25 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseSchemaEditor._create_index_sql
(self, model, fields, suffix="", sql=None)
Return the SQL statement to create the index for one or several fields. `sql` can be specified if the syntax differs from the standard (GIS indexes, ...).
Return the SQL statement to create the index for one or several fields. `sql` can be specified if the syntax differs from the standard (GIS indexes, ...).
def _create_index_sql(self, model, fields, suffix="", sql=None): """ Return the SQL statement to create the index for one or several fields. `sql` can be specified if the syntax differs from the standard (GIS indexes, ...). """ tablespace_sql = self._get_index_tablespace_...
[ "def", "_create_index_sql", "(", "self", ",", "model", ",", "fields", ",", "suffix", "=", "\"\"", ",", "sql", "=", "None", ")", ":", "tablespace_sql", "=", "self", ".", "_get_index_tablespace_sql", "(", "model", ",", "fields", ")", "columns", "=", "[", "...
[ 878, 4 ]
[ 893, 9 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseSchemaEditor._model_indexes_sql
(self, model)
Return all index SQL statements (field indexes, index_together, Meta.indexes) for the specified model, as a list.
Return all index SQL statements (field indexes, index_together, Meta.indexes) for the specified model, as a list.
def _model_indexes_sql(self, model): """ Return all index SQL statements (field indexes, index_together, Meta.indexes) for the specified model, as a list. """ if not model._meta.managed or model._meta.proxy or model._meta.swapped: return [] output = [] ...
[ "def", "_model_indexes_sql", "(", "self", ",", "model", ")", ":", "if", "not", "model", ".", "_meta", ".", "managed", "or", "model", ".", "_meta", ".", "proxy", "or", "model", ".", "_meta", ".", "swapped", ":", "return", "[", "]", "output", "=", "[",...
[ 895, 4 ]
[ 912, 21 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseSchemaEditor._field_indexes_sql
(self, model, field)
Return a list of all index SQL statements for the specified field.
Return a list of all index SQL statements for the specified field.
def _field_indexes_sql(self, model, field): """ Return a list of all index SQL statements for the specified field. """ output = [] if self._field_should_be_indexed(model, field): output.append(self._create_index_sql(model, [field])) return output
[ "def", "_field_indexes_sql", "(", "self", ",", "model", ",", "field", ")", ":", "output", "=", "[", "]", "if", "self", ".", "_field_should_be_indexed", "(", "model", ",", "field", ")", ":", "output", ".", "append", "(", "self", ".", "_create_index_sql", ...
[ 914, 4 ]
[ 921, 21 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseSchemaEditor._constraint_names
(self, model, column_names=None, unique=None, primary_key=None, index=None, foreign_key=None, check=None)
Returns all constraint names matching the columns and conditions
Returns all constraint names matching the columns and conditions
def _constraint_names(self, model, column_names=None, unique=None, primary_key=None, index=None, foreign_key=None, check=None): """ Returns all constraint names matching the columns and conditions """ if column_names is not None: ...
[ "def", "_constraint_names", "(", "self", ",", "model", ",", "column_names", "=", "None", ",", "unique", "=", "None", ",", "primary_key", "=", "None", ",", "index", "=", "None", ",", "foreign_key", "=", "None", ",", "check", "=", "None", ")", ":", "if",...
[ 966, 4 ]
[ 993, 21 ]
python
en
['en', 'error', 'th']
False
distribution
(distribution_name)
Get the ``Distribution`` instance for the named package. :param distribution_name: The name of the distribution package as a string. :return: A ``Distribution`` instance (or subclass thereof).
Get the ``Distribution`` instance for the named package.
def distribution(distribution_name): """Get the ``Distribution`` instance for the named package. :param distribution_name: The name of the distribution package as a string. :return: A ``Distribution`` instance (or subclass thereof). """ return Distribution.from_name(distribution_name)
[ "def", "distribution", "(", "distribution_name", ")", ":", "return", "Distribution", ".", "from_name", "(", "distribution_name", ")" ]
[ 551, 0 ]
[ 557, 52 ]
python
en
['en', 'en', 'en']
True
distributions
(**kwargs)
Get all ``Distribution`` instances in the current environment. :return: An iterable of ``Distribution`` instances.
Get all ``Distribution`` instances in the current environment.
def distributions(**kwargs): """Get all ``Distribution`` instances in the current environment. :return: An iterable of ``Distribution`` instances. """ return Distribution.discover(**kwargs)
[ "def", "distributions", "(", "*", "*", "kwargs", ")", ":", "return", "Distribution", ".", "discover", "(", "*", "*", "kwargs", ")" ]
[ 560, 0 ]
[ 565, 42 ]
python
en
['en', 'en', 'en']
True
metadata
(distribution_name)
Get the metadata for the named package. :param distribution_name: The name of the distribution package to query. :return: An email.Message containing the parsed metadata.
Get the metadata for the named package.
def metadata(distribution_name): """Get the metadata for the named package. :param distribution_name: The name of the distribution package to query. :return: An email.Message containing the parsed metadata. """ return Distribution.from_name(distribution_name).metadata
[ "def", "metadata", "(", "distribution_name", ")", ":", "return", "Distribution", ".", "from_name", "(", "distribution_name", ")", ".", "metadata" ]
[ 568, 0 ]
[ 574, 61 ]
python
en
['en', 'en', 'en']
True
version
(distribution_name)
Get the version string for the named package. :param distribution_name: The name of the distribution package to query. :return: The version string for the package as defined in the package's "Version" metadata key.
Get the version string for the named package.
def version(distribution_name): """Get the version string for the named package. :param distribution_name: The name of the distribution package to query. :return: The version string for the package as defined in the package's "Version" metadata key. """ return distribution(distribution_name...
[ "def", "version", "(", "distribution_name", ")", ":", "return", "distribution", "(", "distribution_name", ")", ".", "version" ]
[ 577, 0 ]
[ 584, 50 ]
python
en
['en', 'en', 'en']
True
entry_points
()
Return EntryPoint objects for all installed packages. :return: EntryPoint objects for all installed packages.
Return EntryPoint objects for all installed packages.
def entry_points(): """Return EntryPoint objects for all installed packages. :return: EntryPoint objects for all installed packages. """ eps = itertools.chain.from_iterable( dist.entry_points for dist in distributions()) by_group = operator.attrgetter('group') ordered = sorted(eps, key=...
[ "def", "entry_points", "(", ")", ":", "eps", "=", "itertools", ".", "chain", ".", "from_iterable", "(", "dist", ".", "entry_points", "for", "dist", "in", "distributions", "(", ")", ")", "by_group", "=", "operator", ".", "attrgetter", "(", "'group'", ")", ...
[ 587, 0 ]
[ 600, 9 ]
python
en
['en', 'en', 'en']
True
files
(distribution_name)
Return a list of files for the named package. :param distribution_name: The name of the distribution package to query. :return: List of files composing the distribution.
Return a list of files for the named package.
def files(distribution_name): """Return a list of files for the named package. :param distribution_name: The name of the distribution package to query. :return: List of files composing the distribution. """ return distribution(distribution_name).files
[ "def", "files", "(", "distribution_name", ")", ":", "return", "distribution", "(", "distribution_name", ")", ".", "files" ]
[ 603, 0 ]
[ 609, 48 ]
python
en
['en', 'en', 'en']
True
requires
(distribution_name)
Return a list of requirements for the named package. :return: An iterator of requirements, suitable for packaging.requirement.Requirement.
Return a list of requirements for the named package.
def requires(distribution_name): """ Return a list of requirements for the named package. :return: An iterator of requirements, suitable for packaging.requirement.Requirement. """ return distribution(distribution_name).requires
[ "def", "requires", "(", "distribution_name", ")", ":", "return", "distribution", "(", "distribution_name", ")", ".", "requires" ]
[ 612, 0 ]
[ 619, 51 ]
python
en
['en', 'error', 'th']
False
EntryPoint.load
(self)
Load the entry point from its definition. If only a module is indicated by the value, return that module. Otherwise, return the named object.
Load the entry point from its definition. If only a module is indicated by the value, return that module. Otherwise, return the named object.
def load(self): """Load the entry point from its definition. If only a module is indicated by the value, return that module. Otherwise, return the named object. """ match = self.pattern.match(self.value) module = import_module(match.group('module')) attrs = filter...
[ "def", "load", "(", "self", ")", ":", "match", "=", "self", ".", "pattern", ".", "match", "(", "self", ".", "value", ")", "module", "=", "import_module", "(", "match", ".", "group", "(", "'module'", ")", ")", "attrs", "=", "filter", "(", "None", ",...
[ 98, 4 ]
[ 106, 55 ]
python
en
['en', 'en', 'en']
True
EntryPoint.__iter__
(self)
Supply iter so one may construct dicts of EntryPoints easily.
Supply iter so one may construct dicts of EntryPoints easily.
def __iter__(self): """ Supply iter so one may construct dicts of EntryPoints easily. """ return iter((self.name, self))
[ "def", "__iter__", "(", "self", ")", ":", "return", "iter", "(", "(", "self", ".", "name", ",", "self", ")", ")" ]
[ 143, 4 ]
[ 147, 38 ]
python
en
['en', 'error', 'th']
False
PackagePath.locate
(self)
Return a path-like object for this path
Return a path-like object for this path
def locate(self): """Return a path-like object for this path""" return self.dist.locate_file(self)
[ "def", "locate", "(", "self", ")", ":", "return", "self", ".", "dist", ".", "locate_file", "(", "self", ")" ]
[ 167, 4 ]
[ 169, 42 ]
python
en
['en', 'en', 'en']
True
Distribution.read_text
(self, filename)
Attempt to load metadata file given by the name. :param filename: The name of the file in the distribution info. :return: The text if found, otherwise None.
Attempt to load metadata file given by the name.
def read_text(self, filename): """Attempt to load metadata file given by the name. :param filename: The name of the file in the distribution info. :return: The text if found, otherwise None. """
[ "def", "read_text", "(", "self", ",", "filename", ")", ":" ]
[ 184, 4 ]
[ 189, 11 ]
python
en
['en', 'en', 'en']
True
Distribution.locate_file
(self, path)
Given a path to a file in this distribution, return a path to it.
Given a path to a file in this distribution, return a path to it.
def locate_file(self, path): """ Given a path to a file in this distribution, return a path to it. """
[ "def", "locate_file", "(", "self", ",", "path", ")", ":" ]
[ 192, 4 ]
[ 196, 11 ]
python
en
['en', 'error', 'th']
False
Distribution.from_name
(cls, name)
Return the Distribution for the given package name. :param name: The name of the distribution package to search for. :return: The Distribution instance (or subclass thereof) for the named package, if found. :raises PackageNotFoundError: When the named package's distribution ...
Return the Distribution for the given package name.
def from_name(cls, name): """Return the Distribution for the given package name. :param name: The name of the distribution package to search for. :return: The Distribution instance (or subclass thereof) for the named package, if found. :raises PackageNotFoundError: When the ...
[ "def", "from_name", "(", "cls", ",", "name", ")", ":", "for", "resolver", "in", "cls", ".", "_discover_resolvers", "(", ")", ":", "dists", "=", "resolver", "(", "DistributionFinder", ".", "Context", "(", "name", "=", "name", ")", ")", "dist", "=", "nex...
[ 199, 4 ]
[ 214, 44 ]
python
en
['en', 'en', 'en']
True
Distribution.discover
(cls, **kwargs)
Return an iterable of Distribution objects for all packages. Pass a ``context`` or pass keyword arguments for constructing a context. :context: A ``DistributionFinder.Context`` object. :return: Iterable of Distribution objects for all packages.
Return an iterable of Distribution objects for all packages.
def discover(cls, **kwargs): """Return an iterable of Distribution objects for all packages. Pass a ``context`` or pass keyword arguments for constructing a context. :context: A ``DistributionFinder.Context`` object. :return: Iterable of Distribution objects for all packages. ...
[ "def", "discover", "(", "cls", ",", "*", "*", "kwargs", ")", ":", "context", "=", "kwargs", ".", "pop", "(", "'context'", ",", "None", ")", "if", "context", "and", "kwargs", ":", "raise", "ValueError", "(", "\"cannot accept context and kwargs\"", ")", "con...
[ 217, 4 ]
[ 233, 13 ]
python
en
['en', 'en', 'en']
True
Distribution.at
(path)
Return a Distribution for the indicated metadata path :param path: a string or path-like object :return: a concrete Distribution instance for the path
Return a Distribution for the indicated metadata path
def at(path): """Return a Distribution for the indicated metadata path :param path: a string or path-like object :return: a concrete Distribution instance for the path """ return PathDistribution(pathlib.Path(path))
[ "def", "at", "(", "path", ")", ":", "return", "PathDistribution", "(", "pathlib", ".", "Path", "(", "path", ")", ")" ]
[ 236, 4 ]
[ 242, 51 ]
python
en
['en', 'en', 'en']
True
Distribution._discover_resolvers
()
Search the meta_path for resolvers.
Search the meta_path for resolvers.
def _discover_resolvers(): """Search the meta_path for resolvers.""" declared = ( getattr(finder, 'find_distributions', None) for finder in sys.meta_path ) return filter(None, declared)
[ "def", "_discover_resolvers", "(", ")", ":", "declared", "=", "(", "getattr", "(", "finder", ",", "'find_distributions'", ",", "None", ")", "for", "finder", "in", "sys", ".", "meta_path", ")", "return", "filter", "(", "None", ",", "declared", ")" ]
[ 245, 4 ]
[ 251, 37 ]
python
en
['en', 'en', 'en']
True
Distribution.metadata
(self)
Return the parsed metadata for this Distribution. The returned object will have keys that name the various bits of metadata. See PEP 566 for details.
Return the parsed metadata for this Distribution.
def metadata(self): """Return the parsed metadata for this Distribution. The returned object will have keys that name the various bits of metadata. See PEP 566 for details. """ text = ( self.read_text('METADATA') or self.read_text('PKG-INFO') ...
[ "def", "metadata", "(", "self", ")", ":", "text", "=", "(", "self", ".", "read_text", "(", "'METADATA'", ")", "or", "self", ".", "read_text", "(", "'PKG-INFO'", ")", "# This last clause is here to support old egg-info files. Its", "# effect is to just end up using the ...
[ 265, 4 ]
[ 279, 46 ]
python
en
['en', 'en', 'en']
True
Distribution.version
(self)
Return the 'Version' metadata for the distribution package.
Return the 'Version' metadata for the distribution package.
def version(self): """Return the 'Version' metadata for the distribution package.""" return self.metadata['Version']
[ "def", "version", "(", "self", ")", ":", "return", "self", ".", "metadata", "[", "'Version'", "]" ]
[ 282, 4 ]
[ 284, 39 ]
python
en
['en', 'en', 'en']
True
Distribution.files
(self)
Files in this distribution. :return: List of PackagePath for this distribution or None Result is `None` if the metadata file that enumerates files (i.e. RECORD for dist-info or SOURCES.txt for egg-info) is missing. Result may be empty if the metadata exists but is empty. ...
Files in this distribution.
def files(self): """Files in this distribution. :return: List of PackagePath for this distribution or None Result is `None` if the metadata file that enumerates files (i.e. RECORD for dist-info or SOURCES.txt for egg-info) is missing. Result may be empty if the metadata...
[ "def", "files", "(", "self", ")", ":", "file_lines", "=", "self", ".", "_read_files_distinfo", "(", ")", "or", "self", ".", "_read_files_egginfo", "(", ")", "def", "make_file", "(", "name", ",", "hash", "=", "None", ",", "size_str", "=", "None", ")", "...
[ 291, 4 ]
[ 310, 78 ]
python
en
['en', 'en', 'en']
True
Distribution._read_files_distinfo
(self)
Read the lines of RECORD
Read the lines of RECORD
def _read_files_distinfo(self): """ Read the lines of RECORD """ text = self.read_text('RECORD') return text and text.splitlines()
[ "def", "_read_files_distinfo", "(", "self", ")", ":", "text", "=", "self", ".", "read_text", "(", "'RECORD'", ")", "return", "text", "and", "text", ".", "splitlines", "(", ")" ]
[ 312, 4 ]
[ 317, 41 ]
python
en
['en', 'error', 'th']
False
Distribution._read_files_egginfo
(self)
SOURCES.txt might contain literal commas, so wrap each line in quotes.
SOURCES.txt might contain literal commas, so wrap each line in quotes.
def _read_files_egginfo(self): """ SOURCES.txt might contain literal commas, so wrap each line in quotes. """ text = self.read_text('SOURCES.txt') return text and map('"{}"'.format, text.splitlines())
[ "def", "_read_files_egginfo", "(", "self", ")", ":", "text", "=", "self", ".", "read_text", "(", "'SOURCES.txt'", ")", "return", "text", "and", "map", "(", "'\"{}\"'", ".", "format", ",", "text", ".", "splitlines", "(", ")", ")" ]
[ 319, 4 ]
[ 325, 61 ]
python
en
['en', 'error', 'th']
False
Distribution.requires
(self)
Generated requirements specified for this Distribution
Generated requirements specified for this Distribution
def requires(self): """Generated requirements specified for this Distribution""" reqs = self._read_dist_info_reqs() or self._read_egg_info_reqs() return reqs and list(reqs)
[ "def", "requires", "(", "self", ")", ":", "reqs", "=", "self", ".", "_read_dist_info_reqs", "(", ")", "or", "self", ".", "_read_egg_info_reqs", "(", ")", "return", "reqs", "and", "list", "(", "reqs", ")" ]
[ 328, 4 ]
[ 331, 34 ]
python
en
['en', 'en', 'en']
True
Distribution._convert_egg_info_reqs_to_simple_reqs
(sections)
Historically, setuptools would solicit and store 'extra' requirements, including those with environment markers, in separate sections. More modern tools expect each dependency to be defined separately, with any relevant extras and environment markers attached directly to that ...
Historically, setuptools would solicit and store 'extra' requirements, including those with environment markers, in separate sections. More modern tools expect each dependency to be defined separately, with any relevant extras and environment markers attached directly to that ...
def _convert_egg_info_reqs_to_simple_reqs(sections): """ Historically, setuptools would solicit and store 'extra' requirements, including those with environment markers, in separate sections. More modern tools expect each dependency to be defined separately, with any relevant ...
[ "def", "_convert_egg_info_reqs_to_simple_reqs", "(", "sections", ")", ":", "def", "make_condition", "(", "name", ")", ":", "return", "name", "and", "'extra == \"{name}\"'", ".", "format", "(", "name", "=", "name", ")", "def", "parse_condition", "(", "section", "...
[ 361, 4 ]
[ 384, 52 ]
python
en
['en', 'error', 'th']
False
DistributionFinder.find_distributions
(self, context=Context())
Find distributions. Return an iterable of all Distribution instances capable of loading the metadata for packages matching the ``context``, a DistributionFinder.Context instance.
Find distributions.
def find_distributions(self, context=Context()): """ Find distributions. Return an iterable of all Distribution instances capable of loading the metadata for packages matching the ``context``, a DistributionFinder.Context instance. """
[ "def", "find_distributions", "(", "self", ",", "context", "=", "Context", "(", ")", ")", ":" ]
[ 424, 4 ]
[ 431, 11 ]
python
en
['en', 'error', 'th']
False
PathDistribution.__init__
(self, path)
Construct a distribution from a path to the metadata directory. :param path: A pathlib.Path or similar object supporting .joinpath(), __div__, .parent, and .read_text().
Construct a distribution from a path to the metadata directory.
def __init__(self, path): """Construct a distribution from a path to the metadata directory. :param path: A pathlib.Path or similar object supporting .joinpath(), __div__, .parent, and .read_text(). """ self._path = path
[ "def", "__init__", "(", "self", ",", "path", ")", ":", "self", ".", "_path", "=", "path" ]
[ 533, 4 ]
[ 539, 25 ]
python
en
['en', 'en', 'en']
True
make_fake_coin
(index: int, puzzle_hash_db: dict)
Make a fake coin with parent id equal to the index (ie. a genesis block coin)
Make a fake coin with parent id equal to the index (ie. a genesis block coin)
def make_fake_coin(index: int, puzzle_hash_db: dict) -> Coin: """ Make a fake coin with parent id equal to the index (ie. a genesis block coin) """ parent = index.to_bytes(32, "big") puzzle_hash = puzzle_hash_for_index(index, puzzle_hash_db) amount = 100000 return Coin(parent, puzzle_hash, ...
[ "def", "make_fake_coin", "(", "index", ":", "int", ",", "puzzle_hash_db", ":", "dict", ")", "->", "Coin", ":", "parent", "=", "index", ".", "to_bytes", "(", "32", ",", "\"big\"", ")", "puzzle_hash", "=", "puzzle_hash_for_index", "(", "index", ",", "puzzle_...
[ 31, 0 ]
[ 39, 52 ]
python
en
['en', 'error', 'th']
False
get_topic_from_message_info
(message_info: Dict[str, Any])
Use this where you are getting dicts that are based off of messages that may come from the outside world, especially from third party APIs and bots. We prefer 'topic' to 'subject' here. We expect at least one field to be present (or the caller must know how to handle KeyError).
Use this where you are getting dicts that are based off of messages that may come from the outside world, especially from third party APIs and bots.
def get_topic_from_message_info(message_info: Dict[str, Any]) -> str: """ Use this where you are getting dicts that are based off of messages that may come from the outside world, especially from third party APIs and bots. We prefer 'topic' to 'subject' here. We expect at least one field to be...
[ "def", "get_topic_from_message_info", "(", "message_info", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "str", ":", "if", "\"topic\"", "in", "message_info", ":", "return", "message_info", "[", "\"topic\"", "]", "return", "message_info", "[", "\"subject...
[ 34, 0 ]
[ 46, 34 ]
python
en
['en', 'error', 'th']
False
search_packages_info
(query)
Gather details from installed distributions. Print distribution name, version, location, and installed files. Installed files requires a pip generated 'installed-files.txt' in the distributions '.egg-info' directory.
Gather details from installed distributions. Print distribution name, version, location, and installed files. Installed files requires a pip generated 'installed-files.txt' in the distributions '.egg-info' directory.
def search_packages_info(query): # type: (List[str]) -> Iterator[Dict[str, str]] """ Gather details from installed distributions. Print distribution name, version, location, and installed files. Installed files requires a pip generated 'installed-files.txt' in the distributions '.egg-info' direc...
[ "def", "search_packages_info", "(", "query", ")", ":", "# type: (List[str]) -> Iterator[Dict[str, str]]", "installed", "=", "{", "}", "for", "p", "in", "pkg_resources", ".", "working_set", ":", "installed", "[", "canonicalize_name", "(", "p", ".", "project_name", ")...
[ 57, 0 ]
[ 144, 21 ]
python
en
['en', 'error', 'th']
False
print_results
(distributions, list_files=False, verbose=False)
Print the information from installed distributions found.
Print the information from installed distributions found.
def print_results(distributions, list_files=False, verbose=False): # type: (Iterator[Dict[str, str]], bool, bool) -> bool """ Print the information from installed distributions found. """ results_printed = False for i, dist in enumerate(distributions): results_printed = True if i...
[ "def", "print_results", "(", "distributions", ",", "list_files", "=", "False", ",", "verbose", "=", "False", ")", ":", "# type: (Iterator[Dict[str, str]], bool, bool) -> bool", "results_printed", "=", "False", "for", "i", ",", "dist", "in", "enumerate", "(", "distri...
[ 147, 0 ]
[ 185, 26 ]
python
en
['en', 'error', 'th']
False
RequestEncodingMixin.path_url
(self)
Build the path URL to use.
Build the path URL to use.
def path_url(self): """Build the path URL to use.""" url = [] p = urlsplit(self.url) path = p.path if not path: path = '/' url.append(path) query = p.query if query: url.append('?') url.append(query) return...
[ "def", "path_url", "(", "self", ")", ":", "url", "=", "[", "]", "p", "=", "urlsplit", "(", "self", ".", "url", ")", "path", "=", "p", ".", "path", "if", "not", "path", ":", "path", "=", "'/'", "url", ".", "append", "(", "path", ")", "query", ...
[ 61, 4 ]
[ 79, 27 ]
python
en
['en', 'en', 'en']
True
RequestEncodingMixin._encode_params
(data)
Encode parameters in a piece of data. Will successfully encode parameters when passed as a dict or a list of 2-tuples. Order is retained if data is a list of 2-tuples but arbitrary if parameters are supplied as a dict.
Encode parameters in a piece of data.
def _encode_params(data): """Encode parameters in a piece of data. Will successfully encode parameters when passed as a dict or a list of 2-tuples. Order is retained if data is a list of 2-tuples but arbitrary if parameters are supplied as a dict. """ if isinstance(data...
[ "def", "_encode_params", "(", "data", ")", ":", "if", "isinstance", "(", "data", ",", "(", "str", ",", "bytes", ")", ")", ":", "return", "data", "elif", "hasattr", "(", "data", ",", "'read'", ")", ":", "return", "data", "elif", "hasattr", "(", "data"...
[ 82, 4 ]
[ 106, 23 ]
python
en
['en', 'en', 'en']
True
RequestEncodingMixin._encode_files
(files, data)
Build the body for a multipart/form-data request. Will successfully encode files when passed as a dict or a list of tuples. Order is retained if data is a list of tuples but arbitrary if parameters are supplied as a dict. The tuples may be 2-tuples (filename, fileobj), 3-tuples (filenam...
Build the body for a multipart/form-data request.
def _encode_files(files, data): """Build the body for a multipart/form-data request. Will successfully encode files when passed as a dict or a list of tuples. Order is retained if data is a list of tuples but arbitrary if parameters are supplied as a dict. The tuples may be 2-tu...
[ "def", "_encode_files", "(", "files", ",", "data", ")", ":", "if", "(", "not", "files", ")", ":", "raise", "ValueError", "(", "\"Files must be provided.\"", ")", "elif", "isinstance", "(", "data", ",", "basestring", ")", ":", "raise", "ValueError", "(", "\...
[ 109, 4 ]
[ 170, 33 ]
python
en
['en', 'en', 'en']
True
RequestHooksMixin.register_hook
(self, event, hook)
Properly register a hook.
Properly register a hook.
def register_hook(self, event, hook): """Properly register a hook.""" if event not in self.hooks: raise ValueError('Unsupported event specified, with event name "%s"' % (event)) if isinstance(hook, Callable): self.hooks[event].append(hook) elif hasattr(hook, '__...
[ "def", "register_hook", "(", "self", ",", "event", ",", "hook", ")", ":", "if", "event", "not", "in", "self", ".", "hooks", ":", "raise", "ValueError", "(", "'Unsupported event specified, with event name \"%s\"'", "%", "(", "event", ")", ")", "if", "isinstance...
[ 174, 4 ]
[ 183, 80 ]
python
en
['en', 'da', 'en']
True