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
SpatialRefSysMixin.ellipsoid
(self)
Return a tuple of the ellipsoid parameters: (semimajor axis, semiminor axis, and inverse flattening).
Return a tuple of the ellipsoid parameters: (semimajor axis, semiminor axis, and inverse flattening).
def ellipsoid(self): """ Return a tuple of the ellipsoid parameters: (semimajor axis, semiminor axis, and inverse flattening). """ return self.srs.ellipsoid
[ "def", "ellipsoid", "(", "self", ")", ":", "return", "self", ".", "srs", ".", "ellipsoid" ]
[ 36, 4 ]
[ 41, 33 ]
python
en
['en', 'error', 'th']
False
SpatialRefSysMixin.name
(self)
Return the projection name.
Return the projection name.
def name(self): "Return the projection name." return self.srs.name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "srs", ".", "name" ]
[ 44, 4 ]
[ 46, 28 ]
python
en
['en', 'en', 'en']
True
SpatialRefSysMixin.spheroid
(self)
Return the spheroid name for this spatial reference.
Return the spheroid name for this spatial reference.
def spheroid(self): "Return the spheroid name for this spatial reference." return self.srs['spheroid']
[ "def", "spheroid", "(", "self", ")", ":", "return", "self", ".", "srs", "[", "'spheroid'", "]" ]
[ 49, 4 ]
[ 51, 35 ]
python
en
['en', 'en', 'en']
True
SpatialRefSysMixin.datum
(self)
Return the datum for this spatial reference.
Return the datum for this spatial reference.
def datum(self): "Return the datum for this spatial reference." return self.srs['datum']
[ "def", "datum", "(", "self", ")", ":", "return", "self", ".", "srs", "[", "'datum'", "]" ]
[ 54, 4 ]
[ 56, 32 ]
python
en
['en', 'en', 'en']
True
SpatialRefSysMixin.projected
(self)
Is this Spatial Reference projected?
Is this Spatial Reference projected?
def projected(self): "Is this Spatial Reference projected?" return self.srs.projected
[ "def", "projected", "(", "self", ")", ":", "return", "self", ".", "srs", ".", "projected" ]
[ 59, 4 ]
[ 61, 33 ]
python
en
['en', 'en', 'en']
True
SpatialRefSysMixin.local
(self)
Is this Spatial Reference local?
Is this Spatial Reference local?
def local(self): "Is this Spatial Reference local?" return self.srs.local
[ "def", "local", "(", "self", ")", ":", "return", "self", ".", "srs", ".", "local" ]
[ 64, 4 ]
[ 66, 29 ]
python
en
['en', 'en', 'en']
True
SpatialRefSysMixin.geographic
(self)
Is this Spatial Reference geographic?
Is this Spatial Reference geographic?
def geographic(self): "Is this Spatial Reference geographic?" return self.srs.geographic
[ "def", "geographic", "(", "self", ")", ":", "return", "self", ".", "srs", ".", "geographic" ]
[ 69, 4 ]
[ 71, 34 ]
python
en
['en', 'en', 'en']
True
SpatialRefSysMixin.linear_name
(self)
Return the linear units name.
Return the linear units name.
def linear_name(self): "Return the linear units name." return self.srs.linear_name
[ "def", "linear_name", "(", "self", ")", ":", "return", "self", ".", "srs", ".", "linear_name" ]
[ 74, 4 ]
[ 76, 35 ]
python
en
['en', 'en', 'en']
True
SpatialRefSysMixin.linear_units
(self)
Return the linear units.
Return the linear units.
def linear_units(self): "Return the linear units." return self.srs.linear_units
[ "def", "linear_units", "(", "self", ")", ":", "return", "self", ".", "srs", ".", "linear_units" ]
[ 79, 4 ]
[ 81, 36 ]
python
en
['en', 'en', 'en']
True
SpatialRefSysMixin.angular_name
(self)
Return the name of the angular units.
Return the name of the angular units.
def angular_name(self): "Return the name of the angular units." return self.srs.angular_name
[ "def", "angular_name", "(", "self", ")", ":", "return", "self", ".", "srs", ".", "angular_name" ]
[ 84, 4 ]
[ 86, 36 ]
python
en
['en', 'mi', 'en']
True
SpatialRefSysMixin.angular_units
(self)
Return the angular units.
Return the angular units.
def angular_units(self): "Return the angular units." return self.srs.angular_units
[ "def", "angular_units", "(", "self", ")", ":", "return", "self", ".", "srs", ".", "angular_units" ]
[ 89, 4 ]
[ 91, 37 ]
python
en
['en', 'bg', 'en']
True
SpatialRefSysMixin.units
(self)
Return a tuple of the units and the name.
Return a tuple of the units and the name.
def units(self): "Return a tuple of the units and the name." if self.projected or self.local: return (self.linear_units, self.linear_name) elif self.geographic: return (self.angular_units, self.angular_name) else: return (None, None)
[ "def", "units", "(", "self", ")", ":", "if", "self", ".", "projected", "or", "self", ".", "local", ":", "return", "(", "self", ".", "linear_units", ",", "self", ".", "linear_name", ")", "elif", "self", ".", "geographic", ":", "return", "(", "self", "...
[ 94, 4 ]
[ 101, 31 ]
python
en
['en', 'en', 'en']
True
SpatialRefSysMixin.get_units
(cls, wkt)
Return a tuple of (unit_value, unit_name) for the given WKT without using any of the database fields.
Return a tuple of (unit_value, unit_name) for the given WKT without using any of the database fields.
def get_units(cls, wkt): """ Return a tuple of (unit_value, unit_name) for the given WKT without using any of the database fields. """ return gdal.SpatialReference(wkt).units
[ "def", "get_units", "(", "cls", ",", "wkt", ")", ":", "return", "gdal", ".", "SpatialReference", "(", "wkt", ")", ".", "units" ]
[ 104, 4 ]
[ 109, 47 ]
python
en
['en', 'error', 'th']
False
SpatialRefSysMixin.get_spheroid
(cls, wkt, string=True)
Class method used by GeometryField on initialization to retrieve the `SPHEROID[..]` parameters from the given WKT.
Class method used by GeometryField on initialization to retrieve the `SPHEROID[..]` parameters from the given WKT.
def get_spheroid(cls, wkt, string=True): """ Class method used by GeometryField on initialization to retrieve the `SPHEROID[..]` parameters from the given WKT. """ srs = gdal.SpatialReference(wkt) sphere_params = srs.ellipsoid sphere_name = srs['spheroid'] ...
[ "def", "get_spheroid", "(", "cls", ",", "wkt", ",", "string", "=", "True", ")", ":", "srs", "=", "gdal", ".", "SpatialReference", "(", "wkt", ")", "sphere_params", "=", "srs", ".", "ellipsoid", "sphere_name", "=", "srs", "[", "'spheroid'", "]", "if", "...
[ 112, 4 ]
[ 129, 77 ]
python
en
['en', 'error', 'th']
False
SpatialRefSysMixin.__str__
(self)
Return the string representation, a 'pretty' OGC WKT.
Return the string representation, a 'pretty' OGC WKT.
def __str__(self): """ Return the string representation, a 'pretty' OGC WKT. """ return str(self.srs)
[ "def", "__str__", "(", "self", ")", ":", "return", "str", "(", "self", ".", "srs", ")" ]
[ 131, 4 ]
[ 135, 28 ]
python
en
['en', 'error', 'th']
False
FlatpagesSitemapTests.test_flatpage_sitemap
(self)
Basic FlatPage sitemap test
Basic FlatPage sitemap test
def test_flatpage_sitemap(self): "Basic FlatPage sitemap test" # Import FlatPage inside the test so that when django.contrib.flatpages # is not installed we don't get problems trying to delete Site # objects (FlatPage has an M2M to Site, Site.delete() tries to # delete related o...
[ "def", "test_flatpage_sitemap", "(", "self", ")", ":", "# Import FlatPage inside the test so that when django.contrib.flatpages", "# is not installed we don't get problems trying to delete Site", "# objects (FlatPage has an M2M to Site, Site.delete() tries to", "# delete related objects, but the M...
[ 14, 4 ]
[ 41, 90 ]
python
en
['en', 'da', 'en']
True
PaginationTests.check_paginator
(self, params, output)
Helper method that instantiates a Paginator object from the passed params and then checks that its attributes match the passed output.
Helper method that instantiates a Paginator object from the passed params and then checks that its attributes match the passed output.
def check_paginator(self, params, output): """ Helper method that instantiates a Paginator object from the passed params and then checks that its attributes match the passed output. """ count, num_pages, page_range = output paginator = Paginator(*params) self.chec...
[ "def", "check_paginator", "(", "self", ",", "params", ",", "output", ")", ":", "count", ",", "num_pages", ",", "page_range", "=", "output", "paginator", "=", "Paginator", "(", "*", "params", ")", "self", ".", "check_attribute", "(", "'count'", ",", "pagina...
[ 19, 4 ]
[ 28, 86 ]
python
en
['en', 'error', 'th']
False
PaginationTests.check_attribute
(self, name, paginator, expected, params, coerce=None)
Helper method that checks a single attribute and gives a nice error message upon test failure.
Helper method that checks a single attribute and gives a nice error message upon test failure.
def check_attribute(self, name, paginator, expected, params, coerce=None): """ Helper method that checks a single attribute and gives a nice error message upon test failure. """ got = getattr(paginator, name) if coerce is not None: got = coerce(got) se...
[ "def", "check_attribute", "(", "self", ",", "name", ",", "paginator", ",", "expected", ",", "params", ",", "coerce", "=", "None", ")", ":", "got", "=", "getattr", "(", "paginator", ",", "name", ")", "if", "coerce", "is", "not", "None", ":", "got", "=...
[ 30, 4 ]
[ 40, 44 ]
python
en
['en', 'error', 'th']
False
PaginationTests.test_paginator
(self)
Tests the paginator attributes using varying inputs.
Tests the paginator attributes using varying inputs.
def test_paginator(self): """ Tests the paginator attributes using varying inputs. """ nine = [1, 2, 3, 4, 5, 6, 7, 8, 9] ten = nine + [10] eleven = ten + [11] tests = ( # Each item is two tuples: # First tuple is Paginator parameters -...
[ "def", "test_paginator", "(", "self", ")", ":", "nine", "=", "[", "1", ",", "2", ",", "3", ",", "4", ",", "5", ",", "6", ",", "7", ",", "8", ",", "9", "]", "ten", "=", "nine", "+", "[", "10", "]", "eleven", "=", "ten", "+", "[", "11", "...
[ 42, 4 ]
[ 107, 48 ]
python
en
['en', 'error', 'th']
False
PaginationTests.test_invalid_page_number
(self)
Tests that invalid page numbers result in the correct exception being raised.
Tests that invalid page numbers result in the correct exception being raised.
def test_invalid_page_number(self): """ Tests that invalid page numbers result in the correct exception being raised. """ paginator = Paginator([1, 2, 3], 2) self.assertRaises(InvalidPage, paginator.page, 3) self.assertRaises(PageNotAnInteger, paginator.validate_n...
[ "def", "test_invalid_page_number", "(", "self", ")", ":", "paginator", "=", "Paginator", "(", "[", "1", ",", "2", ",", "3", "]", ",", "2", ")", "self", ".", "assertRaises", "(", "InvalidPage", ",", "paginator", ".", "page", ",", "3", ")", "self", "."...
[ 109, 4 ]
[ 120, 57 ]
python
en
['en', 'error', 'th']
False
PaginationTests.check_indexes
(self, params, page_num, indexes)
Helper method that instantiates a Paginator object from the passed params and then checks that the start and end indexes of the passed page_num match those given as a 2-tuple in indexes.
Helper method that instantiates a Paginator object from the passed params and then checks that the start and end indexes of the passed page_num match those given as a 2-tuple in indexes.
def check_indexes(self, params, page_num, indexes): """ Helper method that instantiates a Paginator object from the passed params and then checks that the start and end indexes of the passed page_num match those given as a 2-tuple in indexes. """ paginator = Paginator(*pa...
[ "def", "check_indexes", "(", "self", ",", "params", ",", "page_num", ",", "indexes", ")", ":", "paginator", "=", "Paginator", "(", "*", "params", ")", "if", "page_num", "==", "'first'", ":", "page_num", "=", "1", "elif", "page_num", "==", "'last'", ":", ...
[ 141, 4 ]
[ 159, 73 ]
python
en
['en', 'error', 'th']
False
PaginationTests.test_page_indexes
(self)
Tests that paginator pages have the correct start and end indexes.
Tests that paginator pages have the correct start and end indexes.
def test_page_indexes(self): """ Tests that paginator pages have the correct start and end indexes. """ ten = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] tests = ( # Each item is three tuples: # First tuple is Paginator parameters - object_list, per_page, ...
[ "def", "test_page_indexes", "(", "self", ")", ":", "ten", "=", "[", "1", ",", "2", ",", "3", ",", "4", ",", "5", ",", "6", ",", "7", ",", "8", ",", "9", ",", "10", "]", "tests", "=", "(", "# Each item is three tuples:", "# First tuple is Paginato...
[ 161, 4 ]
[ 206, 84 ]
python
en
['en', 'error', 'th']
False
PaginationTests.test_page_sequence
(self)
Tests that a paginator page acts like a standard sequence.
Tests that a paginator page acts like a standard sequence.
def test_page_sequence(self): """ Tests that a paginator page acts like a standard sequence. """ eleven = 'abcdefghijk' page2 = Paginator(eleven, per_page=5, orphans=1).page(2) self.assertEqual(len(page2), 6) self.assertTrue('k' in page2) self.assertFalse(...
[ "def", "test_page_sequence", "(", "self", ")", ":", "eleven", "=", "'abcdefghijk'", "page2", "=", "Paginator", "(", "eleven", ",", "per_page", "=", "5", ",", "orphans", "=", "1", ")", ".", "page", "(", "2", ")", "self", ".", "assertEqual", "(", "len", ...
[ 208, 4 ]
[ 218, 60 ]
python
en
['en', 'error', 'th']
False
PaginationTests.test_get_page_hook
(self)
Tests that a Paginator subclass can use the ``_get_page`` hook to return an alternative to the standard Page class.
Tests that a Paginator subclass can use the ``_get_page`` hook to return an alternative to the standard Page class.
def test_get_page_hook(self): """ Tests that a Paginator subclass can use the ``_get_page`` hook to return an alternative to the standard Page class. """ eleven = 'abcdefghijk' paginator = ValidAdjacentNumsPaginator(eleven, per_page=6) page1 = paginator.page(1) ...
[ "def", "test_get_page_hook", "(", "self", ")", ":", "eleven", "=", "'abcdefghijk'", "paginator", "=", "ValidAdjacentNumsPaginator", "(", "eleven", ",", "per_page", "=", "6", ")", "page1", "=", "paginator", ".", "page", "(", "1", ")", "page2", "=", "paginator...
[ 220, 4 ]
[ 232, 51 ]
python
en
['en', 'error', 'th']
False
ModelPaginationTests.test_page_getitem
(self)
Tests proper behavior of a paginator page __getitem__ (queryset evaluation, slicing, exception raised).
Tests proper behavior of a paginator page __getitem__ (queryset evaluation, slicing, exception raised).
def test_page_getitem(self): """ Tests proper behavior of a paginator page __getitem__ (queryset evaluation, slicing, exception raised). """ paginator = Paginator(Article.objects.all(), 5) p = paginator.page(1) # Make sure object_list queryset is not evaluated by...
[ "def", "test_page_getitem", "(", "self", ")", ":", "paginator", "=", "Paginator", "(", "Article", ".", "objects", ".", "all", "(", ")", ",", "5", ")", "p", "=", "paginator", ".", "page", "(", "1", ")", "# Make sure object_list queryset is not evaluated by an i...
[ 286, 4 ]
[ 309, 50 ]
python
en
['en', 'error', 'th']
False
register_handler
(handler)
Install application-specific FITS image handler. :param handler: Handler object.
Install application-specific FITS image handler.
def register_handler(handler): """ Install application-specific FITS image handler. :param handler: Handler object. """ global _handler _handler = handler
[ "def", "register_handler", "(", "handler", ")", ":", "global", "_handler", "_handler", "=", "handler" ]
[ 16, 0 ]
[ 23, 22 ]
python
en
['en', 'error', 'th']
False
CustomTagTests.test_15070_current_app
(self)
Test that inclusion tag passes down `current_app` of context to the Context of the included/rendered template as well.
Test that inclusion tag passes down `current_app` of context to the Context of the included/rendered template as well.
def test_15070_current_app(self): """ Test that inclusion tag passes down `current_app` of context to the Context of the included/rendered template as well. """ c = template.Context({}) t = template.Template('{% load custom %}{% inclusion_tag_current_app %}') self...
[ "def", "test_15070_current_app", "(", "self", ")", ":", "c", "=", "template", ".", "Context", "(", "{", "}", ")", "t", "=", "template", ".", "Template", "(", "'{% load custom %}{% inclusion_tag_current_app %}'", ")", "self", ".", "assertEqual", "(", "t", ".", ...
[ 246, 4 ]
[ 256, 57 ]
python
en
['en', 'error', 'th']
False
CustomTagTests.test_15070_use_l10n
(self)
Test that inclusion tag passes down `use_l10n` of context to the Context of the included/rendered template as well.
Test that inclusion tag passes down `use_l10n` of context to the Context of the included/rendered template as well.
def test_15070_use_l10n(self): """ Test that inclusion tag passes down `use_l10n` of context to the Context of the included/rendered template as well. """ c = template.Context({}) t = template.Template('{% load custom %}{% inclusion_tag_use_l10n %}') self.assertEq...
[ "def", "test_15070_use_l10n", "(", "self", ")", ":", "c", "=", "template", ".", "Context", "(", "{", "}", ")", "t", "=", "template", ".", "Template", "(", "'{% load custom %}{% inclusion_tag_use_l10n %}'", ")", "self", ".", "assertEqual", "(", "t", ".", "ren...
[ 258, 4 ]
[ 268, 53 ]
python
en
['en', 'error', 'th']
False
BaseAdapter.send
(self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None)
Sends PreparedRequest object. Returns Response object. :param request: The :class:`PreparedRequest <PreparedRequest>` being sent. :param stream: (optional) Whether to stream the request content. :param timeout: (optional) How long to wait for the server to send data before giving up...
Sends PreparedRequest object. Returns Response object.
def send(self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None): """Sends PreparedRequest object. Returns Response object. :param request: The :class:`PreparedRequest <PreparedRequest>` being sent. :param stream: (optional) Whether to stream the request co...
[ "def", "send", "(", "self", ",", "request", ",", "stream", "=", "False", ",", "timeout", "=", "None", ",", "verify", "=", "True", ",", "cert", "=", "None", ",", "proxies", "=", "None", ")", ":", "raise", "NotImplementedError" ]
[ 60, 4 ]
[ 76, 33 ]
python
en
['en', 'lb', 'en']
True
BaseAdapter.close
(self)
Cleans up adapter specific items.
Cleans up adapter specific items.
def close(self): """Cleans up adapter specific items.""" raise NotImplementedError
[ "def", "close", "(", "self", ")", ":", "raise", "NotImplementedError" ]
[ 78, 4 ]
[ 80, 33 ]
python
en
['en', 'en', 'en']
True
HTTPAdapter.init_poolmanager
(self, connections, maxsize, block=DEFAULT_POOLBLOCK, **pool_kwargs)
Initializes a urllib3 PoolManager. This method should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`. :param connections: The number of urllib3 connection pools to cache. :param maxsize: The ma...
Initializes a urllib3 PoolManager.
def init_poolmanager(self, connections, maxsize, block=DEFAULT_POOLBLOCK, **pool_kwargs): """Initializes a urllib3 PoolManager. This method should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`. ...
[ "def", "init_poolmanager", "(", "self", ",", "connections", ",", "maxsize", ",", "block", "=", "DEFAULT_POOLBLOCK", ",", "*", "*", "pool_kwargs", ")", ":", "# save these values for pickling", "self", ".", "_pool_connections", "=", "connections", "self", ".", "_poo...
[ 145, 4 ]
[ 163, 79 ]
python
en
['en', 'en', 'it']
True
HTTPAdapter.proxy_manager_for
(self, proxy, **proxy_kwargs)
Return urllib3 ProxyManager for the given proxy. This method should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`. :param proxy: The proxy to return a urllib3 ProxyManager for. :param proxy_kw...
Return urllib3 ProxyManager for the given proxy.
def proxy_manager_for(self, proxy, **proxy_kwargs): """Return urllib3 ProxyManager for the given proxy. This method should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`. :param proxy: The prox...
[ "def", "proxy_manager_for", "(", "self", ",", "proxy", ",", "*", "*", "proxy_kwargs", ")", ":", "if", "proxy", "in", "self", ".", "proxy_manager", ":", "manager", "=", "self", ".", "proxy_manager", "[", "proxy", "]", "elif", "proxy", ".", "lower", "(", ...
[ 165, 4 ]
[ 200, 22 ]
python
en
['en', 'en', 'en']
True
HTTPAdapter.cert_verify
(self, conn, url, verify, cert)
Verify a SSL certificate. This method should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`. :param conn: The urllib3 connection object associated with the cert. :param url: The requested URL. :...
Verify a SSL certificate. This method should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
def cert_verify(self, conn, url, verify, cert): """Verify a SSL certificate. This method should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`. :param conn: The urllib3 connection object associated with...
[ "def", "cert_verify", "(", "self", ",", "conn", ",", "url", ",", "verify", ",", "cert", ")", ":", "if", "url", ".", "lower", "(", ")", ".", "startswith", "(", "'https'", ")", "and", "verify", ":", "cert_loc", "=", "None", "# Allow self-specified cert loc...
[ 202, 4 ]
[ 252, 71 ]
python
en
['en', 'en', 'en']
True
HTTPAdapter.build_response
(self, req, resp)
Builds a :class:`Response <requests.Response>` object from a urllib3 response. This should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>` :param req: The :class:`PreparedRequest <PreparedRequest>` used ...
Builds a :class:`Response <requests.Response>` object from a urllib3 response. This should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`
def build_response(self, req, resp): """Builds a :class:`Response <requests.Response>` object from a urllib3 response. This should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>` :param req: The ...
[ "def", "build_response", "(", "self", ",", "req", ",", "resp", ")", ":", "response", "=", "Response", "(", ")", "# Fallback to None if there's no status_code, for whatever reason.", "response", ".", "status_code", "=", "getattr", "(", "resp", ",", "'status'", ",", ...
[ 254, 4 ]
[ 289, 23 ]
python
en
['en', 'en', 'en']
True
HTTPAdapter.get_connection
(self, url, proxies=None)
Returns a urllib3 connection for the given URL. This should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`. :param url: The URL to connect to. :param proxies: (optional) A Requests-style dictionary of p...
Returns a urllib3 connection for the given URL. This should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
def get_connection(self, url, proxies=None): """Returns a urllib3 connection for the given URL. This should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`. :param url: The URL to connect to. :pa...
[ "def", "get_connection", "(", "self", ",", "url", ",", "proxies", "=", "None", ")", ":", "proxy", "=", "select_proxy", "(", "url", ",", "proxies", ")", "if", "proxy", ":", "proxy", "=", "prepend_scheme_if_needed", "(", "proxy", ",", "'http'", ")", "proxy...
[ 291, 4 ]
[ 316, 19 ]
python
en
['en', 'en', 'en']
True
HTTPAdapter.close
(self)
Disposes of any internal state. Currently, this closes the PoolManager and any active ProxyManager, which closes any pooled connections.
Disposes of any internal state.
def close(self): """Disposes of any internal state. Currently, this closes the PoolManager and any active ProxyManager, which closes any pooled connections. """ self.poolmanager.clear() for proxy in self.proxy_manager.values(): proxy.clear()
[ "def", "close", "(", "self", ")", ":", "self", ".", "poolmanager", ".", "clear", "(", ")", "for", "proxy", "in", "self", ".", "proxy_manager", ".", "values", "(", ")", ":", "proxy", ".", "clear", "(", ")" ]
[ 318, 4 ]
[ 326, 25 ]
python
en
['en', 'en', 'en']
True
HTTPAdapter.request_url
(self, request, proxies)
Obtain the url to use when making the final request. If the message is being sent through a HTTP proxy, the full URL has to be used. Otherwise, we should only use the path portion of the URL. This should not be called from user code, and is only exposed for use when subclassing the ...
Obtain the url to use when making the final request.
def request_url(self, request, proxies): """Obtain the url to use when making the final request. If the message is being sent through a HTTP proxy, the full URL has to be used. Otherwise, we should only use the path portion of the URL. This should not be called from user code, and is o...
[ "def", "request_url", "(", "self", ",", "request", ",", "proxies", ")", ":", "proxy", "=", "select_proxy", "(", "request", ".", "url", ",", "proxies", ")", "scheme", "=", "urlparse", "(", "request", ".", "url", ")", ".", "scheme", "is_proxied_http_request"...
[ 328, 4 ]
[ 355, 18 ]
python
en
['en', 'en', 'en']
True
HTTPAdapter.add_headers
(self, request, **kwargs)
Add any headers needed by the connection. As of v2.0 this does nothing by default, but is left for overriding by users that subclass the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`. This should not be called from user code, and is only exposed for use when subclassing the ...
Add any headers needed by the connection. As of v2.0 this does nothing by default, but is left for overriding by users that subclass the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
def add_headers(self, request, **kwargs): """Add any headers needed by the connection. As of v2.0 this does nothing by default, but is left for overriding by users that subclass the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`. This should not be called from user code, and is on...
[ "def", "add_headers", "(", "self", ",", "request", ",", "*", "*", "kwargs", ")", ":", "pass" ]
[ 357, 4 ]
[ 369, 12 ]
python
en
['en', 'en', 'en']
True
HTTPAdapter.proxy_headers
(self, proxy)
Returns a dictionary of the headers to add to any request sent through a proxy. This works with urllib3 magic to ensure that they are correctly sent to the proxy, rather than in a tunnelled request if CONNECT is being used. This should not be called from user code, and is only exposed f...
Returns a dictionary of the headers to add to any request sent through a proxy. This works with urllib3 magic to ensure that they are correctly sent to the proxy, rather than in a tunnelled request if CONNECT is being used.
def proxy_headers(self, proxy): """Returns a dictionary of the headers to add to any request sent through a proxy. This works with urllib3 magic to ensure that they are correctly sent to the proxy, rather than in a tunnelled request if CONNECT is being used. This should not be c...
[ "def", "proxy_headers", "(", "self", ",", "proxy", ")", ":", "headers", "=", "{", "}", "username", ",", "password", "=", "get_auth_from_url", "(", "proxy", ")", "if", "username", ":", "headers", "[", "'Proxy-Authorization'", "]", "=", "_basic_auth_str", "(",...
[ 371, 4 ]
[ 391, 22 ]
python
en
['en', 'en', 'en']
True
HTTPAdapter.send
(self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None)
Sends PreparedRequest object. Returns Response object. :param request: The :class:`PreparedRequest <PreparedRequest>` being sent. :param stream: (optional) Whether to stream the request content. :param timeout: (optional) How long to wait for the server to send data before giving up...
Sends PreparedRequest object. Returns Response object.
def send(self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None): """Sends PreparedRequest object. Returns Response object. :param request: The :class:`PreparedRequest <PreparedRequest>` being sent. :param stream: (optional) Whether to stream the request content. ...
[ "def", "send", "(", "self", ",", "request", ",", "stream", "=", "False", ",", "timeout", "=", "None", ",", "verify", "=", "True", ",", "cert", "=", "None", ",", "proxies", "=", "None", ")", ":", "try", ":", "conn", "=", "self", ".", "get_connection...
[ 393, 4 ]
[ 532, 49 ]
python
en
['en', 'lb', 'en']
True
page_not_found
(request, template_name='404.html')
Default 404 handler. Templates: :template:`404.html` Context: request_path The path of the requested URL (e.g., '/app/pages/bad_page/')
Default 404 handler.
def page_not_found(request, template_name='404.html'): """ Default 404 handler. Templates: :template:`404.html` Context: request_path The path of the requested URL (e.g., '/app/pages/bad_page/') """ try: template = loader.get_template(template_name) content_t...
[ "def", "page_not_found", "(", "request", ",", "template_name", "=", "'404.html'", ")", ":", "try", ":", "template", "=", "loader", ".", "get_template", "(", "template_name", ")", "content_type", "=", "None", "# Django will use DEFAULT_CONTENT_TYPE", "except", "Templ...
[ 10, 0 ]
[ 28, 69 ]
python
en
['en', 'error', 'th']
False
server_error
(request, template_name='500.html')
500 error handler. Templates: :template:`500.html` Context: None
500 error handler.
def server_error(request, template_name='500.html'): """ 500 error handler. Templates: :template:`500.html` Context: None """ try: template = loader.get_template(template_name) except TemplateDoesNotExist: return http.HttpResponseServerError('<h1>Server Error (500)</h1>', co...
[ "def", "server_error", "(", "request", ",", "template_name", "=", "'500.html'", ")", ":", "try", ":", "template", "=", "loader", ".", "get_template", "(", "template_name", ")", "except", "TemplateDoesNotExist", ":", "return", "http", ".", "HttpResponseServerError"...
[ 32, 0 ]
[ 43, 69 ]
python
en
['en', 'error', 'th']
False
bad_request
(request, template_name='400.html')
400 error handler. Templates: :template:`400.html` Context: None
400 error handler.
def bad_request(request, template_name='400.html'): """ 400 error handler. Templates: :template:`400.html` Context: None """ try: template = loader.get_template(template_name) except TemplateDoesNotExist: return http.HttpResponseBadRequest('<h1>Bad Request (400)</h1>', conte...
[ "def", "bad_request", "(", "request", ",", "template_name", "=", "'400.html'", ")", ":", "try", ":", "template", "=", "loader", ".", "get_template", "(", "template_name", ")", "except", "TemplateDoesNotExist", ":", "return", "http", ".", "HttpResponseBadRequest", ...
[ 47, 0 ]
[ 58, 68 ]
python
en
['en', 'error', 'th']
False
permission_denied
(request, template_name='403.html')
Permission denied (403) handler. Templates: :template:`403.html` Context: None If the template does not exist, an Http403 response containing the text "403 Forbidden" (as per RFC 2616) will be returned.
Permission denied (403) handler.
def permission_denied(request, template_name='403.html'): """ Permission denied (403) handler. Templates: :template:`403.html` Context: None If the template does not exist, an Http403 response containing the text "403 Forbidden" (as per RFC 2616) will be returned. """ try: temp...
[ "def", "permission_denied", "(", "request", ",", "template_name", "=", "'403.html'", ")", ":", "try", ":", "template", "=", "loader", ".", "get_template", "(", "template_name", ")", "except", "TemplateDoesNotExist", ":", "return", "http", ".", "HttpResponseForbidd...
[ 65, 0 ]
[ 79, 79 ]
python
en
['en', 'error', 'th']
False
HttpResponseBase.serialize_headers
(self)
HTTP headers as a bytestring.
HTTP headers as a bytestring.
def serialize_headers(self): """HTTP headers as a bytestring.""" def to_bytes(val, encoding): return val if isinstance(val, bytes) else val.encode(encoding) headers = [ (to_bytes(key, 'ascii') + b': ' + to_bytes(value, 'latin-1')) for key, value in self._head...
[ "def", "serialize_headers", "(", "self", ")", ":", "def", "to_bytes", "(", "val", ",", "encoding", ")", ":", "return", "val", "if", "isinstance", "(", "val", ",", "bytes", ")", "else", "val", ".", "encode", "(", "encoding", ")", "headers", "=", "[", ...
[ 89, 4 ]
[ 98, 36 ]
python
en
['en', 'sv', 'en']
True
HttpResponseBase._convert_to_charset
(self, value, charset, mime_encode=False)
Convert headers key/value to ascii/latin-1 native strings. `charset` must be 'ascii' or 'latin-1'. If `mime_encode` is True and `value` can't be represented in the given charset, apply MIME-encoding.
Convert headers key/value to ascii/latin-1 native strings.
def _convert_to_charset(self, value, charset, mime_encode=False): """ Convert headers key/value to ascii/latin-1 native strings. `charset` must be 'ascii' or 'latin-1'. If `mime_encode` is True and `value` can't be represented in the given charset, apply MIME-encoding. """ ...
[ "def", "_convert_to_charset", "(", "self", ",", "value", ",", "charset", ",", "mime_encode", "=", "False", ")", ":", "if", "not", "isinstance", "(", "value", ",", "(", "bytes", ",", "str", ")", ")", ":", "value", "=", "str", "(", "value", ")", "if", ...
[ 106, 4 ]
[ 131, 20 ]
python
en
['en', 'error', 'th']
False
HttpResponseBase.has_header
(self, header)
Case-insensitive check for a header.
Case-insensitive check for a header.
def has_header(self, header): """Case-insensitive check for a header.""" return header.lower() in self._headers
[ "def", "has_header", "(", "self", ",", "header", ")", ":", "return", "header", ".", "lower", "(", ")", "in", "self", ".", "_headers" ]
[ 144, 4 ]
[ 146, 46 ]
python
en
['en', 'en', 'en']
True
HttpResponseBase.set_cookie
(self, key, value='', max_age=None, expires=None, path='/', domain=None, secure=False, httponly=False, samesite=None)
Set a cookie. ``expires`` can be: - a string in the correct format, - a naive ``datetime.datetime`` object in UTC, - an aware ``datetime.datetime`` object in any time zone. If it is a ``datetime.datetime`` object then calculate ``max_age``.
Set a cookie.
def set_cookie(self, key, value='', max_age=None, expires=None, path='/', domain=None, secure=False, httponly=False, samesite=None): """ Set a cookie. ``expires`` can be: - a string in the correct format, - a naive ``datetime.datetime`` object in UTC, ...
[ "def", "set_cookie", "(", "self", ",", "key", ",", "value", "=", "''", ",", "max_age", "=", "None", ",", "expires", "=", "None", ",", "path", "=", "'/'", ",", "domain", "=", "None", ",", "secure", "=", "False", ",", "httponly", "=", "False", ",", ...
[ 156, 4 ]
[ 200, 52 ]
python
en
['en', 'error', 'th']
False
HttpResponseBase.setdefault
(self, key, value)
Set a header unless it has already been set.
Set a header unless it has already been set.
def setdefault(self, key, value): """Set a header unless it has already been set.""" if key not in self: self[key] = value
[ "def", "setdefault", "(", "self", ",", "key", ",", "value", ")", ":", "if", "key", "not", "in", "self", ":", "self", "[", "key", "]", "=", "value" ]
[ 202, 4 ]
[ 205, 29 ]
python
en
['en', 'lb', 'en']
True
HttpResponseBase.make_bytes
(self, value)
Turn a value into a bytestring encoded in the output charset.
Turn a value into a bytestring encoded in the output charset.
def make_bytes(self, value): """Turn a value into a bytestring encoded in the output charset.""" # Per PEP 3333, this response body must be bytes. To avoid returning # an instance of a subclass, this function returns `bytes(value)`. # This doesn't make a copy when `value` already contain...
[ "def", "make_bytes", "(", "self", ",", "value", ")", ":", "# Per PEP 3333, this response body must be bytes. To avoid returning", "# an instance of a subclass, this function returns `bytes(value)`.", "# This doesn't make a copy when `value` already contains bytes.", "# Handle string types -- w...
[ 222, 4 ]
[ 236, 46 ]
python
en
['en', 'en', 'en']
True
HttpResponse.serialize
(self)
Full HTTP message, including headers, as a bytestring.
Full HTTP message, including headers, as a bytestring.
def serialize(self): """Full HTTP message, including headers, as a bytestring.""" return self.serialize_headers() + b'\r\n\r\n' + self.content
[ "def", "serialize", "(", "self", ")", ":", "return", "self", ".", "serialize_headers", "(", ")", "+", "b'\\r\\n\\r\\n'", "+", "self", ".", "content" ]
[ 300, 4 ]
[ 302, 68 ]
python
en
['en', 'en', 'en']
True
FileResponse.set_headers
(self, filelike)
Set some common response headers (Content-Length, Content-Type, and Content-Disposition) based on the `filelike` response content.
Set some common response headers (Content-Length, Content-Type, and Content-Disposition) based on the `filelike` response content.
def set_headers(self, filelike): """ Set some common response headers (Content-Length, Content-Type, and Content-Disposition) based on the `filelike` response content. """ encoding_map = { 'bzip2': 'application/x-bzip', 'gzip': 'application/gzip', ...
[ "def", "set_headers", "(", "self", ",", "filelike", ")", ":", "encoding_map", "=", "{", "'bzip2'", ":", "'application/x-bzip'", ",", "'gzip'", ":", "'application/gzip'", ",", "'xz'", ":", "'application/x-xz'", ",", "}", "filename", "=", "getattr", "(", "fileli...
[ 413, 4 ]
[ 450, 54 ]
python
en
['en', 'error', 'th']
False
create_keras_neuropod
( sess, model, node_name_mapping=None, input_spec=None, output_spec=None, **kwargs )
Packages a Keras model as a neuropod package. Currently, only the TensorFlow backend is supported. {common_doc_pre} :param sess: A TensorFlow session containing weights (usually `keras.backend.get_session()`). :param model: A Keras model object. :param node_name_ma...
Packages a Keras model as a neuropod package. Currently, only the TensorFlow backend is supported.
def create_keras_neuropod( sess, model, node_name_mapping=None, input_spec=None, output_spec=None, **kwargs ): """ Packages a Keras model as a neuropod package. Currently, only the TensorFlow backend is supported. {common_doc_pre} :param sess: A TensorFlow session containing weights...
[ "def", "create_keras_neuropod", "(", "sess", ",", "model", ",", "node_name_mapping", "=", "None", ",", "input_spec", "=", "None", ",", "output_spec", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "input_spec", "is", "None", ":", "input_spec", "=", ...
[ 25, 0 ]
[ 111, 5 ]
python
en
['en', 'error', 'th']
False
_check_spec
(spec, spec_type, names, node_name_mapping)
Function checking whether specification only references allowed set of names.
Function checking whether specification only references allowed set of names.
def _check_spec(spec, spec_type, names, node_name_mapping): """ Function checking whether specification only references allowed set of names. """ for spec_el in spec: name = spec_el["name"] if node_name_mapping: keras_name = node_name_mapping.get(name) if keras_na...
[ "def", "_check_spec", "(", "spec", ",", "spec_type", ",", "names", ",", "node_name_mapping", ")", ":", "for", "spec_el", "in", "spec", ":", "name", "=", "spec_el", "[", "\"name\"", "]", "if", "node_name_mapping", ":", "keras_name", "=", "node_name_mapping", ...
[ 114, 0 ]
[ 139, 17 ]
python
en
['en', 'error', 'th']
False
infer_keras_input_spec
(model, node_name_mapping=None)
Infers input schema of a Keras model. :param model: A Keras model object. :param node_name_mapping: Optional mapping from a neuropod input/output name to a name of Keras layers Ex: { "x": "input_1", ...
Infers input schema of a Keras model.
def infer_keras_input_spec(model, node_name_mapping=None): """ Infers input schema of a Keras model. :param model: A Keras model object. :param node_name_mapping: Optional mapping from a neuropod input/output name to a name of Keras layers Ex: { ...
[ "def", "infer_keras_input_spec", "(", "model", ",", "node_name_mapping", "=", "None", ")", ":", "return", "_infer_keras_spec", "(", "model", ".", "input_names", ",", "model", ".", "inputs", ",", "node_name_mapping", ")" ]
[ 142, 0 ]
[ 158, 80 ]
python
en
['en', 'error', 'th']
False
infer_keras_output_spec
(model, node_name_mapping=None)
Infers output schema of a Keras model. :param model: A Keras model object. :param node_name_mapping: Optional mapping from a neuropod input/output name to a name of Keras layers Ex: { "x": "input_1", ...
Infers output schema of a Keras model.
def infer_keras_output_spec(model, node_name_mapping=None): """ Infers output schema of a Keras model. :param model: A Keras model object. :param node_name_mapping: Optional mapping from a neuropod input/output name to a name of Keras layers Ex: { ...
[ "def", "infer_keras_output_spec", "(", "model", ",", "node_name_mapping", "=", "None", ")", ":", "return", "_infer_keras_spec", "(", "model", ".", "output_names", ",", "model", ".", "outputs", ",", "node_name_mapping", ")" ]
[ 161, 0 ]
[ 177, 82 ]
python
en
['en', 'error', 'th']
False
_infer_keras_spec
(names, tensors, node_name_mapping)
Function implementing the spec inference for either input or output.
Function implementing the spec inference for either input or output.
def _infer_keras_spec(names, tensors, node_name_mapping): """ Function implementing the spec inference for either input or output. """ reverse_node_name_mapping = { keras_name: name for name, keras_name in (node_name_mapping or dict()).items() } spec = [] for keras_name, tensor in z...
[ "def", "_infer_keras_spec", "(", "names", ",", "tensors", ",", "node_name_mapping", ")", ":", "reverse_node_name_mapping", "=", "{", "keras_name", ":", "name", "for", "name", ",", "keras_name", "in", "(", "node_name_mapping", "or", "dict", "(", ")", ")", ".", ...
[ 180, 0 ]
[ 208, 15 ]
python
en
['en', 'error', 'th']
False
create_torchscript_neuropod
(neuropod_path, module=None, module_path=None, **kwargs)
Packages a TorchScript model as a neuropod package. {common_doc_pre} :param module: An instance of a PyTorch ScriptModule. This model should return the outputs as a dictionary. If this is not provided, `module_path` must be set. ...
Packages a TorchScript model as a neuropod package.
def create_torchscript_neuropod(neuropod_path, module=None, module_path=None, **kwargs): """ Packages a TorchScript model as a neuropod package. {common_doc_pre} :param module: An instance of a PyTorch ScriptModule. This model should return the outputs as a...
[ "def", "create_torchscript_neuropod", "(", "neuropod_path", ",", "module", "=", "None", ",", "module_path", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# Make sure the inputs are valid", "if", "(", "module", "is", "None", ")", "==", "(", "module_path", "i...
[ 22, 0 ]
[ 61, 42 ]
python
en
['en', 'error', 'th']
False
read_mandyoc_particles
( path, parameters_file=PARAMETERS_FILE, steps_slice=None, filetype="ascii", )
Read the particle files generated by Mandyoc code and return the dataset with the position, id, layer and cumulative strain in time. Parameters ---------- path : str Path to the folder where the Mandyoc files are located. parameters_file : str (optional) Name of the parameter f...
Read the particle files generated by Mandyoc code and return the dataset with the position, id, layer and cumulative strain in time.
def read_mandyoc_particles( path, parameters_file=PARAMETERS_FILE, steps_slice=None, filetype="ascii", ): """ Read the particle files generated by Mandyoc code and return the dataset with the position, id, layer and cumulative strain in time. Parameters ---------- path : str ...
[ "def", "read_mandyoc_particles", "(", "path", ",", "parameters_file", "=", "PARAMETERS_FILE", ",", "steps_slice", "=", "None", ",", "filetype", "=", "\"ascii\"", ",", ")", ":", "# Check valid filetype", "_check_filetype", "(", "filetype", ")", "# Get particle files", ...
[ 10, 0 ]
[ 94, 13 ]
python
en
['en', 'error', 'th']
False
_check_filetype
(filetype)
Checks if passed filetype is either ascii or binary
Checks if passed filetype is either ascii or binary
def _check_filetype(filetype): """ Checks if passed filetype is either ascii or binary """ if filetype not in ("ascii", "binary"): raise ValueError(f"Invalid filetype '{filetype}'")
[ "def", "_check_filetype", "(", "filetype", ")", ":", "if", "filetype", "not", "in", "(", "\"ascii\"", ",", "\"binary\"", ")", ":", "raise", "ValueError", "(", "f\"Invalid filetype '{filetype}'\"", ")" ]
[ 97, 0 ]
[ 102, 58 ]
python
en
['en', 'error', 'th']
False
_get_all_particles_ids
( path, particle_files, filetype, first_step=0, )
Function to get the particle id from the first step file
Function to get the particle id from the first step file
def _get_all_particles_ids( path, particle_files, filetype, first_step=0, ): """ Function to get the particle id from the first step file """ first_step_files = [f for f in particle_files if "step_{}".format(first_step) in f] particle_ids = [] for i in range(len(first_step_files)...
[ "def", "_get_all_particles_ids", "(", "path", ",", "particle_files", ",", "filetype", ",", "first_step", "=", "0", ",", ")", ":", "first_step_files", "=", "[", "f", "for", "f", "in", "particle_files", "if", "\"step_{}\"", ".", "format", "(", "first_step", ")...
[ 105, 0 ]
[ 125, 23 ]
python
en
['en', 'error', 'th']
False
SessionStorage._get
(self, *args, **kwargs)
Retrieves a list of messages from the request's session. This storage always stores everything it is given, so return True for the all_retrieved flag.
Retrieves a list of messages from the request's session. This storage always stores everything it is given, so return True for the all_retrieved flag.
def _get(self, *args, **kwargs): """ Retrieves a list of messages from the request's session. This storage always stores everything it is given, so return True for the all_retrieved flag. """ return self.deserialize_messages(self.request.session.get(self.session_key)), T...
[ "def", "_get", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "deserialize_messages", "(", "self", ".", "request", ".", "session", ".", "get", "(", "self", ".", "session_key", ")", ")", ",", "True" ]
[ 20, 4 ]
[ 26, 90 ]
python
en
['en', 'error', 'th']
False
SessionStorage._store
(self, messages, response, *args, **kwargs)
Stores a list of messages to the request's session.
Stores a list of messages to the request's session.
def _store(self, messages, response, *args, **kwargs): """ Stores a list of messages to the request's session. """ if messages: self.request.session[self.session_key] = self.serialize_messages(messages) else: self.request.session.pop(self.session_key, None...
[ "def", "_store", "(", "self", ",", "messages", ",", "response", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "messages", ":", "self", ".", "request", ".", "session", "[", "self", ".", "session_key", "]", "=", "self", ".", "serialize_mes...
[ 28, 4 ]
[ 36, 17 ]
python
en
['en', 'error', 'th']
False
MigrationRecorder.Migration
(cls)
Lazy load to avoid AppRegistryNotReady if installed apps import MigrationRecorder.
Lazy load to avoid AppRegistryNotReady if installed apps import MigrationRecorder.
def Migration(cls): """ Lazy load to avoid AppRegistryNotReady if installed apps import MigrationRecorder. """ if cls._migration_class is None: class Migration(models.Model): app = models.CharField(max_length=255) name = models.CharFiel...
[ "def", "Migration", "(", "cls", ")", ":", "if", "cls", ".", "_migration_class", "is", "None", ":", "class", "Migration", "(", "models", ".", "Model", ")", ":", "app", "=", "models", ".", "CharField", "(", "max_length", "=", "255", ")", "name", "=", "...
[ 24, 4 ]
[ 44, 35 ]
python
en
['en', 'error', 'th']
False
MigrationRecorder.has_table
(self)
Return True if the django_migrations table exists.
Return True if the django_migrations table exists.
def has_table(self): """Return True if the django_migrations table exists.""" return self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor())
[ "def", "has_table", "(", "self", ")", ":", "return", "self", ".", "Migration", ".", "_meta", ".", "db_table", "in", "self", ".", "connection", ".", "introspection", ".", "table_names", "(", "self", ".", "connection", ".", "cursor", "(", ")", ")" ]
[ 53, 4 ]
[ 55, 115 ]
python
en
['en', 'ca', 'en']
True
MigrationRecorder.ensure_schema
(self)
Ensure the table exists and has the correct schema.
Ensure the table exists and has the correct schema.
def ensure_schema(self): """Ensure the table exists and has the correct schema.""" # If the table's there, that's fine - we've never changed its schema # in the codebase. if self.has_table(): return # Make the table try: with self.connection.schema...
[ "def", "ensure_schema", "(", "self", ")", ":", "# If the table's there, that's fine - we've never changed its schema", "# in the codebase.", "if", "self", ".", "has_table", "(", ")", ":", "return", "# Make the table", "try", ":", "with", "self", ".", "connection", ".", ...
[ 57, 4 ]
[ 68, 99 ]
python
en
['en', 'en', 'en']
True
MigrationRecorder.applied_migrations
(self)
Return a dict mapping (app_name, migration_name) to Migration instances for all applied migrations.
Return a dict mapping (app_name, migration_name) to Migration instances for all applied migrations.
def applied_migrations(self): """ Return a dict mapping (app_name, migration_name) to Migration instances for all applied migrations. """ if self.has_table(): return {(migration.app, migration.name): migration for migration in self.migration_qs} else: ...
[ "def", "applied_migrations", "(", "self", ")", ":", "if", "self", ".", "has_table", "(", ")", ":", "return", "{", "(", "migration", ".", "app", ",", "migration", ".", "name", ")", ":", "migration", "for", "migration", "in", "self", ".", "migration_qs", ...
[ 70, 4 ]
[ 80, 21 ]
python
en
['en', 'error', 'th']
False
MigrationRecorder.record_applied
(self, app, name)
Record that a migration was applied.
Record that a migration was applied.
def record_applied(self, app, name): """Record that a migration was applied.""" self.ensure_schema() self.migration_qs.create(app=app, name=name)
[ "def", "record_applied", "(", "self", ",", "app", ",", "name", ")", ":", "self", ".", "ensure_schema", "(", ")", "self", ".", "migration_qs", ".", "create", "(", "app", "=", "app", ",", "name", "=", "name", ")" ]
[ 82, 4 ]
[ 85, 52 ]
python
en
['en', 'en', 'en']
True
MigrationRecorder.record_unapplied
(self, app, name)
Record that a migration was unapplied.
Record that a migration was unapplied.
def record_unapplied(self, app, name): """Record that a migration was unapplied.""" self.ensure_schema() self.migration_qs.filter(app=app, name=name).delete()
[ "def", "record_unapplied", "(", "self", ",", "app", ",", "name", ")", ":", "self", ".", "ensure_schema", "(", ")", "self", ".", "migration_qs", ".", "filter", "(", "app", "=", "app", ",", "name", "=", "name", ")", ".", "delete", "(", ")" ]
[ 87, 4 ]
[ 90, 61 ]
python
en
['en', 'en', 'en']
True
MigrationRecorder.flush
(self)
Delete all migration records. Useful for testing migrations.
Delete all migration records. Useful for testing migrations.
def flush(self): """Delete all migration records. Useful for testing migrations.""" self.migration_qs.all().delete()
[ "def", "flush", "(", "self", ")", ":", "self", ".", "migration_qs", ".", "all", "(", ")", ".", "delete", "(", ")" ]
[ 92, 4 ]
[ 94, 40 ]
python
en
['en', 'en', 'en']
True
MiscTests.test_no_sites_framework
(self)
Without the sites framework, should not access SITE_ID or Site objects. Deleting settings is fine here as UserSettingsHolder is used.
Without the sites framework, should not access SITE_ID or Site objects. Deleting settings is fine here as UserSettingsHolder is used.
def test_no_sites_framework(self): """ Without the sites framework, should not access SITE_ID or Site objects. Deleting settings is fine here as UserSettingsHolder is used. """ Site.objects.all().delete() del settings.SITE_ID self.client.get('/admindocs/views/')
[ "def", "test_no_sites_framework", "(", "self", ")", ":", "Site", ".", "objects", ".", "all", "(", ")", ".", "delete", "(", ")", "del", "settings", ".", "SITE_ID", "self", ".", "client", ".", "get", "(", "'/admindocs/views/'", ")" ]
[ 30, 4 ]
[ 37, 44 ]
python
en
['en', 'error', 'th']
False
delete_old_scheduled_jobs
(apps: StateApps, schema_editor: DatabaseSchemaEditor)
Delete any old scheduled jobs, to handle changes in the format of send_email. Ideally, we'd translate the jobs, but it's not really worth the development effort to save a few invitation reminders and day2 followup emails.
Delete any old scheduled jobs, to handle changes in the format of send_email. Ideally, we'd translate the jobs, but it's not really worth the development effort to save a few invitation reminders and day2 followup emails.
def delete_old_scheduled_jobs(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: """Delete any old scheduled jobs, to handle changes in the format of send_email. Ideally, we'd translate the jobs, but it's not really worth the development effort to save a few invitation reminders and day2 fol...
[ "def", "delete_old_scheduled_jobs", "(", "apps", ":", "StateApps", ",", "schema_editor", ":", "DatabaseSchemaEditor", ")", "->", "None", ":", "ScheduledJob", "=", "apps", ".", "get_model", "(", "\"zerver\"", ",", "\"ScheduledJob\"", ")", "ScheduledJob", ".", "obje...
[ 6, 0 ]
[ 13, 39 ]
python
en
['en', 'en', 'en']
True
autoescape
(parser, token)
Force autoescape behavior for this block.
Force autoescape behavior for this block.
def autoescape(parser, token): """ Force autoescape behavior for this block. """ # token.split_contents() isn't useful here because this tag doesn't accept variable as arguments args = token.contents.split() if len(args) != 2: raise TemplateSyntaxError("'autoescape' tag requires exactly ...
[ "def", "autoescape", "(", "parser", ",", "token", ")", ":", "# token.split_contents() isn't useful here because this tag doesn't accept variable as arguments", "args", "=", "token", ".", "contents", ".", "split", "(", ")", "if", "len", "(", "args", ")", "!=", "2", "...
[ 516, 0 ]
[ 529, 57 ]
python
en
['en', 'error', 'th']
False
comment
(parser, token)
Ignore everything between ``{% comment %}`` and ``{% endcomment %}``.
Ignore everything between ``{% comment %}`` and ``{% endcomment %}``.
def comment(parser, token): """ Ignore everything between ``{% comment %}`` and ``{% endcomment %}``. """ parser.skip_past('endcomment') return CommentNode()
[ "def", "comment", "(", "parser", ",", "token", ")", ":", "parser", ".", "skip_past", "(", "'endcomment'", ")", "return", "CommentNode", "(", ")" ]
[ 533, 0 ]
[ 538, 24 ]
python
en
['en', 'error', 'th']
False
cycle
(parser, token)
Cycle among the given strings each time this tag is encountered. Within a loop, cycles among the given strings each time through the loop:: {% for o in some_list %} <tr class="{% cycle 'row1' 'row2' %}"> ... </tr> {% endfor %} Outside of a loop...
Cycle among the given strings each time this tag is encountered.
def cycle(parser, token): """ Cycle among the given strings each time this tag is encountered. Within a loop, cycles among the given strings each time through the loop:: {% for o in some_list %} <tr class="{% cycle 'row1' 'row2' %}"> ... </tr> {%...
[ "def", "cycle", "(", "parser", ",", "token", ")", ":", "# Note: This returns the exact same node on each {% cycle name %} call;", "# that is, the node object returned from {% cycle a b c as name %} and the", "# one returned from {% cycle name %} are the exact same object. This", "# shouldn't c...
[ 542, 0 ]
[ 626, 15 ]
python
en
['en', 'error', 'th']
False
debug
(parser, token)
Output a whole load of debugging information, including the current context and imported modules. Sample usage:: <pre> {% debug %} </pre>
Output a whole load of debugging information, including the current context and imported modules.
def debug(parser, token): """ Output a whole load of debugging information, including the current context and imported modules. Sample usage:: <pre> {% debug %} </pre> """ return DebugNode()
[ "def", "debug", "(", "parser", ",", "token", ")", ":", "return", "DebugNode", "(", ")" ]
[ 635, 0 ]
[ 646, 22 ]
python
en
['en', 'error', 'th']
False
do_filter
(parser, token)
Filter the contents of the block through variable filters. Filters can also be piped through each other, and they can have arguments -- just like in variable syntax. Sample usage:: {% filter force_escape|lower %} This text will be HTML-escaped, and will appear in lowercase. ...
Filter the contents of the block through variable filters.
def do_filter(parser, token): """ Filter the contents of the block through variable filters. Filters can also be piped through each other, and they can have arguments -- just like in variable syntax. Sample usage:: {% filter force_escape|lower %} This text will be HTML-escaped...
[ "def", "do_filter", "(", "parser", ",", "token", ")", ":", "# token.split_contents() isn't useful here because this tag doesn't accept variable as arguments", "_", ",", "rest", "=", "token", ".", "contents", ".", "split", "(", "None", ",", "1", ")", "filter_expr", "="...
[ 650, 0 ]
[ 676, 44 ]
python
en
['en', 'error', 'th']
False
firstof
(parser, token)
Output the first variable passed that is not False. Output nothing if all the passed variables are False. Sample usage:: {% firstof var1 var2 var3 as myvar %} This is equivalent to:: {% if var1 %} {{ var1 }} {% elif var2 %} {{ var2 }} {% elif...
Output the first variable passed that is not False.
def firstof(parser, token): """ Output the first variable passed that is not False. Output nothing if all the passed variables are False. Sample usage:: {% firstof var1 var2 var3 as myvar %} This is equivalent to:: {% if var1 %} {{ var1 }} {% elif var2 %} ...
[ "def", "firstof", "(", "parser", ",", "token", ")", ":", "bits", "=", "token", ".", "split_contents", "(", ")", "[", "1", ":", "]", "asvar", "=", "None", "if", "not", "bits", ":", "raise", "TemplateSyntaxError", "(", "\"'firstof' statement requires at least ...
[ 680, 0 ]
[ 725, 75 ]
python
en
['en', 'error', 'th']
False
do_for
(parser, token)
Loop over each item in an array. For example, to display a list of athletes given ``athlete_list``:: <ul> {% for athlete in athlete_list %} <li>{{ athlete.name }}</li> {% endfor %} </ul> You can loop over a list in reverse by using ``{% for obj in list rev...
Loop over each item in an array.
def do_for(parser, token): """ Loop over each item in an array. For example, to display a list of athletes given ``athlete_list``:: <ul> {% for athlete in athlete_list %} <li>{{ athlete.name }}</li> {% endfor %} </ul> You can loop over a list in reverse by ...
[ "def", "do_for", "(", "parser", ",", "token", ")", ":", "bits", "=", "token", ".", "split_contents", "(", ")", "if", "len", "(", "bits", ")", "<", "4", ":", "raise", "TemplateSyntaxError", "(", "\"'for' statements should have at least four\"", "\" words: %s\"", ...
[ 729, 0 ]
[ 817, 82 ]
python
en
['en', 'error', 'th']
False
ifequal
(parser, token)
Output the contents of the block if the two arguments equal each other. Examples:: {% ifequal user.id comment.user_id %} ... {% endifequal %} {% ifnotequal user.id comment.user_id %} ... {% else %} ... {% endifnotequal %}
Output the contents of the block if the two arguments equal each other.
def ifequal(parser, token): """ Output the contents of the block if the two arguments equal each other. Examples:: {% ifequal user.id comment.user_id %} ... {% endifequal %} {% ifnotequal user.id comment.user_id %} ... {% else %} ... ...
[ "def", "ifequal", "(", "parser", ",", "token", ")", ":", "return", "do_ifequal", "(", "parser", ",", "token", ",", "False", ")" ]
[ 838, 0 ]
[ 854, 43 ]
python
en
['en', 'error', 'th']
False
ifnotequal
(parser, token)
Output the contents of the block if the two arguments are not equal. See ifequal.
Output the contents of the block if the two arguments are not equal. See ifequal.
def ifnotequal(parser, token): """ Output the contents of the block if the two arguments are not equal. See ifequal. """ return do_ifequal(parser, token, True)
[ "def", "ifnotequal", "(", "parser", ",", "token", ")", ":", "return", "do_ifequal", "(", "parser", ",", "token", ",", "True", ")" ]
[ 858, 0 ]
[ 863, 42 ]
python
en
['en', 'error', 'th']
False
do_if
(parser, token)
Evaluate a variable, and if that variable is "true" (i.e., exists, is not empty, and is not a false boolean value), output the contents of the block: :: {% if athlete_list %} Number of athletes: {{ athlete_list|count }} {% elif athlete_in_locker_room_list %} Athlet...
Evaluate a variable, and if that variable is "true" (i.e., exists, is not empty, and is not a false boolean value), output the contents of the block:
def do_if(parser, token): """ Evaluate a variable, and if that variable is "true" (i.e., exists, is not empty, and is not a false boolean value), output the contents of the block: :: {% if athlete_list %} Number of athletes: {{ athlete_list|count }} {% elif athlete_in_locke...
[ "def", "do_if", "(", "parser", ",", "token", ")", ":", "# {% if ... %}", "bits", "=", "token", ".", "split_contents", "(", ")", "[", "1", ":", "]", "condition", "=", "TemplateIfParser", "(", "parser", ",", "bits", ")", ".", "parse", "(", ")", "nodelist...
[ 890, 0 ]
[ 973, 39 ]
python
en
['en', 'error', 'th']
False
ifchanged
(parser, token)
Check if a value has changed from the last iteration of a loop. The ``{% ifchanged %}`` block tag is used within a loop. It has two possible uses. 1. Check its own rendered contents against its previous state and only displays the content if it has changed. For example, this displays a ...
Check if a value has changed from the last iteration of a loop.
def ifchanged(parser, token): """ Check if a value has changed from the last iteration of a loop. The ``{% ifchanged %}`` block tag is used within a loop. It has two possible uses. 1. Check its own rendered contents against its previous state and only displays the content if it has changed....
[ "def", "ifchanged", "(", "parser", ",", "token", ")", ":", "bits", "=", "token", ".", "split_contents", "(", ")", "nodelist_true", "=", "parser", ".", "parse", "(", "(", "'else'", ",", "'endifchanged'", ")", ")", "token", "=", "parser", ".", "next_token"...
[ 977, 0 ]
[ 1015, 64 ]
python
en
['en', 'error', 'th']
False
load_from_library
(library, label, names)
Return a subset of tags and filters from a library.
Return a subset of tags and filters from a library.
def load_from_library(library, label, names): """ Return a subset of tags and filters from a library. """ subset = Library() for name in names: found = False if name in library.tags: found = True subset.tags[name] = library.tags[name] if name in librar...
[ "def", "load_from_library", "(", "library", ",", "label", ",", "names", ")", ":", "subset", "=", "Library", "(", ")", "for", "name", "in", "names", ":", "found", "=", "False", "if", "name", "in", "library", ".", "tags", ":", "found", "=", "True", "su...
[ 1029, 0 ]
[ 1048, 17 ]
python
en
['en', 'error', 'th']
False
load
(parser, token)
Load a custom template tag library into the parser. For example, to load the template tags in ``django/templatetags/news/photos.py``:: {% load news.photos %} Can also be used to load an individual tag/filter from a library:: {% load byline from news %}
Load a custom template tag library into the parser.
def load(parser, token): """ Load a custom template tag library into the parser. For example, to load the template tags in ``django/templatetags/news/photos.py``:: {% load news.photos %} Can also be used to load an individual tag/filter from a library:: {% load byline from ne...
[ "def", "load", "(", "parser", ",", "token", ")", ":", "# token.split_contents() isn't useful here because this tag doesn't accept variable as arguments", "bits", "=", "token", ".", "contents", ".", "split", "(", ")", "if", "len", "(", "bits", ")", ">=", "4", "and", ...
[ 1052, 0 ]
[ 1079, 21 ]
python
en
['en', 'error', 'th']
False
lorem
(parser, token)
Create random Latin text useful for providing test data in templates. Usage format:: {% lorem [count] [method] [random] %} ``count`` is a number (or variable) containing the number of paragraphs or words to generate (default is 1). ``method`` is either ``w`` for words, ``p`` for HTML pa...
Create random Latin text useful for providing test data in templates.
def lorem(parser, token): """ Create random Latin text useful for providing test data in templates. Usage format:: {% lorem [count] [method] [random] %} ``count`` is a number (or variable) containing the number of paragraphs or words to generate (default is 1). ``method`` is either `...
[ "def", "lorem", "(", "parser", ",", "token", ")", ":", "bits", "=", "list", "(", "token", ".", "split_contents", "(", ")", ")", "tagname", "=", "bits", "[", "0", "]", "# Random bit", "common", "=", "bits", "[", "-", "1", "]", "!=", "'random'", "if"...
[ 1083, 0 ]
[ 1126, 43 ]
python
en
['en', 'error', 'th']
False
now
(parser, token)
Display the date, formatted according to the given string. Use the same format as PHP's ``date()`` function; see https://php.net/date for all the possible values. Sample usage:: It is {% now "jS F Y H:i" %}
Display the date, formatted according to the given string.
def now(parser, token): """ Display the date, formatted according to the given string. Use the same format as PHP's ``date()`` function; see https://php.net/date for all the possible values. Sample usage:: It is {% now "jS F Y H:i" %} """ bits = token.split_contents() asvar = ...
[ "def", "now", "(", "parser", ",", "token", ")", ":", "bits", "=", "token", ".", "split_contents", "(", ")", "asvar", "=", "None", "if", "len", "(", "bits", ")", "==", "4", "and", "bits", "[", "-", "2", "]", "==", "'as'", ":", "asvar", "=", "bit...
[ 1130, 0 ]
[ 1149, 40 ]
python
en
['en', 'error', 'th']
False
regroup
(parser, token)
Regroup a list of alike objects by a common attribute. This complex tag is best illustrated by use of an example: say that ``musicians`` is a list of ``Musician`` objects that have ``name`` and ``instrument`` attributes, and you'd like to display a list that looks like: * Guitar: ...
Regroup a list of alike objects by a common attribute.
def regroup(parser, token): """ Regroup a list of alike objects by a common attribute. This complex tag is best illustrated by use of an example: say that ``musicians`` is a list of ``Musician`` objects that have ``name`` and ``instrument`` attributes, and you'd like to display a list that look...
[ "def", "regroup", "(", "parser", ",", "token", ")", ":", "bits", "=", "token", ".", "split_contents", "(", ")", "if", "len", "(", "bits", ")", "!=", "6", ":", "raise", "TemplateSyntaxError", "(", "\"'regroup' tag takes five arguments\"", ")", "target", "=", ...
[ 1153, 0 ]
[ 1218, 52 ]
python
en
['en', 'error', 'th']
False
resetcycle
(parser, token)
Reset a cycle tag. If an argument is given, reset the last rendered cycle tag whose name matches the argument, else reset the last rendered cycle tag (named or unnamed).
Reset a cycle tag.
def resetcycle(parser, token): """ Reset a cycle tag. If an argument is given, reset the last rendered cycle tag whose name matches the argument, else reset the last rendered cycle tag (named or unnamed). """ args = token.split_contents() if len(args) > 2: raise TemplateSyntaxE...
[ "def", "resetcycle", "(", "parser", ",", "token", ")", ":", "args", "=", "token", ".", "split_contents", "(", ")", "if", "len", "(", "args", ")", ">", "2", ":", "raise", "TemplateSyntaxError", "(", "\"%r tag accepts at most one argument.\"", "%", "args", "["...
[ 1222, 0 ]
[ 1244, 59 ]
python
en
['en', 'error', 'th']
False
spaceless
(parser, token)
Remove whitespace between HTML tags, including tab and newline characters. Example usage:: {% spaceless %} <p> <a href="foo/">Foo</a> </p> {% endspaceless %} This example returns this HTML:: <p><a href="foo/">Foo</a></p> Only space be...
Remove whitespace between HTML tags, including tab and newline characters.
def spaceless(parser, token): """ Remove whitespace between HTML tags, including tab and newline characters. Example usage:: {% spaceless %} <p> <a href="foo/">Foo</a> </p> {% endspaceless %} This example returns this HTML:: <p><a href=...
[ "def", "spaceless", "(", "parser", ",", "token", ")", ":", "nodelist", "=", "parser", ".", "parse", "(", "(", "'endspaceless'", ",", ")", ")", "parser", ".", "delete_first_token", "(", ")", "return", "SpacelessNode", "(", "nodelist", ")" ]
[ 1248, 0 ]
[ 1275, 34 ]
python
en
['en', 'error', 'th']
False
templatetag
(parser, token)
Output one of the bits used to compose template tags. Since the template system has no concept of "escaping", to display one of the bits used in template tags, you must use the ``{% templatetag %}`` tag. The argument tells which template bit to output: ================== ======= Arg...
Output one of the bits used to compose template tags.
def templatetag(parser, token): """ Output one of the bits used to compose template tags. Since the template system has no concept of "escaping", to display one of the bits used in template tags, you must use the ``{% templatetag %}`` tag. The argument tells which template bit to output: ...
[ "def", "templatetag", "(", "parser", ",", "token", ")", ":", "# token.split_contents() isn't useful here because this tag doesn't accept variable as arguments", "bits", "=", "token", ".", "contents", ".", "split", "(", ")", "if", "len", "(", "bits", ")", "!=", "2", ...
[ 1279, 0 ]
[ 1310, 31 ]
python
en
['en', 'error', 'th']
False
url
(parser, token)
r""" Return an absolute URL matching the given view with its parameters. This is a way to define links that aren't tied to a particular URL configuration:: {% url "url_name" arg1 arg2 %} or {% url "url_name" name1=value1 name2=value2 %} The first argument is a URL pattern na...
r""" Return an absolute URL matching the given view with its parameters.
def url(parser, token): r""" Return an absolute URL matching the given view with its parameters. This is a way to define links that aren't tied to a particular URL configuration:: {% url "url_name" arg1 arg2 %} or {% url "url_name" name1=value1 name2=value2 %} The first ...
[ "def", "url", "(", "parser", ",", "token", ")", ":", "bits", "=", "token", ".", "split_contents", "(", ")", "if", "len", "(", "bits", ")", "<", "2", ":", "raise", "TemplateSyntaxError", "(", "\"'%s' takes at least one argument, a URL pattern name.\"", "%", "bi...
[ 1314, 0 ]
[ 1377, 49 ]
python
cy
['en', 'cy', 'hi']
False
verbatim
(parser, token)
Stop the template engine from rendering the contents of this block tag. Usage:: {% verbatim %} {% don't process this %} {% endverbatim %} You can also designate a specific closing tag block (allowing the unrendered use of ``{% endverbatim %}``):: {% verbatim mybl...
Stop the template engine from rendering the contents of this block tag.
def verbatim(parser, token): """ Stop the template engine from rendering the contents of this block tag. Usage:: {% verbatim %} {% don't process this %} {% endverbatim %} You can also designate a specific closing tag block (allowing the unrendered use of ``{% endverbat...
[ "def", "verbatim", "(", "parser", ",", "token", ")", ":", "nodelist", "=", "parser", ".", "parse", "(", "(", "'endverbatim'", ",", ")", ")", "parser", ".", "delete_first_token", "(", ")", "return", "VerbatimNode", "(", "nodelist", ".", "render", "(", "Co...
[ 1381, 0 ]
[ 1400, 51 ]
python
en
['en', 'error', 'th']
False
widthratio
(parser, token)
For creating bar charts and such. Calculate the ratio of a given value to a maximum value, and then apply that ratio to a constant. For example:: <img src="bar.png" alt="Bar" height="10" width="{% widthratio this_value max_value max_width %}"> If ``this_value`` is 175, ``max_val...
For creating bar charts and such. Calculate the ratio of a given value to a maximum value, and then apply that ratio to a constant.
def widthratio(parser, token): """ For creating bar charts and such. Calculate the ratio of a given value to a maximum value, and then apply that ratio to a constant. For example:: <img src="bar.png" alt="Bar" height="10" width="{% widthratio this_value max_value max_width %}"> ...
[ "def", "widthratio", "(", "parser", ",", "token", ")", ":", "bits", "=", "token", ".", "split_contents", "(", ")", "if", "len", "(", "bits", ")", "==", "4", ":", "tag", ",", "this_value_expr", ",", "max_value_expr", ",", "max_width", "=", "bits", "asva...
[ 1404, 0 ]
[ 1438, 38 ]
python
en
['en', 'error', 'th']
False
do_with
(parser, token)
Add one or more values to the context (inside of this block) for caching and easy access. For example:: {% with total=person.some_sql_method %} {{ total }} object{{ total|pluralize }} {% endwith %} Multiple values can be added to the context:: {% with foo=1 bar=2...
Add one or more values to the context (inside of this block) for caching and easy access.
def do_with(parser, token): """ Add one or more values to the context (inside of this block) for caching and easy access. For example:: {% with total=person.some_sql_method %} {{ total }} object{{ total|pluralize }} {% endwith %} Multiple values can be added to the con...
[ "def", "do_with", "(", "parser", ",", "token", ")", ":", "bits", "=", "token", ".", "split_contents", "(", ")", "remaining_bits", "=", "bits", "[", "1", ":", "]", "extra_context", "=", "token_kwargs", "(", "remaining_bits", ",", "parser", ",", "support_leg...
[ 1442, 0 ]
[ 1473, 70 ]
python
en
['en', 'error', 'th']
False
CycleNode.reset
(self, context)
Reset the cycle iteration back to the beginning.
Reset the cycle iteration back to the beginning.
def reset(self, context): """ Reset the cycle iteration back to the beginning. """ context.render_context[self] = itertools_cycle(self.cyclevars)
[ "def", "reset", "(", "self", ",", "context", ")", ":", "context", ".", "render_context", "[", "self", "]", "=", "itertools_cycle", "(", "self", ".", "cyclevars", ")" ]
[ 87, 4 ]
[ 91, 70 ]
python
en
['en', 'error', 'th']
False
register_adapter
(typ, callable)
Register 'callable' as an ISQLQuote adapter for type 'typ'.
Register 'callable' as an ISQLQuote adapter for type 'typ'.
def register_adapter(typ, callable): """Register 'callable' as an ISQLQuote adapter for type 'typ'.""" adapters[(typ, ISQLQuote)] = callable
[ "def", "register_adapter", "(", "typ", ",", "callable", ")", ":", "adapters", "[", "(", "typ", ",", "ISQLQuote", ")", "]", "=", "callable" ]
[ 102, 0 ]
[ 104, 41 ]
python
en
['en', 'en', 'en']
True
make_dsn
(dsn=None, **kwargs)
Convert a set of keywords into a connection strings.
Convert a set of keywords into a connection strings.
def make_dsn(dsn=None, **kwargs): """Convert a set of keywords into a connection strings.""" if dsn is None and not kwargs: return '' # If no kwarg is specified don't mung the dsn, but verify it if not kwargs: parse_dsn(dsn) return dsn # Override the dsn with the parameters...
[ "def", "make_dsn", "(", "dsn", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "dsn", "is", "None", "and", "not", "kwargs", ":", "return", "''", "# If no kwarg is specified don't mung the dsn, but verify it", "if", "not", "kwargs", ":", "parse_dsn", "(",...
[ 145, 0 ]
[ 176, 14 ]
python
en
['en', 'en', 'en']
True
_param_escape
(s, re_escape=_re.compile(r"([\\'])"), re_space=_re.compile(r'\s'))
Apply the escaping rule required by PQconnectdb
Apply the escaping rule required by PQconnectdb
def _param_escape(s, re_escape=_re.compile(r"([\\'])"), re_space=_re.compile(r'\s')): """ Apply the escaping rule required by PQconnectdb """ if not s: return "''" s = re_escape.sub(r'\\\1', s) if re_space.search(s): s = "'" + s + "'" return s
[ "def", "_param_escape", "(", "s", ",", "re_escape", "=", "_re", ".", "compile", "(", "r\"([\\\\'])\"", ")", ",", "re_space", "=", "_re", ".", "compile", "(", "r'\\s'", ")", ")", ":", "if", "not", "s", ":", "return", "\"''\"", "s", "=", "re_escape", "...
[ 179, 0 ]
[ 192, 12 ]
python
en
['en', 'error', 'th']
False
GoogleZoom.__init__
(self, num_zoom=19, tilesize=256)
Initializes the Google Zoom object.
Initializes the Google Zoom object.
def __init__(self, num_zoom=19, tilesize=256): "Initializes the Google Zoom object." # Google's tilesize is 256x256, square tiles are assumed. self._tilesize = tilesize # The number of zoom levels self._nzoom = num_zoom # Initializing arrays to hold the parameters for e...
[ "def", "__init__", "(", "self", ",", "num_zoom", "=", "19", ",", "tilesize", "=", "256", ")", ":", "# Google's tilesize is 256x256, square tiles are assumed.", "self", ".", "_tilesize", "=", "tilesize", "# The number of zoom levels", "self", ".", "_nzoom", "=", "num...
[ 27, 4 ]
[ 51, 18 ]
python
en
['en', 'en', 'en']
True