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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
Page.is_previewable | (self) | Returns True if at least one preview mode is specified | Returns True if at least one preview mode is specified | def is_previewable(self):
"""Returns True if at least one preview mode is specified"""
# It's possible that this will be called from a listing page using a plain Page queryset -
# if so, checking self.preview_modes would incorrectly give us the default set from
# Page.preview_modes. Howe... | [
"def",
"is_previewable",
"(",
"self",
")",
":",
"# It's possible that this will be called from a listing page using a plain Page queryset -",
"# if so, checking self.preview_modes would incorrectly give us the default set from",
"# Page.preview_modes. However, accessing self.specific.preview_modes w... | [
2092,
4
] | [
2104,
39
] | python | en | ['en', 'en', 'en'] | True |
Page.serve_preview | (self, request, mode_name) |
Return an HTTP response for use in page previews. Normally this would be equivalent
to self.serve(request), since we obviously want the preview to be indicative of how
it looks on the live site. However, there are a couple of cases where this is not
appropriate, and custom behaviour is ... |
Return an HTTP response for use in page previews. Normally this would be equivalent
to self.serve(request), since we obviously want the preview to be indicative of how
it looks on the live site. However, there are a couple of cases where this is not
appropriate, and custom behaviour is ... | def serve_preview(self, request, mode_name):
"""
Return an HTTP response for use in page previews. Normally this would be equivalent
to self.serve(request), since we obviously want the preview to be indicative of how
it looks on the live site. However, there are a couple of cases where t... | [
"def",
"serve_preview",
"(",
"self",
",",
"request",
",",
"mode_name",
")",
":",
"request",
".",
"is_preview",
"=",
"True",
"response",
"=",
"self",
".",
"serve",
"(",
"request",
")",
"patch_cache_control",
"(",
"response",
",",
"private",
"=",
"True",
")"... | [
2106,
4
] | [
2135,
23
] | python | en | ['en', 'error', 'th'] | False |
Page.get_cached_paths | (self) |
This returns a list of paths to invalidate in a frontend cache
|
This returns a list of paths to invalidate in a frontend cache
| def get_cached_paths(self):
"""
This returns a list of paths to invalidate in a frontend cache
"""
return ['/'] | [
"def",
"get_cached_paths",
"(",
"self",
")",
":",
"return",
"[",
"'/'",
"]"
] | [
2137,
4
] | [
2141,
20
] | python | en | ['en', 'error', 'th'] | False |
Page.get_static_site_paths | (self) |
This is a generator of URL paths to feed into a static site generator
Override this if you would like to create static versions of subpages
|
This is a generator of URL paths to feed into a static site generator
Override this if you would like to create static versions of subpages
| def get_static_site_paths(self):
"""
This is a generator of URL paths to feed into a static site generator
Override this if you would like to create static versions of subpages
"""
# Yield path for this page
yield '/'
# Yield paths for child pages
for chi... | [
"def",
"get_static_site_paths",
"(",
"self",
")",
":",
"# Yield path for this page",
"yield",
"'/'",
"# Yield paths for child pages",
"for",
"child",
"in",
"self",
".",
"get_children",
"(",
")",
".",
"live",
"(",
")",
":",
"for",
"path",
"in",
"child",
".",
"s... | [
2153,
4
] | [
2164,
45
] | python | en | ['en', 'error', 'th'] | False |
Page.get_ancestors | (self, inclusive=False) |
Returns a queryset of the current page's ancestors, starting at the root page
and descending to the parent, or to the current page itself if ``inclusive`` is true.
|
Returns a queryset of the current page's ancestors, starting at the root page
and descending to the parent, or to the current page itself if ``inclusive`` is true.
| def get_ancestors(self, inclusive=False):
"""
Returns a queryset of the current page's ancestors, starting at the root page
and descending to the parent, or to the current page itself if ``inclusive`` is true.
"""
return Page.objects.ancestor_of(self, inclusive) | [
"def",
"get_ancestors",
"(",
"self",
",",
"inclusive",
"=",
"False",
")",
":",
"return",
"Page",
".",
"objects",
".",
"ancestor_of",
"(",
"self",
",",
"inclusive",
")"
] | [
2166,
4
] | [
2171,
56
] | python | en | ['en', 'error', 'th'] | False |
Page.get_descendants | (self, inclusive=False) |
Returns a queryset of all pages underneath the current page, any number of levels deep.
If ``inclusive`` is true, the current page itself is included in the queryset.
|
Returns a queryset of all pages underneath the current page, any number of levels deep.
If ``inclusive`` is true, the current page itself is included in the queryset.
| def get_descendants(self, inclusive=False):
"""
Returns a queryset of all pages underneath the current page, any number of levels deep.
If ``inclusive`` is true, the current page itself is included in the queryset.
"""
return Page.objects.descendant_of(self, inclusive) | [
"def",
"get_descendants",
"(",
"self",
",",
"inclusive",
"=",
"False",
")",
":",
"return",
"Page",
".",
"objects",
".",
"descendant_of",
"(",
"self",
",",
"inclusive",
")"
] | [
2173,
4
] | [
2178,
58
] | python | en | ['en', 'error', 'th'] | False |
Page.get_siblings | (self, inclusive=True) |
Returns a queryset of all other pages with the same parent as the current page.
If ``inclusive`` is true, the current page itself is included in the queryset.
|
Returns a queryset of all other pages with the same parent as the current page.
If ``inclusive`` is true, the current page itself is included in the queryset.
| def get_siblings(self, inclusive=True):
"""
Returns a queryset of all other pages with the same parent as the current page.
If ``inclusive`` is true, the current page itself is included in the queryset.
"""
return Page.objects.sibling_of(self, inclusive) | [
"def",
"get_siblings",
"(",
"self",
",",
"inclusive",
"=",
"True",
")",
":",
"return",
"Page",
".",
"objects",
".",
"sibling_of",
"(",
"self",
",",
"inclusive",
")"
] | [
2180,
4
] | [
2185,
55
] | python | en | ['en', 'error', 'th'] | False |
Page.get_view_restrictions | (self) |
Return a query set of all page view restrictions that apply to this page.
This checks the current page and all ancestor pages for page view restrictions.
If any of those pages are aliases, it will resolve them to their source pages
before querying PageViewRestrictions so alias pages u... |
Return a query set of all page view restrictions that apply to this page. | def get_view_restrictions(self):
"""
Return a query set of all page view restrictions that apply to this page.
This checks the current page and all ancestor pages for page view restrictions.
If any of those pages are aliases, it will resolve them to their source pages
before qu... | [
"def",
"get_view_restrictions",
"(",
"self",
")",
":",
"page_ids_to_check",
"=",
"set",
"(",
")",
"def",
"add_page_to_check_list",
"(",
"page",
")",
":",
"# If the page is an alias, add the source page to the check list instead",
"if",
"page",
".",
"alias_of",
":",
"add... | [
2193,
4
] | [
2219,
80
] | python | en | ['en', 'error', 'th'] | False |
Page.serve_password_required_response | (self, request, form, action_url) |
Serve a response indicating that the user has been denied access to view this page,
and must supply a password.
form = a Django form object containing the password input
(and zero or more hidden fields that also need to be output on the template)
action_url = URL that this f... |
Serve a response indicating that the user has been denied access to view this page,
and must supply a password.
form = a Django form object containing the password input
(and zero or more hidden fields that also need to be output on the template)
action_url = URL that this f... | def serve_password_required_response(self, request, form, action_url):
"""
Serve a response indicating that the user has been denied access to view this page,
and must supply a password.
form = a Django form object containing the password input
(and zero or more hidden fields... | [
"def",
"serve_password_required_response",
"(",
"self",
",",
"request",
",",
"form",
",",
"action_url",
")",
":",
"context",
"=",
"self",
".",
"get_context",
"(",
"request",
")",
"context",
"[",
"'form'",
"]",
"=",
"form",
"context",
"[",
"'action_url'",
"]"... | [
2223,
4
] | [
2234,
82
] | python | en | ['en', 'error', 'th'] | False |
Page.with_content_json | (self, content_json) |
Returns a new version of the page with field values updated to reflect changes
in the provided ``content_json`` (which usually comes from a previously-saved
page revision).
Certain field values are preserved in order to prevent errors if the returned
page is saved, such as ``id... |
Returns a new version of the page with field values updated to reflect changes
in the provided ``content_json`` (which usually comes from a previously-saved
page revision). | def with_content_json(self, content_json):
"""
Returns a new version of the page with field values updated to reflect changes
in the provided ``content_json`` (which usually comes from a previously-saved
page revision).
Certain field values are preserved in order to prevent erro... | [
"def",
"with_content_json",
"(",
"self",
",",
"content_json",
")",
":",
"obj",
"=",
"self",
".",
"specific_class",
".",
"from_json",
"(",
"content_json",
")",
"# These should definitely never change between revisions",
"obj",
".",
"id",
"=",
"self",
".",
"id",
"ob... | [
2236,
4
] | [
2302,
18
] | python | en | ['en', 'error', 'th'] | False |
Page.has_workflow | (self) | Returns True if the page or an ancestor has an active workflow assigned, otherwise False | Returns True if the page or an ancestor has an active workflow assigned, otherwise False | def has_workflow(self):
"""Returns True if the page or an ancestor has an active workflow assigned, otherwise False"""
if not getattr(settings, 'WAGTAIL_WORKFLOW_ENABLED', True):
return False
return self.get_ancestors(inclusive=True).filter(workflowpage__isnull=False).filter(workflow... | [
"def",
"has_workflow",
"(",
"self",
")",
":",
"if",
"not",
"getattr",
"(",
"settings",
",",
"'WAGTAIL_WORKFLOW_ENABLED'",
",",
"True",
")",
":",
"return",
"False",
"return",
"self",
".",
"get_ancestors",
"(",
"inclusive",
"=",
"True",
")",
".",
"filter",
"... | [
2305,
4
] | [
2309,
137
] | python | en | ['en', 'en', 'en'] | True |
Page.get_workflow | (self) | Returns the active workflow assigned to the page or its nearest ancestor | Returns the active workflow assigned to the page or its nearest ancestor | def get_workflow(self):
"""Returns the active workflow assigned to the page or its nearest ancestor"""
if not getattr(settings, 'WAGTAIL_WORKFLOW_ENABLED', True):
return None
if hasattr(self, 'workflowpage') and self.workflowpage.workflow.active:
return self.workflowpage... | [
"def",
"get_workflow",
"(",
"self",
")",
":",
"if",
"not",
"getattr",
"(",
"settings",
",",
"'WAGTAIL_WORKFLOW_ENABLED'",
",",
"True",
")",
":",
"return",
"None",
"if",
"hasattr",
"(",
"self",
",",
"'workflowpage'",
")",
"and",
"self",
".",
"workflowpage",
... | [
2311,
4
] | [
2324,
27
] | python | en | ['en', 'en', 'en'] | True |
Page.workflow_in_progress | (self) | Returns True if a workflow is in progress on the current page, otherwise False | Returns True if a workflow is in progress on the current page, otherwise False | def workflow_in_progress(self):
"""Returns True if a workflow is in progress on the current page, otherwise False"""
if not getattr(settings, 'WAGTAIL_WORKFLOW_ENABLED', True):
return False
# `_current_workflow_states` may be populated by `prefetch_workflow_states` on `PageQuerySet`... | [
"def",
"workflow_in_progress",
"(",
"self",
")",
":",
"if",
"not",
"getattr",
"(",
"settings",
",",
"'WAGTAIL_WORKFLOW_ENABLED'",
",",
"True",
")",
":",
"return",
"False",
"# `_current_workflow_states` may be populated by `prefetch_workflow_states` on `PageQuerySet` as a",
"#... | [
2327,
4
] | [
2340,
104
] | python | en | ['en', 'en', 'en'] | True |
Page.current_workflow_state | (self) | Returns the in progress or needs changes workflow state on this page, if it exists | Returns the in progress or needs changes workflow state on this page, if it exists | def current_workflow_state(self):
"""Returns the in progress or needs changes workflow state on this page, if it exists"""
if not getattr(settings, 'WAGTAIL_WORKFLOW_ENABLED', True):
return None
# `_current_workflow_states` may be populated by `prefetch_workflow_states` on `pagequer... | [
"def",
"current_workflow_state",
"(",
"self",
")",
":",
"if",
"not",
"getattr",
"(",
"settings",
",",
"'WAGTAIL_WORKFLOW_ENABLED'",
",",
"True",
")",
":",
"return",
"None",
"# `_current_workflow_states` may be populated by `prefetch_workflow_states` on `pagequeryset` as a",
"... | [
2343,
4
] | [
2359,
18
] | python | en | ['en', 'en', 'en'] | True |
Page.current_workflow_task_state | (self) | Returns (specific class of) the current task state of the workflow on this page, if it exists | Returns (specific class of) the current task state of the workflow on this page, if it exists | def current_workflow_task_state(self):
"""Returns (specific class of) the current task state of the workflow on this page, if it exists"""
current_workflow_state = self.current_workflow_state
if current_workflow_state and current_workflow_state.status == WorkflowState.STATUS_IN_PROGRESS and curr... | [
"def",
"current_workflow_task_state",
"(",
"self",
")",
":",
"current_workflow_state",
"=",
"self",
".",
"current_workflow_state",
"if",
"current_workflow_state",
"and",
"current_workflow_state",
".",
"status",
"==",
"WorkflowState",
".",
"STATUS_IN_PROGRESS",
"and",
"cur... | [
2362,
4
] | [
2366,
69
] | python | en | ['en', 'en', 'en'] | True |
Page.current_workflow_task | (self) | Returns (specific class of) the current task in progress on this page, if it exists | Returns (specific class of) the current task in progress on this page, if it exists | def current_workflow_task(self):
"""Returns (specific class of) the current task in progress on this page, if it exists"""
current_workflow_task_state = self.current_workflow_task_state
if current_workflow_task_state:
return current_workflow_task_state.task.specific | [
"def",
"current_workflow_task",
"(",
"self",
")",
":",
"current_workflow_task_state",
"=",
"self",
".",
"current_workflow_task_state",
"if",
"current_workflow_task_state",
":",
"return",
"current_workflow_task_state",
".",
"task",
".",
"specific"
] | [
2369,
4
] | [
2373,
60
] | python | en | ['en', 'en', 'en'] | True |
initialize_pipeline_config | (pipe_cfg_file, job_name=False) |
Initializes the default variables and loads the ConfigParser file.
Sets defaults for start_time, job_name and cwd; these can then be used
via variable substitution in other config values.
|
Initializes the default variables and loads the ConfigParser file. | def initialize_pipeline_config(pipe_cfg_file, job_name=False):
"""
Initializes the default variables and loads the ConfigParser file.
Sets defaults for start_time, job_name and cwd; these can then be used
via variable substitution in other config values.
"""
start_time = datetime.datetime.utcn... | [
"def",
"initialize_pipeline_config",
"(",
"pipe_cfg_file",
",",
"job_name",
"=",
"False",
")",
":",
"start_time",
"=",
"datetime",
".",
"datetime",
".",
"utcnow",
"(",
")",
".",
"replace",
"(",
"microsecond",
"=",
"0",
")",
".",
"isoformat",
"(",
")",
"con... | [
14,
0
] | [
30,
32
] | python | en | ['en', 'error', 'th'] | False |
get_database_config | (pipeline_config=None, apply=None) |
Determine database config and (optionally) use to set up the Database.
Determines a database configuration using the settings
defined in a dict (if supplied) and possibly overridden by
environment variables.
The config resulting from the combination of defaults, supplied dict,
and environment ... |
Determine database config and (optionally) use to set up the Database. | def get_database_config(pipeline_config=None, apply=None):
"""
Determine database config and (optionally) use to set up the Database.
Determines a database configuration using the settings
defined in a dict (if supplied) and possibly overridden by
environment variables.
The config resulting fro... | [
"def",
"get_database_config",
"(",
"pipeline_config",
"=",
"None",
",",
"apply",
"=",
"None",
")",
":",
"user",
"=",
"getpass",
".",
"getuser",
"(",
")",
"# Default values",
"combined",
"=",
"{",
"'engine'",
":",
"None",
",",
"'database'",
":",
"user",
","... | [
33,
0
] | [
114,
19
] | python | en | ['en', 'error', 'th'] | False |
reject_check_aartfaac | (accessor) |
Executes quality checks for any type of telescope
args:
accessor: tkp.db.accessor image accessor
returns: A rejection reason if the image is bad, None otherwise
|
Executes quality checks for any type of telescope | def reject_check_aartfaac(accessor):
"""
Executes quality checks for any type of telescope
args:
accessor: tkp.db.accessor image accessor
returns: A rejection reason if the image is bad, None otherwise
"""
nan_check = contains_nan(accessor.data)
if nan_check:
logger.warnin... | [
"def",
"reject_check_aartfaac",
"(",
"accessor",
")",
":",
"nan_check",
"=",
"contains_nan",
"(",
"accessor",
".",
"data",
")",
"if",
"nan_check",
":",
"logger",
".",
"warning",
"(",
"\"image %s REJECTED: contains NaN\"",
"%",
"accessor",
".",
"url",
")",
"retur... | [
7,
0
] | [
22,
19
] | python | en | ['en', 'error', 'th'] | False |
calculate_cost_of_program | (program: SerializedProgram, npc_result: NPCResult, cost_per_byte: int) |
This function calculates the total cost of either a block or a spendbundle
|
This function calculates the total cost of either a block or a spendbundle
| def calculate_cost_of_program(program: SerializedProgram, npc_result: NPCResult, cost_per_byte: int) -> uint64:
"""
This function calculates the total cost of either a block or a spendbundle
"""
total_cost = 0
total_cost += npc_result.clvm_cost
npc_list = npc_result.npc_list
# Add cost of co... | [
"def",
"calculate_cost_of_program",
"(",
"program",
":",
"SerializedProgram",
",",
"npc_result",
":",
"NPCResult",
",",
"cost_per_byte",
":",
"int",
")",
"->",
"uint64",
":",
"total_cost",
"=",
"0",
"total_cost",
"+=",
"npc_result",
".",
"clvm_cost",
"npc_list",
... | [
19,
0
] | [
61,
29
] | python | en | ['en', 'error', 'th'] | False |
SpatialReference.__init__ | (self, srs_input='', srs_type='user') |
Creates a GDAL OSR Spatial Reference object from the given input.
The input may be string of OGC Well Known Text (WKT), an integer
EPSG code, a PROJ.4 string, and/or a projection "well known" shorthand
string (one of 'WGS84', 'WGS72', 'NAD27', 'NAD83').
|
Creates a GDAL OSR Spatial Reference object from the given input.
The input may be string of OGC Well Known Text (WKT), an integer
EPSG code, a PROJ.4 string, and/or a projection "well known" shorthand
string (one of 'WGS84', 'WGS72', 'NAD27', 'NAD83').
| def __init__(self, srs_input='', srs_type='user'):
"""
Creates a GDAL OSR Spatial Reference object from the given input.
The input may be string of OGC Well Known Text (WKT), an integer
EPSG code, a PROJ.4 string, and/or a projection "well known" shorthand
string (one of 'WGS84',... | [
"def",
"__init__",
"(",
"self",
",",
"srs_input",
"=",
"''",
",",
"srs_type",
"=",
"'user'",
")",
":",
"if",
"srs_type",
"==",
"'wkt'",
":",
"self",
".",
"ptr",
"=",
"capi",
".",
"new_srs",
"(",
"c_char_p",
"(",
"b''",
")",
")",
"self",
".",
"impor... | [
45,
4
] | [
92,
39
] | python | en | ['en', 'error', 'th'] | False |
SpatialReference.__getitem__ | (self, target) |
Returns the value of the given string attribute node, None if the node
doesn't exist. Can also take a tuple as a parameter, (target, child),
where child is the index of the attribute in the WKT. For example:
>>> wkt = 'GEOGCS["WGS 84", DATUM["WGS_1984, ... AUTHORITY["EPSG","4326"]]'
... |
Returns the value of the given string attribute node, None if the node
doesn't exist. Can also take a tuple as a parameter, (target, child),
where child is the index of the attribute in the WKT. For example: | def __getitem__(self, target):
"""
Returns the value of the given string attribute node, None if the node
doesn't exist. Can also take a tuple as a parameter, (target, child),
where child is the index of the attribute in the WKT. For example:
>>> wkt = 'GEOGCS["WGS 84", DATUM[... | [
"def",
"__getitem__",
"(",
"self",
",",
"target",
")",
":",
"if",
"isinstance",
"(",
"target",
",",
"tuple",
")",
":",
"return",
"self",
".",
"attr_value",
"(",
"*",
"target",
")",
"else",
":",
"return",
"self",
".",
"attr_value",
"(",
"target",
")"
] | [
94,
4
] | [
120,
42
] | python | en | ['en', 'error', 'th'] | False |
SpatialReference.__str__ | (self) | The string representation uses 'pretty' WKT. | The string representation uses 'pretty' WKT. | def __str__(self):
"The string representation uses 'pretty' WKT."
return self.pretty_wkt | [
"def",
"__str__",
"(",
"self",
")",
":",
"return",
"self",
".",
"pretty_wkt"
] | [
122,
4
] | [
124,
30
] | python | en | ['en', 'en', 'en'] | True |
SpatialReference.attr_value | (self, target, index=0) |
The attribute value for the given target node (e.g. 'PROJCS'). The index
keyword specifies an index of the child node to return.
|
The attribute value for the given target node (e.g. 'PROJCS'). The index
keyword specifies an index of the child node to return.
| def attr_value(self, target, index=0):
"""
The attribute value for the given target node (e.g. 'PROJCS'). The index
keyword specifies an index of the child node to return.
"""
if not isinstance(target, six.string_types) or not isinstance(index, int):
raise TypeError
... | [
"def",
"attr_value",
"(",
"self",
",",
"target",
",",
"index",
"=",
"0",
")",
":",
"if",
"not",
"isinstance",
"(",
"target",
",",
"six",
".",
"string_types",
")",
"or",
"not",
"isinstance",
"(",
"index",
",",
"int",
")",
":",
"raise",
"TypeError",
"r... | [
127,
4
] | [
134,
72
] | python | en | ['en', 'error', 'th'] | False |
SpatialReference.auth_name | (self, target) | Returns the authority name for the given string target node. | Returns the authority name for the given string target node. | def auth_name(self, target):
"Returns the authority name for the given string target node."
return capi.get_auth_name(self.ptr, force_bytes(target)) | [
"def",
"auth_name",
"(",
"self",
",",
"target",
")",
":",
"return",
"capi",
".",
"get_auth_name",
"(",
"self",
".",
"ptr",
",",
"force_bytes",
"(",
"target",
")",
")"
] | [
136,
4
] | [
138,
64
] | python | en | ['en', 'en', 'en'] | True |
SpatialReference.auth_code | (self, target) | Returns the authority code for the given string target node. | Returns the authority code for the given string target node. | def auth_code(self, target):
"Returns the authority code for the given string target node."
return capi.get_auth_code(self.ptr, force_bytes(target)) | [
"def",
"auth_code",
"(",
"self",
",",
"target",
")",
":",
"return",
"capi",
".",
"get_auth_code",
"(",
"self",
".",
"ptr",
",",
"force_bytes",
"(",
"target",
")",
")"
] | [
140,
4
] | [
142,
64
] | python | en | ['en', 'en', 'en'] | True |
SpatialReference.clone | (self) | Returns a clone of this SpatialReference object. | Returns a clone of this SpatialReference object. | def clone(self):
"Returns a clone of this SpatialReference object."
return SpatialReference(capi.clone_srs(self.ptr)) | [
"def",
"clone",
"(",
"self",
")",
":",
"return",
"SpatialReference",
"(",
"capi",
".",
"clone_srs",
"(",
"self",
".",
"ptr",
")",
")"
] | [
144,
4
] | [
146,
57
] | python | en | ['en', 'en', 'en'] | True |
SpatialReference.from_esri | (self) | Morphs this SpatialReference from ESRI's format to EPSG. | Morphs this SpatialReference from ESRI's format to EPSG. | def from_esri(self):
"Morphs this SpatialReference from ESRI's format to EPSG."
capi.morph_from_esri(self.ptr) | [
"def",
"from_esri",
"(",
"self",
")",
":",
"capi",
".",
"morph_from_esri",
"(",
"self",
".",
"ptr",
")"
] | [
148,
4
] | [
150,
38
] | python | en | ['en', 'en', 'en'] | True |
SpatialReference.identify_epsg | (self) |
This method inspects the WKT of this SpatialReference, and will
add EPSG authority nodes where an EPSG identifier is applicable.
|
This method inspects the WKT of this SpatialReference, and will
add EPSG authority nodes where an EPSG identifier is applicable.
| def identify_epsg(self):
"""
This method inspects the WKT of this SpatialReference, and will
add EPSG authority nodes where an EPSG identifier is applicable.
"""
capi.identify_epsg(self.ptr) | [
"def",
"identify_epsg",
"(",
"self",
")",
":",
"capi",
".",
"identify_epsg",
"(",
"self",
".",
"ptr",
")"
] | [
152,
4
] | [
157,
36
] | python | en | ['en', 'error', 'th'] | False |
SpatialReference.to_esri | (self) | Morphs this SpatialReference to ESRI's format. | Morphs this SpatialReference to ESRI's format. | def to_esri(self):
"Morphs this SpatialReference to ESRI's format."
capi.morph_to_esri(self.ptr) | [
"def",
"to_esri",
"(",
"self",
")",
":",
"capi",
".",
"morph_to_esri",
"(",
"self",
".",
"ptr",
")"
] | [
159,
4
] | [
161,
36
] | python | en | ['en', 'en', 'en'] | True |
SpatialReference.validate | (self) | Checks to see if the given spatial reference is valid. | Checks to see if the given spatial reference is valid. | def validate(self):
"Checks to see if the given spatial reference is valid."
capi.srs_validate(self.ptr) | [
"def",
"validate",
"(",
"self",
")",
":",
"capi",
".",
"srs_validate",
"(",
"self",
".",
"ptr",
")"
] | [
163,
4
] | [
165,
35
] | python | en | ['en', 'en', 'en'] | True |
SpatialReference.name | (self) | Returns the name of this Spatial Reference. | Returns the name of this Spatial Reference. | def name(self):
"Returns the name of this Spatial Reference."
if self.projected:
return self.attr_value('PROJCS')
elif self.geographic:
return self.attr_value('GEOGCS')
elif self.local:
return self.attr_value('LOCAL_CS')
else:
retur... | [
"def",
"name",
"(",
"self",
")",
":",
"if",
"self",
".",
"projected",
":",
"return",
"self",
".",
"attr_value",
"(",
"'PROJCS'",
")",
"elif",
"self",
".",
"geographic",
":",
"return",
"self",
".",
"attr_value",
"(",
"'GEOGCS'",
")",
"elif",
"self",
"."... | [
169,
4
] | [
178,
23
] | python | en | ['en', 'en', 'en'] | True |
SpatialReference.srid | (self) | Returns the SRID of top-level authority, or None if undefined. | Returns the SRID of top-level authority, or None if undefined. | def srid(self):
"Returns the SRID of top-level authority, or None if undefined."
try:
return int(self.attr_value('AUTHORITY', 1))
except (TypeError, ValueError):
return None | [
"def",
"srid",
"(",
"self",
")",
":",
"try",
":",
"return",
"int",
"(",
"self",
".",
"attr_value",
"(",
"'AUTHORITY'",
",",
"1",
")",
")",
"except",
"(",
"TypeError",
",",
"ValueError",
")",
":",
"return",
"None"
] | [
181,
4
] | [
186,
23
] | python | en | ['en', 'en', 'en'] | True |
SpatialReference.linear_name | (self) | Returns the name of the linear units. | Returns the name of the linear units. | def linear_name(self):
"Returns the name of the linear units."
units, name = capi.linear_units(self.ptr, byref(c_char_p()))
return name | [
"def",
"linear_name",
"(",
"self",
")",
":",
"units",
",",
"name",
"=",
"capi",
".",
"linear_units",
"(",
"self",
".",
"ptr",
",",
"byref",
"(",
"c_char_p",
"(",
")",
")",
")",
"return",
"name"
] | [
190,
4
] | [
193,
19
] | python | en | ['en', 'en', 'en'] | True |
SpatialReference.linear_units | (self) | Returns the value of the linear units. | Returns the value of the linear units. | def linear_units(self):
"Returns the value of the linear units."
units, name = capi.linear_units(self.ptr, byref(c_char_p()))
return units | [
"def",
"linear_units",
"(",
"self",
")",
":",
"units",
",",
"name",
"=",
"capi",
".",
"linear_units",
"(",
"self",
".",
"ptr",
",",
"byref",
"(",
"c_char_p",
"(",
")",
")",
")",
"return",
"units"
] | [
196,
4
] | [
199,
20
] | python | en | ['en', 'en', 'en'] | True |
SpatialReference.angular_name | (self) | Returns the name of the angular units. | Returns the name of the angular units. | def angular_name(self):
"Returns the name of the angular units."
units, name = capi.angular_units(self.ptr, byref(c_char_p()))
return name | [
"def",
"angular_name",
"(",
"self",
")",
":",
"units",
",",
"name",
"=",
"capi",
".",
"angular_units",
"(",
"self",
".",
"ptr",
",",
"byref",
"(",
"c_char_p",
"(",
")",
")",
")",
"return",
"name"
] | [
202,
4
] | [
205,
19
] | python | en | ['en', 'mi', 'en'] | True |
SpatialReference.angular_units | (self) | Returns the value of the angular units. | Returns the value of the angular units. | def angular_units(self):
"Returns the value of the angular units."
units, name = capi.angular_units(self.ptr, byref(c_char_p()))
return units | [
"def",
"angular_units",
"(",
"self",
")",
":",
"units",
",",
"name",
"=",
"capi",
".",
"angular_units",
"(",
"self",
".",
"ptr",
",",
"byref",
"(",
"c_char_p",
"(",
")",
")",
")",
"return",
"units"
] | [
208,
4
] | [
211,
20
] | python | en | ['en', 'en', 'en'] | True |
SpatialReference.units | (self) |
Returns a 2-tuple of the units value and the units name,
and will automatically determines whether to return the linear
or angular units.
|
Returns a 2-tuple of the units value and the units name,
and will automatically determines whether to return the linear
or angular units.
| def units(self):
"""
Returns a 2-tuple of the units value and the units name,
and will automatically determines whether to return the linear
or angular units.
"""
units, name = None, None
if self.projected or self.local:
units, name = capi.linear_units... | [
"def",
"units",
"(",
"self",
")",
":",
"units",
",",
"name",
"=",
"None",
",",
"None",
"if",
"self",
".",
"projected",
"or",
"self",
".",
"local",
":",
"units",
",",
"name",
"=",
"capi",
".",
"linear_units",
"(",
"self",
".",
"ptr",
",",
"byref",
... | [
214,
4
] | [
227,
28
] | python | en | ['en', 'error', 'th'] | False |
SpatialReference.ellipsoid | (self) |
Returns a tuple of the ellipsoid parameters:
(semimajor axis, semiminor axis, and inverse flattening)
|
Returns a tuple of the ellipsoid parameters:
(semimajor axis, semiminor axis, and inverse flattening)
| def ellipsoid(self):
"""
Returns a tuple of the ellipsoid parameters:
(semimajor axis, semiminor axis, and inverse flattening)
"""
return (self.semi_major, self.semi_minor, self.inverse_flattening) | [
"def",
"ellipsoid",
"(",
"self",
")",
":",
"return",
"(",
"self",
".",
"semi_major",
",",
"self",
".",
"semi_minor",
",",
"self",
".",
"inverse_flattening",
")"
] | [
231,
4
] | [
236,
74
] | python | en | ['en', 'error', 'th'] | False |
SpatialReference.semi_major | (self) | Returns the Semi Major Axis for this Spatial Reference. | Returns the Semi Major Axis for this Spatial Reference. | def semi_major(self):
"Returns the Semi Major Axis for this Spatial Reference."
return capi.semi_major(self.ptr, byref(c_int())) | [
"def",
"semi_major",
"(",
"self",
")",
":",
"return",
"capi",
".",
"semi_major",
"(",
"self",
".",
"ptr",
",",
"byref",
"(",
"c_int",
"(",
")",
")",
")"
] | [
239,
4
] | [
241,
56
] | python | en | ['en', 'en', 'en'] | True |
SpatialReference.semi_minor | (self) | Returns the Semi Minor Axis for this Spatial Reference. | Returns the Semi Minor Axis for this Spatial Reference. | def semi_minor(self):
"Returns the Semi Minor Axis for this Spatial Reference."
return capi.semi_minor(self.ptr, byref(c_int())) | [
"def",
"semi_minor",
"(",
"self",
")",
":",
"return",
"capi",
".",
"semi_minor",
"(",
"self",
".",
"ptr",
",",
"byref",
"(",
"c_int",
"(",
")",
")",
")"
] | [
244,
4
] | [
246,
56
] | python | en | ['en', 'en', 'en'] | True |
SpatialReference.inverse_flattening | (self) | Returns the Inverse Flattening for this Spatial Reference. | Returns the Inverse Flattening for this Spatial Reference. | def inverse_flattening(self):
"Returns the Inverse Flattening for this Spatial Reference."
return capi.invflattening(self.ptr, byref(c_int())) | [
"def",
"inverse_flattening",
"(",
"self",
")",
":",
"return",
"capi",
".",
"invflattening",
"(",
"self",
".",
"ptr",
",",
"byref",
"(",
"c_int",
"(",
")",
")",
")"
] | [
249,
4
] | [
251,
59
] | python | en | ['en', 'en', 'en'] | True |
SpatialReference.geographic | (self) |
Returns True if this SpatialReference is geographic
(root node is GEOGCS).
|
Returns True if this SpatialReference is geographic
(root node is GEOGCS).
| def geographic(self):
"""
Returns True if this SpatialReference is geographic
(root node is GEOGCS).
"""
return bool(capi.isgeographic(self.ptr)) | [
"def",
"geographic",
"(",
"self",
")",
":",
"return",
"bool",
"(",
"capi",
".",
"isgeographic",
"(",
"self",
".",
"ptr",
")",
")"
] | [
255,
4
] | [
260,
48
] | python | en | ['en', 'error', 'th'] | False |
SpatialReference.local | (self) | Returns True if this SpatialReference is local (root node is LOCAL_CS). | Returns True if this SpatialReference is local (root node is LOCAL_CS). | def local(self):
"Returns True if this SpatialReference is local (root node is LOCAL_CS)."
return bool(capi.islocal(self.ptr)) | [
"def",
"local",
"(",
"self",
")",
":",
"return",
"bool",
"(",
"capi",
".",
"islocal",
"(",
"self",
".",
"ptr",
")",
")"
] | [
263,
4
] | [
265,
43
] | python | en | ['en', 'en', 'en'] | True |
SpatialReference.projected | (self) |
Returns True if this SpatialReference is a projected coordinate system
(root node is PROJCS).
|
Returns True if this SpatialReference is a projected coordinate system
(root node is PROJCS).
| def projected(self):
"""
Returns True if this SpatialReference is a projected coordinate system
(root node is PROJCS).
"""
return bool(capi.isprojected(self.ptr)) | [
"def",
"projected",
"(",
"self",
")",
":",
"return",
"bool",
"(",
"capi",
".",
"isprojected",
"(",
"self",
".",
"ptr",
")",
")"
] | [
268,
4
] | [
273,
47
] | python | en | ['en', 'error', 'th'] | False |
SpatialReference.import_epsg | (self, epsg) | Imports the Spatial Reference from the EPSG code (an integer). | Imports the Spatial Reference from the EPSG code (an integer). | def import_epsg(self, epsg):
"Imports the Spatial Reference from the EPSG code (an integer)."
capi.from_epsg(self.ptr, epsg) | [
"def",
"import_epsg",
"(",
"self",
",",
"epsg",
")",
":",
"capi",
".",
"from_epsg",
"(",
"self",
".",
"ptr",
",",
"epsg",
")"
] | [
276,
4
] | [
278,
38
] | python | en | ['en', 'en', 'en'] | True |
SpatialReference.import_proj | (self, proj) | Imports the Spatial Reference from a PROJ.4 string. | Imports the Spatial Reference from a PROJ.4 string. | def import_proj(self, proj):
"Imports the Spatial Reference from a PROJ.4 string."
capi.from_proj(self.ptr, proj) | [
"def",
"import_proj",
"(",
"self",
",",
"proj",
")",
":",
"capi",
".",
"from_proj",
"(",
"self",
".",
"ptr",
",",
"proj",
")"
] | [
280,
4
] | [
282,
38
] | python | en | ['en', 'en', 'en'] | True |
SpatialReference.import_user_input | (self, user_input) | Imports the Spatial Reference from the given user input string. | Imports the Spatial Reference from the given user input string. | def import_user_input(self, user_input):
"Imports the Spatial Reference from the given user input string."
capi.from_user_input(self.ptr, force_bytes(user_input)) | [
"def",
"import_user_input",
"(",
"self",
",",
"user_input",
")",
":",
"capi",
".",
"from_user_input",
"(",
"self",
".",
"ptr",
",",
"force_bytes",
"(",
"user_input",
")",
")"
] | [
284,
4
] | [
286,
63
] | python | en | ['en', 'en', 'en'] | True |
SpatialReference.import_wkt | (self, wkt) | Imports the Spatial Reference from OGC WKT (string) | Imports the Spatial Reference from OGC WKT (string) | def import_wkt(self, wkt):
"Imports the Spatial Reference from OGC WKT (string)"
capi.from_wkt(self.ptr, byref(c_char_p(force_bytes(wkt)))) | [
"def",
"import_wkt",
"(",
"self",
",",
"wkt",
")",
":",
"capi",
".",
"from_wkt",
"(",
"self",
".",
"ptr",
",",
"byref",
"(",
"c_char_p",
"(",
"force_bytes",
"(",
"wkt",
")",
")",
")",
")"
] | [
288,
4
] | [
290,
66
] | python | en | ['en', 'en', 'en'] | True |
SpatialReference.import_xml | (self, xml) | Imports the Spatial Reference from an XML string. | Imports the Spatial Reference from an XML string. | def import_xml(self, xml):
"Imports the Spatial Reference from an XML string."
capi.from_xml(self.ptr, xml) | [
"def",
"import_xml",
"(",
"self",
",",
"xml",
")",
":",
"capi",
".",
"from_xml",
"(",
"self",
".",
"ptr",
",",
"xml",
")"
] | [
292,
4
] | [
294,
36
] | python | en | ['en', 'en', 'en'] | True |
SpatialReference.wkt | (self) | Returns the WKT representation of this Spatial Reference. | Returns the WKT representation of this Spatial Reference. | def wkt(self):
"Returns the WKT representation of this Spatial Reference."
return capi.to_wkt(self.ptr, byref(c_char_p())) | [
"def",
"wkt",
"(",
"self",
")",
":",
"return",
"capi",
".",
"to_wkt",
"(",
"self",
".",
"ptr",
",",
"byref",
"(",
"c_char_p",
"(",
")",
")",
")"
] | [
298,
4
] | [
300,
55
] | python | en | ['en', 'en', 'en'] | True |
SpatialReference.pretty_wkt | (self, simplify=0) | Returns the 'pretty' representation of the WKT. | Returns the 'pretty' representation of the WKT. | def pretty_wkt(self, simplify=0):
"Returns the 'pretty' representation of the WKT."
return capi.to_pretty_wkt(self.ptr, byref(c_char_p()), simplify) | [
"def",
"pretty_wkt",
"(",
"self",
",",
"simplify",
"=",
"0",
")",
":",
"return",
"capi",
".",
"to_pretty_wkt",
"(",
"self",
".",
"ptr",
",",
"byref",
"(",
"c_char_p",
"(",
")",
")",
",",
"simplify",
")"
] | [
303,
4
] | [
305,
72
] | python | en | ['en', 'en', 'en'] | True |
SpatialReference.proj | (self) | Returns the PROJ.4 representation for this Spatial Reference. | Returns the PROJ.4 representation for this Spatial Reference. | def proj(self):
"Returns the PROJ.4 representation for this Spatial Reference."
return capi.to_proj(self.ptr, byref(c_char_p())) | [
"def",
"proj",
"(",
"self",
")",
":",
"return",
"capi",
".",
"to_proj",
"(",
"self",
".",
"ptr",
",",
"byref",
"(",
"c_char_p",
"(",
")",
")",
")"
] | [
308,
4
] | [
310,
56
] | python | en | ['en', 'en', 'en'] | True |
SpatialReference.proj4 | (self) | Alias for proj(). | Alias for proj(). | def proj4(self):
"Alias for proj()."
return self.proj | [
"def",
"proj4",
"(",
"self",
")",
":",
"return",
"self",
".",
"proj"
] | [
313,
4
] | [
315,
24
] | python | eo | ['es', 'eo', 'ur'] | False |
SpatialReference.xml | (self, dialect='') | Returns the XML representation of this Spatial Reference. | Returns the XML representation of this Spatial Reference. | def xml(self, dialect=''):
"Returns the XML representation of this Spatial Reference."
return capi.to_xml(self.ptr, byref(c_char_p()), force_bytes(dialect)) | [
"def",
"xml",
"(",
"self",
",",
"dialect",
"=",
"''",
")",
":",
"return",
"capi",
".",
"to_xml",
"(",
"self",
".",
"ptr",
",",
"byref",
"(",
"c_char_p",
"(",
")",
")",
",",
"force_bytes",
"(",
"dialect",
")",
")"
] | [
318,
4
] | [
320,
77
] | python | en | ['en', 'en', 'en'] | True |
CoordTransform.__init__ | (self, source, target) | Initializes on a source and target SpatialReference objects. | Initializes on a source and target SpatialReference objects. | def __init__(self, source, target):
"Initializes on a source and target SpatialReference objects."
if not isinstance(source, SpatialReference) or not isinstance(target, SpatialReference):
raise TypeError('source and target must be of type SpatialReference')
self.ptr = capi.new_ct(sou... | [
"def",
"__init__",
"(",
"self",
",",
"source",
",",
"target",
")",
":",
"if",
"not",
"isinstance",
"(",
"source",
",",
"SpatialReference",
")",
"or",
"not",
"isinstance",
"(",
"target",
",",
"SpatialReference",
")",
":",
"raise",
"TypeError",
"(",
"'source... | [
327,
4
] | [
333,
37
] | python | en | ['en', 'en', 'en'] | True |
get_field_size | (name) | Extract the size number from a "varchar(11)" type name | Extract the size number from a "varchar(11)" type name | def get_field_size(name):
""" Extract the size number from a "varchar(11)" type name """
m = field_size_re.search(name)
return int(m.group(1)) if m else None | [
"def",
"get_field_size",
"(",
"name",
")",
":",
"m",
"=",
"field_size_re",
".",
"search",
"(",
"name",
")",
"return",
"int",
"(",
"m",
".",
"group",
"(",
"1",
")",
")",
"if",
"m",
"else",
"None"
] | [
12,
0
] | [
15,
41
] | python | en | ['en', 'en', 'en'] | True |
DatabaseIntrospection.get_table_list | (self, cursor) |
Returns a list of table and view names in the current database.
|
Returns a list of table and view names in the current database.
| def get_table_list(self, cursor):
"""
Returns a list of table and view names in the current database.
"""
# Skip the sqlite_sequence system table used for autoincrement key
# generation.
cursor.execute("""
SELECT name, type FROM sqlite_master
WHERE... | [
"def",
"get_table_list",
"(",
"self",
",",
"cursor",
")",
":",
"# Skip the sqlite_sequence system table used for autoincrement key",
"# generation.",
"cursor",
".",
"execute",
"(",
"\"\"\"\n SELECT name, type FROM sqlite_master\n WHERE type in ('table', 'view') AND ... | [
59,
4
] | [
69,
74
] | python | en | ['en', 'error', 'th'] | False |
DatabaseIntrospection.get_table_description | (self, cursor, table_name) | Returns a description of the table, with the DB-API cursor.description interface. | Returns a description of the table, with the DB-API cursor.description interface. | def get_table_description(self, cursor, table_name):
"Returns a description of the table, with the DB-API cursor.description interface."
return [
FieldInfo(
info['name'],
info['type'],
None,
info['size'],
None,
... | [
"def",
"get_table_description",
"(",
"self",
",",
"cursor",
",",
"table_name",
")",
":",
"return",
"[",
"FieldInfo",
"(",
"info",
"[",
"'name'",
"]",
",",
"info",
"[",
"'type'",
"]",
",",
"None",
",",
"info",
"[",
"'size'",
"]",
",",
"None",
",",
"No... | [
71,
4
] | [
84,
9
] | python | en | ['en', 'fr', 'en'] | True |
DatabaseIntrospection.column_name_converter | (self, name) |
SQLite will in some cases, e.g. when returning columns from views and
subselects, return column names in 'alias."column"' format instead of
simply 'column'.
Affects SQLite < 3.7.15, fixed by http://www.sqlite.org/src/info/5526e0aa3c
|
SQLite will in some cases, e.g. when returning columns from views and
subselects, return column names in 'alias."column"' format instead of
simply 'column'. | def column_name_converter(self, name):
"""
SQLite will in some cases, e.g. when returning columns from views and
subselects, return column names in 'alias."column"' format instead of
simply 'column'.
Affects SQLite < 3.7.15, fixed by http://www.sqlite.org/src/info/5526e0aa3c
... | [
"def",
"column_name_converter",
"(",
"self",
",",
"name",
")",
":",
"# TODO: remove when SQLite < 3.7.15 is sufficiently old.",
"# 3.7.13 ships in Debian stable as of 2014-03-21.",
"if",
"self",
".",
"connection",
".",
"Database",
".",
"sqlite_version_info",
"<",
"(",
"3",
... | [
86,
4
] | [
99,
23
] | python | en | ['en', 'error', 'th'] | False |
DatabaseIntrospection.get_relations | (self, cursor, table_name) |
Return a dictionary of {field_name: (field_name_other_table, other_table)}
representing all relationships to the given table.
|
Return a dictionary of {field_name: (field_name_other_table, other_table)}
representing all relationships to the given table.
| def get_relations(self, cursor, table_name):
"""
Return a dictionary of {field_name: (field_name_other_table, other_table)}
representing all relationships to the given table.
"""
# Dictionary of relations to return
relations = {}
# Schema for this table
c... | [
"def",
"get_relations",
"(",
"self",
",",
"cursor",
",",
"table_name",
")",
":",
"# Dictionary of relations to return",
"relations",
"=",
"{",
"}",
"# Schema for this table",
"cursor",
".",
"execute",
"(",
"\"SELECT sql FROM sqlite_master WHERE tbl_name = %s AND type = %s\"",... | [
101,
4
] | [
154,
24
] | python | en | ['en', 'error', 'th'] | False |
DatabaseIntrospection.get_key_columns | (self, cursor, table_name) |
Returns a list of (column_name, referenced_table_name, referenced_column_name) for all
key columns in given table.
|
Returns a list of (column_name, referenced_table_name, referenced_column_name) for all
key columns in given table.
| def get_key_columns(self, cursor, table_name):
"""
Returns a list of (column_name, referenced_table_name, referenced_column_name) for all
key columns in given table.
"""
key_columns = []
# Schema for this table
cursor.execute("SELECT sql FROM sqlite_master WHERE ... | [
"def",
"get_key_columns",
"(",
"self",
",",
"cursor",
",",
"table_name",
")",
":",
"key_columns",
"=",
"[",
"]",
"# Schema for this table",
"cursor",
".",
"execute",
"(",
"\"SELECT sql FROM sqlite_master WHERE tbl_name = %s AND type = %s\"",
",",
"[",
"table_name",
",",... | [
156,
4
] | [
183,
26
] | python | en | ['en', 'error', 'th'] | False |
DatabaseIntrospection.get_primary_key_column | (self, cursor, table_name) |
Get the column name of the primary key for the given table.
|
Get the column name of the primary key for the given table.
| def get_primary_key_column(self, cursor, table_name):
"""
Get the column name of the primary key for the given table.
"""
# Don't use PRAGMA because that causes issues with some transactions
cursor.execute("SELECT sql FROM sqlite_master WHERE tbl_name = %s AND type = %s", [table_... | [
"def",
"get_primary_key_column",
"(",
"self",
",",
"cursor",
",",
"table_name",
")",
":",
"# Don't use PRAGMA because that causes issues with some transactions",
"cursor",
".",
"execute",
"(",
"\"SELECT sql FROM sqlite_master WHERE tbl_name = %s AND type = %s\"",
",",
"[",
"table... | [
208,
4
] | [
224,
19
] | python | en | ['en', 'error', 'th'] | False |
DatabaseIntrospection.get_constraints | (self, cursor, table_name) |
Retrieves any constraints or keys (unique, pk, fk, check, index) across one or more columns.
|
Retrieves any constraints or keys (unique, pk, fk, check, index) across one or more columns.
| def get_constraints(self, cursor, table_name):
"""
Retrieves any constraints or keys (unique, pk, fk, check, index) across one or more columns.
"""
constraints = {}
# Get the index info
cursor.execute("PRAGMA index_list(%s)" % self.connection.ops.quote_name(table_name))
... | [
"def",
"get_constraints",
"(",
"self",
",",
"cursor",
",",
"table_name",
")",
":",
"constraints",
"=",
"{",
"}",
"# Get the index info",
"cursor",
".",
"execute",
"(",
"\"PRAGMA index_list(%s)\"",
"%",
"self",
".",
"connection",
".",
"ops",
".",
"quote_name",
... | [
238,
4
] | [
291,
26
] | python | en | ['en', 'error', 'th'] | False |
check_emoji_admin | (user_profile: UserProfile, emoji_name: Optional[str] = None) | Raises an exception if the user cannot administer the target realm
emoji name in their organization. | Raises an exception if the user cannot administer the target realm
emoji name in their organization. | def check_emoji_admin(user_profile: UserProfile, emoji_name: Optional[str] = None) -> None:
"""Raises an exception if the user cannot administer the target realm
emoji name in their organization."""
# Realm administrators can always administer emoji
if user_profile.is_realm_admin:
return
if... | [
"def",
"check_emoji_admin",
"(",
"user_profile",
":",
"UserProfile",
",",
"emoji_name",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
")",
"->",
"None",
":",
"# Realm administrators can always administer emoji",
"if",
"user_profile",
".",
"is_realm_admin",
":",
"re... | [
87,
0
] | [
109,
87
] | python | en | ['en', 'en', 'en'] | True |
StreamField.formfield | (self, **kwargs) |
Override formfield to use a plain forms.Field so that we do no transformation on the value
(as distinct from the usual fallback of forms.CharField, which transforms it into a string).
|
Override formfield to use a plain forms.Field so that we do no transformation on the value
(as distinct from the usual fallback of forms.CharField, which transforms it into a string).
| def formfield(self, **kwargs):
"""
Override formfield to use a plain forms.Field so that we do no transformation on the value
(as distinct from the usual fallback of forms.CharField, which transforms it into a string).
"""
defaults = {'form_class': BlockField, 'block': self.strea... | [
"def",
"formfield",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"defaults",
"=",
"{",
"'form_class'",
":",
"BlockField",
",",
"'block'",
":",
"self",
".",
"stream_block",
"}",
"defaults",
".",
"update",
"(",
"kwargs",
")",
"return",
"super",
"(",
"... | [
149,
4
] | [
156,
44
] | python | en | ['en', 'error', 'th'] | False |
email_is_not_mit_mailing_list | (email: str) | Prevent MIT mailing lists from signing up for Zulip | Prevent MIT mailing lists from signing up for Zulip | def email_is_not_mit_mailing_list(email: str) -> None:
"""Prevent MIT mailing lists from signing up for Zulip"""
if "@mit.edu" in email:
username = email.rsplit("@", 1)[0]
# Check whether the user exists and can get mail.
try:
DNS.dnslookup(f"{username}.pobox.ns.athena.mit.ed... | [
"def",
"email_is_not_mit_mailing_list",
"(",
"email",
":",
"str",
")",
"->",
"None",
":",
"if",
"\"@mit.edu\"",
"in",
"email",
":",
"username",
"=",
"email",
".",
"rsplit",
"(",
"\"@\"",
",",
"1",
")",
"[",
"0",
"]",
"# Check whether the user exists and can ge... | [
71,
0
] | [
82,
60
] | python | en | ['en', 'en', 'en'] | True |
HomepageForm.clean_email | (self) | Returns the email if and only if the user's email address is
allowed to join the realm they are trying to join. | Returns the email if and only if the user's email address is
allowed to join the realm they are trying to join. | def clean_email(self) -> str:
"""Returns the email if and only if the user's email address is
allowed to join the realm they are trying to join."""
email = self.cleaned_data["email"]
# Otherwise, the user is trying to join a specific realm.
realm = self.realm
from_multiu... | [
"def",
"clean_email",
"(",
"self",
")",
"->",
"str",
":",
"email",
"=",
"self",
".",
"cleaned_data",
"[",
"\"email\"",
"]",
"# Otherwise, the user is trying to join a specific realm.",
"realm",
"=",
"self",
".",
"realm",
"from_multiuse_invite",
"=",
"self",
".",
"... | [
170,
4
] | [
225,
20
] | python | en | ['en', 'en', 'en'] | True |
ZulipPasswordResetForm.save | (
self,
domain_override: Optional[bool] = None,
subject_template_name: str = "registration/password_reset_subject.txt",
email_template_name: str = "registration/password_reset_email.html",
use_https: bool = False,
token_generator: PasswordResetTokenGenerator = default_tok... |
If the email address has an account in the target realm,
generates a one-use only link for resetting password and sends
to the user.
We send a different email if an associated account does not exist in the
database, or an account does exist, but not in the realm.
Note:... |
If the email address has an account in the target realm,
generates a one-use only link for resetting password and sends
to the user. | def save(
self,
domain_override: Optional[bool] = None,
subject_template_name: str = "registration/password_reset_subject.txt",
email_template_name: str = "registration/password_reset_email.html",
use_https: bool = False,
token_generator: PasswordResetTokenGenerator = def... | [
"def",
"save",
"(",
"self",
",",
"domain_override",
":",
"Optional",
"[",
"bool",
"]",
"=",
"None",
",",
"subject_template_name",
":",
"str",
"=",
"\"registration/password_reset_subject.txt\"",
",",
"email_template_name",
":",
"str",
"=",
"\"registration/password_rese... | [
277,
4
] | [
369,
13
] | python | en | ['en', 'error', 'th'] | False |
OurAuthenticationForm.add_prefix | (self, field_name: str) | Disable prefix, since Zulip doesn't use this Django forms feature
(and django-two-factor does use it), and we'd like both to be
happy with this form.
| Disable prefix, since Zulip doesn't use this Django forms feature
(and django-two-factor does use it), and we'd like both to be
happy with this form.
| def add_prefix(self, field_name: str) -> str:
"""Disable prefix, since Zulip doesn't use this Django forms feature
(and django-two-factor does use it), and we'd like both to be
happy with this form.
"""
return field_name | [
"def",
"add_prefix",
"(",
"self",
",",
"field_name",
":",
"str",
")",
"->",
"str",
":",
"return",
"field_name"
] | [
447,
4
] | [
452,
25
] | python | en | ['en', 'en', 'en'] | True |
MultiEmailField.to_python | (self, emails: str) | Normalize data to a list of strings. | Normalize data to a list of strings. | def to_python(self, emails: str) -> List[str]:
"""Normalize data to a list of strings."""
if not emails:
return []
return [email.strip() for email in emails.split(",")] | [
"def",
"to_python",
"(",
"self",
",",
"emails",
":",
"str",
")",
"->",
"List",
"[",
"str",
"]",
":",
"if",
"not",
"emails",
":",
"return",
"[",
"]",
"return",
"[",
"email",
".",
"strip",
"(",
")",
"for",
"email",
"in",
"emails",
".",
"split",
"("... | [
468,
4
] | [
473,
61
] | python | en | ['en', 'en', 'en'] | True |
MultiEmailField.validate | (self, emails: List[str]) | Check if value consists only of valid emails. | Check if value consists only of valid emails. | def validate(self, emails: List[str]) -> None:
"""Check if value consists only of valid emails."""
super().validate(emails)
for email in emails:
validate_email(email) | [
"def",
"validate",
"(",
"self",
",",
"emails",
":",
"List",
"[",
"str",
"]",
")",
"->",
"None",
":",
"super",
"(",
")",
".",
"validate",
"(",
"emails",
")",
"for",
"email",
"in",
"emails",
":",
"validate_email",
"(",
"email",
")"
] | [
475,
4
] | [
479,
33
] | python | en | ['en', 'en', 'en'] | True |
_reproject_and_scale | (gdir, do_error=False) | Reproject and scale itslive data, avoid code duplication for error | Reproject and scale itslive data, avoid code duplication for error | def _reproject_and_scale(gdir, do_error=False):
"""Reproject and scale itslive data, avoid code duplication for error"""
reg = find_region(gdir)
if reg is None:
raise InvalidWorkflowError('There does not seem to be its_live data '
'available for this glacier')
... | [
"def",
"_reproject_and_scale",
"(",
"gdir",
",",
"do_error",
"=",
"False",
")",
":",
"reg",
"=",
"find_region",
"(",
"gdir",
")",
"if",
"reg",
"is",
"None",
":",
"raise",
"InvalidWorkflowError",
"(",
"'There does not seem to be its_live data '",
"'available for this... | [
77,
0
] | [
180,
32
] | python | en | ['en', 'en', 'en'] | True |
velocity_to_gdir | (gdir, add_error=False) | Reproject the its_live files to the given glacier directory.
The data source used is https://its-live.jpl.nasa.gov/#data
Currently the only data downloaded is the 120m composite for both
(u, v) and their uncertainty. The composite is computed from the
1985 to 2018 average.
Variables are added to t... | Reproject the its_live files to the given glacier directory. | def velocity_to_gdir(gdir, add_error=False):
"""Reproject the its_live files to the given glacier directory.
The data source used is https://its-live.jpl.nasa.gov/#data
Currently the only data downloaded is the 120m composite for both
(u, v) and their uncertainty. The composite is computed from the
... | [
"def",
"velocity_to_gdir",
"(",
"gdir",
",",
"add_error",
"=",
"False",
")",
":",
"if",
"not",
"gdir",
".",
"has_file",
"(",
"'gridded_data'",
")",
":",
"raise",
"InvalidWorkflowError",
"(",
"'Please run `glacier_masks` before running '",
"'this task'",
")",
"_repro... | [
184,
0
] | [
221,
49
] | python | en | ['en', 'en', 'en'] | True |
SearchableQuerySetMixin.search | (self, query, fields=None,
operator=None, order_by_relevance=True, partial_match=True, backend='default') |
This runs a search query on all the items in the QuerySet
|
This runs a search query on all the items in the QuerySet
| def search(self, query, fields=None,
operator=None, order_by_relevance=True, partial_match=True, backend='default'):
"""
This runs a search query on all the items in the QuerySet
"""
search_backend = get_search_backend(backend)
return search_backend.search(query, s... | [
"def",
"search",
"(",
"self",
",",
"query",
",",
"fields",
"=",
"None",
",",
"operator",
"=",
"None",
",",
"order_by_relevance",
"=",
"True",
",",
"partial_match",
"=",
"True",
",",
"backend",
"=",
"'default'",
")",
":",
"search_backend",
"=",
"get_search_... | [
4,
4
] | [
11,
123
] | python | en | ['en', 'error', 'th'] | False |
SearchableQuerySetMixin.autocomplete | (self, query, fields=None,
operator=None, order_by_relevance=True, backend='default') |
This runs an autocomplete query on all the items in the QuerySet
|
This runs an autocomplete query on all the items in the QuerySet
| def autocomplete(self, query, fields=None,
operator=None, order_by_relevance=True, backend='default'):
"""
This runs an autocomplete query on all the items in the QuerySet
"""
search_backend = get_search_backend(backend)
return search_backend.autocomplete(que... | [
"def",
"autocomplete",
"(",
"self",
",",
"query",
",",
"fields",
"=",
"None",
",",
"operator",
"=",
"None",
",",
"order_by_relevance",
"=",
"True",
",",
"backend",
"=",
"'default'",
")",
":",
"search_backend",
"=",
"get_search_backend",
"(",
"backend",
")",
... | [
13,
4
] | [
20,
100
] | python | en | ['en', 'error', 'th'] | False |
show | (obj) | Show the dump of the properties of the object. | Show the dump of the properties of the object. | def show(obj):
'''Show the dump of the properties of the object.'''
pprint(vars(obj)) | [
"def",
"show",
"(",
"obj",
")",
":",
"pprint",
"(",
"vars",
"(",
"obj",
")",
")"
] | [
4,
0
] | [
6,
21
] | python | en | ['en', 'en', 'en'] | True |
start | (io_loop=None, check_time=500) | Begins watching source files for changes.
.. versionchanged:: 4.1
The ``io_loop`` argument is deprecated.
| Begins watching source files for changes. | def start(io_loop=None, check_time=500):
"""Begins watching source files for changes.
.. versionchanged:: 4.1
The ``io_loop`` argument is deprecated.
"""
io_loop = io_loop or ioloop.IOLoop.current()
if io_loop in _io_loops:
return
_io_loops[io_loop] = True
if len(_io_loops) >... | [
"def",
"start",
"(",
"io_loop",
"=",
"None",
",",
"check_time",
"=",
"500",
")",
":",
"io_loop",
"=",
"io_loop",
"or",
"ioloop",
".",
"IOLoop",
".",
"current",
"(",
")",
"if",
"io_loop",
"in",
"_io_loops",
":",
"return",
"_io_loops",
"[",
"io_loop",
"]... | [
83,
0
] | [
98,
21
] | python | en | ['en', 'en', 'en'] | True |
wait | () | Wait for a watched file to change, then restart the process.
Intended to be used at the end of scripts like unit test runners,
to run the tests again after any source file changes (but see also
the command-line interface in `main`)
| Wait for a watched file to change, then restart the process. | def wait():
"""Wait for a watched file to change, then restart the process.
Intended to be used at the end of scripts like unit test runners,
to run the tests again after any source file changes (but see also
the command-line interface in `main`)
"""
io_loop = ioloop.IOLoop()
start(io_loop)... | [
"def",
"wait",
"(",
")",
":",
"io_loop",
"=",
"ioloop",
".",
"IOLoop",
"(",
")",
"start",
"(",
"io_loop",
")",
"io_loop",
".",
"start",
"(",
")"
] | [
101,
0
] | [
110,
19
] | python | en | ['en', 'en', 'en'] | True |
watch | (filename) | Add a file to the watch list.
All imported modules are watched by default.
| Add a file to the watch list. | def watch(filename):
"""Add a file to the watch list.
All imported modules are watched by default.
"""
_watched_files.add(filename) | [
"def",
"watch",
"(",
"filename",
")",
":",
"_watched_files",
".",
"add",
"(",
"filename",
")"
] | [
113,
0
] | [
118,
32
] | python | en | ['en', 'en', 'en'] | True |
add_reload_hook | (fn) | Add a function to be called before reloading the process.
Note that for open file and socket handles it is generally
preferable to set the ``FD_CLOEXEC`` flag (using `fcntl` or
``tornado.platform.auto.set_close_exec``) instead
of using a reload hook to close them.
| Add a function to be called before reloading the process. | def add_reload_hook(fn):
"""Add a function to be called before reloading the process.
Note that for open file and socket handles it is generally
preferable to set the ``FD_CLOEXEC`` flag (using `fcntl` or
``tornado.platform.auto.set_close_exec``) instead
of using a reload hook to close them.
""... | [
"def",
"add_reload_hook",
"(",
"fn",
")",
":",
"_reload_hooks",
".",
"append",
"(",
"fn",
")"
] | [
121,
0
] | [
129,
28
] | python | en | ['en', 'en', 'en'] | True |
Tracing.start | (self, options: dict = None, **kwargs: Any) | Start tracing.
Only one trace can be active at a time per browser.
This method accepts the following options:
* ``path`` (str): A path to write the trace file to.
* ``screenshots`` (bool): Capture screenshots in the trace.
* ``categories`` (List[str]): Specify custom categorie... | Start tracing. | async def start(self, options: dict = None, **kwargs: Any) -> None:
"""Start tracing.
Only one trace can be active at a time per browser.
This method accepts the following options:
* ``path`` (str): A path to write the trace file to.
* ``screenshots`` (bool): Capture screensho... | [
"async",
"def",
"start",
"(",
"self",
",",
"options",
":",
"dict",
"=",
"None",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"None",
":",
"options",
"=",
"merge_dict",
"(",
"options",
",",
"kwargs",
")",
"defaultCategories",
"=",
"[",
"'-*'",
",",... | [
31,
4
] | [
63,
10
] | python | en | ['en', 'ja', 'en'] | False |
Tracing.stop | (self) | Stop tracing.
:return: trace data as string.
| Stop tracing. | async def stop(self) -> str:
"""Stop tracing.
:return: trace data as string.
"""
contentPromise = self._client._loop.create_future()
self._client.once(
'Tracing.tracingComplete',
lambda event: self._client._loop.create_task(
self._readStre... | [
"async",
"def",
"stop",
"(",
"self",
")",
"->",
"str",
":",
"contentPromise",
"=",
"self",
".",
"_client",
".",
"_loop",
".",
"create_future",
"(",
")",
"self",
".",
"_client",
".",
"once",
"(",
"'Tracing.tracingComplete'",
",",
"lambda",
"event",
":",
"... | [
65,
4
] | [
81,
35
] | python | en | ['es', 'en', 'en'] | False |
pre_deploy | () | Add, commit and push the Git repo before final deployment. | Add, commit and push the Git repo before final deployment. | def pre_deploy():
'''Add, commit and push the Git repo before final deployment.'''
local("git add -p && git commit")
local("git push") | [
"def",
"pre_deploy",
"(",
")",
":",
"local",
"(",
"\"git add -p && git commit\"",
")",
"local",
"(",
"\"git push\"",
")"
] | [
45,
0
] | [
48,
22
] | python | en | ['en', 'en', 'en'] | True |
deploy | () | Final deployment of the application | Final deployment of the application | def deploy():
global code_dir
'''Final deployment of the application'''
with cd(code_dir):
run("git pull")
run("touch flask_application.wsgi") | [
"def",
"deploy",
"(",
")",
":",
"global",
"code_dir",
"with",
"cd",
"(",
"code_dir",
")",
":",
"run",
"(",
"\"git pull\"",
")",
"run",
"(",
"\"touch flask_application.wsgi\"",
")"
] | [
51,
0
] | [
56,
43
] | python | en | ['en', 'en', 'en'] | True |
init | (site_name=SITE_NAME) | Call env_setup, env_init, and skeletonize for one-step init | Call env_setup, env_init, and skeletonize for one-step init | def init(site_name=SITE_NAME):
'''Call env_setup, env_init, and skeletonize for one-step init'''
print green(u"Call env_setup, env_init, and skeletonize for one-step init:")
env_setup()
env_init(site_name=site_name)
skeletonize() | [
"def",
"init",
"(",
"site_name",
"=",
"SITE_NAME",
")",
":",
"print",
"green",
"(",
"u\"Call env_setup, env_init, and skeletonize for one-step init:\"",
")",
"env_setup",
"(",
")",
"env_init",
"(",
"site_name",
"=",
"site_name",
")",
"skeletonize",
"(",
")"
] | [
60,
0
] | [
65,
17
] | python | en | ['en', 'en', 'en'] | True |
env_init | (site_name=SITE_NAME) | Initialize with this site hostname. | Initialize with this site hostname. | def env_init(site_name=SITE_NAME):
'''Initialize with this site hostname.'''
print green(u"Initializing new site configuration...")
#
# Generate secret key and update config file
#
import random
import string
CHARS = string.letters + string.digits
SECRET_KEY = "".join([random.choic... | [
"def",
"env_init",
"(",
"site_name",
"=",
"SITE_NAME",
")",
":",
"print",
"green",
"(",
"u\"Initializing new site configuration...\"",
")",
"#",
"# Generate secret key and update config file",
"#",
"import",
"random",
"import",
"string",
"CHARS",
"=",
"string",
".",
"... | [
68,
0
] | [
104,
15
] | python | en | ['en', 'en', 'en'] | True |
env_setup | () | Initialize environment with requisite Python modules. | Initialize environment with requisite Python modules. | def env_setup():
'''Initialize environment with requisite Python modules.'''
print green("Installing requisite modules...")
# Install our requistite modules for the website.
sh.pip("install", r="requirements.txt")
import platform
if platform.python_version_tuple() < (2,7):
sh.pip("inst... | [
"def",
"env_setup",
"(",
")",
":",
"print",
"green",
"(",
"\"Installing requisite modules...\"",
")",
"# Install our requistite modules for the website.",
"sh",
".",
"pip",
"(",
"\"install\"",
",",
"r",
"=",
"\"requirements.txt\"",
")",
"import",
"platform",
"if",
"pl... | [
108,
0
] | [
117,
38
] | python | en | ['en', 'en', 'en'] | True |
skeletonize | () | Update Skeleton HTML5-Boilerplate. | Update Skeleton HTML5-Boilerplate. | def skeletonize():
'''Update Skeleton HTML5-Boilerplate.'''
print green("Skeletonizing the project directory...")
# Skeleton
print blue("Installing skeleton HTML5 Boilerplate.")
os.chdir(PROJ_DIR)
sh.git.submodule.update(init=True)
os.chdir(PROJ_DIR + "/skeleton")
sh.git.pull("origin",... | [
"def",
"skeletonize",
"(",
")",
":",
"print",
"green",
"(",
"\"Skeletonizing the project directory...\"",
")",
"# Skeleton",
"print",
"blue",
"(",
"\"Installing skeleton HTML5 Boilerplate.\"",
")",
"os",
".",
"chdir",
"(",
"PROJ_DIR",
")",
"sh",
".",
"git",
".",
"... | [
121,
0
] | [
149,
22
] | python | af | ['en', 'af', 'it'] | False |
console | () | Load the application in an interactive console. | Load the application in an interactive console. | def console():
'''Load the application in an interactive console.'''
local('env DEV=yes python -i runserver.py', capture=False) | [
"def",
"console",
"(",
")",
":",
"local",
"(",
"'env DEV=yes python -i runserver.py'",
",",
"capture",
"=",
"False",
")"
] | [
154,
0
] | [
156,
62
] | python | en | ['en', 'en', 'en'] | True |
server | () | Run the dev server | Run the dev server | def server():
'''Run the dev server'''
os.chdir(PROJ_DIR)
local('env DEV=yes python runserver.py', capture=False) | [
"def",
"server",
"(",
")",
":",
"os",
".",
"chdir",
"(",
"PROJ_DIR",
")",
"local",
"(",
"'env DEV=yes python runserver.py'",
",",
"capture",
"=",
"False",
")"
] | [
159,
0
] | [
162,
59
] | python | en | ['en', 'ku', 'en'] | True |
test | () | Run the test suite | Run the test suite | def test():
'''Run the test suite'''
local('env TEST=yes python tests.py', capture=False) | [
"def",
"test",
"(",
")",
":",
"local",
"(",
"'env TEST=yes python tests.py'",
",",
"capture",
"=",
"False",
")"
] | [
165,
0
] | [
167,
56
] | python | en | ['en', 'en', 'en'] | True |
clean | () | Clear the cached .pyc files. | Clear the cached .pyc files. | def clean():
'''Clear the cached .pyc files.'''
local("find . \( -iname '*.pyc' -o -name '*~' \) -exec rm -v {} \;", capture=False) | [
"def",
"clean",
"(",
")",
":",
"local",
"(",
"\"find . \\( -iname '*.pyc' -o -name '*~' \\) -exec rm -v {} \\;\"",
",",
"capture",
"=",
"False",
")"
] | [
170,
0
] | [
172,
87
] | python | en | ['en', 'en', 'en'] | True |
find_commands | (management_dir) |
Given a path to a management directory, returns a list of all the command
names that are available.
Returns an empty list if no commands are defined.
|
Given a path to a management directory, returns a list of all the command
names that are available. | def find_commands(management_dir):
"""
Given a path to a management directory, returns a list of all the command
names that are available.
Returns an empty list if no commands are defined.
"""
command_dir = os.path.join(management_dir, 'commands')
return [name for _, name, is_pkg in pkgutil... | [
"def",
"find_commands",
"(",
"management_dir",
")",
":",
"command_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"management_dir",
",",
"'commands'",
")",
"return",
"[",
"name",
"for",
"_",
",",
"name",
",",
"is_pkg",
"in",
"pkgutil",
".",
"iter_modules",... | [
21,
0
] | [
30,
55
] | python | en | ['en', 'error', 'th'] | False |
load_command_class | (app_name, name) |
Given a command name and an application name, returns the Command
class instance. All errors raised by the import process
(ImportError, AttributeError) are allowed to propagate.
|
Given a command name and an application name, returns the Command
class instance. All errors raised by the import process
(ImportError, AttributeError) are allowed to propagate.
| def load_command_class(app_name, name):
"""
Given a command name and an application name, returns the Command
class instance. All errors raised by the import process
(ImportError, AttributeError) are allowed to propagate.
"""
module = import_module('%s.management.commands.%s' % (app_name, name))... | [
"def",
"load_command_class",
"(",
"app_name",
",",
"name",
")",
":",
"module",
"=",
"import_module",
"(",
"'%s.management.commands.%s'",
"%",
"(",
"app_name",
",",
"name",
")",
")",
"return",
"module",
".",
"Command",
"(",
")"
] | [
33,
0
] | [
40,
27
] | python | en | ['en', 'error', 'th'] | False |
get_commands | () |
Returns a dictionary mapping command names to their callback applications.
This works by looking for a management.commands package in django.core, and
in each installed application -- if a commands package exists, all commands
in that package are registered.
Core commands are always included. If ... |
Returns a dictionary mapping command names to their callback applications. | def get_commands():
"""
Returns a dictionary mapping command names to their callback applications.
This works by looking for a management.commands package in django.core, and
in each installed application -- if a commands package exists, all commands
in that package are registered.
Core comman... | [
"def",
"get_commands",
"(",
")",
":",
"commands",
"=",
"{",
"name",
":",
"'django.core'",
"for",
"name",
"in",
"find_commands",
"(",
"upath",
"(",
"__path__",
"[",
"0",
"]",
")",
")",
"}",
"if",
"not",
"settings",
".",
"configured",
":",
"return",
"com... | [
44,
0
] | [
75,
19
] | python | en | ['en', 'error', 'th'] | False |
call_command | (command_name, *args, **options) |
Calls the given command, with the given options and args/kwargs.
This is the primary API you should use for calling specific commands.
`name` may be a string or a command object. Using a string is preferred
unless the command object is required for further processing or testing.
Some examples:
... |
Calls the given command, with the given options and args/kwargs. | def call_command(command_name, *args, **options):
"""
Calls the given command, with the given options and args/kwargs.
This is the primary API you should use for calling specific commands.
`name` may be a string or a command object. Using a string is preferred
unless the command object is required... | [
"def",
"call_command",
"(",
"command_name",
",",
"*",
"args",
",",
"*",
"*",
"options",
")",
":",
"if",
"isinstance",
"(",
"command_name",
",",
"BaseCommand",
")",
":",
"# Command object passed in.",
"command",
"=",
"command_name",
"command_name",
"=",
"command"... | [
78,
0
] | [
129,
45
] | python | en | ['en', 'error', 'th'] | False |
execute_from_command_line | (argv=None) |
A simple method that runs a ManagementUtility.
|
A simple method that runs a ManagementUtility.
| def execute_from_command_line(argv=None):
"""
A simple method that runs a ManagementUtility.
"""
utility = ManagementUtility(argv)
utility.execute() | [
"def",
"execute_from_command_line",
"(",
"argv",
"=",
"None",
")",
":",
"utility",
"=",
"ManagementUtility",
"(",
"argv",
")",
"utility",
".",
"execute",
"(",
")"
] | [
357,
0
] | [
362,
21
] | python | en | ['en', 'error', 'th'] | False |
ManagementUtility.main_help_text | (self, commands_only=False) |
Returns the script's main help text, as a string.
|
Returns the script's main help text, as a string.
| def main_help_text(self, commands_only=False):
"""
Returns the script's main help text, as a string.
"""
if commands_only:
usage = sorted(get_commands().keys())
else:
usage = [
"",
"Type '%s help <subcommand>' for help on a ... | [
"def",
"main_help_text",
"(",
"self",
",",
"commands_only",
"=",
"False",
")",
":",
"if",
"commands_only",
":",
"usage",
"=",
"sorted",
"(",
"get_commands",
"(",
")",
".",
"keys",
"(",
")",
")",
"else",
":",
"usage",
"=",
"[",
"\"\"",
",",
"\"Type '%s ... | [
141,
4
] | [
174,
31
] | python | en | ['en', 'error', 'th'] | False |
ManagementUtility.fetch_command | (self, subcommand) |
Tries to fetch the given subcommand, printing a message with the
appropriate command called from the command line (usually
"django-admin" or "manage.py") if it can't be found.
|
Tries to fetch the given subcommand, printing a message with the
appropriate command called from the command line (usually
"django-admin" or "manage.py") if it can't be found.
| def fetch_command(self, subcommand):
"""
Tries to fetch the given subcommand, printing a message with the
appropriate command called from the command line (usually
"django-admin" or "manage.py") if it can't be found.
"""
# Get commands outside of try block to prevent swal... | [
"def",
"fetch_command",
"(",
"self",
",",
"subcommand",
")",
":",
"# Get commands outside of try block to prevent swallowing exceptions",
"commands",
"=",
"get_commands",
"(",
")",
"try",
":",
"app_name",
"=",
"commands",
"[",
"subcommand",
"]",
"except",
"KeyError",
... | [
176,
4
] | [
205,
20
] | python | en | ['en', 'error', 'th'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.