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
LayerMapping.verify_geom
(self, geom, model_field)
Verify the geometry -- construct and return a GeometryCollection if necessary (for example if the model field is MultiPolygonField while the mapped shapefile only contains Polygons).
Verify the geometry -- construct and return a GeometryCollection if necessary (for example if the model field is MultiPolygonField while the mapped shapefile only contains Polygons).
def verify_geom(self, geom, model_field): """ Verify the geometry -- construct and return a GeometryCollection if necessary (for example if the model field is MultiPolygonField while the mapped shapefile only contains Polygons). """ # Downgrade a 3D geom to a 2D one, if n...
[ "def", "verify_geom", "(", "self", ",", "geom", ",", "model_field", ")", ":", "# Downgrade a 3D geom to a 2D one, if necessary.", "if", "self", ".", "coord_dim", "!=", "geom", ".", "coord_dim", ":", "geom", ".", "coord_dim", "=", "self", ".", "coord_dim", "if", ...
[ 422, 4 ]
[ 447, 20 ]
python
en
['en', 'error', 'th']
False
LayerMapping.coord_transform
(self)
Return the coordinate transformation object.
Return the coordinate transformation object.
def coord_transform(self): "Return the coordinate transformation object." SpatialRefSys = self.spatial_backend.spatial_ref_sys() try: # Getting the target spatial reference system target_srs = SpatialRefSys.objects.using(self.using).get(srid=self.geo_field.srid).srs ...
[ "def", "coord_transform", "(", "self", ")", ":", "SpatialRefSys", "=", "self", ".", "spatial_backend", ".", "spatial_ref_sys", "(", ")", "try", ":", "# Getting the target spatial reference system", "target_srs", "=", "SpatialRefSys", ".", "objects", ".", "using", "(...
[ 450, 4 ]
[ 462, 22 ]
python
en
['en', 'en', 'en']
True
LayerMapping.geometry_field
(self)
Return the GeometryField instance associated with the geographic column.
Return the GeometryField instance associated with the geographic column.
def geometry_field(self): "Return the GeometryField instance associated with the geographic column." # Use `get_field()` on the model's options so that we # get the correct field instance if there's model inheritance. opts = self.model._meta return opts.get_field(self.geom_field)
[ "def", "geometry_field", "(", "self", ")", ":", "# Use `get_field()` on the model's options so that we", "# get the correct field instance if there's model inheritance.", "opts", "=", "self", ".", "model", ".", "_meta", "return", "opts", ".", "get_field", "(", "self", ".", ...
[ 464, 4 ]
[ 469, 46 ]
python
en
['en', 'en', 'en']
True
LayerMapping.make_multi
(self, geom_type, model_field)
Given the OGRGeomType for a geometry and its associated GeometryField, determine whether the geometry should be turned into a GeometryCollection.
Given the OGRGeomType for a geometry and its associated GeometryField, determine whether the geometry should be turned into a GeometryCollection.
def make_multi(self, geom_type, model_field): """ Given the OGRGeomType for a geometry and its associated GeometryField, determine whether the geometry should be turned into a GeometryCollection. """ return (geom_type.num in self.MULTI_TYPES and model_field.__clas...
[ "def", "make_multi", "(", "self", ",", "geom_type", ",", "model_field", ")", ":", "return", "(", "geom_type", ".", "num", "in", "self", ".", "MULTI_TYPES", "and", "model_field", ".", "__class__", ".", "__name__", "==", "'Multi%s'", "%", "geom_type", ".", "...
[ 471, 4 ]
[ 477, 79 ]
python
en
['en', 'error', 'th']
False
LayerMapping.save
(self, verbose=False, fid_range=False, step=False, progress=False, silent=False, stream=sys.stdout, strict=False)
Save the contents from the OGR DataSource Layer into the database according to the mapping dictionary given at initialization. Keyword Parameters: verbose: If set, information will be printed subsequent to each model save executed on the database. fid_r...
Save the contents from the OGR DataSource Layer into the database according to the mapping dictionary given at initialization.
def save(self, verbose=False, fid_range=False, step=False, progress=False, silent=False, stream=sys.stdout, strict=False): """ Save the contents from the OGR DataSource Layer into the database according to the mapping dictionary given at initialization. Keyword Parameters: ...
[ "def", "save", "(", "self", ",", "verbose", "=", "False", ",", "fid_range", "=", "False", ",", "step", "=", "False", ",", "progress", "=", "False", ",", "silent", "=", "False", ",", "stream", "=", "sys", ".", "stdout", ",", "strict", "=", "False", ...
[ 479, 4 ]
[ 634, 19 ]
python
en
['en', 'error', 'th']
False
do_cache
(parser, token)
This will cache the contents of a template fragment for a given amount of time. Usage:: {% load cache %} {% cache [expire_time] [fragment_name] %} .. some expensive processing .. {% endcache %} This tag also supports varying by a list of arguments:: {% lo...
This will cache the contents of a template fragment for a given amount of time.
def do_cache(parser, token): """ This will cache the contents of a template fragment for a given amount of time. Usage:: {% load cache %} {% cache [expire_time] [fragment_name] %} .. some expensive processing .. {% endcache %} This tag also supports varying by ...
[ "def", "do_cache", "(", "parser", ",", "token", ")", ":", "nodelist", "=", "parser", ".", "parse", "(", "(", "'endcache'", ",", ")", ")", "parser", ".", "delete_first_token", "(", ")", "tokens", "=", "token", ".", "split_contents", "(", ")", "if", "len...
[ 52, 0 ]
[ 92, 5 ]
python
en
['en', 'error', 'th']
False
replace_assignees_username_with_name
(assignees: List[Dict[str, str]])
Replace the username of each assignee with their (full) name. This is a hack-like adaptor so that when assignees are passed to `get_pull_request_event_message` we can use the assignee's name and not their username (for more consistency).
Replace the username of each assignee with their (full) name.
def replace_assignees_username_with_name(assignees: List[Dict[str, str]]) -> List[Dict[str, str]]: """Replace the username of each assignee with their (full) name. This is a hack-like adaptor so that when assignees are passed to `get_pull_request_event_message` we can use the assignee's name and not th...
[ "def", "replace_assignees_username_with_name", "(", "assignees", ":", "List", "[", "Dict", "[", "str", ",", "str", "]", "]", ")", "->", "List", "[", "Dict", "[", "str", ",", "str", "]", "]", ":", "for", "assignee", "in", "assignees", ":", "assignee", "...
[ 172, 0 ]
[ 181, 20 ]
python
en
['en', 'en', 'en']
True
EC2.get_prerequisites
(self, only_if_not_already_done=False)
Gather instance status by calling EC2 APIs.
Gather instance status by calling EC2 APIs.
def get_prerequisites(self, only_if_not_already_done=False): """ Gather instance status by calling EC2 APIs. """ if only_if_not_already_done and self.prereqs_done: return self.state_table = self.o_state.get_state_table() client = self.context["ec2.client"] ...
[ "def", "get_prerequisites", "(", "self", ",", "only_if_not_already_done", "=", "False", ")", ":", "if", "only_if_not_already_done", "and", "self", ".", "prereqs_done", ":", "return", "self", ".", "state_table", "=", "self", ".", "o_state", ".", "get_state_table", ...
[ 226, 4 ]
[ 354, 32 ]
python
en
['en', 'en', 'en']
True
EC2.get_instance_statuses
(self)
Return the result of describe_instance_status()
Return the result of describe_instance_status()
def get_instance_statuses(self): """ Return the result of describe_instance_status() """ return self.instance_statuses
[ "def", "get_instance_statuses", "(", "self", ")", ":", "return", "self", ".", "instance_statuses" ]
[ 359, 4 ]
[ 362, 37 ]
python
en
['en', 'en', 'en']
True
EC2.is_instance_state
(self, instance_id, state)
Perform test if data returned by describe_instance_status(). This method returns is the specified is in one of the state listed in 'state' variable. The fiels instance["InstanceState"]["Name"] is compared. Note: a special "az_evicted" value is understood that is not port of the values returned...
Perform test if data returned by describe_instance_status().
def is_instance_state(self, instance_id, state): """ Perform test if data returned by describe_instance_status(). This method returns is the specified is in one of the state listed in 'state' variable. The fiels instance["InstanceState"]["Name"] is compared. Note: a special "az_evicted"...
[ "def", "is_instance_state", "(", "self", ",", "instance_id", ",", "state", ")", ":", "now", "=", "self", ".", "context", "[", "\"now\"", "]", "# Retrieve the instance structure based on the id", "i", "=", "next", "(", "filter", "(", "lambda", "i", ":", "i", ...
[ 404, 4 ]
[ 449, 53 ]
python
en
['en', 'en', 'en']
True
EC2.get_azs_with_issues
(self)
Return a list of AZ 'zone name' (ex: eu-west-1a) that have issues.
Return a list of AZ 'zone name' (ex: eu-west-1a) that have issues.
def get_azs_with_issues(self): """ Return a list of AZ 'zone name' (ex: eu-west-1a) that have issues. """ return [ az["ZoneName"] for az in self.az_with_issues ]
[ "def", "get_azs_with_issues", "(", "self", ")", ":", "return", "[", "az", "[", "\"ZoneName\"", "]", "for", "az", "in", "self", ".", "az_with_issues", "]" ]
[ 451, 4 ]
[ 454, 63 ]
python
en
['en', 'en', 'en']
True
EC2.is_instance_excluded
(self, instance_id)
Test if an instance is excluded.
Test if an instance is excluded.
def is_instance_excluded(self, instance_id): """ Test if an instance is excluded. """ excluded_instances = Cfg.get_list("ec2.state.excluded_instance_ids", default=[]) instance = self.get_instance_by_id(instance_id) if isinstance(instance_id, str) else instance_id inst...
[ "def", "is_instance_excluded", "(", "self", ",", "instance_id", ")", ":", "excluded_instances", "=", "Cfg", ".", "get_list", "(", "\"ec2.state.excluded_instance_ids\"", ",", "default", "=", "[", "]", ")", "instance", "=", "self", ".", "get_instance_by_id", "(", ...
[ 456, 4 ]
[ 466, 20 ]
python
en
['en', 'en', 'en']
True
EC2.get_subfleet_instances
(self, subfleet_name=None, with_excluded_instances=False)
Return a list of instance structure that are part the specified subfleet. :param subfleet_name: If 'None', return all subfleets in all subfleets; if set, filter on the subfleet name specified. :return A list instance structures
Return a list of instance structure that are part the specified subfleet.
def get_subfleet_instances(self, subfleet_name=None, with_excluded_instances=False): """ Return a list of instance structure that are part the specified subfleet. :param subfleet_name: If 'None', return all subfleets in all subfleets; if set, filter on the subfleet name specified. :return A lis...
[ "def", "get_subfleet_instances", "(", "self", ",", "subfleet_name", "=", "None", ",", "with_excluded_instances", "=", "False", ")", ":", "value", "=", "[", "subfleet_name", "]", "if", "subfleet_name", "is", "not", "None", "else", "None", "instances", "=", "sel...
[ 468, 4 ]
[ 479, 24 ]
python
en
['en', 'en', 'en']
True
EC2.get_subfleet_names
(self)
Return the list of all active subfleets.
Return the list of all active subfleets.
def get_subfleet_names(self): """ Return the list of all active subfleets. """ instances = self.get_subfleet_instances(with_excluded_instances=True) names = [] for i in instances: tags = self.get_instance_tags(i) [names.append(tags[k]) for k in tags if...
[ "def", "get_subfleet_names", "(", "self", ")", ":", "instances", "=", "self", ".", "get_subfleet_instances", "(", "with_excluded_instances", "=", "True", ")", "names", "=", "[", "]", "for", "i", "in", "instances", ":", "tags", "=", "self", ".", "get_instance...
[ 481, 4 ]
[ 489, 20 ]
python
en
['en', 'en', 'en']
True
EC2.get_subfleet_name_for_instance
(self, i)
Return the name of subfleet that the instance is part of or None is not part of a subfleet.
Return the name of subfleet that the instance is part of or None is not part of a subfleet.
def get_subfleet_name_for_instance(self, i): """ Return the name of subfleet that the instance is part of or None is not part of a subfleet. """ if isinstance(i, str): i = self.get_instance_by_id(i) tags = self.get_instance_tags(i) return tags["clonesquad:subfleet-nam...
[ "def", "get_subfleet_name_for_instance", "(", "self", ",", "i", ")", ":", "if", "isinstance", "(", "i", ",", "str", ")", ":", "i", "=", "self", ".", "get_instance_by_id", "(", "i", ")", "tags", "=", "self", ".", "get_instance_tags", "(", "i", ")", "ret...
[ 491, 4 ]
[ 497, 95 ]
python
en
['en', 'en', 'en']
True
EC2.is_subfleet_instance
(self, instance_id, subfleet_name=None)
Return 'True' if specified instance is part of a subfleet. If 'subfleet_name' is specified, it also check that the instance is part of the specified subfleet.
Return 'True' if specified instance is part of a subfleet. If 'subfleet_name' is specified, it also check that the instance is part of the specified subfleet.
def is_subfleet_instance(self, instance_id, subfleet_name=None): """ Return 'True' if specified instance is part of a subfleet. If 'subfleet_name' is specified, it also check that the instance is part of the specified subfleet. """ instances = self.get_subfleet_instances(subfleet_nam...
[ "def", "is_subfleet_instance", "(", "self", ",", "instance_id", ",", "subfleet_name", "=", "None", ")", ":", "instances", "=", "self", ".", "get_subfleet_instances", "(", "subfleet_name", "=", "subfleet_name", ")", "instance_ids", "=", "[", "i", "[", "\"Instance...
[ 499, 4 ]
[ 505, 42 ]
python
en
['en', 'en', 'en']
True
EC2.get_timesorted_instances
(self, instances=None)
Return a sortied list of instance structure. The list is sorted with from the oldest to newest last start attempt. (As a consequence, it makes sure that an instance that failed to start for any reason won't the one that will be attempted at next scheduling).
Return a sortied list of instance structure.
def get_timesorted_instances(self, instances=None): """ Return a sortied list of instance structure. The list is sorted with from the oldest to newest last start attempt. (As a consequence, it makes sure that an instance that failed to start for any reason won't the one that will be attempted a...
[ "def", "get_timesorted_instances", "(", "self", ",", "instances", "=", "None", ")", ":", "if", "instances", "is", "None", ":", "instances", "=", "self", ".", "instances", "# Sort instance list starting from the oldest launch to the newest", "return", "sorted", "(", "i...
[ 507, 4 ]
[ 515, 74 ]
python
en
['en', 'en', 'en']
True
EC2.get_instances
(self, instances=None, State=None, ScalingState=None, main_fleet_only=False, details=None, max_results=-1, azs_filtered_out=None)
Return a list of instance structures based on specified criteria. This method is a critical one used in all scheduling algorithms. It sorts and filters this way: * Sort all instances from the oldest running to the youngest running. * Filter based on 'State' that represents the ...
Return a list of instance structures based on specified criteria.
def get_instances(self, instances=None, State=None, ScalingState=None, main_fleet_only=False, details=None, max_results=-1, azs_filtered_out=None): """ Return a list of instance structures based on specified criteria. This method is a critical one used in all scheduling algorithms. It sorts and...
[ "def", "get_instances", "(", "self", ",", "instances", "=", "None", ",", "State", "=", "None", ",", "ScalingState", "=", "None", ",", "main_fleet_only", "=", "False", ",", "details", "=", "None", ",", "max_results", "=", "-", "1", ",", "azs_filtered_out", ...
[ 517, 4 ]
[ 564, 31 ]
python
en
['en', 'en', 'en']
True
EC2.start_instances
(self, instance_ids_to_start, max_started_instances=-1)
Call EC2 start_instance() is a smart way... This critical method is responsible to implement safest logic to start instances when needed. It doesn't simply call the EC2 start_instances() API but manages corner cases in the most efficient way possible. Heuristics: * It is recommend...
Call EC2 start_instance() is a smart way...
def start_instances(self, instance_ids_to_start, max_started_instances=-1): """ Call EC2 start_instance() is a smart way... This critical method is responsible to implement safest logic to start instances when needed. It doesn't simply call the EC2 start_instances() API but manages corner cases...
[ "def", "start_instances", "(", "self", ",", "instance_ids_to_start", ",", "max_started_instances", "=", "-", "1", ")", ":", "# Remember when we tried to start all these instances. Used to detect instances with issues", "# by placing them at end of get_instances() generated list", "i...
[ 566, 4 ]
[ 672, 62 ]
python
en
['en', 'lb', 'en']
True
EC2.stop_instances
(self, instance_ids_to_stop)
Stop instances the smart way... This method is paranoid in the way to stop instances. It tries first to stop them at once but it fails it falls back to one-by-one stop_instances() call. It is designed to ensure that a single instance condition blocks any instance stop. :param instance_ids_to_...
Stop instances the smart way...
def stop_instances(self, instance_ids_to_stop): """ Stop instances the smart way... This method is paranoid in the way to stop instances. It tries first to stop them at once but it fails it falls back to one-by-one stop_instances() call. It is designed to ensure that a single instance condition...
[ "def", "stop_instances", "(", "self", ",", "instance_ids_to_stop", ")", ":", "now", "=", "self", ".", "context", "[", "\"now\"", "]", "client", "=", "self", ".", "context", "[", "\"ec2.client\"", "]", "ids", "=", "instance_ids_to_stop", "max_stop", "=", "Cfg...
[ 675, 4 ]
[ 723, 81 ]
python
en
['en', 'nl', 'en']
True
EC2.instance_in_error
(self, Operation=None, InstanceId=None, PreviousState=None, CurrentState=None)
Template method for user Event generation.
Template method for user Event generation.
def instance_in_error(self, Operation=None, InstanceId=None, PreviousState=None, CurrentState=None): """ Template method for user Event generation. """ return {}
[ "def", "instance_in_error", "(", "self", ",", "Operation", "=", "None", ",", "InstanceId", "=", "None", ",", "PreviousState", "=", "None", ",", "CurrentState", "=", "None", ")", ":", "return", "{", "}" ]
[ 728, 4 ]
[ 731, 17 ]
python
en
['en', 'en', 'en']
True
EC2.sort_by_prefered_azs
(self, instances, prefered_azs=None, prefered_before=True)
Return a list of instance sorted by prefered_azs. It used by algorithms to manage AZ eviction by putting instances in a faulty AZ in front or at end of this list depending on what is needed by the algorithm.
Return a list of instance sorted by prefered_azs.
def sort_by_prefered_azs(self, instances, prefered_azs=None, prefered_before=True): """ Return a list of instance sorted by prefered_azs. It used by algorithms to manage AZ eviction by putting instances in a faulty AZ in front or at end of this list depending on what is needed by the algorithm...
[ "def", "sort_by_prefered_azs", "(", "self", ",", "instances", ",", "prefered_azs", "=", "None", ",", "prefered_before", "=", "True", ")", ":", "if", "prefered_azs", "is", "None", ":", "return", "instances", "sorted_instances", "=", "[", "]", "for", "i", "in"...
[ 733, 4 ]
[ 755, 31 ]
python
en
['en', 'en', 'en']
True
EC2.sort_by_prefered_instance_ids
(self, instances, prefered_ids=None, prefered_before=True)
Return a sorted list of instance structures based on 'prefered_ids'. Used by scaling algorithms to put in high or low priority a set of designed instance ids.
Return a sorted list of instance structures based on 'prefered_ids'.
def sort_by_prefered_instance_ids(self, instances, prefered_ids=None, prefered_before=True): """ Return a sorted list of instance structures based on 'prefered_ids'. Used by scaling algorithms to put in high or low priority a set of designed instance ids. """ if prefered_ids is None: r...
[ "def", "sort_by_prefered_instance_ids", "(", "self", ",", "instances", ",", "prefered_ids", "=", "None", ",", "prefered_before", "=", "True", ")", ":", "if", "prefered_ids", "is", "None", ":", "return", "instances", "sorted_instances", "=", "[", "]", "for", "i...
[ 757, 4 ]
[ 778, 31 ]
python
en
['en', 'en', 'en']
True
EC2.sort_by_balanced_az
(self, candidate_instances, ref_instances, smallest_to_biggest_az=True, excluded_instance_ids=None)
Sort the supplied candidate instance list in a way that keeps the AZ balanced. This is a critical method that scaling algorithm call to ensure AZs are always kept balanced the best possible. :param candidate_instances: The list of instance structures to sort :param ref_instances: ...
Sort the supplied candidate instance list in a way that keeps the AZ balanced.
def sort_by_balanced_az(self, candidate_instances, ref_instances, smallest_to_biggest_az=True, excluded_instance_ids=None): """ Sort the supplied candidate instance list in a way that keeps the AZ balanced. This is a critical method that scaling algorithm call to ensure AZs are always kept balanced the...
[ "def", "sort_by_balanced_az", "(", "self", ",", "candidate_instances", ",", "ref_instances", ",", "smallest_to_biggest_az", "=", "True", ",", "excluded_instance_ids", "=", "None", ")", ":", "candidate_instances", "=", "candidate_instances", ".", "copy", "(", ")", "r...
[ 781, 4 ]
[ 828, 34 ]
python
en
['en', 'en', 'en']
True
EC2.get_instance_tags
(self, instance, default=None)
Return instance tags as simple dict.
Return instance tags as simple dict.
def get_instance_tags(self, instance, default=None): """ Return instance tags as simple dict. """ if instance is None: return default tags = {} for t in instance["Tags"]: tags[t["Key"]] = t["Value"] return tags
[ "def", "get_instance_tags", "(", "self", ",", "instance", ",", "default", "=", "None", ")", ":", "if", "instance", "is", "None", ":", "return", "default", "tags", "=", "{", "}", "for", "t", "in", "instance", "[", "\"Tags\"", "]", ":", "tags", "[", "t...
[ 830, 4 ]
[ 838, 19 ]
python
en
['en', 'en', 'en']
True
EC2.instance_has_tag
(self, instance, tag, value=None)
Test if an instance has the specified tag and, if defined, the specified value.
Test if an instance has the specified tag and, if defined, the specified value.
def instance_has_tag(self, instance, tag, value=None): """ Test if an instance has the specified tag and, if defined, the specified value. """ if instance is None: return None for t in instance["Tags"]: if t["Key"] != tag: continue if v...
[ "def", "instance_has_tag", "(", "self", ",", "instance", ",", "tag", ",", "value", "=", "None", ")", ":", "if", "instance", "is", "None", ":", "return", "None", "for", "t", "in", "instance", "[", "\"Tags\"", "]", ":", "if", "t", "[", "\"Key\"", "]", ...
[ 841, 4 ]
[ 852, 19 ]
python
en
['en', 'en', 'en']
True
EC2.filter_spot_instances
(self, instances, EventType="+rebalance_recommended,interrupted,other_states", filter_out_instance_types=None, filter_in_instance_types=None, match_only_spot=False, merge_matching_spot_first=False)
Filter the supplied 'instances' list related to Spot one. :param instances: The instance list to filter :param EventType: A query string that matchs (+) or excluded (-) Spot instance based on status 'rebalance_recommended' and 'interrupted' ...
Filter the supplied 'instances' list related to Spot one.
def filter_spot_instances(self, instances, EventType="+rebalance_recommended,interrupted,other_states", filter_out_instance_types=None, filter_in_instance_types=None, match_only_spot=False, merge_matching_spot_first=False): """ Filter the supplied 'instances' list related to Spot one. :par...
[ "def", "filter_spot_instances", "(", "self", ",", "instances", ",", "EventType", "=", "\"+rebalance_recommended,interrupted,other_states\"", ",", "filter_out_instance_types", "=", "None", ",", "filter_in_instance_types", "=", "None", ",", "match_only_spot", "=", "False", ...
[ 854, 4 ]
[ 906, 18 ]
python
en
['en', 'en', 'en']
True
EC2.filter_instance_recently_stopped
(self, instances, min_age, filter_only_spot=True)
Filter out recently stopped instance. TODO: Remove this method as it was used by scaling algorithms to exclude Spot instances recently stopped but as start_instances() is now able to manage this smartly so no more need to filter this way...
Filter out recently stopped instance. TODO: Remove this method as it was used by scaling algorithms to exclude Spot instances recently stopped but as start_instances() is now able to manage this smartly so no more need to filter this way...
def filter_instance_recently_stopped(self, instances, min_age, filter_only_spot=True): """ Filter out recently stopped instance. TODO: Remove this method as it was used by scaling algorithms to exclude Spot instances recently stopped but as start_instances() is now able to manage this smartly so...
[ "def", "filter_instance_recently_stopped", "(", "self", ",", "instances", ",", "min_age", ",", "filter_only_spot", "=", "True", ")", ":", "now", "=", "self", ".", "context", "[", "\"now\"", "]", "res", "=", "[", "]", "for", "i", "in", "instances", ":", "...
[ 911, 4 ]
[ 926, 18 ]
python
en
['en', 'en', 'en']
True
EC2.filter_instance_list_by_tag
(self, instances, key, value=None)
Perform sort-in/sort-out operation of the supplied instance list based on tags. :param instances: The instance list to filter :param key: The instance key to search prepend with '+' for filter-in and '-' for filter-out :param value: When set, the filter looks not only for tag p...
Perform sort-in/sort-out operation of the supplied instance list based on tags.
def filter_instance_list_by_tag(self, instances, key, value=None): """ Perform sort-in/sort-out operation of the supplied instance list based on tags. :param instances: The instance list to filter :param key: The instance key to search prepend with '+' for filter-in and '-' for filter...
[ "def", "filter_instance_list_by_tag", "(", "self", ",", "instances", ",", "key", ",", "value", "=", "None", ")", ":", "exclude", "=", "key", ".", "startswith", "(", "\"-\"", ")", "if", "exclude", ":", "key", "=", "key", "[", "1", ":", "]", "i_s", "="...
[ 928, 4 ]
[ 944, 18 ]
python
en
['en', 'en', 'en']
True
EC2.get_cpu_creditbalance
(self, instance)
Return the CPU Credit balance for the specified instance structure. Return -1 if not a burstable intance or CPU Credit is not yet known.
Return the CPU Credit balance for the specified instance structure.
def get_cpu_creditbalance(self, instance): """ Return the CPU Credit balance for the specified instance structure. Return -1 if not a burstable intance or CPU Credit is not yet known. """ debug_state_key = "ec2.debug.instance.%s.cpu_credit_balance" % instance["InstanceId"] ...
[ "def", "get_cpu_creditbalance", "(", "self", ",", "instance", ")", ":", "debug_state_key", "=", "\"ec2.debug.instance.%s.cpu_credit_balance\"", "%", "instance", "[", "\"InstanceId\"", "]", "forced_cpu_credit_balance", "=", "self", ".", "get_state", "(", "debug_state_key",...
[ 983, 4 ]
[ 1005, 17 ]
python
en
['en', 'en', 'en']
True
EC2.get_all_scaling_states
(self)
Return a dict of scaling instance states and associated list of instance id.
Return a dict of scaling instance states and associated list of instance id.
def get_all_scaling_states(self): """ Return a dict of scaling instance states and associated list of instance id. """ r = defaultdict(list) for i in self.get_instances(): instance_id = i["InstanceId"] state = self.get_scaling_state(instance_id, default="unknown")...
[ "def", "get_all_scaling_states", "(", "self", ")", ":", "r", "=", "defaultdict", "(", "list", ")", "for", "i", "in", "self", ".", "get_instances", "(", ")", ":", "instance_id", "=", "i", "[", "\"InstanceId\"", "]", "state", "=", "self", ".", "get_scaling...
[ 1007, 4 ]
[ 1015, 22 ]
python
en
['en', 'en', 'en']
True
EC2.compute_scaling_states
(self, instance_id=None)
Compute an optimized lookup structure of scaling instance state.
Compute an optimized lookup structure of scaling instance state.
def compute_scaling_states(self, instance_id=None): """ Compute an optimized lookup structure of scaling instance state. """ def _update_scaling_state(i): instance_id = i["InstanceId"] state = self.scaling_states[instance_id] key = f"ec2.insta...
[ "def", "compute_scaling_states", "(", "self", ",", "instance_id", "=", "None", ")", ":", "def", "_update_scaling_state", "(", "i", ")", ":", "instance_id", "=", "i", "[", "\"InstanceId\"", "]", "state", "=", "self", ".", "scaling_states", "[", "instance_id", ...
[ 1017, 4 ]
[ 1040, 40 ]
python
en
['en', 'en', 'en']
True
EC2.get_scaling_state
(self, instance_id, default=None, meta=None, default_date=None, do_not_return_excluded=False, raw=False)
Return the scaling state for specified instance.
Return the scaling state for specified instance.
def get_scaling_state(self, instance_id, default=None, meta=None, default_date=None, do_not_return_excluded=False, raw=False): """ Return the scaling state for specified instance. """ if meta is not None: newest_action_date = None i = self.get_instance_b...
[ "def", "get_scaling_state", "(", "self", ",", "instance_id", ",", "default", "=", "None", ",", "meta", "=", "None", ",", "default_date", "=", "None", ",", "do_not_return_excluded", "=", "False", ",", "raw", "=", "False", ")", ":", "if", "meta", "is", "no...
[ 1042, 4 ]
[ 1062, 72 ]
python
en
['en', 'en', 'en']
True
EC2.get_instance_control_state
(self)
Retrieve the structure describing unstoppable/unstartable instances maintained through the API GW.
Retrieve the structure describing unstoppable/unstartable instances maintained through the API GW.
def get_instance_control_state(self): """ Retrieve the structure describing unstoppable/unstartable instances maintained through the API GW. """ state = self.get_state_json("ec2.control.state", default={ "unstoppable": {}, "unstartable": {} }) # Purge obso...
[ "def", "get_instance_control_state", "(", "self", ")", ":", "state", "=", "self", ".", "get_state_json", "(", "\"ec2.control.state\"", ",", "default", "=", "{", "\"unstoppable\"", ":", "{", "}", ",", "\"unstartable\"", ":", "{", "}", "}", ")", "# Purge obsolet...
[ 1183, 4 ]
[ 1197, 20 ]
python
en
['en', 'en', 'en']
True
ResolverTests.test_resolver_repr
(self)
Test repr of RegexURLResolver, especially when urlconf_name is a list (#17892).
Test repr of RegexURLResolver, especially when urlconf_name is a list (#17892).
def test_resolver_repr(self): """ Test repr of RegexURLResolver, especially when urlconf_name is a list (#17892). """ # Pick a resolver from a namespaced urlconf resolver = get_resolver('urlpatterns_reverse.namespace_urls') sub_resolver = resolver.namespace_dict['...
[ "def", "test_resolver_repr", "(", "self", ")", ":", "# Pick a resolver from a namespaced urlconf", "resolver", "=", "get_resolver", "(", "'urlpatterns_reverse.namespace_urls'", ")", "sub_resolver", "=", "resolver", ".", "namespace_dict", "[", "'test-ns1'", "]", "[", "1", ...
[ 233, 4 ]
[ 241, 67 ]
python
en
['en', 'error', 'th']
False
ResolverTests.test_reverse_lazy_object_coercion_by_resolve
(self)
Verifies lazy object returned by reverse_lazy is coerced to text by resolve(). Previous to #21043, this would raise a TypeError.
Verifies lazy object returned by reverse_lazy is coerced to text by resolve(). Previous to #21043, this would raise a TypeError.
def test_reverse_lazy_object_coercion_by_resolve(self): """ Verifies lazy object returned by reverse_lazy is coerced to text by resolve(). Previous to #21043, this would raise a TypeError. """ urls = 'urlpatterns_reverse.named_urls' proxy_url = reverse_lazy('named-url1', ...
[ "def", "test_reverse_lazy_object_coercion_by_resolve", "(", "self", ")", ":", "urls", "=", "'urlpatterns_reverse.named_urls'", "proxy_url", "=", "reverse_lazy", "(", "'named-url1'", ",", "urlconf", "=", "urls", ")", "resolver", "=", "get_resolver", "(", "urls", ")", ...
[ 243, 4 ]
[ 254, 61 ]
python
en
['en', 'error', 'th']
False
ResolverTests.test_non_regex
(self)
Verifies that we raise a Resolver404 if what we are resolving doesn't meet the basic requirements of a path to match - i.e., at the very least, it matches the root pattern '^/'. We must never return None from resolve, or we will get a TypeError further down the line. Regression...
Verifies that we raise a Resolver404 if what we are resolving doesn't meet the basic requirements of a path to match - i.e., at the very least, it matches the root pattern '^/'. We must never return None from resolve, or we will get a TypeError further down the line.
def test_non_regex(self): """ Verifies that we raise a Resolver404 if what we are resolving doesn't meet the basic requirements of a path to match - i.e., at the very least, it matches the root pattern '^/'. We must never return None from resolve, or we will get a TypeError furth...
[ "def", "test_non_regex", "(", "self", ")", ":", "self", ".", "assertRaises", "(", "Resolver404", ",", "resolve", ",", "''", ")", "self", ".", "assertRaises", "(", "Resolver404", ",", "resolve", ",", "'a'", ")", "self", ".", "assertRaises", "(", "Resolver40...
[ 256, 4 ]
[ 268, 52 ]
python
en
['en', 'error', 'th']
False
ResolverTests.test_404_tried_urls_have_names
(self)
Verifies that the list of URLs that come back from a Resolver404 exception contains a list in the right format for printing out in the DEBUG 404 page with both the patterns and URL names, if available.
Verifies that the list of URLs that come back from a Resolver404 exception contains a list in the right format for printing out in the DEBUG 404 page with both the patterns and URL names, if available.
def test_404_tried_urls_have_names(self): """ Verifies that the list of URLs that come back from a Resolver404 exception contains a list in the right format for printing out in the DEBUG 404 page with both the patterns and URL names, if available. """ urls = 'urlpatterns_...
[ "def", "test_404_tried_urls_have_names", "(", "self", ")", ":", "urls", "=", "'urlpatterns_reverse.named_urls'", "# this list matches the expected URL types and names returned when", "# you try to resolve a non-existent URL in the first level of included", "# URLs in named_urls.py (e.g., '/inc...
[ 270, 4 ]
[ 304, 130 ]
python
en
['en', 'error', 'th']
False
main
(args)
Validate all submissions and copy them into place
Validate all submissions and copy them into place
def main(args): """Validate all submissions and copy them into place""" random.seed() temp_dir = tempfile.mkdtemp() logging.info("Created temporary directory: %s", temp_dir) validator = SubmissionValidator( source_dir=args.source_dir, target_dir=args.target_dir, temp_dir=temp...
[ "def", "main", "(", "args", ")", ":", "random", ".", "seed", "(", ")", "temp_dir", "=", "tempfile", ".", "mkdtemp", "(", ")", "logging", ".", "info", "(", "\"Created temporary directory: %s\"", ",", "temp_dir", ")", "validator", "=", "SubmissionValidator", "...
[ 239, 0 ]
[ 254, 44 ]
python
en
['en', 'en', 'en']
True
ValidationStats._update_stat
(self, submission_type, increase_success, increase_fail)
Common method to update submission statistics.
Common method to update submission statistics.
def _update_stat(self, submission_type, increase_success, increase_fail): """Common method to update submission statistics.""" stat = self.stats.get(submission_type, (0, 0)) stat = (stat[0] + increase_success, stat[1] + increase_fail) self.stats[submission_type] = stat
[ "def", "_update_stat", "(", "self", ",", "submission_type", ",", "increase_success", ",", "increase_fail", ")", ":", "stat", "=", "self", ".", "stats", ".", "get", "(", "submission_type", ",", "(", "0", ",", "0", ")", ")", "stat", "=", "(", "stat", "["...
[ 63, 4 ]
[ 67, 42 ]
python
en
['en', 'en', 'en']
True
ValidationStats.add_success
(self, submission_type)
Add one successfull submission of given type.
Add one successfull submission of given type.
def add_success(self, submission_type): """Add one successfull submission of given type.""" self._update_stat(submission_type, 1, 0)
[ "def", "add_success", "(", "self", ",", "submission_type", ")", ":", "self", ".", "_update_stat", "(", "submission_type", ",", "1", ",", "0", ")" ]
[ 69, 4 ]
[ 71, 48 ]
python
en
['en', 'en', 'en']
True
ValidationStats.add_failure
(self, submission_type="unknown")
Add one failed submission of given type.
Add one failed submission of given type.
def add_failure(self, submission_type="unknown"): """Add one failed submission of given type.""" self._update_stat(submission_type, 0, 1)
[ "def", "add_failure", "(", "self", ",", "submission_type", "=", "\"unknown\"", ")", ":", "self", ".", "_update_stat", "(", "submission_type", ",", "0", ",", "1", ")" ]
[ 73, 4 ]
[ 75, 48 ]
python
en
['en', 'en', 'en']
True
ValidationStats.log_stats
(self)
Print statistics into log.
Print statistics into log.
def log_stats(self): """Print statistics into log.""" logging.info("Validation statistics: ") for k, v in iteritems(self.stats): logging.info( "%s - %d valid out of %d total submissions", k, v[0], v[0] + v[1] )
[ "def", "log_stats", "(", "self", ")", ":", "logging", ".", "info", "(", "\"Validation statistics: \"", ")", "for", "k", ",", "v", "in", "iteritems", "(", "self", ".", "stats", ")", ":", "logging", ".", "info", "(", "\"%s - %d valid out of %d total submissions\...
[ 77, 4 ]
[ 83, 13 ]
python
en
['en', 'fa', 'en']
True
SubmissionValidator.__init__
( self, source_dir, target_dir, temp_dir, do_copy, use_gpu, containers_file=None )
Initializes SubmissionValidator. Args: source_dir: source Google Cloud Storage directory with all submissions target_dir: target Google Cloud Storage directory where to copy submissions temp_dir: local temporary directory do_copy: if True then validate and co...
Initializes SubmissionValidator.
def __init__( self, source_dir, target_dir, temp_dir, do_copy, use_gpu, containers_file=None ): """Initializes SubmissionValidator. Args: source_dir: source Google Cloud Storage directory with all submissions target_dir: target Google Cloud Storage directory where to cop...
[ "def", "__init__", "(", "self", ",", "source_dir", ",", "target_dir", ",", "temp_dir", ",", "do_copy", ",", "use_gpu", ",", "containers_file", "=", "None", ")", ":", "self", ".", "source_dir", "=", "source_dir", "self", ".", "target_dir", "=", "target_dir", ...
[ 89, 4 ]
[ 120, 36 ]
python
it
['pl', 'zu', 'it']
False
SubmissionValidator.copy_submission_locally
(self, cloud_path)
Copies submission from Google Cloud Storage to local directory. Args: cloud_path: path of the submission in Google Cloud Storage Returns: name of the local file where submission is copied to
Copies submission from Google Cloud Storage to local directory.
def copy_submission_locally(self, cloud_path): """Copies submission from Google Cloud Storage to local directory. Args: cloud_path: path of the submission in Google Cloud Storage Returns: name of the local file where submission is copied to """ local_path = ...
[ "def", "copy_submission_locally", "(", "self", ",", "cloud_path", ")", ":", "local_path", "=", "os", ".", "path", ".", "join", "(", "self", ".", "download_dir", ",", "os", ".", "path", ".", "basename", "(", "cloud_path", ")", ")", "cmd", "=", "[", "\"g...
[ 122, 4 ]
[ 136, 25 ]
python
en
['en', 'en', 'en']
True
SubmissionValidator.copy_submission_to_destination
(self, src_filename, dst_subdir, submission_id)
Copies submission to target directory. Args: src_filename: source filename of the submission dst_subdir: subdirectory of the target directory where submission should be copied to submission_id: ID of the submission, will be used as a new submission filename...
Copies submission to target directory.
def copy_submission_to_destination(self, src_filename, dst_subdir, submission_id): """Copies submission to target directory. Args: src_filename: source filename of the submission dst_subdir: subdirectory of the target directory where submission should be copied to ...
[ "def", "copy_submission_to_destination", "(", "self", ",", "src_filename", ",", "dst_subdir", ",", "submission_id", ")", ":", "extension", "=", "[", "e", "for", "e", "in", "ALLOWED_EXTENSIONS", "if", "src_filename", ".", "endswith", "(", "e", ")", "]", "if", ...
[ 138, 4 ]
[ 160, 66 ]
python
en
['en', 'en', 'en']
True
SubmissionValidator.validate_and_copy_one_submission
(self, submission_path)
Validates one submission and copies it to target directory. Args: submission_path: path in Google Cloud Storage of the submission file
Validates one submission and copies it to target directory.
def validate_and_copy_one_submission(self, submission_path): """Validates one submission and copies it to target directory. Args: submission_path: path in Google Cloud Storage of the submission file """ if os.path.exists(self.download_dir): shutil.rmtree(self.downl...
[ "def", "validate_and_copy_one_submission", "(", "self", ",", "submission_path", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "self", ".", "download_dir", ")", ":", "shutil", ".", "rmtree", "(", "self", ".", "download_dir", ")", "os", ".", "makedi...
[ 162, 4 ]
[ 195, 68 ]
python
en
['en', 'en', 'en']
True
SubmissionValidator.save_id_to_path_mapping
(self)
Saves mapping from submission IDs to original filenames. This mapping is saved as CSV file into target directory.
Saves mapping from submission IDs to original filenames.
def save_id_to_path_mapping(self): """Saves mapping from submission IDs to original filenames. This mapping is saved as CSV file into target directory. """ if not self.id_to_path_mapping: return with open(self.local_id_to_path_mapping_file, "w") as f: wri...
[ "def", "save_id_to_path_mapping", "(", "self", ")", ":", "if", "not", "self", ".", "id_to_path_mapping", ":", "return", "with", "open", "(", "self", ".", "local_id_to_path_mapping_file", ",", "\"w\"", ")", "as", "f", ":", "writer", "=", "csv", ".", "writer",...
[ 197, 4 ]
[ 216, 82 ]
python
en
['en', 'en', 'en']
True
SubmissionValidator.run
(self)
Runs validation of all submissions.
Runs validation of all submissions.
def run(self): """Runs validation of all submissions.""" cmd = ["gsutil", "ls", os.path.join(self.source_dir, "**")] try: files_list = subprocess.check_output(cmd).split("\n") except subprocess.CalledProcessError: logging.error("Can" "t read source directory") ...
[ "def", "run", "(", "self", ")", ":", "cmd", "=", "[", "\"gsutil\"", ",", "\"ls\"", ",", "os", ".", "path", ".", "join", "(", "self", ".", "source_dir", ",", "\"**\"", ")", "]", "try", ":", "files_list", "=", "subprocess", ".", "check_output", "(", ...
[ 218, 4 ]
[ 236, 67 ]
python
en
['en', 'en', 'en']
True
SOCKSConnection._new_conn
(self)
Establish a new connection via the SOCKS proxy.
Establish a new connection via the SOCKS proxy.
def _new_conn(self): """ Establish a new connection via the SOCKS proxy. """ extra_kw = {} if self.source_address: extra_kw["source_address"] = self.source_address if self.socket_options: extra_kw["socket_options"] = self.socket_options t...
[ "def", "_new_conn", "(", "self", ")", ":", "extra_kw", "=", "{", "}", "if", "self", ".", "source_address", ":", "extra_kw", "[", "\"source_address\"", "]", "=", "self", ".", "source_address", "if", "self", ".", "socket_options", ":", "extra_kw", "[", "\"so...
[ 77, 4 ]
[ 133, 19 ]
python
en
['en', 'error', 'th']
False
ModelInstanceCreationTests.test_can_initialize_model_instance_using_positional_arguments
(self)
You can initialize a model instance using positional arguments, which should match the field order as defined in the model.
You can initialize a model instance using positional arguments, which should match the field order as defined in the model.
def test_can_initialize_model_instance_using_positional_arguments(self): """ You can initialize a model instance using positional arguments, which should match the field order as defined in the model. """ a = Article(None, 'Second article', datetime(2005, 7, 29)) a.save()...
[ "def", "test_can_initialize_model_instance_using_positional_arguments", "(", "self", ")", ":", "a", "=", "Article", "(", "None", ",", "'Second article'", ",", "datetime", "(", "2005", ",", "7", ",", "29", ")", ")", "a", ".", "save", "(", ")", "self", ".", ...
[ 34, 4 ]
[ 43, 65 ]
python
en
['en', 'error', 'th']
False
ModelInstanceCreationTests.test_can_leave_off_value_for_autofield_and_it_gets_value_on_save
(self)
You can leave off the value for an AutoField when creating an object, because it'll get filled in automatically when you save().
You can leave off the value for an AutoField when creating an object, because it'll get filled in automatically when you save().
def test_can_leave_off_value_for_autofield_and_it_gets_value_on_save(self): """ You can leave off the value for an AutoField when creating an object, because it'll get filled in automatically when you save(). """ a = Article(headline='Article 5', pub_date=datetime(2005, 7, 31)) ...
[ "def", "test_can_leave_off_value_for_autofield_and_it_gets_value_on_save", "(", "self", ")", ":", "a", "=", "Article", "(", "headline", "=", "'Article 5'", ",", "pub_date", "=", "datetime", "(", "2005", ",", "7", ",", "31", ")", ")", "a", ".", "save", "(", "...
[ 81, 4 ]
[ 89, 39 ]
python
en
['en', 'error', 'th']
False
ModelInstanceCreationTests.test_for_datetimefields_saves_as_much_precision_as_was_given
(self)
as much precision in *seconds*
as much precision in *seconds*
def test_for_datetimefields_saves_as_much_precision_as_was_given(self): """as much precision in *seconds*""" a1 = Article( headline='Article 7', pub_date=datetime(2005, 7, 31, 12, 30), ) a1.save() self.assertEqual(Article.objects.get(id__exact=a1.id).pub_d...
[ "def", "test_for_datetimefields_saves_as_much_precision_as_was_given", "(", "self", ")", ":", "a1", "=", "Article", "(", "headline", "=", "'Article 7'", ",", "pub_date", "=", "datetime", "(", "2005", ",", "7", ",", "31", ",", "12", ",", "30", ")", ",", ")", ...
[ 96, 4 ]
[ 112, 46 ]
python
en
['en', 'en', 'en']
True
ModelTest.test_multiple_objects_max_num_fetched
(self)
#6785 - get() should fetch a limited number of results.
#6785 - get() should fetch a limited number of results.
def test_multiple_objects_max_num_fetched(self): """ #6785 - get() should fetch a limited number of results. """ Article.objects.bulk_create( Article(headline='Area %s' % i, pub_date=datetime(2005, 7, 28)) for i in range(MAX_GET_RESULTS) ) six.asse...
[ "def", "test_multiple_objects_max_num_fetched", "(", "self", ")", ":", "Article", ".", "objects", ".", "bulk_create", "(", "Article", "(", "headline", "=", "'Area %s'", "%", "i", ",", "pub_date", "=", "datetime", "(", "2005", ",", "7", ",", "28", ")", ")",...
[ 180, 4 ]
[ 202, 9 ]
python
en
['en', 'error', 'th']
False
ModelTest.test_field_ordering
(self)
Field instances have a `__lt__` comparison function to define an ordering based on their creation. Prior to #17851 this ordering comparison relied on the now unsupported `__cmp__` and was assuming compared objects were both Field instances raising `AttributeError` when it should...
Field instances have a `__lt__` comparison function to define an ordering based on their creation. Prior to #17851 this ordering comparison relied on the now unsupported `__cmp__` and was assuming compared objects were both Field instances raising `AttributeError` when it should...
def test_field_ordering(self): """ Field instances have a `__lt__` comparison function to define an ordering based on their creation. Prior to #17851 this ordering comparison relied on the now unsupported `__cmp__` and was assuming compared objects were both Field instances raisi...
[ "def", "test_field_ordering", "(", "self", ")", ":", "f1", "=", "Field", "(", ")", "f2", "=", "Field", "(", "auto_created", "=", "True", ")", "f3", "=", "Field", "(", ")", "self", ".", "assertTrue", "(", "f2", "<", "f1", ")", "self", ".", "assertTr...
[ 290, 4 ]
[ 304, 45 ]
python
en
['en', 'error', 'th']
False
ModelTest.test_create_relation_with_ugettext_lazy
(self)
Test that ugettext_lazy objects work when saving model instances through various methods. Refs #10498.
Test that ugettext_lazy objects work when saving model instances through various methods. Refs #10498.
def test_create_relation_with_ugettext_lazy(self): """ Test that ugettext_lazy objects work when saving model instances through various methods. Refs #10498. """ notlazy = 'test' lazy = ugettext_lazy(notlazy) Article.objects.create(headline=lazy, pub_date=datetime...
[ "def", "test_create_relation_with_ugettext_lazy", "(", "self", ")", ":", "notlazy", "=", "'test'", "lazy", "=", "ugettext_lazy", "(", "notlazy", ")", "Article", ".", "objects", ".", "create", "(", "headline", "=", "lazy", ",", "pub_date", "=", "datetime", ".",...
[ 349, 4 ]
[ 371, 51 ]
python
en
['en', 'error', 'th']
False
ConcurrentSaveTests.test_concurrent_delete_with_save
(self)
Test fetching, deleting and finally saving an object - we should get an insert in this case.
Test fetching, deleting and finally saving an object - we should get an insert in this case.
def test_concurrent_delete_with_save(self): """ Test fetching, deleting and finally saving an object - we should get an insert in this case. """ a = Article.objects.create(headline='foo', pub_date=datetime.now()) exceptions = [] def deleter(): try: ...
[ "def", "test_concurrent_delete_with_save", "(", "self", ")", ":", "a", "=", "Article", ".", "objects", ".", "create", "(", "headline", "=", "'foo'", ",", "pub_date", "=", "datetime", ".", "now", "(", ")", ")", "exceptions", "=", "[", "]", "def", "deleter...
[ 581, 4 ]
[ 602, 70 ]
python
en
['en', 'error', 'th']
False
ManagerTest.test_manager_methods
(self)
This test ensures that the correct set of methods from `QuerySet` are copied onto `Manager`. It's particularly useful to prevent accidentally leaking new methods into `Manager`. New `QuerySet` methods that should also be copied onto `Manager` will need to be added to `ManagerTe...
This test ensures that the correct set of methods from `QuerySet` are copied onto `Manager`.
def test_manager_methods(self): """ This test ensures that the correct set of methods from `QuerySet` are copied onto `Manager`. It's particularly useful to prevent accidentally leaking new methods into `Manager`. New `QuerySet` methods that should also be copied onto `M...
[ "def", "test_manager_methods", "(", "self", ")", ":", "self", ".", "assertEqual", "(", "sorted", "(", "BaseManager", ".", "_get_queryset_methods", "(", "QuerySet", ")", ".", "keys", "(", ")", ")", ",", "sorted", "(", "self", ".", "QUERYSET_PROXY_METHODS", ")...
[ 646, 4 ]
[ 658, 9 ]
python
en
['en', 'error', 'th']
False
SelectOnSaveTests.test_select_on_save_lying_update
(self)
Test that select_on_save works correctly if the database doesn't return correct information about matched rows from UPDATE.
Test that select_on_save works correctly if the database doesn't return correct information about matched rows from UPDATE.
def test_select_on_save_lying_update(self): """ Test that select_on_save works correctly if the database doesn't return correct information about matched rows from UPDATE. """ # Change the manager to not return "row matched" for update(). # We are going to change ...
[ "def", "test_select_on_save_lying_update", "(", "self", ")", ":", "# Change the manager to not return \"row matched\" for update().", "# We are going to change the Article's _base_manager class", "# dynamically. This is a bit of a hack, but it seems hard to", "# test this properly otherwise. Artic...
[ 676, 4 ]
[ 716, 56 ]
python
en
['en', 'error', 'th']
False
_simple_domain_name_validator
(value)
Validates that the given value contains no whitespaces to prevent common typos.
Validates that the given value contains no whitespaces to prevent common typos.
def _simple_domain_name_validator(value): """ Validates that the given value contains no whitespaces to prevent common typos. """ if not value: return checks = ((s in value) for s in string.whitespace) if any(checks): raise ValidationError( _("The domain name cann...
[ "def", "_simple_domain_name_validator", "(", "value", ")", ":", "if", "not", "value", ":", "return", "checks", "=", "(", "(", "s", "in", "value", ")", "for", "s", "in", "string", ".", "whitespace", ")", "if", "any", "(", "checks", ")", ":", "raise", ...
[ 19, 0 ]
[ 31, 9 ]
python
en
['en', 'error', 'th']
False
clear_site_cache
(sender, **kwargs)
Clears the cache (if primed) each time a site is saved or deleted
Clears the cache (if primed) each time a site is saved or deleted
def clear_site_cache(sender, **kwargs): """ Clears the cache (if primed) each time a site is saved or deleted """ instance = kwargs['instance'] try: del SITE_CACHE[instance.pk] except KeyError: pass try: del SITE_CACHE[Site.objects.get(pk=instance.pk).domain] exce...
[ "def", "clear_site_cache", "(", "sender", ",", "*", "*", "kwargs", ")", ":", "instance", "=", "kwargs", "[", "'instance'", "]", "try", ":", "del", "SITE_CACHE", "[", "instance", ".", "pk", "]", "except", "KeyError", ":", "pass", "try", ":", "del", "SIT...
[ 109, 0 ]
[ 121, 12 ]
python
en
['en', 'error', 'th']
False
SiteManager.get_current
(self, request=None)
Returns the current Site based on the SITE_ID in the project's settings. If SITE_ID isn't defined, it returns the site with domain matching request.get_host(). The ``Site`` object is cached the first time it's retrieved from the database.
Returns the current Site based on the SITE_ID in the project's settings. If SITE_ID isn't defined, it returns the site with domain matching request.get_host(). The ``Site`` object is cached the first time it's retrieved from the database.
def get_current(self, request=None): """ Returns the current Site based on the SITE_ID in the project's settings. If SITE_ID isn't defined, it returns the site with domain matching request.get_host(). The ``Site`` object is cached the first time it's retrieved from the database. ...
[ "def", "get_current", "(", "self", ",", "request", "=", "None", ")", ":", "from", "django", ".", "conf", "import", "settings", "if", "getattr", "(", "settings", ",", "'SITE_ID'", ",", "''", ")", ":", "site_id", "=", "settings", ".", "SITE_ID", "return", ...
[ 49, 4 ]
[ 68, 9 ]
python
en
['en', 'error', 'th']
False
SiteManager.clear_cache
(self)
Clears the ``Site`` object cache.
Clears the ``Site`` object cache.
def clear_cache(self): """Clears the ``Site`` object cache.""" global SITE_CACHE SITE_CACHE = {}
[ "def", "clear_cache", "(", "self", ")", ":", "global", "SITE_CACHE", "SITE_CACHE", "=", "{", "}" ]
[ 70, 4 ]
[ 73, 23 ]
python
en
['en', 'en', 'en']
True
is_mm_32_format
(msg_string: Optional[str])
Missed message strings are formatted with a little "mm" prefix followed by a randomly generated 32-character string.
Missed message strings are formatted with a little "mm" prefix followed by a randomly generated 32-character string.
def is_mm_32_format(msg_string: Optional[str]) -> bool: """ Missed message strings are formatted with a little "mm" prefix followed by a randomly generated 32-character string. """ return msg_string is not None and msg_string.startswith("mm") and len(msg_string) == 34
[ "def", "is_mm_32_format", "(", "msg_string", ":", "Optional", "[", "str", "]", ")", "->", "bool", ":", "return", "msg_string", "is", "not", "None", "and", "msg_string", ".", "startswith", "(", "\"mm\"", ")", "and", "len", "(", "msg_string", ")", "==", "3...
[ 120, 0 ]
[ 125, 91 ]
python
en
['en', 'error', 'th']
False
unpackb
(packed, **kwargs)
Unpack an object from `packed`. Raises ``ExtraData`` when *packed* contains extra bytes. Raises ``ValueError`` when *packed* is incomplete. Raises ``FormatError`` when *packed* is not valid msgpack. Raises ``StackError`` when *packed* contains too nested. Other exceptions can be raised during ...
Unpack an object from `packed`.
def unpackb(packed, **kwargs): """ Unpack an object from `packed`. Raises ``ExtraData`` when *packed* contains extra bytes. Raises ``ValueError`` when *packed* is incomplete. Raises ``FormatError`` when *packed* is not valid msgpack. Raises ``StackError`` when *packed* contains too nested. ...
[ "def", "unpackb", "(", "packed", ",", "*", "*", "kwargs", ")", ":", "unpacker", "=", "Unpacker", "(", "None", ",", "max_buffer_size", "=", "len", "(", "packed", ")", ",", "*", "*", "kwargs", ")", "unpacker", ".", "feed", "(", "packed", ")", "try", ...
[ 113, 0 ]
[ 137, 14 ]
python
en
['en', 'error', 'th']
False
Unpacker._consume
(self)
Gets rid of the used parts of the buffer.
Gets rid of the used parts of the buffer.
def _consume(self): """ Gets rid of the used parts of the buffer. """ self._stream_offset += self._buff_i - self._buf_checkpoint self._buf_checkpoint = self._buff_i
[ "def", "_consume", "(", "self", ")", ":", "self", ".", "_stream_offset", "+=", "self", ".", "_buff_i", "-", "self", ".", "_buf_checkpoint", "self", ".", "_buf_checkpoint", "=", "self", ".", "_buff_i" ]
[ 355, 4 ]
[ 358, 43 ]
python
en
['en', 'en', 'en']
True
Packer.bytes
(self)
Return internal buffer contents as bytes object
Return internal buffer contents as bytes object
def bytes(self): """Return internal buffer contents as bytes object""" return self._buffer.getvalue()
[ "def", "bytes", "(", "self", ")", ":", "return", "self", ".", "_buffer", ".", "getvalue", "(", ")" ]
[ 1046, 4 ]
[ 1048, 38 ]
python
en
['en', 'lb', 'en']
True
Packer.reset
(self)
Reset internal buffer. This method is useful only when autoreset=False.
Reset internal buffer.
def reset(self): """Reset internal buffer. This method is useful only when autoreset=False. """ self._buffer = StringIO()
[ "def", "reset", "(", "self", ")", ":", "self", ".", "_buffer", "=", "StringIO", "(", ")" ]
[ 1050, 4 ]
[ 1055, 33 ]
python
en
['en', 'lb', 'en']
True
Packer.getbuffer
(self)
Return view of internal buffer.
Return view of internal buffer.
def getbuffer(self): """Return view of internal buffer.""" if USING_STRINGBUILDER or PY2: return memoryview(self.bytes()) else: return self._buffer.getbuffer()
[ "def", "getbuffer", "(", "self", ")", ":", "if", "USING_STRINGBUILDER", "or", "PY2", ":", "return", "memoryview", "(", "self", ".", "bytes", "(", ")", ")", "else", ":", "return", "self", ".", "_buffer", ".", "getbuffer", "(", ")" ]
[ 1057, 4 ]
[ 1062, 43 ]
python
en
['en', 'lb', 'en']
True
Feature.__init__
(self, feat, layer)
Initialize Feature from a pointer and its Layer object.
Initialize Feature from a pointer and its Layer object.
def __init__(self, feat, layer): """ Initialize Feature from a pointer and its Layer object. """ if not feat: raise GDALException('Cannot create OGR Feature, invalid pointer given.') self.ptr = feat self._layer = layer
[ "def", "__init__", "(", "self", ",", "feat", ",", "layer", ")", ":", "if", "not", "feat", ":", "raise", "GDALException", "(", "'Cannot create OGR Feature, invalid pointer given.'", ")", "self", ".", "ptr", "=", "feat", "self", ".", "_layer", "=", "layer" ]
[ 19, 4 ]
[ 26, 27 ]
python
en
['en', 'error', 'th']
False
Feature.__getitem__
(self, index)
Get the Field object at the specified index, which may be either an integer or the Field's string label. Note that the Field object is not the field's _value_ -- use the `get` method instead to retrieve the value (e.g. an integer) instead of a Field instance.
Get the Field object at the specified index, which may be either an integer or the Field's string label. Note that the Field object is not the field's _value_ -- use the `get` method instead to retrieve the value (e.g. an integer) instead of a Field instance.
def __getitem__(self, index): """ Get the Field object at the specified index, which may be either an integer or the Field's string label. Note that the Field object is not the field's _value_ -- use the `get` method instead to retrieve the value (e.g. an integer) instead of a F...
[ "def", "__getitem__", "(", "self", ",", "index", ")", ":", "if", "isinstance", "(", "index", ",", "str", ")", ":", "i", "=", "self", ".", "index", "(", "index", ")", "elif", "0", "<=", "index", "<", "self", ".", "num_fields", ":", "i", "=", "inde...
[ 28, 4 ]
[ 41, 29 ]
python
en
['en', 'error', 'th']
False
Feature.__len__
(self)
Return the count of fields in this feature.
Return the count of fields in this feature.
def __len__(self): "Return the count of fields in this feature." return self.num_fields
[ "def", "__len__", "(", "self", ")", ":", "return", "self", ".", "num_fields" ]
[ 43, 4 ]
[ 45, 30 ]
python
en
['en', 'en', 'en']
True
Feature.__str__
(self)
The string name of the feature.
The string name of the feature.
def __str__(self): "The string name of the feature." return 'Feature FID %d in Layer<%s>' % (self.fid, self.layer_name)
[ "def", "__str__", "(", "self", ")", ":", "return", "'Feature FID %d in Layer<%s>'", "%", "(", "self", ".", "fid", ",", "self", ".", "layer_name", ")" ]
[ 47, 4 ]
[ 49, 74 ]
python
en
['en', 'en', 'en']
True
Feature.__eq__
(self, other)
Do equivalence testing on the features.
Do equivalence testing on the features.
def __eq__(self, other): "Do equivalence testing on the features." return bool(capi.feature_equal(self.ptr, other._ptr))
[ "def", "__eq__", "(", "self", ",", "other", ")", ":", "return", "bool", "(", "capi", ".", "feature_equal", "(", "self", ".", "ptr", ",", "other", ".", "_ptr", ")", ")" ]
[ 51, 4 ]
[ 53, 61 ]
python
en
['en', 'en', 'en']
True
Feature.fid
(self)
Return the feature identifier.
Return the feature identifier.
def fid(self): "Return the feature identifier." return capi.get_fid(self.ptr)
[ "def", "fid", "(", "self", ")", ":", "return", "capi", ".", "get_fid", "(", "self", ".", "ptr", ")" ]
[ 61, 4 ]
[ 63, 37 ]
python
en
['en', 'fy', 'en']
True
Feature.layer_name
(self)
Return the name of the layer for the feature.
Return the name of the layer for the feature.
def layer_name(self): "Return the name of the layer for the feature." name = capi.get_feat_name(self._layer._ldefn) return force_str(name, self.encoding, strings_only=True)
[ "def", "layer_name", "(", "self", ")", ":", "name", "=", "capi", ".", "get_feat_name", "(", "self", ".", "_layer", ".", "_ldefn", ")", "return", "force_str", "(", "name", ",", "self", ".", "encoding", ",", "strings_only", "=", "True", ")" ]
[ 66, 4 ]
[ 69, 64 ]
python
en
['en', 'en', 'en']
True
Feature.num_fields
(self)
Return the number of fields in the Feature.
Return the number of fields in the Feature.
def num_fields(self): "Return the number of fields in the Feature." return capi.get_feat_field_count(self.ptr)
[ "def", "num_fields", "(", "self", ")", ":", "return", "capi", ".", "get_feat_field_count", "(", "self", ".", "ptr", ")" ]
[ 72, 4 ]
[ 74, 50 ]
python
en
['en', 'en', 'en']
True
Feature.fields
(self)
Return a list of fields in the Feature.
Return a list of fields in the Feature.
def fields(self): "Return a list of fields in the Feature." return [ force_str( capi.get_field_name(capi.get_field_defn(self._layer._ldefn, i)), self.encoding, strings_only=True ) for i in range(self.num_fields) ]
[ "def", "fields", "(", "self", ")", ":", "return", "[", "force_str", "(", "capi", ".", "get_field_name", "(", "capi", ".", "get_field_defn", "(", "self", ".", "_layer", ".", "_ldefn", ",", "i", ")", ")", ",", "self", ".", "encoding", ",", "strings_only"...
[ 77, 4 ]
[ 85, 9 ]
python
en
['en', 'en', 'en']
True
Feature.geom
(self)
Return the OGR Geometry for this Feature.
Return the OGR Geometry for this Feature.
def geom(self): "Return the OGR Geometry for this Feature." # Retrieving the geometry pointer for the feature. geom_ptr = capi.get_feat_geom_ref(self.ptr) return OGRGeometry(geom_api.clone_geom(geom_ptr))
[ "def", "geom", "(", "self", ")", ":", "# Retrieving the geometry pointer for the feature.", "geom_ptr", "=", "capi", ".", "get_feat_geom_ref", "(", "self", ".", "ptr", ")", "return", "OGRGeometry", "(", "geom_api", ".", "clone_geom", "(", "geom_ptr", ")", ")" ]
[ 88, 4 ]
[ 92, 57 ]
python
en
['en', 'en', 'en']
True
Feature.geom_type
(self)
Return the OGR Geometry Type for this Feature.
Return the OGR Geometry Type for this Feature.
def geom_type(self): "Return the OGR Geometry Type for this Feature." return OGRGeomType(capi.get_fd_geom_type(self._layer._ldefn))
[ "def", "geom_type", "(", "self", ")", ":", "return", "OGRGeomType", "(", "capi", ".", "get_fd_geom_type", "(", "self", ".", "_layer", ".", "_ldefn", ")", ")" ]
[ 95, 4 ]
[ 97, 69 ]
python
en
['en', 'en', 'en']
True
Feature.get
(self, field)
Return the value of the field, instead of an instance of the Field object. May take a string of the field name or a Field object as parameters.
Return the value of the field, instead of an instance of the Field object. May take a string of the field name or a Field object as parameters.
def get(self, field): """ Return the value of the field, instead of an instance of the Field object. May take a string of the field name or a Field object as parameters. """ field_name = getattr(field, 'name', field) return self[field_name].value
[ "def", "get", "(", "self", ",", "field", ")", ":", "field_name", "=", "getattr", "(", "field", ",", "'name'", ",", "field", ")", "return", "self", "[", "field_name", "]", ".", "value" ]
[ 100, 4 ]
[ 107, 37 ]
python
en
['en', 'error', 'th']
False
Feature.index
(self, field_name)
Return the index of the given field name.
Return the index of the given field name.
def index(self, field_name): "Return the index of the given field name." i = capi.get_field_index(self.ptr, force_bytes(field_name)) if i < 0: raise IndexError('Invalid OFT field name given: %s.' % field_name) return i
[ "def", "index", "(", "self", ",", "field_name", ")", ":", "i", "=", "capi", ".", "get_field_index", "(", "self", ".", "ptr", ",", "force_bytes", "(", "field_name", ")", ")", "if", "i", "<", "0", ":", "raise", "IndexError", "(", "'Invalid OFT field name g...
[ 109, 4 ]
[ 114, 16 ]
python
en
['en', 'en', 'en']
True
ld_cifar10
()
Load training and test data.
Load training and test data.
def ld_cifar10(): """Load training and test data.""" def convert_types(image, label): image = tf.cast(image, tf.float32) image /= 127.5 image -= 1.0 return image, label dataset, info = tfds.load("cifar10", with_info=True, as_supervised=True) def augment_mirror(x): ...
[ "def", "ld_cifar10", "(", ")", ":", "def", "convert_types", "(", "image", ",", "label", ")", ":", "image", "=", "tf", ".", "cast", "(", "image", ",", "tf", ".", "float32", ")", "image", "/=", "127.5", "image", "-=", "1.0", "return", "image", ",", "...
[ 38, 0 ]
[ 64, 59 ]
python
en
['en', 'en', 'en']
True
ld_cifar10
()
Load training and test data.
Load training and test data.
def ld_cifar10(): """Load training and test data.""" train_transforms = torchvision.transforms.Compose( [torchvision.transforms.ToTensor()] ) test_transforms = torchvision.transforms.Compose( [torchvision.transforms.ToTensor()] ) train_dataset = torchvision.datasets.CIFAR10( ...
[ "def", "ld_cifar10", "(", ")", ":", "train_transforms", "=", "torchvision", ".", "transforms", ".", "Compose", "(", "[", "torchvision", ".", "transforms", ".", "ToTensor", "(", ")", "]", ")", "test_transforms", "=", "torchvision", ".", "transforms", ".", "Co...
[ 35, 0 ]
[ 55, 57 ]
python
en
['en', 'en', 'en']
True
StatelessServer.run
(self)
Runs the asyncio event loop with our handler loop.
Runs the asyncio event loop with our handler loop.
def run(self): """ Runs the asyncio event loop with our handler loop. """ event_loop = asyncio.get_event_loop() asyncio.ensure_future(self.application_checker()) try: event_loop.run_until_complete(self.handle()) except KeyboardInterrupt: lo...
[ "def", "run", "(", "self", ")", ":", "event_loop", "=", "asyncio", ".", "get_event_loop", "(", ")", "asyncio", ".", "ensure_future", "(", "self", ".", "application_checker", "(", ")", ")", "try", ":", "event_loop", ".", "run_until_complete", "(", "self", "...
[ 52, 4 ]
[ 61, 58 ]
python
en
['en', 'error', 'th']
False
StatelessServer.application_send
(self, scope, message)
Receives outbound sends from applications and handles them.
Receives outbound sends from applications and handles them.
async def application_send(self, scope, message): """ Receives outbound sends from applications and handles them. """ raise NotImplementedError("You must implement application_send()")
[ "async", "def", "application_send", "(", "self", ",", "scope", ",", "message", ")", ":", "raise", "NotImplementedError", "(", "\"You must implement application_send()\"", ")" ]
[ 66, 4 ]
[ 70, 74 ]
python
en
['en', 'error', 'th']
False
StatelessServer.get_or_create_application_instance
(self, scope_id, scope)
Creates an application instance and returns its queue.
Creates an application instance and returns its queue.
def get_or_create_application_instance(self, scope_id, scope): """ Creates an application instance and returns its queue. """ if scope_id in self.application_instances: self.application_instances[scope_id]["last_used"] = time.time() return self.application_instanc...
[ "def", "get_or_create_application_instance", "(", "self", ",", "scope_id", ",", "scope", ")", ":", "if", "scope_id", "in", "self", ".", "application_instances", ":", "self", ".", "application_instances", "[", "scope_id", "]", "[", "\"last_used\"", "]", "=", "tim...
[ 74, 4 ]
[ 100, 26 ]
python
en
['en', 'error', 'th']
False
StatelessServer.delete_oldest_application_instance
(self)
Finds and deletes the oldest application instance
Finds and deletes the oldest application instance
def delete_oldest_application_instance(self): """ Finds and deletes the oldest application instance """ oldest_time = min( details["last_used"] for details in self.application_instances.values() ) for scope_id, details in self.application_instances.items(): ...
[ "def", "delete_oldest_application_instance", "(", "self", ")", ":", "oldest_time", "=", "min", "(", "details", "[", "\"last_used\"", "]", "for", "details", "in", "self", ".", "application_instances", ".", "values", "(", ")", ")", "for", "scope_id", ",", "detai...
[ 102, 4 ]
[ 114, 22 ]
python
en
['en', 'error', 'th']
False
StatelessServer.delete_application_instance
(self, scope_id)
Removes an application instance (makes sure its task is stopped, then removes it from the current set)
Removes an application instance (makes sure its task is stopped, then removes it from the current set)
def delete_application_instance(self, scope_id): """ Removes an application instance (makes sure its task is stopped, then removes it from the current set) """ details = self.application_instances[scope_id] del self.application_instances[scope_id] if not details["...
[ "def", "delete_application_instance", "(", "self", ",", "scope_id", ")", ":", "details", "=", "self", ".", "application_instances", "[", "scope_id", "]", "del", "self", ".", "application_instances", "[", "scope_id", "]", "if", "not", "details", "[", "\"future\""...
[ 116, 4 ]
[ 124, 38 ]
python
en
['en', 'error', 'th']
False
StatelessServer.application_checker
(self)
Goes through the set of current application instance Futures and cleans up any that are done/prints exceptions for any that errored.
Goes through the set of current application instance Futures and cleans up any that are done/prints exceptions for any that errored.
async def application_checker(self): """ Goes through the set of current application instance Futures and cleans up any that are done/prints exceptions for any that errored. """ while True: await asyncio.sleep(self.application_checker_interval) for scope_i...
[ "async", "def", "application_checker", "(", "self", ")", ":", "while", "True", ":", "await", "asyncio", ".", "sleep", "(", "self", ".", "application_checker_interval", ")", "for", "scope_id", ",", "details", "in", "list", "(", "self", ".", "application_instanc...
[ 126, 4 ]
[ 142, 28 ]
python
en
['en', 'error', 'th']
False
StatelessServer.application_exception
(self, exception, application_details)
Called whenever an application coroutine has an exception.
Called whenever an application coroutine has an exception.
async def application_exception(self, exception, application_details): """ Called whenever an application coroutine has an exception. """ logging.error( "Exception inside application: %s\n%s%s", exception, "".join(traceback.format_tb(exception.__traceb...
[ "async", "def", "application_exception", "(", "self", ",", "exception", ",", "application_details", ")", ":", "logging", ".", "error", "(", "\"Exception inside application: %s\\n%s%s\"", ",", "exception", ",", "\"\"", ".", "join", "(", "traceback", ".", "format_tb",...
[ 144, 4 ]
[ 153, 9 ]
python
en
['en', 'error', 'th']
False
DatabaseIntrospection.get_table_list
(self, cursor)
Return a list of table and view names in the current database.
Return a list of table and view names in the current database.
def get_table_list(self, cursor): """Return a list of table and view names in the current database.""" cursor.execute("SHOW FULL TABLES") return [TableInfo(row[0], {'BASE TABLE': 't', 'VIEW': 'v'}.get(row[1])) for row in cursor.fetchall()]
[ "def", "get_table_list", "(", "self", ",", "cursor", ")", ":", "cursor", ".", "execute", "(", "\"SHOW FULL TABLES\"", ")", "return", "[", "TableInfo", "(", "row", "[", "0", "]", ",", "{", "'BASE TABLE'", ":", "'t'", ",", "'VIEW'", ":", "'v'", "}", ".",...
[ 55, 4 ]
[ 59, 45 ]
python
en
['en', 'en', 'en']
True
DatabaseIntrospection.get_table_description
(self, cursor, table_name)
Return a description of the table with the DB-API cursor.description interface."
Return a description of the table with the DB-API cursor.description interface."
def get_table_description(self, cursor, table_name): """ Return a description of the table with the DB-API cursor.description interface." """ # information_schema database gives more accurate results for some figures: # - varchar length returned by cursor.description is a...
[ "def", "get_table_description", "(", "self", ",", "cursor", ",", "table_name", ")", ":", "# information_schema database gives more accurate results for some figures:", "# - varchar length returned by cursor.description is an internal length,", "# not visible length (#5725)", "# - precisi...
[ 61, 4 ]
[ 101, 21 ]
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. """ constraints = self.get_key_columns(cursor, table_name) relations = {} for my_fieldnam...
[ "def", "get_relations", "(", "self", ",", "cursor", ",", "table_name", ")", ":", "constraints", "=", "self", ".", "get_key_columns", "(", "cursor", ",", "table_name", ")", "relations", "=", "{", "}", "for", "my_fieldname", ",", "other_table", ",", "other_fie...
[ 110, 4 ]
[ 119, 24 ]
python
en
['en', 'error', 'th']
False
DatabaseIntrospection.get_key_columns
(self, cursor, table_name)
Return a list of (column_name, referenced_table_name, referenced_column_name) for all key columns in the given table.
Return a list of (column_name, referenced_table_name, referenced_column_name) for all key columns in the given table.
def get_key_columns(self, cursor, table_name): """ Return a list of (column_name, referenced_table_name, referenced_column_name) for all key columns in the given table. """ key_columns = [] cursor.execute(""" SELECT column_name, referenced_table_name, referenc...
[ "def", "get_key_columns", "(", "self", ",", "cursor", ",", "table_name", ")", ":", "key_columns", "=", "[", "]", "cursor", ".", "execute", "(", "\"\"\"\n SELECT column_name, referenced_table_name, referenced_column_name\n FROM information_schema.key_column_u...
[ 121, 4 ]
[ 135, 26 ]
python
en
['en', 'error', 'th']
False
DatabaseIntrospection.get_storage_engine
(self, cursor, table_name)
Retrieve the storage engine for a given table. Return the default storage engine if the table doesn't exist.
Retrieve the storage engine for a given table. Return the default storage engine if the table doesn't exist.
def get_storage_engine(self, cursor, table_name): """ Retrieve the storage engine for a given table. Return the default storage engine if the table doesn't exist. """ cursor.execute( "SELECT engine " "FROM information_schema.tables " "WHERE tab...
[ "def", "get_storage_engine", "(", "self", ",", "cursor", ",", "table_name", ")", ":", "cursor", ".", "execute", "(", "\"SELECT engine \"", "\"FROM information_schema.tables \"", "\"WHERE table_name = %s\"", ",", "[", "table_name", "]", ")", "result", "=", "cursor", ...
[ 137, 4 ]
[ 149, 24 ]
python
en
['en', 'error', 'th']
False
DatabaseIntrospection.get_constraints
(self, cursor, table_name)
Retrieve any constraints or keys (unique, pk, fk, check, index) across one or more columns.
Retrieve any constraints or keys (unique, pk, fk, check, index) across one or more columns.
def get_constraints(self, cursor, table_name): """ Retrieve any constraints or keys (unique, pk, fk, check, index) across one or more columns. """ constraints = {} # Get the actual constraint names and columns name_query = """ SELECT kc.`constraint_nam...
[ "def", "get_constraints", "(", "self", ",", "cursor", ",", "table_name", ")", ":", "constraints", "=", "{", "}", "# Get the actual constraint names and columns", "name_query", "=", "\"\"\"\n SELECT kc.`constraint_name`, kc.`column_name`,\n kc.`referenced_t...
[ 164, 4 ]
[ 266, 26 ]
python
en
['en', 'error', 'th']
False
ZabbixHookTests.test_zabbix_alert_message
(self)
Tests if zabbix alert is handled correctly
Tests if zabbix alert is handled correctly
def test_zabbix_alert_message(self) -> None: """ Tests if zabbix alert is handled correctly """ expected_topic = "www.example.com" expected_message = "PROBLEM (Average) alert on [www.example.com](https://zabbix.example.com/tr_events.php?triggerid=14032&eventid=10528):\n* Zabbix a...
[ "def", "test_zabbix_alert_message", "(", "self", ")", "->", "None", ":", "expected_topic", "=", "\"www.example.com\"", "expected_message", "=", "\"PROBLEM (Average) alert on [www.example.com](https://zabbix.example.com/tr_events.php?triggerid=14032&eventid=10528):\\n* Zabbix agent on www.e...
[ 11, 4 ]
[ 17, 76 ]
python
en
['en', 'error', 'th']
False
ZabbixHookTests.test_zabbix_invalid_payload_with_missing_data
(self)
Tests if invalid Zabbix payloads are handled correctly
Tests if invalid Zabbix payloads are handled correctly
def test_zabbix_invalid_payload_with_missing_data(self) -> None: """ Tests if invalid Zabbix payloads are handled correctly """ self.url = self.build_webhook_url() payload = self.get_body("zabbix_invalid_payload_with_missing_data") result = self.client_post(self.url, payl...
[ "def", "test_zabbix_invalid_payload_with_missing_data", "(", "self", ")", "->", "None", ":", "self", ".", "url", "=", "self", ".", "build_webhook_url", "(", ")", "payload", "=", "self", ".", "get_body", "(", "\"zabbix_invalid_payload_with_missing_data\"", ")", "resu...
[ 19, 4 ]
[ 35, 64 ]
python
en
['en', 'error', 'th']
False
DecoratorFromMiddlewareTests.test_process_view_middleware
(self)
Test a middleware that implements process_view.
Test a middleware that implements process_view.
def test_process_view_middleware(self): """ Test a middleware that implements process_view. """ process_view(self.rf.get('/'))
[ "def", "test_process_view_middleware", "(", "self", ")", ":", "process_view", "(", "self", ".", "rf", ".", "get", "(", "'/'", ")", ")" ]
[ 53, 4 ]
[ 57, 38 ]
python
en
['en', 'error', 'th']
False