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
Query.add_extra
(self, select, select_params, where, params, tables, order_by)
Add data to the various extra_* attributes for user-created additions to the query.
Add data to the various extra_* attributes for user-created additions to the query.
def add_extra(self, select, select_params, where, params, tables, order_by): """ Add data to the various extra_* attributes for user-created additions to the query. """ if select: # We need to pair any placeholder markers in the 'select' # dictionary with ...
[ "def", "add_extra", "(", "self", ",", "select", ",", "select_params", ",", "where", ",", "params", ",", "tables", ",", "order_by", ")", ":", "if", "select", ":", "# We need to pair any placeholder markers in the 'select'", "# dictionary with their parameters in 'select_pa...
[ 1986, 4 ]
[ 2016, 42 ]
python
en
['en', 'error', 'th']
False
Query.clear_deferred_loading
(self)
Remove any fields from the deferred loading set.
Remove any fields from the deferred loading set.
def clear_deferred_loading(self): """Remove any fields from the deferred loading set.""" self.deferred_loading = (frozenset(), True)
[ "def", "clear_deferred_loading", "(", "self", ")", ":", "self", ".", "deferred_loading", "=", "(", "frozenset", "(", ")", ",", "True", ")" ]
[ 2018, 4 ]
[ 2020, 51 ]
python
en
['en', 'en', 'en']
True
Query.add_deferred_loading
(self, field_names)
Add the given list of model field names to the set of fields to exclude from loading from the database when automatic column selection is done. Add the new field names to any existing field names that are deferred (or removed from any existing field names that are marked as the ...
Add the given list of model field names to the set of fields to exclude from loading from the database when automatic column selection is done. Add the new field names to any existing field names that are deferred (or removed from any existing field names that are marked as the ...
def add_deferred_loading(self, field_names): """ Add the given list of model field names to the set of fields to exclude from loading from the database when automatic column selection is done. Add the new field names to any existing field names that are deferred (or removed from ...
[ "def", "add_deferred_loading", "(", "self", ",", "field_names", ")", ":", "# Fields on related models are stored in the literal double-underscore", "# format, so that we can use a set datastructure. We do the foo__bar", "# splitting and handling when computing the SQL column names (as part of", ...
[ 2022, 4 ]
[ 2040, 75 ]
python
en
['en', 'error', 'th']
False
Query.add_immediate_loading
(self, field_names)
Add the given list of model field names to the set of fields to retrieve when the SQL is executed ("immediate loading" fields). The field names replace any existing immediate loading field names. If there are field names already specified for deferred loading, remove those names...
Add the given list of model field names to the set of fields to retrieve when the SQL is executed ("immediate loading" fields). The field names replace any existing immediate loading field names. If there are field names already specified for deferred loading, remove those names...
def add_immediate_loading(self, field_names): """ Add the given list of model field names to the set of fields to retrieve when the SQL is executed ("immediate loading" fields). The field names replace any existing immediate loading field names. If there are field names already s...
[ "def", "add_immediate_loading", "(", "self", ",", "field_names", ")", ":", "existing", ",", "defer", "=", "self", ".", "deferred_loading", "field_names", "=", "set", "(", "field_names", ")", "if", "'pk'", "in", "field_names", ":", "field_names", ".", "remove",...
[ 2042, 4 ]
[ 2064, 65 ]
python
en
['en', 'error', 'th']
False
Query.get_loaded_field_names
(self)
If any fields are marked to be deferred, return a dictionary mapping models to a set of names in those fields that will be loaded. If a model is not in the returned dictionary, none of its fields are deferred. If no fields are marked for deferral, return an empty dictionary. ...
If any fields are marked to be deferred, return a dictionary mapping models to a set of names in those fields that will be loaded. If a model is not in the returned dictionary, none of its fields are deferred.
def get_loaded_field_names(self): """ If any fields are marked to be deferred, return a dictionary mapping models to a set of names in those fields that will be loaded. If a model is not in the returned dictionary, none of its fields are deferred. If no fields are marked...
[ "def", "get_loaded_field_names", "(", "self", ")", ":", "# We cache this because we call this function multiple times", "# (compiler.fill_related_selections, query.iterator)", "try", ":", "return", "self", ".", "_loaded_field_names_cache", "except", "AttributeError", ":", "collecti...
[ 2066, 4 ]
[ 2083, 29 ]
python
en
['en', 'error', 'th']
False
Query.get_loaded_field_names_cb
(self, target, model, fields)
Callback used by get_deferred_field_names().
Callback used by get_deferred_field_names().
def get_loaded_field_names_cb(self, target, model, fields): """Callback used by get_deferred_field_names().""" target[model] = {f.attname for f in fields}
[ "def", "get_loaded_field_names_cb", "(", "self", ",", "target", ",", "model", ",", "fields", ")", ":", "target", "[", "model", "]", "=", "{", "f", ".", "attname", "for", "f", "in", "fields", "}" ]
[ 2085, 4 ]
[ 2087, 51 ]
python
en
['en', 'en', 'en']
True
Query.set_annotation_mask
(self, names)
Set the mask of annotations that will be returned by the SELECT.
Set the mask of annotations that will be returned by the SELECT.
def set_annotation_mask(self, names): """Set the mask of annotations that will be returned by the SELECT.""" if names is None: self.annotation_select_mask = None else: self.annotation_select_mask = set(names) self._annotation_select_cache = None
[ "def", "set_annotation_mask", "(", "self", ",", "names", ")", ":", "if", "names", "is", "None", ":", "self", ".", "annotation_select_mask", "=", "None", "else", ":", "self", ".", "annotation_select_mask", "=", "set", "(", "names", ")", "self", ".", "_annot...
[ 2089, 4 ]
[ 2095, 44 ]
python
en
['en', 'en', 'en']
True
Query.set_extra_mask
(self, names)
Set the mask of extra select items that will be returned by SELECT. Don't remove them from the Query since they might be used later.
Set the mask of extra select items that will be returned by SELECT. Don't remove them from the Query since they might be used later.
def set_extra_mask(self, names): """ Set the mask of extra select items that will be returned by SELECT. Don't remove them from the Query since they might be used later. """ if names is None: self.extra_select_mask = None else: self.extra_select_ma...
[ "def", "set_extra_mask", "(", "self", ",", "names", ")", ":", "if", "names", "is", "None", ":", "self", ".", "extra_select_mask", "=", "None", "else", ":", "self", ".", "extra_select_mask", "=", "set", "(", "names", ")", "self", ".", "_extra_select_cache",...
[ 2101, 4 ]
[ 2110, 39 ]
python
en
['en', 'error', 'th']
False
Query.annotation_select
(self)
Return the dictionary of aggregate columns that are not masked and should be used in the SELECT clause. Cache this result for performance.
Return the dictionary of aggregate columns that are not masked and should be used in the SELECT clause. Cache this result for performance.
def annotation_select(self): """ Return the dictionary of aggregate columns that are not masked and should be used in the SELECT clause. Cache this result for performance. """ if self._annotation_select_cache is not None: return self._annotation_select_cache e...
[ "def", "annotation_select", "(", "self", ")", ":", "if", "self", ".", "_annotation_select_cache", "is", "not", "None", ":", "return", "self", ".", "_annotation_select_cache", "elif", "not", "self", ".", "annotations", ":", "return", "{", "}", "elif", "self", ...
[ 2160, 4 ]
[ 2176, 35 ]
python
en
['en', 'error', 'th']
False
Query.trim_start
(self, names_with_path)
Trim joins from the start of the join path. The candidates for trim are the PathInfos in names_with_path structure that are m2m joins. Also set the select column so the start matches the join. This method is meant to be used for generating the subquery joins & cols in split_ex...
Trim joins from the start of the join path. The candidates for trim are the PathInfos in names_with_path structure that are m2m joins.
def trim_start(self, names_with_path): """ Trim joins from the start of the join path. The candidates for trim are the PathInfos in names_with_path structure that are m2m joins. Also set the select column so the start matches the join. This method is meant to be used for genera...
[ "def", "trim_start", "(", "self", ",", "names_with_path", ")", ":", "all_paths", "=", "[", "]", "for", "_", ",", "paths", "in", "names_with_path", ":", "all_paths", ".", "extend", "(", "paths", ")", "contains_louter", "=", "False", "# Trim and operate only on ...
[ 2193, 4 ]
[ 2243, 69 ]
python
en
['en', 'error', 'th']
False
clip
(signal, high, low)
Clip a signal from above at high and from below at low.
Clip a signal from above at high and from below at low.
def clip(signal, high, low): """ Clip a signal from above at high and from below at low. """ s = signal.copy() s[np.where(s > high)] = high s[np.where(s < low)] = low return s
[ "def", "clip", "(", "signal", ",", "high", ",", "low", ")", ":", "s", "=", "signal", ".", "copy", "(", ")", "s", "[", "np", ".", "where", "(", "s", ">", "high", ")", "]", "=", "high", "s", "[", "np", ".", "where", "(", "s", "<", "low", ")...
[ 9, 0 ]
[ 18, 12 ]
python
en
['en', 'error', 'th']
False
normalize
(signal, bits=None)
normalize to be in a given range.
normalize to be in a given range.
def normalize(signal, bits=None): """ normalize to be in a given range. """ s = signal.copy() s /= np.abs(s).max() # if one wants to scale for bits allocated if bits is not None: s *= 2 ** (bits - 1) - 1 s = clip(s, 2 ** (bits - 1) - 1, -(2 ** (bits - 1))) return s
[ "def", "normalize", "(", "signal", ",", "bits", "=", "None", ")", ":", "s", "=", "signal", ".", "copy", "(", ")", "s", "/=", "np", ".", "abs", "(", "s", ")", ".", "max", "(", ")", "# if one wants to scale for bits allocated", "if", "bits", "is", "not...
[ 21, 0 ]
[ 34, 12 ]
python
en
['en', 'error', 'th']
False
deconstructible
(*args, **kwargs)
Class decorator that allow the decorated class to be serialized by the migrations subsystem. Accepts an optional kwarg `path` to specify the import path.
Class decorator that allow the decorated class to be serialized by the migrations subsystem.
def deconstructible(*args, **kwargs): """ Class decorator that allow the decorated class to be serialized by the migrations subsystem. Accepts an optional kwarg `path` to specify the import path. """ path = kwargs.pop('path', None) def decorator(klass): def __new__(cls, *args, **kw...
[ "def", "deconstructible", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "path", "=", "kwargs", ".", "pop", "(", "'path'", ",", "None", ")", "def", "decorator", "(", "klass", ")", ":", "def", "__new__", "(", "cls", ",", "*", "args", ",", "*...
[ 4, 0 ]
[ 55, 37 ]
python
en
['en', 'error', 'th']
False
compress_kml
(kml)
Returns compressed KMZ from the given KML string.
Returns compressed KMZ from the given KML string.
def compress_kml(kml): "Returns compressed KMZ from the given KML string." kmz = BytesIO() zf = zipfile.ZipFile(kmz, 'a', zipfile.ZIP_DEFLATED) zf.writestr('doc.kml', kml.encode(settings.DEFAULT_CHARSET)) zf.close() kmz.seek(0) return kmz.read()
[ "def", "compress_kml", "(", "kml", ")", ":", "kmz", "=", "BytesIO", "(", ")", "zf", "=", "zipfile", ".", "ZipFile", "(", "kmz", ",", "'a'", ",", "zipfile", ".", "ZIP_DEFLATED", ")", "zf", ".", "writestr", "(", "'doc.kml'", ",", "kml", ".", "encode", ...
[ 8, 0 ]
[ 15, 21 ]
python
en
['en', 'en', 'en']
True
render_to_kml
(*args, **kwargs)
Renders the response as KML (using the correct MIME type).
Renders the response as KML (using the correct MIME type).
def render_to_kml(*args, **kwargs): "Renders the response as KML (using the correct MIME type)." return HttpResponse(loader.render_to_string(*args, **kwargs), content_type='application/vnd.google-earth.kml+xml')
[ "def", "render_to_kml", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "HttpResponse", "(", "loader", ".", "render_to_string", "(", "*", "args", ",", "*", "*", "kwargs", ")", ",", "content_type", "=", "'application/vnd.google-earth.kml+xml'", ...
[ 18, 0 ]
[ 21, 60 ]
python
en
['en', 'en', 'en']
True
render_to_kmz
(*args, **kwargs)
Compresses the KML content and returns as KMZ (using the correct MIME type).
Compresses the KML content and returns as KMZ (using the correct MIME type).
def render_to_kmz(*args, **kwargs): """ Compresses the KML content and returns as KMZ (using the correct MIME type). """ return HttpResponse(compress_kml(loader.render_to_string(*args, **kwargs)), content_type='application/vnd.google-earth.kmz')
[ "def", "render_to_kmz", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "HttpResponse", "(", "compress_kml", "(", "loader", ".", "render_to_string", "(", "*", "args", ",", "*", "*", "kwargs", ")", ")", ",", "content_type", "=", "'applicati...
[ 24, 0 ]
[ 30, 56 ]
python
en
['en', 'error', 'th']
False
render_to_text
(*args, **kwargs)
Renders the response using the MIME type for plain text.
Renders the response using the MIME type for plain text.
def render_to_text(*args, **kwargs): "Renders the response using the MIME type for plain text." return HttpResponse(loader.render_to_string(*args, **kwargs), content_type='text/plain')
[ "def", "render_to_text", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "HttpResponse", "(", "loader", ".", "render_to_string", "(", "*", "args", ",", "*", "*", "kwargs", ")", ",", "content_type", "=", "'text/plain'", ")" ]
[ 33, 0 ]
[ 36, 34 ]
python
en
['en', 'en', 'en']
True
contained_in
(filename, directory)
Test if a file is located within the given directory.
Test if a file is located within the given directory.
def contained_in(filename, directory): """Test if a file is located within the given directory.""" filename = os.path.normcase(os.path.abspath(filename)) directory = os.path.normcase(os.path.abspath(directory)) return os.path.commonprefix([filename, directory]) == directory
[ "def", "contained_in", "(", "filename", ",", "directory", ")", ":", "filename", "=", "os", ".", "path", ".", "normcase", "(", "os", ".", "path", ".", "abspath", "(", "filename", ")", ")", "directory", "=", "os", ".", "path", ".", "normcase", "(", "os...
[ 67, 0 ]
[ 71, 67 ]
python
en
['en', 'en', 'en']
True
_build_backend
()
Find and load the build backend
Find and load the build backend
def _build_backend(): """Find and load the build backend""" # Add in-tree backend directories to the front of sys.path. backend_path = os.environ.get('PEP517_BACKEND_PATH') if backend_path: extra_pathitems = backend_path.split(os.pathsep) sys.path[:0] = extra_pathitems ep = os.envir...
[ "def", "_build_backend", "(", ")", ":", "# Add in-tree backend directories to the front of sys.path.", "backend_path", "=", "os", ".", "environ", ".", "get", "(", "'PEP517_BACKEND_PATH'", ")", "if", "backend_path", ":", "extra_pathitems", "=", "backend_path", ".", "spli...
[ 74, 0 ]
[ 99, 14 ]
python
en
['en', 'en', 'en']
True
get_requires_for_build_wheel
(config_settings)
Invoke the optional get_requires_for_build_wheel hook Returns [] if the hook is not defined.
Invoke the optional get_requires_for_build_wheel hook
def get_requires_for_build_wheel(config_settings): """Invoke the optional get_requires_for_build_wheel hook Returns [] if the hook is not defined. """ backend = _build_backend() try: hook = backend.get_requires_for_build_wheel except AttributeError: return [] else: r...
[ "def", "get_requires_for_build_wheel", "(", "config_settings", ")", ":", "backend", "=", "_build_backend", "(", ")", "try", ":", "hook", "=", "backend", ".", "get_requires_for_build_wheel", "except", "AttributeError", ":", "return", "[", "]", "else", ":", "return"...
[ 102, 0 ]
[ 113, 36 ]
python
en
['en', 'en', 'en']
True
prepare_metadata_for_build_wheel
( metadata_directory, config_settings, _allow_fallback)
Invoke optional prepare_metadata_for_build_wheel Implements a fallback by building a wheel if the hook isn't defined, unless _allow_fallback is False in which case HookMissing is raised.
Invoke optional prepare_metadata_for_build_wheel
def prepare_metadata_for_build_wheel( metadata_directory, config_settings, _allow_fallback): """Invoke optional prepare_metadata_for_build_wheel Implements a fallback by building a wheel if the hook isn't defined, unless _allow_fallback is False in which case HookMissing is raised. """ back...
[ "def", "prepare_metadata_for_build_wheel", "(", "metadata_directory", ",", "config_settings", ",", "_allow_fallback", ")", ":", "backend", "=", "_build_backend", "(", ")", "try", ":", "hook", "=", "backend", ".", "prepare_metadata_for_build_wheel", "except", "AttributeE...
[ 116, 0 ]
[ 132, 56 ]
python
en
['en', 'no', 'en']
True
_dist_info_files
(whl_zip)
Identify the .dist-info folder inside a wheel ZipFile.
Identify the .dist-info folder inside a wheel ZipFile.
def _dist_info_files(whl_zip): """Identify the .dist-info folder inside a wheel ZipFile.""" res = [] for path in whl_zip.namelist(): m = re.match(r'[^/\\]+-[^/\\]+\.dist-info/', path) if m: res.append(path) if res: return res raise Exception("No .dist-info folder ...
[ "def", "_dist_info_files", "(", "whl_zip", ")", ":", "res", "=", "[", "]", "for", "path", "in", "whl_zip", ".", "namelist", "(", ")", ":", "m", "=", "re", ".", "match", "(", "r'[^/\\\\]+-[^/\\\\]+\\.dist-info/'", ",", "path", ")", "if", "m", ":", "res"...
[ 138, 0 ]
[ 147, 58 ]
python
en
['en', 'fy', 'en']
True
_get_wheel_metadata_from_wheel
( backend, metadata_directory, config_settings)
Build a wheel and extract the metadata from it. Fallback for when the build backend does not define the 'get_wheel_metadata' hook.
Build a wheel and extract the metadata from it.
def _get_wheel_metadata_from_wheel( backend, metadata_directory, config_settings): """Build a wheel and extract the metadata from it. Fallback for when the build backend does not define the 'get_wheel_metadata' hook. """ from zipfile import ZipFile whl_basename = backend.build_wheel(met...
[ "def", "_get_wheel_metadata_from_wheel", "(", "backend", ",", "metadata_directory", ",", "config_settings", ")", ":", "from", "zipfile", "import", "ZipFile", "whl_basename", "=", "backend", ".", "build_wheel", "(", "metadata_directory", ",", "config_settings", ")", "w...
[ 150, 0 ]
[ 166, 37 ]
python
en
['en', 'en', 'en']
True
_find_already_built_wheel
(metadata_directory)
Check for a wheel already built during the get_wheel_metadata hook.
Check for a wheel already built during the get_wheel_metadata hook.
def _find_already_built_wheel(metadata_directory): """Check for a wheel already built during the get_wheel_metadata hook. """ if not metadata_directory: return None metadata_parent = os.path.dirname(metadata_directory) if not os.path.isfile(pjoin(metadata_parent, WHEEL_BUILT_MARKER)): ...
[ "def", "_find_already_built_wheel", "(", "metadata_directory", ")", ":", "if", "not", "metadata_directory", ":", "return", "None", "metadata_parent", "=", "os", ".", "path", ".", "dirname", "(", "metadata_directory", ")", "if", "not", "os", ".", "path", ".", "...
[ 169, 0 ]
[ 188, 23 ]
python
en
['en', 'en', 'en']
True
build_wheel
(wheel_directory, config_settings, metadata_directory=None)
Invoke the mandatory build_wheel hook. If a wheel was already built in the prepare_metadata_for_build_wheel fallback, this will copy it rather than rebuilding the wheel.
Invoke the mandatory build_wheel hook.
def build_wheel(wheel_directory, config_settings, metadata_directory=None): """Invoke the mandatory build_wheel hook. If a wheel was already built in the prepare_metadata_for_build_wheel fallback, this will copy it rather than rebuilding the wheel. """ prebuilt_whl = _find_already_built_wheel(m...
[ "def", "build_wheel", "(", "wheel_directory", ",", "config_settings", ",", "metadata_directory", "=", "None", ")", ":", "prebuilt_whl", "=", "_find_already_built_wheel", "(", "metadata_directory", ")", "if", "prebuilt_whl", ":", "shutil", ".", "copy2", "(", "prebuil...
[ 191, 0 ]
[ 204, 59 ]
python
en
['en', 'st', 'en']
True
get_requires_for_build_sdist
(config_settings)
Invoke the optional get_requires_for_build_wheel hook Returns [] if the hook is not defined.
Invoke the optional get_requires_for_build_wheel hook
def get_requires_for_build_sdist(config_settings): """Invoke the optional get_requires_for_build_wheel hook Returns [] if the hook is not defined. """ backend = _build_backend() try: hook = backend.get_requires_for_build_sdist except AttributeError: return [] else: r...
[ "def", "get_requires_for_build_sdist", "(", "config_settings", ")", ":", "backend", "=", "_build_backend", "(", ")", "try", ":", "hook", "=", "backend", ".", "get_requires_for_build_sdist", "except", "AttributeError", ":", "return", "[", "]", "else", ":", "return"...
[ 207, 0 ]
[ 218, 36 ]
python
en
['en', 'en', 'en']
True
build_sdist
(sdist_directory, config_settings)
Invoke the mandatory build_sdist hook.
Invoke the mandatory build_sdist hook.
def build_sdist(sdist_directory, config_settings): """Invoke the mandatory build_sdist hook.""" backend = _build_backend() try: return backend.build_sdist(sdist_directory, config_settings) except getattr(backend, 'UnsupportedOperation', _DummyException): raise GotUnsupportedOperation(tra...
[ "def", "build_sdist", "(", "sdist_directory", ",", "config_settings", ")", ":", "backend", "=", "_build_backend", "(", ")", "try", ":", "return", "backend", ".", "build_sdist", "(", "sdist_directory", ",", "config_settings", ")", "except", "getattr", "(", "backe...
[ 231, 0 ]
[ 237, 61 ]
python
en
['en', 'st', 'en']
True
ReadFromWav
(data, batch_size)
Returns: audios_np: a numpy array of size (batch_size, max_length) in float trans: a numpy array includes the targeted transcriptions (batch_size, ) th_batch: a numpy array of the masking threshold, each of size (?, 1025) psd_max_batch: a numpy array of the psd_max of the original a...
Returns: audios_np: a numpy array of size (batch_size, max_length) in float trans: a numpy array includes the targeted transcriptions (batch_size, ) th_batch: a numpy array of the masking threshold, each of size (?, 1025) psd_max_batch: a numpy array of the psd_max of the original a...
def ReadFromWav(data, batch_size): """ Returns: audios_np: a numpy array of size (batch_size, max_length) in float trans: a numpy array includes the targeted transcriptions (batch_size, ) th_batch: a numpy array of the masking threshold, each of size (?, 1025) psd_max_batch: a nu...
[ "def", "ReadFromWav", "(", "data", ",", "batch_size", ")", ":", "audios", "=", "[", "]", "lengths", "=", "[", "]", "th_batch", "=", "[", "]", "psd_max_batch", "=", "[", "]", "# read the .wav file", "for", "i", "in", "range", "(", "batch_size", ")", ":"...
[ 41, 0 ]
[ 110, 5 ]
python
en
['en', 'error', 'th']
False
BaseValidator.check_field_spec
(self, cls, model, flds, label)
Validate the fields specification in `flds` from a ModelAdmin subclass `cls` for the `model` model. Use `label` for reporting problems to the user. The fields specification can be a ``fields`` option or a ``fields`` sub-option from a ``fieldsets`` option component.
Validate the fields specification in `flds` from a ModelAdmin subclass `cls` for the `model` model. Use `label` for reporting problems to the user.
def check_field_spec(self, cls, model, flds, label): """ Validate the fields specification in `flds` from a ModelAdmin subclass `cls` for the `model` model. Use `label` for reporting problems to the user. The fields specification can be a ``fields`` option or a ``fields`` sub-op...
[ "def", "check_field_spec", "(", "self", ",", "cls", ",", "model", ",", "flds", ",", "label", ")", ":", "for", "fields", "in", "flds", ":", "# The entry in fields might be a tuple. If it is a standalone", "# field, make it into a tuple to make processing easier.", "if", "t...
[ 22, 4 ]
[ 52, 63 ]
python
en
['en', 'error', 'th']
False
BaseValidator.validate_raw_id_fields
(self, cls, model)
Validate that raw_id_fields only contains field names that are listed on the model.
Validate that raw_id_fields only contains field names that are listed on the model.
def validate_raw_id_fields(self, cls, model): " Validate that raw_id_fields only contains field names that are listed on the model. " if hasattr(cls, 'raw_id_fields'): check_isseq(cls, 'raw_id_fields', cls.raw_id_fields) for idx, field in enumerate(cls.raw_id_fields): ...
[ "def", "validate_raw_id_fields", "(", "self", ",", "cls", ",", "model", ")", ":", "if", "hasattr", "(", "cls", ",", "'raw_id_fields'", ")", ":", "check_isseq", "(", "cls", ",", "'raw_id_fields'", ",", "cls", ".", "raw_id_fields", ")", "for", "idx", ",", ...
[ 54, 4 ]
[ 63, 57 ]
python
en
['en', 'en', 'en']
True
BaseValidator.validate_fields
(self, cls, model)
Validate that fields only refer to existing fields, doesn't contain duplicates.
Validate that fields only refer to existing fields, doesn't contain duplicates.
def validate_fields(self, cls, model): " Validate that fields only refer to existing fields, doesn't contain duplicates. " # fields if cls.fields: # default value is None check_isseq(cls, 'fields', cls.fields) self.check_field_spec(cls, model, cls.fields, 'fields') ...
[ "def", "validate_fields", "(", "self", ",", "cls", ",", "model", ")", ":", "# fields", "if", "cls", ".", "fields", ":", "# default value is None", "check_isseq", "(", "cls", ",", "'fields'", ",", "cls", ".", "fields", ")", "self", ".", "check_field_spec", ...
[ 65, 4 ]
[ 74, 102 ]
python
en
['en', 'en', 'en']
True
BaseValidator.validate_fieldsets
(self, cls, model)
Validate that fieldsets is properly formatted and doesn't contain duplicates.
Validate that fieldsets is properly formatted and doesn't contain duplicates.
def validate_fieldsets(self, cls, model): " Validate that fieldsets is properly formatted and doesn't contain duplicates. " from django.contrib.admin.options import flatten_fieldsets if cls.fieldsets: # default value is None check_isseq(cls, 'fieldsets', cls.fieldsets) f...
[ "def", "validate_fieldsets", "(", "self", ",", "cls", ",", "model", ")", ":", "from", "django", ".", "contrib", ".", "admin", ".", "options", "import", "flatten_fieldsets", "if", "cls", ".", "fieldsets", ":", "# default value is None", "check_isseq", "(", "cls...
[ 76, 4 ]
[ 94, 105 ]
python
en
['en', 'en', 'en']
True
BaseValidator.validate_exclude
(self, cls, model)
Validate that exclude is a sequence without duplicates.
Validate that exclude is a sequence without duplicates.
def validate_exclude(self, cls, model): " Validate that exclude is a sequence without duplicates. " if cls.exclude: # default value is None check_isseq(cls, 'exclude', cls.exclude) if len(cls.exclude) > len(set(cls.exclude)): raise ImproperlyConfigured('There are...
[ "def", "validate_exclude", "(", "self", ",", "cls", ",", "model", ")", ":", "if", "cls", ".", "exclude", ":", "# default value is None", "check_isseq", "(", "cls", ",", "'exclude'", ",", "cls", ".", "exclude", ")", "if", "len", "(", "cls", ".", "exclude"...
[ 96, 4 ]
[ 101, 103 ]
python
en
['en', 'en', 'en']
True
BaseValidator.validate_form
(self, cls, model)
Validate that form subclasses BaseModelForm.
Validate that form subclasses BaseModelForm.
def validate_form(self, cls, model): " Validate that form subclasses BaseModelForm. " if hasattr(cls, 'form') and not issubclass(cls.form, BaseModelForm): raise ImproperlyConfigured("%s.form does not inherit from " "BaseModelForm." % cls.__name__)
[ "def", "validate_form", "(", "self", ",", "cls", ",", "model", ")", ":", "if", "hasattr", "(", "cls", ",", "'form'", ")", "and", "not", "issubclass", "(", "cls", ".", "form", ",", "BaseModelForm", ")", ":", "raise", "ImproperlyConfigured", "(", "\"%s.for...
[ 103, 4 ]
[ 107, 52 ]
python
en
['en', 'en', 'en']
True
BaseValidator.validate_filter_vertical
(self, cls, model)
Validate that filter_vertical is a sequence of field names.
Validate that filter_vertical is a sequence of field names.
def validate_filter_vertical(self, cls, model): " Validate that filter_vertical is a sequence of field names. " if hasattr(cls, 'filter_vertical'): check_isseq(cls, 'filter_vertical', cls.filter_vertical) for idx, field in enumerate(cls.filter_vertical): f = get_f...
[ "def", "validate_filter_vertical", "(", "self", ",", "cls", ",", "model", ")", ":", "if", "hasattr", "(", "cls", ",", "'filter_vertical'", ")", ":", "check_isseq", "(", "cls", ",", "'filter_vertical'", ",", "cls", ".", "filter_vertical", ")", "for", "idx", ...
[ 109, 4 ]
[ 117, 67 ]
python
en
['en', 'en', 'en']
True
BaseValidator.validate_filter_horizontal
(self, cls, model)
Validate that filter_horizontal is a sequence of field names.
Validate that filter_horizontal is a sequence of field names.
def validate_filter_horizontal(self, cls, model): " Validate that filter_horizontal is a sequence of field names. " if hasattr(cls, 'filter_horizontal'): check_isseq(cls, 'filter_horizontal', cls.filter_horizontal) for idx, field in enumerate(cls.filter_horizontal): ...
[ "def", "validate_filter_horizontal", "(", "self", ",", "cls", ",", "model", ")", ":", "if", "hasattr", "(", "cls", ",", "'filter_horizontal'", ")", ":", "check_isseq", "(", "cls", ",", "'filter_horizontal'", ",", "cls", ".", "filter_horizontal", ")", "for", ...
[ 119, 4 ]
[ 127, 67 ]
python
en
['en', 'en', 'en']
True
BaseValidator.validate_radio_fields
(self, cls, model)
Validate that radio_fields is a dictionary of choice or foreign key fields.
Validate that radio_fields is a dictionary of choice or foreign key fields.
def validate_radio_fields(self, cls, model): " Validate that radio_fields is a dictionary of choice or foreign key fields. " from django.contrib.admin.options import HORIZONTAL, VERTICAL if hasattr(cls, 'radio_fields'): check_isdict(cls, 'radio_fields', cls.radio_fields) ...
[ "def", "validate_radio_fields", "(", "self", ",", "cls", ",", "model", ")", ":", "from", "django", ".", "contrib", ".", "admin", ".", "options", "import", "HORIZONTAL", ",", "VERTICAL", "if", "hasattr", "(", "cls", ",", "'radio_fields'", ")", ":", "check_i...
[ 129, 4 ]
[ 143, 52 ]
python
en
['en', 'en', 'en']
True
BaseValidator.validate_prepopulated_fields
(self, cls, model)
Validate that prepopulated_fields if a dictionary containing allowed field types.
Validate that prepopulated_fields if a dictionary containing allowed field types.
def validate_prepopulated_fields(self, cls, model): " Validate that prepopulated_fields if a dictionary containing allowed field types. " # prepopulated_fields if hasattr(cls, 'prepopulated_fields'): check_isdict(cls, 'prepopulated_fields', cls.prepopulated_fields) for f...
[ "def", "validate_prepopulated_fields", "(", "self", ",", "cls", ",", "model", ")", ":", "# prepopulated_fields", "if", "hasattr", "(", "cls", ",", "'prepopulated_fields'", ")", ":", "check_isdict", "(", "cls", ",", "'prepopulated_fields'", ",", "cls", ".", "prep...
[ 145, 4 ]
[ 160, 92 ]
python
en
['en', 'en', 'en']
True
BaseValidator.validate_ordering
(self, cls, model)
Validate that ordering refers to existing fields or is random.
Validate that ordering refers to existing fields or is random.
def validate_ordering(self, cls, model): " Validate that ordering refers to existing fields or is random. " # ordering = None if cls.ordering: check_isseq(cls, 'ordering', cls.ordering) for idx, field in enumerate(cls.ordering): if field == '?' and len(cls...
[ "def", "validate_ordering", "(", "self", ",", "cls", ",", "model", ")", ":", "# ordering = None", "if", "cls", ".", "ordering", ":", "check_isseq", "(", "cls", ",", "'ordering'", ",", "cls", ".", "ordering", ")", "for", "idx", ",", "field", "in", "enumer...
[ 167, 4 ]
[ 186, 66 ]
python
en
['en', 'en', 'en']
True
BaseValidator.validate_readonly_fields
(self, cls, model)
Validate that readonly_fields refers to proper attribute or field.
Validate that readonly_fields refers to proper attribute or field.
def validate_readonly_fields(self, cls, model): " Validate that readonly_fields refers to proper attribute or field. " if hasattr(cls, "readonly_fields"): check_isseq(cls, "readonly_fields", cls.readonly_fields) for idx, field in enumerate(cls.readonly_fields): if...
[ "def", "validate_readonly_fields", "(", "self", ",", "cls", ",", "model", ")", ":", "if", "hasattr", "(", "cls", ",", "\"readonly_fields\"", ")", ":", "check_isseq", "(", "cls", ",", "\"readonly_fields\"", ",", "cls", ".", "readonly_fields", ")", "for", "idx...
[ 188, 4 ]
[ 203, 33 ]
python
en
['en', 'en', 'en']
True
ModelAdminValidator.validate_save_as
(self, cls, model)
Validate save_as is a boolean.
Validate save_as is a boolean.
def validate_save_as(self, cls, model): " Validate save_as is a boolean. " check_type(cls, 'save_as', bool)
[ "def", "validate_save_as", "(", "self", ",", "cls", ",", "model", ")", ":", "check_type", "(", "cls", ",", "'save_as'", ",", "bool", ")" ]
[ 207, 4 ]
[ 209, 40 ]
python
en
['en', 'en', 'en']
True
ModelAdminValidator.validate_save_on_top
(self, cls, model)
Validate save_on_top is a boolean.
Validate save_on_top is a boolean.
def validate_save_on_top(self, cls, model): " Validate save_on_top is a boolean. " check_type(cls, 'save_on_top', bool)
[ "def", "validate_save_on_top", "(", "self", ",", "cls", ",", "model", ")", ":", "check_type", "(", "cls", ",", "'save_on_top'", ",", "bool", ")" ]
[ 211, 4 ]
[ 213, 44 ]
python
en
['en', 'en', 'en']
True
ModelAdminValidator.validate_inlines
(self, cls, model)
Validate inline model admin classes.
Validate inline model admin classes.
def validate_inlines(self, cls, model): " Validate inline model admin classes. " from django.contrib.admin.options import BaseModelAdmin if hasattr(cls, 'inlines'): check_isseq(cls, 'inlines', cls.inlines) for idx, inline in enumerate(cls.inlines): if not ...
[ "def", "validate_inlines", "(", "self", ",", "cls", ",", "model", ")", ":", "from", "django", ".", "contrib", ".", "admin", ".", "options", "import", "BaseModelAdmin", "if", "hasattr", "(", "cls", ",", "'inlines'", ")", ":", "check_isseq", "(", "cls", ",...
[ 215, 4 ]
[ 231, 48 ]
python
en
['es', 'la', 'en']
False
ModelAdminValidator.check_inline
(self, cls, parent_model)
Validate inline class's fk field is not excluded.
Validate inline class's fk field is not excluded.
def check_inline(self, cls, parent_model): " Validate inline class's fk field is not excluded. " fk = _get_foreign_key(parent_model, cls.model, fk_name=cls.fk_name, can_fail=True) if hasattr(cls, 'exclude') and cls.exclude: if fk and fk.name in cls.exclude: raise Impr...
[ "def", "check_inline", "(", "self", ",", "cls", ",", "parent_model", ")", ":", "fk", "=", "_get_foreign_key", "(", "parent_model", ",", "cls", ".", "model", ",", "fk_name", "=", "cls", ".", "fk_name", ",", "can_fail", "=", "True", ")", "if", "hasattr", ...
[ 233, 4 ]
[ 240, 112 ]
python
en
['en', 'en', 'en']
True
ModelAdminValidator.validate_list_display
(self, cls, model)
Validate that list_display only contains fields or usable attributes.
Validate that list_display only contains fields or usable attributes.
def validate_list_display(self, cls, model): " Validate that list_display only contains fields or usable attributes. " if hasattr(cls, 'list_display'): check_isseq(cls, 'list_display', cls.list_display) for idx, field in enumerate(cls.list_display): if not callabl...
[ "def", "validate_list_display", "(", "self", ",", "cls", ",", "model", ")", ":", "if", "hasattr", "(", "cls", ",", "'list_display'", ")", ":", "check_isseq", "(", "cls", ",", "'list_display'", ",", "cls", ".", "list_display", ")", "for", "idx", ",", "fie...
[ 242, 4 ]
[ 266, 33 ]
python
en
['en', 'en', 'en']
True
ModelAdminValidator.validate_list_display_links
(self, cls, model)
Validate that list_display_links either is None or a unique subset of list_display.
Validate that list_display_links either is None or a unique subset of list_display.
def validate_list_display_links(self, cls, model): " Validate that list_display_links either is None or a unique subset of list_display." if hasattr(cls, 'list_display_links'): if cls.list_display_links is None: return check_isseq(cls, 'list_display_links', cls.li...
[ "def", "validate_list_display_links", "(", "self", ",", "cls", ",", "model", ")", ":", "if", "hasattr", "(", "cls", ",", "'list_display_links'", ")", ":", "if", "cls", ".", "list_display_links", "is", "None", ":", "return", "check_isseq", "(", "cls", ",", ...
[ 268, 4 ]
[ 278, 57 ]
python
en
['en', 'en', 'en']
True
ModelAdminValidator.validate_list_filter
(self, cls, model)
Validate that list_filter is a sequence of one of three options: 1: 'field' - a basic field filter, possibly w/ relationships (eg, 'field__rel') 2: ('field', SomeFieldListFilter) - a field-based list filter class 3: SomeListFilter - a non-field list filter class
Validate that list_filter is a sequence of one of three options: 1: 'field' - a basic field filter, possibly w/ relationships (eg, 'field__rel') 2: ('field', SomeFieldListFilter) - a field-based list filter class 3: SomeListFilter - a non-field list filter class
def validate_list_filter(self, cls, model): """ Validate that list_filter is a sequence of one of three options: 1: 'field' - a basic field filter, possibly w/ relationships (eg, 'field__rel') 2: ('field', SomeFieldListFilter) - a field-based list filter class 3: Some...
[ "def", "validate_list_filter", "(", "self", ",", "cls", ",", "model", ")", ":", "from", "django", ".", "contrib", ".", "admin", "import", "ListFilter", ",", "FieldListFilter", "if", "hasattr", "(", "cls", ",", "'list_filter'", ")", ":", "check_isseq", "(", ...
[ 280, 4 ]
[ 320, 61 ]
python
en
['en', 'error', 'th']
False
ModelAdminValidator.validate_list_select_related
(self, cls, model)
Validate that list_select_related is a boolean, a list or a tuple.
Validate that list_select_related is a boolean, a list or a tuple.
def validate_list_select_related(self, cls, model): " Validate that list_select_related is a boolean, a list or a tuple. " list_select_related = getattr(cls, 'list_select_related', None) if list_select_related: types = (bool, tuple, list) if not isinstance(list_select_rel...
[ "def", "validate_list_select_related", "(", "self", ",", "cls", ",", "model", ")", ":", "list_select_related", "=", "getattr", "(", "cls", ",", "'list_select_related'", ",", "None", ")", "if", "list_select_related", ":", "types", "=", "(", "bool", ",", "tuple"...
[ 322, 4 ]
[ 330, 56 ]
python
en
['en', 'en', 'en']
True
ModelAdminValidator.validate_list_per_page
(self, cls, model)
Validate that list_per_page is an integer.
Validate that list_per_page is an integer.
def validate_list_per_page(self, cls, model): " Validate that list_per_page is an integer. " check_type(cls, 'list_per_page', int)
[ "def", "validate_list_per_page", "(", "self", ",", "cls", ",", "model", ")", ":", "check_type", "(", "cls", ",", "'list_per_page'", ",", "int", ")" ]
[ 332, 4 ]
[ 334, 45 ]
python
en
['en', 'en', 'en']
True
ModelAdminValidator.validate_list_max_show_all
(self, cls, model)
Validate that list_max_show_all is an integer.
Validate that list_max_show_all is an integer.
def validate_list_max_show_all(self, cls, model): " Validate that list_max_show_all is an integer. " check_type(cls, 'list_max_show_all', int)
[ "def", "validate_list_max_show_all", "(", "self", ",", "cls", ",", "model", ")", ":", "check_type", "(", "cls", ",", "'list_max_show_all'", ",", "int", ")" ]
[ 336, 4 ]
[ 338, 49 ]
python
en
['en', 'en', 'en']
True
ModelAdminValidator.validate_list_editable
(self, cls, model)
Validate that list_editable is a sequence of editable fields from list_display without first element.
Validate that list_editable is a sequence of editable fields from list_display without first element.
def validate_list_editable(self, cls, model): """ Validate that list_editable is a sequence of editable fields from list_display without first element. """ if hasattr(cls, 'list_editable') and cls.list_editable: check_isseq(cls, 'list_editable', cls.list_editable) ...
[ "def", "validate_list_editable", "(", "self", ",", "cls", ",", "model", ")", ":", "if", "hasattr", "(", "cls", ",", "'list_editable'", ")", "and", "cls", ".", "list_editable", ":", "check_isseq", "(", "cls", ",", "'list_editable'", ",", "cls", ".", "list_e...
[ 340, 4 ]
[ 371, 58 ]
python
en
['en', 'error', 'th']
False
ModelAdminValidator.validate_search_fields
(self, cls, model)
Validate search_fields is a sequence.
Validate search_fields is a sequence.
def validate_search_fields(self, cls, model): " Validate search_fields is a sequence. " if hasattr(cls, 'search_fields'): check_isseq(cls, 'search_fields', cls.search_fields)
[ "def", "validate_search_fields", "(", "self", ",", "cls", ",", "model", ")", ":", "if", "hasattr", "(", "cls", ",", "'search_fields'", ")", ":", "check_isseq", "(", "cls", ",", "'search_fields'", ",", "cls", ".", "search_fields", ")" ]
[ 373, 4 ]
[ 376, 64 ]
python
en
['en', 'en', 'en']
True
ModelAdminValidator.validate_date_hierarchy
(self, cls, model)
Validate that date_hierarchy refers to DateField or DateTimeField.
Validate that date_hierarchy refers to DateField or DateTimeField.
def validate_date_hierarchy(self, cls, model): " Validate that date_hierarchy refers to DateField or DateTimeField. " if cls.date_hierarchy: f = get_field(cls, model, 'date_hierarchy', cls.date_hierarchy) if not isinstance(f, (models.DateField, models.DateTimeField)): ...
[ "def", "validate_date_hierarchy", "(", "self", ",", "cls", ",", "model", ")", ":", "if", "cls", ".", "date_hierarchy", ":", "f", "=", "get_field", "(", "cls", ",", "model", ",", "'date_hierarchy'", ",", "cls", ".", "date_hierarchy", ")", "if", "not", "is...
[ 378, 4 ]
[ 385, 39 ]
python
en
['en', 'en', 'en']
True
InlineValidator.validate_fk_name
(self, cls, model)
Validate that fk_name refers to a ForeignKey.
Validate that fk_name refers to a ForeignKey.
def validate_fk_name(self, cls, model): " Validate that fk_name refers to a ForeignKey. " if cls.fk_name: # default value is None f = get_field(cls, model, 'fk_name', cls.fk_name) if not isinstance(f, models.ForeignKey): raise ImproperlyConfigured("'%s.fk_name is...
[ "def", "validate_fk_name", "(", "self", ",", "cls", ",", "model", ")", ":", "if", "cls", ".", "fk_name", ":", "# default value is None", "f", "=", "get_field", "(", "cls", ",", "model", ",", "'fk_name'", ",", "cls", ".", "fk_name", ")", "if", "not", "i...
[ 389, 4 ]
[ 395, 60 ]
python
en
['en', 'en', 'en']
True
InlineValidator.validate_extra
(self, cls, model)
Validate that extra is an integer.
Validate that extra is an integer.
def validate_extra(self, cls, model): " Validate that extra is an integer. " check_type(cls, 'extra', int)
[ "def", "validate_extra", "(", "self", ",", "cls", ",", "model", ")", ":", "check_type", "(", "cls", ",", "'extra'", ",", "int", ")" ]
[ 397, 4 ]
[ 399, 37 ]
python
en
['en', 'en', 'en']
True
InlineValidator.validate_max_num
(self, cls, model)
Validate that max_num is an integer.
Validate that max_num is an integer.
def validate_max_num(self, cls, model): " Validate that max_num is an integer. " check_type(cls, 'max_num', int)
[ "def", "validate_max_num", "(", "self", ",", "cls", ",", "model", ")", ":", "check_type", "(", "cls", ",", "'max_num'", ",", "int", ")" ]
[ 401, 4 ]
[ 403, 39 ]
python
en
['en', 'en', 'en']
True
InlineValidator.validate_formset
(self, cls, model)
Validate formset is a subclass of BaseModelFormSet.
Validate formset is a subclass of BaseModelFormSet.
def validate_formset(self, cls, model): " Validate formset is a subclass of BaseModelFormSet. " if hasattr(cls, 'formset') and not issubclass(cls.formset, BaseModelFormSet): raise ImproperlyConfigured("'%s.formset' does not inherit from " "BaseModelFormSet." % cls.__name_...
[ "def", "validate_formset", "(", "self", ",", "cls", ",", "model", ")", ":", "if", "hasattr", "(", "cls", ",", "'formset'", ")", "and", "not", "issubclass", "(", "cls", ".", "formset", ",", "BaseModelFormSet", ")", ":", "raise", "ImproperlyConfigured", "(",...
[ 405, 4 ]
[ 409, 55 ]
python
en
['en', 'en', 'en']
True
Widget.format_value
(self, value)
Return a value as it should appear when rendered in a template.
Return a value as it should appear when rendered in a template.
def format_value(self, value): """ Return a value as it should appear when rendered in a template. """ if value == '' or value is None: return None if self.is_localized: return formats.localize_input(value) return str(value)
[ "def", "format_value", "(", "self", ",", "value", ")", ":", "if", "value", "==", "''", "or", "value", "is", "None", ":", "return", "None", "if", "self", ".", "is_localized", ":", "return", "formats", ".", "localize_input", "(", "value", ")", "return", ...
[ 216, 4 ]
[ 224, 25 ]
python
en
['en', 'error', 'th']
False
Widget.render
(self, name, value, attrs=None, renderer=None)
Render the widget as an HTML string.
Render the widget as an HTML string.
def render(self, name, value, attrs=None, renderer=None): """Render the widget as an HTML string.""" context = self.get_context(name, value, attrs) return self._render(self.template_name, context, renderer)
[ "def", "render", "(", "self", ",", "name", ",", "value", ",", "attrs", "=", "None", ",", "renderer", "=", "None", ")", ":", "context", "=", "self", ".", "get_context", "(", "name", ",", "value", ",", "attrs", ")", "return", "self", ".", "_render", ...
[ 238, 4 ]
[ 241, 66 ]
python
en
['en', 'lb', 'en']
True
Widget.build_attrs
(self, base_attrs, extra_attrs=None)
Build an attribute dictionary.
Build an attribute dictionary.
def build_attrs(self, base_attrs, extra_attrs=None): """Build an attribute dictionary.""" return {**base_attrs, **(extra_attrs or {})}
[ "def", "build_attrs", "(", "self", ",", "base_attrs", ",", "extra_attrs", "=", "None", ")", ":", "return", "{", "*", "*", "base_attrs", ",", "*", "*", "(", "extra_attrs", "or", "{", "}", ")", "}" ]
[ 248, 4 ]
[ 250, 52 ]
python
en
['en', 'en', 'en']
True
Widget.value_from_datadict
(self, data, files, name)
Given a dictionary of data and this widget's name, return the value of this widget or None if it's not provided.
Given a dictionary of data and this widget's name, return the value of this widget or None if it's not provided.
def value_from_datadict(self, data, files, name): """ Given a dictionary of data and this widget's name, return the value of this widget or None if it's not provided. """ return data.get(name)
[ "def", "value_from_datadict", "(", "self", ",", "data", ",", "files", ",", "name", ")", ":", "return", "data", ".", "get", "(", "name", ")" ]
[ 252, 4 ]
[ 257, 29 ]
python
en
['en', 'error', 'th']
False
Widget.id_for_label
(self, id_)
Return the HTML ID attribute of this Widget for use by a <label>, given the ID of the field. Return None if no ID is available. This hook is necessary because some widgets have multiple HTML elements and, thus, multiple IDs. In that case, this method should return an ID value t...
Return the HTML ID attribute of this Widget for use by a <label>, given the ID of the field. Return None if no ID is available.
def id_for_label(self, id_): """ Return the HTML ID attribute of this Widget for use by a <label>, given the ID of the field. Return None if no ID is available. This hook is necessary because some widgets have multiple HTML elements and, thus, multiple IDs. In that case, this me...
[ "def", "id_for_label", "(", "self", ",", "id_", ")", ":", "return", "id_" ]
[ 262, 4 ]
[ 272, 18 ]
python
en
['en', 'error', 'th']
False
FileInput.format_value
(self, value)
File input never renders a value.
File input never renders a value.
def format_value(self, value): """File input never renders a value.""" return
[ "def", "format_value", "(", "self", ",", "value", ")", ":", "return" ]
[ 378, 4 ]
[ 380, 14 ]
python
en
['hu', 'en', 'en']
True
FileInput.value_from_datadict
(self, data, files, name)
File widgets take data from FILES, not POST
File widgets take data from FILES, not POST
def value_from_datadict(self, data, files, name): "File widgets take data from FILES, not POST" return files.get(name)
[ "def", "value_from_datadict", "(", "self", ",", "data", ",", "files", ",", "name", ")", ":", "return", "files", ".", "get", "(", "name", ")" ]
[ 382, 4 ]
[ 384, 30 ]
python
en
['en', 'en', 'en']
True
ClearableFileInput.clear_checkbox_name
(self, name)
Given the name of the file input, return the name of the clear checkbox input.
Given the name of the file input, return the name of the clear checkbox input.
def clear_checkbox_name(self, name): """ Given the name of the file input, return the name of the clear checkbox input. """ return name + '-clear'
[ "def", "clear_checkbox_name", "(", "self", ",", "name", ")", ":", "return", "name", "+", "'-clear'" ]
[ 399, 4 ]
[ 404, 30 ]
python
en
['en', 'error', 'th']
False
ClearableFileInput.clear_checkbox_id
(self, name)
Given the name of the clear checkbox input, return the HTML id for it.
Given the name of the clear checkbox input, return the HTML id for it.
def clear_checkbox_id(self, name): """ Given the name of the clear checkbox input, return the HTML id for it. """ return name + '_id'
[ "def", "clear_checkbox_id", "(", "self", ",", "name", ")", ":", "return", "name", "+", "'_id'" ]
[ 406, 4 ]
[ 410, 27 ]
python
en
['en', 'error', 'th']
False
ClearableFileInput.is_initial
(self, value)
Return whether value is considered to be initial value.
Return whether value is considered to be initial value.
def is_initial(self, value): """ Return whether value is considered to be initial value. """ return bool(value and getattr(value, 'url', False))
[ "def", "is_initial", "(", "self", ",", "value", ")", ":", "return", "bool", "(", "value", "and", "getattr", "(", "value", ",", "'url'", ",", "False", ")", ")" ]
[ 412, 4 ]
[ 416, 59 ]
python
en
['en', 'error', 'th']
False
ClearableFileInput.format_value
(self, value)
Return the file object if it has a defined url attribute.
Return the file object if it has a defined url attribute.
def format_value(self, value): """ Return the file object if it has a defined url attribute. """ if self.is_initial(value): return value
[ "def", "format_value", "(", "self", ",", "value", ")", ":", "if", "self", ".", "is_initial", "(", "value", ")", ":", "return", "value" ]
[ 418, 4 ]
[ 423, 24 ]
python
en
['en', 'error', 'th']
False
CheckboxInput.format_value
(self, value)
Only return the 'value' attribute if value isn't empty.
Only return the 'value' attribute if value isn't empty.
def format_value(self, value): """Only return the 'value' attribute if value isn't empty.""" if value is True or value is False or value is None or value == '': return return str(value)
[ "def", "format_value", "(", "self", ",", "value", ")", ":", "if", "value", "is", "True", "or", "value", "is", "False", "or", "value", "is", "None", "or", "value", "==", "''", ":", "return", "return", "str", "(", "value", ")" ]
[ 516, 4 ]
[ 520, 25 ]
python
en
['en', 'en', 'en']
True
ChoiceWidget.subwidgets
(self, name, value, attrs=None)
Yield all "subwidgets" of this widget. Used to enable iterating options from a BoundField for choice widgets.
Yield all "subwidgets" of this widget. Used to enable iterating options from a BoundField for choice widgets.
def subwidgets(self, name, value, attrs=None): """ Yield all "subwidgets" of this widget. Used to enable iterating options from a BoundField for choice widgets. """ value = self.format_value(value) yield from self.options(name, value, attrs)
[ "def", "subwidgets", "(", "self", ",", "name", ",", "value", ",", "attrs", "=", "None", ")", ":", "value", "=", "self", ".", "format_value", "(", "value", ")", "yield", "from", "self", ".", "options", "(", "name", ",", "value", ",", "attrs", ")" ]
[ 568, 4 ]
[ 574, 51 ]
python
en
['en', 'error', 'th']
False
ChoiceWidget.options
(self, name, value, attrs=None)
Yield a flat list of options for this widgets.
Yield a flat list of options for this widgets.
def options(self, name, value, attrs=None): """Yield a flat list of options for this widgets.""" for group in self.optgroups(name, value, attrs): yield from group[1]
[ "def", "options", "(", "self", ",", "name", ",", "value", ",", "attrs", "=", "None", ")", ":", "for", "group", "in", "self", ".", "optgroups", "(", "name", ",", "value", ",", "attrs", ")", ":", "yield", "from", "group", "[", "1", "]" ]
[ 576, 4 ]
[ 579, 31 ]
python
en
['en', 'en', 'en']
True
ChoiceWidget.optgroups
(self, name, value, attrs=None)
Return a list of optgroups for this widget.
Return a list of optgroups for this widget.
def optgroups(self, name, value, attrs=None): """Return a list of optgroups for this widget.""" groups = [] has_selected = False for index, (option_value, option_label) in enumerate(self.choices): if option_value is None: option_value = '' subgro...
[ "def", "optgroups", "(", "self", ",", "name", ",", "value", ",", "attrs", "=", "None", ")", ":", "groups", "=", "[", "]", "has_selected", "=", "False", "for", "index", ",", "(", "option_value", ",", "option_label", ")", "in", "enumerate", "(", "self", ...
[ 581, 4 ]
[ 613, 21 ]
python
en
['en', 'en', 'en']
True
ChoiceWidget.id_for_label
(self, id_, index='0')
Use an incremented id for each option where the main widget references the zero index.
Use an incremented id for each option where the main widget references the zero index.
def id_for_label(self, id_, index='0'): """ Use an incremented id for each option where the main widget references the zero index. """ if id_ and self.add_id_index: id_ = '%s_%s' % (id_, index) return id_
[ "def", "id_for_label", "(", "self", ",", "id_", ",", "index", "=", "'0'", ")", ":", "if", "id_", "and", "self", ".", "add_id_index", ":", "id_", "=", "'%s_%s'", "%", "(", "id_", ",", "index", ")", "return", "id_" ]
[ 641, 4 ]
[ 648, 18 ]
python
en
['en', 'error', 'th']
False
ChoiceWidget.format_value
(self, value)
Return selected values as a list.
Return selected values as a list.
def format_value(self, value): """Return selected values as a list.""" if value is None and self.allow_multiple_selected: return [] if not isinstance(value, (tuple, list)): value = [value] return [str(v) if v is not None else '' for v in value]
[ "def", "format_value", "(", "self", ",", "value", ")", ":", "if", "value", "is", "None", "and", "self", ".", "allow_multiple_selected", ":", "return", "[", "]", "if", "not", "isinstance", "(", "value", ",", "(", "tuple", ",", "list", ")", ")", ":", "...
[ 659, 4 ]
[ 665, 63 ]
python
en
['en', 'en', 'en']
True
Select._choice_has_empty_value
(choice)
Return True if the choice's value is empty string or None.
Return True if the choice's value is empty string or None.
def _choice_has_empty_value(choice): """Return True if the choice's value is empty string or None.""" value, _ = choice return value is None or value == ''
[ "def", "_choice_has_empty_value", "(", "choice", ")", ":", "value", ",", "_", "=", "choice", "return", "value", "is", "None", "or", "value", "==", "''" ]
[ 683, 4 ]
[ 686, 43 ]
python
en
['en', 'en', 'en']
True
Select.use_required_attribute
(self, initial)
Don't render 'required' if the first <option> has a value, as that's invalid HTML.
Don't render 'required' if the first <option> has a value, as that's invalid HTML.
def use_required_attribute(self, initial): """ Don't render 'required' if the first <option> has a value, as that's invalid HTML. """ use_required_attribute = super().use_required_attribute(initial) # 'required' is always okay for <select multiple>. if self.allow_...
[ "def", "use_required_attribute", "(", "self", ",", "initial", ")", ":", "use_required_attribute", "=", "super", "(", ")", ".", "use_required_attribute", "(", "initial", ")", "# 'required' is always okay for <select multiple>.", "if", "self", ".", "allow_multiple_selected"...
[ 688, 4 ]
[ 699, 113 ]
python
en
['en', 'error', 'th']
False
CheckboxSelectMultiple.id_for_label
(self, id_, index=None)
Don't include for="field_0" in <label> because clicking such a label would toggle the first checkbox.
Don't include for="field_0" in <label> because clicking such a label would toggle the first checkbox.
def id_for_label(self, id_, index=None): """" Don't include for="field_0" in <label> because clicking such a label would toggle the first checkbox. """ if index is None: return '' return super().id_for_label(id_, index)
[ "def", "id_for_label", "(", "self", ",", "id_", ",", "index", "=", "None", ")", ":", "if", "index", "is", "None", ":", "return", "''", "return", "super", "(", ")", ".", "id_for_label", "(", "id_", ",", "index", ")" ]
[ 778, 4 ]
[ 785, 47 ]
python
en
['en', 'error', 'th']
False
MultiWidget.decompress
(self, value)
Return a list of decompressed values for the given compressed value. The given value can be assumed to be valid, but not necessarily non-empty.
Return a list of decompressed values for the given compressed value. The given value can be assumed to be valid, but not necessarily non-empty.
def decompress(self, value): """ Return a list of decompressed values for the given compressed value. The given value can be assumed to be valid, but not necessarily non-empty. """ raise NotImplementedError('Subclasses must implement this method.')
[ "def", "decompress", "(", "self", ",", "value", ")", ":", "raise", "NotImplementedError", "(", "'Subclasses must implement this method.'", ")" ]
[ 853, 4 ]
[ 859, 75 ]
python
en
['en', 'error', 'th']
False
MultiWidget._get_media
(self)
Media for a multiwidget is the combination of all media of the subwidgets.
Media for a multiwidget is the combination of all media of the subwidgets.
def _get_media(self): """ Media for a multiwidget is the combination of all media of the subwidgets. """ media = Media() for w in self.widgets: media = media + w.media return media
[ "def", "_get_media", "(", "self", ")", ":", "media", "=", "Media", "(", ")", "for", "w", "in", "self", ".", "widgets", ":", "media", "=", "media", "+", "w", ".", "media", "return", "media" ]
[ 861, 4 ]
[ 869, 20 ]
python
en
['en', 'error', 'th']
False
SelectDateWidget.format_value
(self, value)
Return a dict containing the year, month, and day of the current value. Use dict instead of a datetime to allow invalid dates such as February 31 to display correctly.
Return a dict containing the year, month, and day of the current value. Use dict instead of a datetime to allow invalid dates such as February 31 to display correctly.
def format_value(self, value): """ Return a dict containing the year, month, and day of the current value. Use dict instead of a datetime to allow invalid dates such as February 31 to display correctly. """ year, month, day = None, None, None if isinstance(value, ...
[ "def", "format_value", "(", "self", ",", "value", ")", ":", "year", ",", "month", ",", "day", "=", "None", ",", "None", ",", "None", "if", "isinstance", "(", "value", ",", "(", "datetime", ".", "date", ",", "datetime", ".", "datetime", ")", ")", ":...
[ 1005, 4 ]
[ 1028, 57 ]
python
en
['en', 'error', 'th']
False
CPointerBase.__del__
(self)
Free the memory used by the C++ object.
Free the memory used by the C++ object.
def __del__(self): """ Free the memory used by the C++ object. """ if self.destructor and self._ptr: try: self.destructor(self.ptr) except (AttributeError, ImportError, TypeError): pass
[ "def", "__del__", "(", "self", ")", ":", "if", "self", ".", "destructor", "and", "self", ".", "_ptr", ":", "try", ":", "self", ".", "destructor", "(", "self", ".", "ptr", ")", "except", "(", "AttributeError", ",", "ImportError", ",", "TypeError", ")", ...
[ 29, 4 ]
[ 37, 20 ]
python
en
['en', 'error', 'th']
False
get_test_image_data
(size=(32, 32), color=(250, 250, 210), format="JPEG")
Get binary image data with the given specs. :param size: Size tuple :type size: tuple[int, int] :param color: RGB color triple :type color: tuple[int, int, int] :param format: PIL image format specifier :type format: str :return: Binary data :rtype: bytes
Get binary image data with the given specs.
def get_test_image_data(size=(32, 32), color=(250, 250, 210), format="JPEG"): """ Get binary image data with the given specs. :param size: Size tuple :type size: tuple[int, int] :param color: RGB color triple :type color: tuple[int, int, int] :param format: PIL image format specifier :t...
[ "def", "get_test_image_data", "(", "size", "=", "(", "32", ",", "32", ")", ",", "color", "=", "(", "250", ",", "250", ",", "210", ")", ",", "format", "=", "\"JPEG\"", ")", ":", "img", "=", "Image", ".", "new", "(", "mode", "=", "\"RGB\"", ",", ...
[ 18, 0 ]
[ 35, 25 ]
python
en
['en', 'error', 'th']
False
create_resource_image
(resource, size=(32, 32), color=(250, 250, 210), format="JPEG", **instance_kwargs)
Create a ResourceImage object with image data with the given specs. :param resource: Resource to attach the ResourceImage to. :type resource: resources.models.Resource :param size: Size tuple :type size: tuple[int, int] :param color: RGB color triple :type color: tuple[int, int, int] :...
Create a ResourceImage object with image data with the given specs.
def create_resource_image(resource, size=(32, 32), color=(250, 250, 210), format="JPEG", **instance_kwargs): """ Create a ResourceImage object with image data with the given specs. :param resource: Resource to attach the ResourceImage to. :type resource: resources.models.Resource :param size: Size ...
[ "def", "create_resource_image", "(", "resource", ",", "size", "=", "(", "32", ",", "32", ")", ",", "color", "=", "(", "250", ",", "250", ",", "210", ")", ",", "format", "=", "\"JPEG\"", ",", "*", "*", "instance_kwargs", ")", ":", "instance_kwargs", "...
[ 38, 0 ]
[ 64, 13 ]
python
en
['en', 'error', 'th']
False
check_disallowed_methods
(api_client, urls, disallowed_methods)
Check that given urls return http 405 (or 401 for unauthenticad users) :param api_client: API client that executes the requests :type api_client: DRF APIClient :param urls: urls to check :type urls: tuple [str] :param disallowed_methods: methods that should ne disallowed :type disallowed_m...
Check that given urls return http 405 (or 401 for unauthenticad users)
def check_disallowed_methods(api_client, urls, disallowed_methods): """ Check that given urls return http 405 (or 401 for unauthenticad users) :param api_client: API client that executes the requests :type api_client: DRF APIClient :param urls: urls to check :type urls: tuple [str] :param d...
[ "def", "check_disallowed_methods", "(", "api_client", ",", "urls", ",", "disallowed_methods", ")", ":", "# endpoints return 401 instead of 405 if there is no user", "expected_status_codes", "=", "(", "401", ",", "405", ")", "if", "api_client", ".", "handler", ".", "_for...
[ 110, 0 ]
[ 126, 88 ]
python
en
['en', 'error', 'th']
False
assert_non_field_errors_contain
(response, text)
Check if any of the response's non field errors contain the given text. :type response: Response :type text: str
Check if any of the response's non field errors contain the given text.
def assert_non_field_errors_contain(response, text): """ Check if any of the response's non field errors contain the given text. :type response: Response :type text: str """ error_messages = [force_text(error_message) for error_message in response.data['non_field_errors']] assert any(text i...
[ "def", "assert_non_field_errors_contain", "(", "response", ",", "text", ")", ":", "error_messages", "=", "[", "force_text", "(", "error_message", ")", "for", "error_message", "in", "response", ".", "data", "[", "'non_field_errors'", "]", "]", "assert", "any", "(...
[ 133, 0 ]
[ 141, 73 ]
python
en
['en', 'error', 'th']
False
get_field_errors
(validation_error, field_name)
Return an individual field's validation error messages. :type validation_error: Django ValidationError :type field_name: str :rtype: list
Return an individual field's validation error messages.
def get_field_errors(validation_error, field_name): """ Return an individual field's validation error messages. :type validation_error: Django ValidationError :type field_name: str :rtype: list """ error_dict = validation_error.error_dict assert field_name in error_dict return error...
[ "def", "get_field_errors", "(", "validation_error", ",", "field_name", ")", ":", "error_dict", "=", "validation_error", ".", "error_dict", "assert", "field_name", "in", "error_dict", "return", "error_dict", "[", "field_name", "]", "[", "0", "]", ".", "messages" ]
[ 144, 0 ]
[ 154, 45 ]
python
en
['en', 'error', 'th']
False
assert_response_objects
(response, objects)
Assert object or objects exist in response data.
Assert object or objects exist in response data.
def assert_response_objects(response, objects): """ Assert object or objects exist in response data. """ data = response.data if 'results' in data: data = data['results'] if not (isinstance(objects, list) or isinstance(objects, tuple)): objects = [objects] expected_ids = {o...
[ "def", "assert_response_objects", "(", "response", ",", "objects", ")", ":", "data", "=", "response", ".", "data", "if", "'results'", "in", "data", ":", "data", "=", "data", "[", "'results'", "]", "if", "not", "(", "isinstance", "(", "objects", ",", "lis...
[ 174, 0 ]
[ 188, 88 ]
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): """ 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. """ installed = {} for p in pkg_re...
[ "def", "search_packages_info", "(", "query", ")", ":", "installed", "=", "{", "}", "for", "p", "in", "pkg_resources", ".", "working_set", ":", "installed", "[", "canonicalize_name", "(", "p", ".", "project_name", ")", "]", "=", "p", "query_names", "=", "["...
[ 54, 0 ]
[ 139, 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): """ Print the information from installed distributions found. """ results_printed = False for i, dist in enumerate(distributions): results_printed = True if i > 0: write_output("---") write_output...
[ "def", "print_results", "(", "distributions", ",", "list_files", "=", "False", ",", "verbose", "=", "False", ")", ":", "results_printed", "=", "False", "for", "i", ",", "dist", "in", "enumerate", "(", "distributions", ")", ":", "results_printed", "=", "True"...
[ 142, 0 ]
[ 179, 26 ]
python
en
['en', 'error', 'th']
False
lookupEncoding
(encoding)
Return the python codec name corresponding to an encoding or None if the string doesn't correspond to a valid encoding.
Return the python codec name corresponding to an encoding or None if the string doesn't correspond to a valid encoding.
def lookupEncoding(encoding): """Return the python codec name corresponding to an encoding or None if the string doesn't correspond to a valid encoding.""" if isinstance(encoding, binary_type): try: encoding = encoding.decode("ascii") except UnicodeDecodeError: return...
[ "def", "lookupEncoding", "(", "encoding", ")", ":", "if", "isinstance", "(", "encoding", ",", "binary_type", ")", ":", "try", ":", "encoding", "=", "encoding", ".", "decode", "(", "\"ascii\"", ")", "except", "UnicodeDecodeError", ":", "return", "None", "if",...
[ 907, 0 ]
[ 922, 19 ]
python
en
['en', 'en', 'en']
True
HTMLUnicodeInputStream.__init__
(self, source)
Initialises the HTMLInputStream. HTMLInputStream(source, [encoding]) -> Normalized stream from source for use by html5lib. source can be either a file-object, local filename or a string. The optional encoding parameter must be a string that indicates the encoding. If specifie...
Initialises the HTMLInputStream.
def __init__(self, source): """Initialises the HTMLInputStream. HTMLInputStream(source, [encoding]) -> Normalized stream from source for use by html5lib. source can be either a file-object, local filename or a string. The optional encoding parameter must be a string that indic...
[ "def", "__init__", "(", "self", ",", "source", ")", ":", "if", "not", "_utils", ".", "supports_lone_surrogates", ":", "# Such platforms will have already checked for such", "# surrogate errors, so no need to do this checking.", "self", ".", "reportCharacterErrors", "=", "None...
[ 163, 4 ]
[ 193, 20 ]
python
en
['en', 'sn', 'en']
True
HTMLUnicodeInputStream.openStream
(self, source)
Produces a file object from source. source can be either a file object, local filename or a string.
Produces a file object from source.
def openStream(self, source): """Produces a file object from source. source can be either a file object, local filename or a string. """ # Already a file object if hasattr(source, 'read'): stream = source else: stream = StringIO(source) ...
[ "def", "openStream", "(", "self", ",", "source", ")", ":", "# Already a file object", "if", "hasattr", "(", "source", ",", "'read'", ")", ":", "stream", "=", "source", "else", ":", "stream", "=", "StringIO", "(", "source", ")", "return", "stream" ]
[ 209, 4 ]
[ 221, 21 ]
python
en
['en', 'en', 'en']
True
HTMLUnicodeInputStream.position
(self)
Returns (line, col) of the current position in the stream.
Returns (line, col) of the current position in the stream.
def position(self): """Returns (line, col) of the current position in the stream.""" line, col = self._position(self.chunkOffset) return (line + 1, col)
[ "def", "position", "(", "self", ")", ":", "line", ",", "col", "=", "self", ".", "_position", "(", "self", ".", "chunkOffset", ")", "return", "(", "line", "+", "1", ",", "col", ")" ]
[ 234, 4 ]
[ 237, 30 ]
python
en
['en', 'en', 'en']
True
HTMLUnicodeInputStream.char
(self)
Read one character from the stream or queue if available. Return EOF when EOF is reached.
Read one character from the stream or queue if available. Return EOF when EOF is reached.
def char(self): """ Read one character from the stream or queue if available. Return EOF when EOF is reached. """ # Read a new chunk from the input stream if necessary if self.chunkOffset >= self.chunkSize: if not self.readChunk(): return EOF ...
[ "def", "char", "(", "self", ")", ":", "# Read a new chunk from the input stream if necessary", "if", "self", ".", "chunkOffset", ">=", "self", ".", "chunkSize", ":", "if", "not", "self", ".", "readChunk", "(", ")", ":", "return", "EOF", "chunkOffset", "=", "se...
[ 239, 4 ]
[ 252, 19 ]
python
en
['en', 'en', 'en']
True
HTMLUnicodeInputStream.charsUntil
(self, characters, opposite=False)
Returns a string of characters from the stream up to but not including any character in 'characters' or EOF. 'characters' must be a container that supports the 'in' method and iteration over its characters.
Returns a string of characters from the stream up to but not including any character in 'characters' or EOF. 'characters' must be a container that supports the 'in' method and iteration over its characters.
def charsUntil(self, characters, opposite=False): """ Returns a string of characters from the stream up to but not including any character in 'characters' or EOF. 'characters' must be a container that supports the 'in' method and iteration over its characters. """ # Use ...
[ "def", "charsUntil", "(", "self", ",", "characters", ",", "opposite", "=", "False", ")", ":", "# Use a cache of regexps to find the required characters", "try", ":", "chars", "=", "charsUntilRegEx", "[", "(", "characters", ",", "opposite", ")", "]", "except", "Key...
[ 319, 4 ]
[ 364, 16 ]
python
en
['en', 'en', 'en']
True
HTMLBinaryInputStream.__init__
(self, source, override_encoding=None, transport_encoding=None, same_origin_parent_encoding=None, likely_encoding=None, default_encoding="windows-1252", useChardet=True)
Initialises the HTMLInputStream. HTMLInputStream(source, [encoding]) -> Normalized stream from source for use by html5lib. source can be either a file-object, local filename or a string. The optional encoding parameter must be a string that indicates the encoding. If specifie...
Initialises the HTMLInputStream.
def __init__(self, source, override_encoding=None, transport_encoding=None, same_origin_parent_encoding=None, likely_encoding=None, default_encoding="windows-1252", useChardet=True): """Initialises the HTMLInputStream. HTMLInputStream(source, [encoding]) -> Normalized ...
[ "def", "__init__", "(", "self", ",", "source", ",", "override_encoding", "=", "None", ",", "transport_encoding", "=", "None", ",", "same_origin_parent_encoding", "=", "None", ",", "likely_encoding", "=", "None", ",", "default_encoding", "=", "\"windows-1252\"", ",...
[ 391, 4 ]
[ 431, 20 ]
python
en
['en', 'sn', 'en']
True
HTMLBinaryInputStream.openStream
(self, source)
Produces a file object from source. source can be either a file object, local filename or a string.
Produces a file object from source.
def openStream(self, source): """Produces a file object from source. source can be either a file object, local filename or a string. """ # Already a file object if hasattr(source, 'read'): stream = source else: stream = BytesIO(source) t...
[ "def", "openStream", "(", "self", ",", "source", ")", ":", "# Already a file object", "if", "hasattr", "(", "source", ",", "'read'", ")", ":", "stream", "=", "source", "else", ":", "stream", "=", "BytesIO", "(", "source", ")", "try", ":", "stream", ".", ...
[ 437, 4 ]
[ 454, 21 ]
python
en
['en', 'en', 'en']
True
HTMLBinaryInputStream.detectBOM
(self)
Attempts to detect at BOM at the start of the stream. If an encoding can be determined from the BOM return the name of the encoding otherwise return None
Attempts to detect at BOM at the start of the stream. If an encoding can be determined from the BOM return the name of the encoding otherwise return None
def detectBOM(self): """Attempts to detect at BOM at the start of the stream. If an encoding can be determined from the BOM return the name of the encoding otherwise return None""" bomDict = { codecs.BOM_UTF8: 'utf-8', codecs.BOM_UTF16_LE: 'utf-16le', codecs.BOM_U...
[ "def", "detectBOM", "(", "self", ")", ":", "bomDict", "=", "{", "codecs", ".", "BOM_UTF8", ":", "'utf-8'", ",", "codecs", ".", "BOM_UTF16_LE", ":", "'utf-16le'", ",", "codecs", ".", "BOM_UTF16_BE", ":", "'utf-16be'", ",", "codecs", ".", "BOM_UTF32_LE", ":"...
[ 534, 4 ]
[ 566, 23 ]
python
en
['en', 'en', 'en']
True
HTMLBinaryInputStream.detectEncodingMeta
(self)
Report the encoding declared by the meta element
Report the encoding declared by the meta element
def detectEncodingMeta(self): """Report the encoding declared by the meta element """ buffer = self.rawStream.read(self.numBytesMeta) assert isinstance(buffer, bytes) parser = EncodingParser(buffer) self.rawStream.seek(0) encoding = parser.getEncoding() i...
[ "def", "detectEncodingMeta", "(", "self", ")", ":", "buffer", "=", "self", ".", "rawStream", ".", "read", "(", "self", ".", "numBytesMeta", ")", "assert", "isinstance", "(", "buffer", ",", "bytes", ")", "parser", "=", "EncodingParser", "(", "buffer", ")", ...
[ 568, 4 ]
[ 580, 23 ]
python
en
['en', 'en', 'en']
True
EncodingBytes.skip
(self, chars=spaceCharactersBytes)
Skip past a list of characters
Skip past a list of characters
def skip(self, chars=spaceCharactersBytes): """Skip past a list of characters""" p = self.position # use property for the error-checking while p < len(self): c = self[p:p + 1] if c not in chars: self._position = p return c ...
[ "def", "skip", "(", "self", ",", "chars", "=", "spaceCharactersBytes", ")", ":", "p", "=", "self", ".", "position", "# use property for the error-checking", "while", "p", "<", "len", "(", "self", ")", ":", "c", "=", "self", "[", "p", ":", "p", "+", "1"...
[ 639, 4 ]
[ 649, 19 ]
python
en
['en', 'en', 'en']
True