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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
PostGISOperations.postgis_geos_version | (self) | Returns the version of the GEOS library used with PostGIS. | Returns the version of the GEOS library used with PostGIS. | def postgis_geos_version(self):
"Returns the version of the GEOS library used with PostGIS."
return self._get_postgis_func('postgis_geos_version') | [
"def",
"postgis_geos_version",
"(",
"self",
")",
":",
"return",
"self",
".",
"_get_postgis_func",
"(",
"'postgis_geos_version'",
")"
] | [
315,
4
] | [
317,
61
] | python | en | ['en', 'en', 'en'] | True |
PostGISOperations.postgis_lib_version | (self) | Returns the version number of the PostGIS library used with PostgreSQL. | Returns the version number of the PostGIS library used with PostgreSQL. | def postgis_lib_version(self):
"Returns the version number of the PostGIS library used with PostgreSQL."
return self._get_postgis_func('postgis_lib_version') | [
"def",
"postgis_lib_version",
"(",
"self",
")",
":",
"return",
"self",
".",
"_get_postgis_func",
"(",
"'postgis_lib_version'",
")"
] | [
319,
4
] | [
321,
60
] | python | en | ['en', 'en', 'en'] | True |
PostGISOperations.postgis_proj_version | (self) | Returns the version of the PROJ.4 library used with PostGIS. | Returns the version of the PROJ.4 library used with PostGIS. | def postgis_proj_version(self):
"Returns the version of the PROJ.4 library used with PostGIS."
return self._get_postgis_func('postgis_proj_version') | [
"def",
"postgis_proj_version",
"(",
"self",
")",
":",
"return",
"self",
".",
"_get_postgis_func",
"(",
"'postgis_proj_version'",
")"
] | [
323,
4
] | [
325,
61
] | python | en | ['en', 'en', 'en'] | True |
PostGISOperations.postgis_version | (self) | Returns PostGIS version number and compile-time options. | Returns PostGIS version number and compile-time options. | def postgis_version(self):
"Returns PostGIS version number and compile-time options."
return self._get_postgis_func('postgis_version') | [
"def",
"postgis_version",
"(",
"self",
")",
":",
"return",
"self",
".",
"_get_postgis_func",
"(",
"'postgis_version'",
")"
] | [
327,
4
] | [
329,
56
] | python | en | ['en', 'en', 'en'] | True |
PostGISOperations.postgis_full_version | (self) | Returns PostGIS version number and compile-time options. | Returns PostGIS version number and compile-time options. | def postgis_full_version(self):
"Returns PostGIS version number and compile-time options."
return self._get_postgis_func('postgis_full_version') | [
"def",
"postgis_full_version",
"(",
"self",
")",
":",
"return",
"self",
".",
"_get_postgis_func",
"(",
"'postgis_full_version'",
")"
] | [
331,
4
] | [
333,
61
] | python | en | ['en', 'en', 'en'] | True |
PostGISOperations.postgis_version_tuple | (self) |
Returns the PostGIS version as a tuple (version string, major,
minor, subminor).
|
Returns the PostGIS version as a tuple (version string, major,
minor, subminor).
| def postgis_version_tuple(self):
"""
Returns the PostGIS version as a tuple (version string, major,
minor, subminor).
"""
# Getting the PostGIS version
version = self.postgis_lib_version()
m = self.version_regex.match(version)
if m:
major = in... | [
"def",
"postgis_version_tuple",
"(",
"self",
")",
":",
"# Getting the PostGIS version",
"version",
"=",
"self",
".",
"postgis_lib_version",
"(",
")",
"m",
"=",
"self",
".",
"version_regex",
".",
"match",
"(",
"version",
")",
"if",
"m",
":",
"major",
"=",
"in... | [
335,
4
] | [
351,
47
] | python | en | ['en', 'error', 'th'] | False |
PostGISOperations.proj_version_tuple | (self) |
Return the version of PROJ.4 used by PostGIS as a tuple of the
major, minor, and subminor release numbers.
|
Return the version of PROJ.4 used by PostGIS as a tuple of the
major, minor, and subminor release numbers.
| def proj_version_tuple(self):
"""
Return the version of PROJ.4 used by PostGIS as a tuple of the
major, minor, and subminor release numbers.
"""
proj_regex = re.compile(r'(\d+)\.(\d+)\.(\d+)')
proj_ver_str = self.postgis_proj_version()
m = proj_regex.search(proj_v... | [
"def",
"proj_version_tuple",
"(",
"self",
")",
":",
"proj_regex",
"=",
"re",
".",
"compile",
"(",
"r'(\\d+)\\.(\\d+)\\.(\\d+)'",
")",
"proj_ver_str",
"=",
"self",
".",
"postgis_proj_version",
"(",
")",
"m",
"=",
"proj_regex",
".",
"search",
"(",
"proj_ver_str",
... | [
353,
4
] | [
364,
79
] | python | en | ['en', 'error', 'th'] | False |
PostGISOperations.spatial_aggregate_sql | (self, agg) |
Returns the spatial aggregate SQL template and function for the
given Aggregate instance.
|
Returns the spatial aggregate SQL template and function for the
given Aggregate instance.
| def spatial_aggregate_sql(self, agg):
"""
Returns the spatial aggregate SQL template and function for the
given Aggregate instance.
"""
agg_name = agg.__class__.__name__
if not self.check_aggregate_support(agg):
raise NotImplementedError('%s spatial aggregate ... | [
"def",
"spatial_aggregate_sql",
"(",
"self",
",",
"agg",
")",
":",
"agg_name",
"=",
"agg",
".",
"__class__",
".",
"__name__",
"if",
"not",
"self",
".",
"check_aggregate_support",
"(",
"agg",
")",
":",
"raise",
"NotImplementedError",
"(",
"'%s spatial aggregate i... | [
366,
4
] | [
379,
41
] | python | en | ['en', 'error', 'th'] | False |
get_build_version | () | Return the version of MSVC that was used to build Python.
For Python 2.3 and up, the version number is included in
sys.version. For earlier versions, assume the compiler is MSVC 6.
| Return the version of MSVC that was used to build Python. | def get_build_version():
"""Return the version of MSVC that was used to build Python.
For Python 2.3 and up, the version number is included in
sys.version. For earlier versions, assume the compiler is MSVC 6.
"""
prefix = "MSC v."
i = sys.version.find(prefix)
if i == -1:
return 6
... | [
"def",
"get_build_version",
"(",
")",
":",
"prefix",
"=",
"\"MSC v.\"",
"i",
"=",
"sys",
".",
"version",
".",
"find",
"(",
"prefix",
")",
"if",
"i",
"==",
"-",
"1",
":",
"return",
"6",
"i",
"=",
"i",
"+",
"len",
"(",
"prefix",
")",
"s",
",",
"r... | [
166,
0
] | [
189,
15
] | python | en | ['en', 'en', 'en'] | True |
normalize_and_reduce_paths | (paths) | Return a list of normalized paths with duplicates removed.
The current order of paths is maintained.
| Return a list of normalized paths with duplicates removed. | def normalize_and_reduce_paths(paths):
"""Return a list of normalized paths with duplicates removed.
The current order of paths is maintained.
"""
# Paths are normalized so things like: /a and /a/ aren't both preserved.
reduced_paths = []
for p in paths:
np = os.path.normpath(p)
... | [
"def",
"normalize_and_reduce_paths",
"(",
"paths",
")",
":",
"# Paths are normalized so things like: /a and /a/ aren't both preserved.",
"reduced_paths",
"=",
"[",
"]",
"for",
"p",
"in",
"paths",
":",
"np",
"=",
"os",
".",
"path",
".",
"normpath",
"(",
"p",
")",
... | [
191,
0
] | [
203,
24
] | python | en | ['en', 'en', 'en'] | True |
removeDuplicates | (variable) | Remove duplicate values of an environment variable.
| Remove duplicate values of an environment variable.
| def removeDuplicates(variable):
"""Remove duplicate values of an environment variable.
"""
oldList = variable.split(os.pathsep)
newList = []
for i in oldList:
if i not in newList:
newList.append(i)
newVariable = os.pathsep.join(newList)
return newVariable | [
"def",
"removeDuplicates",
"(",
"variable",
")",
":",
"oldList",
"=",
"variable",
".",
"split",
"(",
"os",
".",
"pathsep",
")",
"newList",
"=",
"[",
"]",
"for",
"i",
"in",
"oldList",
":",
"if",
"i",
"not",
"in",
"newList",
":",
"newList",
".",
"appen... | [
205,
0
] | [
214,
22
] | python | en | ['en', 'en', 'en'] | True |
find_vcvarsall | (version) | Find the vcvarsall.bat file
At first it tries to find the productdir of VS 2008 in the registry. If
that fails it falls back to the VS90COMNTOOLS env var.
| Find the vcvarsall.bat file | def find_vcvarsall(version):
"""Find the vcvarsall.bat file
At first it tries to find the productdir of VS 2008 in the registry. If
that fails it falls back to the VS90COMNTOOLS env var.
"""
vsbase = VS_BASE % version
try:
productdir = Reg.get_value(r"%s\Setup\VC" % vsbase,
... | [
"def",
"find_vcvarsall",
"(",
"version",
")",
":",
"vsbase",
"=",
"VS_BASE",
"%",
"version",
"try",
":",
"productdir",
"=",
"Reg",
".",
"get_value",
"(",
"r\"%s\\Setup\\VC\"",
"%",
"vsbase",
",",
"\"productdir\"",
")",
"except",
"KeyError",
":",
"log",
".",
... | [
216,
0
] | [
249,
15
] | python | en | ['en', 'en', 'en'] | True |
query_vcvarsall | (version, arch="x86") | Launch vcvarsall.bat and read the settings from its environment
| Launch vcvarsall.bat and read the settings from its environment
| def query_vcvarsall(version, arch="x86"):
"""Launch vcvarsall.bat and read the settings from its environment
"""
vcvarsall = find_vcvarsall(version)
interesting = {"include", "lib", "libpath", "path"}
result = {}
if vcvarsall is None:
raise DistutilsPlatformError("Unable to find vcvarsa... | [
"def",
"query_vcvarsall",
"(",
"version",
",",
"arch",
"=",
"\"x86\"",
")",
":",
"vcvarsall",
"=",
"find_vcvarsall",
"(",
"version",
")",
"interesting",
"=",
"{",
"\"include\"",
",",
"\"lib\"",
",",
"\"libpath\"",
",",
"\"path\"",
"}",
"result",
"=",
"{",
... | [
251,
0
] | [
289,
17
] | python | en | ['en', 'en', 'en'] | True |
Reg.read_keys | (cls, base, key) | Return list of registry keys. | Return list of registry keys. | def read_keys(cls, base, key):
"""Return list of registry keys."""
try:
handle = RegOpenKeyEx(base, key)
except RegError:
return None
L = []
i = 0
while True:
try:
k = RegEnumKey(handle, i)
except RegError:
... | [
"def",
"read_keys",
"(",
"cls",
",",
"base",
",",
"key",
")",
":",
"try",
":",
"handle",
"=",
"RegOpenKeyEx",
"(",
"base",
",",
"key",
")",
"except",
"RegError",
":",
"return",
"None",
"L",
"=",
"[",
"]",
"i",
"=",
"0",
"while",
"True",
":",
"try... | [
70,
4
] | [
85,
16
] | python | en | ['en', 'no', 'en'] | True |
Reg.read_values | (cls, base, key) | Return dict of registry keys and values.
All names are converted to lowercase.
| Return dict of registry keys and values. | def read_values(cls, base, key):
"""Return dict of registry keys and values.
All names are converted to lowercase.
"""
try:
handle = RegOpenKeyEx(base, key)
except RegError:
return None
d = {}
i = 0
while True:
try:
... | [
"def",
"read_values",
"(",
"cls",
",",
"base",
",",
"key",
")",
":",
"try",
":",
"handle",
"=",
"RegOpenKeyEx",
"(",
"base",
",",
"key",
")",
"except",
"RegError",
":",
"return",
"None",
"d",
"=",
"{",
"}",
"i",
"=",
"0",
"while",
"True",
":",
"t... | [
88,
4
] | [
107,
16
] | python | en | ['en', 'en', 'en'] | True |
MSVCCompiler.find_exe | (self, exe) | Return path to an MSVC executable program.
Tries to find the program in several places: first, one of the
MSVC program search paths from the registry; next, the directories
in the PATH environment variable. If any of those work, return an
absolute path that is known to exist. If none ... | Return path to an MSVC executable program. | def find_exe(self, exe):
"""Return path to an MSVC executable program.
Tries to find the program in several places: first, one of the
MSVC program search paths from the registry; next, the directories
in the PATH environment variable. If any of those work, return an
absolute pa... | [
"def",
"find_exe",
"(",
"self",
",",
"exe",
")",
":",
"for",
"p",
"in",
"self",
".",
"__paths",
":",
"fn",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"p",
")",
",",
"exe",
")",
"if",
"os",
".",
"path",
... | [
767,
4
] | [
787,
18
] | python | en | ['en', 'en', 'en'] | True |
generic_inlineformset_factory | (model, form=ModelForm,
formset=BaseGenericInlineFormSet,
ct_field="content_type", fk_field="object_id",
fields=None, exclude=None,
extra=3, can_order=False, can_delete=True,
... |
Returns a ``GenericInlineFormSet`` for the given kwargs.
You must provide ``ct_field`` and ``fk_field`` if they are different from
the defaults ``content_type`` and ``object_id`` respectively.
|
Returns a ``GenericInlineFormSet`` for the given kwargs. | def generic_inlineformset_factory(model, form=ModelForm,
formset=BaseGenericInlineFormSet,
ct_field="content_type", fk_field="object_id",
fields=None, exclude=None,
extra=3, can_order=... | [
"def",
"generic_inlineformset_factory",
"(",
"model",
",",
"form",
"=",
"ModelForm",
",",
"formset",
"=",
"BaseGenericInlineFormSet",
",",
"ct_field",
"=",
"\"content_type\"",
",",
"fk_field",
"=",
"\"object_id\"",
",",
"fields",
"=",
"None",
",",
"exclude",
"=",
... | [
53,
0
] | [
88,
18
] | python | en | ['en', 'error', 'th'] | False |
LazySettings._setup | (self, name=None) |
Load the settings module pointed to by the environment variable. This
is used the first time we need any settings at all, if the user has not
previously configured the settings manually.
|
Load the settings module pointed to by the environment variable. This
is used the first time we need any settings at all, if the user has not
previously configured the settings manually.
| def _setup(self, name=None):
"""
Load the settings module pointed to by the environment variable. This
is used the first time we need any settings at all, if the user has not
previously configured the settings manually.
"""
settings_module = os.environ.get(ENVIRONMENT_VAR... | [
"def",
"_setup",
"(",
"self",
",",
"name",
"=",
"None",
")",
":",
"settings_module",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"ENVIRONMENT_VARIABLE",
")",
"if",
"not",
"settings_module",
":",
"desc",
"=",
"(",
"\"setting %s\"",
"%",
"name",
")",
"if",... | [
26,
4
] | [
41,
49
] | python | en | ['en', 'error', 'th'] | False |
LazySettings.configure | (self, default_settings=global_settings, **options) |
Called to manually configure the settings. The 'default_settings'
parameter sets where to retrieve any unspecified values from (its
argument must support attribute access (__getattr__)).
|
Called to manually configure the settings. The 'default_settings'
parameter sets where to retrieve any unspecified values from (its
argument must support attribute access (__getattr__)).
| def configure(self, default_settings=global_settings, **options):
"""
Called to manually configure the settings. The 'default_settings'
parameter sets where to retrieve any unspecified values from (its
argument must support attribute access (__getattr__)).
"""
if self._wr... | [
"def",
"configure",
"(",
"self",
",",
"default_settings",
"=",
"global_settings",
",",
"*",
"*",
"options",
")",
":",
"if",
"self",
".",
"_wrapped",
"is",
"not",
"empty",
":",
"raise",
"RuntimeError",
"(",
"'Settings already configured.'",
")",
"holder",
"=",
... | [
48,
4
] | [
59,
30
] | python | en | ['en', 'error', 'th'] | False |
LazySettings.configured | (self) |
Returns True if the settings have already been configured.
|
Returns True if the settings have already been configured.
| def configured(self):
"""
Returns True if the settings have already been configured.
"""
return self._wrapped is not empty | [
"def",
"configured",
"(",
"self",
")",
":",
"return",
"self",
".",
"_wrapped",
"is",
"not",
"empty"
] | [
62,
4
] | [
66,
41
] | python | en | ['en', 'error', 'th'] | False |
UserSettingsHolder.__init__ | (self, default_settings) |
Requests for configuration variables not in this class are satisfied
from the module specified in default_settings (if possible).
|
Requests for configuration variables not in this class are satisfied
from the module specified in default_settings (if possible).
| def __init__(self, default_settings):
"""
Requests for configuration variables not in this class are satisfied
from the module specified in default_settings (if possible).
"""
self.__dict__['_deleted'] = set()
self.default_settings = default_settings | [
"def",
"__init__",
"(",
"self",
",",
"default_settings",
")",
":",
"self",
".",
"__dict__",
"[",
"'_deleted'",
"]",
"=",
"set",
"(",
")",
"self",
".",
"default_settings",
"=",
"default_settings"
] | [
134,
4
] | [
140,
48
] | python | en | ['en', 'error', 'th'] | False |
add_lazy_relation | (cls, field, relation, operation) |
Adds a lookup on ``cls`` when a related field is defined using a string,
i.e.::
class MyModel(Model):
fk = ForeignKey("AnotherModel")
This string can be:
* RECURSIVE_RELATIONSHIP_CONSTANT (i.e. "self") to indicate a recursive
relation.
* The name of a model... |
Adds a lookup on ``cls`` when a related field is defined using a string,
i.e.:: | def add_lazy_relation(cls, field, relation, operation):
"""
Adds a lookup on ``cls`` when a related field is defined using a string,
i.e.::
class MyModel(Model):
fk = ForeignKey("AnotherModel")
This string can be:
* RECURSIVE_RELATIONSHIP_CONSTANT (i.e. "self") to indicate... | [
"def",
"add_lazy_relation",
"(",
"cls",
",",
"field",
",",
"relation",
",",
"operation",
")",
":",
"# Check for recursive relations",
"if",
"relation",
"==",
"RECURSIVE_RELATIONSHIP_CONSTANT",
":",
"app_label",
"=",
"cls",
".",
"_meta",
".",
"app_label",
"model_name... | [
26,
0
] | [
82,
36
] | python | en | ['en', 'error', 'th'] | False |
do_pending_lookups | (sender, **kwargs) |
Handle any pending relations to the sending model. Sent from class_prepared.
|
Handle any pending relations to the sending model. Sent from class_prepared.
| def do_pending_lookups(sender, **kwargs):
"""
Handle any pending relations to the sending model. Sent from class_prepared.
"""
key = (sender._meta.app_label, sender.__name__)
for cls, field, operation in sender._meta.apps._pending_lookups.pop(key, []):
operation(field, sender, cls) | [
"def",
"do_pending_lookups",
"(",
"sender",
",",
"*",
"*",
"kwargs",
")",
":",
"key",
"=",
"(",
"sender",
".",
"_meta",
".",
"app_label",
",",
"sender",
".",
"__name__",
")",
"for",
"cls",
",",
"field",
",",
"operation",
"in",
"sender",
".",
"_meta",
... | [
85,
0
] | [
91,
37
] | python | en | ['en', 'error', 'th'] | False |
create_many_related_manager | (superclass, rel) | Creates a manager that subclasses 'superclass' (which is a Manager)
and adds behavior for many-to-many related objects. | Creates a manager that subclasses 'superclass' (which is a Manager)
and adds behavior for many-to-many related objects. | def create_many_related_manager(superclass, rel):
"""Creates a manager that subclasses 'superclass' (which is a Manager)
and adds behavior for many-to-many related objects."""
class ManyRelatedManager(superclass):
def __init__(self, model=None, query_field_name=None, instance=None, symmetrical=None,... | [
"def",
"create_many_related_manager",
"(",
"superclass",
",",
"rel",
")",
":",
"class",
"ManyRelatedManager",
"(",
"superclass",
")",
":",
"def",
"__init__",
"(",
"self",
",",
"model",
"=",
"None",
",",
"query_field_name",
"=",
"None",
",",
"instance",
"=",
... | [
824,
0
] | [
1123,
29
] | python | en | ['en', 'en', 'en'] | True |
RelatedField._check_clashes | (self) | Check accessor and reverse query name clashes. | Check accessor and reverse query name clashes. | def _check_clashes(self):
""" Check accessor and reverse query name clashes. """
from django.db.models.base import ModelBase
errors = []
opts = self.model._meta
# `f.rel.to` may be a string instead of a model. Skip if model name is
# not resolved.
if not isinst... | [
"def",
"_check_clashes",
"(",
"self",
")",
":",
"from",
"django",
".",
"db",
".",
"models",
".",
"base",
"import",
"ModelBase",
"errors",
"=",
"[",
"]",
"opts",
"=",
"self",
".",
"model",
".",
"_meta",
"# `f.rel.to` may be a string instead of a model. Skip if mo... | [
160,
4
] | [
265,
21
] | python | en | ['en', 'en', 'en'] | True |
RelatedField.db_type | (self, connection) | By default related field will not have a column
as it relates columns to another table | By default related field will not have a column
as it relates columns to another table | def db_type(self, connection):
'''By default related field will not have a column
as it relates columns to another table'''
return None | [
"def",
"db_type",
"(",
"self",
",",
"connection",
")",
":",
"return",
"None"
] | [
267,
4
] | [
270,
19
] | python | en | ['en', 'en', 'en'] | True |
RelatedField.swappable_setting | (self) |
Gets the setting that this is powered from for swapping, or None
if it's not swapped in / marked with swappable=False.
|
Gets the setting that this is powered from for swapping, or None
if it's not swapped in / marked with swappable=False.
| def swappable_setting(self):
"""
Gets the setting that this is powered from for swapping, or None
if it's not swapped in / marked with swappable=False.
"""
if self.swappable:
# Work out string form of "to"
if isinstance(self.rel.to, six.string_types):
... | [
"def",
"swappable_setting",
"(",
"self",
")",
":",
"if",
"self",
".",
"swappable",
":",
"# Work out string form of \"to\"",
"if",
"isinstance",
"(",
"self",
".",
"rel",
".",
"to",
",",
"six",
".",
"string_types",
")",
":",
"to_string",
"=",
"self",
".",
"r... | [
297,
4
] | [
318,
19
] | python | en | ['en', 'error', 'th'] | False |
RelatedField.get_limit_choices_to | (self) | Returns 'limit_choices_to' for this model field.
If it is a callable, it will be invoked and the result will be
returned.
| Returns 'limit_choices_to' for this model field. | def get_limit_choices_to(self):
"""Returns 'limit_choices_to' for this model field.
If it is a callable, it will be invoked and the result will be
returned.
"""
if callable(self.rel.limit_choices_to):
return self.rel.limit_choices_to()
return self.rel.limit_c... | [
"def",
"get_limit_choices_to",
"(",
"self",
")",
":",
"if",
"callable",
"(",
"self",
".",
"rel",
".",
"limit_choices_to",
")",
":",
"return",
"self",
".",
"rel",
".",
"limit_choices_to",
"(",
")",
"return",
"self",
".",
"rel",
".",
"limit_choices_to"
] | [
332,
4
] | [
340,
40
] | python | en | ['en', 'en', 'en'] | True |
RelatedField.formfield | (self, **kwargs) | Passes ``limit_choices_to`` to field being constructed.
Only passes it if there is a type that supports related fields.
This is a similar strategy used to pass the ``queryset`` to the field
being constructed.
| Passes ``limit_choices_to`` to field being constructed. | def formfield(self, **kwargs):
"""Passes ``limit_choices_to`` to field being constructed.
Only passes it if there is a type that supports related fields.
This is a similar strategy used to pass the ``queryset`` to the field
being constructed.
"""
defaults = {}
if... | [
"def",
"formfield",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"defaults",
"=",
"{",
"}",
"if",
"hasattr",
"(",
"self",
".",
"rel",
",",
"'get_related_field'",
")",
":",
"# If this is a callable, do not invoke it here. Just pass",
"# it in the defaults for when... | [
342,
4
] | [
359,
62
] | python | en | ['en', 'en', 'en'] | True |
ForeignObjectRel.is_hidden | (self) | Should the related object be hidden? | Should the related object be hidden? | def is_hidden(self):
"Should the related object be hidden?"
return self.related_name and self.related_name[-1] == '+' | [
"def",
"is_hidden",
"(",
"self",
")",
":",
"return",
"self",
".",
"related_name",
"and",
"self",
".",
"related_name",
"[",
"-",
"1",
"]",
"==",
"'+'"
] | [
1266,
4
] | [
1268,
65
] | python | en | ['en', 'en', 'en'] | True |
ForeignObjectRel.set_field_name | (self) |
Sets the related field's name, this is not available until later stages
of app loading, so set_field_name is called from
set_attributes_from_rel()
|
Sets the related field's name, this is not available until later stages
of app loading, so set_field_name is called from
set_attributes_from_rel()
| def set_field_name(self):
"""
Sets the related field's name, this is not available until later stages
of app loading, so set_field_name is called from
set_attributes_from_rel()
"""
# By default foreign object doesn't relate to any remote field (for
# example custo... | [
"def",
"set_field_name",
"(",
"self",
")",
":",
"# By default foreign object doesn't relate to any remote field (for",
"# example custom multicolumn joins currently have no remote field).",
"self",
".",
"field_name",
"=",
"None"
] | [
1276,
4
] | [
1284,
30
] | python | en | ['en', 'error', 'th'] | False |
ManyToOneRel.get_related_field | (self) |
Returns the Field in the 'to' object to which this relationship is
tied.
|
Returns the Field in the 'to' object to which this relationship is
tied.
| def get_related_field(self):
"""
Returns the Field in the 'to' object to which this relationship is
tied.
"""
data = self.to._meta.get_field_by_name(self.field_name)
if not data[2]:
raise FieldDoesNotExist("No related field named '%s'" %
se... | [
"def",
"get_related_field",
"(",
"self",
")",
":",
"data",
"=",
"self",
".",
"to",
".",
"_meta",
".",
"get_field_by_name",
"(",
"self",
".",
"field_name",
")",
"if",
"not",
"data",
"[",
"2",
"]",
":",
"raise",
"FieldDoesNotExist",
"(",
"\"No related field ... | [
1300,
4
] | [
1309,
22
] | python | en | ['en', 'error', 'th'] | False |
ManyToManyRel.is_hidden | (self) | Should the related object be hidden? | Should the related object be hidden? | def is_hidden(self):
"Should the related object be hidden?"
return self.related_name and self.related_name[-1] == '+' | [
"def",
"is_hidden",
"(",
"self",
")",
":",
"return",
"self",
".",
"related_name",
"and",
"self",
".",
"related_name",
"[",
"-",
"1",
"]",
"==",
"'+'"
] | [
1344,
4
] | [
1346,
65
] | python | en | ['en', 'en', 'en'] | True |
ManyToManyRel.get_related_field | (self) |
Returns the field in the to' object to which this relationship is tied
(this is always the primary key on the target model). Provided for
symmetry with ManyToOneRel.
|
Returns the field in the to' object to which this relationship is tied
(this is always the primary key on the target model). Provided for
symmetry with ManyToOneRel.
| def get_related_field(self):
"""
Returns the field in the to' object to which this relationship is tied
(this is always the primary key on the target model). Provided for
symmetry with ManyToOneRel.
"""
return self.to._meta.pk | [
"def",
"get_related_field",
"(",
"self",
")",
":",
"return",
"self",
".",
"to",
".",
"_meta",
".",
"pk"
] | [
1348,
4
] | [
1354,
31
] | python | en | ['en', 'error', 'th'] | False |
ForeignObject.get_extra_descriptor_filter | (self, instance) |
Returns an extra filter condition for related object fetching when
user does 'instance.fieldname', that is the extra filter is used in
the descriptor of the field.
The filter should be either a dict usable in .filter(**kwargs) call or
a Q-object. The condition will be ANDed tog... |
Returns an extra filter condition for related object fetching when
user does 'instance.fieldname', that is the extra filter is used in
the descriptor of the field. | def get_extra_descriptor_filter(self, instance):
"""
Returns an extra filter condition for related object fetching when
user does 'instance.fieldname', that is the extra filter is used in
the descriptor of the field.
The filter should be either a dict usable in .filter(**kwargs)... | [
"def",
"get_extra_descriptor_filter",
"(",
"self",
",",
"instance",
")",
":",
"return",
"{",
"}"
] | [
1537,
4
] | [
1550,
17
] | python | en | ['en', 'error', 'th'] | False |
ForeignObject.get_extra_restriction | (self, where_class, alias, related_alias) |
Returns a pair condition used for joining and subquery pushdown. The
condition is something that responds to as_sql(qn, connection) method.
Note that currently referring both the 'alias' and 'related_alias'
will not work in some conditions, like subquery pushdown.
A parallel m... |
Returns a pair condition used for joining and subquery pushdown. The
condition is something that responds to as_sql(qn, connection) method. | def get_extra_restriction(self, where_class, alias, related_alias):
"""
Returns a pair condition used for joining and subquery pushdown. The
condition is something that responds to as_sql(qn, connection) method.
Note that currently referring both the 'alias' and 'related_alias'
... | [
"def",
"get_extra_restriction",
"(",
"self",
",",
"where_class",
",",
"alias",
",",
"related_alias",
")",
":",
"return",
"None"
] | [
1552,
4
] | [
1563,
19
] | python | en | ['en', 'error', 'th'] | False |
ForeignObject.get_path_info | (self) |
Get path from this field to the related model.
|
Get path from this field to the related model.
| def get_path_info(self):
"""
Get path from this field to the related model.
"""
opts = self.rel.to._meta
from_opts = self.model._meta
return [PathInfo(from_opts, opts, self.foreign_related_fields, self, False, True)] | [
"def",
"get_path_info",
"(",
"self",
")",
":",
"opts",
"=",
"self",
".",
"rel",
".",
"to",
".",
"_meta",
"from_opts",
"=",
"self",
".",
"model",
".",
"_meta",
"return",
"[",
"PathInfo",
"(",
"from_opts",
",",
"opts",
",",
"self",
".",
"foreign_related_... | [
1565,
4
] | [
1571,
90
] | python | en | ['en', 'error', 'th'] | False |
ForeignObject.get_reverse_path_info | (self) |
Get path from the related model to this field's model.
|
Get path from the related model to this field's model.
| def get_reverse_path_info(self):
"""
Get path from the related model to this field's model.
"""
opts = self.model._meta
from_opts = self.rel.to._meta
pathinfos = [PathInfo(from_opts, opts, (opts.pk,), self.rel, not self.unique, False)]
return pathinfos | [
"def",
"get_reverse_path_info",
"(",
"self",
")",
":",
"opts",
"=",
"self",
".",
"model",
".",
"_meta",
"from_opts",
"=",
"self",
".",
"rel",
".",
"to",
".",
"_meta",
"pathinfos",
"=",
"[",
"PathInfo",
"(",
"from_opts",
",",
"opts",
",",
"(",
"opts",
... | [
1573,
4
] | [
1580,
24
] | python | en | ['en', 'error', 'th'] | False |
ForeignKey.get_reverse_path_info | (self) |
Get path from the related model to this field's model.
|
Get path from the related model to this field's model.
| def get_reverse_path_info(self):
"""
Get path from the related model to this field's model.
"""
opts = self.model._meta
from_opts = self.rel.to._meta
pathinfos = [PathInfo(from_opts, opts, (opts.pk,), self.rel, not self.unique, False)]
return pathinfos | [
"def",
"get_reverse_path_info",
"(",
"self",
")",
":",
"opts",
"=",
"self",
".",
"model",
".",
"_meta",
"from_opts",
"=",
"self",
".",
"rel",
".",
"to",
".",
"_meta",
"pathinfos",
"=",
"[",
"PathInfo",
"(",
"from_opts",
",",
"opts",
",",
"(",
"opts",
... | [
1750,
4
] | [
1757,
24
] | python | en | ['en', 'error', 'th'] | False |
ForeignKey.get_default | (self) | Here we check if the default value is an object and return the to_field if so. | Here we check if the default value is an object and return the to_field if so. | def get_default(self):
"Here we check if the default value is an object and return the to_field if so."
field_default = super(ForeignKey, self).get_default()
if isinstance(field_default, self.rel.to):
return getattr(field_default, self.related_field.attname)
return field_defa... | [
"def",
"get_default",
"(",
"self",
")",
":",
"field_default",
"=",
"super",
"(",
"ForeignKey",
",",
"self",
")",
".",
"get_default",
"(",
")",
"if",
"isinstance",
"(",
"field_default",
",",
"self",
".",
"rel",
".",
"to",
")",
":",
"return",
"getattr",
... | [
1792,
4
] | [
1797,
28
] | python | en | ['en', 'en', 'en'] | True |
main | (argv=None) | Takes the path to a directory with reports and renders success fail plots. | Takes the path to a directory with reports and renders success fail plots. | def main(argv=None):
"""Takes the path to a directory with reports and renders success fail plots."""
report_paths = argv[1:]
fail_names = FLAGS.fail_names.split(",")
for report_path in report_paths:
plot_report_from_path(report_path, label=report_path, fail_names=fail_names)
pyplot.legend... | [
"def",
"main",
"(",
"argv",
"=",
"None",
")",
":",
"report_paths",
"=",
"argv",
"[",
"1",
":",
"]",
"fail_names",
"=",
"FLAGS",
".",
"fail_names",
".",
"split",
"(",
"\",\"",
")",
"for",
"report_path",
"in",
"report_paths",
":",
"plot_report_from_path",
... | [
27,
0
] | [
40,
17
] | python | en | ['en', 'en', 'en'] | True |
LogFormatter.__init__ | (self, color=True, datefmt=None) | r"""
:arg bool color: Enables color support.
:arg string fmt: Log message format.
It will be applied to the attributes dict of log records. The
text between ``%(color)s`` and ``%(end_color)s`` will be colored
depending on the level if color support is on.
:arg dict colors... | r"""
:arg bool color: Enables color support.
:arg string fmt: Log message format.
It will be applied to the attributes dict of log records. The
text between ``%(color)s`` and ``%(end_color)s`` will be colored
depending on the level if color support is on.
:arg dict colors... | def __init__(self, color=True, datefmt=None):
r"""
:arg bool color: Enables color support.
:arg string fmt: Log message format.
It will be applied to the attributes dict of log records. The
text between ``%(color)s`` and ``%(end_color)s`` will be colored
depending on the ... | [
"def",
"__init__",
"(",
"self",
",",
"color",
"=",
"True",
",",
"datefmt",
"=",
"None",
")",
":",
"logging",
".",
"Formatter",
".",
"__init__",
"(",
"self",
",",
"datefmt",
"=",
"datefmt",
")",
"self",
".",
"_colors",
"=",
"{",
"}",
"if",
"color",
... | [
49,
4
] | [
90,
31
] | python | cy | ['en', 'cy', 'hi'] | False |
format | (number, decimal_sep, decimal_pos=None, grouping=0, thousand_sep='',
force_grouping=False) |
Gets a number (as a number or string), and returns it as a string,
using formats defined as arguments:
* decimal_sep: Decimal separator symbol (for example ".")
* decimal_pos: Number of decimal positions
* grouping: Number of digits in every group limited by thousand separator
* thousand_sep: ... |
Gets a number (as a number or string), and returns it as a string,
using formats defined as arguments: | def format(number, decimal_sep, decimal_pos=None, grouping=0, thousand_sep='',
force_grouping=False):
"""
Gets a number (as a number or string), and returns it as a string,
using formats defined as arguments:
* decimal_sep: Decimal separator symbol (for example ".")
* decimal_pos: Number... | [
"def",
"format",
"(",
"number",
",",
"decimal_sep",
",",
"decimal_pos",
"=",
"None",
",",
"grouping",
"=",
"0",
",",
"thousand_sep",
"=",
"''",
",",
"force_grouping",
"=",
"False",
")",
":",
"use_grouping",
"=",
"settings",
".",
"USE_L10N",
"and",
"setting... | [
5,
0
] | [
47,
37
] | python | en | ['en', 'error', 'th'] | False |
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",
")"
] | [
43,
0
] | [
49,
32
] | python | en | ['en', 'error', 'th'] | False |
BaseArchive.has_leading_dir | (self, paths) |
Returns true if all the paths have the same leading path name
(i.e., everything is in one subdirectory in an archive)
|
Returns 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):
"""
Returns 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",... | [
111,
4
] | [
125,
19
] | python | en | ['en', 'error', 'th'] | False |
Muncher.__init__ | (self, config) | constructor
Returns:
void
| constructor | def __init__(self, config):
"""constructor
Returns:
void
"""
self.id_counter = {}
self.class_counter = {}
self.id_map = {}
self.class_map = {}
self.config = config | [
"def",
"__init__",
"(",
"self",
",",
"config",
")",
":",
"self",
".",
"id_counter",
"=",
"{",
"}",
"self",
".",
"class_counter",
"=",
"{",
"}",
"self",
".",
"id_map",
"=",
"{",
"}",
"self",
".",
"class_map",
"=",
"{",
"}",
"self",
".",
"config",
... | [
22,
4
] | [
33,
28
] | python | en | ['en', 'en', 'ur'] | False |
Muncher.showUsage | () | shows usage information for this script | shows usage information for this script | def showUsage():
"""shows usage information for this script"""
print "\n---------------------------------"
print " html-muncher"
print "---------------------------------"
print "\n" + '\033[91m' + "USAGE:" + '\033[0m'
print "munch --css file1.css,/path/to/css1,file2.css,... | [
"def",
"showUsage",
"(",
")",
":",
"print",
"\"\\n---------------------------------\"",
"print",
"\" html-muncher\"",
"print",
"\"---------------------------------\"",
"print",
"\"\\n\"",
"+",
"'\\033[91m'",
"+",
"\"USAGE:\"",
"+",
"'\\033[0m'",
"print",
"\"munch --css file1.... | [
36,
4
] | [
79,
19
] | python | en | ['en', 'en', 'en'] | True |
Muncher.run | (self) | runs the optimizer and does all the magic
Returns:
void
| runs the optimizer and does all the magic | def run(self):
"""runs the optimizer and does all the magic
Returns:
void
"""
self.output("searching for classes and ids...", False)
if self.config.js_manifest is not None:
self.outputJsWarnings()
self.processCss()
self.processViews()
... | [
"def",
"run",
"(",
"self",
")",
":",
"self",
".",
"output",
"(",
"\"searching for classes and ids...\"",
",",
"False",
")",
"if",
"self",
".",
"config",
".",
"js_manifest",
"is",
"not",
"None",
":",
"self",
".",
"outputJsWarnings",
"(",
")",
"self",
".",
... | [
81,
4
] | [
122,
53
] | python | en | ['en', 'en', 'en'] | True |
Muncher.output | (self, text, verbose_only = True) | outputs text during the script run
Arguments:
text -- string of text to output
verbose_only -- should we only show this in verbose mode?
Returns:
void
| outputs text during the script run | def output(self, text, verbose_only = True):
"""outputs text during the script run
Arguments:
text -- string of text to output
verbose_only -- should we only show this in verbose mode?
Returns:
void
"""
if verbose_only and not self.config.verbose:
... | [
"def",
"output",
"(",
"self",
",",
"text",
",",
"verbose_only",
"=",
"True",
")",
":",
"if",
"verbose_only",
"and",
"not",
"self",
".",
"config",
".",
"verbose",
":",
"return",
"print",
"text"
] | [
127,
4
] | [
141,
18
] | python | en | ['en', 'en', 'en'] | True |
Muncher.processCssDirectory | (self, file) | processes a directory of css files
Arguments:
file -- path to directory
Returns:
void
| processes a directory of css files | def processCssDirectory(self, file):
"""processes a directory of css files
Arguments:
file -- path to directory
Returns:
void
"""
if ".svn" in file:
return
for dir_file in Util.getFilesFromDir(file):
if Util.isDir(dir_file):
... | [
"def",
"processCssDirectory",
"(",
"self",
",",
"file",
")",
":",
"if",
"\".svn\"",
"in",
"file",
":",
"return",
"for",
"dir_file",
"in",
"Util",
".",
"getFilesFromDir",
"(",
"file",
")",
":",
"if",
"Util",
".",
"isDir",
"(",
"dir_file",
")",
":",
"sel... | [
143,
4
] | [
161,
41
] | python | en | ['en', 'en', 'en'] | True |
Muncher.processCss | (self) | gets all css files from config and processes them to see what to replace
Returns:
void
| gets all css files from config and processes them to see what to replace | def processCss(self):
"""gets all css files from config and processes them to see what to replace
Returns:
void
"""
files = self.config.css
for file in files:
if not Util.isDir(file):
self.processCssFile(file)
continue
... | [
"def",
"processCss",
"(",
"self",
")",
":",
"files",
"=",
"self",
".",
"config",
".",
"css",
"for",
"file",
"in",
"files",
":",
"if",
"not",
"Util",
".",
"isDir",
"(",
"file",
")",
":",
"self",
".",
"processCssFile",
"(",
"file",
")",
"continue",
"... | [
163,
4
] | [
175,
42
] | python | en | ['en', 'en', 'en'] | True |
Muncher.processViewDirectory | (self, file) | processes a directory of view files
Arguments:
file -- path to directory
Returns:
void
| processes a directory of view files | def processViewDirectory(self, file):
"""processes a directory of view files
Arguments:
file -- path to directory
Returns:
void
"""
if ".svn" in file:
return
for dir_file in Util.getFilesFromDir(file):
if Util.isDir(dir_file):
... | [
"def",
"processViewDirectory",
"(",
"self",
",",
"file",
")",
":",
"if",
"\".svn\"",
"in",
"file",
":",
"return",
"for",
"dir_file",
"in",
"Util",
".",
"getFilesFromDir",
"(",
"file",
")",
":",
"if",
"Util",
".",
"isDir",
"(",
"dir_file",
")",
":",
"se... | [
177,
4
] | [
195,
38
] | python | en | ['en', 'en', 'en'] | True |
Muncher.processViews | (self) | processes all view files
Returns:
void
| processes all view files | def processViews(self):
"""processes all view files
Returns:
void
"""
files = self.config.views
for file in files:
if not Util.isDir(file):
self.processView(file)
continue
self.processViewDirectory(file) | [
"def",
"processViews",
"(",
"self",
")",
":",
"files",
"=",
"self",
".",
"config",
".",
"views",
"for",
"file",
"in",
"files",
":",
"if",
"not",
"Util",
".",
"isDir",
"(",
"file",
")",
":",
"self",
".",
"processView",
"(",
"file",
")",
"continue",
... | [
197,
4
] | [
209,
43
] | python | en | ['en', 'en', 'en'] | True |
Muncher.processJsDirectory | (self, file) | processes a directory of js files
Arguments:
file -- path to directory
Returns:
void
| processes a directory of js files | def processJsDirectory(self, file):
"""processes a directory of js files
Arguments:
file -- path to directory
Returns:
void
"""
if ".svn" in file:
return
for dir_file in Util.getFilesFromDir(file):
if Util.isDir(dir_file):
... | [
"def",
"processJsDirectory",
"(",
"self",
",",
"file",
")",
":",
"if",
"\".svn\"",
"in",
"file",
":",
"return",
"for",
"dir_file",
"in",
"Util",
".",
"getFilesFromDir",
"(",
"file",
")",
":",
"if",
"Util",
".",
"isDir",
"(",
"dir_file",
")",
":",
"self... | [
211,
4
] | [
228,
40
] | python | en | ['en', 'ca', 'en'] | True |
Muncher.processJs | (self) | gets all js files from config and processes them to see what to replace
Returns:
void
| gets all js files from config and processes them to see what to replace | def processJs(self):
"""gets all js files from config and processes them to see what to replace
Returns:
void
"""
files = self.config.js
for file in files:
if not Util.isDir(file):
self.processJsFile(file)
continue
... | [
"def",
"processJs",
"(",
"self",
")",
":",
"files",
"=",
"self",
".",
"config",
".",
"js",
"for",
"file",
"in",
"files",
":",
"if",
"not",
"Util",
".",
"isDir",
"(",
"file",
")",
":",
"self",
".",
"processJsFile",
"(",
"file",
")",
"continue",
"sel... | [
230,
4
] | [
242,
41
] | python | en | ['en', 'en', 'en'] | True |
Muncher.processView | (self, file) | processes a single view file
Arguments:
file -- path to directory
| processes a single view file | def processView(self, file):
"""processes a single view file
Arguments:
file -- path to directory
"""
self.processCssFile(file, True)
self.processJsFile(file, True) | [
"def",
"processView",
"(",
"self",
",",
"file",
")",
":",
"self",
".",
"processCssFile",
"(",
"file",
",",
"True",
")",
"self",
".",
"processJsFile",
"(",
"file",
",",
"True",
")"
] | [
244,
4
] | [
252,
38
] | python | en | ['en', 'mk', 'en'] | True |
Muncher.processCssFile | (self, path, inline = False) | processes a single css file to find all classes and ids to replace
Arguments:
path -- path to css file to process
Returns:
void
| processes a single css file to find all classes and ids to replace | def processCssFile(self, path, inline = False):
"""processes a single css file to find all classes and ids to replace
Arguments:
path -- path to css file to process
Returns:
void
"""
contents = Util.fileGetContents(path)
if inline is True:
b... | [
"def",
"processCssFile",
"(",
"self",
",",
"path",
",",
"inline",
"=",
"False",
")",
":",
"contents",
"=",
"Util",
".",
"fileGetContents",
"(",
"path",
")",
"if",
"inline",
"is",
"True",
":",
"blocks",
"=",
"self",
".",
"getCssBlocks",
"(",
"contents",
... | [
254,
4
] | [
274,
38
] | python | en | ['en', 'en', 'en'] | True |
Muncher.processJsFile | (self, path, inline = False) | processes a single js file to find all classes and ids to replace
Arguments:
path -- path to css file to process
Returns:
void
| processes a single js file to find all classes and ids to replace | def processJsFile(self, path, inline = False):
"""processes a single js file to find all classes and ids to replace
Arguments:
path -- path to css file to process
Returns:
void
"""
contents = Util.fileGetContents(path)
if inline is True:
blo... | [
"def",
"processJsFile",
"(",
"self",
",",
"path",
",",
"inline",
"=",
"False",
")",
":",
"contents",
"=",
"Util",
".",
"fileGetContents",
"(",
"path",
")",
"if",
"inline",
"is",
"True",
":",
"blocks",
"=",
"self",
".",
"getJsBlocks",
"(",
"contents",
"... | [
276,
4
] | [
331,
43
] | python | en | ['en', 'en', 'en'] | True |
Muncher.processMaps | (self) | loops through classes and ids to process to determine shorter names to use for them
and creates a dictionary with these mappings
Returns:
void
| loops through classes and ids to process to determine shorter names to use for them
and creates a dictionary with these mappings | def processMaps(self):
"""loops through classes and ids to process to determine shorter names to use for them
and creates a dictionary with these mappings
Returns:
void
"""
# reverse sort so we can figure out the biggest savings
classes = self.class_counter.item... | [
"def",
"processMaps",
"(",
"self",
")",
":",
"# reverse sort so we can figure out the biggest savings",
"classes",
"=",
"self",
".",
"class_counter",
".",
"items",
"(",
")",
"classes",
".",
"sort",
"(",
"key",
"=",
"itemgetter",
"(",
"1",
")",
",",
"reverse",
... | [
379,
4
] | [
412,
38
] | python | en | ['en', 'en', 'en'] | True |
Muncher.incrementIdCounter | (self, name) | called for every time an id is added to increment the bytes we will save
Arguments:
name -- string of id
Returns:
void
| called for every time an id is added to increment the bytes we will save | def incrementIdCounter(self, name):
"""called for every time an id is added to increment the bytes we will save
Arguments:
name -- string of id
Returns:
void
"""
length = len(name)
if not name in self.id_counter:
self.id_counter[name] = len... | [
"def",
"incrementIdCounter",
"(",
"self",
",",
"name",
")",
":",
"length",
"=",
"len",
"(",
"name",
")",
"if",
"not",
"name",
"in",
"self",
".",
"id_counter",
":",
"self",
".",
"id_counter",
"[",
"name",
"]",
"=",
"length",
"return",
"self",
".",
"id... | [
414,
4
] | [
430,
39
] | python | en | ['en', 'en', 'en'] | True |
Muncher.incrementClassCounter | (self, name) | called for every time a class is added to increment the bytes we will save
Arguments:
name -- string of class
Returns:
void
| called for every time a class is added to increment the bytes we will save | def incrementClassCounter(self, name):
"""called for every time a class is added to increment the bytes we will save
Arguments:
name -- string of class
Returns:
void
"""
length = len(name)
if not name in self.class_counter:
self.class_count... | [
"def",
"incrementClassCounter",
"(",
"self",
",",
"name",
")",
":",
"length",
"=",
"len",
"(",
"name",
")",
"if",
"not",
"name",
"in",
"self",
".",
"class_counter",
":",
"self",
".",
"class_counter",
"[",
"name",
"]",
"=",
"length",
"return",
"self",
"... | [
432,
4
] | [
448,
42
] | python | en | ['en', 'en', 'en'] | True |
Muncher.incrementCounter | (self, name) | called everytime a class or id is added
Arguments:
name -- string of class or id name
Returns:
void
| called everytime a class or id is added | def incrementCounter(self, name):
"""called everytime a class or id is added
Arguments:
name -- string of class or id name
Returns:
void
"""
if name[0] == "#":
return self.incrementIdCounter(name)
return self.incrementClassCounter(name) | [
"def",
"incrementCounter",
"(",
"self",
",",
"name",
")",
":",
"if",
"name",
"[",
"0",
"]",
"==",
"\"#\"",
":",
"return",
"self",
".",
"incrementIdCounter",
"(",
"name",
")",
"return",
"self",
".",
"incrementClassCounter",
"(",
"name",
")"
] | [
450,
4
] | [
463,
47
] | python | en | ['en', 'en', 'en'] | True |
Muncher.addId | (self, id) | adds a single id to the master list of ids
Arguments:
id -- single id to add
Returns:
void
| adds a single id to the master list of ids | def addId(self, id):
"""adds a single id to the master list of ids
Arguments:
id -- single id to add
Returns:
void
"""
if id in self.config.ignore or id is '#':
return
# skip $ ids from manifest
if self.config.js_manifest is not Non... | [
"def",
"addId",
"(",
"self",
",",
"id",
")",
":",
"if",
"id",
"in",
"self",
".",
"config",
".",
"ignore",
"or",
"id",
"is",
"'#'",
":",
"return",
"# skip $ ids from manifest",
"if",
"self",
".",
"config",
".",
"js_manifest",
"is",
"not",
"None",
"and",... | [
465,
4
] | [
482,
33
] | python | en | ['en', 'en', 'en'] | True |
Muncher.addIds | (self, ids) | adds a list of ids to the master id list to replace
Arguments:
ids -- list of ids to add
Returns:
void
| adds a list of ids to the master id list to replace | def addIds(self, ids):
"""adds a list of ids to the master id list to replace
Arguments:
ids -- list of ids to add
Returns:
void
"""
for id in ids:
self.addId(id[0]) | [
"def",
"addIds",
"(",
"self",
",",
"ids",
")",
":",
"for",
"id",
"in",
"ids",
":",
"self",
".",
"addId",
"(",
"id",
"[",
"0",
"]",
")"
] | [
484,
4
] | [
495,
29
] | python | en | ['en', 'en', 'en'] | True |
Muncher.addClass | (self, class_name) | adds a single class to the master list of classes
Arguments:
class_name -- single class to add
Returns:
void
| adds a single class to the master list of classes | def addClass(self, class_name):
"""adds a single class to the master list of classes
Arguments:
class_name -- single class to add
Returns:
void
"""
if class_name in self.config.ignore or class_name is '.':
return
# skip $$ class names from ... | [
"def",
"addClass",
"(",
"self",
",",
"class_name",
")",
":",
"if",
"class_name",
"in",
"self",
".",
"config",
".",
"ignore",
"or",
"class_name",
"is",
"'.'",
":",
"return",
"# skip $$ class names from manifest",
"if",
"self",
".",
"config",
".",
"js_manifest",... | [
497,
4
] | [
514,
41
] | python | en | ['en', 'en', 'en'] | True |
Muncher.addClasses | (self, classes) | adds a list of classes to the master class list to replace
Arguments:
classes -- list of classes to add
Returns:
void
| adds a list of classes to the master class list to replace | def addClasses(self, classes):
"""adds a list of classes to the master class list to replace
Arguments:
classes -- list of classes to add
Returns:
void
"""
for class_name in classes:
self.addClass(class_name) | [
"def",
"addClasses",
"(",
"self",
",",
"classes",
")",
":",
"for",
"class_name",
"in",
"classes",
":",
"self",
".",
"addClass",
"(",
"class_name",
")"
] | [
516,
4
] | [
527,
37
] | python | en | ['en', 'en', 'en'] | True |
Muncher.optimizeFiles | (self, paths, callback, extension = "", minimize = False) | loops through a bunch of files and directories, runs them through a callback, then saves them to disk
Arguments:
paths -- array of files and directories
callback -- function to process each file with
Returns:
void
| loops through a bunch of files and directories, runs them through a callback, then saves them to disk | def optimizeFiles(self, paths, callback, extension = "", minimize = False):
"""loops through a bunch of files and directories, runs them through a callback, then saves them to disk
Arguments:
paths -- array of files and directories
callback -- function to process each file with
... | [
"def",
"optimizeFiles",
"(",
"self",
",",
"paths",
",",
"callback",
",",
"extension",
"=",
"\"\"",
",",
"minimize",
"=",
"False",
")",
":",
"for",
"file",
"in",
"paths",
":",
"if",
"not",
"Util",
".",
"isDir",
"(",
"file",
")",
":",
"self",
".",
"o... | [
529,
4
] | [
545,
71
] | python | en | ['en', 'en', 'en'] | True |
Muncher.optimizeFile | (self, file, callback, minimize = False, new_path = None, prepend = "opt") | optimizes a single file
Arguments:
file -- path to file
callback -- function to run the file through
minimize -- whether or not we should minimize the file contents (html)
prepend -- what extension to prepend
Returns:
void
| optimizes a single file | def optimizeFile(self, file, callback, minimize = False, new_path = None, prepend = "opt"):
"""optimizes a single file
Arguments:
file -- path to file
callback -- function to run the file through
minimize -- whether or not we should minimize the file contents (html)
prep... | [
"def",
"optimizeFile",
"(",
"self",
",",
"file",
",",
"callback",
",",
"minimize",
"=",
"False",
",",
"new_path",
"=",
"None",
",",
"prepend",
"=",
"\"opt\"",
")",
":",
"content",
"=",
"callback",
"(",
"file",
")",
"if",
"new_path",
"is",
"None",
":",
... | [
547,
4
] | [
570,
49
] | python | en | ['en', 'sm', 'en'] | True |
Muncher.optimizeDirectory | (self, path, callback, extension = "", minimize = False) | optimizes a directory
Arguments:
path -- path to directory
callback -- function to run the file through
extension -- extension to search for in the directory
minimize -- whether or not we should minimize the file contents (html)
Returns:
void
| optimizes a directory | def optimizeDirectory(self, path, callback, extension = "", minimize = False):
"""optimizes a directory
Arguments:
path -- path to directory
callback -- function to run the file through
extension -- extension to search for in the directory
minimize -- whether or not we s... | [
"def",
"optimizeDirectory",
"(",
"self",
",",
"path",
",",
"callback",
",",
"extension",
"=",
"\"\"",
",",
"minimize",
"=",
"False",
")",
":",
"directory",
"=",
"path",
"+",
"\"_opt\"",
"skip",
"=",
"self",
".",
"prepareDirectory",
"(",
"directory",
")",
... | [
584,
4
] | [
608,
69
] | python | en | ['en', 'en', 'en'] | True |
Muncher.optimizeSubdirectory | (self, path, callback, new_path, extension = "", minimize = False) | optimizes a subdirectory within a directory being optimized
Arguments:
path -- path to directory
callback -- function to run the file through
new_path -- path to optimized parent directory
extension -- extension to search for in the directory
minimize -- whether or not w... | optimizes a subdirectory within a directory being optimized | def optimizeSubdirectory(self, path, callback, new_path, extension = "", minimize = False):
"""optimizes a subdirectory within a directory being optimized
Arguments:
path -- path to directory
callback -- function to run the file through
new_path -- path to optimized parent direc... | [
"def",
"optimizeSubdirectory",
"(",
"self",
",",
"path",
",",
"callback",
",",
"new_path",
",",
"extension",
"=",
"\"\"",
",",
"minimize",
"=",
"False",
")",
":",
"subdir_path",
"=",
"new_path",
"+",
"\"/\"",
"+",
"path",
".",
"split",
"(",
"\"/\"",
")",... | [
610,
4
] | [
635,
74
] | python | en | ['en', 'en', 'en'] | True |
Muncher.optimizeCss | (self, path) | replaces classes and ids with new values in a css file
Arguments:
path -- string path to css file to optimize
Returns:
string
| replaces classes and ids with new values in a css file | def optimizeCss(self, path):
"""replaces classes and ids with new values in a css file
Arguments:
path -- string path to css file to optimize
Returns:
string
"""
css = Util.fileGetContents(path)
return self.replaceCss(css) | [
"def",
"optimizeCss",
"(",
"self",
",",
"path",
")",
":",
"css",
"=",
"Util",
".",
"fileGetContents",
"(",
"path",
")",
"return",
"self",
".",
"replaceCss",
"(",
"css",
")"
] | [
643,
4
] | [
654,
35
] | python | en | ['en', 'en', 'en'] | True |
Muncher.optimizeHtml | (self, path) | replaces classes and ids with new values in an html file
Uses:
Muncher.replaceHtml
Arguments:
path -- string path to file to optimize
Returns:
string
| replaces classes and ids with new values in an html file | def optimizeHtml(self, path):
"""replaces classes and ids with new values in an html file
Uses:
Muncher.replaceHtml
Arguments:
path -- string path to file to optimize
Returns:
string
"""
html = Util.fileGetContents(path)
html = self.rep... | [
"def",
"optimizeHtml",
"(",
"self",
",",
"path",
")",
":",
"html",
"=",
"Util",
".",
"fileGetContents",
"(",
"path",
")",
"html",
"=",
"self",
".",
"replaceHtml",
"(",
"html",
")",
"html",
"=",
"self",
".",
"optimizeCssBlocks",
"(",
"html",
")",
"html"... | [
656,
4
] | [
674,
19
] | python | en | ['en', 'en', 'en'] | True |
Muncher.replaceHtml | (self, html) | replaces classes and ids with new values in an html file
Arguments:
html -- contents to replace
Returns:
string
| replaces classes and ids with new values in an html file | def replaceHtml(self, html):
"""replaces classes and ids with new values in an html file
Arguments:
html -- contents to replace
Returns:
string
"""
html = self.replaceHtmlIds(html)
html = self.replaceHtmlClasses(html)
return html | [
"def",
"replaceHtml",
"(",
"self",
",",
"html",
")",
":",
"html",
"=",
"self",
".",
"replaceHtmlIds",
"(",
"html",
")",
"html",
"=",
"self",
".",
"replaceHtmlClasses",
"(",
"html",
")",
"return",
"html"
] | [
676,
4
] | [
688,
19
] | python | en | ['en', 'en', 'en'] | True |
Muncher.replaceHtmlIds | (self, html) | replaces any instances of ids in html markup
Arguments:
html -- contents of file to replaces ids in
Returns:
string
| replaces any instances of ids in html markup | def replaceHtmlIds(self, html):
"""replaces any instances of ids in html markup
Arguments:
html -- contents of file to replaces ids in
Returns:
string
"""
for key, value in self.id_map.items():
key = key[1:]
value = value[1:]
... | [
"def",
"replaceHtmlIds",
"(",
"self",
",",
"html",
")",
":",
"for",
"key",
",",
"value",
"in",
"self",
".",
"id_map",
".",
"items",
"(",
")",
":",
"key",
"=",
"key",
"[",
"1",
":",
"]",
"value",
"=",
"value",
"[",
"1",
":",
"]",
"html",
"=",
... | [
690,
4
] | [
705,
19
] | python | en | ['en', 'en', 'en'] | True |
Muncher.replaceClassBlock | (self, class_block, key, value) | replaces a class string with the new class name
Arguments:
class_block -- string from what would be found within class="{class_block}"
key -- current class
value -- new class
Returns:
string
| replaces a class string with the new class name | def replaceClassBlock(self, class_block, key, value):
"""replaces a class string with the new class name
Arguments:
class_block -- string from what would be found within class="{class_block}"
key -- current class
value -- new class
Returns:
string
"""
... | [
"def",
"replaceClassBlock",
"(",
"self",
",",
"class_block",
",",
"key",
",",
"value",
")",
":",
"key_length",
"=",
"len",
"(",
"key",
")",
"classes",
"=",
"class_block",
".",
"split",
"(",
"\" \"",
")",
"i",
"=",
"0",
"for",
"class_name",
"in",
"class... | [
707,
4
] | [
731,
32
] | python | en | ['en', 'en', 'en'] | True |
Muncher.replaceHtmlClasses | (self, html) | replaces any instances of classes in html markup
Arguments:
html -- contents of file to replace classes in
Returns:
string
| replaces any instances of classes in html markup | def replaceHtmlClasses(self, html):
"""replaces any instances of classes in html markup
Arguments:
html -- contents of file to replace classes in
Returns:
string
"""
for key, value in self.class_map.items():
key = key[1:]
value = value[1... | [
"def",
"replaceHtmlClasses",
"(",
"self",
",",
"html",
")",
":",
"for",
"key",
",",
"value",
"in",
"self",
".",
"class_map",
".",
"items",
"(",
")",
":",
"key",
"=",
"key",
"[",
"1",
":",
"]",
"value",
"=",
"value",
"[",
"1",
":",
"]",
"class_blo... | [
733,
4
] | [
751,
19
] | python | en | ['en', 'en', 'en'] | True |
Muncher.optimizeCssBlocks | (self, html) | rewrites css blocks that are part of an html file
Arguments:
html -- contents of file we are replacing
Returns:
string
| rewrites css blocks that are part of an html file | def optimizeCssBlocks(self, html):
"""rewrites css blocks that are part of an html file
Arguments:
html -- contents of file we are replacing
Returns:
string
"""
result_css = ""
matches = self.getCssBlocks(html)
for match in matches:
... | [
"def",
"optimizeCssBlocks",
"(",
"self",
",",
"html",
")",
":",
"result_css",
"=",
"\"\"",
"matches",
"=",
"self",
".",
"getCssBlocks",
"(",
"html",
")",
"for",
"match",
"in",
"matches",
":",
"match",
"=",
"self",
".",
"replaceCss",
"(",
"match",
")",
... | [
753,
4
] | [
772,
19
] | python | en | ['en', 'en', 'en'] | True |
Muncher.getCssBlocks | (html) | searches a file and returns all css blocks <style type="text/css"></style>
Arguments:
html -- contents of file we are replacing
Returns:
list
| searches a file and returns all css blocks <style type="text/css"></style> | def getCssBlocks(html):
"""searches a file and returns all css blocks <style type="text/css"></style>
Arguments:
html -- contents of file we are replacing
Returns:
list
"""
return re.compile(r'\<style.*?\>(.*)\<\/style\>', re.DOTALL).findall(html) | [
"def",
"getCssBlocks",
"(",
"html",
")",
":",
"return",
"re",
".",
"compile",
"(",
"r'\\<style.*?\\>(.*)\\<\\/style\\>'",
",",
"re",
".",
"DOTALL",
")",
".",
"findall",
"(",
"html",
")"
] | [
775,
4
] | [
785,
82
] | python | en | ['en', 'en', 'en'] | True |
Muncher.replaceCss | (self, css) | single call to handle replacing ids and classes
Arguments:
css -- contents of file to replace
Returns:
string
| single call to handle replacing ids and classes | def replaceCss(self, css):
"""single call to handle replacing ids and classes
Arguments:
css -- contents of file to replace
Returns:
string
"""
css = self.replaceCssFromDictionary(self.class_map, css)
css = self.replaceCssFromDictionary(self.id_map, css... | [
"def",
"replaceCss",
"(",
"self",
",",
"css",
")",
":",
"css",
"=",
"self",
".",
"replaceCssFromDictionary",
"(",
"self",
".",
"class_map",
",",
"css",
")",
"css",
"=",
"self",
".",
"replaceCssFromDictionary",
"(",
"self",
".",
"id_map",
",",
"css",
")",... | [
787,
4
] | [
799,
18
] | python | en | ['en', 'en', 'en'] | True |
Muncher.replaceCssFromDictionary | (self, dictionary, css) | replaces any instances of classes and ids based on a dictionary
Arguments:
dictionary -- map of classes or ids to replace
css -- contents of css to replace
Returns:
string
| replaces any instances of classes and ids based on a dictionary | def replaceCssFromDictionary(self, dictionary, css):
"""replaces any instances of classes and ids based on a dictionary
Arguments:
dictionary -- map of classes or ids to replace
css -- contents of css to replace
Returns:
string
"""
# this really should ... | [
"def",
"replaceCssFromDictionary",
"(",
"self",
",",
"dictionary",
",",
"css",
")",
":",
"# this really should be done better",
"for",
"key",
",",
"value",
"in",
"dictionary",
".",
"items",
"(",
")",
":",
"css",
"=",
"css",
".",
"replace",
"(",
"key",
"+",
... | [
801,
4
] | [
826,
18
] | python | en | ['en', 'en', 'en'] | True |
Muncher.optimizeJavascriptBlocks | (self, html) | rewrites javascript blocks that are part of an html file
Arguments:
html -- contents of file we are replacing
Returns:
string
| rewrites javascript blocks that are part of an html file | def optimizeJavascriptBlocks(self, html):
"""rewrites javascript blocks that are part of an html file
Arguments:
html -- contents of file we are replacing
Returns:
string
"""
matches = self.getJsBlocks(html)
for match in matches:
new_js = m... | [
"def",
"optimizeJavascriptBlocks",
"(",
"self",
",",
"html",
")",
":",
"matches",
"=",
"self",
".",
"getJsBlocks",
"(",
"html",
")",
"for",
"match",
"in",
"matches",
":",
"new_js",
"=",
"match",
"if",
"self",
".",
"config",
".",
"compress_html",
":",
"ma... | [
828,
4
] | [
851,
19
] | python | en | ['en', 'en', 'en'] | True |
Muncher.getJsBlocks | (html) | searches a file and returns all javascript blocks: <script type="text/javascript"></script>
Arguments:
html -- contents of file we are replacing
Returns:
list
| searches a file and returns all javascript blocks: <script type="text/javascript"></script> | def getJsBlocks(html):
"""searches a file and returns all javascript blocks: <script type="text/javascript"></script>
Arguments:
html -- contents of file we are replacing
Returns:
list
"""
return re.compile(r'\<script(?! src).*?\>(.*?)\<\/script\>', re.DOTALL).... | [
"def",
"getJsBlocks",
"(",
"html",
")",
":",
"return",
"re",
".",
"compile",
"(",
"r'\\<script(?! src).*?\\>(.*?)\\<\\/script\\>'",
",",
"re",
".",
"DOTALL",
")",
".",
"findall",
"(",
"html",
")"
] | [
854,
4
] | [
864,
93
] | python | en | ['en', 'en', 'en'] | True |
Muncher.optimizeJavascript | (self, path) | optimizes javascript for a specific file
Arguments:
path -- path to js file on disk that we are optimizing
Returns:
string -- contents to replace file with
| optimizes javascript for a specific file | def optimizeJavascript(self, path):
"""optimizes javascript for a specific file
Arguments:
path -- path to js file on disk that we are optimizing
Returns:
string -- contents to replace file with
"""
js = Util.fileGetContents(path)
return self.replaceJav... | [
"def",
"optimizeJavascript",
"(",
"self",
",",
"path",
")",
":",
"js",
"=",
"Util",
".",
"fileGetContents",
"(",
"path",
")",
"return",
"self",
".",
"replaceJavascript",
"(",
"js",
")"
] | [
866,
4
] | [
877,
41
] | python | en | ['en', 'en', 'en'] | True |
Muncher.replaceJavascript | (self, js) | single call to handle replacing ids and classes
Arguments:
js -- contents of file to replace
Returns:
string
| single call to handle replacing ids and classes | def replaceJavascript(self, js):
"""single call to handle replacing ids and classes
Arguments:
js -- contents of file to replace
Returns:
string
"""
js = self.replaceJsFromDictionary(self.id_map, js)
js = self.replaceJsFromDictionary(self.class_map, js)... | [
"def",
"replaceJavascript",
"(",
"self",
",",
"js",
")",
":",
"js",
"=",
"self",
".",
"replaceJsFromDictionary",
"(",
"self",
".",
"id_map",
",",
"js",
")",
"js",
"=",
"self",
".",
"replaceJsFromDictionary",
"(",
"self",
".",
"class_map",
",",
"js",
")",... | [
879,
4
] | [
891,
17
] | python | en | ['en', 'en', 'en'] | True |
Muncher.getJsSelectors | (js, config) | finds all js selectors within a js block
Arguments:
js -- contents of js file to search
Returns:
list
| finds all js selectors within a js block | def getJsSelectors(js, config):
"""finds all js selectors within a js block
Arguments:
js -- contents of js file to search
Returns:
list
"""
valid_selectors = "|".join(config.custom_selectors) + "|" + "|".join(config.id_selectors) + "|" + "|".join(config.class_... | [
"def",
"getJsSelectors",
"(",
"js",
",",
"config",
")",
":",
"valid_selectors",
"=",
"\"|\"",
".",
"join",
"(",
"config",
".",
"custom_selectors",
")",
"+",
"\"|\"",
"+",
"\"|\"",
".",
"join",
"(",
"config",
".",
"id_selectors",
")",
"+",
"\"|\"",
"+",
... | [
894,
4
] | [
906,
85
] | python | en | ['en', 'ca', 'en'] | True |
Muncher.replaceJsFromDictionary | (self, dictionary, js) | replaces any instances of classes and ids based on a dictionary
Arguments:
dictionary -- map of classes or ids to replace
js -- contents of javascript to replace
Returns:
string
| replaces any instances of classes and ids based on a dictionary | def replaceJsFromDictionary(self, dictionary, js):
"""replaces any instances of classes and ids based on a dictionary
Arguments:
dictionary -- map of classes or ids to replace
js -- contents of javascript to replace
Returns:
string
"""
for key, value in... | [
"def",
"replaceJsFromDictionary",
"(",
"self",
",",
"dictionary",
",",
"js",
")",
":",
"for",
"key",
",",
"value",
"in",
"dictionary",
".",
"items",
"(",
")",
":",
"blocks",
"=",
"self",
".",
"getJsSelectors",
"(",
"js",
",",
"self",
".",
"config",
")"... | [
908,
4
] | [
942,
17
] | python | en | ['en', 'en', 'en'] | True |
MessageDictTest.test_both_codepaths | (self) |
We have two different codepaths that
extract a particular shape of dictionary
for messages to send to clients:
events:
These are the events we send to MANY
clients when a message is originally
sent.
fetch:
... |
We have two different codepaths that
extract a particular shape of dictionary
for messages to send to clients: | def test_both_codepaths(self) -> None:
"""
We have two different codepaths that
extract a particular shape of dictionary
for messages to send to clients:
events:
These are the events we send to MANY
clients when a message is originally
... | [
"def",
"test_both_codepaths",
"(",
"self",
")",
"->",
"None",
":",
"def",
"reload_message",
"(",
"msg_id",
":",
"int",
")",
"->",
"Message",
":",
"# Get a clean copy of the message, and",
"# clear the cache.",
"cache_delete",
"(",
"to_dict_cache_key_id",
"(",
"msg_id"... | [
27,
4
] | [
139,
65
] | python | en | ['en', 'error', 'th'] | False |
MessageHydrationTest.test_display_recipient_up_to_date | (self) |
This is a test for a bug where due to caching of message_dicts,
after updating a user's information, fetching those cached messages
via messages_for_ids would return message_dicts with display_recipient
still having the old information. The returned message_dicts should have
up-... |
This is a test for a bug where due to caching of message_dicts,
after updating a user's information, fetching those cached messages
via messages_for_ids would return message_dicts with display_recipient
still having the old information. The returned message_dicts should have
up-... | def test_display_recipient_up_to_date(self) -> None:
"""
This is a test for a bug where due to caching of message_dicts,
after updating a user's information, fetching those cached messages
via messages_for_ids would return message_dicts with display_recipient
still having the old... | [
"def",
"test_display_recipient_up_to_date",
"(",
"self",
")",
"->",
"None",
":",
"hamlet",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"cordelia",
"=",
"self",
".",
"example_user",
"(",
"\"cordelia\"",
")",
"message_id",
"=",
"self",
".",
"send_p... | [
434,
4
] | [
477,
81
] | python | en | ['en', 'error', 'th'] | False |
UpdateCacheMiddleware.process_response | (self, request, response) | Set the cache, if needed. | Set the cache, if needed. | def process_response(self, request, response):
"""Set the cache, if needed."""
if not self._should_update_cache(request, response):
# We don't need to update the cache, just return.
return response
if response.streaming or response.status_code not in (200, 304):
... | [
"def",
"process_response",
"(",
"self",
",",
"request",
",",
"response",
")",
":",
"if",
"not",
"self",
".",
"_should_update_cache",
"(",
"request",
",",
"response",
")",
":",
"# We don't need to update the cache, just return.",
"return",
"response",
"if",
"response... | [
73,
4
] | [
109,
23
] | python | en | ['en', 'en', 'en'] | True |
FetchFromCacheMiddleware.process_request | (self, request) |
Check whether the page is already cached and return the cached
version if available.
|
Check whether the page is already cached and return the cached
version if available.
| def process_request(self, request):
"""
Check whether the page is already cached and return the cached
version if available.
"""
if request.method not in ('GET', 'HEAD'):
request._cache_update_cache = False
return None # Don't bother checking the cache.
... | [
"def",
"process_request",
"(",
"self",
",",
"request",
")",
":",
"if",
"request",
".",
"method",
"not",
"in",
"(",
"'GET'",
",",
"'HEAD'",
")",
":",
"request",
".",
"_cache_update_cache",
"=",
"False",
"return",
"None",
"# Don't bother checking the cache.",
"#... | [
126,
4
] | [
152,
23
] | python | en | ['en', 'error', 'th'] | False |
GeoIP2.__init__ | (self, path=None, cache=0, country=None, city=None) |
Initialize the GeoIP object. No parameters are required to use default
settings. Keyword arguments may be passed in to customize the locations
of the GeoIP datasets.
* path: Base directory to where GeoIP data is located or the full path
to where the city or country data fil... |
Initialize the GeoIP object. No parameters are required to use default
settings. Keyword arguments may be passed in to customize the locations
of the GeoIP datasets. | def __init__(self, path=None, cache=0, country=None, city=None):
"""
Initialize the GeoIP object. No parameters are required to use default
settings. Keyword arguments may be passed in to customize the locations
of the GeoIP datasets.
* path: Base directory to where GeoIP data i... | [
"def",
"__init__",
"(",
"self",
",",
"path",
"=",
"None",
",",
"cache",
"=",
"0",
",",
"country",
"=",
"None",
",",
"city",
"=",
"None",
")",
":",
"# Checking the given cache option.",
"if",
"cache",
"in",
"self",
".",
"cache_options",
":",
"self",
".",
... | [
45,
4
] | [
113,
82
] | python | en | ['en', 'error', 'th'] | False |
GeoIP2._check_query | (self, query, country=False, city=False, city_or_country=False) | Check the query and database availability. | Check the query and database availability. | def _check_query(self, query, country=False, city=False, city_or_country=False):
"Check the query and database availability."
# Making sure a string was passed in for the query.
if not isinstance(query, str):
raise TypeError('GeoIP query must be a string, not type %s' % type(query)._... | [
"def",
"_check_query",
"(",
"self",
",",
"query",
",",
"country",
"=",
"False",
",",
"city",
"=",
"False",
",",
"city_or_country",
"=",
"False",
")",
":",
"# Making sure a string was passed in for the query.",
"if",
"not",
"isinstance",
"(",
"query",
",",
"str",... | [
141,
4
] | [
161,
20
] | python | en | ['en', 'en', 'en'] | True |
GeoIP2.city | (self, query) |
Return a dictionary of city information for the given IP address or
Fully Qualified Domain Name (FQDN). Some information in the dictionary
may be undefined (None).
|
Return a dictionary of city information for the given IP address or
Fully Qualified Domain Name (FQDN). Some information in the dictionary
may be undefined (None).
| def city(self, query):
"""
Return a dictionary of city information for the given IP address or
Fully Qualified Domain Name (FQDN). Some information in the dictionary
may be undefined (None).
"""
enc_query = self._check_query(query, city=True)
return City(self._cit... | [
"def",
"city",
"(",
"self",
",",
"query",
")",
":",
"enc_query",
"=",
"self",
".",
"_check_query",
"(",
"query",
",",
"city",
"=",
"True",
")",
"return",
"City",
"(",
"self",
".",
"_city",
".",
"city",
"(",
"enc_query",
")",
")"
] | [
163,
4
] | [
170,
47
] | python | en | ['en', 'error', 'th'] | False |
GeoIP2.country_code | (self, query) | Return the country code for the given IP Address or FQDN. | Return the country code for the given IP Address or FQDN. | def country_code(self, query):
"Return the country code for the given IP Address or FQDN."
enc_query = self._check_query(query, city_or_country=True)
return self.country(enc_query)['country_code'] | [
"def",
"country_code",
"(",
"self",
",",
"query",
")",
":",
"enc_query",
"=",
"self",
".",
"_check_query",
"(",
"query",
",",
"city_or_country",
"=",
"True",
")",
"return",
"self",
".",
"country",
"(",
"enc_query",
")",
"[",
"'country_code'",
"]"
] | [
172,
4
] | [
175,
54
] | python | en | ['en', 'en', 'en'] | True |
GeoIP2.country_name | (self, query) | Return the country name for the given IP Address or FQDN. | Return the country name for the given IP Address or FQDN. | def country_name(self, query):
"Return the country name for the given IP Address or FQDN."
enc_query = self._check_query(query, city_or_country=True)
return self.country(enc_query)['country_name'] | [
"def",
"country_name",
"(",
"self",
",",
"query",
")",
":",
"enc_query",
"=",
"self",
".",
"_check_query",
"(",
"query",
",",
"city_or_country",
"=",
"True",
")",
"return",
"self",
".",
"country",
"(",
"enc_query",
")",
"[",
"'country_name'",
"]"
] | [
177,
4
] | [
180,
54
] | python | en | ['en', 'en', 'en'] | True |
GeoIP2.country | (self, query) |
Return a dictionary with the country code and name when given an
IP address or a Fully Qualified Domain Name (FQDN). For example, both
'24.124.1.80' and 'djangoproject.com' are valid parameters.
|
Return a dictionary with the country code and name when given an
IP address or a Fully Qualified Domain Name (FQDN). For example, both
'24.124.1.80' and 'djangoproject.com' are valid parameters.
| def country(self, query):
"""
Return a dictionary with the country code and name when given an
IP address or a Fully Qualified Domain Name (FQDN). For example, both
'24.124.1.80' and 'djangoproject.com' are valid parameters.
"""
# Returning the country code and name
... | [
"def",
"country",
"(",
"self",
",",
"query",
")",
":",
"# Returning the country code and name",
"enc_query",
"=",
"self",
".",
"_check_query",
"(",
"query",
",",
"city_or_country",
"=",
"True",
")",
"return",
"Country",
"(",
"self",
".",
"_country_or_city",
"(",... | [
182,
4
] | [
190,
56
] | python | en | ['en', 'error', 'th'] | False |
GeoIP2.lon_lat | (self, query) | Return a tuple of the (longitude, latitude) for the given query. | Return a tuple of the (longitude, latitude) for the given query. | def lon_lat(self, query):
"Return a tuple of the (longitude, latitude) for the given query."
return self.coords(query) | [
"def",
"lon_lat",
"(",
"self",
",",
"query",
")",
":",
"return",
"self",
".",
"coords",
"(",
"query",
")"
] | [
200,
4
] | [
202,
33
] | python | en | ['en', 'en', 'en'] | True |
GeoIP2.lat_lon | (self, query) | Return a tuple of the (latitude, longitude) for the given query. | Return a tuple of the (latitude, longitude) for the given query. | def lat_lon(self, query):
"Return a tuple of the (latitude, longitude) for the given query."
return self.coords(query, ('latitude', 'longitude')) | [
"def",
"lat_lon",
"(",
"self",
",",
"query",
")",
":",
"return",
"self",
".",
"coords",
"(",
"query",
",",
"(",
"'latitude'",
",",
"'longitude'",
")",
")"
] | [
204,
4
] | [
206,
60
] | python | en | ['en', 'en', 'en'] | True |
GeoIP2.geos | (self, query) | Return a GEOS Point object for the given query. | Return a GEOS Point object for the given query. | def geos(self, query):
"Return a GEOS Point object for the given query."
ll = self.lon_lat(query)
if ll:
from django.contrib.gis.geos import Point
return Point(ll, srid=4326)
else:
return None | [
"def",
"geos",
"(",
"self",
",",
"query",
")",
":",
"ll",
"=",
"self",
".",
"lon_lat",
"(",
"query",
")",
"if",
"ll",
":",
"from",
"django",
".",
"contrib",
".",
"gis",
".",
"geos",
"import",
"Point",
"return",
"Point",
"(",
"ll",
",",
"srid",
"=... | [
208,
4
] | [
215,
23
] | python | en | ['en', 'en', 'en'] | True |
GeoIP2.info | (self) | Return information about the GeoIP library and databases in use. | Return information about the GeoIP library and databases in use. | def info(self):
"Return information about the GeoIP library and databases in use."
meta = self._reader.metadata()
return 'GeoIP Library:\n\t%s.%s\n' % (meta.binary_format_major_version, meta.binary_format_minor_version) | [
"def",
"info",
"(",
"self",
")",
":",
"meta",
"=",
"self",
".",
"_reader",
".",
"metadata",
"(",
")",
"return",
"'GeoIP Library:\\n\\t%s.%s\\n'",
"%",
"(",
"meta",
".",
"binary_format_major_version",
",",
"meta",
".",
"binary_format_minor_version",
")"
] | [
219,
4
] | [
222,
113
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.