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
list_intersection
(list1, list2)
Take the not-in-place intersection of two lists, similar to sets but preserving order. Does not check unicity of list1.
Take the not-in-place intersection of two lists, similar to sets but preserving order. Does not check unicity of list1.
def list_intersection(list1, list2): """ Take the not-in-place intersection of two lists, similar to sets but preserving order. Does not check unicity of list1. """ return [item for item in list1 if item in list2]
[ "def", "list_intersection", "(", "list1", ",", "list2", ")", ":", "return", "[", "item", "for", "item", "in", "list1", "if", "item", "in", "list2", "]" ]
[ 172, 0 ]
[ 177, 52 ]
python
en
['en', 'ja', 'th']
False
list_difference
(left, right)
Take the not-in-place difference of two lists (left - right), similar to sets but preserving order.
Take the not-in-place difference of two lists (left - right), similar to sets but preserving order.
def list_difference(left, right): """ Take the not-in-place difference of two lists (left - right), similar to sets but preserving order. """ blocked = set(right) difference = [] for item in left: if item not in blocked: blocked.add(item) difference.appen...
[ "def", "list_difference", "(", "left", ",", "right", ")", ":", "blocked", "=", "set", "(", "right", ")", "difference", "=", "[", "]", "for", "item", "in", "left", ":", "if", "item", "not", "in", "blocked", ":", "blocked", ".", "add", "(", "item", "...
[ 180, 0 ]
[ 190, 21 ]
python
en
['en', 'ja', 'th']
False
load_images
(input_dir, batch_shape)
Read png images from input directory in batches. Args: input_dir: input directory batch_shape: shape of minibatch array, i.e. [batch_size, height, width, 3] Yields: filenames: list file names without path of each image Lenght of this list could be less than batch_size, in this case o...
Read png images from input directory in batches.
def load_images(input_dir, batch_shape): """Read png images from input directory in batches. Args: input_dir: input directory batch_shape: shape of minibatch array, i.e. [batch_size, height, width, 3] Yields: filenames: list file names without path of each image Lenght of this li...
[ "def", "load_images", "(", "input_dir", ",", "batch_shape", ")", ":", "images", "=", "np", ".", "zeros", "(", "batch_shape", ")", "filenames", "=", "[", "]", "idx", "=", "0", "batch_size", "=", "batch_shape", "[", "0", "]", "for", "filepath", "in", "tf...
[ 40, 0 ]
[ 70, 31 ]
python
en
['en', 'en', 'en']
True
main
(_)
Run the sample defense
Run the sample defense
def main(_): """Run the sample defense""" batch_shape = [FLAGS.batch_size, FLAGS.image_height, FLAGS.image_width, 3] nb_classes = 1001 tf.logging.set_verbosity(tf.logging.INFO) with tf.Graph().as_default(): # Prepare graph x_input = tf.placeholder(tf.float32, shape=batch_shape) ...
[ "def", "main", "(", "_", ")", ":", "batch_shape", "=", "[", "FLAGS", ".", "batch_size", ",", "FLAGS", ".", "image_height", ",", "FLAGS", ".", "image_width", ",", "3", "]", "nb_classes", "=", "1001", "tf", ".", "logging", ".", "set_verbosity", "(", "tf"...
[ 73, 0 ]
[ 104, 75 ]
python
en
['en', 'ms', 'en']
True
BaseDatabaseFeatures.supports_explaining_query_execution
(self)
Does this backend support explaining query execution?
Does this backend support explaining query execution?
def supports_explaining_query_execution(self): """Does this backend support explaining query execution?""" return self.connection.ops.explain_prefix is not None
[ "def", "supports_explaining_query_execution", "(", "self", ")", ":", "return", "self", ".", "connection", ".", "ops", ".", "explain_prefix", "is", "not", "None" ]
[ 299, 4 ]
[ 301, 61 ]
python
en
['en', 'en', 'en']
True
BaseDatabaseFeatures.supports_transactions
(self)
Confirm support for transactions.
Confirm support for transactions.
def supports_transactions(self): """Confirm support for transactions.""" with self.connection.cursor() as cursor: cursor.execute('CREATE TABLE ROLLBACK_TEST (X INT)') self.connection.set_autocommit(False) cursor.execute('INSERT INTO ROLLBACK_TEST (X) VALUES (8)') ...
[ "def", "supports_transactions", "(", "self", ")", ":", "with", "self", ".", "connection", ".", "cursor", "(", ")", "as", "cursor", ":", "cursor", ".", "execute", "(", "'CREATE TABLE ROLLBACK_TEST (X INT)'", ")", "self", ".", "connection", ".", "set_autocommit", ...
[ 304, 4 ]
[ 315, 25 ]
python
en
['en', 'en', 'en']
True
parse_bits
(parser, bits, params, varargs, varkw, defaults, kwonly, kwonly_defaults, takes_context, name)
Parse bits for template tag helpers simple_tag and inclusion_tag, in particular by detecting syntax errors and by extracting positional and keyword arguments.
Parse bits for template tag helpers simple_tag and inclusion_tag, in particular by detecting syntax errors and by extracting positional and keyword arguments.
def parse_bits(parser, bits, params, varargs, varkw, defaults, kwonly, kwonly_defaults, takes_context, name): """ Parse bits for template tag helpers simple_tag and inclusion_tag, in particular by detecting syntax errors and by extracting positional and keyword arguments. """ if t...
[ "def", "parse_bits", "(", "parser", ",", "bits", ",", "params", ",", "varargs", ",", "varkw", ",", "defaults", ",", "kwonly", ",", "kwonly_defaults", ",", "takes_context", ",", "name", ")", ":", "if", "takes_context", ":", "if", "params", "[", "0", "]", ...
[ 236, 0 ]
[ 308, 23 ]
python
en
['en', 'error', 'th']
False
import_library
(name)
Load a Library object from a template tag module.
Load a Library object from a template tag module.
def import_library(name): """ Load a Library object from a template tag module. """ try: module = import_module(name) except ImportError as e: raise InvalidTemplateLibrary( "Invalid template library specified. ImportError raised when " "trying to load '%s': %s...
[ "def", "import_library", "(", "name", ")", ":", "try", ":", "module", "=", "import_module", "(", "name", ")", "except", "ImportError", "as", "e", ":", "raise", "InvalidTemplateLibrary", "(", "\"Invalid template library specified. ImportError raised when \"", "\"trying t...
[ 311, 0 ]
[ 327, 9 ]
python
en
['en', 'error', 'th']
False
Library.filter
(self, name=None, filter_func=None, **flags)
Register a callable as a template filter. Example: @register.filter def lower(value): return value.lower()
Register a callable as a template filter. Example:
def filter(self, name=None, filter_func=None, **flags): """ Register a callable as a template filter. Example: @register.filter def lower(value): return value.lower() """ if name is None and filter_func is None: # @register.filter() de...
[ "def", "filter", "(", "self", ",", "name", "=", "None", ",", "filter_func", "=", "None", ",", "*", "*", "flags", ")", ":", "if", "name", "is", "None", "and", "filter_func", "is", "None", ":", "# @register.filter()", "def", "dec", "(", "func", ")", ":...
[ 53, 4 ]
[ 93, 13 ]
python
en
['en', 'error', 'th']
False
Library.simple_tag
(self, func=None, takes_context=None, name=None)
Register a callable as a compiled template tag. Example: @register.simple_tag def hello(*args, **kwargs): return 'world'
Register a callable as a compiled template tag. Example:
def simple_tag(self, func=None, takes_context=None, name=None): """ Register a callable as a compiled template tag. Example: @register.simple_tag def hello(*args, **kwargs): return 'world' """ def dec(func): params, varargs, varkw, defaults, kwonl...
[ "def", "simple_tag", "(", "self", ",", "func", "=", "None", ",", "takes_context", "=", "None", ",", "name", "=", "None", ")", ":", "def", "dec", "(", "func", ")", ":", "params", ",", "varargs", ",", "varkw", ",", "defaults", ",", "kwonly", ",", "kw...
[ 99, 4 ]
[ 133, 72 ]
python
en
['en', 'error', 'th']
False
Library.inclusion_tag
(self, filename, func=None, takes_context=None, name=None)
Register a callable as an inclusion tag: @register.inclusion_tag('results.html') def show_results(poll): choices = poll.choice_set.all() return {'choices': choices}
Register a callable as an inclusion tag:
def inclusion_tag(self, filename, func=None, takes_context=None, name=None): """ Register a callable as an inclusion tag: @register.inclusion_tag('results.html') def show_results(poll): choices = poll.choice_set.all() return {'choices': choices} """ ...
[ "def", "inclusion_tag", "(", "self", ",", "filename", ",", "func", "=", "None", ",", "takes_context", "=", "None", ",", "name", "=", "None", ")", ":", "def", "dec", "(", "func", ")", ":", "params", ",", "varargs", ",", "varkw", ",", "defaults", ",", ...
[ 135, 4 ]
[ 160, 18 ]
python
en
['en', 'error', 'th']
False
InclusionNode.render
(self, context)
Render the specified template and context. Cache the template object in render_context to avoid reparsing and loading when used in a for loop.
Render the specified template and context. Cache the template object in render_context to avoid reparsing and loading when used in a for loop.
def render(self, context): """ Render the specified template and context. Cache the template object in render_context to avoid reparsing and loading when used in a for loop. """ resolved_args, resolved_kwargs = self.get_resolved_arguments(context) _dict = self.fun...
[ "def", "render", "(", "self", ",", "context", ")", ":", "resolved_args", ",", "resolved_kwargs", "=", "self", ".", "get_resolved_arguments", "(", "context", ")", "_dict", "=", "self", ".", "func", "(", "*", "resolved_args", ",", "*", "*", "resolved_kwargs", ...
[ 206, 4 ]
[ 233, 36 ]
python
en
['en', 'error', 'th']
False
load
(f, _dict=dict, decoder=None)
Parses named file or files as toml and returns a dictionary Args: f: Path to the file to open, array of files to read into single dict or a file descriptor _dict: (optional) Specifies the class of the returned toml dictionary Returns: Parsed toml file represented as a dictio...
Parses named file or files as toml and returns a dictionary
def load(f, _dict=dict, decoder=None): """Parses named file or files as toml and returns a dictionary Args: f: Path to the file to open, array of files to read into single dict or a file descriptor _dict: (optional) Specifies the class of the returned toml dictionary Returns: ...
[ "def", "load", "(", "f", ",", "_dict", "=", "dict", ",", "decoder", "=", "None", ")", ":", "if", "_ispath", "(", "f", ")", ":", "with", "io", ".", "open", "(", "_getpath", "(", "f", ")", ",", "encoding", "=", "'utf-8'", ")", "as", "ffile", ":",...
[ 91, 0 ]
[ 136, 35 ]
python
en
['en', 'en', 'en']
True
loads
(s, _dict=dict, decoder=None)
Parses string as toml Args: s: String to be parsed _dict: (optional) Specifies the class of the returned toml dictionary Returns: Parsed toml file represented as a dictionary Raises: TypeError: When a non-string is passed TomlDecodeError: Error while decoding toml ...
Parses string as toml
def loads(s, _dict=dict, decoder=None): """Parses string as toml Args: s: String to be parsed _dict: (optional) Specifies the class of the returned toml dictionary Returns: Parsed toml file represented as a dictionary Raises: TypeError: When a non-string is passed ...
[ "def", "loads", "(", "s", ",", "_dict", "=", "dict", ",", "decoder", "=", "None", ")", ":", "implicitgroups", "=", "[", "]", "if", "decoder", "is", "None", ":", "decoder", "=", "TomlDecoder", "(", "_dict", ")", "retval", "=", "decoder", ".", "get_emp...
[ 142, 0 ]
[ 460, 17 ]
python
en
['en', 'en', 'en']
True
_unescape
(v)
Unescape characters in a TOML string.
Unescape characters in a TOML string.
def _unescape(v): """Unescape characters in a TOML string.""" i = 0 backslash = False while i < len(v): if backslash: backslash = False if v[i] in _escapes: v = v[:i - 1] + _escape_to_escapedchars[v[i]] + v[i + 1:] elif v[i] == '\\': ...
[ "def", "_unescape", "(", "v", ")", ":", "i", "=", "0", "backslash", "=", "False", "while", "i", "<", "len", "(", "v", ")", ":", "if", "backslash", ":", "backslash", "=", "False", "if", "v", "[", "i", "]", "in", "_escapes", ":", "v", "=", "v", ...
[ 552, 0 ]
[ 571, 12 ]
python
en
['en', 'en', 'en']
True
GenericForeignKeyTests.test_unsaved_instance_on_generic_foreign_key
(self)
#10811 -- Assigning an unsaved object to GenericForeignKey should raise an exception.
#10811 -- Assigning an unsaved object to GenericForeignKey should raise an exception.
def test_unsaved_instance_on_generic_foreign_key(self): """ #10811 -- Assigning an unsaved object to GenericForeignKey should raise an exception. """ class Model(models.Model): content_type = models.ForeignKey(ContentType, null=True) object_id = models.Pos...
[ "def", "test_unsaved_instance_on_generic_foreign_key", "(", "self", ")", ":", "class", "Model", "(", "models", ".", "Model", ")", ":", "content_type", "=", "models", ".", "ForeignKey", "(", "ContentType", ",", "null", "=", "True", ")", "object_id", "=", "model...
[ 215, 4 ]
[ 234, 37 ]
python
en
['en', 'error', 'th']
False
UpdateContentTypesTests.test_interactive_true
(self)
interactive mode of update_contenttypes() (the default) should delete stale contenttypes.
interactive mode of update_contenttypes() (the default) should delete stale contenttypes.
def test_interactive_true(self): """ interactive mode of update_contenttypes() (the default) should delete stale contenttypes. """ management.input = lambda x: force_str("yes") management.update_contenttypes(self.app_config) self.assertIn("Deleting stale content t...
[ "def", "test_interactive_true", "(", "self", ")", ":", "management", ".", "input", "=", "lambda", "x", ":", "force_str", "(", "\"yes\"", ")", "management", ".", "update_contenttypes", "(", "self", ".", "app_config", ")", "self", ".", "assertIn", "(", "\"Dele...
[ 375, 4 ]
[ 383, 72 ]
python
en
['en', 'error', 'th']
False
UpdateContentTypesTests.test_interactive_false
(self)
non-interactive mode of update_contenttypes() shouldn't delete stale content types.
non-interactive mode of update_contenttypes() shouldn't delete stale content types.
def test_interactive_false(self): """ non-interactive mode of update_contenttypes() shouldn't delete stale content types. """ management.update_contenttypes(self.app_config, interactive=False) self.assertIn("Stale content types remain.", sys.stdout.getvalue()) sel...
[ "def", "test_interactive_false", "(", "self", ")", ":", "management", ".", "update_contenttypes", "(", "self", ".", "app_config", ",", "interactive", "=", "False", ")", "self", ".", "assertIn", "(", "\"Stale content types remain.\"", ",", "sys", ".", "stdout", "...
[ 385, 4 ]
[ 392, 76 ]
python
en
['en', 'error', 'th']
False
ContentTypesMultidbTestCase.test_multidb
(self)
Test that, when using multiple databases, we use the db_for_read (see #20401).
Test that, when using multiple databases, we use the db_for_read (see #20401).
def test_multidb(self): """ Test that, when using multiple databases, we use the db_for_read (see #20401). """ ContentType.objects.clear_cache() with self.assertNumQueries(0, using='default'), \ self.assertNumQueries(1, using='other'): Content...
[ "def", "test_multidb", "(", "self", ")", ":", "ContentType", ".", "objects", ".", "clear_cache", "(", ")", "with", "self", ".", "assertNumQueries", "(", "0", ",", "using", "=", "'default'", ")", ",", "self", ".", "assertNumQueries", "(", "1", ",", "using...
[ 420, 4 ]
[ 429, 53 ]
python
en
['en', 'error', 'th']
False
modify_WORKSPACE
(wksp, distro_path)
Update the WORKSPACE file in the example to point to our locally-built tar.gz This allows users to clone rules_python, cd into the example/dir, and run the example directly, while our integration tests use the locally-built copy. Args: wksp: filesystem absolute path of the bazel WORKSPACE file unde...
Update the WORKSPACE file in the example to point to our locally-built tar.gz This allows users to clone rules_python, cd into the example/dir, and run the example directly, while our integration tests use the locally-built copy.
def modify_WORKSPACE(wksp, distro_path): """Update the WORKSPACE file in the example to point to our locally-built tar.gz This allows users to clone rules_python, cd into the example/dir, and run the example directly, while our integration tests use the locally-built copy. Args: wksp: filesyste...
[ "def", "modify_WORKSPACE", "(", "wksp", ",", "distro_path", ")", ":", "with", "open", "(", "wksp", ",", "'r'", ")", "as", "wksp_file", ":", "content", "=", "wksp_file", ".", "read", "(", ")", "# Replace the url for rules_python with our locally built one", "conten...
[ 13, 0 ]
[ 33, 32 ]
python
en
['en', 'en', 'en']
True
PyPIRCCommand._get_rc_file
(self)
Returns rc file path.
Returns rc file path.
def _get_rc_file(self): """Returns rc file path.""" return os.path.join(os.path.expanduser('~'), '.pypirc')
[ "def", "_get_rc_file", "(", "self", ")", ":", "return", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "expanduser", "(", "'~'", ")", ",", "'.pypirc'", ")" ]
[ 37, 4 ]
[ 39, 63 ]
python
en
['fr', 'ja', 'en']
False
PyPIRCCommand._store_pypirc
(self, username, password)
Creates a default .pypirc file.
Creates a default .pypirc file.
def _store_pypirc(self, username, password): """Creates a default .pypirc file.""" rc = self._get_rc_file() with os.fdopen(os.open(rc, os.O_CREAT | os.O_WRONLY, 0o600), 'w') as f: f.write(DEFAULT_PYPIRC % (username, password))
[ "def", "_store_pypirc", "(", "self", ",", "username", ",", "password", ")", ":", "rc", "=", "self", ".", "_get_rc_file", "(", ")", "with", "os", ".", "fdopen", "(", "os", ".", "open", "(", "rc", ",", "os", ".", "O_CREAT", "|", "os", ".", "O_WRONLY"...
[ 41, 4 ]
[ 45, 58 ]
python
en
['es', 'fr', 'en']
False
PyPIRCCommand._read_pypirc
(self)
Reads the .pypirc file.
Reads the .pypirc file.
def _read_pypirc(self): """Reads the .pypirc file.""" rc = self._get_rc_file() if os.path.exists(rc): self.announce('Using PyPI login from %s' % rc) repository = self.repository or self.DEFAULT_REPOSITORY config = RawConfigParser() config.read(rc)...
[ "def", "_read_pypirc", "(", "self", ")", ":", "rc", "=", "self", ".", "_get_rc_file", "(", ")", "if", "os", ".", "path", ".", "exists", "(", "rc", ")", ":", "self", ".", "announce", "(", "'Using PyPI login from %s'", "%", "rc", ")", "repository", "=", ...
[ 47, 4 ]
[ 109, 17 ]
python
en
['en', 'en', 'en']
True
PyPIRCCommand._read_pypi_response
(self, response)
Read and decode a PyPI HTTP response.
Read and decode a PyPI HTTP response.
def _read_pypi_response(self, response): """Read and decode a PyPI HTTP response.""" import cgi content_type = response.getheader('content-type', 'text/plain') encoding = cgi.parse_header(content_type)[1].get('charset', 'ascii') return response.read().decode(encoding)
[ "def", "_read_pypi_response", "(", "self", ",", "response", ")", ":", "import", "cgi", "content_type", "=", "response", ".", "getheader", "(", "'content-type'", ",", "'text/plain'", ")", "encoding", "=", "cgi", ".", "parse_header", "(", "content_type", ")", "[...
[ 111, 4 ]
[ 116, 47 ]
python
en
['en', 'en', 'en']
True
PyPIRCCommand.initialize_options
(self)
Initialize options.
Initialize options.
def initialize_options(self): """Initialize options.""" self.repository = None self.realm = None self.show_response = 0
[ "def", "initialize_options", "(", "self", ")", ":", "self", ".", "repository", "=", "None", "self", ".", "realm", "=", "None", "self", ".", "show_response", "=", "0" ]
[ 118, 4 ]
[ 122, 30 ]
python
en
['en', 'en', 'en']
False
PyPIRCCommand.finalize_options
(self)
Finalizes options.
Finalizes options.
def finalize_options(self): """Finalizes options.""" if self.repository is None: self.repository = self.DEFAULT_REPOSITORY if self.realm is None: self.realm = self.DEFAULT_REALM
[ "def", "finalize_options", "(", "self", ")", ":", "if", "self", ".", "repository", "is", "None", ":", "self", ".", "repository", "=", "self", ".", "DEFAULT_REPOSITORY", "if", "self", ".", "realm", "is", "None", ":", "self", ".", "realm", "=", "self", "...
[ 124, 4 ]
[ 129, 43 ]
python
en
['en', 'en', 'en']
False
Feature.__init__
(self, feat, layer)
Initializes Feature from a pointer and its Layer object.
Initializes Feature from a pointer and its Layer object.
def __init__(self, feat, layer): """ Initializes Feature from a pointer and its Layer object. """ if not feat: raise OGRException('Cannot create OGR Feature, invalid pointer given.') self.ptr = feat self._layer = layer
[ "def", "__init__", "(", "self", ",", "feat", ",", "layer", ")", ":", "if", "not", "feat", ":", "raise", "OGRException", "(", "'Cannot create OGR Feature, invalid pointer given.'", ")", "self", ".", "ptr", "=", "feat", "self", ".", "_layer", "=", "layer" ]
[ 25, 4 ]
[ 32, 27 ]
python
en
['en', 'error', 'th']
False
Feature.__del__
(self)
Releases a reference to this object.
Releases a reference to this object.
def __del__(self): "Releases a reference to this object." if self._ptr and capi: capi.destroy_feature(self._ptr)
[ "def", "__del__", "(", "self", ")", ":", "if", "self", ".", "_ptr", "and", "capi", ":", "capi", ".", "destroy_feature", "(", "self", ".", "_ptr", ")" ]
[ 34, 4 ]
[ 37, 43 ]
python
en
['en', 'en', 'en']
True
Feature.__getitem__
(self, index)
Gets the Field object at the specified index, which may be either an integer or the Field's string label. Note that the Field object is not the field's _value_ -- use the `get` method instead to retrieve the value (e.g. an integer) instead of a Field instance.
Gets the Field object at the specified index, which may be either an integer or the Field's string label. Note that the Field object is not the field's _value_ -- use the `get` method instead to retrieve the value (e.g. an integer) instead of a Field instance.
def __getitem__(self, index): """ Gets the Field object at the specified index, which may be either an integer or the Field's string label. Note that the Field object is not the field's _value_ -- use the `get` method instead to retrieve the value (e.g. an integer) instead of a ...
[ "def", "__getitem__", "(", "self", ",", "index", ")", ":", "if", "isinstance", "(", "index", ",", "six", ".", "string_types", ")", ":", "i", "=", "self", ".", "index", "(", "index", ")", "else", ":", "if", "index", "<", "0", "or", "index", ">", "...
[ 39, 4 ]
[ 52, 29 ]
python
en
['en', 'error', 'th']
False
Feature.__iter__
(self)
Iterates over each field in the Feature.
Iterates over each field in the Feature.
def __iter__(self): "Iterates over each field in the Feature." for i in xrange(self.num_fields): yield self[i]
[ "def", "__iter__", "(", "self", ")", ":", "for", "i", "in", "xrange", "(", "self", ".", "num_fields", ")", ":", "yield", "self", "[", "i", "]" ]
[ 54, 4 ]
[ 57, 25 ]
python
en
['en', 'en', 'en']
True
Feature.__len__
(self)
Returns the count of fields in this feature.
Returns the count of fields in this feature.
def __len__(self): "Returns the count of fields in this feature." return self.num_fields
[ "def", "__len__", "(", "self", ")", ":", "return", "self", ".", "num_fields" ]
[ 59, 4 ]
[ 61, 30 ]
python
en
['en', 'en', 'en']
True
Feature.__str__
(self)
The string name of the feature.
The string name of the feature.
def __str__(self): "The string name of the feature." return 'Feature FID %d in Layer<%s>' % (self.fid, self.layer_name)
[ "def", "__str__", "(", "self", ")", ":", "return", "'Feature FID %d in Layer<%s>'", "%", "(", "self", ".", "fid", ",", "self", ".", "layer_name", ")" ]
[ 63, 4 ]
[ 65, 74 ]
python
en
['en', 'en', 'en']
True
Feature.__eq__
(self, other)
Does equivalence testing on the features.
Does equivalence testing on the features.
def __eq__(self, other): "Does equivalence testing on the features." return bool(capi.feature_equal(self.ptr, other._ptr))
[ "def", "__eq__", "(", "self", ",", "other", ")", ":", "return", "bool", "(", "capi", ".", "feature_equal", "(", "self", ".", "ptr", ",", "other", ".", "_ptr", ")", ")" ]
[ 67, 4 ]
[ 69, 61 ]
python
en
['en', 'en', 'en']
True
Feature.fid
(self)
Returns the feature identifier.
Returns the feature identifier.
def fid(self): "Returns the feature identifier." return capi.get_fid(self.ptr)
[ "def", "fid", "(", "self", ")", ":", "return", "capi", ".", "get_fid", "(", "self", ".", "ptr", ")" ]
[ 77, 4 ]
[ 79, 37 ]
python
en
['en', 'en', 'en']
True
Feature.layer_name
(self)
Returns the name of the layer for the feature.
Returns the name of the layer for the feature.
def layer_name(self): "Returns the name of the layer for the feature." name = capi.get_feat_name(self._layer._ldefn) return force_text(name, self.encoding, strings_only=True)
[ "def", "layer_name", "(", "self", ")", ":", "name", "=", "capi", ".", "get_feat_name", "(", "self", ".", "_layer", ".", "_ldefn", ")", "return", "force_text", "(", "name", ",", "self", ".", "encoding", ",", "strings_only", "=", "True", ")" ]
[ 82, 4 ]
[ 85, 65 ]
python
en
['en', 'en', 'en']
True
Feature.num_fields
(self)
Returns the number of fields in the Feature.
Returns the number of fields in the Feature.
def num_fields(self): "Returns the number of fields in the Feature." return capi.get_feat_field_count(self.ptr)
[ "def", "num_fields", "(", "self", ")", ":", "return", "capi", ".", "get_feat_field_count", "(", "self", ".", "ptr", ")" ]
[ 88, 4 ]
[ 90, 50 ]
python
en
['en', 'en', 'en']
True
Feature.fields
(self)
Returns a list of fields in the Feature.
Returns a list of fields in the Feature.
def fields(self): "Returns a list of fields in the Feature." return [capi.get_field_name(capi.get_field_defn(self._layer._ldefn, i)) for i in xrange(self.num_fields)]
[ "def", "fields", "(", "self", ")", ":", "return", "[", "capi", ".", "get_field_name", "(", "capi", ".", "get_field_defn", "(", "self", ".", "_layer", ".", "_ldefn", ",", "i", ")", ")", "for", "i", "in", "xrange", "(", "self", ".", "num_fields", ")", ...
[ 93, 4 ]
[ 96, 49 ]
python
en
['en', 'en', 'en']
True
Feature.geom
(self)
Returns the OGR Geometry for this Feature.
Returns the OGR Geometry for this Feature.
def geom(self): "Returns the OGR Geometry for this Feature." # Retrieving the geometry pointer for the feature. geom_ptr = capi.get_feat_geom_ref(self.ptr) return OGRGeometry(geom_api.clone_geom(geom_ptr))
[ "def", "geom", "(", "self", ")", ":", "# Retrieving the geometry pointer for the feature.", "geom_ptr", "=", "capi", ".", "get_feat_geom_ref", "(", "self", ".", "ptr", ")", "return", "OGRGeometry", "(", "geom_api", ".", "clone_geom", "(", "geom_ptr", ")", ")" ]
[ 99, 4 ]
[ 103, 57 ]
python
en
['en', 'en', 'en']
True
Feature.geom_type
(self)
Returns the OGR Geometry Type for this Feture.
Returns the OGR Geometry Type for this Feture.
def geom_type(self): "Returns the OGR Geometry Type for this Feture." return OGRGeomType(capi.get_fd_geom_type(self._layer._ldefn))
[ "def", "geom_type", "(", "self", ")", ":", "return", "OGRGeomType", "(", "capi", ".", "get_fd_geom_type", "(", "self", ".", "_layer", ".", "_ldefn", ")", ")" ]
[ 106, 4 ]
[ 108, 69 ]
python
en
['en', 'en', 'en']
True
Feature.get
(self, field)
Returns the value of the field, instead of an instance of the Field object. May take a string of the field name or a Field object as parameters.
Returns the value of the field, instead of an instance of the Field object. May take a string of the field name or a Field object as parameters.
def get(self, field): """ Returns the value of the field, instead of an instance of the Field object. May take a string of the field name or a Field object as parameters. """ field_name = getattr(field, 'name', field) return self[field_name].value
[ "def", "get", "(", "self", ",", "field", ")", ":", "field_name", "=", "getattr", "(", "field", ",", "'name'", ",", "field", ")", "return", "self", "[", "field_name", "]", ".", "value" ]
[ 111, 4 ]
[ 118, 37 ]
python
en
['en', 'error', 'th']
False
Feature.index
(self, field_name)
Returns the index of the given field name.
Returns the index of the given field name.
def index(self, field_name): "Returns the index of the given field name." i = capi.get_field_index(self.ptr, force_bytes(field_name)) if i < 0: raise OGRIndexError('invalid OFT field name given: "%s"' % field_name) return i
[ "def", "index", "(", "self", ",", "field_name", ")", ":", "i", "=", "capi", ".", "get_field_index", "(", "self", ".", "ptr", ",", "force_bytes", "(", "field_name", ")", ")", "if", "i", "<", "0", ":", "raise", "OGRIndexError", "(", "'invalid OFT field nam...
[ 120, 4 ]
[ 125, 16 ]
python
en
['en', 'en', 'en']
True
matches_patterns
(path, patterns=None)
Return True or False depending on whether the ``path`` should be ignored (if it matches any pattern in ``ignore_patterns``).
Return True or False depending on whether the ``path`` should be ignored (if it matches any pattern in ``ignore_patterns``).
def matches_patterns(path, patterns=None): """ Return True or False depending on whether the ``path`` should be ignored (if it matches any pattern in ``ignore_patterns``). """ return any(fnmatch.fnmatchcase(path, pattern) for pattern in (patterns or []))
[ "def", "matches_patterns", "(", "path", ",", "patterns", "=", "None", ")", ":", "return", "any", "(", "fnmatch", ".", "fnmatchcase", "(", "path", ",", "pattern", ")", "for", "pattern", "in", "(", "patterns", "or", "[", "]", ")", ")" ]
[ 7, 0 ]
[ 12, 82 ]
python
en
['en', 'error', 'th']
False
get_files
(storage, ignore_patterns=None, location='')
Recursively walk the storage directories yielding the paths of all files that should be copied.
Recursively walk the storage directories yielding the paths of all files that should be copied.
def get_files(storage, ignore_patterns=None, location=''): """ Recursively walk the storage directories yielding the paths of all files that should be copied. """ if ignore_patterns is None: ignore_patterns = [] directories, files = storage.listdir(location) for fn in files: ...
[ "def", "get_files", "(", "storage", ",", "ignore_patterns", "=", "None", ",", "location", "=", "''", ")", ":", "if", "ignore_patterns", "is", "None", ":", "ignore_patterns", "=", "[", "]", "directories", ",", "files", "=", "storage", ".", "listdir", "(", ...
[ 15, 0 ]
[ 38, 59 ]
python
en
['en', 'error', 'th']
False
check_settings
(base_url=None)
Check if the staticfiles settings have sane values.
Check if the staticfiles settings have sane values.
def check_settings(base_url=None): """ Check if the staticfiles settings have sane values. """ if base_url is None: base_url = settings.STATIC_URL if not base_url: raise ImproperlyConfigured( "You're using the staticfiles app " "without having set the required...
[ "def", "check_settings", "(", "base_url", "=", "None", ")", ":", "if", "base_url", "is", "None", ":", "base_url", "=", "settings", ".", "STATIC_URL", "if", "not", "base_url", ":", "raise", "ImproperlyConfigured", "(", "\"You're using the staticfiles app \"", "\"wi...
[ 41, 0 ]
[ 62, 73 ]
python
en
['en', 'error', 'th']
False
MultipleObjectMixin.get_queryset
(self)
Return the list of items for this view. The return value must be an iterable and may be an instance of `QuerySet` in which case `QuerySet` specific behavior will be enabled.
Return the list of items for this view.
def get_queryset(self): """ Return the list of items for this view. The return value must be an iterable and may be an instance of `QuerySet` in which case `QuerySet` specific behavior will be enabled. """ if self.queryset is not None: queryset = self.queryse...
[ "def", "get_queryset", "(", "self", ")", ":", "if", "self", ".", "queryset", "is", "not", "None", ":", "queryset", "=", "self", ".", "queryset", "if", "isinstance", "(", "queryset", ",", "QuerySet", ")", ":", "queryset", "=", "queryset", ".", "all", "(...
[ 25, 4 ]
[ 52, 23 ]
python
en
['en', 'error', 'th']
False
MultipleObjectMixin.get_ordering
(self)
Return the field or fields to use for ordering the queryset.
Return the field or fields to use for ordering the queryset.
def get_ordering(self): """ Return the field or fields to use for ordering the queryset. """ return self.ordering
[ "def", "get_ordering", "(", "self", ")", ":", "return", "self", ".", "ordering" ]
[ 54, 4 ]
[ 58, 28 ]
python
en
['en', 'error', 'th']
False
MultipleObjectMixin.paginate_queryset
(self, queryset, page_size)
Paginate the queryset, if needed.
Paginate the queryset, if needed.
def paginate_queryset(self, queryset, page_size): """ Paginate the queryset, if needed. """ paginator = self.get_paginator( queryset, page_size, orphans=self.get_paginate_orphans(), allow_empty_first_page=self.get_allow_empty()) page_kwarg = self.page_kwar...
[ "def", "paginate_queryset", "(", "self", ",", "queryset", ",", "page_size", ")", ":", "paginator", "=", "self", ".", "get_paginator", "(", "queryset", ",", "page_size", ",", "orphans", "=", "self", ".", "get_paginate_orphans", "(", ")", ",", "allow_empty_first...
[ 60, 4 ]
[ 83, 14 ]
python
en
['en', 'error', 'th']
False
MultipleObjectMixin.get_paginate_by
(self, queryset)
Get the number of items to paginate by, or ``None`` for no pagination.
Get the number of items to paginate by, or ``None`` for no pagination.
def get_paginate_by(self, queryset): """ Get the number of items to paginate by, or ``None`` for no pagination. """ return self.paginate_by
[ "def", "get_paginate_by", "(", "self", ",", "queryset", ")", ":", "return", "self", ".", "paginate_by" ]
[ 85, 4 ]
[ 89, 31 ]
python
en
['en', 'error', 'th']
False
MultipleObjectMixin.get_paginator
(self, queryset, per_page, orphans=0, allow_empty_first_page=True, **kwargs)
Return an instance of the paginator for this view.
Return an instance of the paginator for this view.
def get_paginator(self, queryset, per_page, orphans=0, allow_empty_first_page=True, **kwargs): """ Return an instance of the paginator for this view. """ return self.paginator_class( queryset, per_page, orphans=orphans, allow_empty_first_page...
[ "def", "get_paginator", "(", "self", ",", "queryset", ",", "per_page", ",", "orphans", "=", "0", ",", "allow_empty_first_page", "=", "True", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "paginator_class", "(", "queryset", ",", "per_page", ",",...
[ 91, 4 ]
[ 98, 68 ]
python
en
['en', 'error', 'th']
False
MultipleObjectMixin.get_paginate_orphans
(self)
Returns the maximum number of orphans extend the last page by when paginating.
Returns the maximum number of orphans extend the last page by when paginating.
def get_paginate_orphans(self): """ Returns the maximum number of orphans extend the last page by when paginating. """ return self.paginate_orphans
[ "def", "get_paginate_orphans", "(", "self", ")", ":", "return", "self", ".", "paginate_orphans" ]
[ 100, 4 ]
[ 105, 36 ]
python
en
['en', 'error', 'th']
False
MultipleObjectMixin.get_allow_empty
(self)
Returns ``True`` if the view should display empty lists, and ``False`` if a 404 should be raised instead.
Returns ``True`` if the view should display empty lists, and ``False`` if a 404 should be raised instead.
def get_allow_empty(self): """ Returns ``True`` if the view should display empty lists, and ``False`` if a 404 should be raised instead. """ return self.allow_empty
[ "def", "get_allow_empty", "(", "self", ")", ":", "return", "self", ".", "allow_empty" ]
[ 107, 4 ]
[ 112, 31 ]
python
en
['en', 'error', 'th']
False
MultipleObjectMixin.get_context_object_name
(self, object_list)
Get the name of the item to be used in the context.
Get the name of the item to be used in the context.
def get_context_object_name(self, object_list): """ Get the name of the item to be used in the context. """ if self.context_object_name: return self.context_object_name elif hasattr(object_list, 'model'): return '%s_list' % object_list.model._meta.model_na...
[ "def", "get_context_object_name", "(", "self", ",", "object_list", ")", ":", "if", "self", ".", "context_object_name", ":", "return", "self", ".", "context_object_name", "elif", "hasattr", "(", "object_list", ",", "'model'", ")", ":", "return", "'%s_list'", "%",...
[ 114, 4 ]
[ 123, 23 ]
python
en
['en', 'error', 'th']
False
MultipleObjectMixin.get_context_data
(self, **kwargs)
Get the context for this view.
Get the context for this view.
def get_context_data(self, **kwargs): """ Get the context for this view. """ queryset = kwargs.pop('object_list', self.object_list) page_size = self.get_paginate_by(queryset) context_object_name = self.get_context_object_name(queryset) if page_size: pa...
[ "def", "get_context_data", "(", "self", ",", "*", "*", "kwargs", ")", ":", "queryset", "=", "kwargs", ".", "pop", "(", "'object_list'", ",", "self", ".", "object_list", ")", "page_size", "=", "self", ".", "get_paginate_by", "(", "queryset", ")", "context_o...
[ 125, 4 ]
[ 150, 75 ]
python
en
['en', 'error', 'th']
False
MultipleObjectTemplateResponseMixin.get_template_names
(self)
Return a list of template names to be used for the request. Must return a list. May not be called if render_to_response is overridden.
Return a list of template names to be used for the request. Must return a list. May not be called if render_to_response is overridden.
def get_template_names(self): """ Return a list of template names to be used for the request. Must return a list. May not be called if render_to_response is overridden. """ try: names = super(MultipleObjectTemplateResponseMixin, self).get_template_names() exce...
[ "def", "get_template_names", "(", "self", ")", ":", "try", ":", "names", "=", "super", "(", "MultipleObjectTemplateResponseMixin", ",", "self", ")", ".", "get_template_names", "(", ")", "except", "ImproperlyConfigured", ":", "# If template_name isn't specified, it's not...
[ 183, 4 ]
[ 203, 20 ]
python
en
['en', 'error', 'th']
False
BaseEngine.__init__
(self, params)
Initialize the template engine. `params` is a dict of configuration settings.
Initialize the template engine.
def __init__(self, params): """ Initialize the template engine. `params` is a dict of configuration settings. """ params = params.copy() self.name = params.pop('NAME') self.dirs = list(params.pop('DIRS')) self.app_dirs = params.pop('APP_DIRS') if ...
[ "def", "__init__", "(", "self", ",", "params", ")", ":", "params", "=", "params", ".", "copy", "(", ")", "self", ".", "name", "=", "params", ".", "pop", "(", "'NAME'", ")", "self", ".", "dirs", "=", "list", "(", "params", ".", "pop", "(", "'DIRS'...
[ 13, 4 ]
[ 25, 67 ]
python
en
['en', 'error', 'th']
False
BaseEngine.from_string
(self, template_code)
Create and return a template for the given source code. This method is optional.
Create and return a template for the given source code.
def from_string(self, template_code): """ Create and return a template for the given source code. This method is optional. """ raise NotImplementedError( "subclasses of BaseEngine should provide " "a from_string() method")
[ "def", "from_string", "(", "self", ",", "template_code", ")", ":", "raise", "NotImplementedError", "(", "\"subclasses of BaseEngine should provide \"", "\"a from_string() method\"", ")" ]
[ 33, 4 ]
[ 41, 37 ]
python
en
['en', 'error', 'th']
False
BaseEngine.get_template
(self, template_name)
Load and return a template for the given name. Raise TemplateDoesNotExist if no such template exists.
Load and return a template for the given name.
def get_template(self, template_name): """ Load and return a template for the given name. Raise TemplateDoesNotExist if no such template exists. """ raise NotImplementedError( "subclasses of BaseEngine must provide " "a get_template() method")
[ "def", "get_template", "(", "self", ",", "template_name", ")", ":", "raise", "NotImplementedError", "(", "\"subclasses of BaseEngine must provide \"", "\"a get_template() method\"", ")" ]
[ 43, 4 ]
[ 51, 38 ]
python
en
['en', 'error', 'th']
False
BaseEngine.template_dirs
(self)
Return a list of directories to search for templates.
Return a list of directories to search for templates.
def template_dirs(self): """ Return a list of directories to search for templates. """ # Immutable return value because it's cached and shared by callers. template_dirs = tuple(self.dirs) if self.app_dirs: template_dirs += get_app_template_dirs(self.app_dirnam...
[ "def", "template_dirs", "(", "self", ")", ":", "# Immutable return value because it's cached and shared by callers.", "template_dirs", "=", "tuple", "(", "self", ".", "dirs", ")", "if", "self", ".", "app_dirs", ":", "template_dirs", "+=", "get_app_template_dirs", "(", ...
[ 57, 4 ]
[ 65, 28 ]
python
en
['en', 'error', 'th']
False
BaseEngine.iter_template_filenames
(self, template_name)
Iterate over candidate files for template_name. Ignore files that don't lie inside configured template dirs to avoid directory traversal attacks.
Iterate over candidate files for template_name.
def iter_template_filenames(self, template_name): """ Iterate over candidate files for template_name. Ignore files that don't lie inside configured template dirs to avoid directory traversal attacks. """ for template_dir in self.template_dirs: try: ...
[ "def", "iter_template_filenames", "(", "self", ",", "template_name", ")", ":", "for", "template_dir", "in", "self", ".", "template_dirs", ":", "try", ":", "yield", "safe_join", "(", "template_dir", ",", "template_name", ")", "except", "SuspiciousFileOperation", ":...
[ 67, 4 ]
[ 80, 20 ]
python
en
['en', 'error', 'th']
False
FieldsTests.test_charfield_length_not_int
(self)
Ensure that setting min_length or max_length to something that is not a number returns an exception.
Ensure that setting min_length or max_length to something that is not a number returns an exception.
def test_charfield_length_not_int(self): """ Ensure that setting min_length or max_length to something that is not a number returns an exception. """ self.assertRaises(ValueError, CharField, min_length='a') self.assertRaises(ValueError, CharField, max_length='a') ...
[ "def", "test_charfield_length_not_int", "(", "self", ")", ":", "self", ".", "assertRaises", "(", "ValueError", ",", "CharField", ",", "min_length", "=", "'a'", ")", "self", ".", "assertRaises", "(", "ValueError", ",", "CharField", ",", "max_length", "=", "'a'"...
[ 141, 4 ]
[ 148, 53 ]
python
en
['en', 'error', 'th']
False
FieldsTests.test_charfield_widget_attrs
(self)
Ensure that CharField.widget_attrs() always returns a dictionary. Refs #15912
Ensure that CharField.widget_attrs() always returns a dictionary. Refs #15912
def test_charfield_widget_attrs(self): """ Ensure that CharField.widget_attrs() always returns a dictionary. Refs #15912 """ # Return an empty dictionary if max_length is None f = CharField() self.assertEqual(f.widget_attrs(TextInput()), {}) self.assertEqu...
[ "def", "test_charfield_widget_attrs", "(", "self", ")", ":", "# Return an empty dictionary if max_length is None", "f", "=", "CharField", "(", ")", "self", ".", "assertEqual", "(", "f", ".", "widget_attrs", "(", "TextInput", "(", ")", ")", ",", "{", "}", ")", ...
[ 150, 4 ]
[ 164, 73 ]
python
en
['en', 'error', 'th']
False
FieldsTests.test_integerfield_localized
(self)
Make sure localized IntegerField's widget renders to a text input with no number input specific attributes.
Make sure localized IntegerField's widget renders to a text input with no number input specific attributes.
def test_integerfield_localized(self): """ Make sure localized IntegerField's widget renders to a text input with no number input specific attributes. """ f1 = IntegerField(localize=True) self.assertWidgetRendersTo(f1, '<input id="id_f" name="f" type="text" />')
[ "def", "test_integerfield_localized", "(", "self", ")", ":", "f1", "=", "IntegerField", "(", "localize", "=", "True", ")", "self", ".", "assertWidgetRendersTo", "(", "f1", ",", "'<input id=\"id_f\" name=\"f\" type=\"text\" />'", ")" ]
[ 241, 4 ]
[ 247, 82 ]
python
en
['en', 'error', 'th']
False
FieldsTests.test_integerfield_subclass
(self)
Test that class-defined widget is not overwritten by __init__ (#22245).
Test that class-defined widget is not overwritten by __init__ (#22245).
def test_integerfield_subclass(self): """ Test that class-defined widget is not overwritten by __init__ (#22245). """ class MyIntegerField(IntegerField): widget = Textarea f = MyIntegerField() self.assertEqual(f.widget.__class__, Textarea) f = MyInteg...
[ "def", "test_integerfield_subclass", "(", "self", ")", ":", "class", "MyIntegerField", "(", "IntegerField", ")", ":", "widget", "=", "Textarea", "f", "=", "MyIntegerField", "(", ")", "self", ".", "assertEqual", "(", "f", ".", "widget", ".", "__class__", ",",...
[ 249, 4 ]
[ 259, 54 ]
python
en
['en', 'error', 'th']
False
FieldsTests.test_floatfield_localized
(self)
Make sure localized FloatField's widget renders to a text input with no number input specific attributes.
Make sure localized FloatField's widget renders to a text input with no number input specific attributes.
def test_floatfield_localized(self): """ Make sure localized FloatField's widget renders to a text input with no number input specific attributes. """ f = FloatField(localize=True) self.assertWidgetRendersTo(f, '<input id="id_f" name="f" type="text" />')
[ "def", "test_floatfield_localized", "(", "self", ")", ":", "f", "=", "FloatField", "(", "localize", "=", "True", ")", "self", ".", "assertWidgetRendersTo", "(", "f", ",", "'<input id=\"id_f\" name=\"f\" type=\"text\" />'", ")" ]
[ 307, 4 ]
[ 313, 81 ]
python
en
['en', 'error', 'th']
False
FieldsTests.test_decimalfield_localized
(self)
Make sure localized DecimalField's widget renders to a text input with no number input specific attributes.
Make sure localized DecimalField's widget renders to a text input with no number input specific attributes.
def test_decimalfield_localized(self): """ Make sure localized DecimalField's widget renders to a text input with no number input specific attributes. """ f = DecimalField(localize=True) self.assertWidgetRendersTo(f, '<input id="id_f" name="f" type="text" />')
[ "def", "test_decimalfield_localized", "(", "self", ")", ":", "f", "=", "DecimalField", "(", "localize", "=", "True", ")", "self", ".", "assertWidgetRendersTo", "(", "f", ",", "'<input id=\"id_f\" name=\"f\" type=\"text\" />'", ")" ]
[ 420, 4 ]
[ 426, 81 ]
python
en
['en', 'error', 'th']
False
FieldsTests.test_datefield_strptime
(self)
Test that field.strptime doesn't raise an UnicodeEncodeError (#16123)
Test that field.strptime doesn't raise an UnicodeEncodeError (#16123)
def test_datefield_strptime(self): """Test that field.strptime doesn't raise an UnicodeEncodeError (#16123)""" f = DateField() try: f.strptime('31 мая 2011', '%d-%b-%y') except Exception as e: # assertIsInstance or assertRaises cannot be used because UnicodeEncode...
[ "def", "test_datefield_strptime", "(", "self", ")", ":", "f", "=", "DateField", "(", ")", "try", ":", "f", ".", "strptime", "(", "'31 мая 2011', '", "%", "-%b-%y')", "", "except", "Exception", "as", "e", ":", "# assertIsInstance or assertRaises cannot be used beca...
[ 502, 4 ]
[ 510, 53 ]
python
en
['en', 'lb', 'en']
True
FieldsTests.test_regexfield_6
(self)
Ensure that it works with unicode characters. Refs #.
Ensure that it works with unicode characters. Refs #.
def test_regexfield_6(self): """ Ensure that it works with unicode characters. Refs #. """ f = RegexField('^\w+$') self.assertEqual('éèøçÎÎ你好', f.clean('éèøçÎÎ你好'))
[ "def", "test_regexfield_6", "(", "self", ")", ":", "f", "=", "RegexField", "(", "'^\\w+$'", ")", "self", ".", "assertEqual", "(", "'éèøçÎÎ你好', f.clean(", "'", "è", "ø", "çÎÎ你好", "'", "))", "", "" ]
[ 655, 4 ]
[ 661, 77 ]
python
en
['en', 'error', 'th']
False
FieldsTests.test_filefield_changed
(self)
Test for the behavior of has_changed for FileField. The value of data will more than likely come from request.FILES. The value of initial data will likely be a filename stored in the database. Since its value is of no use to a FileField it is ignored.
Test for the behavior of has_changed for FileField. The value of data will more than likely come from request.FILES. The value of initial data will likely be a filename stored in the database. Since its value is of no use to a FileField it is ignored.
def test_filefield_changed(self): ''' Test for the behavior of has_changed for FileField. The value of data will more than likely come from request.FILES. The value of initial data will likely be a filename stored in the database. Since its value is of no use to a FileField it is...
[ "def", "test_filefield_changed", "(", "self", ")", ":", "f", "=", "FileField", "(", ")", "# No file was uploaded and no initial data.", "self", ".", "assertFalse", "(", "f", ".", "has_changed", "(", "''", ",", "None", ")", ")", "# A file was uploaded and no initial ...
[ 736, 4 ]
[ 756, 104 ]
python
en
['en', 'error', 'th']
False
FieldsTests.test_urlfield_10
(self)
Test URLField correctly validates IPv6 (#18779).
Test URLField correctly validates IPv6 (#18779).
def test_urlfield_10(self): """Test URLField correctly validates IPv6 (#18779).""" f = URLField() urls = ( 'http://::/', 'http://6:21b4:92/', 'http://[12:34:3a53]/', 'http://[a34:9238::]:8080/', ) for url in urls: self.a...
[ "def", "test_urlfield_10", "(", "self", ")", ":", "f", "=", "URLField", "(", ")", "urls", "=", "(", "'http://::/'", ",", "'http://6:21b4:92/'", ",", "'http://[12:34:3a53]/'", ",", "'http://[a34:9238::]:8080/'", ",", ")", "for", "url", "in", "urls", ":", "self"...
[ 870, 4 ]
[ 880, 47 ]
python
en
['en', 'zu', 'en']
True
FieldsTests.test_typedchoicefield_special_coerce
(self)
Test a coerce function which results in a value not present in choices. Refs #21397.
Test a coerce function which results in a value not present in choices. Refs #21397.
def test_typedchoicefield_special_coerce(self): """ Test a coerce function which results in a value not present in choices. Refs #21397. """ def coerce_func(val): return Decimal('1.%s' % val) f = TypedChoiceField(choices=[(1, "1"), (2, "2")], coerce=coerce_fu...
[ "def", "test_typedchoicefield_special_coerce", "(", "self", ")", ":", "def", "coerce_func", "(", "val", ")", ":", "return", "Decimal", "(", "'1.%s'", "%", "val", ")", "f", "=", "TypedChoiceField", "(", "choices", "=", "[", "(", "1", ",", "\"1\"", ")", ",...
[ 1006, 4 ]
[ 1020, 25 ]
python
en
['en', 'error', 'th']
False
FieldsTests.test_typedmultiplechoicefield_special_coerce
(self)
Test a coerce function which results in a value not present in choices. Refs #21397.
Test a coerce function which results in a value not present in choices. Refs #21397.
def test_typedmultiplechoicefield_special_coerce(self): """ Test a coerce function which results in a value not present in choices. Refs #21397. """ def coerce_func(val): return Decimal('1.%s' % val) f = TypedMultipleChoiceField( choices=[(1, "1")...
[ "def", "test_typedmultiplechoicefield_special_coerce", "(", "self", ")", ":", "def", "coerce_func", "(", "val", ")", ":", "return", "Decimal", "(", "'1.%s'", "%", "val", ")", "f", "=", "TypedMultipleChoiceField", "(", "choices", "=", "[", "(", "1", ",", "\"1...
[ 1178, 4 ]
[ 1193, 27 ]
python
en
['en', 'error', 'th']
False
dev_version
()
Returns a hexdigest of all the python files in the module.
Returns a hexdigest of all the python files in the module.
def dev_version(): """ Returns a hexdigest of all the python files in the module. """ md5_hash = hashlib.md5() py_files = sorted(list_files(suffix=".py")) if not py_files: return "" for filename in py_files: with open(filename, "rb") as fobj: content = fobj.read(...
[ "def", "dev_version", "(", ")", ":", "md5_hash", "=", "hashlib", ".", "md5", "(", ")", "py_files", "=", "sorted", "(", "list_files", "(", "suffix", "=", "\".py\"", ")", ")", "if", "not", "py_files", ":", "return", "\"\"", "for", "filename", "in", "py_f...
[ 10, 0 ]
[ 23, 31 ]
python
en
['en', 'error', 'th']
False
append_dev_version
(release_version)
If dev version is not empty appends it to release_version.
If dev version is not empty appends it to release_version.
def append_dev_version(release_version): """ If dev version is not empty appends it to release_version. """ dev_version_value = dev_version() if dev_version_value: return release_version + "-" + dev_version_value else: return release_version
[ "def", "append_dev_version", "(", "release_version", ")", ":", "dev_version_value", "=", "dev_version", "(", ")", "if", "dev_version_value", ":", "return", "release_version", "+", "\"-\"", "+", "dev_version_value", "else", ":", "return", "release_version" ]
[ 26, 0 ]
[ 35, 30 ]
python
en
['en', 'error', 'th']
False
normalize_together
(option_together)
option_together can be either a tuple of tuples, or a single tuple of two strings. Normalize it to a tuple of tuples, so that calling code can uniformly expect that.
option_together can be either a tuple of tuples, or a single tuple of two strings. Normalize it to a tuple of tuples, so that calling code can uniformly expect that.
def normalize_together(option_together): """ option_together can be either a tuple of tuples, or a single tuple of two strings. Normalize it to a tuple of tuples, so that calling code can uniformly expect that. """ try: if not option_together: return () if not isinsta...
[ "def", "normalize_together", "(", "option_together", ")", ":", "try", ":", "if", "not", "option_together", ":", "return", "(", ")", "if", "not", "isinstance", "(", "option_together", ",", "(", "tuple", ",", "list", ")", ")", ":", "raise", "TypeError", "fir...
[ 25, 0 ]
[ 44, 30 ]
python
en
['en', 'error', 'th']
False
env_func
(f, argtypes)
For getting OGREnvelopes.
For getting OGREnvelopes.
def env_func(f, argtypes): "For getting OGREnvelopes." f.argtypes = argtypes f.restype = None f.errcheck = check_envelope return f
[ "def", "env_func", "(", "f", ",", "argtypes", ")", ":", "f", ".", "argtypes", "=", "argtypes", "f", ".", "restype", "=", "None", "f", ".", "errcheck", "=", "check_envelope", "return", "f" ]
[ 9, 0 ]
[ 14, 12 ]
python
de
['de', 'no', 'en']
False
pnt_func
(f)
For accessing point information.
For accessing point information.
def pnt_func(f): "For accessing point information." return double_output(f, [c_void_p, c_int])
[ "def", "pnt_func", "(", "f", ")", ":", "return", "double_output", "(", "f", ",", "[", "c_void_p", ",", "c_int", "]", ")" ]
[ 17, 0 ]
[ 19, 46 ]
python
en
['en', 'en', 'en']
True
LiveServerViews.test_404
(self)
Ensure that the LiveServerTestCase serves 404s. Refs #2879.
Ensure that the LiveServerTestCase serves 404s. Refs #2879.
def test_404(self): """ Ensure that the LiveServerTestCase serves 404s. Refs #2879. """ try: self.urlopen('/') except HTTPError as err: self.assertEqual(err.code, 404, 'Expected 404 response') else: self.fail('Expected 404 respo...
[ "def", "test_404", "(", "self", ")", ":", "try", ":", "self", ".", "urlopen", "(", "'/'", ")", "except", "HTTPError", "as", "err", ":", "self", ".", "assertEqual", "(", "err", ".", "code", ",", "404", ",", "'Expected 404 response'", ")", "else", ":", ...
[ 111, 4 ]
[ 121, 46 ]
python
en
['en', 'error', 'th']
False
LiveServerViews.test_view
(self)
Ensure that the LiveServerTestCase serves views. Refs #2879.
Ensure that the LiveServerTestCase serves views. Refs #2879.
def test_view(self): """ Ensure that the LiveServerTestCase serves views. Refs #2879. """ f = self.urlopen('/example_view/') self.assertEqual(f.read(), b'example view')
[ "def", "test_view", "(", "self", ")", ":", "f", "=", "self", ".", "urlopen", "(", "'/example_view/'", ")", "self", ".", "assertEqual", "(", "f", ".", "read", "(", ")", ",", "b'example view'", ")" ]
[ 123, 4 ]
[ 129, 51 ]
python
en
['en', 'error', 'th']
False
LiveServerViews.test_static_files
(self)
Ensure that the LiveServerTestCase serves static files. Refs #2879.
Ensure that the LiveServerTestCase serves static files. Refs #2879.
def test_static_files(self): """ Ensure that the LiveServerTestCase serves static files. Refs #2879. """ f = self.urlopen('/static/example_static_file.txt') self.assertEqual(f.read().rstrip(b'\r\n'), b'example static file')
[ "def", "test_static_files", "(", "self", ")", ":", "f", "=", "self", ".", "urlopen", "(", "'/static/example_static_file.txt'", ")", "self", ".", "assertEqual", "(", "f", ".", "read", "(", ")", ".", "rstrip", "(", "b'\\r\\n'", ")", ",", "b'example static file...
[ 131, 4 ]
[ 137, 74 ]
python
en
['en', 'error', 'th']
False
LiveServerViews.test_no_collectstatic_emulation
(self)
Test that LiveServerTestCase reports a 404 status code when HTTP client tries to access a static file that isn't explicitly put under STATIC_ROOT.
Test that LiveServerTestCase reports a 404 status code when HTTP client tries to access a static file that isn't explicitly put under STATIC_ROOT.
def test_no_collectstatic_emulation(self): """ Test that LiveServerTestCase reports a 404 status code when HTTP client tries to access a static file that isn't explicitly put under STATIC_ROOT. """ try: self.urlopen('/static/another_app/another_app_static_file...
[ "def", "test_no_collectstatic_emulation", "(", "self", ")", ":", "try", ":", "self", ".", "urlopen", "(", "'/static/another_app/another_app_static_file.txt'", ")", "except", "HTTPError", "as", "err", ":", "self", ".", "assertEqual", "(", "err", ".", "code", ",", ...
[ 139, 4 ]
[ 150, 66 ]
python
en
['en', 'error', 'th']
False
LiveServerViews.test_media_files
(self)
Ensure that the LiveServerTestCase serves media files. Refs #2879.
Ensure that the LiveServerTestCase serves media files. Refs #2879.
def test_media_files(self): """ Ensure that the LiveServerTestCase serves media files. Refs #2879. """ f = self.urlopen('/media/example_media_file.txt') self.assertEqual(f.read().rstrip(b'\r\n'), b'example media file')
[ "def", "test_media_files", "(", "self", ")", ":", "f", "=", "self", ".", "urlopen", "(", "'/media/example_media_file.txt'", ")", "self", ".", "assertEqual", "(", "f", ".", "read", "(", ")", ".", "rstrip", "(", "b'\\r\\n'", ")", ",", "b'example media file'", ...
[ 152, 4 ]
[ 158, 73 ]
python
en
['en', 'error', 'th']
False
LiveServerDatabase.test_fixtures_loaded
(self)
Ensure that fixtures are properly loaded and visible to the live server thread. Refs #2879.
Ensure that fixtures are properly loaded and visible to the live server thread. Refs #2879.
def test_fixtures_loaded(self): """ Ensure that fixtures are properly loaded and visible to the live server thread. Refs #2879. """ f = self.urlopen('/model_view/') self.assertEqual(f.read().splitlines(), [b'jane', b'robert'])
[ "def", "test_fixtures_loaded", "(", "self", ")", ":", "f", "=", "self", ".", "urlopen", "(", "'/model_view/'", ")", "self", ".", "assertEqual", "(", "f", ".", "read", "(", ")", ".", "splitlines", "(", ")", ",", "[", "b'jane'", ",", "b'robert'", "]", ...
[ 167, 4 ]
[ 174, 69 ]
python
en
['en', 'error', 'th']
False
LiveServerDatabase.test_database_writes
(self)
Ensure that data written to the database by a view can be read. Refs #2879.
Ensure that data written to the database by a view can be read. Refs #2879.
def test_database_writes(self): """ Ensure that data written to the database by a view can be read. Refs #2879. """ self.urlopen('/create_model_instance/') self.assertQuerysetEqual( Person.objects.all().order_by('pk'), ['jane', 'robert', 'emily'], ...
[ "def", "test_database_writes", "(", "self", ")", ":", "self", ".", "urlopen", "(", "'/create_model_instance/'", ")", "self", ".", "assertQuerysetEqual", "(", "Person", ".", "objects", ".", "all", "(", ")", ".", "order_by", "(", "'pk'", ")", ",", "[", "'jan...
[ 176, 4 ]
[ 186, 9 ]
python
en
['en', 'error', 'th']
False
DatabaseSchemaEditor._create_like_index_sql
(self, model, field)
Return the statement to create an index with varchar operator pattern when the column type is 'varchar' or 'text', otherwise return None.
Return the statement to create an index with varchar operator pattern when the column type is 'varchar' or 'text', otherwise return None.
def _create_like_index_sql(self, model, field): """ Return the statement to create an index with varchar operator pattern when the column type is 'varchar' or 'text', otherwise return None. """ db_type = field.db_type(connection=self.connection) if db_type is not None and...
[ "def", "_create_like_index_sql", "(", "self", ",", "model", ",", "field", ")", ":", "db_type", "=", "field", ".", "db_type", "(", "connection", "=", "self", ".", "connection", ")", "if", "db_type", "is", "not", "None", "and", "(", "field", ".", "db_index...
[ 54, 4 ]
[ 74, 19 ]
python
en
['en', 'error', 'th']
False
check_other_queues
(queue_counts_dict: Dict[str, int])
Do a simple queue size check for queues whose workers don't publish stats files.
Do a simple queue size check for queues whose workers don't publish stats files.
def check_other_queues(queue_counts_dict: Dict[str, int]) -> List[Dict[str, Any]]: """ Do a simple queue size check for queues whose workers don't publish stats files.""" results = [] for queue, count in queue_counts_dict.items(): if queue in normal_queues: continue if count > ...
[ "def", "check_other_queues", "(", "queue_counts_dict", ":", "Dict", "[", "str", ",", "int", "]", ")", "->", "List", "[", "Dict", "[", "str", ",", "Any", "]", "]", ":", "results", "=", "[", "]", "for", "queue", ",", "count", "in", "queue_counts_dict", ...
[ 111, 0 ]
[ 126, 18 ]
python
en
['en', 'en', 'en']
True
extract
(path, to_path)
Unpack the tar or zip file at the specified path to the directory specified by to_path.
Unpack the tar or zip file at the specified path to the directory specified by to_path.
def extract(path, to_path): """ Unpack the tar or zip file at the specified path to the directory specified by to_path. """ with Archive(path) as archive: archive.extract(to_path)
[ "def", "extract", "(", "path", ",", "to_path", ")", ":", "with", "Archive", "(", "path", ")", "as", "archive", ":", "archive", ".", "extract", "(", "to_path", ")" ]
[ 42, 0 ]
[ 48, 32 ]
python
en
['en', 'error', 'th']
False
BaseArchive._copy_permissions
(mode, filename)
If the file in the archive has some permissions (this assumes a file won't be writable/executable without being readable), apply those permissions to the unarchived file.
If the file in the archive has some permissions (this assumes a file won't be writable/executable without being readable), apply those permissions to the unarchived file.
def _copy_permissions(mode, filename): """ If the file in the archive has some permissions (this assumes a file won't be writable/executable without being readable), apply those permissions to the unarchived file. """ if mode & stat.S_IROTH: os.chmod(filename,...
[ "def", "_copy_permissions", "(", "mode", ",", "filename", ")", ":", "if", "mode", "&", "stat", ".", "S_IROTH", ":", "os", ".", "chmod", "(", "filename", ",", "mode", ")" ]
[ 100, 4 ]
[ 107, 36 ]
python
en
['en', 'error', 'th']
False
BaseArchive.has_leading_dir
(self, paths)
Return True if all the paths have the same leading path name (i.e., everything is in one subdirectory in an archive).
Return True if all the paths have the same leading path name (i.e., everything is in one subdirectory in an archive).
def has_leading_dir(self, paths): """ Return True if all the paths have the same leading path name (i.e., everything is in one subdirectory in an archive). """ common_prefix = None for path in paths: prefix, rest = self.split_leading_dir(path) if n...
[ "def", "has_leading_dir", "(", "self", ",", "paths", ")", ":", "common_prefix", "=", "None", "for", "path", "in", "paths", ":", "prefix", ",", "rest", "=", "self", ".", "split_leading_dir", "(", "path", ")", "if", "not", "prefix", ":", "return", "False",...
[ 119, 4 ]
[ 133, 19 ]
python
en
['en', 'error', 'th']
False
TestProjectedGradientDescent.test_do_not_reach_lp_boundary
(self)
Make sure that iterative attack don't reach boundary of Lp neighbourhood if nb_iter * eps_iter is relatively small compared to epsilon.
Make sure that iterative attack don't reach boundary of Lp neighbourhood if nb_iter * eps_iter is relatively small compared to epsilon.
def test_do_not_reach_lp_boundary(self): """ Make sure that iterative attack don't reach boundary of Lp neighbourhood if nb_iter * eps_iter is relatively small compared to epsilon. """ for ord in [1, 2, np.infty]: try: _, _, delta = self.genera...
[ "def", "test_do_not_reach_lp_boundary", "(", "self", ")", ":", "for", "ord", "in", "[", "1", ",", "2", ",", "np", ".", "infty", "]", ":", "try", ":", "_", ",", "_", ",", "delta", "=", "self", ".", "generate_adversarial_examples_np", "(", "ord", "=", ...
[ 536, 4 ]
[ 550, 55 ]
python
en
['en', 'error', 'th']
False
TestProjectedGradientDescent.test_attack_strength_linf
(self)
If clipping is not done at each iteration (not passing clip_min and clip_max to fgm), this attack fails by np.mean(orig_labels == new_labels) == .39.
If clipping is not done at each iteration (not passing clip_min and clip_max to fgm), this attack fails by np.mean(orig_labels == new_labels) == .39.
def test_attack_strength_linf(self): """ If clipping is not done at each iteration (not passing clip_min and clip_max to fgm), this attack fails by np.mean(orig_labels == new_labels) == .39. """ x_val = np.random.rand(100, 2) x_val = np.array(x_val, dtype=np.float...
[ "def", "test_attack_strength_linf", "(", "self", ")", ":", "x_val", "=", "np", ".", "random", ".", "rand", "(", "100", ",", "2", ")", "x_val", "=", "np", ".", "array", "(", "x_val", ",", "dtype", "=", "np", ".", "float32", ")", "# sanity checks turned ...
[ 552, 4 ]
[ 575, 60 ]
python
en
['en', 'error', 'th']
False
TestProjectedGradientDescent.test_multiple_initial_random_step
(self)
This test generates multiple adversarial examples until an adversarial example is generated with a different label compared to the original label. This is the procedure suggested in Madry et al. (2017). This test will fail if an initial random step is not taken (error>0.5).
This test generates multiple adversarial examples until an adversarial example is generated with a different label compared to the original label. This is the procedure suggested in Madry et al. (2017).
def test_multiple_initial_random_step(self): """ This test generates multiple adversarial examples until an adversarial example is generated with a different label compared to the original label. This is the procedure suggested in Madry et al. (2017). This test will fail if an i...
[ "def", "test_multiple_initial_random_step", "(", "self", ")", ":", "x_val", "=", "np", ".", "array", "(", "np", ".", "random", ".", "rand", "(", "100", ",", "2", ")", ",", "dtype", "=", "np", ".", "float32", ")", "orig_labs", "=", "np", ".", "argmax"...
[ 700, 4 ]
[ 730, 66 ]
python
en
['en', 'error', 'th']
False
TestSparseL1Descent.test_do_not_reach_lp_boundary
(self)
Make sure that iterative attack don't reach boundary of Lp neighbourhood if nb_iter * eps_iter is relatively small compared to epsilon.
Make sure that iterative attack don't reach boundary of Lp neighbourhood if nb_iter * eps_iter is relatively small compared to epsilon.
def test_do_not_reach_lp_boundary(self): """ Make sure that iterative attack don't reach boundary of Lp neighbourhood if nb_iter * eps_iter is relatively small compared to epsilon. """ _, _, delta = self.generate_adversarial_examples_np( eps=0.5, nb_iter=10, ...
[ "def", "test_do_not_reach_lp_boundary", "(", "self", ")", ":", "_", ",", "_", ",", "delta", "=", "self", ".", "generate_adversarial_examples_np", "(", "eps", "=", "0.5", ",", "nb_iter", "=", "10", ",", "eps_iter", "=", "0.01", ")", "self", ".", "assertTrue...
[ 826, 4 ]
[ 837, 51 ]
python
en
['en', 'error', 'th']
False
TestSparseL1Descent.test_attack_strength
(self)
Without clipped gradients, we achieve np.mean(orig_labels == new_labels) == 0.31.
Without clipped gradients, we achieve np.mean(orig_labels == new_labels) == 0.31.
def test_attack_strength(self): """ Without clipped gradients, we achieve np.mean(orig_labels == new_labels) == 0.31. """ x_val = np.random.rand(100, 2) x_val = np.array(x_val, dtype=np.float32) # sanity checks turned off because this test initializes outside ...
[ "def", "test_attack_strength", "(", "self", ")", ":", "x_val", "=", "np", ".", "random", ".", "rand", "(", "100", ",", "2", ")", "x_val", "=", "np", ".", "array", "(", "x_val", ",", "dtype", "=", "np", ".", "float32", ")", "# sanity checks turned off b...
[ 904, 4 ]
[ 927, 63 ]
python
en
['en', 'error', 'th']
False
TestSparseL1Descent.test_grad_clip
(self)
With clipped gradients, we achieve np.mean(orig_labels == new_labels) == 0.0
With clipped gradients, we achieve np.mean(orig_labels == new_labels) == 0.0
def test_grad_clip(self): """ With clipped gradients, we achieve np.mean(orig_labels == new_labels) == 0.0 """ x_val = np.random.rand(100, 2) x_val = np.array(x_val, dtype=np.float32) # sanity checks turned off because this test initializes outside # the ...
[ "def", "test_grad_clip", "(", "self", ")", ":", "x_val", "=", "np", ".", "random", ".", "rand", "(", "100", ",", "2", ")", "x_val", "=", "np", ".", "array", "(", "x_val", ",", "dtype", "=", "np", ".", "float32", ")", "# sanity checks turned off because...
[ 929, 4 ]
[ 952, 60 ]
python
en
['en', 'error', 'th']
False
TestFastFeatureAdversaries.test_attack_strength
(self)
This test generates a random source and guide and feeds them in a randomly initialized CNN. Checks if an adversarial example can get at least 50% closer to the guide compared to the original distance of the source and the guide.
This test generates a random source and guide and feeds them in a randomly initialized CNN. Checks if an adversarial example can get at least 50% closer to the guide compared to the original distance of the source and the guide.
def test_attack_strength(self): """ This test generates a random source and guide and feeds them in a randomly initialized CNN. Checks if an adversarial example can get at least 50% closer to the guide compared to the original distance of the source and the guide. """ ...
[ "def", "test_attack_strength", "(", "self", ")", ":", "tf", ".", "set_random_seed", "(", "1234", ")", "input_shape", "=", "self", ".", "input_shape", "x_src", "=", "tf", ".", "abs", "(", "tf", ".", "random_uniform", "(", "input_shape", ",", "0.0", ",", "...
[ 1523, 4 ]
[ 1568, 49 ]
python
en
['en', 'error', 'th']
False
Command.set_options
(self, **options)
Set instance variables based on an options dict
Set instance variables based on an options dict
def set_options(self, **options): """ Set instance variables based on an options dict """ self.interactive = options['interactive'] self.verbosity = options['verbosity'] self.symlink = options['link'] self.clear = options['clear'] self.dry_run = options['d...
[ "def", "set_options", "(", "self", ",", "*", "*", "options", ")", ":", "self", ".", "interactive", "=", "options", "[", "'interactive'", "]", "self", ".", "verbosity", "=", "options", "[", "'verbosity'", "]", "self", ".", "symlink", "=", "options", "[", ...
[ 69, 4 ]
[ 82, 51 ]
python
en
['en', 'error', 'th']
False
Command.collect
(self)
Perform the bulk of the work of collectstatic. Split off from handle() to facilitate testing.
Perform the bulk of the work of collectstatic.
def collect(self): """ Perform the bulk of the work of collectstatic. Split off from handle() to facilitate testing. """ if self.symlink and not self.local: raise CommandError("Can't symlink to a remote destination.") if self.clear: self.clear_di...
[ "def", "collect", "(", "self", ")", ":", "if", "self", ".", "symlink", "and", "not", "self", ".", "local", ":", "raise", "CommandError", "(", "\"Can't symlink to a remote destination.\"", ")", "if", "self", ".", "clear", ":", "self", ".", "clear_dir", "(", ...
[ 84, 4 ]
[ 144, 9 ]
python
en
['en', 'error', 'th']
False
Command.log
(self, msg, level=2)
Small log helper
Small log helper
def log(self, msg, level=2): """ Small log helper """ if self.verbosity >= level: self.stdout.write(msg)
[ "def", "log", "(", "self", ",", "msg", ",", "level", "=", "2", ")", ":", "if", "self", ".", "verbosity", ">=", "level", ":", "self", ".", "stdout", ".", "write", "(", "msg", ")" ]
[ 206, 4 ]
[ 211, 34 ]
python
en
['en', 'error', 'th']
False
Command.clear_dir
(self, path)
Delete the given relative path using the destination storage backend.
Delete the given relative path using the destination storage backend.
def clear_dir(self, path): """ Delete the given relative path using the destination storage backend. """ if not self.storage.exists(path): return dirs, files = self.storage.listdir(path) for f in files: fpath = os.path.join(path, f) if...
[ "def", "clear_dir", "(", "self", ",", "path", ")", ":", "if", "not", "self", ".", "storage", ".", "exists", "(", "path", ")", ":", "return", "dirs", ",", "files", "=", "self", ".", "storage", ".", "listdir", "(", "path", ")", "for", "f", "in", "f...
[ 216, 4 ]
[ 241, 49 ]
python
en
['en', 'error', 'th']
False
Command.delete_file
(self, path, prefixed_path, source_storage)
Check if the target file should be deleted if it already exists.
Check if the target file should be deleted if it already exists.
def delete_file(self, path, prefixed_path, source_storage): """ Check if the target file should be deleted if it already exists. """ if self.storage.exists(prefixed_path): try: # When was the target file modified last time? target_last_modified...
[ "def", "delete_file", "(", "self", ",", "path", ",", "prefixed_path", ",", "source_storage", ")", ":", "if", "self", ".", "storage", ".", "exists", "(", "prefixed_path", ")", ":", "try", ":", "# When was the target file modified last time?", "target_last_modified", ...
[ 243, 4 ]
[ 291, 19 ]
python
en
['en', 'error', 'th']
False