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
Stat._getmean
(self)
Get average pixel level for each layer
Get average pixel level for each layer
def _getmean(self): """Get average pixel level for each layer""" v = [] for i in self.bands: v.append(self.sum[i] / self.count[i]) return v
[ "def", "_getmean", "(", "self", ")", ":", "v", "=", "[", "]", "for", "i", "in", "self", ".", "bands", ":", "v", ".", "append", "(", "self", ".", "sum", "[", "i", "]", "/", "self", ".", "count", "[", "i", "]", ")", "return", "v" ]
[ 97, 4 ]
[ 103, 16 ]
python
en
['en', 'en', 'en']
True
Stat._getmedian
(self)
Get median pixel level for each layer
Get median pixel level for each layer
def _getmedian(self): """Get median pixel level for each layer""" v = [] for i in self.bands: s = 0 half = self.count[i] // 2 b = i * 256 for j in range(256): s = s + self.h[b + j] if s > half: b...
[ "def", "_getmedian", "(", "self", ")", ":", "v", "=", "[", "]", "for", "i", "in", "self", ".", "bands", ":", "s", "=", "0", "half", "=", "self", ".", "count", "[", "i", "]", "//", "2", "b", "=", "i", "*", "256", "for", "j", "in", "range", ...
[ 105, 4 ]
[ 118, 16 ]
python
en
['en', 'da', 'en']
True
Stat._getrms
(self)
Get RMS for each layer
Get RMS for each layer
def _getrms(self): """Get RMS for each layer""" v = [] for i in self.bands: v.append(math.sqrt(self.sum2[i] / self.count[i])) return v
[ "def", "_getrms", "(", "self", ")", ":", "v", "=", "[", "]", "for", "i", "in", "self", ".", "bands", ":", "v", ".", "append", "(", "math", ".", "sqrt", "(", "self", ".", "sum2", "[", "i", "]", "/", "self", ".", "count", "[", "i", "]", ")", ...
[ 120, 4 ]
[ 126, 16 ]
python
en
['en', 'en', 'en']
True
Stat._getvar
(self)
Get variance for each layer
Get variance for each layer
def _getvar(self): """Get variance for each layer""" v = [] for i in self.bands: n = self.count[i] v.append((self.sum2[i] - (self.sum[i] ** 2.0) / n) / n) return v
[ "def", "_getvar", "(", "self", ")", ":", "v", "=", "[", "]", "for", "i", "in", "self", ".", "bands", ":", "n", "=", "self", ".", "count", "[", "i", "]", "v", ".", "append", "(", "(", "self", ".", "sum2", "[", "i", "]", "-", "(", "self", "...
[ 128, 4 ]
[ 135, 16 ]
python
en
['en', 'en', 'en']
True
Stat._getstddev
(self)
Get standard deviation for each layer
Get standard deviation for each layer
def _getstddev(self): """Get standard deviation for each layer""" v = [] for i in self.bands: v.append(math.sqrt(self.var[i])) return v
[ "def", "_getstddev", "(", "self", ")", ":", "v", "=", "[", "]", "for", "i", "in", "self", ".", "bands", ":", "v", ".", "append", "(", "math", ".", "sqrt", "(", "self", ".", "var", "[", "i", "]", ")", ")", "return", "v" ]
[ 137, 4 ]
[ 143, 16 ]
python
en
['en', 'en', 'en']
True
Command.compile_messages
(self, locations)
Locations is a list of tuples: [(directory, file), ...]
Locations is a list of tuples: [(directory, file), ...]
def compile_messages(self, locations): """ Locations is a list of tuples: [(directory, file), ...] """ with concurrent.futures.ThreadPoolExecutor() as executor: futures = [] for i, (dirpath, f) in enumerate(locations): if self.verbosity > 0: ...
[ "def", "compile_messages", "(", "self", ",", "locations", ")", ":", "with", "concurrent", ".", "futures", ".", "ThreadPoolExecutor", "(", ")", "as", "executor", ":", "futures", "=", "[", "]", "for", "i", ",", "(", "dirpath", ",", "f", ")", "in", "enume...
[ 116, 4 ]
[ 157, 42 ]
python
en
['en', 'error', 'th']
False
test_price_as_sub_units
(price_even)
Test the price is converted to sub units
Test the price is converted to sub units
def test_price_as_sub_units(price_even): """Test the price is converted to sub units""" even = price_as_sub_units(price_even) assert even == 1000
[ "def", "test_price_as_sub_units", "(", "price_even", ")", ":", "even", "=", "price_as_sub_units", "(", "price_even", ")", "assert", "even", "==", "1000" ]
[ 22, 0 ]
[ 25, 23 ]
python
en
['en', 'en', 'en']
True
test_round_price
(price_even, price_round_up, price_round_down)
Test the price is round correctly
Test the price is round correctly
def test_round_price(price_even, price_round_up, price_round_down): """Test the price is round correctly""" even = round_price(price_even) up = round_price(price_round_up) down = round_price(price_round_down) assert even == Decimal('10.00') assert up == Decimal('10.00') assert down == Decima...
[ "def", "test_round_price", "(", "price_even", ",", "price_round_up", ",", "price_round_down", ")", ":", "even", "=", "round_price", "(", "price_even", ")", "up", "=", "round_price", "(", "price_round_up", ")", "down", "=", "round_price", "(", "price_round_down", ...
[ 28, 0 ]
[ 35, 34 ]
python
en
['en', 'en', 'en']
True
StubsModule.context
(self)
Component stub context.
Component stub context.
def context(self): """Component stub context.""" return self.parent.context
[ "def", "context", "(", "self", ")", ":", "return", "self", ".", "parent", ".", "context" ]
[ 33, 4 ]
[ 35, 34 ]
python
en
['en', 'ca', 'en']
True
StubsModule.config
(self)
Component specific config values. Returns: dict: Current config.
Component specific config values.
def config(self) -> dict: """Component specific config values. Returns: dict: Current config. """ return self.parent.config
[ "def", "config", "(", "self", ")", "->", "dict", ":", "return", "self", ".", "parent", ".", "config" ]
[ 38, 4 ]
[ 45, 33 ]
python
en
['en', 'en', 'en']
True
StubsModule.stubs
(self)
Component stubs. Returns: List[micropy.stubs.Stub]: List of stubs used in project.
Component stubs.
def stubs(self) -> Union[StubManager, Sequence[DeviceStub]]: """Component stubs. Returns: List[micropy.stubs.Stub]: List of stubs used in project. """ _stubs = self.context.get("stubs", []) return self._resolve_subresource(_stubs)
[ "def", "stubs", "(", "self", ")", "->", "Union", "[", "StubManager", ",", "Sequence", "[", "DeviceStub", "]", "]", ":", "_stubs", "=", "self", ".", "context", ".", "get", "(", "\"stubs\"", ",", "[", "]", ")", "return", "self", ".", "_resolve_subresourc...
[ 49, 4 ]
[ 57, 48 ]
python
en
['de', 'en', 'en']
False
StubsModule.get_stub_tree
(self, stubs)
Retrieve and order paths to base stubs and any stubs they depend on. Args: stubs: List of Stub Items Returns: Paths to all stubs project depends on.
Retrieve and order paths to base stubs and any stubs they depend on.
def get_stub_tree(self, stubs) -> Sequence[Path]: """Retrieve and order paths to base stubs and any stubs they depend on. Args: stubs: List of Stub Items Returns: Paths to all stubs project depends on. """ stub_tree = setutils.IndexedSet() base_...
[ "def", "get_stub_tree", "(", "self", ",", "stubs", ")", "->", "Sequence", "[", "Path", "]", ":", "stub_tree", "=", "setutils", ".", "IndexedSet", "(", ")", "base_stubs", "=", "setutils", ".", "IndexedSet", "(", "[", "s", ".", "stubs", "for", "s", "in",...
[ 59, 4 ]
[ 74, 30 ]
python
en
['en', 'en', 'en']
True
StubsModule._resolve_subresource
( self, stubs: List[DeviceStub] )
Resolves stub resource. Args: stubs (stubs): Stubs Passed to Manager
Resolves stub resource.
def _resolve_subresource( self, stubs: List[DeviceStub] ) -> Union[StubManager, Sequence[DeviceStub]]: """Resolves stub resource. Args: stubs (stubs): Stubs Passed to Manager """ if not hasattr(self, "_parent"): return self._stubs if not self...
[ "def", "_resolve_subresource", "(", "self", ",", "stubs", ":", "List", "[", "DeviceStub", "]", ")", "->", "Union", "[", "StubManager", ",", "Sequence", "[", "DeviceStub", "]", "]", ":", "if", "not", "hasattr", "(", "self", ",", "\"_parent\"", ")", ":", ...
[ 76, 4 ]
[ 96, 27 ]
python
en
['et', 'ko', 'en']
False
StubsModule._load_stub_data
(self, stub_data=None, **kwargs)
Loads Serialized Stub Data. Args: stub_data (dict): Dict of Stubs
Loads Serialized Stub Data.
def _load_stub_data(self, stub_data=None, **kwargs): """Loads Serialized Stub Data. Args: stub_data (dict): Dict of Stubs """ for name, location in stub_data.items(): _path = Path(location).absolute() if Path(_path).exists(): yield se...
[ "def", "_load_stub_data", "(", "self", ",", "stub_data", "=", "None", ",", "*", "*", "kwargs", ")", ":", "for", "name", ",", "location", "in", "stub_data", ".", "items", "(", ")", ":", "_path", "=", "Path", "(", "location", ")", ".", "absolute", "(",...
[ 98, 4 ]
[ 109, 45 ]
python
pl
['pl', 'pl', 'en']
True
StubsModule.load
(self, **kwargs)
Loads stubs from info file. Args: stub_list (dict): Dict of Stubs
Loads stubs from info file.
def load(self, **kwargs): """Loads stubs from info file. Args: stub_list (dict): Dict of Stubs """ self.config.upsert("stubs", {s.name: s.stub_version for s in self._stubs}) stubs = list(self._load_stub_data(stub_data=self.config.get("stubs"))) stubs.extend(...
[ "def", "load", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "config", ".", "upsert", "(", "\"stubs\"", ",", "{", "s", ".", "name", ":", "s", ".", "stub_version", "for", "s", "in", "self", ".", "_stubs", "}", ")", "stubs", "=", "...
[ 111, 4 ]
[ 124, 25 ]
python
en
['en', 'en', 'en']
True
StubsModule.create
(self)
Create stub project files.
Create stub project files.
def create(self): """Create stub project files.""" self.log.info(f"Stubs: $[{' '.join(str(s) for s in self.stubs)}]") return self.load()
[ "def", "create", "(", "self", ")", ":", "self", ".", "log", ".", "info", "(", "f\"Stubs: $[{' '.join(str(s) for s in self.stubs)}]\"", ")", "return", "self", ".", "load", "(", ")" ]
[ 126, 4 ]
[ 129, 26 ]
python
en
['ro', 'en', 'en']
True
StubsModule.update
(self)
Update current project stubs.
Update current project stubs.
def update(self): """Update current project stubs.""" self.load() return self.stubs
[ "def", "update", "(", "self", ")", ":", "self", ".", "load", "(", ")", "return", "self", ".", "stubs" ]
[ 131, 4 ]
[ 134, 25 ]
python
en
['ro', 'en', 'en']
True
StubsModule.add_stub
(self, stub, **kwargs)
Add stub to project. Args: stub (Stub): Stub object to add Returns: [Stubs]: Project Stubs
Add stub to project.
def add_stub(self, stub, **kwargs): """Add stub to project. Args: stub (Stub): Stub object to add Returns: [Stubs]: Project Stubs """ self.context.extend("stubs", [stub]) self.log.info("Loading project...") self._resolve_subresource(self...
[ "def", "add_stub", "(", "self", ",", "stub", ",", "*", "*", "kwargs", ")", ":", "self", ".", "context", ".", "extend", "(", "\"stubs\"", ",", "[", "stub", "]", ")", "self", ".", "log", ".", "info", "(", "\"Loading project...\"", ")", "self", ".", "...
[ 137, 4 ]
[ 154, 25 ]
python
en
['en', 'en', 'en']
True
parse_html
(html)
Take a string that contains *valid* HTML and turn it into a Python object structure that can be easily compared against other HTML on semantic equivalence. Syntactical differences like which quotation is used on arguments will be ignored.
Take a string that contains *valid* HTML and turn it into a Python object structure that can be easily compared against other HTML on semantic equivalence. Syntactical differences like which quotation is used on arguments will be ignored.
def parse_html(html): """ Take a string that contains *valid* HTML and turn it into a Python object structure that can be easily compared against other HTML on semantic equivalence. Syntactical differences like which quotation is used on arguments will be ignored. """ parser = Parser() p...
[ "def", "parse_html", "(", "html", ")", ":", "parser", "=", "Parser", "(", ")", "parser", ".", "feed", "(", "html", ")", "parser", ".", "close", "(", ")", "document", "=", "parser", ".", "root", "document", ".", "finalize", "(", ")", "# Removing ROOT el...
[ 211, 0 ]
[ 227, 19 ]
python
en
['en', 'error', 'th']
False
AppsTests.test_singleton_master
(self)
Ensures that only one master registry can exist.
Ensures that only one master registry can exist.
def test_singleton_master(self): """ Ensures that only one master registry can exist. """ with self.assertRaises(RuntimeError): Apps(installed_apps=None)
[ "def", "test_singleton_master", "(", "self", ")", ":", "with", "self", ".", "assertRaises", "(", "RuntimeError", ")", ":", "Apps", "(", "installed_apps", "=", "None", ")" ]
[ 42, 4 ]
[ 47, 37 ]
python
en
['en', 'error', 'th']
False
AppsTests.test_ready
(self)
Tests the ready property of the master registry.
Tests the ready property of the master registry.
def test_ready(self): """ Tests the ready property of the master registry. """ # The master app registry is always ready when the tests run. self.assertTrue(apps.ready) # Non-master app registries are populated in __init__. self.assertTrue(Apps().ready)
[ "def", "test_ready", "(", "self", ")", ":", "# The master app registry is always ready when the tests run.", "self", ".", "assertTrue", "(", "apps", ".", "ready", ")", "# Non-master app registries are populated in __init__.", "self", ".", "assertTrue", "(", "Apps", "(", "...
[ 49, 4 ]
[ 56, 37 ]
python
en
['en', 'error', 'th']
False
AppsTests.test_bad_app_config
(self)
Tests when INSTALLED_APPS contains an incorrect app config.
Tests when INSTALLED_APPS contains an incorrect app config.
def test_bad_app_config(self): """ Tests when INSTALLED_APPS contains an incorrect app config. """ with self.assertRaises(ImproperlyConfigured): with self.settings(INSTALLED_APPS=['apps.apps.BadConfig']): pass
[ "def", "test_bad_app_config", "(", "self", ")", ":", "with", "self", ".", "assertRaises", "(", "ImproperlyConfigured", ")", ":", "with", "self", ".", "settings", "(", "INSTALLED_APPS", "=", "[", "'apps.apps.BadConfig'", "]", ")", ":", "pass" ]
[ 58, 4 ]
[ 64, 20 ]
python
en
['en', 'error', 'th']
False
AppsTests.test_not_an_app_config
(self)
Tests when INSTALLED_APPS contains a class that isn't an app config.
Tests when INSTALLED_APPS contains a class that isn't an app config.
def test_not_an_app_config(self): """ Tests when INSTALLED_APPS contains a class that isn't an app config. """ with self.assertRaises(ImproperlyConfigured): with self.settings(INSTALLED_APPS=['apps.apps.NotAConfig']): pass
[ "def", "test_not_an_app_config", "(", "self", ")", ":", "with", "self", ".", "assertRaises", "(", "ImproperlyConfigured", ")", ":", "with", "self", ".", "settings", "(", "INSTALLED_APPS", "=", "[", "'apps.apps.NotAConfig'", "]", ")", ":", "pass" ]
[ 66, 4 ]
[ 72, 20 ]
python
en
['en', 'error', 'th']
False
AppsTests.test_no_such_app
(self)
Tests when INSTALLED_APPS contains an app that doesn't exist, either directly or via an app config.
Tests when INSTALLED_APPS contains an app that doesn't exist, either directly or via an app config.
def test_no_such_app(self): """ Tests when INSTALLED_APPS contains an app that doesn't exist, either directly or via an app config. """ with self.assertRaises(ImportError): with self.settings(INSTALLED_APPS=['there is no such app']): pass with ...
[ "def", "test_no_such_app", "(", "self", ")", ":", "with", "self", ".", "assertRaises", "(", "ImportError", ")", ":", "with", "self", ".", "settings", "(", "INSTALLED_APPS", "=", "[", "'there is no such app'", "]", ")", ":", "pass", "with", "self", ".", "as...
[ 74, 4 ]
[ 84, 20 ]
python
en
['en', 'error', 'th']
False
AppsTests.test_no_such_app_config
(self)
Tests when INSTALLED_APPS contains an entry that doesn't exist.
Tests when INSTALLED_APPS contains an entry that doesn't exist.
def test_no_such_app_config(self): """ Tests when INSTALLED_APPS contains an entry that doesn't exist. """ with self.assertRaises(ImportError): with self.settings(INSTALLED_APPS=['apps.apps.NoSuchConfig']): pass
[ "def", "test_no_such_app_config", "(", "self", ")", ":", "with", "self", ".", "assertRaises", "(", "ImportError", ")", ":", "with", "self", ".", "settings", "(", "INSTALLED_APPS", "=", "[", "'apps.apps.NoSuchConfig'", "]", ")", ":", "pass" ]
[ 86, 4 ]
[ 92, 20 ]
python
en
['en', 'error', 'th']
False
AppsTests.test_get_app_configs
(self)
Tests apps.get_app_configs().
Tests apps.get_app_configs().
def test_get_app_configs(self): """ Tests apps.get_app_configs(). """ app_configs = apps.get_app_configs() self.assertListEqual( [app_config.name for app_config in app_configs], SOME_INSTALLED_APPS_NAMES)
[ "def", "test_get_app_configs", "(", "self", ")", ":", "app_configs", "=", "apps", ".", "get_app_configs", "(", ")", "self", ".", "assertListEqual", "(", "[", "app_config", ".", "name", "for", "app_config", "in", "app_configs", "]", ",", "SOME_INSTALLED_APPS_NAME...
[ 100, 4 ]
[ 107, 38 ]
python
en
['en', 'error', 'th']
False
AppsTests.test_get_app_config
(self)
Tests apps.get_app_config().
Tests apps.get_app_config().
def test_get_app_config(self): """ Tests apps.get_app_config(). """ app_config = apps.get_app_config('admin') self.assertEqual(app_config.name, 'django.contrib.admin') app_config = apps.get_app_config('staticfiles') self.assertEqual(app_config.name, 'django.contr...
[ "def", "test_get_app_config", "(", "self", ")", ":", "app_config", "=", "apps", ".", "get_app_config", "(", "'admin'", ")", "self", ".", "assertEqual", "(", "app_config", ".", "name", ",", "'django.contrib.admin'", ")", "app_config", "=", "apps", ".", "get_app...
[ 110, 4 ]
[ 121, 44 ]
python
en
['en', 'error', 'th']
False
AppsTests.test_is_installed
(self)
Tests apps.is_installed().
Tests apps.is_installed().
def test_is_installed(self): """ Tests apps.is_installed(). """ self.assertTrue(apps.is_installed('django.contrib.admin')) self.assertTrue(apps.is_installed('django.contrib.auth')) self.assertTrue(apps.is_installed('django.contrib.staticfiles')) self.assertFalse(a...
[ "def", "test_is_installed", "(", "self", ")", ":", "self", ".", "assertTrue", "(", "apps", ".", "is_installed", "(", "'django.contrib.admin'", ")", ")", "self", ".", "assertTrue", "(", "apps", ".", "is_installed", "(", "'django.contrib.auth'", ")", ")", "self"...
[ 124, 4 ]
[ 131, 71 ]
python
en
['en', 'error', 'th']
False
AppsTests.test_get_model
(self)
Tests apps.get_model().
Tests apps.get_model().
def test_get_model(self): """ Tests apps.get_model(). """ self.assertEqual(apps.get_model('admin', 'LogEntry'), LogEntry) with self.assertRaises(LookupError): apps.get_model('admin', 'LogExit') # App label is case-sensitive, Model name is case-insensitive. ...
[ "def", "test_get_model", "(", "self", ")", ":", "self", ".", "assertEqual", "(", "apps", ".", "get_model", "(", "'admin'", ",", "'LogEntry'", ")", ",", "LogEntry", ")", "with", "self", ".", "assertRaises", "(", "LookupError", ")", ":", "apps", ".", "get_...
[ 134, 4 ]
[ 152, 44 ]
python
en
['en', 'error', 'th']
False
AppsTests.test_import_exception_is_not_masked
(self)
App discovery should preserve stack traces. Regression test for #22920.
App discovery should preserve stack traces. Regression test for #22920.
def test_import_exception_is_not_masked(self): """ App discovery should preserve stack traces. Regression test for #22920. """ with six.assertRaisesRegex(self, ImportError, "Oops"): with self.settings(INSTALLED_APPS=['apps.failing_app']): pass
[ "def", "test_import_exception_is_not_masked", "(", "self", ")", ":", "with", "six", ".", "assertRaisesRegex", "(", "self", ",", "ImportError", ",", "\"Oops\"", ")", ":", "with", "self", ".", "settings", "(", "INSTALLED_APPS", "=", "[", "'apps.failing_app'", "]",...
[ 168, 4 ]
[ 174, 20 ]
python
en
['en', 'error', 'th']
False
AppsTests.test_models_py
(self)
Tests that the models in the models.py file were loaded correctly.
Tests that the models in the models.py file were loaded correctly.
def test_models_py(self): """ Tests that the models in the models.py file were loaded correctly. """ self.assertEqual(apps.get_model("apps", "TotallyNormal"), TotallyNormal) with self.assertRaises(LookupError): apps.get_model("apps", "SoAlternative") with sel...
[ "def", "test_models_py", "(", "self", ")", ":", "self", ".", "assertEqual", "(", "apps", ".", "get_model", "(", "\"apps\"", ",", "\"TotallyNormal\"", ")", ",", "TotallyNormal", ")", "with", "self", ".", "assertRaises", "(", "LookupError", ")", ":", "apps", ...
[ 176, 4 ]
[ 186, 84 ]
python
en
['en', 'error', 'th']
False
AppsTests.test_dynamic_load
(self)
Makes a new model at runtime and ensures it goes into the right place.
Makes a new model at runtime and ensures it goes into the right place.
def test_dynamic_load(self): """ Makes a new model at runtime and ensures it goes into the right place. """ old_models = list(apps.get_app_config("apps").get_models()) # Construct a new model in a new app registry body = {} new_apps = Apps(["apps"]) meta_c...
[ "def", "test_dynamic_load", "(", "self", ")", ":", "old_models", "=", "list", "(", "apps", ".", "get_app_config", "(", "\"apps\"", ")", ".", "get_models", "(", ")", ")", "# Construct a new model in a new app registry", "body", "=", "{", "}", "new_apps", "=", "...
[ 188, 4 ]
[ 208, 79 ]
python
en
['en', 'error', 'th']
False
AppConfigTests.test_path_set_explicitly
(self)
If subclass sets path as class attr, no module attributes needed.
If subclass sets path as class attr, no module attributes needed.
def test_path_set_explicitly(self): """If subclass sets path as class attr, no module attributes needed.""" class MyAppConfig(AppConfig): path = 'foo' ac = MyAppConfig('label', Stub()) self.assertEqual(ac.path, 'foo')
[ "def", "test_path_set_explicitly", "(", "self", ")", ":", "class", "MyAppConfig", "(", "AppConfig", ")", ":", "path", "=", "'foo'", "ac", "=", "MyAppConfig", "(", "'label'", ",", "Stub", "(", ")", ")", "self", ".", "assertEqual", "(", "ac", ".", "path", ...
[ 218, 4 ]
[ 225, 40 ]
python
en
['en', 'en', 'en']
True
AppConfigTests.test_explicit_path_overrides
(self)
If path set as class attr, overrides __path__ and __file__.
If path set as class attr, overrides __path__ and __file__.
def test_explicit_path_overrides(self): """If path set as class attr, overrides __path__ and __file__.""" class MyAppConfig(AppConfig): path = 'foo' ac = MyAppConfig('label', Stub(__path__=['a'], __file__='b/__init__.py')) self.assertEqual(ac.path, 'foo')
[ "def", "test_explicit_path_overrides", "(", "self", ")", ":", "class", "MyAppConfig", "(", "AppConfig", ")", ":", "path", "=", "'foo'", "ac", "=", "MyAppConfig", "(", "'label'", ",", "Stub", "(", "__path__", "=", "[", "'a'", "]", ",", "__file__", "=", "'...
[ 227, 4 ]
[ 234, 40 ]
python
en
['en', 'en', 'en']
True
AppConfigTests.test_dunder_path
(self)
If single element in __path__, use it (in preference to __file__).
If single element in __path__, use it (in preference to __file__).
def test_dunder_path(self): """If single element in __path__, use it (in preference to __file__).""" ac = AppConfig('label', Stub(__path__=['a'], __file__='b/__init__.py')) self.assertEqual(ac.path, 'a')
[ "def", "test_dunder_path", "(", "self", ")", ":", "ac", "=", "AppConfig", "(", "'label'", ",", "Stub", "(", "__path__", "=", "[", "'a'", "]", ",", "__file__", "=", "'b/__init__.py'", ")", ")", "self", ".", "assertEqual", "(", "ac", ".", "path", ",", ...
[ 236, 4 ]
[ 240, 38 ]
python
en
['en', 'en', 'en']
True
AppConfigTests.test_no_dunder_path_fallback_to_dunder_file
(self)
If there is no __path__ attr, use __file__.
If there is no __path__ attr, use __file__.
def test_no_dunder_path_fallback_to_dunder_file(self): """If there is no __path__ attr, use __file__.""" ac = AppConfig('label', Stub(__file__='b/__init__.py')) self.assertEqual(ac.path, 'b')
[ "def", "test_no_dunder_path_fallback_to_dunder_file", "(", "self", ")", ":", "ac", "=", "AppConfig", "(", "'label'", ",", "Stub", "(", "__file__", "=", "'b/__init__.py'", ")", ")", "self", ".", "assertEqual", "(", "ac", ".", "path", ",", "'b'", ")" ]
[ 242, 4 ]
[ 246, 38 ]
python
en
['en', 'en', 'en']
True
AppConfigTests.test_empty_dunder_path_fallback_to_dunder_file
(self)
If the __path__ attr is empty, use __file__ if set.
If the __path__ attr is empty, use __file__ if set.
def test_empty_dunder_path_fallback_to_dunder_file(self): """If the __path__ attr is empty, use __file__ if set.""" ac = AppConfig('label', Stub(__path__=[], __file__='b/__init__.py')) self.assertEqual(ac.path, 'b')
[ "def", "test_empty_dunder_path_fallback_to_dunder_file", "(", "self", ")", ":", "ac", "=", "AppConfig", "(", "'label'", ",", "Stub", "(", "__path__", "=", "[", "]", ",", "__file__", "=", "'b/__init__.py'", ")", ")", "self", ".", "assertEqual", "(", "ac", "."...
[ 248, 4 ]
[ 252, 38 ]
python
en
['en', 'en', 'en']
True
AppConfigTests.test_multiple_dunder_path_fallback_to_dunder_file
(self)
If the __path__ attr is length>1, use __file__ if set.
If the __path__ attr is length>1, use __file__ if set.
def test_multiple_dunder_path_fallback_to_dunder_file(self): """If the __path__ attr is length>1, use __file__ if set.""" ac = AppConfig('label', Stub(__path__=['a', 'b'], __file__='c/__init__.py')) self.assertEqual(ac.path, 'c')
[ "def", "test_multiple_dunder_path_fallback_to_dunder_file", "(", "self", ")", ":", "ac", "=", "AppConfig", "(", "'label'", ",", "Stub", "(", "__path__", "=", "[", "'a'", ",", "'b'", "]", ",", "__file__", "=", "'c/__init__.py'", ")", ")", "self", ".", "assert...
[ 254, 4 ]
[ 258, 38 ]
python
en
['en', 'en', 'en']
True
AppConfigTests.test_no_dunder_path_or_dunder_file
(self)
If there is no __path__ or __file__, raise ImproperlyConfigured.
If there is no __path__ or __file__, raise ImproperlyConfigured.
def test_no_dunder_path_or_dunder_file(self): """If there is no __path__ or __file__, raise ImproperlyConfigured.""" with self.assertRaises(ImproperlyConfigured): AppConfig('label', Stub())
[ "def", "test_no_dunder_path_or_dunder_file", "(", "self", ")", ":", "with", "self", ".", "assertRaises", "(", "ImproperlyConfigured", ")", ":", "AppConfig", "(", "'label'", ",", "Stub", "(", ")", ")" ]
[ 260, 4 ]
[ 263, 38 ]
python
en
['en', 'en', 'en']
True
AppConfigTests.test_empty_dunder_path_no_dunder_file
(self)
If the __path__ attr is empty and there is no __file__, raise.
If the __path__ attr is empty and there is no __file__, raise.
def test_empty_dunder_path_no_dunder_file(self): """If the __path__ attr is empty and there is no __file__, raise.""" with self.assertRaises(ImproperlyConfigured): AppConfig('label', Stub(__path__=[]))
[ "def", "test_empty_dunder_path_no_dunder_file", "(", "self", ")", ":", "with", "self", ".", "assertRaises", "(", "ImproperlyConfigured", ")", ":", "AppConfig", "(", "'label'", ",", "Stub", "(", "__path__", "=", "[", "]", ")", ")" ]
[ 265, 4 ]
[ 268, 49 ]
python
en
['en', 'en', 'en']
True
AppConfigTests.test_multiple_dunder_path_no_dunder_file
(self)
If the __path__ attr is length>1 and there is no __file__, raise.
If the __path__ attr is length>1 and there is no __file__, raise.
def test_multiple_dunder_path_no_dunder_file(self): """If the __path__ attr is length>1 and there is no __file__, raise.""" with self.assertRaises(ImproperlyConfigured): AppConfig('label', Stub(__path__=['a', 'b']))
[ "def", "test_multiple_dunder_path_no_dunder_file", "(", "self", ")", ":", "with", "self", ".", "assertRaises", "(", "ImproperlyConfigured", ")", ":", "AppConfig", "(", "'label'", ",", "Stub", "(", "__path__", "=", "[", "'a'", ",", "'b'", "]", ")", ")" ]
[ 270, 4 ]
[ 273, 57 ]
python
en
['en', 'en', 'en']
True
RelatedObject.get_choices
(self, include_blank=True, blank_choice=BLANK_CHOICE_DASH, limit_to_currently_related=False)
Returns choices with a default blank choices included, for use as SelectField choices for this field. Analogue of django.db.models.fields.Field.get_choices, provided initially for utilization by RelatedFieldListFilter.
Returns choices with a default blank choices included, for use as SelectField choices for this field.
def get_choices(self, include_blank=True, blank_choice=BLANK_CHOICE_DASH, limit_to_currently_related=False): """Returns choices with a default blank choices included, for use as SelectField choices for this field. Analogue of django.db.models.fields.Field.get_choices, provid...
[ "def", "get_choices", "(", "self", ",", "include_blank", "=", "True", ",", "blank_choice", "=", "BLANK_CHOICE_DASH", ",", "limit_to_currently_related", "=", "False", ")", ":", "first_choice", "=", "blank_choice", "if", "include_blank", "else", "[", "]", "queryset"...
[ 22, 4 ]
[ 36, 33 ]
python
en
['en', 'en', 'en']
True
RelatedObject.editable_fields
(self)
Get the fields in this class that should be edited inline.
Get the fields in this class that should be edited inline.
def editable_fields(self): "Get the fields in this class that should be edited inline." return [f for f in self.opts.fields + self.opts.many_to_many if f.editable and f != self.field]
[ "def", "editable_fields", "(", "self", ")", ":", "return", "[", "f", "for", "f", "in", "self", ".", "opts", ".", "fields", "+", "self", ".", "opts", ".", "many_to_many", "if", "f", ".", "editable", "and", "f", "!=", "self", ".", "field", "]" ]
[ 43, 4 ]
[ 45, 103 ]
python
en
['en', 'en', 'en']
True
register_handler
(handler)
Install application-specific GRIB image handler. :param handler: Handler object.
Install application-specific GRIB image handler.
def register_handler(handler): """ Install application-specific GRIB image handler. :param handler: Handler object. """ global _handler _handler = handler
[ "def", "register_handler", "(", "handler", ")", ":", "global", "_handler", "_handler", "=", "handler" ]
[ 17, 0 ]
[ 24, 22 ]
python
en
['en', 'error', 'th']
False
ActionAdmin.remove_url
(self, name)
Remove all entries named 'name' from the ModelAdmin instance URL patterns list
Remove all entries named 'name' from the ModelAdmin instance URL patterns list
def remove_url(self, name): """ Remove all entries named 'name' from the ModelAdmin instance URL patterns list """ return [url for url in super(ActionAdmin, self).get_urls() if url.name != name]
[ "def", "remove_url", "(", "self", ",", "name", ")", ":", "return", "[", "url", "for", "url", "in", "super", "(", "ActionAdmin", ",", "self", ")", ".", "get_urls", "(", ")", "if", "url", ".", "name", "!=", "name", "]" ]
[ 27, 4 ]
[ 32, 87 ]
python
en
['en', 'error', 'th']
False
ScriptMaker._build_shebang
(self, executable, post_interp)
Build a shebang line. In the simple case (on Windows, or a shebang line which is not too long or contains spaces) use a simple formulation for the shebang. Otherwise, use /bin/sh as the executable, with a contrived shebang which allows the script to run either under Python or sh, using ...
Build a shebang line. In the simple case (on Windows, or a shebang line which is not too long or contains spaces) use a simple formulation for the shebang. Otherwise, use /bin/sh as the executable, with a contrived shebang which allows the script to run either under Python or sh, using ...
def _build_shebang(self, executable, post_interp): """ Build a shebang line. In the simple case (on Windows, or a shebang line which is not too long or contains spaces) use a simple formulation for the shebang. Otherwise, use /bin/sh as the executable, with a contrived shebang wh...
[ "def", "_build_shebang", "(", "self", ",", "executable", ",", "post_interp", ")", ":", "if", "os", ".", "name", "!=", "'posix'", ":", "simple_shebang", "=", "True", "else", ":", "# Add 3 for '#!' prefix and newline suffix.", "shebang_length", "=", "len", "(", "e...
[ 123, 4 ]
[ 152, 21 ]
python
en
['en', 'error', 'th']
False
ScriptMaker.make
(self, specification, options=None)
Make a script. :param specification: The specification, which is either a valid export entry specification (to make a script from a callable) or a filename (to make a script by copying from a source location). ...
Make a script.
def make(self, specification, options=None): """ Make a script. :param specification: The specification, which is either a valid export entry specification (to make a script from a callable) or a filename (to make a script by ...
[ "def", "make", "(", "self", ",", "specification", ",", "options", "=", "None", ")", ":", "filenames", "=", "[", "]", "entry", "=", "get_export_entry", "(", "specification", ")", "if", "entry", "is", "None", ":", "self", ".", "_copy_script", "(", "specifi...
[ 387, 4 ]
[ 404, 24 ]
python
en
['en', 'error', 'th']
False
ScriptMaker.make_multiple
(self, specifications, options=None)
Take a list of specifications and make scripts from them, :param specifications: A list of specifications. :return: A list of all absolute pathnames written to,
Take a list of specifications and make scripts from them, :param specifications: A list of specifications. :return: A list of all absolute pathnames written to,
def make_multiple(self, specifications, options=None): """ Take a list of specifications and make scripts from them, :param specifications: A list of specifications. :return: A list of all absolute pathnames written to, """ filenames = [] for specification in spec...
[ "def", "make_multiple", "(", "self", ",", "specifications", ",", "options", "=", "None", ")", ":", "filenames", "=", "[", "]", "for", "specification", "in", "specifications", ":", "filenames", ".", "extend", "(", "self", ".", "make", "(", "specification", ...
[ 406, 4 ]
[ 415, 24 ]
python
en
['en', 'error', 'th']
False
Loader.get_template
(self, template_name, skip=None)
Call self.get_template_sources() and return a Template object for the first template matching template_name. If skip is provided, ignore template origins in skip. This is used to avoid recursion during template extending.
Call self.get_template_sources() and return a Template object for the first template matching template_name. If skip is provided, ignore template origins in skip. This is used to avoid recursion during template extending.
def get_template(self, template_name, skip=None): """ Call self.get_template_sources() and return a Template object for the first template matching template_name. If skip is provided, ignore template origins in skip. This is used to avoid recursion during template extending. ...
[ "def", "get_template", "(", "self", ",", "template_name", ",", "skip", "=", "None", ")", ":", "tried", "=", "[", "]", "for", "origin", "in", "self", ".", "get_template_sources", "(", "template_name", ")", ":", "if", "skip", "is", "not", "None", "and", ...
[ 8, 4 ]
[ 32, 62 ]
python
en
['en', 'error', 'th']
False
Loader.get_template_sources
(self, template_name)
An iterator that yields possible matching template paths for a template name.
An iterator that yields possible matching template paths for a template name.
def get_template_sources(self, template_name): """ An iterator that yields possible matching template paths for a template name. """ raise NotImplementedError( 'subclasses of Loader must provide a get_template_sources() method' )
[ "def", "get_template_sources", "(", "self", ",", "template_name", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of Loader must provide a get_template_sources() method'", ")" ]
[ 34, 4 ]
[ 41, 9 ]
python
en
['en', 'error', 'th']
False
Loader.reset
(self)
Reset any state maintained by the loader instance (e.g. cached templates or cached loader modules).
Reset any state maintained by the loader instance (e.g. cached templates or cached loader modules).
def reset(self): """ Reset any state maintained by the loader instance (e.g. cached templates or cached loader modules). """ pass
[ "def", "reset", "(", "self", ")", ":", "pass" ]
[ 43, 4 ]
[ 48, 12 ]
python
en
['en', 'error', 'th']
False
CheckRegistry.register
(self, check=None, *tags, **kwargs)
Can be used as a function or a decorator. Register given function `f` labeled with given `tags`. The function should receive **kwargs and return list of Errors and Warnings. Example:: registry = CheckRegistry() @registry.register('mytag', 'anothertag') ...
Can be used as a function or a decorator. Register given function `f` labeled with given `tags`. The function should receive **kwargs and return list of Errors and Warnings.
def register(self, check=None, *tags, **kwargs): """ Can be used as a function or a decorator. Register given function `f` labeled with given `tags`. The function should receive **kwargs and return list of Errors and Warnings. Example:: registry = CheckRegistry() ...
[ "def", "register", "(", "self", ",", "check", "=", "None", ",", "*", "tags", ",", "*", "*", "kwargs", ")", ":", "def", "inner", "(", "check", ")", ":", "check", ".", "tags", "=", "tags", "checks", "=", "self", ".", "deployment_checks", "if", "kwarg...
[ 27, 4 ]
[ 54, 24 ]
python
en
['en', 'error', 'th']
False
CheckRegistry.run_checks
(self, app_configs=None, tags=None, include_deployment_checks=False)
Run all registered checks and return list of Errors and Warnings.
Run all registered checks and return list of Errors and Warnings.
def run_checks(self, app_configs=None, tags=None, include_deployment_checks=False): """ Run all registered checks and return list of Errors and Warnings. """ errors = [] checks = self.get_checks(include_deployment_checks) if tags is not None: checks = [check ...
[ "def", "run_checks", "(", "self", ",", "app_configs", "=", "None", ",", "tags", "=", "None", ",", "include_deployment_checks", "=", "False", ")", ":", "errors", "=", "[", "]", "checks", "=", "self", ".", "get_checks", "(", "include_deployment_checks", ")", ...
[ 56, 4 ]
[ 76, 21 ]
python
en
['en', 'error', 'th']
False
SettingsTests.test_override_settings_delete
(self)
Allow deletion of a setting in an overridden settings set (#18824)
Allow deletion of a setting in an overridden settings set (#18824)
def test_override_settings_delete(self): """ Allow deletion of a setting in an overridden settings set (#18824) """ previous_i18n = settings.USE_I18N previous_l10n = settings.USE_L10N with self.settings(USE_I18N=False): del settings.USE_I18N self.a...
[ "def", "test_override_settings_delete", "(", "self", ")", ":", "previous_i18n", "=", "settings", ".", "USE_I18N", "previous_l10n", "=", "settings", ".", "USE_L10N", "with", "self", ".", "settings", "(", "USE_I18N", "=", "False", ")", ":", "del", "settings", "....
[ 229, 4 ]
[ 242, 58 ]
python
en
['en', 'error', 'th']
False
SettingsTests.test_override_settings_nested
(self)
Test that override_settings uses the actual _wrapped attribute at runtime, not when it was instantiated.
Test that override_settings uses the actual _wrapped attribute at runtime, not when it was instantiated.
def test_override_settings_nested(self): """ Test that override_settings uses the actual _wrapped attribute at runtime, not when it was instantiated. """ self.assertRaises(AttributeError, getattr, settings, 'TEST') self.assertRaises(AttributeError, getattr, settings, 'TE...
[ "def", "test_override_settings_nested", "(", "self", ")", ":", "self", ".", "assertRaises", "(", "AttributeError", ",", "getattr", ",", "settings", ",", "'TEST'", ")", "self", ".", "assertRaises", "(", "AttributeError", ",", "getattr", ",", "settings", ",", "'...
[ 244, 4 ]
[ 265, 69 ]
python
en
['en', 'error', 'th']
False
SettingsTests.test_allowed_include_roots_string
(self)
ALLOWED_INCLUDE_ROOTS is not allowed to be incorrectly set to a string rather than a tuple.
ALLOWED_INCLUDE_ROOTS is not allowed to be incorrectly set to a string rather than a tuple.
def test_allowed_include_roots_string(self): """ ALLOWED_INCLUDE_ROOTS is not allowed to be incorrectly set to a string rather than a tuple. """ self.assertRaises(ValueError, setattr, settings, 'ALLOWED_INCLUDE_ROOTS', '/var/www/ssi/')
[ "def", "test_allowed_include_roots_string", "(", "self", ")", ":", "self", ".", "assertRaises", "(", "ValueError", ",", "setattr", ",", "settings", ",", "'ALLOWED_INCLUDE_ROOTS'", ",", "'/var/www/ssi/'", ")" ]
[ 267, 4 ]
[ 273, 53 ]
python
en
['en', 'error', 'th']
False
TestComplexSettingOverride.test_complex_override_warning
(self)
Regression test for #19031
Regression test for #19031
def test_complex_override_warning(self): """Regression test for #19031""" with warnings.catch_warnings(record=True) as w: warnings.simplefilter("always") with override_settings(TEST_WARN='override'): self.assertEqual(settings.TEST_WARN, 'override') s...
[ "def", "test_complex_override_warning", "(", "self", ")", ":", "with", "warnings", ".", "catch_warnings", "(", "record", "=", "True", ")", "as", "w", ":", "warnings", ".", "simplefilter", "(", "\"always\"", ")", "with", "override_settings", "(", "TEST_WARN", "...
[ 285, 4 ]
[ 298, 80 ]
python
en
['en', 'en', 'en']
True
TrailingSlashURLTests.test_blank
(self)
The empty string is accepted, even though it doesn't end in a slash.
The empty string is accepted, even though it doesn't end in a slash.
def test_blank(self): """ The empty string is accepted, even though it doesn't end in a slash. """ self.settings_module.MEDIA_URL = '' self.assertEqual('', self.settings_module.MEDIA_URL) self.settings_module.STATIC_URL = '' self.assertEqual('', self.settings_mod...
[ "def", "test_blank", "(", "self", ")", ":", "self", ".", "settings_module", ".", "MEDIA_URL", "=", "''", "self", ".", "assertEqual", "(", "''", ",", "self", ".", "settings_module", ".", "MEDIA_URL", ")", "self", ".", "settings_module", ".", "STATIC_URL", "...
[ 318, 4 ]
[ 326, 61 ]
python
en
['en', 'error', 'th']
False
TrailingSlashURLTests.test_end_slash
(self)
It works if the value ends in a slash.
It works if the value ends in a slash.
def test_end_slash(self): """ It works if the value ends in a slash. """ self.settings_module.MEDIA_URL = '/foo/' self.assertEqual('/foo/', self.settings_module.MEDIA_URL) self.settings_module.MEDIA_URL = 'http://media.foo.com/' self.assertEqual('http://media.foo...
[ "def", "test_end_slash", "(", "self", ")", ":", "self", ".", "settings_module", ".", "MEDIA_URL", "=", "'/foo/'", "self", ".", "assertEqual", "(", "'/foo/'", ",", "self", ".", "settings_module", ".", "MEDIA_URL", ")", "self", ".", "settings_module", ".", "ME...
[ 328, 4 ]
[ 344, 57 ]
python
en
['en', 'error', 'th']
False
TrailingSlashURLTests.test_no_end_slash
(self)
An ImproperlyConfigured exception is raised if the value doesn't end in a slash.
An ImproperlyConfigured exception is raised if the value doesn't end in a slash.
def test_no_end_slash(self): """ An ImproperlyConfigured exception is raised if the value doesn't end in a slash. """ with self.assertRaises(ImproperlyConfigured): self.settings_module.MEDIA_URL = '/foo' with self.assertRaises(ImproperlyConfigured): ...
[ "def", "test_no_end_slash", "(", "self", ")", ":", "with", "self", ".", "assertRaises", "(", "ImproperlyConfigured", ")", ":", "self", ".", "settings_module", ".", "MEDIA_URL", "=", "'/foo'", "with", "self", ".", "assertRaises", "(", "ImproperlyConfigured", ")",...
[ 346, 4 ]
[ 361, 69 ]
python
en
['en', 'error', 'th']
False
TrailingSlashURLTests.test_double_slash
(self)
If the value ends in more than one slash, presume they know what they're doing.
If the value ends in more than one slash, presume they know what they're doing.
def test_double_slash(self): """ If the value ends in more than one slash, presume they know what they're doing. """ self.settings_module.MEDIA_URL = '/wrong//' self.assertEqual('/wrong//', self.settings_module.MEDIA_URL) self.settings_module.MEDIA_URL = 'http://...
[ "def", "test_double_slash", "(", "self", ")", ":", "self", ".", "settings_module", ".", "MEDIA_URL", "=", "'/wrong//'", "self", ".", "assertEqual", "(", "'/wrong//'", ",", "self", ".", "settings_module", ".", "MEDIA_URL", ")", "self", ".", "settings_module", "...
[ 363, 4 ]
[ 380, 57 ]
python
en
['en', 'error', 'th']
False
format
(value, format_string)
Convenience function
Convenience function
def format(value, format_string): "Convenience function" df = DateFormat(value) return df.format(format_string)
[ "def", "format", "(", "value", ",", "format_string", ")", ":", "df", "=", "DateFormat", "(", "value", ")", "return", "df", ".", "format", "(", "format_string", ")" ]
[ 357, 0 ]
[ 360, 35 ]
python
en
['en', 'en', 'en']
False
time_format
(value, format_string)
Convenience function
Convenience function
def time_format(value, format_string): "Convenience function" tf = TimeFormat(value) return tf.format(format_string)
[ "def", "time_format", "(", "value", ",", "format_string", ")", ":", "tf", "=", "TimeFormat", "(", "value", ")", "return", "tf", ".", "format", "(", "format_string", ")" ]
[ 363, 0 ]
[ 366, 35 ]
python
en
['en', 'en', 'en']
False
TimeFormat.a
(self)
a.m.' or 'p.m.
a.m.' or 'p.m.
def a(self): "'a.m.' or 'p.m.'" if self.data.hour > 11: return _('p.m.') return _('a.m.')
[ "def", "a", "(", "self", ")", ":", "if", "self", ".", "data", ".", "hour", ">", "11", ":", "return", "_", "(", "'p.m.'", ")", "return", "_", "(", "'a.m.'", ")" ]
[ 58, 4 ]
[ 62, 24 ]
python
en
['en', 'en', 'en']
True
TimeFormat.B
(self)
Swatch Internet time
Swatch Internet time
def B(self): "Swatch Internet time" raise NotImplementedError('may be implemented in a future release')
[ "def", "B", "(", "self", ")", ":", "raise", "NotImplementedError", "(", "'may be implemented in a future release'", ")" ]
[ 70, 4 ]
[ 72, 75 ]
python
en
['en', 'en', 'en']
True
TimeFormat.e
(self)
Timezone name. If timezone information is not available, return an empty string.
Timezone name.
def e(self): """ Timezone name. If timezone information is not available, return an empty string. """ if not self.timezone: return "" try: if hasattr(self.data, 'tzinfo') and self.data.tzinfo: return self.data.tzname() or '' ...
[ "def", "e", "(", "self", ")", ":", "if", "not", "self", ".", "timezone", ":", "return", "\"\"", "try", ":", "if", "hasattr", "(", "self", ".", "data", ",", "'tzinfo'", ")", "and", "self", ".", "data", ".", "tzinfo", ":", "return", "self", ".", "d...
[ 74, 4 ]
[ 88, 17 ]
python
en
['en', 'error', 'th']
False
TimeFormat.f
(self)
Time, in 12-hour hours and minutes, with minutes left off if they're zero. Examples: '1', '1:30', '2:05', '2' Proprietary extension.
Time, in 12-hour hours and minutes, with minutes left off if they're zero. Examples: '1', '1:30', '2:05', '2' Proprietary extension.
def f(self): """ Time, in 12-hour hours and minutes, with minutes left off if they're zero. Examples: '1', '1:30', '2:05', '2' Proprietary extension. """ if self.data.minute == 0: return self.g() return '%s:%s' % (self.g(), self.i())
[ "def", "f", "(", "self", ")", ":", "if", "self", ".", "data", ".", "minute", "==", "0", ":", "return", "self", ".", "g", "(", ")", "return", "'%s:%s'", "%", "(", "self", ".", "g", "(", ")", ",", "self", ".", "i", "(", ")", ")" ]
[ 90, 4 ]
[ 99, 45 ]
python
en
['en', 'error', 'th']
False
TimeFormat.g
(self)
Hour, 12-hour format without leading zeros; i.e. '1' to '12
Hour, 12-hour format without leading zeros; i.e. '1' to '12
def g(self): "Hour, 12-hour format without leading zeros; i.e. '1' to '12'" if self.data.hour == 0: return 12 if self.data.hour > 12: return self.data.hour - 12 return self.data.hour
[ "def", "g", "(", "self", ")", ":", "if", "self", ".", "data", ".", "hour", "==", "0", ":", "return", "12", "if", "self", ".", "data", ".", "hour", ">", "12", ":", "return", "self", ".", "data", ".", "hour", "-", "12", "return", "self", ".", "...
[ 101, 4 ]
[ 107, 29 ]
python
en
['en', 'en', 'en']
True
TimeFormat.G
(self)
Hour, 24-hour format without leading zeros; i.e. '0' to '23
Hour, 24-hour format without leading zeros; i.e. '0' to '23
def G(self): "Hour, 24-hour format without leading zeros; i.e. '0' to '23'" return self.data.hour
[ "def", "G", "(", "self", ")", ":", "return", "self", ".", "data", ".", "hour" ]
[ 109, 4 ]
[ 111, 29 ]
python
en
['en', 'en', 'en']
True
TimeFormat.h
(self)
Hour, 12-hour format; i.e. '01' to '12
Hour, 12-hour format; i.e. '01' to '12
def h(self): "Hour, 12-hour format; i.e. '01' to '12'" return '%02d' % self.g()
[ "def", "h", "(", "self", ")", ":", "return", "'%02d'", "%", "self", ".", "g", "(", ")" ]
[ 113, 4 ]
[ 115, 32 ]
python
en
['en', 'pt', 'it']
False
TimeFormat.H
(self)
Hour, 24-hour format; i.e. '00' to '23
Hour, 24-hour format; i.e. '00' to '23
def H(self): "Hour, 24-hour format; i.e. '00' to '23'" return '%02d' % self.G()
[ "def", "H", "(", "self", ")", ":", "return", "'%02d'", "%", "self", ".", "G", "(", ")" ]
[ 117, 4 ]
[ 119, 32 ]
python
en
['en', 'pt', 'it']
False
TimeFormat.i
(self)
Minutes; i.e. '00' to '59
Minutes; i.e. '00' to '59
def i(self): "Minutes; i.e. '00' to '59'" return '%02d' % self.data.minute
[ "def", "i", "(", "self", ")", ":", "return", "'%02d'", "%", "self", ".", "data", ".", "minute" ]
[ 121, 4 ]
[ 123, 40 ]
python
en
['en', 'mi', 'it']
False
TimeFormat.O
(self)
Difference to Greenwich time in hours; e.g. '+0200', '-0430'. If timezone information is not available, return an empty string.
Difference to Greenwich time in hours; e.g. '+0200', '-0430'.
def O(self): # NOQA: E743, E741 """ Difference to Greenwich time in hours; e.g. '+0200', '-0430'. If timezone information is not available, return an empty string. """ if not self.timezone: return "" seconds = self.Z() if seconds == "": ...
[ "def", "O", "(", "self", ")", ":", "# NOQA: E743, E741", "if", "not", "self", ".", "timezone", ":", "return", "\"\"", "seconds", "=", "self", ".", "Z", "(", ")", "if", "seconds", "==", "\"\"", ":", "return", "\"\"", "sign", "=", "'-'", "if", "seconds...
[ 125, 4 ]
[ 139, 75 ]
python
en
['en', 'error', 'th']
False
TimeFormat.P
(self)
Time, in 12-hour hours, minutes and 'a.m.'/'p.m.', with minutes left off if they're zero and the strings 'midnight' and 'noon' if appropriate. Examples: '1 a.m.', '1:30 p.m.', 'midnight', 'noon', '12:30 p.m.' Proprietary extension.
Time, in 12-hour hours, minutes and 'a.m.'/'p.m.', with minutes left off if they're zero and the strings 'midnight' and 'noon' if appropriate. Examples: '1 a.m.', '1:30 p.m.', 'midnight', 'noon', '12:30 p.m.' Proprietary extension.
def P(self): """ Time, in 12-hour hours, minutes and 'a.m.'/'p.m.', with minutes left off if they're zero and the strings 'midnight' and 'noon' if appropriate. Examples: '1 a.m.', '1:30 p.m.', 'midnight', 'noon', '12:30 p.m.' Proprietary extension. """ if self.dat...
[ "def", "P", "(", "self", ")", ":", "if", "self", ".", "data", ".", "minute", "==", "0", "and", "self", ".", "data", ".", "hour", "==", "0", ":", "return", "_", "(", "'midnight'", ")", "if", "self", ".", "data", ".", "minute", "==", "0", "and", ...
[ 141, 4 ]
[ 152, 45 ]
python
en
['en', 'error', 'th']
False
TimeFormat.s
(self)
Seconds; i.e. '00' to '59
Seconds; i.e. '00' to '59
def s(self): "Seconds; i.e. '00' to '59'" return '%02d' % self.data.second
[ "def", "s", "(", "self", ")", ":", "return", "'%02d'", "%", "self", ".", "data", ".", "second" ]
[ 154, 4 ]
[ 156, 40 ]
python
en
['en', 'pt', 'it']
False
TimeFormat.T
(self)
Time zone of this machine; e.g. 'EST' or 'MDT'. If timezone information is not available, return an empty string.
Time zone of this machine; e.g. 'EST' or 'MDT'.
def T(self): """ Time zone of this machine; e.g. 'EST' or 'MDT'. If timezone information is not available, return an empty string. """ if not self.timezone: return "" name = None try: name = self.timezone.tzname(self.data) except ...
[ "def", "T", "(", "self", ")", ":", "if", "not", "self", ".", "timezone", ":", "return", "\"\"", "name", "=", "None", "try", ":", "name", "=", "self", ".", "timezone", ".", "tzname", "(", "self", ".", "data", ")", "except", "Exception", ":", "# pytz...
[ 158, 4 ]
[ 177, 24 ]
python
en
['en', 'error', 'th']
False
TimeFormat.u
(self)
Microseconds; i.e. '000000' to '999999
Microseconds; i.e. '000000' to '999999
def u(self): "Microseconds; i.e. '000000' to '999999'" return '%06d' % self.data.microsecond
[ "def", "u", "(", "self", ")", ":", "return", "'%06d'", "%", "self", ".", "data", ".", "microsecond" ]
[ 179, 4 ]
[ 181, 45 ]
python
en
['en', 'mk', 'en']
True
TimeFormat.Z
(self)
Time zone offset in seconds (i.e. '-43200' to '43200'). The offset for timezones west of UTC is always negative, and for those east of UTC is always positive. If timezone information is not available, return an empty string.
Time zone offset in seconds (i.e. '-43200' to '43200'). The offset for timezones west of UTC is always negative, and for those east of UTC is always positive.
def Z(self): """ Time zone offset in seconds (i.e. '-43200' to '43200'). The offset for timezones west of UTC is always negative, and for those east of UTC is always positive. If timezone information is not available, return an empty string. """ if not self.timez...
[ "def", "Z", "(", "self", ")", ":", "if", "not", "self", ".", "timezone", ":", "return", "\"\"", "try", ":", "offset", "=", "self", ".", "timezone", ".", "utcoffset", "(", "self", ".", "data", ")", "except", "Exception", ":", "# pytz raises AmbiguousTimeE...
[ 183, 4 ]
[ 206, 51 ]
python
en
['en', 'error', 'th']
False
DateFormat.b
(self)
Month, textual, 3 letters, lowercase; e.g. 'jan
Month, textual, 3 letters, lowercase; e.g. 'jan
def b(self): "Month, textual, 3 letters, lowercase; e.g. 'jan'" return MONTHS_3[self.data.month]
[ "def", "b", "(", "self", ")", ":", "return", "MONTHS_3", "[", "self", ".", "data", ".", "month", "]" ]
[ 212, 4 ]
[ 214, 40 ]
python
en
['en', 'en', 'en']
True
DateFormat.c
(self)
ISO 8601 Format Example : '2008-01-02T10:30:00.000123'
ISO 8601 Format Example : '2008-01-02T10:30:00.000123'
def c(self): """ ISO 8601 Format Example : '2008-01-02T10:30:00.000123' """ return self.data.isoformat()
[ "def", "c", "(", "self", ")", ":", "return", "self", ".", "data", ".", "isoformat", "(", ")" ]
[ 216, 4 ]
[ 221, 36 ]
python
en
['en', 'error', 'th']
False
DateFormat.d
(self)
Day of the month, 2 digits with leading zeros; i.e. '01' to '31
Day of the month, 2 digits with leading zeros; i.e. '01' to '31
def d(self): "Day of the month, 2 digits with leading zeros; i.e. '01' to '31'" return '%02d' % self.data.day
[ "def", "d", "(", "self", ")", ":", "return", "'%02d'", "%", "self", ".", "data", ".", "day" ]
[ 223, 4 ]
[ 225, 37 ]
python
en
['en', 'en', 'en']
True
DateFormat.D
(self)
Day of the week, textual, 3 letters; e.g. 'Fri
Day of the week, textual, 3 letters; e.g. 'Fri
def D(self): "Day of the week, textual, 3 letters; e.g. 'Fri'" return WEEKDAYS_ABBR[self.data.weekday()]
[ "def", "D", "(", "self", ")", ":", "return", "WEEKDAYS_ABBR", "[", "self", ".", "data", ".", "weekday", "(", ")", "]" ]
[ 227, 4 ]
[ 229, 49 ]
python
en
['en', 'en', 'en']
True
DateFormat.E
(self)
Alternative month names as required by some locales. Proprietary extension.
Alternative month names as required by some locales. Proprietary extension.
def E(self): "Alternative month names as required by some locales. Proprietary extension." return MONTHS_ALT[self.data.month]
[ "def", "E", "(", "self", ")", ":", "return", "MONTHS_ALT", "[", "self", ".", "data", ".", "month", "]" ]
[ 231, 4 ]
[ 233, 42 ]
python
en
['en', 'en', 'en']
True
DateFormat.F
(self)
Month, textual, long; e.g. 'January
Month, textual, long; e.g. 'January
def F(self): "Month, textual, long; e.g. 'January'" return MONTHS[self.data.month]
[ "def", "F", "(", "self", ")", ":", "return", "MONTHS", "[", "self", ".", "data", ".", "month", "]" ]
[ 235, 4 ]
[ 237, 38 ]
python
en
['en', 'en', 'pt']
True
DateFormat.I
(self)
1' if Daylight Savings Time, '0' otherwise.
1' if Daylight Savings Time, '0' otherwise.
def I(self): # NOQA: E743, E741 "'1' if Daylight Savings Time, '0' otherwise." try: if self.timezone and self.timezone.dst(self.data): return '1' else: return '0' except Exception: # pytz raises AmbiguousTimeError during the au...
[ "def", "I", "(", "self", ")", ":", "# NOQA: E743, E741", "try", ":", "if", "self", ".", "timezone", "and", "self", ".", "timezone", ".", "dst", "(", "self", ".", "data", ")", ":", "return", "'1'", "else", ":", "return", "'0'", "except", "Exception", ...
[ 239, 4 ]
[ 250, 21 ]
python
en
['en', 'en', 'en']
True
DateFormat.j
(self)
Day of the month without leading zeros; i.e. '1' to '31
Day of the month without leading zeros; i.e. '1' to '31
def j(self): "Day of the month without leading zeros; i.e. '1' to '31'" return self.data.day
[ "def", "j", "(", "self", ")", ":", "return", "self", ".", "data", ".", "day" ]
[ 252, 4 ]
[ 254, 28 ]
python
en
['en', 'en', 'en']
True
DateFormat.l
(self)
Day of the week, textual, long; e.g. 'Friday
Day of the week, textual, long; e.g. 'Friday
def l(self): # NOQA: E743, E741 "Day of the week, textual, long; e.g. 'Friday'" return WEEKDAYS[self.data.weekday()]
[ "def", "l", "(", "self", ")", ":", "# NOQA: E743, E741", "return", "WEEKDAYS", "[", "self", ".", "data", ".", "weekday", "(", ")", "]" ]
[ 256, 4 ]
[ 258, 44 ]
python
en
['en', 'en', 'en']
True
DateFormat.L
(self)
Boolean for whether it is a leap year; i.e. True or False
Boolean for whether it is a leap year; i.e. True or False
def L(self): "Boolean for whether it is a leap year; i.e. True or False" return calendar.isleap(self.data.year)
[ "def", "L", "(", "self", ")", ":", "return", "calendar", ".", "isleap", "(", "self", ".", "data", ".", "year", ")" ]
[ 260, 4 ]
[ 262, 46 ]
python
en
['en', 'en', 'en']
True
DateFormat.m
(self)
Month; i.e. '01' to '12
Month; i.e. '01' to '12
def m(self): "Month; i.e. '01' to '12'" return '%02d' % self.data.month
[ "def", "m", "(", "self", ")", ":", "return", "'%02d'", "%", "self", ".", "data", ".", "month" ]
[ 264, 4 ]
[ 266, 39 ]
python
en
['en', 'pt', 'it']
False
DateFormat.M
(self)
Month, textual, 3 letters; e.g. 'Jan
Month, textual, 3 letters; e.g. 'Jan
def M(self): "Month, textual, 3 letters; e.g. 'Jan'" return MONTHS_3[self.data.month].title()
[ "def", "M", "(", "self", ")", ":", "return", "MONTHS_3", "[", "self", ".", "data", ".", "month", "]", ".", "title", "(", ")" ]
[ 268, 4 ]
[ 270, 48 ]
python
en
['en', 'fr', 'pt']
False
DateFormat.n
(self)
Month without leading zeros; i.e. '1' to '12
Month without leading zeros; i.e. '1' to '12
def n(self): "Month without leading zeros; i.e. '1' to '12'" return self.data.month
[ "def", "n", "(", "self", ")", ":", "return", "self", ".", "data", ".", "month" ]
[ 272, 4 ]
[ 274, 30 ]
python
en
['en', 'en', 'en']
True
DateFormat.N
(self)
Month abbreviation in Associated Press style. Proprietary extension.
Month abbreviation in Associated Press style. Proprietary extension.
def N(self): "Month abbreviation in Associated Press style. Proprietary extension." return MONTHS_AP[self.data.month]
[ "def", "N", "(", "self", ")", ":", "return", "MONTHS_AP", "[", "self", ".", "data", ".", "month", "]" ]
[ 276, 4 ]
[ 278, 41 ]
python
en
['en', 'en', 'en']
True
DateFormat.o
(self)
ISO 8601 year number matching the ISO week number (W)
ISO 8601 year number matching the ISO week number (W)
def o(self): "ISO 8601 year number matching the ISO week number (W)" return self.data.isocalendar()[0]
[ "def", "o", "(", "self", ")", ":", "return", "self", ".", "data", ".", "isocalendar", "(", ")", "[", "0", "]" ]
[ 280, 4 ]
[ 282, 41 ]
python
en
['en', 'en', 'en']
True
DateFormat.r
(self)
RFC 5322 formatted date; e.g. 'Thu, 21 Dec 2000 16:01:07 +0200
RFC 5322 formatted date; e.g. 'Thu, 21 Dec 2000 16:01:07 +0200
def r(self): "RFC 5322 formatted date; e.g. 'Thu, 21 Dec 2000 16:01:07 +0200'" return self.format('D, j M Y H:i:s O')
[ "def", "r", "(", "self", ")", ":", "return", "self", ".", "format", "(", "'D, j M Y H:i:s O'", ")" ]
[ 284, 4 ]
[ 286, 46 ]
python
co
['fr', 'co', 'it']
False
DateFormat.S
(self)
English ordinal suffix for the day of the month, 2 characters; i.e. 'st', 'nd', 'rd' or 'th
English ordinal suffix for the day of the month, 2 characters; i.e. 'st', 'nd', 'rd' or 'th
def S(self): "English ordinal suffix for the day of the month, 2 characters; i.e. 'st', 'nd', 'rd' or 'th'" if self.data.day in (11, 12, 13): # Special case return 'th' last = self.data.day % 10 if last == 1: return 'st' if last == 2: return '...
[ "def", "S", "(", "self", ")", ":", "if", "self", ".", "data", ".", "day", "in", "(", "11", ",", "12", ",", "13", ")", ":", "# Special case", "return", "'th'", "last", "=", "self", ".", "data", ".", "day", "%", "10", "if", "last", "==", "1", "...
[ 288, 4 ]
[ 299, 19 ]
python
en
['en', 'en', 'en']
True
DateFormat.t
(self)
Number of days in the given month; i.e. '28' to '31
Number of days in the given month; i.e. '28' to '31
def t(self): "Number of days in the given month; i.e. '28' to '31'" return '%02d' % calendar.monthrange(self.data.year, self.data.month)[1]
[ "def", "t", "(", "self", ")", ":", "return", "'%02d'", "%", "calendar", ".", "monthrange", "(", "self", ".", "data", ".", "year", ",", "self", ".", "data", ".", "month", ")", "[", "1", "]" ]
[ 301, 4 ]
[ 303, 79 ]
python
en
['en', 'en', 'en']
True
DateFormat.U
(self)
Seconds since the Unix epoch (January 1 1970 00:00:00 GMT)
Seconds since the Unix epoch (January 1 1970 00:00:00 GMT)
def U(self): "Seconds since the Unix epoch (January 1 1970 00:00:00 GMT)" if isinstance(self.data, datetime.datetime) and is_aware(self.data): return int(calendar.timegm(self.data.utctimetuple())) else: return int(time.mktime(self.data.timetuple()))
[ "def", "U", "(", "self", ")", ":", "if", "isinstance", "(", "self", ".", "data", ",", "datetime", ".", "datetime", ")", "and", "is_aware", "(", "self", ".", "data", ")", ":", "return", "int", "(", "calendar", ".", "timegm", "(", "self", ".", "data"...
[ 305, 4 ]
[ 310, 58 ]
python
en
['en', 'cs', 'en']
True
DateFormat.w
(self)
Day of the week, numeric, i.e. '0' (Sunday) to '6' (Saturday)
Day of the week, numeric, i.e. '0' (Sunday) to '6' (Saturday)
def w(self): "Day of the week, numeric, i.e. '0' (Sunday) to '6' (Saturday)" return (self.data.weekday() + 1) % 7
[ "def", "w", "(", "self", ")", ":", "return", "(", "self", ".", "data", ".", "weekday", "(", ")", "+", "1", ")", "%", "7" ]
[ 312, 4 ]
[ 314, 44 ]
python
en
['en', 'en', 'en']
True
DateFormat.W
(self)
ISO-8601 week number of year, weeks starting on Monday
ISO-8601 week number of year, weeks starting on Monday
def W(self): "ISO-8601 week number of year, weeks starting on Monday" # Algorithm from http://www.personal.ecu.edu/mccartyr/ISOwdALG.txt jan1_weekday = self.data.replace(month=1, day=1).weekday() + 1 weekday = self.data.weekday() + 1 day_of_year = self.z() if day_of_year ...
[ "def", "W", "(", "self", ")", ":", "# Algorithm from http://www.personal.ecu.edu/mccartyr/ISOwdALG.txt", "jan1_weekday", "=", "self", ".", "data", ".", "replace", "(", "month", "=", "1", ",", "day", "=", "1", ")", ".", "weekday", "(", ")", "+", "1", "weekday...
[ 316, 4 ]
[ 339, 26 ]
python
en
['en', 'en', 'en']
True
DateFormat.y
(self)
Year, 2 digits; e.g. '99
Year, 2 digits; e.g. '99
def y(self): "Year, 2 digits; e.g. '99'" return str(self.data.year)[2:]
[ "def", "y", "(", "self", ")", ":", "return", "str", "(", "self", ".", "data", ".", "year", ")", "[", "2", ":", "]" ]
[ 341, 4 ]
[ 343, 38 ]
python
da
['da', 'ny', 'en']
False