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
WhereNode.relabel_aliases
(self, change_map)
Relabel the alias values of any children. 'change_map' is a dictionary mapping old (current) alias values to the new values.
Relabel the alias values of any children. 'change_map' is a dictionary mapping old (current) alias values to the new values.
def relabel_aliases(self, change_map): """ Relabel the alias values of any children. 'change_map' is a dictionary mapping old (current) alias values to the new values. """ for pos, child in enumerate(self.children): if hasattr(child, 'relabel_aliases'): ...
[ "def", "relabel_aliases", "(", "self", ",", "change_map", ")", ":", "for", "pos", ",", "child", "in", "enumerate", "(", "self", ".", "children", ")", ":", "if", "hasattr", "(", "child", ",", "'relabel_aliases'", ")", ":", "# For example another WhereNode", "...
[ 129, 4 ]
[ 139, 70 ]
python
en
['en', 'error', 'th']
False
WhereNode.clone
(self)
Create a clone of the tree. Must only be called on root nodes (nodes with empty subtree_parents). Childs must be either (Constraint, lookup, value) tuples, or objects supporting .clone().
Create a clone of the tree. Must only be called on root nodes (nodes with empty subtree_parents). Childs must be either (Constraint, lookup, value) tuples, or objects supporting .clone().
def clone(self): """ Create a clone of the tree. Must only be called on root nodes (nodes with empty subtree_parents). Childs must be either (Constraint, lookup, value) tuples, or objects supporting .clone(). """ clone = self.__class__._new_instance( children=...
[ "def", "clone", "(", "self", ")", ":", "clone", "=", "self", ".", "__class__", ".", "_new_instance", "(", "children", "=", "[", "]", ",", "connector", "=", "self", ".", "connector", ",", "negated", "=", "self", ".", "negated", ")", "for", "child", "i...
[ 141, 4 ]
[ 154, 20 ]
python
en
['en', 'error', 'th']
False
WheelDistribution.get_pkg_resources_distribution
(self)
Loads the metadata from the wheel file into memory and returns a Distribution that uses it, not relying on the wheel file or requirement.
Loads the metadata from the wheel file into memory and returns a Distribution that uses it, not relying on the wheel file or requirement.
def get_pkg_resources_distribution(self): # type: () -> Distribution """Loads the metadata from the wheel file into memory and returns a Distribution that uses it, not relying on the wheel file or requirement. """ # Set as part of preparation during download. asse...
[ "def", "get_pkg_resources_distribution", "(", "self", ")", ":", "# type: () -> Distribution", "# Set as part of preparation during download.", "assert", "self", ".", "req", ".", "local_file_path", "# Wheels are never unnamed.", "assert", "self", ".", "req", ".", "name", "wi...
[ 17, 4 ]
[ 31, 13 ]
python
en
['en', 'en', 'en']
True
messages
(request)
Returns a lazy 'messages' context variable.
Returns a lazy 'messages' context variable.
def messages(request): """ Returns a lazy 'messages' context variable. """ return { 'messages': get_messages(request), 'DEFAULT_MESSAGE_LEVELS': DEFAULT_LEVELS, }
[ "def", "messages", "(", "request", ")", ":", "return", "{", "'messages'", ":", "get_messages", "(", "request", ")", ",", "'DEFAULT_MESSAGE_LEVELS'", ":", "DEFAULT_LEVELS", ",", "}" ]
[ 4, 0 ]
[ 11, 5 ]
python
en
['en', 'error', 'th']
False
GeometryCollection.__init__
(self, *args, **kwargs)
Initialize a Geometry Collection from a sequence of Geometry objects.
Initialize a Geometry Collection from a sequence of Geometry objects.
def __init__(self, *args, **kwargs): "Initialize a Geometry Collection from a sequence of Geometry objects." # Checking the arguments if len(args) == 1: # If only one geometry provided or a list of geometries is provided # in the first argument. if isinstance...
[ "def", "__init__", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# Checking the arguments", "if", "len", "(", "args", ")", "==", "1", ":", "# If only one geometry provided or a list of geometries is provided", "# in the first argument.", "if", ...
[ 17, 4 ]
[ 36, 46 ]
python
en
['en', 'en', 'en']
True
GeometryCollection.__iter__
(self)
Iterate over each Geometry in the Collection.
Iterate over each Geometry in the Collection.
def __iter__(self): "Iterate over each Geometry in the Collection." for i in range(len(self)): yield self[i]
[ "def", "__iter__", "(", "self", ")", ":", "for", "i", "in", "range", "(", "len", "(", "self", ")", ")", ":", "yield", "self", "[", "i", "]" ]
[ 38, 4 ]
[ 41, 25 ]
python
en
['en', 'en', 'en']
True
GeometryCollection.__len__
(self)
Return the number of geometries in this Collection.
Return the number of geometries in this Collection.
def __len__(self): "Return the number of geometries in this Collection." return self.num_geom
[ "def", "__len__", "(", "self", ")", ":", "return", "self", ".", "num_geom" ]
[ 43, 4 ]
[ 45, 28 ]
python
en
['en', 'en', 'en']
True
GeometryCollection._get_single_external
(self, index)
Return the Geometry from this Collection at the given index (0-based).
Return the Geometry from this Collection at the given index (0-based).
def _get_single_external(self, index): "Return the Geometry from this Collection at the given index (0-based)." # Checking the index and returning the corresponding GEOS geometry. return GEOSGeometry(capi.geom_clone(self._get_single_internal(index)), srid=self.srid)
[ "def", "_get_single_external", "(", "self", ",", "index", ")", ":", "# Checking the index and returning the corresponding GEOS geometry.", "return", "GEOSGeometry", "(", "capi", ".", "geom_clone", "(", "self", ".", "_get_single_internal", "(", "index", ")", ")", ",", ...
[ 60, 4 ]
[ 63, 94 ]
python
en
['en', 'en', 'en']
True
GeometryCollection._set_list
(self, length, items)
Create a new collection, and destroy the contents of the previous pointer.
Create a new collection, and destroy the contents of the previous pointer.
def _set_list(self, length, items): "Create a new collection, and destroy the contents of the previous pointer." prev_ptr = self.ptr srid = self.srid self.ptr = self._create_collection(length, items) if srid: self.srid = srid capi.destroy_geom(prev_ptr)
[ "def", "_set_list", "(", "self", ",", "length", ",", "items", ")", ":", "prev_ptr", "=", "self", ".", "ptr", "srid", "=", "self", ".", "srid", "self", ".", "ptr", "=", "self", ".", "_create_collection", "(", "length", ",", "items", ")", "if", "srid",...
[ 65, 4 ]
[ 72, 35 ]
python
en
['en', 'en', 'en']
True
GeometryCollection.kml
(self)
Return the KML for this Geometry Collection.
Return the KML for this Geometry Collection.
def kml(self): "Return the KML for this Geometry Collection." return '<MultiGeometry>%s</MultiGeometry>' % ''.join(g.kml for g in self)
[ "def", "kml", "(", "self", ")", ":", "return", "'<MultiGeometry>%s</MultiGeometry>'", "%", "''", ".", "join", "(", "g", ".", "kml", "for", "g", "in", "self", ")" ]
[ 78, 4 ]
[ 80, 81 ]
python
en
['en', 'en', 'en']
True
GeometryCollection.tuple
(self)
Return a tuple of all the coordinates in this Geometry Collection
Return a tuple of all the coordinates in this Geometry Collection
def tuple(self): "Return a tuple of all the coordinates in this Geometry Collection" return tuple(g.tuple for g in self)
[ "def", "tuple", "(", "self", ")", ":", "return", "tuple", "(", "g", ".", "tuple", "for", "g", "in", "self", ")" ]
[ 83, 4 ]
[ 85, 43 ]
python
en
['en', 'en', 'en']
True
BaseModelAdmin.formfield_for_dbfield
(self, db_field, **kwargs)
Hook for specifying the form Field instance for a given database Field instance. If kwargs are given, they're passed to the form Field's constructor.
Hook for specifying the form Field instance for a given database Field instance.
def formfield_for_dbfield(self, db_field, **kwargs): """ Hook for specifying the form Field instance for a given database Field instance. If kwargs are given, they're passed to the form Field's constructor. """ request = kwargs.pop("request", None) # If the fiel...
[ "def", "formfield_for_dbfield", "(", "self", ",", "db_field", ",", "*", "*", "kwargs", ")", ":", "request", "=", "kwargs", ".", "pop", "(", "\"request\"", ",", "None", ")", "# If the field specifies choices, we don't need to look for special", "# admin widgets - we just...
[ 155, 4 ]
[ 206, 43 ]
python
en
['en', 'error', 'th']
False
BaseModelAdmin.formfield_for_choice_field
(self, db_field, request=None, **kwargs)
Get a form Field for a database Field that has declared choices.
Get a form Field for a database Field that has declared choices.
def formfield_for_choice_field(self, db_field, request=None, **kwargs): """ Get a form Field for a database Field that has declared choices. """ # If the field is named as a radio_field, use a RadioSelect if db_field.name in self.radio_fields: # Avoid stomping on cust...
[ "def", "formfield_for_choice_field", "(", "self", ",", "db_field", ",", "request", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# If the field is named as a radio_field, use a RadioSelect", "if", "db_field", ".", "name", "in", "self", ".", "radio_fields", ":", ...
[ 208, 4 ]
[ 224, 43 ]
python
en
['en', 'error', 'th']
False
BaseModelAdmin.get_field_queryset
(self, db, db_field, request)
If the ModelAdmin specifies ordering, the queryset should respect that ordering. Otherwise don't specify the queryset, let the field decide (returns None in that case).
If the ModelAdmin specifies ordering, the queryset should respect that ordering. Otherwise don't specify the queryset, let the field decide (returns None in that case).
def get_field_queryset(self, db, db_field, request): """ If the ModelAdmin specifies ordering, the queryset should respect that ordering. Otherwise don't specify the queryset, let the field decide (returns None in that case). """ related_admin = self.admin_site._registry...
[ "def", "get_field_queryset", "(", "self", ",", "db", ",", "db_field", ",", "request", ")", ":", "related_admin", "=", "self", ".", "admin_site", ".", "_registry", ".", "get", "(", "db_field", ".", "rel", ".", "to", ",", "None", ")", "if", "related_admin"...
[ 226, 4 ]
[ 237, 19 ]
python
en
['en', 'error', 'th']
False
BaseModelAdmin.formfield_for_foreignkey
(self, db_field, request=None, **kwargs)
Get a form Field for a ForeignKey.
Get a form Field for a ForeignKey.
def formfield_for_foreignkey(self, db_field, request=None, **kwargs): """ Get a form Field for a ForeignKey. """ db = kwargs.get('using') if db_field.name in self.raw_id_fields: kwargs['widget'] = widgets.ForeignKeyRawIdWidget(db_field.rel, ...
[ "def", "formfield_for_foreignkey", "(", "self", ",", "db_field", ",", "request", "=", "None", ",", "*", "*", "kwargs", ")", ":", "db", "=", "kwargs", ".", "get", "(", "'using'", ")", "if", "db_field", ".", "name", "in", "self", ".", "raw_id_fields", ":...
[ 239, 4 ]
[ 258, 43 ]
python
en
['en', 'error', 'th']
False
BaseModelAdmin.formfield_for_manytomany
(self, db_field, request=None, **kwargs)
Get a form Field for a ManyToManyField.
Get a form Field for a ManyToManyField.
def formfield_for_manytomany(self, db_field, request=None, **kwargs): """ Get a form Field for a ManyToManyField. """ # If it uses an intermediary model that isn't auto created, don't show # a field in admin. if not db_field.rel.through._meta.auto_created: ret...
[ "def", "formfield_for_manytomany", "(", "self", ",", "db_field", ",", "request", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# If it uses an intermediary model that isn't auto created, don't show", "# a field in admin.", "if", "not", "db_field", ".", "rel", ".", ...
[ 260, 4 ]
[ 290, 25 ]
python
en
['en', 'error', 'th']
False
BaseModelAdmin.get_fields
(self, request, obj=None)
Hook for specifying fields.
Hook for specifying fields.
def get_fields(self, request, obj=None): """ Hook for specifying fields. """ return self.fields
[ "def", "get_fields", "(", "self", ",", "request", ",", "obj", "=", "None", ")", ":", "return", "self", ".", "fields" ]
[ 319, 4 ]
[ 323, 26 ]
python
en
['en', 'error', 'th']
False
BaseModelAdmin.get_fieldsets
(self, request, obj=None)
Hook for specifying fieldsets.
Hook for specifying fieldsets.
def get_fieldsets(self, request, obj=None): """ Hook for specifying fieldsets. """ # We access the property and check if it triggers a warning. # If it does, then it's ours and we can safely ignore it, but if # it doesn't then it has been overridden so we must warn about ...
[ "def", "get_fieldsets", "(", "self", ",", "request", ",", "obj", "=", "None", ")", ":", "# We access the property and check if it triggers a warning.", "# If it does, then it's ours and we can safely ignore it, but if", "# it doesn't then it has been overridden so we must warn about the"...
[ 325, 4 ]
[ 347, 66 ]
python
en
['en', 'error', 'th']
False
BaseModelAdmin.get_ordering
(self, request)
Hook for specifying field ordering.
Hook for specifying field ordering.
def get_ordering(self, request): """ Hook for specifying field ordering. """ return self.ordering or ()
[ "def", "get_ordering", "(", "self", ",", "request", ")", ":", "return", "self", ".", "ordering", "or", "(", ")" ]
[ 349, 4 ]
[ 353, 34 ]
python
en
['en', 'error', 'th']
False
BaseModelAdmin.get_readonly_fields
(self, request, obj=None)
Hook for specifying custom readonly fields.
Hook for specifying custom readonly fields.
def get_readonly_fields(self, request, obj=None): """ Hook for specifying custom readonly fields. """ return self.readonly_fields
[ "def", "get_readonly_fields", "(", "self", ",", "request", ",", "obj", "=", "None", ")", ":", "return", "self", ".", "readonly_fields" ]
[ 355, 4 ]
[ 359, 35 ]
python
en
['en', 'error', 'th']
False
BaseModelAdmin.get_prepopulated_fields
(self, request, obj=None)
Hook for specifying custom prepopulated fields.
Hook for specifying custom prepopulated fields.
def get_prepopulated_fields(self, request, obj=None): """ Hook for specifying custom prepopulated fields. """ return self.prepopulated_fields
[ "def", "get_prepopulated_fields", "(", "self", ",", "request", ",", "obj", "=", "None", ")", ":", "return", "self", ".", "prepopulated_fields" ]
[ 361, 4 ]
[ 365, 39 ]
python
en
['en', 'error', 'th']
False
BaseModelAdmin.get_queryset
(self, request)
Returns a QuerySet of all model instances that can be edited by the admin site. This is used by changelist_view.
Returns a QuerySet of all model instances that can be edited by the admin site. This is used by changelist_view.
def get_queryset(self, request): """ Returns a QuerySet of all model instances that can be edited by the admin site. This is used by changelist_view. """ qs = self.model._default_manager.get_queryset() # TODO: this should be handled by some parameter to the ChangeList. ...
[ "def", "get_queryset", "(", "self", ",", "request", ")", ":", "qs", "=", "self", ".", "model", ".", "_default_manager", ".", "get_queryset", "(", ")", "# TODO: this should be handled by some parameter to the ChangeList.", "ordering", "=", "self", ".", "get_ordering", ...
[ 367, 4 ]
[ 377, 17 ]
python
en
['en', 'error', 'th']
False
BaseModelAdmin.to_field_allowed
(self, request, to_field)
Returns True if the model associated with this admin should be allowed to be referenced by the specified field.
Returns True if the model associated with this admin should be allowed to be referenced by the specified field.
def to_field_allowed(self, request, to_field): """ Returns True if the model associated with this admin should be allowed to be referenced by the specified field. """ opts = self.model._meta try: field = opts.get_field(to_field) except FieldDoesNotExi...
[ "def", "to_field_allowed", "(", "self", ",", "request", ",", "to_field", ")", ":", "opts", "=", "self", ".", "model", ".", "_meta", "try", ":", "field", "=", "opts", ".", "get_field", "(", "to_field", ")", "except", "FieldDoesNotExist", ":", "return", "F...
[ 441, 4 ]
[ 473, 20 ]
python
en
['en', 'error', 'th']
False
BaseModelAdmin.has_add_permission
(self, request)
Returns True if the given request has permission to add an object. Can be overridden by the user in subclasses.
Returns True if the given request has permission to add an object. Can be overridden by the user in subclasses.
def has_add_permission(self, request): """ Returns True if the given request has permission to add an object. Can be overridden by the user in subclasses. """ opts = self.opts codename = get_permission_codename('add', opts) return request.user.has_perm("%s.%s" % (...
[ "def", "has_add_permission", "(", "self", ",", "request", ")", ":", "opts", "=", "self", ".", "opts", "codename", "=", "get_permission_codename", "(", "'add'", ",", "opts", ")", "return", "request", ".", "user", ".", "has_perm", "(", "\"%s.%s\"", "%", "(",...
[ 475, 4 ]
[ 482, 74 ]
python
en
['en', 'error', 'th']
False
BaseModelAdmin.has_change_permission
(self, request, obj=None)
Returns True if the given request has permission to change the given Django model instance, the default implementation doesn't examine the `obj` parameter. Can be overridden by the user in subclasses. In such case it should return True if the given request has permission to cha...
Returns True if the given request has permission to change the given Django model instance, the default implementation doesn't examine the `obj` parameter.
def has_change_permission(self, request, obj=None): """ Returns True if the given request has permission to change the given Django model instance, the default implementation doesn't examine the `obj` parameter. Can be overridden by the user in subclasses. In such case it should...
[ "def", "has_change_permission", "(", "self", ",", "request", ",", "obj", "=", "None", ")", ":", "opts", "=", "self", ".", "opts", "codename", "=", "get_permission_codename", "(", "'change'", ",", "opts", ")", "return", "request", ".", "user", ".", "has_per...
[ 484, 4 ]
[ 497, 74 ]
python
en
['en', 'error', 'th']
False
BaseModelAdmin.has_delete_permission
(self, request, obj=None)
Returns True if the given request has permission to change the given Django model instance, the default implementation doesn't examine the `obj` parameter. Can be overridden by the user in subclasses. In such case it should return True if the given request has permission to del...
Returns True if the given request has permission to change the given Django model instance, the default implementation doesn't examine the `obj` parameter.
def has_delete_permission(self, request, obj=None): """ Returns True if the given request has permission to change the given Django model instance, the default implementation doesn't examine the `obj` parameter. Can be overridden by the user in subclasses. In such case it should...
[ "def", "has_delete_permission", "(", "self", ",", "request", ",", "obj", "=", "None", ")", ":", "opts", "=", "self", ".", "opts", "codename", "=", "get_permission_codename", "(", "'delete'", ",", "opts", ")", "return", "request", ".", "user", ".", "has_per...
[ 499, 4 ]
[ 512, 74 ]
python
en
['en', 'error', 'th']
False
BaseModelAdmin.has_module_permission
(self, request)
Returns True if the given request has any permission in the given app label. Can be overridden by the user in subclasses. In such case it should return True if the given request has permission to view the module on the admin index page and access the module's index page. Overri...
Returns True if the given request has any permission in the given app label.
def has_module_permission(self, request): """ Returns True if the given request has any permission in the given app label. Can be overridden by the user in subclasses. In such case it should return True if the given request has permission to view the module on the admin ...
[ "def", "has_module_permission", "(", "self", ",", "request", ")", ":", "return", "request", ".", "user", ".", "has_module_perms", "(", "self", ".", "opts", ".", "app_label", ")" ]
[ 514, 4 ]
[ 525, 65 ]
python
en
['en', 'error', 'th']
False
InlineModelAdmin.get_extra
(self, request, obj=None, **kwargs)
Hook for customizing the number of extra inline forms.
Hook for customizing the number of extra inline forms.
def get_extra(self, request, obj=None, **kwargs): """Hook for customizing the number of extra inline forms.""" return self.extra
[ "def", "get_extra", "(", "self", ",", "request", ",", "obj", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "extra" ]
[ 1794, 4 ]
[ 1796, 25 ]
python
en
['en', 'en', 'en']
True
InlineModelAdmin.get_min_num
(self, request, obj=None, **kwargs)
Hook for customizing the min number of inline forms.
Hook for customizing the min number of inline forms.
def get_min_num(self, request, obj=None, **kwargs): """Hook for customizing the min number of inline forms.""" return self.min_num
[ "def", "get_min_num", "(", "self", ",", "request", ",", "obj", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "min_num" ]
[ 1798, 4 ]
[ 1800, 27 ]
python
en
['en', 'en', 'en']
True
InlineModelAdmin.get_max_num
(self, request, obj=None, **kwargs)
Hook for customizing the max number of extra inline forms.
Hook for customizing the max number of extra inline forms.
def get_max_num(self, request, obj=None, **kwargs): """Hook for customizing the max number of extra inline forms.""" return self.max_num
[ "def", "get_max_num", "(", "self", ",", "request", ",", "obj", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "max_num" ]
[ 1802, 4 ]
[ 1804, 27 ]
python
en
['en', 'en', 'en']
True
InlineModelAdmin.get_formset
(self, request, obj=None, **kwargs)
Returns a BaseInlineFormSet class for use in admin add/change views.
Returns a BaseInlineFormSet class for use in admin add/change views.
def get_formset(self, request, obj=None, **kwargs): """Returns a BaseInlineFormSet class for use in admin add/change views.""" if 'fields' in kwargs: fields = kwargs.pop('fields') else: fields = flatten_fieldsets(self.get_fieldsets(request, obj)) if self.exclude i...
[ "def", "get_formset", "(", "self", ",", "request", ",", "obj", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "'fields'", "in", "kwargs", ":", "fields", "=", "kwargs", ".", "pop", "(", "'fields'", ")", "else", ":", "fields", "=", "flatten_fiel...
[ 1806, 4 ]
[ 1880, 79 ]
python
en
['en', 'en', 'en']
True
VendorImporter.search_path
(self)
Search first the vendor package then as a natural package.
Search first the vendor package then as a natural package.
def search_path(self): """ Search first the vendor package then as a natural package. """ yield self.vendor_pkg + '.' yield ''
[ "def", "search_path", "(", "self", ")", ":", "yield", "self", ".", "vendor_pkg", "+", "'.'", "yield", "''" ]
[ 15, 4 ]
[ 20, 16 ]
python
en
['en', 'error', 'th']
False
VendorImporter.find_module
(self, fullname, path=None)
Return self when fullname starts with root_name and the target module is one vendored through this importer.
Return self when fullname starts with root_name and the target module is one vendored through this importer.
def find_module(self, fullname, path=None): """ Return self when fullname starts with root_name and the target module is one vendored through this importer. """ root, base, target = fullname.partition(self.root_name + '.') if root: return if not any(ma...
[ "def", "find_module", "(", "self", ",", "fullname", ",", "path", "=", "None", ")", ":", "root", ",", "base", ",", "target", "=", "fullname", ".", "partition", "(", "self", ".", "root_name", "+", "'.'", ")", "if", "root", ":", "return", "if", "not", ...
[ 22, 4 ]
[ 32, 19 ]
python
en
['en', 'error', 'th']
False
VendorImporter.load_module
(self, fullname)
Iterate over the search path to locate and load fullname.
Iterate over the search path to locate and load fullname.
def load_module(self, fullname): """ Iterate over the search path to locate and load fullname. """ root, base, target = fullname.partition(self.root_name + '.') for prefix in self.search_path: try: extant = prefix + target __import__(ex...
[ "def", "load_module", "(", "self", ",", "fullname", ")", ":", "root", ",", "base", ",", "target", "=", "fullname", ".", "partition", "(", "self", ".", "root_name", "+", "'.'", ")", "for", "prefix", "in", "self", ".", "search_path", ":", "try", ":", "...
[ 34, 4 ]
[ 54, 13 ]
python
en
['en', 'error', 'th']
False
VendorImporter.install
(self)
Install this importer into sys.meta_path if not already present.
Install this importer into sys.meta_path if not already present.
def install(self): """ Install this importer into sys.meta_path if not already present. """ if self not in sys.meta_path: sys.meta_path.append(self)
[ "def", "install", "(", "self", ")", ":", "if", "self", "not", "in", "sys", ".", "meta_path", ":", "sys", ".", "meta_path", ".", "append", "(", "self", ")" ]
[ 56, 4 ]
[ 61, 38 ]
python
en
['en', 'error', 'th']
False
message_cache_items
(items_for_remote_cache: Dict[str, Tuple[bytes]], message: Message)
Note: this code is untested, and the caller has been commented out for a while.
Note: this code is untested, and the caller has been commented out for a while.
def message_cache_items(items_for_remote_cache: Dict[str, Tuple[bytes]], message: Message) -> None: """ Note: this code is untested, and the caller has been commented out for a while. """ key = to_dict_cache_key_id(message.id) value = MessageDict.to_dict_uncached([message])[message.id] items...
[ "def", "message_cache_items", "(", "items_for_remote_cache", ":", "Dict", "[", "str", ",", "Tuple", "[", "bytes", "]", "]", ",", "message", ":", "Message", ")", "->", "None", ":", "key", "=", "to_dict_cache_key_id", "(", "message", ".", "id", ")", "value",...
[ 49, 0 ]
[ 56, 42 ]
python
en
['en', 'error', 'th']
False
get_active_realm_ids
()
For installations like Zulip Cloud hosting a lot of realms, it only makes sense to do cache-filling work for realms that have any currently active users/clients. Otherwise, we end up with every single-user trial organization that has ever been created costing us N streams worth of cache work (where N i...
For installations like Zulip Cloud hosting a lot of realms, it only makes sense to do cache-filling work for realms that have any currently active users/clients. Otherwise, we end up with every single-user trial organization that has ever been created costing us N streams worth of cache work (where N i...
def get_active_realm_ids() -> List[int]: """For installations like Zulip Cloud hosting a lot of realms, it only makes sense to do cache-filling work for realms that have any currently active users/clients. Otherwise, we end up with every single-user trial organization that has ever been created costing...
[ "def", "get_active_realm_ids", "(", ")", "->", "List", "[", "int", "]", ":", "date", "=", "timezone_now", "(", ")", "-", "datetime", ".", "timedelta", "(", "days", "=", "2", ")", "return", "(", "RealmCount", ".", "objects", ".", "filter", "(", "end_tim...
[ 93, 0 ]
[ 106, 5 ]
python
en
['en', 'en', 'en']
True
CharDistributionAnalysis.reset
(self)
reset analyser, clear any state
reset analyser, clear any state
def reset(self): """reset analyser, clear any state""" # If this flag is set to True, detection is done and conclusion has # been made self._done = False self._total_chars = 0 # Total characters encountered # The number of characters whose frequency order is less than 51...
[ "def", "reset", "(", "self", ")", ":", "# If this flag is set to True, detection is done and conclusion has", "# been made", "self", ".", "_done", "=", "False", "self", ".", "_total_chars", "=", "0", "# Total characters encountered", "# The number of characters whose frequency ...
[ 60, 4 ]
[ 67, 28 ]
python
en
['en', 'en', 'en']
True
CharDistributionAnalysis.feed
(self, char, char_len)
feed a character with known length
feed a character with known length
def feed(self, char, char_len): """feed a character with known length""" if char_len == 2: # we only care about 2-bytes character in our distribution analysis order = self.get_order(char) else: order = -1 if order >= 0: self._total_chars +=...
[ "def", "feed", "(", "self", ",", "char", ",", "char_len", ")", ":", "if", "char_len", "==", "2", ":", "# we only care about 2-bytes character in our distribution analysis", "order", "=", "self", ".", "get_order", "(", "char", ")", "else", ":", "order", "=", "-...
[ 69, 4 ]
[ 81, 41 ]
python
en
['en', 'en', 'en']
True
CharDistributionAnalysis.get_confidence
(self)
return confidence based on existing data
return confidence based on existing data
def get_confidence(self): """return confidence based on existing data""" # if we didn't receive any character in our consideration range, # return negative answer if self._total_chars <= 0 or self._freq_chars <= self.MINIMUM_DATA_THRESHOLD: return self.SURE_NO if sel...
[ "def", "get_confidence", "(", "self", ")", ":", "# if we didn't receive any character in our consideration range,", "# return negative answer", "if", "self", ".", "_total_chars", "<=", "0", "or", "self", ".", "_freq_chars", "<=", "self", ".", "MINIMUM_DATA_THRESHOLD", ":"...
[ 83, 4 ]
[ 97, 28 ]
python
en
['en', 'zu', 'en']
True
permalink
(func)
Decorator that calls urlresolvers.reverse() to return a URL using parameters returned by the decorated function "func". "func" should be a function that returns a tuple in one of the following formats: (viewname, viewargs) (viewname, viewargs, viewkwargs)
Decorator that calls urlresolvers.reverse() to return a URL using parameters returned by the decorated function "func".
def permalink(func): """ Decorator that calls urlresolvers.reverse() to return a URL using parameters returned by the decorated function "func". "func" should be a function that returns a tuple in one of the following formats: (viewname, viewargs) (viewname, viewargs, viewkwargs) ...
[ "def", "permalink", "(", "func", ")", ":", "from", "django", ".", "core", ".", "urlresolvers", "import", "reverse", "@", "wraps", "(", "func", ")", "def", "inner", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "bits", "=", "func", "(", "*", ...
[ 24, 0 ]
[ 40, 16 ]
python
en
['en', 'error', 'th']
False
get_next_runserver_command
()
Return the next highest priority "runserver" command class
Return the next highest priority "runserver" command class
def get_next_runserver_command(): """ Return the next highest priority "runserver" command class """ for app_name in get_lower_priority_apps(): module_path = "%s.management.commands.runserver" % app_name try: return import_module(module_path).Command except (ImportErr...
[ "def", "get_next_runserver_command", "(", ")", ":", "for", "app_name", "in", "get_lower_priority_apps", "(", ")", ":", "module_path", "=", "\"%s.management.commands.runserver\"", "%", "app_name", "try", ":", "return", "import_module", "(", "module_path", ")", ".", "...
[ 13, 0 ]
[ 22, 16 ]
python
en
['en', 'error', 'th']
False
get_lower_priority_apps
()
Yield all app module names below the current app in the INSTALLED_APPS list
Yield all app module names below the current app in the INSTALLED_APPS list
def get_lower_priority_apps(): """ Yield all app module names below the current app in the INSTALLED_APPS list """ self_app_name = ".".join(__name__.split(".")[:-3]) reached_self = False for app_config in apps.get_app_configs(): if app_config.name == self_app_name: reached_se...
[ "def", "get_lower_priority_apps", "(", ")", ":", "self_app_name", "=", "\".\"", ".", "join", "(", "__name__", ".", "split", "(", "\".\"", ")", "[", ":", "-", "3", "]", ")", "reached_self", "=", "False", "for", "app_config", "in", "apps", ".", "get_app_co...
[ 25, 0 ]
[ 36, 23 ]
python
en
['en', 'error', 'th']
False
get_subset
(dataset, num_trainimages)
reduce the size of the trainingset. Make sure that half of the images belongs to each class num_trainimages: size of new dataset
reduce the size of the trainingset. Make sure that half of the images belongs to each class num_trainimages: size of new dataset
def get_subset(dataset, num_trainimages): ''' reduce the size of the trainingset. Make sure that half of the images belongs to each class num_trainimages: size of new dataset ''' size_dataset = len(dataset.samples) if num_trainimages > size_dataset: raise ValueError("num_trainimages is l...
[ "def", "get_subset", "(", "dataset", ",", "num_trainimages", ")", ":", "size_dataset", "=", "len", "(", "dataset", ".", "samples", ")", "if", "num_trainimages", ">", "size_dataset", ":", "raise", "ValueError", "(", "\"num_trainimages is larger than available dataset\"...
[ 38, 0 ]
[ 50, 17 ]
python
en
['en', 'error', 'th']
False
eval_perf
(outputs, labels)
evaluate model performance
evaluate model performance
def eval_perf(outputs, labels): """evaluate model performance""" sigm = torch.nn.Sigmoid()(outputs) predicted = (sigm > 0.5).float() #if predicted.sum().item()!=64: # print(predicted.sum().item()) #print('number of images classified as class1: ', predicted.sum().item(), ' / ', labels.sum()....
[ "def", "eval_perf", "(", "outputs", ",", "labels", ")", ":", "sigm", "=", "torch", ".", "nn", ".", "Sigmoid", "(", ")", "(", "outputs", ")", "predicted", "=", "(", "sigm", ">", "0.5", ")", ".", "float", "(", ")", "#if predicted.sum().item()!=64:", "# ...
[ 53, 0 ]
[ 60, 64 ]
python
en
['es', 'en', 'en']
True
train
(model, trainloader, optimizer, criterion, writer, epoch, checkpointdir, step)
train the net
train the net
def train(model, trainloader, optimizer, criterion, writer, epoch, checkpointdir, step): """train the net """ model.train() torch.set_grad_enabled(True) # save memory and computation cost by not calculating the grad losses = AverageMeter() # object to record loss perfs = AverageM...
[ "def", "train", "(", "model", ",", "trainloader", ",", "optimizer", ",", "criterion", ",", "writer", ",", "epoch", ",", "checkpointdir", ",", "step", ")", ":", "model", ".", "train", "(", ")", "torch", ".", "set_grad_enabled", "(", "True", ")", "# save m...
[ 82, 0 ]
[ 153, 26 ]
python
en
['en', 'fy', 'en']
True
validate
(model, valloader, criterion, writer, epoch, step)
validate the model
validate the model
def validate(model, valloader, criterion, writer, epoch, step): """validate the model """ model.eval() torch.set_grad_enabled(False) # save memory and computation cost by not calculating the grad losses = AverageMeter() # object to record loss perfs = AverageMeter() ...
[ "def", "validate", "(", "model", ",", "valloader", ",", "criterion", ",", "writer", ",", "epoch", ",", "step", ")", ":", "model", ".", "eval", "(", ")", "torch", ".", "set_grad_enabled", "(", "False", ")", "# save memory and computation cost by not calculating t...
[ 156, 0 ]
[ 211, 46 ]
python
en
['en', 'en', 'en']
True
GeoAggregate.as_sql
(self, qn, connection)
Return the aggregate, rendered as SQL with parameters.
Return the aggregate, rendered as SQL with parameters.
def as_sql(self, qn, connection): "Return the aggregate, rendered as SQL with parameters." if connection.ops.oracle: self.extra['tolerance'] = self.tolerance params = [] if hasattr(self.col, 'as_sql'): field_name, params = self.col.as_sql(qn, connection) ...
[ "def", "as_sql", "(", "self", ",", "qn", ",", "connection", ")", ":", "if", "connection", ".", "ops", ".", "oracle", ":", "self", ".", "extra", "[", "'tolerance'", "]", "=", "self", ".", "tolerance", "params", "=", "[", "]", "if", "hasattr", "(", "...
[ 28, 4 ]
[ 51, 51 ]
python
en
['en', 'en', 'en']
True
GEOSCoordSeq.__init__
(self, ptr, z=False)
Initializes from a GEOS pointer.
Initializes from a GEOS pointer.
def __init__(self, ptr, z=False): "Initializes from a GEOS pointer." if not isinstance(ptr, CS_PTR): raise TypeError('Coordinate sequence should initialize with a CS_PTR.') self._ptr = ptr self._z = z
[ "def", "__init__", "(", "self", ",", "ptr", ",", "z", "=", "False", ")", ":", "if", "not", "isinstance", "(", "ptr", ",", "CS_PTR", ")", ":", "raise", "TypeError", "(", "'Coordinate sequence should initialize with a CS_PTR.'", ")", "self", ".", "_ptr", "=", ...
[ 19, 4 ]
[ 24, 19 ]
python
en
['en', 'en', 'en']
True
GEOSCoordSeq.__iter__
(self)
Iterates over each point in the coordinate sequence.
Iterates over each point in the coordinate sequence.
def __iter__(self): "Iterates over each point in the coordinate sequence." for i in xrange(self.size): yield self[i]
[ "def", "__iter__", "(", "self", ")", ":", "for", "i", "in", "xrange", "(", "self", ".", "size", ")", ":", "yield", "self", "[", "i", "]" ]
[ 26, 4 ]
[ 29, 25 ]
python
en
['en', 'en', 'en']
True
GEOSCoordSeq.__len__
(self)
Returns the number of points in the coordinate sequence.
Returns the number of points in the coordinate sequence.
def __len__(self): "Returns the number of points in the coordinate sequence." return int(self.size)
[ "def", "__len__", "(", "self", ")", ":", "return", "int", "(", "self", ".", "size", ")" ]
[ 31, 4 ]
[ 33, 29 ]
python
en
['en', 'en', 'en']
True
GEOSCoordSeq.__str__
(self)
Returns the string representation of the coordinate sequence.
Returns the string representation of the coordinate sequence.
def __str__(self): "Returns the string representation of the coordinate sequence." return str(self.tuple)
[ "def", "__str__", "(", "self", ")", ":", "return", "str", "(", "self", ".", "tuple", ")" ]
[ 35, 4 ]
[ 37, 30 ]
python
en
['en', 'en', 'en']
True
GEOSCoordSeq.__getitem__
(self, index)
Returns the coordinate sequence value at the given index.
Returns the coordinate sequence value at the given index.
def __getitem__(self, index): "Returns the coordinate sequence value at the given index." coords = [self.getX(index), self.getY(index)] if self.dims == 3 and self._z: coords.append(self.getZ(index)) return tuple(coords)
[ "def", "__getitem__", "(", "self", ",", "index", ")", ":", "coords", "=", "[", "self", ".", "getX", "(", "index", ")", ",", "self", ".", "getY", "(", "index", ")", "]", "if", "self", ".", "dims", "==", "3", "and", "self", ".", "_z", ":", "coord...
[ 39, 4 ]
[ 44, 28 ]
python
en
['en', 'en', 'en']
True
GEOSCoordSeq.__setitem__
(self, index, value)
Sets the coordinate sequence value at the given index.
Sets the coordinate sequence value at the given index.
def __setitem__(self, index, value): "Sets the coordinate sequence value at the given index." # Checking the input value if isinstance(value, (list, tuple)): pass elif numpy and isinstance(value, numpy.ndarray): pass else: raise TypeError('Must...
[ "def", "__setitem__", "(", "self", ",", "index", ",", "value", ")", ":", "# Checking the input value", "if", "isinstance", "(", "value", ",", "(", "list", ",", "tuple", ")", ")", ":", "pass", "elif", "numpy", "and", "isinstance", "(", "value", ",", "nump...
[ 46, 4 ]
[ 68, 38 ]
python
en
['en', 'en', 'en']
True
GEOSCoordSeq._checkindex
(self, index)
Checks the given index.
Checks the given index.
def _checkindex(self, index): "Checks the given index." sz = self.size if (sz < 1) or (index < 0) or (index >= sz): raise GEOSIndexError('invalid GEOS Geometry index: %s' % str(index))
[ "def", "_checkindex", "(", "self", ",", "index", ")", ":", "sz", "=", "self", ".", "size", "if", "(", "sz", "<", "1", ")", "or", "(", "index", "<", "0", ")", "or", "(", "index", ">=", "sz", ")", ":", "raise", "GEOSIndexError", "(", "'invalid GEOS...
[ 71, 4 ]
[ 75, 80 ]
python
en
['en', 'en', 'en']
True
GEOSCoordSeq._checkdim
(self, dim)
Checks the given dimension.
Checks the given dimension.
def _checkdim(self, dim): "Checks the given dimension." if dim < 0 or dim > 2: raise GEOSException('invalid ordinate dimension "%d"' % dim)
[ "def", "_checkdim", "(", "self", ",", "dim", ")", ":", "if", "dim", "<", "0", "or", "dim", ">", "2", ":", "raise", "GEOSException", "(", "'invalid ordinate dimension \"%d\"'", "%", "dim", ")" ]
[ 77, 4 ]
[ 80, 72 ]
python
en
['en', 'it', 'en']
True
GEOSCoordSeq.getOrdinate
(self, dimension, index)
Returns the value for the given dimension and index.
Returns the value for the given dimension and index.
def getOrdinate(self, dimension, index): "Returns the value for the given dimension and index." self._checkindex(index) self._checkdim(dimension) return capi.cs_getordinate(self.ptr, index, dimension, byref(c_double()))
[ "def", "getOrdinate", "(", "self", ",", "dimension", ",", "index", ")", ":", "self", ".", "_checkindex", "(", "index", ")", "self", ".", "_checkdim", "(", "dimension", ")", "return", "capi", ".", "cs_getordinate", "(", "self", ".", "ptr", ",", "index", ...
[ 83, 4 ]
[ 87, 81 ]
python
en
['en', 'en', 'en']
True
GEOSCoordSeq.setOrdinate
(self, dimension, index, value)
Sets the value for the given dimension and index.
Sets the value for the given dimension and index.
def setOrdinate(self, dimension, index, value): "Sets the value for the given dimension and index." self._checkindex(index) self._checkdim(dimension) capi.cs_setordinate(self.ptr, index, dimension, value)
[ "def", "setOrdinate", "(", "self", ",", "dimension", ",", "index", ",", "value", ")", ":", "self", ".", "_checkindex", "(", "index", ")", "self", ".", "_checkdim", "(", "dimension", ")", "capi", ".", "cs_setordinate", "(", "self", ".", "ptr", ",", "ind...
[ 89, 4 ]
[ 93, 62 ]
python
en
['en', 'en', 'en']
True
GEOSCoordSeq.getX
(self, index)
Get the X value at the index.
Get the X value at the index.
def getX(self, index): "Get the X value at the index." return self.getOrdinate(0, index)
[ "def", "getX", "(", "self", ",", "index", ")", ":", "return", "self", ".", "getOrdinate", "(", "0", ",", "index", ")" ]
[ 95, 4 ]
[ 97, 41 ]
python
en
['en', 'en', 'en']
True
GEOSCoordSeq.setX
(self, index, value)
Set X with the value at the given index.
Set X with the value at the given index.
def setX(self, index, value): "Set X with the value at the given index." self.setOrdinate(0, index, value)
[ "def", "setX", "(", "self", ",", "index", ",", "value", ")", ":", "self", ".", "setOrdinate", "(", "0", ",", "index", ",", "value", ")" ]
[ 99, 4 ]
[ 101, 41 ]
python
en
['en', 'en', 'en']
True
GEOSCoordSeq.getY
(self, index)
Get the Y value at the given index.
Get the Y value at the given index.
def getY(self, index): "Get the Y value at the given index." return self.getOrdinate(1, index)
[ "def", "getY", "(", "self", ",", "index", ")", ":", "return", "self", ".", "getOrdinate", "(", "1", ",", "index", ")" ]
[ 103, 4 ]
[ 105, 41 ]
python
en
['en', 'en', 'en']
True
GEOSCoordSeq.setY
(self, index, value)
Set Y with the value at the given index.
Set Y with the value at the given index.
def setY(self, index, value): "Set Y with the value at the given index." self.setOrdinate(1, index, value)
[ "def", "setY", "(", "self", ",", "index", ",", "value", ")", ":", "self", ".", "setOrdinate", "(", "1", ",", "index", ",", "value", ")" ]
[ 107, 4 ]
[ 109, 41 ]
python
en
['en', 'en', 'en']
True
GEOSCoordSeq.getZ
(self, index)
Get Z with the value at the given index.
Get Z with the value at the given index.
def getZ(self, index): "Get Z with the value at the given index." return self.getOrdinate(2, index)
[ "def", "getZ", "(", "self", ",", "index", ")", ":", "return", "self", ".", "getOrdinate", "(", "2", ",", "index", ")" ]
[ 111, 4 ]
[ 113, 41 ]
python
en
['en', 'en', 'en']
True
GEOSCoordSeq.setZ
(self, index, value)
Set Z with the value at the given index.
Set Z with the value at the given index.
def setZ(self, index, value): "Set Z with the value at the given index." self.setOrdinate(2, index, value)
[ "def", "setZ", "(", "self", ",", "index", ",", "value", ")", ":", "self", ".", "setOrdinate", "(", "2", ",", "index", ",", "value", ")" ]
[ 115, 4 ]
[ 117, 41 ]
python
en
['en', 'en', 'en']
True
GEOSCoordSeq.size
(self)
Returns the size of this coordinate sequence.
Returns the size of this coordinate sequence.
def size(self): "Returns the size of this coordinate sequence." return capi.cs_getsize(self.ptr, byref(c_uint()))
[ "def", "size", "(", "self", ")", ":", "return", "capi", ".", "cs_getsize", "(", "self", ".", "ptr", ",", "byref", "(", "c_uint", "(", ")", ")", ")" ]
[ 121, 4 ]
[ 123, 57 ]
python
en
['en', 'en', 'en']
True
GEOSCoordSeq.dims
(self)
Returns the dimensions of this coordinate sequence.
Returns the dimensions of this coordinate sequence.
def dims(self): "Returns the dimensions of this coordinate sequence." return capi.cs_getdims(self.ptr, byref(c_uint()))
[ "def", "dims", "(", "self", ")", ":", "return", "capi", ".", "cs_getdims", "(", "self", ".", "ptr", ",", "byref", "(", "c_uint", "(", ")", ")", ")" ]
[ 126, 4 ]
[ 128, 57 ]
python
en
['en', 'en', 'en']
True
GEOSCoordSeq.hasz
(self)
Returns whether this coordinate sequence is 3D. This property value is inherited from the parent Geometry.
Returns whether this coordinate sequence is 3D. This property value is inherited from the parent Geometry.
def hasz(self): """ Returns whether this coordinate sequence is 3D. This property value is inherited from the parent Geometry. """ return self._z
[ "def", "hasz", "(", "self", ")", ":", "return", "self", ".", "_z" ]
[ 131, 4 ]
[ 136, 22 ]
python
en
['en', 'error', 'th']
False
GEOSCoordSeq.clone
(self)
Clones this coordinate sequence.
Clones this coordinate sequence.
def clone(self): "Clones this coordinate sequence." return GEOSCoordSeq(capi.cs_clone(self.ptr), self.hasz)
[ "def", "clone", "(", "self", ")", ":", "return", "GEOSCoordSeq", "(", "capi", ".", "cs_clone", "(", "self", ".", "ptr", ")", ",", "self", ".", "hasz", ")" ]
[ 139, 4 ]
[ 141, 63 ]
python
en
['en', 'en', 'en']
True
GEOSCoordSeq.kml
(self)
Returns the KML representation for the coordinates.
Returns the KML representation for the coordinates.
def kml(self): "Returns the KML representation for the coordinates." # Getting the substitution string depending on whether the coordinates have # a Z dimension. if self.hasz: substr = '%s,%s,%s ' else: substr = '%s,%s,0 ' return '<coordinates>%s<...
[ "def", "kml", "(", "self", ")", ":", "# Getting the substitution string depending on whether the coordinates have", "# a Z dimension.", "if", "self", ".", "hasz", ":", "substr", "=", "'%s,%s,%s '", "else", ":", "substr", "=", "'%s,%s,0 '", "return", "'<coordinates>%s</co...
[ 144, 4 ]
[ 153, 72 ]
python
en
['en', 'en', 'en']
True
GEOSCoordSeq.tuple
(self)
Returns a tuple version of this coordinate sequence.
Returns a tuple version of this coordinate sequence.
def tuple(self): "Returns a tuple version of this coordinate sequence." n = self.size if n == 1: return self[0] else: return tuple(self[i] for i in xrange(n))
[ "def", "tuple", "(", "self", ")", ":", "n", "=", "self", ".", "size", "if", "n", "==", "1", ":", "return", "self", "[", "0", "]", "else", ":", "return", "tuple", "(", "self", "[", "i", "]", "for", "i", "in", "xrange", "(", "n", ")", ")" ]
[ 156, 4 ]
[ 162, 52 ]
python
en
['en', 'en', 'en']
True
Config.sync
(self)
Sync in-memory config with disk. Returns: dict: updated config
Sync in-memory config with disk.
def sync(self) -> dict: """Sync in-memory config with disk. Returns: dict: updated config """ with self.source as src: dpath.util.merge(src, self.config, flags=dpath.MERGE_REPLACE) return self.config
[ "def", "sync", "(", "self", ")", "->", "dict", ":", "with", "self", ".", "source", "as", "src", ":", "dpath", ".", "util", ".", "merge", "(", "src", ",", "self", ".", "config", ",", "flags", "=", "dpath", ".", "MERGE_REPLACE", ")", "return", "self"...
[ 58, 4 ]
[ 67, 26 ]
python
en
['en', 'en', 'en']
True
Config.parse_key
(self, key: str)
Parses key. Splits it into a path and 'final key' object. Each key is seperates by a: "/" Example: >>> self.parse_key('item/subitem/value') (('item', 'subitem'), 'value') Args: key (str): key in dot notation Returns: Tuple[Seque...
Parses key.
def parse_key(self, key: str) -> Tuple[Sequence[str], str]: """Parses key. Splits it into a path and 'final key' object. Each key is seperates by a: "/" Example: >>> self.parse_key('item/subitem/value') (('item', 'subitem'), 'value') Args: k...
[ "def", "parse_key", "(", "self", ",", "key", ":", "str", ")", "->", "Tuple", "[", "Sequence", "[", "str", "]", ",", "str", "]", ":", "full_path", "=", "tuple", "(", "i", "for", "i", "in", "key", ".", "split", "(", "\"/\"", ")", ")", "path", "="...
[ 69, 4 ]
[ 89, 28 ]
python
en
['en', 'hu', 'en']
False
Config.get
(self, key: str, default: Any = None)
Retrieve config value. Args: key (str): Key (in dot-notation) of value to return. default (Any, optional): Default value to return. Defaults to None. Returns: Any: Value at key given
Retrieve config value.
def get(self, key: str, default: Any = None) -> Any: """Retrieve config value. Args: key (str): Key (in dot-notation) of value to return. default (Any, optional): Default value to return. Defaults to None. Returns: Any: Value at key given ...
[ "def", "get", "(", "self", ",", "key", ":", "str", ",", "default", ":", "Any", "=", "None", ")", "->", "Any", ":", "try", ":", "value", "=", "dpath", ".", "util", ".", "get", "(", "self", ".", "config", ",", "key", ")", "except", "KeyError", ":...
[ 91, 4 ]
[ 109, 20 ]
python
en
['nl', 'pt', 'en']
False
Config.set
(self, key: str, value: Any)
Set config value. Args: key (str): Key (in dot-notation) to update. value (Any): Value to set Returns: Any: Updated config
Set config value.
def set(self, key: str, value: Any) -> Any: """Set config value. Args: key (str): Key (in dot-notation) to update. value (Any): Value to set Returns: Any: Updated config """ dpath.set(self._config, key, value) self.log.debug(f"set co...
[ "def", "set", "(", "self", ",", "key", ":", "str", ",", "value", ":", "Any", ")", "->", "Any", ":", "dpath", ".", "set", "(", "self", ".", "_config", ",", "key", ",", "value", ")", "self", ".", "log", ".", "debug", "(", "f\"set config value [{key}]...
[ 111, 4 ]
[ 124, 26 ]
python
en
['nl', 'pt', 'en']
False
Config.add
(self, key: str, value: Any)
Overwrite or add config value. Args: key: Key to set value: Value to add or update too Returns: Updated config
Overwrite or add config value.
def add(self, key: str, value: Any) -> Any: """Overwrite or add config value. Args: key: Key to set value: Value to add or update too Returns: Updated config """ dpath.new(self._config, key, value) self.log.debug(f"added config value...
[ "def", "add", "(", "self", ",", "key", ":", "str", ",", "value", ":", "Any", ")", "->", "Any", ":", "dpath", ".", "new", "(", "self", ".", "_config", ",", "key", ",", "value", ")", "self", ".", "log", ".", "debug", "(", "f\"added config value [{key...
[ 126, 4 ]
[ 139, 26 ]
python
en
['nl', 'en', 'en']
True
Config.pop
(self, key: str)
Delete and return value at key. Args: key (str): Key to pop. Returns: Any: Popped value.
Delete and return value at key.
def pop(self, key: str) -> Any: """Delete and return value at key. Args: key (str): Key to pop. Returns: Any: Popped value. """ path, target = self.parse_key(key) value = self.get(key) remapped = iterutils.remap( self._config...
[ "def", "pop", "(", "self", ",", "key", ":", "str", ")", "->", "Any", ":", "path", ",", "target", "=", "self", ".", "parse_key", "(", "key", ")", "value", "=", "self", ".", "get", "(", "key", ")", "remapped", "=", "iterutils", ".", "remap", "(", ...
[ 141, 4 ]
[ 158, 26 ]
python
en
['en', 'en', 'en']
True
Config.extend
(self, key: str, value: List[Any], unique: bool = False)
Extend a list in config at key path. Args: key: Key to path to extend. value: List of values to extend by. unique: Only extend values if not already in values. Returns: Updated Config
Extend a list in config at key path.
def extend(self, key: str, value: List[Any], unique: bool = False) -> dict: """Extend a list in config at key path. Args: key: Key to path to extend. value: List of values to extend by. unique: Only extend values if not already in values. Returns: ...
[ "def", "extend", "(", "self", ",", "key", ":", "str", ",", "value", ":", "List", "[", "Any", "]", ",", "unique", ":", "bool", "=", "False", ")", "->", "dict", ":", "to_update", "=", "list", "(", "deepcopy", "(", "self", ".", "get", "(", "key", ...
[ 160, 4 ]
[ 177, 26 ]
python
en
['en', 'en', 'en']
True
Config.upsert
(self, key: str, value: Union[List[Any], dict])
Update or insert values into key list or dict. Args: key: Key to value to upsert. value: Value to upsert by. Returns: Updated config.
Update or insert values into key list or dict.
def upsert(self, key: str, value: Union[List[Any], dict]) -> dict: """Update or insert values into key list or dict. Args: key: Key to value to upsert. value: Value to upsert by. Returns: Updated config. """ to_update = deepcopy(self.get(key...
[ "def", "upsert", "(", "self", ",", "key", ":", "str", ",", "value", ":", "Union", "[", "List", "[", "Any", "]", ",", "dict", "]", ")", "->", "dict", ":", "to_update", "=", "deepcopy", "(", "self", ".", "get", "(", "key", ",", "value", ")", ")",...
[ 179, 4 ]
[ 193, 26 ]
python
en
['en', 'en', 'en']
True
Config.search
(self, key)
Retrieve all values at key (with glob pattern). Args: key: Key with pattern to search with. Returns: Values matching key and pattern.
Retrieve all values at key (with glob pattern).
def search(self, key): """Retrieve all values at key (with glob pattern). Args: key: Key with pattern to search with. Returns: Values matching key and pattern. """ return dpath.values(self.config, key)
[ "def", "search", "(", "self", ",", "key", ")", ":", "return", "dpath", ".", "values", "(", "self", ".", "config", ",", "key", ")" ]
[ 195, 4 ]
[ 205, 45 ]
python
en
['en', 'en', 'en']
True
current_umask
()
Get the current umask which involves having to set it temporarily.
Get the current umask which involves having to set it temporarily.
def current_umask() -> int: """Get the current umask which involves having to set it temporarily.""" mask = os.umask(0) os.umask(mask) return mask
[ "def", "current_umask", "(", ")", "->", "int", ":", "mask", "=", "os", ".", "umask", "(", "0", ")", "os", ".", "umask", "(", "mask", ")", "return", "mask" ]
[ 11, 0 ]
[ 15, 15 ]
python
en
['en', 'en', 'en']
True
set_extracted_file_to_default_mode_plus_executable
(path: str)
Make file present at path have execute for user/group/world (chmod +x) is no-op on windows per python docs
Make file present at path have execute for user/group/world (chmod +x) is no-op on windows per python docs
def set_extracted_file_to_default_mode_plus_executable(path: str) -> None: """ Make file present at path have execute for user/group/world (chmod +x) is no-op on windows per python docs """ os.chmod(path, (0o777 & ~current_umask() | 0o111))
[ "def", "set_extracted_file_to_default_mode_plus_executable", "(", "path", ":", "str", ")", "->", "None", ":", "os", ".", "chmod", "(", "path", ",", "(", "0o777", "&", "~", "current_umask", "(", ")", "|", "0o111", ")", ")" ]
[ 18, 0 ]
[ 23, 54 ]
python
en
['en', 'error', 'th']
False
get_dist_info
(wheel_dir: str)
Returns the relative path to the dist-info directory if it exists. Args: wheel_dir: The root of the extracted wheel directory. Returns: Relative path to the dist-info directory if it exists, else, None.
Returns the relative path to the dist-info directory if it exists.
def get_dist_info(wheel_dir: str) -> str: """"Returns the relative path to the dist-info directory if it exists. Args: wheel_dir: The root of the extracted wheel directory. Returns: Relative path to the dist-info directory if it exists, else, None. """ dist_info_dirs = glob.glob(o...
[ "def", "get_dist_info", "(", "wheel_dir", ":", "str", ")", "->", "str", ":", "dist_info_dirs", "=", "glob", ".", "glob", "(", "os", ".", "path", ".", "join", "(", "wheel_dir", ",", "\"*.dist-info\"", ")", ")", "if", "not", "dist_info_dirs", ":", "raise",...
[ 76, 0 ]
[ 97, 28 ]
python
en
['en', 'en', 'en']
True
get_dot_data_directory
(wheel_dir: str)
Returns the relative path to the data directory if it exists. See: https://www.python.org/dev/peps/pep-0491/#the-data-directory Args: wheel_dir: The root of the extracted wheel directory. Returns: Relative path to the data directory if it exists, else, None.
Returns the relative path to the data directory if it exists.
def get_dot_data_directory(wheel_dir: str) -> Optional[str]: """Returns the relative path to the data directory if it exists. See: https://www.python.org/dev/peps/pep-0491/#the-data-directory Args: wheel_dir: The root of the extracted wheel directory. Returns: Relative path to the da...
[ "def", "get_dot_data_directory", "(", "wheel_dir", ":", "str", ")", "->", "Optional", "[", "str", "]", ":", "dot_data_dirs", "=", "glob", ".", "glob", "(", "os", ".", "path", ".", "join", "(", "wheel_dir", ",", "\"*.data\"", ")", ")", "if", "not", "dot...
[ 100, 0 ]
[ 121, 27 ]
python
en
['en', 'en', 'en']
True
parse_wheel_meta_file
(wheel_dir: str)
Parses the given WHEEL file into a dictionary. Args: wheel_dir: The file path of the WHEEL metadata file in dist-info. Returns: The WHEEL file mapped into a dictionary.
Parses the given WHEEL file into a dictionary.
def parse_wheel_meta_file(wheel_dir: str) -> Dict[str, str]: """Parses the given WHEEL file into a dictionary. Args: wheel_dir: The file path of the WHEEL metadata file in dist-info. Returns: The WHEEL file mapped into a dictionary. """ contents = {} with open(wheel_dir, "r") ...
[ "def", "parse_wheel_meta_file", "(", "wheel_dir", ":", "str", ")", "->", "Dict", "[", "str", ",", "str", "]", ":", "contents", "=", "{", "}", "with", "open", "(", "wheel_dir", ",", "\"r\"", ")", "as", "wheel_file", ":", "for", "line", "in", "wheel_file...
[ 124, 0 ]
[ 146, 19 ]
python
en
['en', 'en', 'en']
True
isImageType
(t)
Checks if an object is an image object. .. warning:: This function is for internal use only. :param t: object to check if it's an image :returns: True if the object is an image
Checks if an object is an image object.
def isImageType(t): """ Checks if an object is an image object. .. warning:: This function is for internal use only. :param t: object to check if it's an image :returns: True if the object is an image """ return hasattr(t, "im")
[ "def", "isImageType", "(", "t", ")", ":", "return", "hasattr", "(", "t", ",", "\"im\"", ")" ]
[ 128, 0 ]
[ 139, 27 ]
python
en
['en', 'error', 'th']
False
getmodebase
(mode)
Gets the "base" mode for given mode. This function returns "L" for images that contain grayscale data, and "RGB" for images that contain color data. :param mode: Input mode. :returns: "L" or "RGB". :exception KeyError: If the input mode was not a standard mode.
Gets the "base" mode for given mode. This function returns "L" for images that contain grayscale data, and "RGB" for images that contain color data.
def getmodebase(mode): """ Gets the "base" mode for given mode. This function returns "L" for images that contain grayscale data, and "RGB" for images that contain color data. :param mode: Input mode. :returns: "L" or "RGB". :exception KeyError: If the input mode was not a standard mode. ...
[ "def", "getmodebase", "(", "mode", ")", ":", "return", "ImageMode", ".", "getmode", "(", "mode", ")", ".", "basemode" ]
[ 289, 0 ]
[ 299, 43 ]
python
en
['en', 'error', 'th']
False
getmodetype
(mode)
Gets the storage type mode. Given a mode, this function returns a single-layer mode suitable for storing individual bands. :param mode: Input mode. :returns: "L", "I", or "F". :exception KeyError: If the input mode was not a standard mode.
Gets the storage type mode. Given a mode, this function returns a single-layer mode suitable for storing individual bands.
def getmodetype(mode): """ Gets the storage type mode. Given a mode, this function returns a single-layer mode suitable for storing individual bands. :param mode: Input mode. :returns: "L", "I", or "F". :exception KeyError: If the input mode was not a standard mode. """ return ImageMod...
[ "def", "getmodetype", "(", "mode", ")", ":", "return", "ImageMode", ".", "getmode", "(", "mode", ")", ".", "basetype" ]
[ 302, 0 ]
[ 311, 43 ]
python
en
['en', 'error', 'th']
False
getmodebandnames
(mode)
Gets a list of individual band names. Given a mode, this function returns a tuple containing the names of individual bands (use :py:method:`~PIL.Image.getmodetype` to get the mode used to store each individual band. :param mode: Input mode. :returns: A tuple containing band names. The length...
Gets a list of individual band names. Given a mode, this function returns a tuple containing the names of individual bands (use :py:method:`~PIL.Image.getmodetype` to get the mode used to store each individual band.
def getmodebandnames(mode): """ Gets a list of individual band names. Given a mode, this function returns a tuple containing the names of individual bands (use :py:method:`~PIL.Image.getmodetype` to get the mode used to store each individual band. :param mode: Input mode. :returns: A tuple...
[ "def", "getmodebandnames", "(", "mode", ")", ":", "return", "ImageMode", ".", "getmode", "(", "mode", ")", ".", "bands" ]
[ 314, 0 ]
[ 326, 40 ]
python
en
['en', 'error', 'th']
False
getmodebands
(mode)
Gets the number of individual bands for this mode. :param mode: Input mode. :returns: The number of bands in this mode. :exception KeyError: If the input mode was not a standard mode.
Gets the number of individual bands for this mode.
def getmodebands(mode): """ Gets the number of individual bands for this mode. :param mode: Input mode. :returns: The number of bands in this mode. :exception KeyError: If the input mode was not a standard mode. """ return len(ImageMode.getmode(mode).bands)
[ "def", "getmodebands", "(", "mode", ")", ":", "return", "len", "(", "ImageMode", ".", "getmode", "(", "mode", ")", ".", "bands", ")" ]
[ 329, 0 ]
[ 337, 45 ]
python
en
['en', 'error', 'th']
False
preinit
()
Explicitly load standard file format drivers.
Explicitly load standard file format drivers.
def preinit(): """Explicitly load standard file format drivers.""" global _initialized if _initialized >= 1: return try: from . import BmpImagePlugin assert BmpImagePlugin except ImportError: pass try: from . import GifImagePlugin assert GifIma...
[ "def", "preinit", "(", ")", ":", "global", "_initialized", "if", "_initialized", ">=", "1", ":", "return", "try", ":", "from", ".", "import", "BmpImagePlugin", "assert", "BmpImagePlugin", "except", "ImportError", ":", "pass", "try", ":", "from", ".", "import...
[ 346, 0 ]
[ 389, 20 ]
python
en
['en', 'en', 'en']
True
init
()
Explicitly initializes the Python Imaging Library. This function loads all available file format drivers.
Explicitly initializes the Python Imaging Library. This function loads all available file format drivers.
def init(): """ Explicitly initializes the Python Imaging Library. This function loads all available file format drivers. """ global _initialized if _initialized >= 2: return 0 for plugin in _plugins: try: logger.debug("Importing %s", plugin) __impor...
[ "def", "init", "(", ")", ":", "global", "_initialized", "if", "_initialized", ">=", "2", ":", "return", "0", "for", "plugin", "in", "_plugins", ":", "try", ":", "logger", ".", "debug", "(", "\"Importing %s\"", ",", "plugin", ")", "__import__", "(", "\"PI...
[ 392, 0 ]
[ 411, 16 ]
python
en
['en', 'error', 'th']
False
_wedge
()
Create greyscale wedge (for debugging only)
Create greyscale wedge (for debugging only)
def _wedge(): """Create greyscale wedge (for debugging only)""" return Image()._new(core.wedge("L"))
[ "def", "_wedge", "(", ")", ":", "return", "Image", "(", ")", ".", "_new", "(", "core", ".", "wedge", "(", "\"L\"", ")", ")" ]
[ 2552, 0 ]
[ 2555, 40 ]
python
en
['en', 'en', 'en']
True
_check_size
(size)
Common check to enforce type and sanity check on size tuples :param size: Should be a 2 tuple of (width, height) :returns: True, or raises a ValueError
Common check to enforce type and sanity check on size tuples
def _check_size(size): """ Common check to enforce type and sanity check on size tuples :param size: Should be a 2 tuple of (width, height) :returns: True, or raises a ValueError """ if not isinstance(size, (list, tuple)): raise ValueError("Size must be a tuple") if len(size) != 2:...
[ "def", "_check_size", "(", "size", ")", ":", "if", "not", "isinstance", "(", "size", ",", "(", "list", ",", "tuple", ")", ")", ":", "raise", "ValueError", "(", "\"Size must be a tuple\"", ")", "if", "len", "(", "size", ")", "!=", "2", ":", "raise", "...
[ 2558, 0 ]
[ 2573, 15 ]
python
en
['en', 'error', 'th']
False
new
(mode, size, color=0)
Creates a new image with the given mode and size. :param mode: The mode to use for the new image. See: :ref:`concept-modes`. :param size: A 2-tuple, containing (width, height) in pixels. :param color: What color to use for the image. Default is black. If given, this should be a single i...
Creates a new image with the given mode and size.
def new(mode, size, color=0): """ Creates a new image with the given mode and size. :param mode: The mode to use for the new image. See: :ref:`concept-modes`. :param size: A 2-tuple, containing (width, height) in pixels. :param color: What color to use for the image. Default is black. ...
[ "def", "new", "(", "mode", ",", "size", ",", "color", "=", "0", ")", ":", "_check_size", "(", "size", ")", "if", "color", "is", "None", ":", "# don't initialize", "return", "Image", "(", ")", ".", "_new", "(", "core", ".", "new", "(", "mode", ",", ...
[ 2576, 0 ]
[ 2612, 48 ]
python
en
['en', 'error', 'th']
False
frombytes
(mode, size, data, decoder_name="raw", *args)
Creates a copy of an image memory from pixel data in a buffer. In its simplest form, this function takes three arguments (mode, size, and unpacked pixel data). You can also use any pixel decoder supported by PIL. For more information on available decoders, see the section :ref:`Writing Your ...
Creates a copy of an image memory from pixel data in a buffer.
def frombytes(mode, size, data, decoder_name="raw", *args): """ Creates a copy of an image memory from pixel data in a buffer. In its simplest form, this function takes three arguments (mode, size, and unpacked pixel data). You can also use any pixel decoder supported by PIL. For more informa...
[ "def", "frombytes", "(", "mode", ",", "size", ",", "data", ",", "decoder_name", "=", "\"raw\"", ",", "*", "args", ")", ":", "_check_size", "(", "size", ")", "# may pass tuple instead of argument list", "if", "len", "(", "args", ")", "==", "1", "and", "isin...
[ 2615, 0 ]
[ 2650, 13 ]
python
en
['en', 'error', 'th']
False
frombuffer
(mode, size, data, decoder_name="raw", *args)
Creates an image memory referencing pixel data in a byte buffer. This function is similar to :py:func:`~PIL.Image.frombytes`, but uses data in the byte buffer, where possible. This means that changes to the original buffer object are reflected in this image). Not all modes can share memory; supp...
Creates an image memory referencing pixel data in a byte buffer.
def frombuffer(mode, size, data, decoder_name="raw", *args): """ Creates an image memory referencing pixel data in a byte buffer. This function is similar to :py:func:`~PIL.Image.frombytes`, but uses data in the byte buffer, where possible. This means that changes to the original buffer object are...
[ "def", "frombuffer", "(", "mode", ",", "size", ",", "data", ",", "decoder_name", "=", "\"raw\"", ",", "*", "args", ")", ":", "_check_size", "(", "size", ")", "# may pass tuple instead of argument list", "if", "len", "(", "args", ")", "==", "1", "and", "isi...
[ 2659, 0 ]
[ 2709, 58 ]
python
en
['en', 'error', 'th']
False
fromarray
(obj, mode=None)
Creates an image memory from an object exporting the array interface (using the buffer protocol). If **obj** is not contiguous, then the tobytes method is called and :py:func:`~PIL.Image.frombuffer` is used. If you have an image in NumPy:: from PIL import Image import numpy as np ...
Creates an image memory from an object exporting the array interface (using the buffer protocol).
def fromarray(obj, mode=None): """ Creates an image memory from an object exporting the array interface (using the buffer protocol). If **obj** is not contiguous, then the tobytes method is called and :py:func:`~PIL.Image.frombuffer` is used. If you have an image in NumPy:: from PIL imp...
[ "def", "fromarray", "(", "obj", ",", "mode", "=", "None", ")", ":", "arr", "=", "obj", ".", "__array_interface__", "shape", "=", "arr", "[", "\"shape\"", "]", "ndim", "=", "len", "(", "shape", ")", "strides", "=", "arr", ".", "get", "(", "\"strides\"...
[ 2712, 0 ]
[ 2769, 60 ]
python
en
['en', 'error', 'th']
False
fromqimage
(im)
Creates an image instance from a QImage image
Creates an image instance from a QImage image
def fromqimage(im): """Creates an image instance from a QImage image""" from . import ImageQt if not ImageQt.qt_is_installed: raise ImportError("Qt bindings are not installed") return ImageQt.fromqimage(im)
[ "def", "fromqimage", "(", "im", ")", ":", "from", ".", "import", "ImageQt", "if", "not", "ImageQt", ".", "qt_is_installed", ":", "raise", "ImportError", "(", "\"Qt bindings are not installed\"", ")", "return", "ImageQt", ".", "fromqimage", "(", "im", ")" ]
[ 2772, 0 ]
[ 2778, 33 ]
python
en
['en', 'en', 'en']
True
fromqpixmap
(im)
Creates an image instance from a QPixmap image
Creates an image instance from a QPixmap image
def fromqpixmap(im): """Creates an image instance from a QPixmap image""" from . import ImageQt if not ImageQt.qt_is_installed: raise ImportError("Qt bindings are not installed") return ImageQt.fromqpixmap(im)
[ "def", "fromqpixmap", "(", "im", ")", ":", "from", ".", "import", "ImageQt", "if", "not", "ImageQt", ".", "qt_is_installed", ":", "raise", "ImportError", "(", "\"Qt bindings are not installed\"", ")", "return", "ImageQt", ".", "fromqpixmap", "(", "im", ")" ]
[ 2781, 0 ]
[ 2787, 34 ]
python
en
['en', 'en', 'en']
True
open
(fp, mode="r")
Opens and identifies the given image file. This is a lazy operation; this function identifies the file, but the file remains open and the actual image data is not read from the file until you try to process the data (or call the :py:meth:`~PIL.Image.Image.load` method). See :py:func:`~PIL.Ima...
Opens and identifies the given image file.
def open(fp, mode="r"): """ Opens and identifies the given image file. This is a lazy operation; this function identifies the file, but the file remains open and the actual image data is not read from the file until you try to process the data (or call the :py:meth:`~PIL.Image.Image.load` metho...
[ "def", "open", "(", "fp", ",", "mode", "=", "\"r\"", ")", ":", "if", "mode", "!=", "\"r\"", ":", "raise", "ValueError", "(", "\"bad mode %r\"", "%", "mode", ")", "elif", "isinstance", "(", "fp", ",", "io", ".", "StringIO", ")", ":", "raise", "ValueEr...
[ 2838, 0 ]
[ 2931, 5 ]
python
en
['en', 'error', 'th']
False