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
SpatialProxy.__init__
(self, klass, field)
Proxy initializes on the given Geometry or Raster class (not an instance) and the corresponding field.
Proxy initializes on the given Geometry or Raster class (not an instance) and the corresponding field.
def __init__(self, klass, field): """ Proxy initializes on the given Geometry or Raster class (not an instance) and the corresponding field. """ self._field = field self._klass = klass super(SpatialProxy, self).__init__(field.attname, klass)
[ "def", "__init__", "(", "self", ",", "klass", ",", "field", ")", ":", "self", ".", "_field", "=", "field", "self", ".", "_klass", "=", "klass", "super", "(", "SpatialProxy", ",", "self", ")", ".", "__init__", "(", "field", ".", "attname", ",", "klass...
[ 12, 4 ]
[ 19, 64 ]
python
en
['en', 'error', 'th']
False
SpatialProxy.__get__
(self, instance, cls=None)
This accessor retrieves the geometry or raster, initializing it using the corresponding class specified during initialization and the value of the field. Currently, GEOS or OGR geometries as well as GDALRasters are supported.
This accessor retrieves the geometry or raster, initializing it using the corresponding class specified during initialization and the value of the field. Currently, GEOS or OGR geometries as well as GDALRasters are supported.
def __get__(self, instance, cls=None): """ This accessor retrieves the geometry or raster, initializing it using the corresponding class specified during initialization and the value of the field. Currently, GEOS or OGR geometries as well as GDALRasters are supported. """...
[ "def", "__get__", "(", "self", ",", "instance", ",", "cls", "=", "None", ")", ":", "if", "instance", "is", "None", ":", "# Accessed on a class, not an instance", "return", "self", "# Getting the value of the field.", "try", ":", "geo_value", "=", "instance", ".", ...
[ 21, 4 ]
[ 47, 22 ]
python
en
['en', 'error', 'th']
False
SpatialProxy.__set__
(self, instance, value)
This accessor sets the proxied geometry or raster with the corresponding class specified during initialization. To set geometries, values of None, HEXEWKB, or WKT may be used. To set rasters, JSON or dict values may be used.
This accessor sets the proxied geometry or raster with the corresponding class specified during initialization.
def __set__(self, instance, value): """ This accessor sets the proxied geometry or raster with the corresponding class specified during initialization. To set geometries, values of None, HEXEWKB, or WKT may be used. To set rasters, JSON or dict values may be used. """ ...
[ "def", "__set__", "(", "self", ",", "instance", ",", "value", ")", ":", "# The geographic type of the field.", "gtype", "=", "self", ".", "_field", ".", "geom_type", "if", "gtype", "==", "'RASTER'", "and", "(", "value", "is", "None", "or", "isinstance", "(",...
[ 49, 4 ]
[ 79, 20 ]
python
en
['en', 'error', 'th']
False
SiegeExecutor.shutdown
(self)
If tool is still running - let's stop it.
If tool is still running - let's stop it.
def shutdown(self): """ If tool is still running - let's stop it. """ shutdown_process(self.process, self.log)
[ "def", "shutdown", "(", "self", ")", ":", "shutdown_process", "(", "self", ".", "process", ",", "self", ".", "log", ")" ]
[ 150, 4 ]
[ 154, 48 ]
python
en
['en', 'error', 'th']
False
sdist_add_defaults.add_defaults
(self)
Add all the default files to self.filelist: - README or README.txt - setup.py - test/test*.py - all pure Python modules mentioned in setup script - all files pointed by package_data (build_py) - all files defined in data_files. - all files defined as...
Add all the default files to self.filelist: - README or README.txt - setup.py - test/test*.py - all pure Python modules mentioned in setup script - all files pointed by package_data (build_py) - all files defined in data_files. - all files defined as...
def add_defaults(self): """Add all the default files to self.filelist: - README or README.txt - setup.py - test/test*.py - all pure Python modules mentioned in setup script - all files pointed by package_data (build_py) - all files defined in data_file...
[ "def", "add_defaults", "(", "self", ")", ":", "self", ".", "_add_defaults_standards", "(", ")", "self", ".", "_add_defaults_optional", "(", ")", "self", ".", "_add_defaults_python", "(", ")", "self", ".", "_add_defaults_data_files", "(", ")", "self", ".", "_ad...
[ 15, 4 ]
[ 35, 36 ]
python
en
['en', 'en', 'en']
True
sdist_add_defaults._cs_path_exists
(fspath)
Case-sensitive path existence check >>> sdist_add_defaults._cs_path_exists(__file__) True >>> sdist_add_defaults._cs_path_exists(__file__.upper()) False
Case-sensitive path existence check
def _cs_path_exists(fspath): """ Case-sensitive path existence check >>> sdist_add_defaults._cs_path_exists(__file__) True >>> sdist_add_defaults._cs_path_exists(__file__.upper()) False """ if not os.path.exists(fspath): return False #...
[ "def", "_cs_path_exists", "(", "fspath", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "fspath", ")", ":", "return", "False", "# make absolute so we always have a directory", "abspath", "=", "os", ".", "path", ".", "abspath", "(", "fspath", "...
[ 38, 4 ]
[ 52, 48 ]
python
en
['en', 'error', 'th']
False
mark_points
(frame, points)
Draw dots corresponding to 'points'. Args: frame: 2-d matrix representing one SMM channel ([y, x]) points: a list of (x, y) coordinates to be marked
Draw dots corresponding to 'points'.
def mark_points(frame, points): """Draw dots corresponding to 'points'. Args: frame: 2-d matrix representing one SMM channel ([y, x]) points: a list of (x, y) coordinates to be marked """ for p in range(len(points) // 2): x = int((points[p * 2] - MINIMAP_NORM_X_MIN) / (MINIMAP_NORM_X_MA...
[ "def", "mark_points", "(", "frame", ",", "points", ")", ":", "for", "p", "in", "range", "(", "len", "(", "points", ")", "//", "2", ")", ":", "x", "=", "int", "(", "(", "points", "[", "p", "*", "2", "]", "-", "MINIMAP_NORM_X_MIN", ")", "/", "(",...
[ 45, 0 ]
[ 59, 31 ]
python
en
['en', 'en', 'en']
True
generate_smm
(observation, config=None, channel_dimensions=(SMM_WIDTH, SMM_HEIGHT))
Returns a list of minimap observations given the raw features for each active player. Args: observation: raw features from the environment channel_dimensions: resolution of SMM to generate config: environment config Returns: (N, H, W, C) - shaped np array representing SMM. N stands for the numbe...
Returns a list of minimap observations given the raw features for each active player.
def generate_smm(observation, config=None, channel_dimensions=(SMM_WIDTH, SMM_HEIGHT)): """Returns a list of minimap observations given the raw features for each active player. Args: observation: raw features from the environment channel_dimensions: resolution of SMM to generate conf...
[ "def", "generate_smm", "(", "observation", ",", "config", "=", "None", ",", "channel_dimensions", "=", "(", "SMM_WIDTH", ",", "SMM_HEIGHT", ")", ")", ":", "frame", "=", "np", ".", "zeros", "(", "(", "len", "(", "observation", ")", ",", "channel_dimensions"...
[ 62, 0 ]
[ 91, 14 ]
python
en
['en', 'en', 'en']
True
page_not_found
(request, exception, template_name=ERROR_404_TEMPLATE_NAME)
Default 404 handler. Templates: :template:`404.html` Context: request_path The path of the requested URL (e.g., '/app/pages/bad_page/') exception The message from the exception which triggered the 404 (if one was supplied), or the exception class name ...
Default 404 handler.
def page_not_found(request, exception, template_name=ERROR_404_TEMPLATE_NAME): """ Default 404 handler. Templates: :template:`404.html` Context: request_path The path of the requested URL (e.g., '/app/pages/bad_page/') exception The message from the exception whi...
[ "def", "page_not_found", "(", "request", ",", "exception", ",", "template_name", "=", "ERROR_404_TEMPLATE_NAME", ")", ":", "exception_repr", "=", "exception", ".", "__class__", ".", "__name__", "# Try to get an \"interesting\" exception message, if any (and not the ugly", "# ...
[ 16, 0 ]
[ 55, 69 ]
python
en
['en', 'error', 'th']
False
server_error
(request, template_name=ERROR_500_TEMPLATE_NAME)
500 error handler. Templates: :template:`500.html` Context: None
500 error handler.
def server_error(request, template_name=ERROR_500_TEMPLATE_NAME): """ 500 error handler. Templates: :template:`500.html` Context: None """ try: template = loader.get_template(template_name) except TemplateDoesNotExist: if template_name != ERROR_500_TEMPLATE_NAME: ...
[ "def", "server_error", "(", "request", ",", "template_name", "=", "ERROR_500_TEMPLATE_NAME", ")", ":", "try", ":", "template", "=", "loader", ".", "get_template", "(", "template_name", ")", "except", "TemplateDoesNotExist", ":", "if", "template_name", "!=", "ERROR...
[ 59, 0 ]
[ 73, 58 ]
python
en
['en', 'error', 'th']
False
bad_request
(request, exception, template_name=ERROR_400_TEMPLATE_NAME)
400 error handler. Templates: :template:`400.html` Context: None
400 error handler.
def bad_request(request, exception, template_name=ERROR_400_TEMPLATE_NAME): """ 400 error handler. Templates: :template:`400.html` Context: None """ try: template = loader.get_template(template_name) except TemplateDoesNotExist: if template_name != ERROR_400_TEMPLATE_NAME: ...
[ "def", "bad_request", "(", "request", ",", "exception", ",", "template_name", "=", "ERROR_400_TEMPLATE_NAME", ")", ":", "try", ":", "template", "=", "loader", ".", "get_template", "(", "template_name", ")", "except", "TemplateDoesNotExist", ":", "if", "template_na...
[ 77, 0 ]
[ 92, 57 ]
python
en
['en', 'error', 'th']
False
permission_denied
(request, exception, template_name=ERROR_403_TEMPLATE_NAME)
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 7231) will be returned.
Permission denied (403) handler.
def permission_denied(request, exception, template_name=ERROR_403_TEMPLATE_NAME): """ 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 7231) will be returned. "...
[ "def", "permission_denied", "(", "request", ",", "exception", ",", "template_name", "=", "ERROR_403_TEMPLATE_NAME", ")", ":", "try", ":", "template", "=", "loader", ".", "get_template", "(", "template_name", ")", "except", "TemplateDoesNotExist", ":", "if", "templ...
[ 99, 0 ]
[ 118, 5 ]
python
en
['en', 'error', 'th']
False
DatabaseValidation.check_field
(self, field, **kwargs)
MySQL has the following field length restriction: No character (varchar) fields can have a length exceeding 255 characters if they have a unique index on them.
MySQL has the following field length restriction: No character (varchar) fields can have a length exceeding 255 characters if they have a unique index on them.
def check_field(self, field, **kwargs): """ MySQL has the following field length restriction: No character (varchar) fields can have a length exceeding 255 characters if they have a unique index on them. """ errors = super(DatabaseValidation, self).check_field(field, **kw...
[ "def", "check_field", "(", "self", ",", "field", ",", "*", "*", "kwargs", ")", ":", "errors", "=", "super", "(", "DatabaseValidation", ",", "self", ")", ".", "check_field", "(", "field", ",", "*", "*", "kwargs", ")", "# Ignore any related fields.", "if", ...
[ 28, 4 ]
[ 63, 21 ]
python
en
['en', 'error', 'th']
False
PodManager.pod_name_for_package
(self, name)
Return the CocoaPod name for a given Swift package.
Return the CocoaPod name for a given Swift package.
def pod_name_for_package(self, name): """Return the CocoaPod name for a given Swift package.""" pod_mappings = { 'swift-log': 'Logging', 'swift-nio': 'SwiftNIO', 'swift-nio-extras': 'SwiftNIOExtras', 'swift-nio-http2': 'SwiftNIOHTTP2', 'swift-n...
[ "def", "pod_name_for_package", "(", "self", ",", "name", ")", ":", "pod_mappings", "=", "{", "'swift-log'", ":", "'Logging'", ",", "'swift-nio'", ":", "'SwiftNIO'", ",", "'swift-nio-extras'", ":", "'SwiftNIOExtras'", ",", "'swift-nio-http2'", ":", "'SwiftNIOHTTP2'",...
[ 165, 4 ]
[ 176, 33 ]
python
en
['en', 'en', 'en']
True
PodManager.pod_name_for_grpc_target
(self, name)
Return the CocoaPod name for a given gRPC Swift target.
Return the CocoaPod name for a given gRPC Swift target.
def pod_name_for_grpc_target(self, name): """Return the CocoaPod name for a given gRPC Swift target.""" return { 'GRPC': 'gRPC-Swift', 'CGRPCZlib': 'CGRPCZlib' }[name]
[ "def", "pod_name_for_grpc_target", "(", "self", ",", "name", ")", ":", "return", "{", "'GRPC'", ":", "'gRPC-Swift'", ",", "'CGRPCZlib'", ":", "'CGRPCZlib'", "}", "[", "name", "]" ]
[ 179, 4 ]
[ 184, 15 ]
python
en
['en', 'en', 'en']
True
PodManager.get_package_requirements
(self, package_name)
Returns the lower and upper bound version requirements for a given package dependency.
Returns the lower and upper bound version requirements for a given package dependency.
def get_package_requirements(self, package_name): """ Returns the lower and upper bound version requirements for a given package dependency. """ for dependency in self.package_dump['dependencies']: if dependency['name'] == package_name: # There should ...
[ "def", "get_package_requirements", "(", "self", ",", "package_name", ")", ":", "for", "dependency", "in", "self", ".", "package_dump", "[", "'dependencies'", "]", ":", "if", "dependency", "[", "'name'", "]", "==", "package_name", ":", "# There should only be 1 ran...
[ 187, 4 ]
[ 199, 71 ]
python
en
['en', 'error', 'th']
False
PodManager.get_dependencies
(self, target_name)
Returns a tuple of dependency lists for a given target. The first entry is the list of product dependencies; dependencies on products from other packages. The second entry is a list of target dependencies, i.e. dependencies on other targets within the package.
Returns a tuple of dependency lists for a given target.
def get_dependencies(self, target_name): """ Returns a tuple of dependency lists for a given target. The first entry is the list of product dependencies; dependencies on products from other packages. The second entry is a list of target dependencies, i.e. dependencies on other t...
[ "def", "get_dependencies", "(", "self", ",", "target_name", ")", ":", "for", "target", "in", "self", ".", "package_dump", "[", "'targets'", "]", ":", "if", "target", "[", "'name'", "]", "==", "target_name", ":", "product_dependencies", "=", "set", "(", ")"...
[ 202, 4 ]
[ 226, 73 ]
python
en
['en', 'error', 'th']
False
PodManager.build_dependency_list
(self, target_name)
Returns a list of dependencies for the given target. Dependencies may be either 'TargetDependency' or 'ProductDependency'.
Returns a list of dependencies for the given target.
def build_dependency_list(self, target_name): """ Returns a list of dependencies for the given target. Dependencies may be either 'TargetDependency' or 'ProductDependency'. """ product, target = self.get_dependencies(target_name) dependencies = [] for package_na...
[ "def", "build_dependency_list", "(", "self", ",", "target_name", ")", ":", "product", ",", "target", "=", "self", ".", "get_dependencies", "(", "target_name", ")", "dependencies", "=", "[", "]", "for", "package_name", "in", "product", ":", "(", "lower", ",",...
[ 229, 4 ]
[ 247, 27 ]
python
en
['en', 'error', 'th']
False
TestAutomaticRootPageDetection.test_type_eventpage
(self)
The chooser should start at the EventIndex that holds all the EventPages.
The chooser should start at the EventIndex that holds all the EventPages.
def test_type_eventpage(self): """ The chooser should start at the EventIndex that holds all the EventPages. """ self.assertEqual( self.get_best_root({'page_type': 'tests.EventPage'}), self.event_index)
[ "def", "test_type_eventpage", "(", "self", ")", ":", "self", ".", "assertEqual", "(", "self", ".", "get_best_root", "(", "{", "'page_type'", ":", "'tests.EventPage'", "}", ")", ",", "self", ".", "event_index", ")" ]
[ 458, 4 ]
[ 465, 29 ]
python
en
['en', 'error', 'th']
False
TestAutomaticRootPageDetection.test_type_eventpage_two_indexes
(self)
The chooser should start at the home page, as there are two EventIndexes with EventPages.
The chooser should start at the home page, as there are two EventIndexes with EventPages.
def test_type_eventpage_two_indexes(self): """ The chooser should start at the home page, as there are two EventIndexes with EventPages. """ self.make_event_section('Other events') self.assertEqual( self.get_best_root({'page_type': 'tests.EventPage'}), ...
[ "def", "test_type_eventpage_two_indexes", "(", "self", ")", ":", "self", ".", "make_event_section", "(", "'Other events'", ")", "self", ".", "assertEqual", "(", "self", ".", "get_best_root", "(", "{", "'page_type'", ":", "'tests.EventPage'", "}", ")", ",", "self...
[ 467, 4 ]
[ 475, 27 ]
python
en
['en', 'error', 'th']
False
TestAutomaticRootPageDetection.test_type_simple_page
(self)
The chooser should start at the home page, as all SimplePages are directly under it
The chooser should start at the home page, as all SimplePages are directly under it
def test_type_simple_page(self): """ The chooser should start at the home page, as all SimplePages are directly under it """ self.assertEqual( self.get_best_root({'page_type': 'tests.BusinessIndex'}), self.tree_root)
[ "def", "test_type_simple_page", "(", "self", ")", ":", "self", ".", "assertEqual", "(", "self", ".", "get_best_root", "(", "{", "'page_type'", ":", "'tests.BusinessIndex'", "}", ")", ",", "self", ".", "tree_root", ")" ]
[ 477, 4 ]
[ 484, 27 ]
python
en
['en', 'error', 'th']
False
TestAutomaticRootPageDetection.test_type_missing
(self)
The chooser should start at the root, as there are no BusinessIndexes
The chooser should start at the root, as there are no BusinessIndexes
def test_type_missing(self): """ The chooser should start at the root, as there are no BusinessIndexes """ self.assertEqual( self.get_best_root({'page_type': 'tests.BusinessIndex'}), self.tree_root)
[ "def", "test_type_missing", "(", "self", ")", ":", "self", ".", "assertEqual", "(", "self", ".", "get_best_root", "(", "{", "'page_type'", ":", "'tests.BusinessIndex'", "}", ")", ",", "self", ".", "tree_root", ")" ]
[ 486, 4 ]
[ 492, 27 ]
python
en
['en', 'error', 'th']
False
run_uncertain_random_climate
(gdir, nyears=700, output_filesuffix='', sigma_t=None, sigma_p=None, sigma_smb=None, rdn_temp_bias_seed=None, rdn_prcp_bia...
Test stuff Parameters ---------- gdir nyears output_filesuffix rdn_temp_bias_seed rdn_prcp_bias_seed rdn_bias_seed kwargs Returns -------
Test stuff
def run_uncertain_random_climate(gdir, nyears=700, output_filesuffix='', sigma_t=None, sigma_p=None, sigma_smb=None, rdn_temp_bias_seed=None, ...
[ "def", "run_uncertain_random_climate", "(", "gdir", ",", "nyears", "=", "700", ",", "output_filesuffix", "=", "''", ",", "sigma_t", "=", "None", ",", "sigma_p", "=", "None", ",", "sigma_smb", "=", "None", ",", "rdn_temp_bias_seed", "=", "None", ",", "rdn_prc...
[ 17, 0 ]
[ 88, 39 ]
python
de
['de', 'mt', 'en']
False
connection_requires_http_tunnel
( proxy_url=None, proxy_config=None, destination_scheme=None )
Returns True if the connection requires an HTTP CONNECT through the proxy. :param URL proxy_url: URL of the proxy. :param ProxyConfig proxy_config: Proxy configuration from poolmanager.py :param str destination_scheme: The scheme of the destination. (i.e https, http, etc)
Returns True if the connection requires an HTTP CONNECT through the proxy.
def connection_requires_http_tunnel( proxy_url=None, proxy_config=None, destination_scheme=None ): """ Returns True if the connection requires an HTTP CONNECT through the proxy. :param URL proxy_url: URL of the proxy. :param ProxyConfig proxy_config: Proxy configuration from poolman...
[ "def", "connection_requires_http_tunnel", "(", "proxy_url", "=", "None", ",", "proxy_config", "=", "None", ",", "destination_scheme", "=", "None", ")", ":", "# If we're not using a proxy, no way to use a tunnel.", "if", "proxy_url", "is", "None", ":", "return", "False",...
[ 3, 0 ]
[ 33, 15 ]
python
en
['en', 'error', 'th']
False
create_proxy_ssl_context
( ssl_version, cert_reqs, ca_certs=None, ca_cert_dir=None, ca_cert_data=None )
Generates a default proxy ssl context if one hasn't been provided by the user.
Generates a default proxy ssl context if one hasn't been provided by the user.
def create_proxy_ssl_context( ssl_version, cert_reqs, ca_certs=None, ca_cert_dir=None, ca_cert_data=None ): """ Generates a default proxy ssl context if one hasn't been provided by the user. """ ssl_context = create_urllib3_context( ssl_version=resolve_ssl_version(ssl_version), c...
[ "def", "create_proxy_ssl_context", "(", "ssl_version", ",", "cert_reqs", ",", "ca_certs", "=", "None", ",", "ca_cert_dir", "=", "None", ",", "ca_cert_data", "=", "None", ")", ":", "ssl_context", "=", "create_urllib3_context", "(", "ssl_version", "=", "resolve_ssl_...
[ 36, 0 ]
[ 55, 22 ]
python
en
['en', 'error', 'th']
False
modernize_apns_payload
(data: Dict[str, Any])
Take a payload in an unknown Zulip version's format, and return in current format.
Take a payload in an unknown Zulip version's format, and return in current format.
def modernize_apns_payload(data: Dict[str, Any]) -> Dict[str, Any]: """Take a payload in an unknown Zulip version's format, and return in current format.""" # TODO this isn't super robust as is -- if a buggy remote server # sends a malformed payload, we are likely to raise an exception. if "message_ids"...
[ "def", "modernize_apns_payload", "(", "data", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "# TODO this isn't super robust as is -- if a buggy remote server", "# sends a malformed payload, we are likely to raise an exception...
[ 86, 0 ]
[ 109, 19 ]
python
en
['en', 'en', 'en']
True
parse_gcm_options
(options: Dict[str, Any], data: Dict[str, Any])
Parse GCM options, supplying defaults, and raising an error if invalid. The options permitted here form part of the Zulip notification bouncer's API. They are: `priority`: Passed through to GCM; see upstream doc linked below. Zulip servers should always set this; when unset, we guess a value...
Parse GCM options, supplying defaults, and raising an error if invalid.
def parse_gcm_options(options: Dict[str, Any], data: Dict[str, Any]) -> str: """ Parse GCM options, supplying defaults, and raising an error if invalid. The options permitted here form part of the Zulip notification bouncer's API. They are: `priority`: Passed through to GCM; see upstream doc link...
[ "def", "parse_gcm_options", "(", "options", ":", "Dict", "[", "str", ",", "Any", "]", ",", "data", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "str", ":", "priority", "=", "options", ".", "pop", "(", "\"priority\"", ",", "None", ")", "if",...
[ 245, 0 ]
[ 287, 19 ]
python
en
['en', 'error', 'th']
False
send_android_push_notification
( devices: List[DeviceToken], data: Dict[str, Any], options: Dict[str, Any], remote: bool = False )
Send a GCM message to the given devices. See https://firebase.google.com/docs/cloud-messaging/http-server-ref for the GCM upstream API which this talks to. data: The JSON object (decoded) to send as the 'data' parameter of the GCM message. options: Additional options to control the GCM me...
Send a GCM message to the given devices.
def send_android_push_notification( devices: List[DeviceToken], data: Dict[str, Any], options: Dict[str, Any], remote: bool = False ) -> None: """ Send a GCM message to the given devices. See https://firebase.google.com/docs/cloud-messaging/http-server-ref for the GCM upstream API which this talks ...
[ "def", "send_android_push_notification", "(", "devices", ":", "List", "[", "DeviceToken", "]", ",", "data", ":", "Dict", "[", "str", ",", "Any", "]", ",", "options", ":", "Dict", "[", "str", ",", "Any", "]", ",", "remote", ":", "bool", "=", "False", ...
[ 291, 0 ]
[ 378, 83 ]
python
en
['en', 'error', 'th']
False
push_notifications_enabled
()
True just if this server has configured a way to send push notifications.
True just if this server has configured a way to send push notifications.
def push_notifications_enabled() -> bool: """True just if this server has configured a way to send push notifications.""" if ( uses_notification_bouncer() and settings.ZULIP_ORG_KEY is not None and settings.ZULIP_ORG_ID is not None ): # nocoverage # We have the needed config...
[ "def", "push_notifications_enabled", "(", ")", "->", "bool", ":", "if", "(", "uses_notification_bouncer", "(", ")", "and", "settings", ".", "ZULIP_ORG_KEY", "is", "not", "None", "and", "settings", ".", "ZULIP_ORG_ID", "is", "not", "None", ")", ":", "# nocovera...
[ 517, 0 ]
[ 538, 16 ]
python
en
['en', 'en', 'en']
True
get_gcm_alert
(message: Message)
Determine what alert string to display based on the missed messages.
Determine what alert string to display based on the missed messages.
def get_gcm_alert(message: Message) -> str: """ Determine what alert string to display based on the missed messages. """ sender_str = message.sender.full_name if message.recipient.type == Recipient.HUDDLE and message.trigger == "private_message": return f"New private group message from {send...
[ "def", "get_gcm_alert", "(", "message", ":", "Message", ")", "->", "str", ":", "sender_str", "=", "message", ".", "sender", ".", "full_name", "if", "message", ".", "recipient", ".", "type", "==", "Recipient", ".", "HUDDLE", "and", "message", ".", "trigger"...
[ 553, 0 ]
[ 567, 100 ]
python
en
['en', 'error', 'th']
False
get_base_payload
(user_profile: UserProfile)
Common fields for all notification payloads.
Common fields for all notification payloads.
def get_base_payload(user_profile: UserProfile) -> Dict[str, Any]: """Common fields for all notification payloads.""" data: Dict[str, Any] = {} # These will let the app support logging into multiple realms and servers. data["server"] = settings.EXTERNAL_HOST data["realm_id"] = user_profile.realm.id...
[ "def", "get_base_payload", "(", "user_profile", ":", "UserProfile", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "data", ":", "Dict", "[", "str", ",", "Any", "]", "=", "{", "}", "# These will let the app support logging into multiple realms and servers.", ...
[ 648, 0 ]
[ 658, 15 ]
python
en
['en', 'en', 'en']
True
get_message_payload
(user_profile: UserProfile, message: Message)
Common fields for `message` payloads, for all platforms.
Common fields for `message` payloads, for all platforms.
def get_message_payload(user_profile: UserProfile, message: Message) -> Dict[str, Any]: """Common fields for `message` payloads, for all platforms.""" data = get_base_payload(user_profile) # `sender_id` is preferred, but some existing versions use `sender_email`. data["sender_id"] = message.sender.id ...
[ "def", "get_message_payload", "(", "user_profile", ":", "UserProfile", ",", "message", ":", "Message", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "data", "=", "get_base_payload", "(", "user_profile", ")", "# `sender_id` is preferred, but some existing vers...
[ 661, 0 ]
[ 679, 15 ]
python
en
['en', 'en', 'en']
True
get_apns_alert_title
(message: Message)
On an iOS notification, this is the first bolded line.
On an iOS notification, this is the first bolded line.
def get_apns_alert_title(message: Message) -> str: """ On an iOS notification, this is the first bolded line. """ if message.recipient.type == Recipient.HUDDLE: recipients = get_display_recipient(message.recipient) assert isinstance(recipients, list) return ", ".join(sorted(r["fu...
[ "def", "get_apns_alert_title", "(", "message", ":", "Message", ")", "->", "str", ":", "if", "message", ".", "recipient", ".", "type", "==", "Recipient", ".", "HUDDLE", ":", "recipients", "=", "get_display_recipient", "(", "message", ".", "recipient", ")", "a...
[ 682, 0 ]
[ 693, 35 ]
python
en
['en', 'error', 'th']
False
get_apns_alert_subtitle
(message: Message)
On an iOS notification, this is the second bolded line.
On an iOS notification, this is the second bolded line.
def get_apns_alert_subtitle(message: Message) -> str: """ On an iOS notification, this is the second bolded line. """ if message.trigger == "mentioned": return _("{full_name} mentioned you:").format(full_name=message.sender.full_name) elif message.trigger == "wildcard_mentioned": ret...
[ "def", "get_apns_alert_subtitle", "(", "message", ":", "Message", ")", "->", "str", ":", "if", "message", ".", "trigger", "==", "\"mentioned\"", ":", "return", "_", "(", "\"{full_name} mentioned you:\"", ")", ".", "format", "(", "full_name", "=", "message", "....
[ 696, 0 ]
[ 707, 41 ]
python
en
['en', 'error', 'th']
False
get_message_payload_apns
(user_profile: UserProfile, message: Message)
A `message` payload for iOS, via APNs.
A `message` payload for iOS, via APNs.
def get_message_payload_apns(user_profile: UserProfile, message: Message) -> Dict[str, Any]: """A `message` payload for iOS, via APNs.""" zulip_data = get_message_payload(user_profile, message) zulip_data.update( message_ids=[message.id], ) assert message.rendered_content is not None co...
[ "def", "get_message_payload_apns", "(", "user_profile", ":", "UserProfile", ",", "message", ":", "Message", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "zulip_data", "=", "get_message_payload", "(", "user_profile", ",", "message", ")", "zulip_data", "...
[ 738, 0 ]
[ 757, 20 ]
python
en
['en', 'en', 'en']
True
get_message_payload_gcm
( user_profile: UserProfile, message: Message, )
A `message` payload + options, for Android via GCM/FCM.
A `message` payload + options, for Android via GCM/FCM.
def get_message_payload_gcm( user_profile: UserProfile, message: Message, ) -> Tuple[Dict[str, Any], Dict[str, Any]]: """A `message` payload + options, for Android via GCM/FCM.""" data = get_message_payload(user_profile, message) assert message.rendered_content is not None content, truncated = t...
[ "def", "get_message_payload_gcm", "(", "user_profile", ":", "UserProfile", ",", "message", ":", "Message", ",", ")", "->", "Tuple", "[", "Dict", "[", "str", ",", "Any", "]", ",", "Dict", "[", "str", ",", "Any", "]", "]", ":", "data", "=", "get_message_...
[ 760, 0 ]
[ 779, 28 ]
python
en
['en', 'en', 'en']
True
get_remove_payload_gcm
( user_profile: UserProfile, message_ids: List[int], )
A `remove` payload + options, for Android via GCM/FCM.
A `remove` payload + options, for Android via GCM/FCM.
def get_remove_payload_gcm( user_profile: UserProfile, message_ids: List[int], ) -> Tuple[Dict[str, Any], Dict[str, Any]]: """A `remove` payload + options, for Android via GCM/FCM.""" gcm_payload = get_base_payload(user_profile) gcm_payload.update( event="remove", zulip_message_ids="...
[ "def", "get_remove_payload_gcm", "(", "user_profile", ":", "UserProfile", ",", "message_ids", ":", "List", "[", "int", "]", ",", ")", "->", "Tuple", "[", "Dict", "[", "str", ",", "Any", "]", ",", "Dict", "[", "str", ",", "Any", "]", "]", ":", "gcm_pa...
[ 782, 0 ]
[ 796, 35 ]
python
en
['en', 'en', 'en']
True
handle_remove_push_notification
(user_profile_id: int, message_ids: List[int])
This should be called when a message that previously had a mobile push notification executed is read. This triggers a push to the mobile app, when the message is read on the server, to remove the message from the notification.
This should be called when a message that previously had a mobile push notification executed is read. This triggers a push to the mobile app, when the message is read on the server, to remove the message from the notification.
def handle_remove_push_notification(user_profile_id: int, message_ids: List[int]) -> None: """This should be called when a message that previously had a mobile push notification executed is read. This triggers a push to the mobile app, when the message is read on the server, to remove the message from ...
[ "def", "handle_remove_push_notification", "(", "user_profile_id", ":", "int", ",", "message_ids", ":", "List", "[", "int", "]", ")", "->", "None", ":", "user_profile", "=", "get_user_profile_by_id", "(", "user_profile_id", ")", "message_ids", "=", "bulk_access_messa...
[ 812, 0 ]
[ 840, 89 ]
python
en
['en', 'en', 'en']
True
handle_push_notification
(user_profile_id: int, missed_message: Dict[str, Any])
missed_message is the event received by the zerver.worker.queue_processors.PushNotificationWorker.consume function.
missed_message is the event received by the zerver.worker.queue_processors.PushNotificationWorker.consume function.
def handle_push_notification(user_profile_id: int, missed_message: Dict[str, Any]) -> None: """ missed_message is the event received by the zerver.worker.queue_processors.PushNotificationWorker.consume function. """ if not push_notifications_enabled(): return user_profile = get_user_prof...
[ "def", "handle_push_notification", "(", "user_profile_id", ":", "int", ",", "missed_message", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "None", ":", "if", "not", "push_notifications_enabled", "(", ")", ":", "return", "user_profile", "=", "get_user_p...
[ 844, 0 ]
[ 919, 77 ]
python
en
['en', 'error', 'th']
False
raise_option_error
(parser, option, msg)
Raise an option parsing error using parser.error(). Args: parser: an OptionParser instance. option: an Option instance. msg: the error text.
Raise an option parsing error using parser.error().
def raise_option_error(parser, option, msg): # type: (OptionParser, Option, str) -> None """ Raise an option parsing error using parser.error(). Args: parser: an OptionParser instance. option: an Option instance. msg: the error text. """ msg = '{} error: {}'.format(option, msg...
[ "def", "raise_option_error", "(", "parser", ",", "option", ",", "msg", ")", ":", "# type: (OptionParser, Option, str) -> None", "msg", "=", "'{} error: {}'", ".", "format", "(", "option", ",", "msg", ")", "msg", "=", "textwrap", ".", "fill", "(", "' '", ".", ...
[ 40, 0 ]
[ 52, 21 ]
python
en
['en', 'error', 'th']
False
make_option_group
(group, parser)
Return an OptionGroup object group -- assumed to be dict with 'name' and 'options' keys parser -- an optparse Parser
Return an OptionGroup object group -- assumed to be dict with 'name' and 'options' keys parser -- an optparse Parser
def make_option_group(group, parser): # type: (Dict[str, Any], ConfigOptionParser) -> OptionGroup """ Return an OptionGroup object group -- assumed to be dict with 'name' and 'options' keys parser -- an optparse Parser """ option_group = OptionGroup(parser, group['name']) for option in ...
[ "def", "make_option_group", "(", "group", ",", "parser", ")", ":", "# type: (Dict[str, Any], ConfigOptionParser) -> OptionGroup", "option_group", "=", "OptionGroup", "(", "parser", ",", "group", "[", "'name'", "]", ")", "for", "option", "in", "group", "[", "'options...
[ 55, 0 ]
[ 65, 23 ]
python
en
['en', 'error', 'th']
False
check_install_build_global
(options, check_options=None)
Disable wheels if per-setup.py call options are set. :param options: The OptionParser options to update. :param check_options: The options to check, if not supplied defaults to options.
Disable wheels if per-setup.py call options are set.
def check_install_build_global(options, check_options=None): # type: (Values, Optional[Values]) -> None """Disable wheels if per-setup.py call options are set. :param options: The OptionParser options to update. :param check_options: The options to check, if not supplied defaults to options. ...
[ "def", "check_install_build_global", "(", "options", ",", "check_options", "=", "None", ")", ":", "# type: (Values, Optional[Values]) -> None", "if", "check_options", "is", "None", ":", "check_options", "=", "options", "def", "getname", "(", "n", ")", ":", "# type: ...
[ 68, 0 ]
[ 89, 9 ]
python
en
['en', 'en', 'en']
True
check_dist_restriction
(options, check_target=False)
Function for determining if custom platform options are allowed. :param options: The OptionParser options. :param check_target: Whether or not to check if --target is being used.
Function for determining if custom platform options are allowed.
def check_dist_restriction(options, check_target=False): # type: (Values, bool) -> None """Function for determining if custom platform options are allowed. :param options: The OptionParser options. :param check_target: Whether or not to check if --target is being used. """ dist_restriction_set ...
[ "def", "check_dist_restriction", "(", "options", ",", "check_target", "=", "False", ")", ":", "# type: (Values, bool) -> None", "dist_restriction_set", "=", "any", "(", "[", "options", ".", "python_version", ",", "options", ".", "platforms", ",", "options", ".", "...
[ 92, 0 ]
[ 129, 13 ]
python
en
['en', 'en', 'en']
True
_get_format_control
(values, option)
Get a format_control object.
Get a format_control object.
def _get_format_control(values, option): # type: (Values, Option) -> Any """Get a format_control object.""" return getattr(values, option.dest)
[ "def", "_get_format_control", "(", "values", ",", "option", ")", ":", "# type: (Values, Option) -> Any", "return", "getattr", "(", "values", ",", "option", ".", "dest", ")" ]
[ 446, 0 ]
[ 449, 39 ]
python
en
['en', 'en', 'en']
True
_convert_python_version
(value)
Convert a version string like "3", "37", or "3.7.3" into a tuple of ints. :return: A 2-tuple (version_info, error_msg), where `error_msg` is non-None if and only if there was a parsing error.
Convert a version string like "3", "37", or "3.7.3" into a tuple of ints.
def _convert_python_version(value): # type: (str) -> Tuple[Tuple[int, ...], Optional[str]] """ Convert a version string like "3", "37", or "3.7.3" into a tuple of ints. :return: A 2-tuple (version_info, error_msg), where `error_msg` is non-None if and only if there was a parsing error. """ ...
[ "def", "_convert_python_version", "(", "value", ")", ":", "# type: (str) -> Tuple[Tuple[int, ...], Optional[str]]", "if", "not", "value", ":", "# The empty string is the same as not providing a value.", "return", "(", "None", ",", "None", ")", "parts", "=", "value", ".", ...
[ 514, 0 ]
[ 541, 31 ]
python
en
['en', 'error', 'th']
False
_handle_python_version
(option, opt_str, value, parser)
Handle a provided --python-version value.
Handle a provided --python-version value.
def _handle_python_version(option, opt_str, value, parser): # type: (Option, str, str, OptionParser) -> None """ Handle a provided --python-version value. """ version_info, error_msg = _convert_python_version(value) if error_msg is not None: msg = ( 'invalid --python-version ...
[ "def", "_handle_python_version", "(", "option", ",", "opt_str", ",", "value", ",", "parser", ")", ":", "# type: (Option, str, str, OptionParser) -> None", "version_info", ",", "error_msg", "=", "_convert_python_version", "(", "value", ")", "if", "error_msg", "is", "no...
[ 544, 0 ]
[ 558, 47 ]
python
en
['en', 'error', 'th']
False
_handle_no_cache_dir
(option, opt, value, parser)
Process a value provided for the --no-cache-dir option. This is an optparse.Option callback for the --no-cache-dir option.
Process a value provided for the --no-cache-dir option.
def _handle_no_cache_dir(option, opt, value, parser): # type: (Option, str, str, OptionParser) -> None """ Process a value provided for the --no-cache-dir option. This is an optparse.Option callback for the --no-cache-dir option. """ # The value argument will be None if --no-cache-dir is passed...
[ "def", "_handle_no_cache_dir", "(", "option", ",", "opt", ",", "value", ",", "parser", ")", ":", "# type: (Option, str, str, OptionParser) -> None", "# The value argument will be None if --no-cache-dir is passed via the", "# command-line, since the option doesn't accept arguments. Howev...
[ 651, 0 ]
[ 676, 35 ]
python
en
['en', 'error', 'th']
False
_handle_no_use_pep517
(option, opt, value, parser)
Process a value provided for the --no-use-pep517 option. This is an optparse.Option callback for the no_use_pep517 option.
Process a value provided for the --no-use-pep517 option.
def _handle_no_use_pep517(option, opt, value, parser): # type: (Option, str, str, OptionParser) -> None """ Process a value provided for the --no-use-pep517 option. This is an optparse.Option callback for the no_use_pep517 option. """ # Since --no-use-pep517 doesn't accept arguments, the value ...
[ "def", "_handle_no_use_pep517", "(", "option", ",", "opt", ",", "value", ",", "parser", ")", ":", "# type: (Option, str, str, OptionParser) -> None", "# Since --no-use-pep517 doesn't accept arguments, the value argument", "# will be None if --no-use-pep517 is passed via the command-line....
[ 726, 0 ]
[ 747, 36 ]
python
en
['en', 'error', 'th']
False
_handle_merge_hash
(option, opt_str, value, parser)
Given a value spelled "algo:digest", append the digest to a list pointed to in a dict by the algo name.
Given a value spelled "algo:digest", append the digest to a list pointed to in a dict by the algo name.
def _handle_merge_hash(option, opt_str, value, parser): # type: (Option, str, str, OptionParser) -> None """Given a value spelled "algo:digest", append the digest to a list pointed to in a dict by the algo name.""" if not parser.values.hashes: parser.values.hashes = {} try: algo, dig...
[ "def", "_handle_merge_hash", "(", "option", ",", "opt_str", ",", "value", ",", "parser", ")", ":", "# type: (Option, str, str, OptionParser) -> None", "if", "not", "parser", ".", "values", ".", "hashes", ":", "parser", ".", "values", ".", "hashes", "=", "{", "...
[ 821, 0 ]
[ 836, 60 ]
python
en
['en', 'en', 'en']
True
set_histalp_url
(url)
If you want to use a different server for HISTALP (for testing, etc).
If you want to use a different server for HISTALP (for testing, etc).
def set_histalp_url(url): """If you want to use a different server for HISTALP (for testing, etc).""" global HISTALP_SERVER HISTALP_SERVER = url
[ "def", "set_histalp_url", "(", "url", ")", ":", "global", "HISTALP_SERVER", "HISTALP_SERVER", "=", "url" ]
[ 26, 0 ]
[ 29, 24 ]
python
en
['en', 'en', 'en']
True
get_histalp_file
(var=None)
Returns a path to the desired HISTALP baseline climate file. If the file is not present, download it. Parameters ---------- var : str 'tmp' for temperature 'pre' for precipitation Returns ------- str path to the file
Returns a path to the desired HISTALP baseline climate file.
def get_histalp_file(var=None): """Returns a path to the desired HISTALP baseline climate file. If the file is not present, download it. Parameters ---------- var : str 'tmp' for temperature 'pre' for precipitation Returns ------- str path to the file """ ...
[ "def", "get_histalp_file", "(", "var", "=", "None", ")", ":", "# Be sure input makes sense", "if", "var", "not", "in", "[", "'tmp'", ",", "'pre'", "]", ":", "raise", "InvalidParamsError", "(", "'HISTALP variable {} '", "'does not exist!'", ".", "format", "(", "v...
[ 33, 0 ]
[ 62, 61 ]
python
en
['en', 'en', 'en']
True
process_histalp_data
(gdir, y0=None, y1=None, output_filesuffix=None)
Processes and writes the HISTALP baseline climate data for this glacier. Extracts the nearest timeseries and writes everything to a NetCDF file. Parameters ---------- gdir : :py:class:`oggm.GlacierDirectory` the glacier directory to process y0 : int the starting year of the timeser...
Processes and writes the HISTALP baseline climate data for this glacier.
def process_histalp_data(gdir, y0=None, y1=None, output_filesuffix=None): """Processes and writes the HISTALP baseline climate data for this glacier. Extracts the nearest timeseries and writes everything to a NetCDF file. Parameters ---------- gdir : :py:class:`oggm.GlacierDirectory` the g...
[ "def", "process_histalp_data", "(", "gdir", ",", "y0", "=", "None", ",", "y1", "=", "None", ",", "output_filesuffix", "=", "None", ")", ":", "if", "cfg", ".", "PARAMS", "[", "'baseline_climate'", "]", "!=", "'HISTALP'", ":", "raise", "InvalidParamsError", ...
[ 66, 0 ]
[ 174, 50 ]
python
en
['en', 'en', 'en']
True
get_keyring_auth
(url, username)
Return the tuple auth for a given url from keyring.
Return the tuple auth for a given url from keyring.
def get_keyring_auth(url, username): # type: (str, str) -> Optional[AuthInfo] """Return the tuple auth for a given url from keyring.""" global keyring if not url or not keyring: return None try: try: get_credential = keyring.get_credential except AttributeError: ...
[ "def", "get_keyring_auth", "(", "url", ",", "username", ")", ":", "# type: (str, str) -> Optional[AuthInfo]", "global", "keyring", "if", "not", "url", "or", "not", "keyring", ":", "return", "None", "try", ":", "try", ":", "get_credential", "=", "keyring", ".", ...
[ 43, 0 ]
[ 73, 15 ]
python
en
['en', 'en', 'en']
True
MultiDomainBasicAuth._get_index_url
(self, url)
Return the original index URL matching the requested URL. Cached or dynamically generated credentials may work against the original index URL rather than just the netloc. The provided url should have had its username and password removed already. If the original index url had credentia...
Return the original index URL matching the requested URL.
def _get_index_url(self, url): # type: (str) -> Optional[str] """Return the original index URL matching the requested URL. Cached or dynamically generated credentials may work against the original index URL rather than just the netloc. The provided url should have had its usern...
[ "def", "_get_index_url", "(", "self", ",", "url", ")", ":", "# type: (str) -> Optional[str]", "if", "not", "url", "or", "not", "self", ".", "index_urls", ":", "return", "None", "for", "u", "in", "self", ".", "index_urls", ":", "prefix", "=", "remove_auth_fro...
[ 90, 4 ]
[ 111, 19 ]
python
en
['en', 'en', 'en']
True
MultiDomainBasicAuth._get_new_credentials
(self, original_url, allow_netrc=True, allow_keyring=True)
Find and return credentials for the specified URL.
Find and return credentials for the specified URL.
def _get_new_credentials(self, original_url, allow_netrc=True, allow_keyring=True): # type: (str, bool, bool) -> AuthInfo """Find and return credentials for the specified URL.""" # Split the credentials and netloc from the url. url, netloc, url_user_password ...
[ "def", "_get_new_credentials", "(", "self", ",", "original_url", ",", "allow_netrc", "=", "True", ",", "allow_keyring", "=", "True", ")", ":", "# type: (str, bool, bool) -> AuthInfo", "# Split the credentials and netloc from the url.", "url", ",", "netloc", ",", "url_user...
[ 113, 4 ]
[ 162, 33 ]
python
en
['en', 'en', 'en']
True
MultiDomainBasicAuth._get_url_and_credentials
(self, original_url)
Return the credentials to use for the provided URL. If allowed, netrc and keyring may be used to obtain the correct credentials. Returns (url_without_credentials, username, password). Note that even if the original URL contains credentials, this function may return a different ...
Return the credentials to use for the provided URL.
def _get_url_and_credentials(self, original_url): # type: (str) -> Tuple[str, Optional[str], Optional[str]] """Return the credentials to use for the provided URL. If allowed, netrc and keyring may be used to obtain the correct credentials. Returns (url_without_credentials, user...
[ "def", "_get_url_and_credentials", "(", "self", ",", "original_url", ")", ":", "# type: (str) -> Tuple[str, Optional[str], Optional[str]]", "url", ",", "netloc", ",", "_", "=", "split_auth_netloc_from_url", "(", "original_url", ")", "# Use any stored credentials that we have fo...
[ 164, 4 ]
[ 203, 38 ]
python
en
['en', 'en', 'en']
True
MultiDomainBasicAuth.warn_on_401
(self, resp, **kwargs)
Response callback to warn about incorrect credentials.
Response callback to warn about incorrect credentials.
def warn_on_401(self, resp, **kwargs): # type: (Response, **Any) -> None """Response callback to warn about incorrect credentials.""" if resp.status_code == 401: logger.warning( '401 Error, Credentials not correct for %s', resp.request.url, )
[ "def", "warn_on_401", "(", "self", ",", "resp", ",", "*", "*", "kwargs", ")", ":", "# type: (Response, **Any) -> None", "if", "resp", ".", "status_code", "==", "401", ":", "logger", ".", "warning", "(", "'401 Error, Credentials not correct for %s'", ",", "resp", ...
[ 287, 4 ]
[ 293, 13 ]
python
en
['en', 'en', 'en']
True
MultiDomainBasicAuth.save_credentials
(self, resp, **kwargs)
Response callback to save credentials on success.
Response callback to save credentials on success.
def save_credentials(self, resp, **kwargs): # type: (Response, **Any) -> None """Response callback to save credentials on success.""" assert keyring is not None, "should never reach here without keyring" if not keyring: return creds = self._credentials_to_save ...
[ "def", "save_credentials", "(", "self", ",", "resp", ",", "*", "*", "kwargs", ")", ":", "# type: (Response, **Any) -> None", "assert", "keyring", "is", "not", "None", ",", "\"should never reach here without keyring\"", "if", "not", "keyring", ":", "return", "creds",...
[ 295, 4 ]
[ 309, 62 ]
python
en
['en', 'en', 'en']
True
get_major_minor_version
()
Return the major-minor version of the current Python as a string, e.g. "3.7" or "3.10".
Return the major-minor version of the current Python as a string, e.g. "3.7" or "3.10".
def get_major_minor_version(): # type: () -> str """ Return the major-minor version of the current Python as a string, e.g. "3.7" or "3.10". """ return '{}.{}'.format(*sys.version_info)
[ "def", "get_major_minor_version", "(", ")", ":", "# type: () -> str", "return", "'{}.{}'", ".", "format", "(", "*", "sys", ".", "version_info", ")" ]
[ 32, 0 ]
[ 38, 44 ]
python
en
['en', 'error', 'th']
False
distutils_scheme
( dist_name, user=False, home=None, root=None, isolated=False, prefix=None )
Return a distutils install scheme
Return a distutils install scheme
def distutils_scheme( dist_name, user=False, home=None, root=None, isolated=False, prefix=None ): # type:(str, bool, str, str, bool, str) -> Dict[str, str] """ Return a distutils install scheme """ from distutils.dist import Distribution dist_args = {'name': dist_name} # type: Dict[str, Un...
[ "def", "distutils_scheme", "(", "dist_name", ",", "user", "=", "False", ",", "home", "=", "None", ",", "root", "=", "None", ",", "isolated", "=", "False", ",", "prefix", "=", "None", ")", ":", "# type:(str, bool, str, str, bool, str) -> Dict[str, str]", "from", ...
[ 93, 0 ]
[ 154, 17 ]
python
en
['en', 'error', 'th']
False
get_scheme
( dist_name, # type: str user=False, # type: bool home=None, # type: Optional[str] root=None, # type: Optional[str] isolated=False, # type: bool prefix=None, # type: Optional[str] )
Get the "scheme" corresponding to the input parameters. The distutils documentation provides the context for the available schemes: https://docs.python.org/3/install/index.html#alternate-installation :param dist_name: the name of the package to retrieve the scheme for, used in the headers sche...
Get the "scheme" corresponding to the input parameters. The distutils documentation provides the context for the available schemes: https://docs.python.org/3/install/index.html#alternate-installation
def get_scheme( dist_name, # type: str user=False, # type: bool home=None, # type: Optional[str] root=None, # type: Optional[str] isolated=False, # type: bool prefix=None, # type: Optional[str] ): # type: (...) -> Scheme """ Get the "scheme" corresponding to the input parameter...
[ "def", "get_scheme", "(", "dist_name", ",", "# type: str", "user", "=", "False", ",", "# type: bool", "home", "=", "None", ",", "# type: Optional[str]", "root", "=", "None", ",", "# type: Optional[str]", "isolated", "=", "False", ",", "# type: bool", "prefix", "...
[ 157, 0 ]
[ 192, 5 ]
python
en
['en', 'error', 'th']
False
PCADiscretizedProjections.__init__
(self, hash_name, projection_count, training_set, bin_width)
Computes principal components for training vector set. Uses first projection_count principal components for projections. Training set must be either a numpy matrix or a list of numpy vectors.
Computes principal components for training vector set. Uses first projection_count principal components for projections.
def __init__(self, hash_name, projection_count, training_set, bin_width): """ Computes principal components for training vector set. Uses first projection_count principal components for projections. Training set must be either a numpy matrix or a list of numpy vectors. "...
[ "def", "__init__", "(", "self", ",", "hash_name", ",", "projection_count", ",", "training_set", ",", "bin_width", ")", ":", "super", "(", "PCADiscretizedProjections", ",", "self", ")", ".", "__init__", "(", "hash_name", ")", "self", ".", "projection_count", "=...
[ 37, 4 ]
[ 80, 34 ]
python
en
['en', 'error', 'th']
False
PCADiscretizedProjections.reset
(self, dim)
Resets / Initializes the hash for the specified dimension.
Resets / Initializes the hash for the specified dimension.
def reset(self, dim): """ Resets / Initializes the hash for the specified dimension. """ if self.dim != dim: raise Exception('PCA hash is trained for specific dimension!')
[ "def", "reset", "(", "self", ",", "dim", ")", ":", "if", "self", ".", "dim", "!=", "dim", ":", "raise", "Exception", "(", "'PCA hash is trained for specific dimension!'", ")" ]
[ 82, 4 ]
[ 85, 74 ]
python
en
['en', 'en', 'en']
True
PCADiscretizedProjections.hash_vector
(self, v, querying=False)
Hashes the vector and returns the binary bucket key as string.
Hashes the vector and returns the binary bucket key as string.
def hash_vector(self, v, querying=False): """ Hashes the vector and returns the binary bucket key as string. """ if scipy.sparse.issparse(v): # If vector is sparse, make sure we have the CSR representation # of the projection matrix if self.components_...
[ "def", "hash_vector", "(", "self", ",", "v", ",", "querying", "=", "False", ")", ":", "if", "scipy", ".", "sparse", ".", "issparse", "(", "v", ")", ":", "# If vector is sparse, make sure we have the CSR representation", "# of the projection matrix", "if", "self", ...
[ 87, 4 ]
[ 106, 60 ]
python
en
['en', 'error', 'th']
False
PCADiscretizedProjections.get_config
(self)
Returns pickle-serializable configuration struct for storage.
Returns pickle-serializable configuration struct for storage.
def get_config(self): """ Returns pickle-serializable configuration struct for storage. """ # Fill this dict with config data return { 'hash_name': self.hash_name, 'dim': self.dim, 'bin_width': self.bin_width, 'projection_count': se...
[ "def", "get_config", "(", "self", ")", ":", "# Fill this dict with config data", "return", "{", "'hash_name'", ":", "self", ".", "hash_name", ",", "'dim'", ":", "self", ".", "dim", ",", "'bin_width'", ":", "self", ".", "bin_width", ",", "'projection_count'", "...
[ 108, 4 ]
[ 119, 9 ]
python
en
['en', 'error', 'th']
False
PCADiscretizedProjections.apply_config
(self, config)
Applies config
Applies config
def apply_config(self, config): """ Applies config """ self.hash_name = config['hash_name'] self.dim = config['dim'] self.bin_width = config['bin_width'] self.projection_count = config['projection_count'] self.components = config['components']
[ "def", "apply_config", "(", "self", ",", "config", ")", ":", "self", ".", "hash_name", "=", "config", "[", "'hash_name'", "]", "self", ".", "dim", "=", "config", "[", "'dim'", "]", "self", ".", "bin_width", "=", "config", "[", "'bin_width'", "]", "self...
[ 121, 4 ]
[ 129, 46 ]
python
en
['en', 'error', 'th']
False
is_ha_environment
()
Return True if this is an HA environment, and False otherwise.
Return True if this is an HA environment, and False otherwise.
def is_ha_environment(): """Return True if this is an HA environment, and False otherwise. """ # If there are two or more instances, then we are in an HA environment. if Instance.objects.count() > 1: return True return False
[ "def", "is_ha_environment", "(", ")", ":", "# If there are two or more instances, then we are in an HA environment.", "if", "Instance", ".", "objects", ".", "count", "(", ")", ">", "1", ":", "return", "True", "return", "False" ]
[ 7, 0 ]
[ 14, 16 ]
python
en
['en', 'en', 'en']
True
glibc_version_string
()
Returns glibc version string, or None if not using glibc.
Returns glibc version string, or None if not using glibc.
def glibc_version_string(): # type: () -> Optional[str] "Returns glibc version string, or None if not using glibc." return glibc_version_string_confstr() or glibc_version_string_ctypes()
[ "def", "glibc_version_string", "(", ")", ":", "# type: () -> Optional[str]", "return", "glibc_version_string_confstr", "(", ")", "or", "glibc_version_string_ctypes", "(", ")" ]
[ 14, 0 ]
[ 17, 74 ]
python
en
['en', 'en', 'en']
True
glibc_version_string_confstr
()
Primary implementation of glibc_version_string using os.confstr.
Primary implementation of glibc_version_string using os.confstr.
def glibc_version_string_confstr(): # type: () -> Optional[str] "Primary implementation of glibc_version_string using os.confstr." # os.confstr is quite a bit faster than ctypes.DLL. It's also less likely # to be broken or missing. This strategy is used in the standard library # platform module: ...
[ "def", "glibc_version_string_confstr", "(", ")", ":", "# type: () -> Optional[str]", "# os.confstr is quite a bit faster than ctypes.DLL. It's also less likely", "# to be broken or missing. This strategy is used in the standard library", "# platform module:", "# https://github.com/python/cpython/b...
[ 20, 0 ]
[ 35, 18 ]
python
en
['en', 'en', 'en']
True
glibc_version_string_ctypes
()
Fallback implementation of glibc_version_string using ctypes.
Fallback implementation of glibc_version_string using ctypes.
def glibc_version_string_ctypes(): # type: () -> Optional[str] "Fallback implementation of glibc_version_string using ctypes." try: import ctypes except ImportError: return None # ctypes.CDLL(None) internally calls dlopen(NULL), and as the dlopen # manpage says, "If filename is...
[ "def", "glibc_version_string_ctypes", "(", ")", ":", "# type: () -> Optional[str]", "try", ":", "import", "ctypes", "except", "ImportError", ":", "return", "None", "# ctypes.CDLL(None) internally calls dlopen(NULL), and as the dlopen", "# manpage says, \"If filename is NULL, then the...
[ 38, 0 ]
[ 66, 22 ]
python
en
['en', 'en', 'en']
True
libc_ver
()
Try to determine the glibc version Returns a tuple of strings (lib, version) which default to empty strings in case the lookup fails.
Try to determine the glibc version
def libc_ver(): # type: () -> Tuple[str, str] """Try to determine the glibc version Returns a tuple of strings (lib, version) which default to empty strings in case the lookup fails. """ glibc_version = glibc_version_string() if glibc_version is None: return ("", "") else: ...
[ "def", "libc_ver", "(", ")", ":", "# type: () -> Tuple[str, str]", "glibc_version", "=", "glibc_version_string", "(", ")", "if", "glibc_version", "is", "None", ":", "return", "(", "\"\"", ",", "\"\"", ")", "else", ":", "return", "(", "\"glibc\"", ",", "glibc_v...
[ 86, 0 ]
[ 97, 39 ]
python
en
['en', 'en', 'en']
True
register_handler
(handler)
Install application-specific HDF5 image handler. :param handler: Handler object.
Install application-specific HDF5 image handler.
def register_handler(handler): """ Install application-specific HDF5 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
test_unified_template_field_consistency
()
Example of what is being tested: The endpoints /projects/N/ and /projects/ should have the same fields as that same project when it is serialized by the unified job template serializer in /unified_job_templates/
Example of what is being tested: The endpoints /projects/N/ and /projects/ should have the same fields as that same project when it is serialized by the unified job template serializer in /unified_job_templates/
def test_unified_template_field_consistency(): """ Example of what is being tested: The endpoints /projects/N/ and /projects/ should have the same fields as that same project when it is serialized by the unified job template serializer in /unified_job_templates/ """ for cls in UnifiedJobTemp...
[ "def", "test_unified_template_field_consistency", "(", ")", ":", "for", "cls", "in", "UnifiedJobTemplate", ".", "__subclasses__", "(", ")", ":", "detail_serializer", "=", "getattr", "(", "serializers", ",", "'{}Serializer'", ".", "format", "(", "cls", ".", "__name...
[ 8, 0 ]
[ 18, 96 ]
python
en
['en', 'error', 'th']
False
test_unified_job_list_field_consistency
()
Example of what is being tested: The endpoint /project_updates/ should have the same fields as that project update when it is serialized by the unified job template serializer in /unified_jobs/
Example of what is being tested: The endpoint /project_updates/ should have the same fields as that project update when it is serialized by the unified job template serializer in /unified_jobs/
def test_unified_job_list_field_consistency(): """ Example of what is being tested: The endpoint /project_updates/ should have the same fields as that project update when it is serialized by the unified job template serializer in /unified_jobs/ """ for cls in UnifiedJob.__subclasses__(): ...
[ "def", "test_unified_job_list_field_consistency", "(", ")", ":", "for", "cls", "in", "UnifiedJob", ".", "__subclasses__", "(", ")", ":", "list_serializer", "=", "getattr", "(", "serializers", ",", "'{}ListSerializer'", ".", "format", "(", "cls", ".", "__name__", ...
[ 21, 0 ]
[ 33, 86 ]
python
en
['en', 'error', 'th']
False
test_unified_job_detail_exclusive_fields
()
For each type, assert that the only fields allowed to be exclusive to detail view are the allowed types
For each type, assert that the only fields allowed to be exclusive to detail view are the allowed types
def test_unified_job_detail_exclusive_fields(): """ For each type, assert that the only fields allowed to be exclusive to detail view are the allowed types """ allowed_detail_fields = frozenset(('result_traceback', 'job_args', 'job_cwd', 'job_env', 'event_processing_finished')) for cls in Unifie...
[ "def", "test_unified_job_detail_exclusive_fields", "(", ")", ":", "allowed_detail_fields", "=", "frozenset", "(", "(", "'result_traceback'", ",", "'job_args'", ",", "'job_cwd'", ",", "'job_env'", ",", "'event_processing_finished'", ")", ")", "for", "cls", "in", "Unifi...
[ 36, 0 ]
[ 47, 103 ]
python
en
['en', 'error', 'th']
False
test_list_views_use_list_serializers
(all_views)
Check that the list serializers are only used for list views, and vice versa
Check that the list serializers are only used for list views, and vice versa
def test_list_views_use_list_serializers(all_views): """ Check that the list serializers are only used for list views, and vice versa """ list_serializers = tuple(getattr(serializers, '{}ListSerializer'.format(cls.__name__)) for cls in (UnifiedJob.__subclasses__() + [UnifiedJob])) for View in al...
[ "def", "test_list_views_use_list_serializers", "(", "all_views", ")", ":", "list_serializers", "=", "tuple", "(", "getattr", "(", "serializers", ",", "'{}ListSerializer'", ".", "format", "(", "cls", ".", "__name__", ")", ")", "for", "cls", "in", "(", "UnifiedJob...
[ 50, 0 ]
[ 61, 67 ]
python
en
['en', 'error', 'th']
False
moments
(data, beam, threshold=0)
Calculate source positional values using moments Args: data (numpy.ndarray): Actual 2D image data beam (3-tuple): beam (psf) information, with semi-major and semi-minor axes Returns: dict: peak, total, x barycenter, y barycenter, semimajor axis, semiminor axis...
Calculate source positional values using moments
def moments(data, beam, threshold=0): """Calculate source positional values using moments Args: data (numpy.ndarray): Actual 2D image data beam (3-tuple): beam (psf) information, with semi-major and semi-minor axes Returns: dict: peak, total, x barycenter, y barycente...
[ "def", "moments", "(", "data", ",", "beam", ",", "threshold", "=", "0", ")", ":", "# Are we fitting a -ve or +ve Gaussian?", "if", "data", ".", "mean", "(", ")", ">=", "0", ":", "# The peak is always underestimated when you take the highest pixel.", "peak", "=", "da...
[ 13, 0 ]
[ 109, 9 ]
python
en
['en', 'en', 'en']
True
fitgaussian
(pixels, params, fixed=None, maxfev=0)
Calculate source positional values by fitting a 2D Gaussian Args: pixels (numpy.ma.MaskedArray): Pixel values (with bad pixels masked) params (dict): initial fit parameters (possibly estimated using the moments() function, above) Kwargs: fixed (dict): parameters & their va...
Calculate source positional values by fitting a 2D Gaussian
def fitgaussian(pixels, params, fixed=None, maxfev=0): """Calculate source positional values by fitting a 2D Gaussian Args: pixels (numpy.ma.MaskedArray): Pixel values (with bad pixels masked) params (dict): initial fit parameters (possibly estimated using the moments() function, a...
[ "def", "fitgaussian", "(", "pixels", ",", "params", ",", "fixed", "=", "None", ",", "maxfev", "=", "0", ")", ":", "fixed", "=", "fixed", "or", "{", "}", "# Collect necessary values from parameter dict; only those which aren't", "# fixed.", "initial", "=", "[", "...
[ 112, 0 ]
[ 221, 18 ]
python
en
['en', 'en', 'en']
True
goodness_of_fit
(masked_residuals, noise, beam)
Calculates the goodness-of-fit values, `chisq` and `reduced_chisq`. .. Warning:: We do not use the `standard chi-squared formula <https://en.wikipedia.org/wiki/Goodness_of_fit#Regression_analysis>`_ for calculating these goodness-of-fit values, and should probably rename them i...
Calculates the goodness-of-fit values, `chisq` and `reduced_chisq`.
def goodness_of_fit(masked_residuals, noise, beam): """ Calculates the goodness-of-fit values, `chisq` and `reduced_chisq`. .. Warning:: We do not use the `standard chi-squared formula <https://en.wikipedia.org/wiki/Goodness_of_fit#Regression_analysis>`_ for calculating these goodne...
[ "def", "goodness_of_fit", "(", "masked_residuals", ",", "noise", ",", "beam", ")", ":", "gauss_resid_normed", "=", "(", "masked_residuals", "/", "noise", ")", ".", "compressed", "(", ")", "chisq", "=", "numpy", ".", "sum", "(", "gauss_resid_normed", "*", "ga...
[ 223, 0 ]
[ 270, 31 ]
python
en
['en', 'error', 'th']
False
specific_iterator
(qs, defer=False)
This efficiently iterates all the specific pages in a queryset, using the minimum number of queries. This should be called from ``PageQuerySet.specific``
This efficiently iterates all the specific pages in a queryset, using the minimum number of queries.
def specific_iterator(qs, defer=False): """ This efficiently iterates all the specific pages in a queryset, using the minimum number of queries. This should be called from ``PageQuerySet.specific`` """ from wagtail.core.models import Page annotation_aliases = qs.query.annotations.keys() ...
[ "def", "specific_iterator", "(", "qs", ",", "defer", "=", "False", ")", ":", "from", "wagtail", ".", "core", ".", "models", "import", "Page", "annotation_aliases", "=", "qs", ".", "query", ".", "annotations", ".", "keys", "(", ")", "values", "=", "qs", ...
[ 474, 0 ]
[ 548, 18 ]
python
en
['en', 'error', 'th']
False
TreeQuerySet.delete
(self)
Redefine the delete method unbound, so we can set the queryset_only parameter.
Redefine the delete method unbound, so we can set the queryset_only parameter.
def delete(self): """Redefine the delete method unbound, so we can set the queryset_only parameter. """ super().delete()
[ "def", "delete", "(", "self", ")", ":", "super", "(", ")", ".", "delete", "(", ")" ]
[ 21, 4 ]
[ 23, 24 ]
python
en
['en', 'en', 'en']
True
TreeQuerySet.descendant_of
(self, other, inclusive=False)
This filters the QuerySet to only contain pages that descend from the specified page. If inclusive is set to True, it will also contain the page itself (instead of just its descendants).
This filters the QuerySet to only contain pages that descend from the specified page.
def descendant_of(self, other, inclusive=False): """ This filters the QuerySet to only contain pages that descend from the specified page. If inclusive is set to True, it will also contain the page itself (instead of just its descendants). """ return self.filter(self.descendant_...
[ "def", "descendant_of", "(", "self", ",", "other", ",", "inclusive", "=", "False", ")", ":", "return", "self", ".", "filter", "(", "self", ".", "descendant_of_q", "(", "other", ",", "inclusive", ")", ")" ]
[ 35, 4 ]
[ 41, 66 ]
python
en
['en', 'error', 'th']
False
TreeQuerySet.not_descendant_of
(self, other, inclusive=False)
This filters the QuerySet to not contain any pages that descend from the specified page. If inclusive is set to True, it will also exclude the specified page.
This filters the QuerySet to not contain any pages that descend from the specified page.
def not_descendant_of(self, other, inclusive=False): """ This filters the QuerySet to not contain any pages that descend from the specified page. If inclusive is set to True, it will also exclude the specified page. """ return self.exclude(self.descendant_of_q(other, inclusive))
[ "def", "not_descendant_of", "(", "self", ",", "other", ",", "inclusive", "=", "False", ")", ":", "return", "self", ".", "exclude", "(", "self", ".", "descendant_of_q", "(", "other", ",", "inclusive", ")", ")" ]
[ 43, 4 ]
[ 49, 67 ]
python
en
['en', 'error', 'th']
False
TreeQuerySet.child_of
(self, other)
This filters the QuerySet to only contain pages that are direct children of the specified page.
This filters the QuerySet to only contain pages that are direct children of the specified page.
def child_of(self, other): """ This filters the QuerySet to only contain pages that are direct children of the specified page. """ return self.filter(self.child_of_q(other))
[ "def", "child_of", "(", "self", ",", "other", ")", ":", "return", "self", ".", "filter", "(", "self", ".", "child_of_q", "(", "other", ")", ")" ]
[ 54, 4 ]
[ 58, 50 ]
python
en
['en', 'error', 'th']
False
TreeQuerySet.not_child_of
(self, other)
This filters the QuerySet to not contain any pages that are direct children of the specified page.
This filters the QuerySet to not contain any pages that are direct children of the specified page.
def not_child_of(self, other): """ This filters the QuerySet to not contain any pages that are direct children of the specified page. """ return self.exclude(self.child_of_q(other))
[ "def", "not_child_of", "(", "self", ",", "other", ")", ":", "return", "self", ".", "exclude", "(", "self", ".", "child_of_q", "(", "other", ")", ")" ]
[ 60, 4 ]
[ 64, 51 ]
python
en
['en', 'error', 'th']
False
TreeQuerySet.ancestor_of
(self, other, inclusive=False)
This filters the QuerySet to only contain pages that are ancestors of the specified page. If inclusive is set to True, it will also include the specified page.
This filters the QuerySet to only contain pages that are ancestors of the specified page.
def ancestor_of(self, other, inclusive=False): """ This filters the QuerySet to only contain pages that are ancestors of the specified page. If inclusive is set to True, it will also include the specified page. """ return self.filter(self.ancestor_of_q(other, inclusive))
[ "def", "ancestor_of", "(", "self", ",", "other", ",", "inclusive", "=", "False", ")", ":", "return", "self", ".", "filter", "(", "self", ".", "ancestor_of_q", "(", "other", ",", "inclusive", ")", ")" ]
[ 78, 4 ]
[ 84, 64 ]
python
en
['en', 'error', 'th']
False
TreeQuerySet.not_ancestor_of
(self, other, inclusive=False)
This filters the QuerySet to not contain any pages that are ancestors of the specified page. If inclusive is set to True, it will also exclude the specified page.
This filters the QuerySet to not contain any pages that are ancestors of the specified page.
def not_ancestor_of(self, other, inclusive=False): """ This filters the QuerySet to not contain any pages that are ancestors of the specified page. If inclusive is set to True, it will also exclude the specified page. """ return self.exclude(self.ancestor_of_q(other, inclusive))
[ "def", "not_ancestor_of", "(", "self", ",", "other", ",", "inclusive", "=", "False", ")", ":", "return", "self", ".", "exclude", "(", "self", ".", "ancestor_of_q", "(", "other", ",", "inclusive", ")", ")" ]
[ 86, 4 ]
[ 92, 65 ]
python
en
['en', 'error', 'th']
False
TreeQuerySet.parent_of
(self, other)
This filters the QuerySet to only contain the parent of the specified page.
This filters the QuerySet to only contain the parent of the specified page.
def parent_of(self, other): """ This filters the QuerySet to only contain the parent of the specified page. """ return self.filter(self.parent_of_q(other))
[ "def", "parent_of", "(", "self", ",", "other", ")", ":", "return", "self", ".", "filter", "(", "self", ".", "parent_of_q", "(", "other", ")", ")" ]
[ 97, 4 ]
[ 101, 51 ]
python
en
['en', 'error', 'th']
False
TreeQuerySet.not_parent_of
(self, other)
This filters the QuerySet to exclude the parent of the specified page.
This filters the QuerySet to exclude the parent of the specified page.
def not_parent_of(self, other): """ This filters the QuerySet to exclude the parent of the specified page. """ return self.exclude(self.parent_of_q(other))
[ "def", "not_parent_of", "(", "self", ",", "other", ")", ":", "return", "self", ".", "exclude", "(", "self", ".", "parent_of_q", "(", "other", ")", ")" ]
[ 103, 4 ]
[ 107, 52 ]
python
en
['en', 'error', 'th']
False
TreeQuerySet.sibling_of
(self, other, inclusive=True)
This filters the QuerySet to only contain pages that are siblings of the specified page. By default, inclusive is set to True so it will include the specified page in the results. If inclusive is set to False, the page will be excluded from the results.
This filters the QuerySet to only contain pages that are siblings of the specified page.
def sibling_of(self, other, inclusive=True): """ This filters the QuerySet to only contain pages that are siblings of the specified page. By default, inclusive is set to True so it will include the specified page in the results. If inclusive is set to False, the page will be excluded f...
[ "def", "sibling_of", "(", "self", ",", "other", ",", "inclusive", "=", "True", ")", ":", "return", "self", ".", "filter", "(", "self", ".", "sibling_of_q", "(", "other", ",", "inclusive", ")", ")" ]
[ 117, 4 ]
[ 125, 63 ]
python
en
['en', 'error', 'th']
False
TreeQuerySet.not_sibling_of
(self, other, inclusive=True)
This filters the QuerySet to not contain any pages that are siblings of the specified page. By default, inclusive is set to True so it will exclude the specified page from the results. If inclusive is set to False, the page will be included in the results.
This filters the QuerySet to not contain any pages that are siblings of the specified page.
def not_sibling_of(self, other, inclusive=True): """ This filters the QuerySet to not contain any pages that are siblings of the specified page. By default, inclusive is set to True so it will exclude the specified page from the results. If inclusive is set to False, the page will be i...
[ "def", "not_sibling_of", "(", "self", ",", "other", ",", "inclusive", "=", "True", ")", ":", "return", "self", ".", "exclude", "(", "self", ".", "sibling_of_q", "(", "other", ",", "inclusive", ")", ")" ]
[ 127, 4 ]
[ 135, 64 ]
python
en
['en', 'error', 'th']
False
PageQuerySet.__init__
(self, *args, **kwargs)
Set custom instance attributes
Set custom instance attributes
def __init__(self, *args, **kwargs): """Set custom instance attributes""" super().__init__(*args, **kwargs) # set by defer_streamfields() self._defer_streamfields = False
[ "def", "__init__", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "super", "(", ")", ".", "__init__", "(", "*", "args", ",", "*", "*", "kwargs", ")", "# set by defer_streamfields()", "self", ".", "_defer_streamfields", "=", "False" ]
[ 139, 4 ]
[ 143, 40 ]
python
en
['en', 'la', 'en']
True
PageQuerySet._clone
(self)
Ensure clones inherit custom attribute values.
Ensure clones inherit custom attribute values.
def _clone(self): """Ensure clones inherit custom attribute values.""" clone = super()._clone() clone._defer_streamfields = self._defer_streamfields return clone
[ "def", "_clone", "(", "self", ")", ":", "clone", "=", "super", "(", ")", ".", "_clone", "(", ")", "clone", ".", "_defer_streamfields", "=", "self", ".", "_defer_streamfields", "return", "clone" ]
[ 145, 4 ]
[ 149, 20 ]
python
en
['en', 'la', 'en']
True
PageQuerySet.live
(self)
This filters the QuerySet to only contain published pages.
This filters the QuerySet to only contain published pages.
def live(self): """ This filters the QuerySet to only contain published pages. """ return self.filter(self.live_q())
[ "def", "live", "(", "self", ")", ":", "return", "self", ".", "filter", "(", "self", ".", "live_q", "(", ")", ")" ]
[ 154, 4 ]
[ 158, 41 ]
python
en
['en', 'error', 'th']
False
PageQuerySet.not_live
(self)
This filters the QuerySet to only contain unpublished pages.
This filters the QuerySet to only contain unpublished pages.
def not_live(self): """ This filters the QuerySet to only contain unpublished pages. """ return self.exclude(self.live_q())
[ "def", "not_live", "(", "self", ")", ":", "return", "self", ".", "exclude", "(", "self", ".", "live_q", "(", ")", ")" ]
[ 160, 4 ]
[ 164, 42 ]
python
en
['en', 'error', 'th']
False
PageQuerySet.in_menu
(self)
This filters the QuerySet to only contain pages that are in the menus.
This filters the QuerySet to only contain pages that are in the menus.
def in_menu(self): """ This filters the QuerySet to only contain pages that are in the menus. """ return self.filter(self.in_menu_q())
[ "def", "in_menu", "(", "self", ")", ":", "return", "self", ".", "filter", "(", "self", ".", "in_menu_q", "(", ")", ")" ]
[ 169, 4 ]
[ 173, 44 ]
python
en
['en', 'error', 'th']
False
PageQuerySet.not_in_menu
(self)
This filters the QuerySet to only contain pages that are not in the menus.
This filters the QuerySet to only contain pages that are not in the menus.
def not_in_menu(self): """ This filters the QuerySet to only contain pages that are not in the menus. """ return self.exclude(self.in_menu_q())
[ "def", "not_in_menu", "(", "self", ")", ":", "return", "self", ".", "exclude", "(", "self", ".", "in_menu_q", "(", ")", ")" ]
[ 175, 4 ]
[ 179, 45 ]
python
en
['en', 'error', 'th']
False
PageQuerySet.page
(self, other)
This filters the QuerySet so it only contains the specified page.
This filters the QuerySet so it only contains the specified page.
def page(self, other): """ This filters the QuerySet so it only contains the specified page. """ return self.filter(self.page_q(other))
[ "def", "page", "(", "self", ",", "other", ")", ":", "return", "self", ".", "filter", "(", "self", ".", "page_q", "(", "other", ")", ")" ]
[ 184, 4 ]
[ 188, 46 ]
python
en
['en', 'error', 'th']
False
PageQuerySet.not_page
(self, other)
This filters the QuerySet so it doesn't contain the specified page.
This filters the QuerySet so it doesn't contain the specified page.
def not_page(self, other): """ This filters the QuerySet so it doesn't contain the specified page. """ return self.exclude(self.page_q(other))
[ "def", "not_page", "(", "self", ",", "other", ")", ":", "return", "self", ".", "exclude", "(", "self", ".", "page_q", "(", "other", ")", ")" ]
[ 190, 4 ]
[ 194, 47 ]
python
en
['en', 'error', 'th']
False
PageQuerySet.type
(self, *types)
This filters the QuerySet to only contain pages that are an instance of the specified model(s) (including subclasses).
This filters the QuerySet to only contain pages that are an instance of the specified model(s) (including subclasses).
def type(self, *types): """ This filters the QuerySet to only contain pages that are an instance of the specified model(s) (including subclasses). """ return self.filter(self.type_q(*types))
[ "def", "type", "(", "self", ",", "*", "types", ")", ":", "return", "self", ".", "filter", "(", "self", ".", "type_q", "(", "*", "types", ")", ")" ]
[ 204, 4 ]
[ 209, 47 ]
python
en
['en', 'error', 'th']
False