_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
31
13.1k
language
stringclasses
1 value
meta_information
dict
q31300
BaseAPI.clean_registration_ids
train
def clean_registration_ids(self, registration_ids=[]): """ Checks registration ids and excludes inactive ids Args: registration_ids (list, optional): list of ids to be cleaned Returns: list: cleaned registration ids """ valid_registration_ids = [...
python
{ "resource": "" }
q31301
BaseAPI.get_registration_id_info
train
def get_registration_id_info(self, registration_id): """ Returns details related to a registration id if it exists otherwise return None Args: registration_id: id to be checked
python
{ "resource": "" }
q31302
BaseAPI.subscribe_registration_ids_to_topic
train
def subscribe_registration_ids_to_topic(self, registration_ids, topic_name): """ Subscribes a list of registration ids to a topic Args: registration_ids (list): ids to be subscribed topic_name (str): name of topic Returns: True: if operation succeede...
python
{ "resource": "" }
q31303
BaseAPI.parse_responses
train
def parse_responses(self): """ Parses the json response sent back by the server and tries to get out the important return variables Returns: dict: multicast_ids (list), success (int), failure (int), canonical_ids (int), results (list) and optional topic_message_id (s...
python
{ "resource": "" }
q31304
FCMNotification.notify_single_device
train
def notify_single_device(self, registration_id=None, message_body=None, message_title=None, message_icon=None, sound=None, condition=None, ...
python
{ "resource": "" }
q31305
FCMNotification.single_device_data_message
train
def single_device_data_message(self, registration_id=None, condition=None, collapse_key=None, delay_while_idle=False, time_to_live=None, ...
python
{ "resource": "" }
q31306
FCMNotification.notify_multiple_devices
train
def notify_multiple_devices(self, registration_ids=None, message_body=None, message_title=None, message_icon=None, sound=None, c...
python
{ "resource": "" }
q31307
FCMNotification.multiple_devices_data_message
train
def multiple_devices_data_message(self, registration_ids=None, condition=None, collapse_key=None, delay_while_idle=False, time_to_...
python
{ "resource": "" }
q31308
get_keys
train
def get_keys(src, dst, keys): """ Copies the value of keys from source object to dest object :param src: :param dst:
python
{ "resource": "" }
q31309
is_throttled
train
def is_throttled(e): """ Determines whether the exception is due to API throttling. :param e: Exception raised :return: True if it's a throttling exception else False
python
{ "resource": "" }
q31310
EC2RegionConfig.parse_instance
train
def parse_instance(self, global_params, region, reservation): """ Parse a single EC2 instance :param global_params: Parameters shared for all regions :param region: Name of the AWS region :param instance: Cluster """ for...
python
{ "resource": "" }
q31311
ElastiCacheRegionConfig.parse_cluster
train
def parse_cluster(self, global_params, region, cluster): """ Parse a single ElastiCache cluster :param global_params: Parameters shared for all regions :param region: Name of the AWS region :param cluster: ElastiCache cluster ""...
python
{ "resource": "" }
q31312
RedshiftRegionConfig.parse_cluster
train
def parse_cluster(self, global_params, region, cluster): """ Parse a single Redshift cluster :param global_params: Parameters shared for all regions :param region: Name of the AWS region :param cluster: Cluster
python
{ "resource": "" }
q31313
RedshiftRegionConfig.parse_parameter_group
train
def parse_parameter_group(self, global_params, region, parameter_group): """ Parse a single Redshift parameter group and fetch all of its parameters :param global_params: Parameters shared for all regions :param region: Name of the AWS region :param pa...
python
{ "resource": "" }
q31314
Route53DomainsConfig.parse_domains
train
def parse_domains(self, domain, params): """ Parse a single Route53Domains domain """ domain_id = self.get_non_aws_id(domain['DomainName']) domain['name'] = domain.pop('DomainName') #TODO: Get Dnssec info when available #api_client = params['api_client'] #...
python
{ "resource": "" }
q31315
Route53Config.parse_hosted_zones
train
def parse_hosted_zones(self, hosted_zone, params): """ Parse a single Route53hosted_zoness hosted_zones """ # When resuming upon throttling error, skip if already fetched hosted_zone_id = hosted_zone.pop('Id') hosted_zone['name'] = hosted_zone.pop('Name')
python
{ "resource": "" }
q31316
CloudFormationRegionConfig.parse_stack
train
def parse_stack(self, global_params, region, stack): """ Parse a single stack and fetch additional attributes :param global_params: Parameters shared for all regions :param region: Name of the AWS region :param stack_url:
python
{ "resource": "" }
q31317
SNSRegionConfig.parse_subscription
train
def parse_subscription(self, params, region, subscription): """ Parse a single subscription and reference it in its corresponding topic :param params: Global parameters (defaults to {}) :param subscription: SNS Subscription """ topic_arn = sub...
python
{ "resource": "" }
q31318
SNSRegionConfig.parse_topic
train
def parse_topic(self, params, region, topic): """ Parse a single topic and fetch additional attributes :param params: Global parameters (defaults to {}) :param topic: SNS Topic """ topic['arn'] = topic.pop('TopicArn') topic['nam...
python
{ "resource": "" }
q31319
EMRRegionConfig.parse_cluster
train
def parse_cluster(self, global_params, region, cluster): """ Parse a single EMR cluster :param global_params: Parameters shared for all regions :param region: Name of the AWS region :param cluster: EMR cluster """ cluste...
python
{ "resource": "" }
q31320
BaseConfig.fetch_all
train
def fetch_all(self, credentials, regions = [], partition_name = 'aws', targets = None): """ Generic fetching function that iterates through all of the service's targets :param credentials: F :param service: Name of the service :param regions: ...
python
{ "resource": "" }
q31321
SESRegionConfig.parse_identitie
train
def parse_identitie(self, global_params, region, identity_name): """ Parse a single identity and fetch additional attributes :param global_params: Parameters shared for all regions :param region: Name of the AWS region """ identity = {'name': i...
python
{ "resource": "" }
q31322
pass_conditions
train
def pass_conditions(all_info, current_path, conditions, unknown_as_pass_condition = False): """ Pass all conditions? :param all_info: :param current_path: :param conditions: :param unknown_as_pass_condition: Consider an undetermined condition as passed :return: """ result = False ...
python
{ "resource": "" }
q31323
DirectConnectRegionConfig.parse_connection
train
def parse_connection(self, global_params, region, connection): """ Parse a single connection and fetch additional attributes :param global_params: Parameters shared for all regions :param region: Name of the AWS region :param connection_url: ...
python
{ "resource": "" }
q31324
format_listall_output
train
def format_listall_output(format_file, format_item_dir, format, rule, option_prefix = None, template = None, skip_options = False): """ Prepare listall output template :param format_file: :param format_item_dir: :param format: :param config: :param option_prefix: :param template: :p...
python
{ "resource": "" }
q31325
generate_listall_output
train
def generate_listall_output(lines, resources, aws_config, template, arguments, nodup = False): """ Format and print the output of ListAll :param lines: :param resources: :param aws_config: :param template: :param arguments: :param nodup: :return: """ for line in lines: ...
python
{ "resource": "" }
q31326
CloudTrailRegionConfig.parse_trail
train
def parse_trail(self, global_params, region, trail): """ Parse a single CloudTrail trail :param global_params: Parameters shared for all regions :param region: Name of the AWS region :param cluster: Trail """ trail_confi...
python
{ "resource": "" }
q31327
IAMConfig.fetch_credential_report
train
def fetch_credential_report(self, credentials, ignore_exception = False): """ Fetch the credential report :param: api_client :type: FOO :param: ignore_exception : initiate credential report creation as not always ready :type: Boolean """ iam_report = {} ...
python
{ "resource": "" }
q31328
IAMConfig.parse_groups
train
def parse_groups(self, group, params): """ Parse a single IAM group and fetch additional information """ # When resuming upon throttling error, skip if already fetched if group['GroupName'] in self.groups: return api_client = params['api_client'] # Ens...
python
{ "resource": "" }
q31329
IAMConfig.parse_policies
train
def parse_policies(self, fetched_policy, params): """ Parse a single IAM policy and fetch additional information """ api_client = params['api_client'] policy = {} policy['name'] = fetched_policy.pop('PolicyName') policy['id'] = fetched_policy.pop('PolicyId') ...
python
{ "resource": "" }
q31330
IAMConfig.fetch_password_policy
train
def fetch_password_policy(self, credentials): """ Fetch the password policy that applies to all IAM users within the AWS account """ self.fetchstatuslogger.counts['password_policy']['discovered'] = 0 self.fetchstatuslogger.counts['password_policy']['fetched'] = 0 try: ...
python
{ "resource": "" }
q31331
IAMConfig.parse_roles
train
def parse_roles(self, fetched_role, params): """ Parse a single IAM role and fetch additional data """ role = {} role['instances_count'] = 'N/A' # When resuming upon throttling error, skip if already fetched if fetched_role['RoleName'] in self.roles: r...
python
{ "resource": "" }
q31332
IAMConfig.parse_users
train
def parse_users(self, user, params): """ Parse a single IAM user and fetch additional data """ if user['UserName'] in self.users: return api_client = params['api_client'] # Ensure consistent attribute names across resource types user['id'] = user.pop('...
python
{ "resource": "" }
q31333
get_subnet_flow_logs_list
train
def get_subnet_flow_logs_list(current_config, subnet): """ Return the flow logs that cover a given subnet :param current_config: :param subnet: the subnet that the flow logs should cover :return:
python
{ "resource": "" }
q31334
VPCRegionConfig.parse_subnet
train
def parse_subnet(self, global_params, region, subnet): """ Parse subnet object. :param global_params: :param region: :param subnet: :return: """ vpc_id = subnet['VpcId'] manage_dictionary(self.vpcs, vpc_id, SingleVPCConfig(self.vpc_resource_types)...
python
{ "resource": "" }
q31335
CloudWatchRegionConfig.parse_alarm
train
def parse_alarm(self, global_params, region, alarm): """ Parse a single CloudWatch trail :param global_params: Parameters shared for all regions :param region: Name of the AWS region :param alarm:
python
{ "resource": "" }
q31336
get_attribute_at
train
def get_attribute_at(config, target_path, key, default_value=None): """ Return attribute value at a given path :param config:
python
{ "resource": "" }
q31337
get_value_at
train
def get_value_at(all_info, current_path, key, to_string=False): """ Get value located at a given path :param all_info: :param current_path: :param key: :param to_string: :return: """ keys = key.split('.') if keys[-1] == 'id': target_obj = current_path[len(keys)-1] el...
python
{ "resource": "" }
q31338
RuleDefinition.load
train
def load(self): """ Load the definition of the rule, searching in the specified rule dirs first, then in the built-in definitions :return: None """ file_name_valid = False rule_type_valid = False # Look for a locally-defined rule fo...
python
{ "resource": "" }
q31339
RegionalServiceConfig.init_region_config
train
def init_region_config(self, region): """ Initialize the region's configuration :param region: Name of the region """
python
{ "resource": "" }
q31340
RegionalServiceConfig.fetch_all
train
def fetch_all(self, credentials, regions = [], partition_name = 'aws', targets = None): """ Fetch all the configuration supported by Scout2 for a given service :param credentials: F :param service: Name of the service :param regions: N...
python
{ "resource": "" }
q31341
RegionalServiceConfig._init_threading
train
def _init_threading(self, function, params={}, num_threads=10): """ Initialize queue and threads :param function: :param params: :param num_threads: :return: """ q = Queue(maxsize=0) # TODO: find something appropriate
python
{ "resource": "" }
q31342
RegionConfig.fetch_all
train
def fetch_all(self, api_client, fetchstatuslogger, q, targets): ''' Make all API calls as defined in metadata.json :param api_client: :param fetchstatuslogger: :param q: :param targets: :return: ''' self.fetchstatuslogger = fetchstatuslogger ...
python
{ "resource": "" }
q31343
SQSRegionConfig.parse_queue
train
def parse_queue(self, global_params, region, queue_url): """ Parse a single queue and fetch additional attributes :param global_params: Parameters shared for all regions :param region: Name of the AWS region :param queue_url: URL of the A...
python
{ "resource": "" }
q31344
get_s3_buckets
train
def get_s3_buckets(api_client, s3_info, s3_params): """ List all available buckets :param api_client: :param s3_info: :param s3_params: :return: """ manage_dictionary(s3_info, 'buckets', {}) buckets = api_client[get_s3_list_region(s3_params['selected_regions'])].list_buckets()['Buck...
python
{ "resource": "" }
q31345
S3Config.parse_buckets
train
def parse_buckets(self, bucket, params): """ Parse a single S3 bucket TODO: - CORS - Lifecycle - Notification ? - Get bucket's policy :param bucket: :param params: :return: """ bucket['name'] = bucket.pop('Name') a...
python
{ "resource": "" }
q31346
Ruleset.load
train
def load(self, rule_type, quiet = False): """ Open a JSON file definiting a ruleset and load it into a Ruleset object :param quiet: :return: """ if self.filename and os.path.exists(self.filename): try: with open(self.filename, 'rt') as f: ...
python
{ "resource": "" }
q31347
Ruleset.handle_rule_versions
train
def handle_rule_versions(self, filename, rule_type, rule): """ For each version of a rule found in the ruleset, append a new Rule object """ if 'versions' in rule: versions = rule.pop('versions')
python
{ "resource": "" }
q31348
Ruleset.prepare_rules
train
def prepare_rules(self, attributes = [], ip_ranges = [], params = {}): """ Update the ruleset's rules by duplicating fields as required by the HTML ruleset generator :return: """ for filename in self.rule_definitions: if filename in self.rules: for ru...
python
{ "resource": "" }
q31349
Ruleset.load_rule_definitions
train
def load_rule_definitions(self, ruleset_generator = False, rule_dirs = []): """ Load definition of rules declared in the ruleset :param services: :param ip_ranges: :param aws_account_id: :param generator: :return: """ # Load rules from JSON files...
python
{ "resource": "" }
q31350
prompt_4_yes_no
train
def prompt_4_yes_no(question): """ Ask a question and prompt for yes or no :param question: Question to ask; answer is yes/no :return: :boolean """ while True: sys.stdout.write(question + ' (y/n)? ') try: choice = raw_inp...
python
{ "resource": "" }
q31351
RDSRegionConfig.parse_instance
train
def parse_instance(self, global_params, region, dbi): """ Parse a single RDS instance :param global_params: Parameters shared for all regions :param region: Name of the AWS region :param instance: Instance """ vpc_id = db...
python
{ "resource": "" }
q31352
preprocessing
train
def preprocessing(aws_config, ip_ranges = [], ip_ranges_name_key = None): """ Tweak the AWS config to match cross-service resources and clean any fetching artifacts :param aws_config: :return: """ map_all_sgs(aws_config) map_all_subnets(aws_config) set_emr_vpc_ids(aws_config) #pars...
python
{ "resource": "" }
q31353
process_vpc_peering_connections_callback
train
def process_vpc_peering_connections_callback(aws_config, current_config, path, current_path, pc_id, callback_args): """ Create a list of peering connection IDs in each VPC :param aws_config: :param current_config: :param path: :param current_path: :param pc_id: :param callback_args: ...
python
{ "resource": "" }
q31354
go_to_and_do
train
def go_to_and_do(aws_config, current_config, path, current_path, callback, callback_args = None): """ Recursively go to a target and execute a callback :param aws_config: :param current_config: :param path: :param current_path: :param callback: :param callback_args: :return: """...
python
{ "resource": "" }
q31355
IsErrorSuppressedByNolint
train
def IsErrorSuppressedByNolint(category, linenum): """Returns true if the specified error category is suppressed on this line. Consults the global error_suppressions map populated by ParseNolintSuppressions/ResetNolintSuppressions. Args: category: str, the category of the error. linenum: int, the curre...
python
{ "resource": "" }
q31356
Error
train
def Error(filename, linenum, category, confidence, message): """Logs the fact we've found a lint error. We log where the error was found, and also our confidence in the error, that is, how certain we are this is a legitimate style regression, and not a misidentification or a use that's sometimes justified. ...
python
{ "resource": "" }
q31357
CheckHeaderFileIncluded
train
def CheckHeaderFileIncluded(filename, include_state, error): """Logs an error if a .cc file does not include its header.""" # Do not check test files if filename.endswith('_test.cc') or filename.endswith('_unittest.cc'): return fileinfo = FileInfo(filename) headerfile = filename[0:len(filename) - 2] + '...
python
{ "resource": "" }
q31358
CheckForBadCharacters
train
def CheckForBadCharacters(filename, lines, error): """Logs an error for each line containing bad characters. Two kinds of bad characters: 1. Unicode replacement characters: These indicate that either the file contained invalid UTF-8 (likely) or Unicode replacement characters (which it shouldn't). Note that...
python
{ "resource": "" }
q31359
CheckOperatorSpacing
train
def CheckOperatorSpacing(filename, clean_lines, linenum, error): """Checks for horizontal spacing around operators. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any...
python
{ "resource": "" }
q31360
IsDeletedOrDefault
train
def IsDeletedOrDefault(clean_lines, linenum): """Check if current constructor or operator is deleted or default. Args: clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. Returns: True if this is a deleted or default constructor. """ open_paren = c...
python
{ "resource": "" }
q31361
IsRValueAllowed
train
def IsRValueAllowed(clean_lines, linenum, typenames): """Check if RValue reference is allowed on a particular line. Args: clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. typenames: set of type names from template-argument-list. Returns: True if...
python
{ "resource": "" }
q31362
GetTemplateArgs
train
def GetTemplateArgs(clean_lines, linenum): """Find list of template arguments associated with this function declaration. Args: clean_lines: A CleansedLines instance containing the file. linenum: Line number containing the start of the function declaration, usually one line after the end of the...
python
{ "resource": "" }
q31363
CheckRValueReference
train
def CheckRValueReference(filename, clean_lines, linenum, nesting_state, error): """Check for rvalue references. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. nesting_state: A NestingState instance w...
python
{ "resource": "" }
q31364
_DropCommonSuffixes
train
def _DropCommonSuffixes(filename): """Drops common suffixes like _test.cc or -inl.h from filename. For example: >>> _DropCommonSuffixes('foo/foo-inl.h') 'foo/foo' >>> _DropCommonSuffixes('foo/bar/foo.cc') 'foo/bar/foo' >>> _DropCommonSuffixes('foo/foo_internal.h') 'foo/foo' >>> _DropCom...
python
{ "resource": "" }
q31365
CheckGlobalStatic
train
def CheckGlobalStatic(filename, clean_lines, linenum, error): """Check for unsafe global or static objects. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors ...
python
{ "resource": "" }
q31366
CheckCStyleCast
train
def CheckCStyleCast(filename, clean_lines, linenum, cast_type, pattern, error): """Checks for a C-style cast by looking for the pattern. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. cast_type: The ...
python
{ "resource": "" }
q31367
FilesBelongToSameModule
train
def FilesBelongToSameModule(filename_cc, filename_h): """Check if these two filenames belong to the same module. The concept of a 'module' here is a as follows: foo.h, foo-inl.h, foo.cc, foo_test.cc and foo_unittest.cc belong to the same 'module' if they are in the same directory. some/path/public/xyzzy and ...
python
{ "resource": "" }
q31368
CheckForIncludeWhatYouUse
train
def CheckForIncludeWhatYouUse(filename, clean_lines, include_state, error, io=codecs): """Reports for missing stl includes. This function will output warnings to make sure you are including the headers necessary for the stl containers and functions that you use. We only give one r...
python
{ "resource": "" }
q31369
CheckDefaultLambdaCaptures
train
def CheckDefaultLambdaCaptures(filename, clean_lines, linenum, error): """Check that default lambda captures are not used. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call w...
python
{ "resource": "" }
q31370
ProcessLine
train
def ProcessLine(filename, file_extension, clean_lines, line, include_state, function_state, nesting_state, error, extra_check_functions=[]): """Processes a single line in the file. Args: filename: Filename of the file that is being processed. file_extension: The extension (d...
python
{ "resource": "" }
q31371
FlagCxx11Features
train
def FlagCxx11Features(filename, clean_lines, linenum, error): """Flag those c++11 features that we only allow in certain places. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to ...
python
{ "resource": "" }
q31372
ProcessConfigOverrides
train
def ProcessConfigOverrides(filename): """ Loads the configuration files and processes the config overrides. Args: filename: The name of the file being processed by the linter. Returns: False if the current |filename| should not be processed further. """ abs_filename = os.path.abspath(filename) cf...
python
{ "resource": "" }
q31373
_CppLintState.PrintErrorCounts
train
def PrintErrorCounts(self): """Print a summary of errors by category, and the total.""" for category, count in self.errors_by_category.iteritems(): sys.stderr.write('Category \'%s\' errors found: %d\n' %
python
{ "resource": "" }
q31374
_FunctionState.Check
train
def Check(self, error, filename, linenum): """Report if too many lines in function body. Args: error: The function to call with any errors found. filename: The name of the current file. linenum: The number of the line to check. """ if Match(r'T(EST|est)', self.current_function): ...
python
{ "resource": "" }
q31375
FileInfo.RepositoryName
train
def RepositoryName(self): """FullName after removing the local path to the repository. If we have a real absolute path name here we can try to do something smart: detecting the root of the checkout and truncating /path/to/checkout from the name so that we get header guards that don't include things lik...
python
{ "resource": "" }
q31376
_NamespaceInfo.CheckEnd
train
def CheckEnd(self, filename, clean_lines, linenum, error): """Check end of namespace comments.""" line = clean_lines.raw_lines[linenum] # Check how many lines is enclosed in this namespace. Don't issue # warning for missing namespace comments if there aren't enough # lines. However, do apply chec...
python
{ "resource": "" }
q31377
PDeque.append
train
def append(self, elem): """ Return new deque with elem as the rightmost element. >>> pdeque([1, 2]).append(3) pdeque([1, 2, 3]) """
python
{ "resource": "" }
q31378
PDeque.extend
train
def extend(self, iterable): """ Return new deque with all elements of iterable appended to the right. >>> pdeque([1, 2]).extend([3, 4])
python
{ "resource": "" }
q31379
PDeque.count
train
def count(self, elem): """ Return the number of elements equal to elem present in the queue
python
{ "resource": "" }
q31380
PDeque.remove
train
def remove(self, elem): """ Return new deque with first element from left equal to elem removed. If no such element is found a ValueError is raised. >>> pdeque([2, 1, 2]).remove(2) pdeque([1, 2]) """ try: return PDeque(self._left_list.remove(elem), se...
python
{ "resource": "" }
q31381
PDeque.rotate
train
def rotate(self, steps): """ Return deque with elements rotated steps steps. >>> x = pdeque([1, 2, 3]) >>> x.rotate(1) pdeque([3, 1, 2]) >>> x.rotate(-2) pdeque([3, 1, 2]) """
python
{ "resource": "" }
q31382
PMap.set
train
def set(self, key, val): """ Return a new PMap with key and val inserted. >>> m1 = m(a=1, b=2) >>> m2 = m1.set('a', 3) >>> m3 = m1.set('c' ,4) >>> m1 pmap({'a': 1, 'b': 2}) >>>
python
{ "resource": "" }
q31383
PMap.update_with
train
def update_with(self, update_fn, *maps): """ Return a new PMap with the items in Mappings maps inserted. If the same key is present in multiple maps the values will be merged using merge_fn going from left to right. >>> from operator import add >>> m1 = m(a=1, b=2) >>> m...
python
{ "resource": "" }
q31384
rex
train
def rex(expr): """ Regular expression matcher to use together with transform functions """ r = re.compile(expr)
python
{ "resource": "" }
q31385
PBag.update
train
def update(self, iterable): """ Update bag with all elements in iterable. >>> s = pbag([1]) >>> s.update([1, 2]) pbag([1, 1, 2]) """
python
{ "resource": "" }
q31386
PBag.remove
train
def remove(self, element): """ Remove an element from the bag. >>> s = pbag([1, 1, 2]) >>> s2 = s.remove(1) >>> s3 = s.remove(2) >>> s2 pbag([1, 2]) >>> s3 pbag([1, 1]) """ if element not in self._counts:
python
{ "resource": "" }
q31387
freeze
train
def freeze(o): """ Recursively convert simple Python containers into pyrsistent versions of those containers. - list is converted to pvector, recursively - dict is converted to pmap, recursively on values (but not keys) - set is converted to pset, but not recursively - tuple is converted to...
python
{ "resource": "" }
q31388
thaw
train
def thaw(o): """ Recursively convert pyrsistent containers into simple Python containers. - pvector is converted to list, recursively - pmap is converted to dict, recursively on values (but not keys) - pset is converted to set, but not recursively - tuple is converted to tuple, recursively. ...
python
{ "resource": "" }
q31389
plist
train
def plist(iterable=(), reverse=False): """ Creates a new persistent list containing all elements of iterable. Optional parameter reverse specifies if the elements should be inserted in reverse order or not. >>> plist([1, 2, 3]) plist([1, 2, 3]) >>> plist([1, 2, 3], reverse=True)
python
{ "resource": "" }
q31390
PSet.update
train
def update(self, iterable): """ Return a new PSet with elements in iterable added >>> s1 = s(1, 2) >>> s1.update([3, 4, 4]) pset([1, 2, 3, 4]) """
python
{ "resource": "" }
q31391
PSet.remove
train
def remove(self, element): """ Return a new PSet with element removed. Raises KeyError if element is not present. >>> s1 = s(1, 2) >>> s1.remove(2) pset([1]) """
python
{ "resource": "" }
q31392
PSet.discard
train
def discard(self, element): """ Return a new PSet with element removed. Returns itself if element is
python
{ "resource": "" }
q31393
maybe_parse_user_type
train
def maybe_parse_user_type(t): """Try to coerce a user-supplied type directive into a list of types. This function should be used in all places where a user specifies a type, for consistency. The policy for what defines valid user input should be clear from the implementation. """ is_type = isi...
python
{ "resource": "" }
q31394
_all_dicts
train
def _all_dicts(bases, seen=None): """ Yield each class in ``bases`` and each of their base classes. """ if seen is None: seen = set() for cls in bases: if cls in seen:
python
{ "resource": "" }
q31395
PythonPVector.tolist
train
def tolist(self): """ The fastest way to convert the vector into a python list. """ the_list = []
python
{ "resource": "" }
q31396
PythonPVector._push_tail
train
def _push_tail(self, level, parent, tail_node): """ if parent is leaf, insert node, else does it map to an existing child? -> node_to_insert = push node one more level else alloc new path return node_to_insert placed in copy of parent """ ret = list...
python
{ "resource": "" }
q31397
_make_seq_field_type
train
def _make_seq_field_type(checked_class, item_type): """Create a subclass of the given checked class with the given item type.""" type_ = _seq_field_types.get((checked_class, item_type)) if type_ is not None: return type_ class TheType(checked_class):
python
{ "resource": "" }
q31398
_sequence_field
train
def _sequence_field(checked_class, item_type, optional, initial): """ Create checked field for either ``PSet`` or ``PVector``. :param checked_class: ``CheckedPSet`` or ``CheckedPVector``. :param item_type: The required type for the items in the set. :param optional: If true, ``None`` can be used as...
python
{ "resource": "" }
q31399
pset_field
train
def pset_field(item_type, optional=False, initial=()): """ Create checked ``PSet`` field. :param item_type: The required type for the items in the set. :param optional: If true, ``None`` can be used as a value for this field. :param initial: Initial value to pass to factory if no value is g...
python
{ "resource": "" }