code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def shorten_path(location, bold=False): original = location short = os.sep.join( [s[0] if len(s) > (len("2long4")) else s for s in location.split(os.sep)] ) short = short.split(os.sep) short[-1] = original.split(os.sep)[-1] if bold: short[-1] = str(crayons.normal(short[-1], bold=True)) return os.sep.join(short)
module function_definition identifier parameters identifier default_parameter identifier false block expression_statement assignment identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list list_comprehension conditional_expression subscript identifier integer comparison_operator call identifier argument_list identifier parenthesized_expression call identifier argument_list string string_start string_content string_end identifier for_in_clause identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment subscript identifier unary_operator integer subscript call attribute identifier identifier argument_list attribute identifier identifier unary_operator integer if_statement identifier block expression_statement assignment subscript identifier unary_operator integer call identifier argument_list call attribute identifier identifier argument_list subscript identifier unary_operator integer keyword_argument identifier true return_statement call attribute attribute identifier identifier identifier argument_list identifier
Returns a visually shorter representation of a given system path.
def _get_queue(self): if self._queue is None: self._links = [] queue, depth = self._resolve_queue(self.queue, links=self._links) if queue is None and depth > 0: raise QueueLinkBroken self._queue = queue return self._queue
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier list expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier attribute identifier identifier if_statement boolean_operator comparison_operator identifier none comparison_operator identifier integer block raise_statement identifier expression_statement assignment attribute identifier identifier identifier return_statement attribute identifier identifier
Gets the actual location of the queue, or None.
def column(environment, book, sheet_name, sheet_source, column_source, column_key): a = book.sheets[sheet_source] b = book.sheets[sheet_name] return environment.copy([a.get(**{column_key: row[column_key]})[column_source] for row in b.all()])
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier identifier expression_statement assignment identifier subscript attribute identifier identifier identifier return_statement call attribute identifier identifier argument_list list_comprehension subscript call attribute identifier identifier argument_list dictionary_splat dictionary pair identifier subscript identifier identifier identifier for_in_clause identifier call attribute identifier identifier argument_list
Returns an array of values from column from a different dataset, ordered as the key.
def _get_centroid_time(self, time_diff): source_time = datetime.datetime.combine(self.date, self.time) second_diff = floor(fabs(time_diff)) microsecond_diff = int(1000. * (time_diff - second_diff)) if time_diff < 0.: source_time = source_time - datetime.timedelta( seconds=int(second_diff), microseconds=microsecond_diff) else: source_time = source_time + datetime.timedelta( seconds=int(second_diff), microseconds=microsecond_diff) self.time = source_time.time() self.date = source_time.date()
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list binary_operator float parenthesized_expression binary_operator identifier identifier if_statement comparison_operator identifier float block expression_statement assignment identifier binary_operator identifier call attribute identifier identifier argument_list keyword_argument identifier call identifier argument_list identifier keyword_argument identifier identifier else_clause block expression_statement assignment identifier binary_operator identifier call attribute identifier identifier argument_list keyword_argument identifier call identifier argument_list identifier keyword_argument identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list
Calculates the time difference between the date-time classes
def file_downloaded(dwn, fName, verbose=False): if verbose: if dwn == 200: fName, fExt = os.path.splitext(fName) print 'Downloaded ' + fName + '.srt' return True elif dwn != -1: print 'Tried downloading got ' + str(dwn) + ' for ' + fName return False
module function_definition identifier parameters identifier identifier default_parameter identifier false block if_statement identifier block if_statement comparison_operator identifier integer block expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list identifier print_statement binary_operator binary_operator string string_start string_content string_end identifier string string_start string_content string_end return_statement true elif_clause comparison_operator identifier unary_operator integer block print_statement binary_operator binary_operator binary_operator string string_start string_content string_end call identifier argument_list identifier string string_start string_content string_end identifier return_statement false
print for downloaded file
def to_proto(self): return sorted((s.get_proto() for s in self.values()), key=lambda s: s.name)
module function_definition identifier parameters identifier block return_statement call identifier argument_list generator_expression call attribute identifier identifier argument_list for_in_clause identifier call attribute identifier identifier argument_list keyword_argument identifier lambda lambda_parameters identifier attribute identifier identifier
Returns a list of SplitInfo protos that we have.
def _delete(self, tree): tablename = tree.table table = self.describe(tablename, require=True) kwargs = {} visitor = Visitor(self.reserved_words) if tree.where: constraints = ConstraintExpression.from_where(tree.where) kwargs["condition"] = constraints.build(visitor) kwargs["expr_values"] = visitor.expression_values kwargs["alias"] = visitor.attribute_names return self._query_and_op(tree, table, "delete_item", kwargs)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier true expression_statement assignment identifier dictionary expression_statement assignment identifier call identifier argument_list attribute identifier identifier if_statement attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list identifier expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier return_statement call attribute identifier identifier argument_list identifier identifier string string_start string_content string_end identifier
Run a DELETE statement
def ObjectTransitionedEventHandler(obj, event): if not supports_snapshots(obj): return entry = { "modified": DateTime().ISO(), "action": event.action, } history = api.get_review_history(obj, rev=True) if history: entry = history[0] timestamp = entry.pop("time", DateTime()) entry["modified"] = timestamp.ISO() entry["action"] = event.action take_snapshot(obj, **entry) reindex_object(obj)
module function_definition identifier parameters identifier identifier block if_statement not_operator call identifier argument_list identifier block return_statement expression_statement assignment identifier dictionary pair string string_start string_content string_end call attribute call identifier argument_list identifier argument_list pair string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier true if_statement identifier block expression_statement assignment identifier subscript identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier expression_statement call identifier argument_list identifier dictionary_splat identifier expression_statement call identifier argument_list identifier
Object has been transitioned to an new state
def initialize(self, request): if request.method == 'GET': self.query = request.META.get('QUERY_STRING', '') elif request.method == 'POST': self.query = request.body.decode('ascii') self.ipaddress = request.META.get('REMOTE_ADDR', '')
module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_end elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_end
Store the data we'll need to make the postback from the request object.
def print_title(title): sprint('\n') sprint('=={}=='.format('=' * len(title))) sprint('= {} ='.format(title)) sprint('=={}=='.format('=' * len(title)))
module function_definition identifier parameters identifier block expression_statement call identifier argument_list string string_start string_content escape_sequence string_end expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list identifier expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list identifier
Helper function to print titles to the console more nicely
def _radix_sort(L, i=0): if len(L) <= 1: return L done_bucket = [] buckets = [ [] for x in range(255) ] for s in L: if i >= len(s): done_bucket.append(s) else: buckets[ ord(s[i]) ].append(s) buckets = [ _radix_sort(b, i + 1) for b in buckets ] return done_bucket + [ b for blist in buckets for b in blist ]
module function_definition identifier parameters identifier default_parameter identifier integer block if_statement comparison_operator call identifier argument_list identifier integer block return_statement identifier expression_statement assignment identifier list expression_statement assignment identifier list_comprehension list for_in_clause identifier call identifier argument_list integer for_statement identifier identifier block if_statement comparison_operator identifier call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement call attribute subscript identifier call identifier argument_list subscript identifier identifier identifier argument_list identifier expression_statement assignment identifier list_comprehension call identifier argument_list identifier binary_operator identifier integer for_in_clause identifier identifier return_statement binary_operator identifier list_comprehension identifier for_in_clause identifier identifier for_in_clause identifier identifier
Most significant char radix sort
def serve_private_file(request, path): logger.debug('Serving {0} to {1}'.format(path, request.user)) if not permissions.has_read_permission(request, path): if settings.DEBUG: raise PermissionDenied else: raise Http404('File not found') return server.serve(request, path=path)
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier attribute identifier identifier if_statement not_operator call attribute identifier identifier argument_list identifier identifier block if_statement attribute identifier identifier block raise_statement identifier else_clause block raise_statement call identifier argument_list string string_start string_content string_end return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier
Serve private files to users with read permission.
def head(filename, n=10): with freader(filename) as fr: for _ in range(n): print(fr.readline().strip())
module function_definition identifier parameters identifier default_parameter identifier integer block with_statement with_clause with_item as_pattern call identifier argument_list identifier as_pattern_target identifier block for_statement identifier call identifier argument_list identifier block expression_statement call identifier argument_list call attribute call attribute identifier identifier argument_list identifier argument_list
prints the top `n` lines of a file
def _pfp__handle_updated(self, watched_field): self._pfp__no_notify = True if watched_field is self._: self._pfp__pack_data() elif self._pfp__update_func is not None: self._pfp__update_func.call( [self] + self._pfp__watch_fields, *self._pfp__update_func_call_info ) self._pfp__no_notify = False
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier true if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list elif_clause comparison_operator attribute identifier identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator list identifier attribute identifier identifier list_splat attribute identifier identifier expression_statement assignment attribute identifier identifier false
Handle the watched field that was updated
def convert(self, value, param, ctx): self.gandi = ctx.obj if value in self.choices: return value new_value = '%s-x86_64' % value if new_value in self.choices: return new_value self.fail('invalid choice: %s. (choose from %s)' % (value, ', '.join(self.choices)), param, ctx)
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment attribute identifier identifier attribute identifier identifier if_statement comparison_operator identifier attribute identifier identifier block return_statement identifier expression_statement assignment identifier binary_operator string string_start string_content string_end identifier if_statement comparison_operator identifier attribute identifier identifier block return_statement identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier identifier identifier
Try to find correct kernel regarding version.
def provision_system_vessel(items, database_name, overwrite=False, clear=False, skip_user_check=False): from hfos.provisions.base import provisionList from hfos.database import objectmodels vessel = objectmodels['vessel'].find_one({'name': 'Default System Vessel'}) if vessel is not None: if overwrite is False: hfoslog('Default vessel already existing. Skipping provisions.') return else: vessel.delete() provisionList([SystemVessel], 'vessel', overwrite, clear, skip_user_check) sysconfig = objectmodels['systemconfig'].find_one({'active': True}) hfoslog('Adapting system config for default vessel:', sysconfig) sysconfig.vesseluuid = SystemVessel['uuid'] sysconfig.save() hfoslog('Provisioning: Vessel: Done.', emitter='PROVISIONS')
module function_definition identifier parameters identifier identifier default_parameter identifier false default_parameter identifier false default_parameter identifier false block import_from_statement dotted_name identifier identifier identifier dotted_name identifier import_from_statement dotted_name identifier identifier dotted_name identifier expression_statement assignment identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list dictionary pair string string_start string_content string_end string string_start string_content string_end if_statement comparison_operator identifier none block if_statement comparison_operator identifier false block expression_statement call identifier argument_list string string_start string_content string_end return_statement else_clause block expression_statement call attribute identifier identifier argument_list expression_statement call identifier argument_list list identifier string string_start string_content string_end identifier identifier identifier expression_statement assignment identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list dictionary pair string string_start string_content string_end true expression_statement call identifier argument_list string string_start string_content string_end identifier expression_statement assignment attribute identifier identifier subscript identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list expression_statement call identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end
Provisions the default system vessel
def _orientation_ok_to_bridge_contigs(self, start_hit, end_hit): assert start_hit.qry_name == end_hit.qry_name if start_hit.ref_name == end_hit.ref_name: return False if ( (self._is_at_ref_end(start_hit) and start_hit.on_same_strand()) or (self._is_at_ref_start(start_hit) and not start_hit.on_same_strand()) ): start_hit_ok = True else: start_hit_ok = False if ( (self._is_at_ref_start(end_hit) and end_hit.on_same_strand()) or (self._is_at_ref_end(end_hit) and not end_hit.on_same_strand()) ): end_hit_ok = True else: end_hit_ok = False return start_hit_ok and end_hit_ok
module function_definition identifier parameters identifier identifier identifier block assert_statement comparison_operator attribute identifier identifier attribute identifier identifier if_statement comparison_operator attribute identifier identifier attribute identifier identifier block return_statement false if_statement parenthesized_expression boolean_operator parenthesized_expression boolean_operator call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list parenthesized_expression boolean_operator call attribute identifier identifier argument_list identifier not_operator call attribute identifier identifier argument_list block expression_statement assignment identifier true else_clause block expression_statement assignment identifier false if_statement parenthesized_expression boolean_operator parenthesized_expression boolean_operator call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list parenthesized_expression boolean_operator call attribute identifier identifier argument_list identifier not_operator call attribute identifier identifier argument_list block expression_statement assignment identifier true else_clause block expression_statement assignment identifier false return_statement boolean_operator identifier identifier
Returns True iff the orientation of the hits means that the query contig of both hits can bridge the reference contigs of the hits
def queue_async_stats_job(klass, account, ids, metric_groups, **kwargs): params = klass._standard_params(ids, metric_groups, **kwargs) params['platform'] = kwargs.get('platform', None) params['country'] = kwargs.get('country', None) params['segmentation_type'] = kwargs.get('segmentation_type', None) resource = klass.RESOURCE_ASYNC.format(account_id=account.id) response = Request(account.client, 'post', resource, params=params).perform() return response.body['data']
module function_definition identifier parameters identifier identifier identifier identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier dictionary_splat identifier expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end none expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end none expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end none expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier expression_statement assignment identifier call attribute call identifier argument_list attribute identifier identifier string string_start string_content string_end identifier keyword_argument identifier identifier identifier argument_list return_statement subscript attribute identifier identifier string string_start string_content string_end
Queues a list of metrics for a specified set of object IDs asynchronously
def _forward(self, x_dot_parameters): return forward(self._lattice, x_dot_parameters, self.state_machine.n_states)
module function_definition identifier parameters identifier identifier block return_statement call identifier argument_list attribute identifier identifier identifier attribute attribute identifier identifier identifier
Helper to calculate the forward weights.
def validate_rid(model, rid): rid_field = getattr(model, model.rid_field) if isinstance(rid_field, IntType): try: int(rid) except (TypeError, ValueError): abort(exceptions.InvalidURL(**{ 'detail': 'The resource id {} in your request is not ' 'syntactically correct. Only numeric type ' 'resource id\'s are allowed'.format(rid) }))
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier attribute identifier identifier if_statement call identifier argument_list identifier identifier block try_statement block expression_statement call identifier argument_list identifier except_clause tuple identifier identifier block expression_statement call identifier argument_list call attribute identifier identifier argument_list dictionary_splat dictionary pair string string_start string_content string_end call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content escape_sequence string_end identifier argument_list identifier
Ensure the resource id is proper
def reference_index(self): if self._db_location: ref_indices = glob.glob(os.path.join(self._db_location, "*", self._REF_INDEX)) if ref_indices: return ref_indices[0]
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list attribute identifier identifier string string_start string_content string_end attribute identifier identifier if_statement identifier block return_statement subscript identifier integer
Absolute path to the BWA index for EricScript reference data.
def _get_string(data, position, obj_end, dummy): length = _UNPACK_INT(data[position:position + 4])[0] position += 4 if length < 1 or obj_end - position < length: raise InvalidBSON("invalid string length") end = position + length - 1 if data[end:end + 1] != b"\x00": raise InvalidBSON("invalid end of string") return _utf_8_decode(data[position:end], None, True)[0], end + 1
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier subscript call identifier argument_list subscript identifier slice identifier binary_operator identifier integer integer expression_statement augmented_assignment identifier integer if_statement boolean_operator comparison_operator identifier integer comparison_operator binary_operator identifier identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier binary_operator binary_operator identifier identifier integer if_statement comparison_operator subscript identifier slice identifier binary_operator identifier integer string string_start string_content escape_sequence string_end block raise_statement call identifier argument_list string string_start string_content string_end return_statement expression_list subscript call identifier argument_list subscript identifier slice identifier identifier none true integer binary_operator identifier integer
Decode a BSON string to python unicode string.
def prepare_shell_data(self, shells, key, entry): if self.can_process_shell(entry): if key in ['python']: entry['type'] = key if 'with' in entry and isinstance(entry['with'], str): rendered_with = ast.literal_eval(render(entry['with'], variables=self.pipeline.variables, model=self.pipeline.model, env=self.get_merged_env(include_os=True))) elif 'with' in entry: rendered_with = entry['with'] else: rendered_with = [''] for item in rendered_with: shells.append({ 'id': self.next_task_id, 'creator': key, 'entry': entry, 'model': self.pipeline.model, 'env': self.get_merged_env(), 'item': item, 'dry_run': self.pipeline.options.dry_run, 'debug': self.pipeline.options.debug, 'strict': self.pipeline.options.strict, 'variables': self.pipeline.variables, 'temporary_scripts_path': self.pipeline.options.temporary_scripts_path}) self.next_task_id += 1
module function_definition identifier parameters identifier identifier identifier identifier block if_statement call attribute identifier identifier argument_list identifier block if_statement comparison_operator identifier list string string_start string_content string_end block expression_statement assignment subscript identifier string string_start string_content string_end identifier if_statement boolean_operator comparison_operator string string_start string_content string_end identifier call identifier argument_list subscript identifier string string_start string_content string_end identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list subscript identifier string string_start string_content string_end keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier call attribute identifier identifier argument_list keyword_argument identifier true elif_clause comparison_operator string string_start string_content string_end identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end else_clause block expression_statement assignment identifier list string string_start string_end for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end attribute attribute identifier identifier identifier pair string string_start string_content string_end call attribute identifier identifier argument_list pair string string_start string_content string_end identifier pair string string_start string_content string_end attribute attribute attribute identifier identifier identifier identifier pair string string_start string_content string_end attribute attribute attribute identifier identifier identifier identifier pair string string_start string_content string_end attribute attribute attribute identifier identifier identifier identifier pair string string_start string_content string_end attribute attribute identifier identifier identifier pair string string_start string_content string_end attribute attribute attribute identifier identifier identifier identifier expression_statement augmented_assignment attribute identifier identifier integer
Prepare one shell or docker task.
def _init_logging(anteater_log): LOG.setLevel(logging.DEBUG) ch = logging.StreamHandler() formatter = logging.Formatter('%(asctime)s - %(name)s - ' '%(levelname)s - %(message)s') ch.setFormatter(formatter) ch.setLevel(logging.DEBUG) path = os.path.dirname(anteater_log) try: os.makedirs(path) except OSError as e: if e.errno != errno.EEXIST: raise handler = logging.FileHandler(anteater_log) handler.setFormatter(formatter) handler.setLevel(logging.DEBUG) del logging.root.handlers[:] logging.root.addHandler(ch) logging.root.addHandler(handler)
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier try_statement block expression_statement call attribute identifier identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block raise_statement expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier delete_statement subscript attribute attribute identifier identifier identifier slice expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Setup root logger for package
def intervalSimulate (interval): from .. import sim sim.runSimWithIntervalFunc(interval, sim.intervalSave) sim.fileGather()
module function_definition identifier parameters identifier block import_from_statement relative_import import_prefix dotted_name identifier expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list
Sequence of commands to simulate network
def MakeDestinationKey(directory, filename): return utils.SmartStr(utils.JoinPath(directory, filename)).lstrip("/")
module function_definition identifier parameters identifier identifier block return_statement call attribute call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier identifier identifier argument_list string string_start string_content string_end
Creates a name that identifies a database file.
def send_email(self): if self.check_user_settings(): send_mail(_(self.type), self.email_message, settings.DEFAULT_FROM_EMAIL, [self.to_user.email]) return True else: return False
module function_definition identifier parameters identifier block if_statement call attribute identifier identifier argument_list block expression_statement call identifier argument_list call identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier list attribute attribute identifier identifier identifier return_statement true else_clause block return_statement false
send email notification according to user settings
def retry_mkstemp(suffix='', prefix='tmp', directory=None, max_retries=3): if directory is None: directory = current_app.config['CFG_TMPSHAREDDIR'] for retry_count in range(1, max_retries + 1): try: tmp_file_fd, tmp_file_name = tempfile.mkstemp(suffix=suffix, prefix=prefix, dir=directory) except OSError as e: if e.errno == 19 and retry_count <= max_retries: time.sleep(10) else: raise else: break return tmp_file_fd, tmp_file_name
module function_definition identifier parameters default_parameter identifier string string_start string_end default_parameter identifier string string_start string_content string_end default_parameter identifier none default_parameter identifier integer block if_statement comparison_operator identifier none block expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end for_statement identifier call identifier argument_list integer binary_operator identifier integer block try_statement block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier except_clause as_pattern identifier as_pattern_target identifier block if_statement boolean_operator comparison_operator attribute identifier identifier integer comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list integer else_clause block raise_statement else_clause block break_statement return_statement expression_list identifier identifier
Make mkstemp more robust against AFS glitches.
def _GetDiscoveryDocFromFlags(args): if args.discovery_url: try: return util.FetchDiscoveryDoc(args.discovery_url) except exceptions.CommunicationError: raise exceptions.GeneratedClientError( 'Could not fetch discovery doc') infile = os.path.expanduser(args.infile) or '/dev/stdin' with io.open(infile, encoding='utf8') as f: return json.loads(util.ReplaceHomoglyphs(f.read()))
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block try_statement block return_statement call attribute identifier identifier argument_list attribute identifier identifier except_clause attribute identifier identifier block raise_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier boolean_operator call attribute attribute identifier identifier identifier argument_list attribute identifier identifier string string_start string_content string_end with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end as_pattern_target identifier block return_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list
Get the discovery doc from flags.
def create_proxy_model(name, model_mixins, base_model, attrs=None, module=None): from django.apps import apps class Meta: proxy = True app_label = 'cmsplugin_cascade' name = str(name + 'Model') try: Model = apps.get_registered_model(Meta.app_label, name) except LookupError: bases = model_mixins + (base_model,) attrs = dict(attrs or {}, Meta=Meta, __module__=module) Model = type(name, bases, attrs) fake_proxy_models[name] = bases return Model
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none default_parameter identifier none block import_from_statement dotted_name identifier identifier dotted_name identifier class_definition identifier block expression_statement assignment identifier true expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list binary_operator identifier string string_start string_content string_end try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier identifier except_clause identifier block expression_statement assignment identifier binary_operator identifier tuple identifier expression_statement assignment identifier call identifier argument_list boolean_operator identifier dictionary keyword_argument identifier identifier keyword_argument identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier identifier expression_statement assignment subscript identifier identifier identifier return_statement identifier
Create a Django Proxy Model on the fly, to be used by any Cascade Plugin.
def reorder(self, single_column=False): if single_column: columns = self.sortOrder[:1] else: columns = self.sortOrder for ascending,column in columns[::-1]: self.sorted.sort( key=column.get, reverse=(not ascending))
module function_definition identifier parameters identifier default_parameter identifier false block if_statement identifier block expression_statement assignment identifier subscript attribute identifier identifier slice integer else_clause block expression_statement assignment identifier attribute identifier identifier for_statement pattern_list identifier identifier subscript identifier slice unary_operator integer block expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier parenthesized_expression not_operator identifier
Force a reorder of the displayed items
def generate_data_with_shared_vocab(self, data_dir, tmp_dir, task_id=-1): global_vocab_filename = os.path.join(data_dir, self.vocab_filename) if not tf.gfile.Exists(global_vocab_filename): raise ValueError( 'Global vocabulary file: %s does not exist, ' 'please create one using build_vocab.py' % global_vocab_filename) for p in self.problems: local_vocab_filename = os.path.join(data_dir, p.vocab_filename) if not tf.gfile.Exists(local_vocab_filename): tf.gfile.Copy(global_vocab_filename, local_vocab_filename) p.generate_data(data_dir, tmp_dir, task_id)
module function_definition identifier parameters identifier identifier identifier default_parameter identifier unary_operator integer block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier attribute identifier identifier if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block raise_statement call identifier argument_list binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end identifier for_statement identifier attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier attribute identifier identifier if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier identifier
Generates TF-Records for problems using a global vocabulary file.
def git_check(): git_status = subprocess.check_output(['git', 'status', '--porcelain']) if len(git_status) is 0: print(Fore.GREEN + 'All changes committed' + Style.RESET_ALL) else: exit(Fore.RED + 'Please commit all files to continue')
module function_definition identifier parameters block expression_statement assignment identifier call attribute identifier identifier argument_list list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end if_statement comparison_operator call identifier argument_list identifier integer block expression_statement call identifier argument_list binary_operator binary_operator attribute identifier identifier string string_start string_content string_end attribute identifier identifier else_clause block expression_statement call identifier argument_list binary_operator attribute identifier identifier string string_start string_content string_end
Check for uncomitted changes
def add_parameter(self, parameter): if parameter.name.lower() not in self.paramorder: self.paramorder.append(parameter.name.lower()) self._parameters[parameter.name.lower()] = parameter
module function_definition identifier parameters identifier identifier block if_statement comparison_operator call attribute attribute identifier identifier identifier argument_list attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list expression_statement assignment subscript attribute identifier identifier call attribute attribute identifier identifier identifier argument_list identifier
Adds the specified parameter value to the list.
def create_project_config_path( path, mode=0o777, parents=False, exist_ok=False ): project_path = Path(path).absolute().joinpath(RENKU_HOME) project_path.mkdir(mode=mode, parents=parents, exist_ok=exist_ok) return str(project_path)
module function_definition identifier parameters identifier default_parameter identifier integer default_parameter identifier false default_parameter identifier false block expression_statement assignment identifier call attribute call attribute call identifier argument_list identifier identifier argument_list identifier argument_list identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier return_statement call identifier argument_list identifier
Create new project configuration folder.
def _getText(nodelist): rc = [] for node in nodelist: if node.nodeType == node.TEXT_NODE: rc.append(node.data) return ''.join(rc)
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier identifier block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier return_statement call attribute string string_start string_end identifier argument_list identifier
Simple function to return value from XML
def from_environ(cls, environ=os.environ): base_path, unused = (environ['PATH_INFO'].rsplit('/', 1) + [''])[:2] return cls( environ['HTTP_X_APPENGINE_TASKNAME'], environ['HTTP_X_APPENGINE_QUEUENAME'], base_path)
module function_definition identifier parameters identifier default_parameter identifier attribute identifier identifier block expression_statement assignment pattern_list identifier identifier subscript parenthesized_expression binary_operator call attribute subscript identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end integer list string string_start string_end slice integer return_statement call identifier argument_list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end identifier
Constructs a _PipelineContext from the task queue environment.
def range(self, value): self._buffer.append(abs(value)) mean = sum(self._buffer) / len(self._buffer) estimate = next( (r for r in self.ranges if mean < self.scale * r), self.ranges[-1] ) if self._mapping: return self._mapping[estimate] else: return estimate
module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list identifier expression_statement assignment identifier binary_operator call identifier argument_list attribute identifier identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier call identifier argument_list generator_expression identifier for_in_clause identifier attribute identifier identifier if_clause comparison_operator identifier binary_operator attribute identifier identifier identifier subscript attribute identifier identifier unary_operator integer if_statement attribute identifier identifier block return_statement subscript attribute identifier identifier identifier else_clause block return_statement identifier
Estimates an appropriate sensitivity range.
def place_visual(self): index = 0 bin_pos = string_to_array(self.bin2_body.get("pos")) bin_size = self.bin_size for _, obj_mjcf in self.visual_objects: bin_x_low = bin_pos[0] bin_y_low = bin_pos[1] if index == 0 or index == 2: bin_x_low -= bin_size[0] / 2 if index < 2: bin_y_low -= bin_size[1] / 2 bin_x_high = bin_x_low + bin_size[0] / 2 bin_y_high = bin_y_low + bin_size[1] / 2 bottom_offset = obj_mjcf.get_bottom_offset() bin_range = [bin_x_low + bin_x_high, bin_y_low + bin_y_high, 2 * bin_pos[2]] bin_center = np.array(bin_range) / 2.0 pos = bin_center - bottom_offset self.visual_obj_mjcf[index].set("pos", array_to_string(pos)) index += 1
module function_definition identifier parameters identifier block expression_statement assignment identifier integer expression_statement assignment identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier attribute identifier identifier for_statement pattern_list identifier identifier attribute identifier identifier block expression_statement assignment identifier subscript identifier integer expression_statement assignment identifier subscript identifier integer if_statement boolean_operator comparison_operator identifier integer comparison_operator identifier integer block expression_statement augmented_assignment identifier binary_operator subscript identifier integer integer if_statement comparison_operator identifier integer block expression_statement augmented_assignment identifier binary_operator subscript identifier integer integer expression_statement assignment identifier binary_operator identifier binary_operator subscript identifier integer integer expression_statement assignment identifier binary_operator identifier binary_operator subscript identifier integer integer expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier list binary_operator identifier identifier binary_operator identifier identifier binary_operator integer subscript identifier integer expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list identifier float expression_statement assignment identifier binary_operator identifier identifier expression_statement call attribute subscript attribute identifier identifier identifier identifier argument_list string string_start string_content string_end call identifier argument_list identifier expression_statement augmented_assignment identifier integer
Places visual objects randomly until no collisions or max iterations hit.
def run_steps_from_string(self, spec, language_name='en'): caller = inspect.currentframe().f_back line = caller.f_lineno - 1 fname = caller.f_code.co_filename steps = parse_steps(spec, fname, line, load_language(language_name)) for s in steps: self.run_step(s)
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier attribute call attribute identifier identifier argument_list identifier expression_statement assignment identifier binary_operator attribute identifier identifier integer expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier identifier call identifier argument_list identifier for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier
Called from within step definitions to run other steps.
def src_paths_changed(self): diff_dict = self._git_diff() return sorted(diff_dict.keys(), key=lambda x: x.lower())
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list return_statement call identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier lambda lambda_parameters identifier call attribute identifier identifier argument_list
See base class docstring.
def run(self): arg_prospector = f'prospector --output-format json {self.repo.diff_files()}' analysis = subprocess.run(arg_prospector, stdout=subprocess.PIPE, shell=True) return json.loads(analysis.stdout)
module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_content interpolation call attribute attribute identifier identifier identifier argument_list string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier true return_statement call attribute identifier identifier argument_list attribute identifier identifier
Runs prospector in the input files and returns a json with the analysis
def rename_tab_uuid(self, term_uuid, new_text, user_set=True): term_uuid = uuid.UUID(term_uuid) page_index, = ( index for index, t in enumerate(self.get_notebook().iter_terminals()) if t.get_uuid() == term_uuid ) self.get_notebook().rename_page(page_index, new_text, user_set)
module function_definition identifier parameters identifier identifier identifier default_parameter identifier true block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment pattern_list identifier generator_expression identifier for_in_clause pattern_list identifier identifier call identifier argument_list call attribute call attribute identifier identifier argument_list identifier argument_list if_clause comparison_operator call attribute identifier identifier argument_list identifier expression_statement call attribute call attribute identifier identifier argument_list identifier argument_list identifier identifier identifier
Rename an already added tab by its UUID
def _merge(*args): return re.compile(r'^' + r'[/-]'.join(args) + r'(?:\s+' + _dow + ')?$')
module function_definition identifier parameters list_splat_pattern identifier block return_statement call attribute identifier identifier argument_list binary_operator binary_operator binary_operator binary_operator string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list identifier string string_start string_content string_end identifier string string_start string_content string_end
Create a composite pattern and compile it.
def close( self, nonce: Nonce, balance_hash: BalanceHash, additional_hash: AdditionalHash, signature: Signature, block_identifier: BlockSpecification, ): self.token_network.close( channel_identifier=self.channel_identifier, partner=self.participant2, balance_hash=balance_hash, nonce=nonce, additional_hash=additional_hash, signature=signature, given_block_identifier=block_identifier, )
module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier block expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
Closes the channel using the provided balance proof.
def to_timezone(dt, tzinfo=None): if not dt: return dt tz = pick_timezone(tzinfo, __timezone__) if not tz: return dt dttz = getattr(dt, 'tzinfo', None) if not dttz: return dt.replace(tzinfo=tz) else: return dt.astimezone(tz)
module function_definition identifier parameters identifier default_parameter identifier none block if_statement not_operator identifier block return_statement identifier expression_statement assignment identifier call identifier argument_list identifier identifier if_statement not_operator identifier block return_statement identifier expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end none if_statement not_operator identifier block return_statement call attribute identifier identifier argument_list keyword_argument identifier identifier else_clause block return_statement call attribute identifier identifier argument_list identifier
Convert a datetime to timezone
def age(self): aff4_type = self.Get(self.Schema.TYPE) if aff4_type: return aff4_type.age else: return rdfvalue.RDFDatetime.Now()
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute attribute identifier identifier identifier if_statement identifier block return_statement attribute identifier identifier else_clause block return_statement call attribute attribute identifier identifier identifier argument_list
RDFDatetime at which the object was created.
def startLoading(self): if super(XBatchItem, self).startLoading(): tree = self.treeWidget() if not isinstance(tree, XOrbTreeWidget): self.takeFromTree() return next_batch = self.batch() tree._loadBatch(self, next_batch)
module function_definition identifier parameters identifier block if_statement call attribute call identifier argument_list identifier identifier identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement not_operator call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list return_statement expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier identifier
Starts loading this item for the batch.
def check_permission(cls, role, permission): result = permission in settings.ARCTIC_ROLES[role] if result: try: return getattr(cls, permission)(role) except AttributeError: pass return result
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier comparison_operator identifier subscript attribute identifier identifier identifier if_statement identifier block try_statement block return_statement call call identifier argument_list identifier identifier argument_list identifier except_clause identifier block pass_statement return_statement identifier
Check if role contains permission
def _fetch_partition_info(self, topic_id, partition_id): info_path = "/brokers/topics/{topic_id}/partitions/{p_id}" try: _, partition_info = self.get( info_path.format(topic_id=topic_id, p_id=partition_id), ) return partition_info except NoNodeError: return {}
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier string string_start string_content string_end try_statement block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier return_statement identifier except_clause identifier block return_statement dictionary
Fetch partition info for given topic-partition.
def update(self, dt): method = "update" A = None metadata = {method: dt} send_array(self.socket, A, metadata) A, metadata = recv_array( self.socket, poll=self.poll, poll_timeout=self.poll_timeout, flags=self.zmq_flags)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier none expression_statement assignment identifier dictionary pair identifier identifier expression_statement call identifier argument_list attribute identifier identifier identifier identifier expression_statement assignment pattern_list identifier identifier call identifier argument_list attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier
Advance the module with timestep dt
def gen_sentences(self, tokens, aliases=None): if aliases is None: aliases = {} for sentence in self._gen_sentences(tokens): try: alias = aliases[str(sentence[0])] except KeyError: pass except IndexError: pass else: sentence[0:1] = list(Program(alias).gen_tokens()) yield transform(Sentence(sentence), self.transforms)
module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier dictionary for_statement identifier call attribute identifier identifier argument_list identifier block try_statement block expression_statement assignment identifier subscript identifier call identifier argument_list subscript identifier integer except_clause identifier block pass_statement except_clause identifier block pass_statement else_clause block expression_statement assignment subscript identifier slice integer integer call identifier argument_list call attribute call identifier argument_list identifier identifier argument_list expression_statement yield call identifier argument_list call identifier argument_list identifier attribute identifier identifier
Generate a sequence of sentences from stream of tokens.
def cancel(self): self._cancelled.set() if not self._dead: self._ready_sem.acquire() self._ready_sem.release()
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list if_statement not_operator attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list
Stop the timer without executing the callback.
def getOffset(self, loc): return Location(loc.x - self.x, loc.y - self.y)
module function_definition identifier parameters identifier identifier block return_statement call identifier argument_list binary_operator attribute identifier identifier attribute identifier identifier binary_operator attribute identifier identifier attribute identifier identifier
Returns the offset between the given point and this point
def wait_for_running(self): self.server_attrs = self.consul.find_running( self.server_attrs, self.launch_timeout_s, )
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier attribute identifier identifier
Waits for found servers to be operational
def _is_sort_order_unique_together_with_something(self): unique_together = self._meta.unique_together for fields in unique_together: if 'sort_order' in fields and len(fields) > 1: return True return False
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier for_statement identifier identifier block if_statement boolean_operator comparison_operator string string_start string_content string_end identifier comparison_operator call identifier argument_list identifier integer block return_statement true return_statement false
Is the sort_order field unique_together with something
def count_delayed_jobs(cls, names): return sum([queue.delayed.zcard() for queue in cls.get_all(names)])
module function_definition identifier parameters identifier identifier block return_statement call identifier argument_list list_comprehension call attribute attribute identifier identifier identifier argument_list for_in_clause identifier call attribute identifier identifier argument_list identifier
Return the number of all delayed jobs in queues with the given names
def wasSolvedBy(self, user): thisExercise = _Solution.what == self byThisUser = _Solution.who == user condition = q.AND(thisExercise, byThisUser) return self.store.query(_Solution, condition, limit=1).count() == 1
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier comparison_operator attribute identifier identifier identifier expression_statement assignment identifier comparison_operator attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier return_statement comparison_operator call attribute call attribute attribute identifier identifier identifier argument_list identifier identifier keyword_argument identifier integer identifier argument_list integer
Checks if this exercise has previously been solved by the user.
def baremetal_models(call=None): if call == 'action': raise SaltCloudSystemExit( 'The baremetal_models function must be called with ' '-f or --function' ) conn = get_conn() bmodels = conn.list_baremetal_models() return bmodels
module function_definition identifier parameters default_parameter identifier none block if_statement comparison_operator identifier string string_start string_content string_end block raise_statement call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list return_statement identifier
Return a dict of all available baremetal models with relevant data.
def warn(self, msg, *args, **kwargs): self.log(self.WARN, msg, *args, **kwargs)
module function_definition identifier parameters identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier list_splat identifier dictionary_splat identifier
Log an warning message.
def download(input, filename, format='sdf', overwrite=False, resolvers=None, **kwargs): kwargs['format'] = format if resolvers: kwargs['resolver'] = ",".join(resolvers) url = API_BASE+'/%s/file?%s' % (urlquote(input), urlencode(kwargs)) try: servefile = urlopen(url) if not overwrite and os.path.isfile(filename): raise IOError("%s already exists. Use 'overwrite=True' to overwrite it." % filename) file = open(filename, "w") file.write(servefile.read()) file.close() except urllib.error.HTTPError: pass
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end default_parameter identifier false default_parameter identifier none dictionary_splat_pattern identifier block expression_statement assignment subscript identifier string string_start string_content string_end identifier if_statement identifier block expression_statement assignment subscript identifier string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier binary_operator identifier binary_operator string string_start string_content string_end tuple call identifier argument_list identifier call identifier argument_list identifier try_statement block expression_statement assignment identifier call identifier argument_list identifier if_statement boolean_operator not_operator identifier call attribute attribute identifier identifier identifier argument_list identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list except_clause attribute attribute identifier identifier identifier block pass_statement
Resolve and download structure as a file
def requires(self, extras=()): dm = self._dep_map deps = [] deps.extend(dm.get(None, ())) for ext in extras: try: deps.extend(dm[safe_extra(ext)]) except KeyError: raise UnknownExtra( "%s has no such extra feature %r" % (self, ext) ) return deps
module function_definition identifier parameters identifier default_parameter identifier tuple block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier list expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list none tuple for_statement identifier identifier block try_statement block expression_statement call attribute identifier identifier argument_list subscript identifier call identifier argument_list identifier except_clause identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier return_statement identifier
List of Requirements needed for this distro if `extras` are used
def ConvertSupportedOSToConditions(src_object): if src_object.supported_os: conditions = " OR ".join("os == '%s'" % o for o in src_object.supported_os) return conditions
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier generator_expression binary_operator string string_start string_content string_end identifier for_in_clause identifier attribute identifier identifier return_statement identifier
Turn supported_os into a condition.
def select (features, properties): assert is_iterable_typed(properties, basestring) result = [] features = add_grist (features) return [p for p in properties if get_grist(p) in features]
module function_definition identifier parameters identifier identifier block assert_statement call identifier argument_list identifier identifier expression_statement assignment identifier list expression_statement assignment identifier call identifier argument_list identifier return_statement list_comprehension identifier for_in_clause identifier identifier if_clause comparison_operator call identifier argument_list identifier identifier
Selects properties which correspond to any of the given features.
def with_descriptor(self, descriptor): res = {} desc = "%s_descriptor" % descriptor for eid, ent in self.items(): if desc in ent: res[eid] = ent return res
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary expression_statement assignment identifier binary_operator string string_start string_content string_end identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement comparison_operator identifier identifier block expression_statement assignment subscript identifier identifier identifier return_statement identifier
Returns any entities with the specified descriptor
def _get_s3_key(): key = __opts__['s3.key'] if 's3.key' in __opts__ else None keyid = __opts__['s3.keyid'] if 's3.keyid' in __opts__ else None service_url = __opts__['s3.service_url'] \ if 's3.service_url' in __opts__ \ else None verify_ssl = __opts__['s3.verify_ssl'] \ if 's3.verify_ssl' in __opts__ \ else None kms_keyid = __opts__['aws.kmw.keyid'] if 'aws.kms.keyid' in __opts__ else None location = __opts__['s3.location'] \ if 's3.location' in __opts__ \ else None path_style = __opts__['s3.path_style'] \ if 's3.path_style' in __opts__ \ else None https_enable = __opts__['s3.https_enable'] \ if 's3.https_enable' in __opts__ \ else None return key, keyid, service_url, verify_ssl, kms_keyid, location, path_style, https_enable
module function_definition identifier parameters block expression_statement assignment identifier conditional_expression subscript identifier string string_start string_content string_end comparison_operator string string_start string_content string_end identifier none expression_statement assignment identifier conditional_expression subscript identifier string string_start string_content string_end comparison_operator string string_start string_content string_end identifier none expression_statement assignment identifier conditional_expression subscript identifier string string_start string_content string_end line_continuation comparison_operator string string_start string_content string_end identifier line_continuation none expression_statement assignment identifier conditional_expression subscript identifier string string_start string_content string_end line_continuation comparison_operator string string_start string_content string_end identifier line_continuation none expression_statement assignment identifier conditional_expression subscript identifier string string_start string_content string_end comparison_operator string string_start string_content string_end identifier none expression_statement assignment identifier conditional_expression subscript identifier string string_start string_content string_end line_continuation comparison_operator string string_start string_content string_end identifier line_continuation none expression_statement assignment identifier conditional_expression subscript identifier string string_start string_content string_end line_continuation comparison_operator string string_start string_content string_end identifier line_continuation none expression_statement assignment identifier conditional_expression subscript identifier string string_start string_content string_end line_continuation comparison_operator string string_start string_content string_end identifier line_continuation none return_statement expression_list identifier identifier identifier identifier identifier identifier identifier identifier
Get AWS keys from pillar or config
def email(self, email): if email == self.email: return email = email.lower() if self._email is None: self._email = email self.require_email_confirmation() else: self.email_new = email self.require_email_confirmation()
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block return_statement expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list else_clause block expression_statement assignment attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list
Set email and generate confirmation
def max_insertion(seqs, gene, domain): seqs = [i[2] for i in list(seqs.values()) if i[2] != [] and i[0] == gene and i[1] == domain] lengths = [] for seq in seqs: for ins in seq: lengths.append(int(ins[2])) if lengths == []: return 100 return max(lengths)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier list_comprehension subscript identifier integer for_in_clause identifier call identifier argument_list call attribute identifier identifier argument_list if_clause boolean_operator boolean_operator comparison_operator subscript identifier integer list comparison_operator subscript identifier integer identifier comparison_operator subscript identifier integer identifier expression_statement assignment identifier list for_statement identifier identifier block for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list subscript identifier integer if_statement comparison_operator identifier list block return_statement integer return_statement call identifier argument_list identifier
length of largest insertion
def extract_function_metadata(wrapped, instance, args, kwargs, return_value): LOGGER.debug( 'Extracting function call metadata', args=args, kwargs=kwargs, ) return { 'metadata': { 'args': args, 'kwargs': kwargs, }, }
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier identifier return_statement dictionary pair string string_start string_content string_end dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier
Stash the `args` and `kwargs` into the metadata of the subsegment.
def string_to_config(s): from .machines import Configuration s = lexer(s) x = parse_multiple(s, parse_store) parse_end(s) return Configuration(x)
module function_definition identifier parameters identifier block import_from_statement relative_import import_prefix dotted_name identifier dotted_name identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement call identifier argument_list identifier return_statement call identifier argument_list identifier
s is a comma-separated list of stores.
def assert_valid_arguments(func, *args, **kwargs): argspec = getargspec(func) func_defaults = argspec.defaults or tuple() defaults = (Required,) * (len(argspec.args) - len(func_defaults)) + func_defaults for index, arg_name in enumerate(argspec.args): arg_value = args[index] if index < len(args) else kwargs.get(arg_name) if arg_value is not None: continue if defaults[index] is not Required: continue abort("Missing required argument: {}".format(arg_name))
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier boolean_operator attribute identifier identifier call identifier argument_list expression_statement assignment identifier binary_operator binary_operator tuple identifier parenthesized_expression binary_operator call identifier argument_list attribute identifier identifier call identifier argument_list identifier identifier for_statement pattern_list identifier identifier call identifier argument_list attribute identifier identifier block expression_statement assignment identifier conditional_expression subscript identifier identifier comparison_operator identifier call identifier argument_list identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block continue_statement if_statement comparison_operator subscript identifier identifier identifier block continue_statement expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier
Validate provided arguments against a function's argspec.
def check_value(self, value): if value and self.size: if not is_string(value): raise ValueError("Value supplied has to be a string") if len(value) > self.size: raise ValueError( "Lenght of the '{0}' is limited to {1}".format( self.name, self.size)) if not value and self.required: raise ValueError("'{0}' field is required".format(self.name)) return value
module function_definition identifier parameters identifier identifier block if_statement boolean_operator identifier attribute identifier identifier block if_statement not_operator call identifier argument_list identifier block raise_statement call identifier argument_list string string_start string_content string_end if_statement comparison_operator call identifier argument_list identifier attribute identifier identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier attribute identifier identifier if_statement boolean_operator not_operator identifier attribute identifier identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier return_statement identifier
Check the validity of a value for the field.
def stem_word(self, word): if self.is_plural(word): return self.stem_plural_word(word) else: return self.stem_singular_word(word)
module function_definition identifier parameters identifier identifier block if_statement call attribute identifier identifier argument_list identifier block return_statement call attribute identifier identifier argument_list identifier else_clause block return_statement call attribute identifier identifier argument_list identifier
Stem a word to its common stem form.
def flatten_dict_vals(dict_): if isinstance(dict_, dict): return dict([ ((key, augkey), augval) for key, val in dict_.items() for augkey, augval in flatten_dict_vals(val).items() ]) else: return {None: dict_}
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier identifier block return_statement call identifier argument_list list_comprehension tuple tuple identifier identifier identifier for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list for_in_clause pattern_list identifier identifier call attribute call identifier argument_list identifier identifier argument_list else_clause block return_statement dictionary pair none identifier
Flattens only values in a heirarchical dictionary, keys are nested.
def to_snake_case(camel_case): if not re.match(r"^[A-Za-z_]\w*$", camel_case): raise ValueError( "Input string %s is not a valid Python identifier." % camel_case) underscored = re.sub(r"([A-Z][a-z])", r"_\1", camel_case) underscored = re.sub(r"([a-z])([A-Z])", r"\1_\2", underscored) underscored = re.sub(r"([a-z])([0-9][^_]*)", r"\1_\2", underscored) return underscored.strip("_").lower()
module function_definition identifier parameters identifier block if_statement not_operator call attribute identifier identifier argument_list string string_start string_content string_end identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier return_statement call attribute call attribute identifier identifier argument_list string string_start string_content string_end identifier argument_list
Returns a CamelCase string as a snake_case string.
def save_translations(self, instance, translated_data): for meta in self.Meta.model._parler_meta: translations = translated_data.get(meta.rel_name, {}) for lang_code, model_fields in translations.items(): translation = instance._get_translated_model(lang_code, auto_create=True, meta=meta) for field, value in model_fields.items(): setattr(translation, field, value) instance.save_translations()
module function_definition identifier parameters identifier identifier identifier block for_statement identifier attribute attribute attribute identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier dictionary for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier true keyword_argument identifier identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement call identifier argument_list identifier identifier identifier expression_statement call attribute identifier identifier argument_list
Save translation data into translation objects.
def release_scheme(self, value): if value not in KNOWN_RELEASE_SCHEMES: msg = "Release scheme %r is not supported! (valid options are %s)" raise ValueError(msg % (value, concatenate(map(repr, KNOWN_RELEASE_SCHEMES)))) set_property(self, 'release_scheme', value)
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier identifier block expression_statement assignment identifier string string_start string_content string_end raise_statement call identifier argument_list binary_operator identifier tuple identifier call identifier argument_list call identifier argument_list identifier identifier expression_statement call identifier argument_list identifier string string_start string_content string_end identifier
Validate the release scheme.
def _get_mean(self, vs30, mag, rrup, imt, scale_fac): C_HR, C_BC, C_SR, SC = self._extract_coeffs(imt) rrup = self._clip_distances(rrup) f0 = self._compute_f0_factor(rrup) f1 = self._compute_f1_factor(rrup) f2 = self._compute_f2_factor(rrup) pga_bc = self._get_pga_bc( f0, f1, f2, SC, mag, rrup, vs30, scale_fac ) mean = np.zeros_like(vs30) self._compute_mean(C_HR, f0, f1, f2, SC, mag, rrup, vs30 >= 2000.0, mean, scale_fac) self._compute_mean(C_BC, f0, f1, f2, SC, mag, rrup, vs30 < 2000.0, mean, scale_fac) self._compute_soil_amplification(C_SR, vs30, pga_bc, mean) if imt == PGV(): mean = np.log(10 ** mean) else: mean = np.log((10 ** mean) * 1e-2 / g) return mean
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block expression_statement assignment pattern_list identifier identifier identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier identifier identifier identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier identifier identifier identifier identifier identifier identifier comparison_operator identifier float identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier identifier identifier identifier identifier identifier comparison_operator identifier float identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier identifier identifier if_statement comparison_operator identifier call identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator integer identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator binary_operator parenthesized_expression binary_operator integer identifier float identifier return_statement identifier
Compute and return mean
def create_basic_app(cls, bundles=None, _config_overrides=None): bundles = bundles or [] name = bundles[-1].module_name if bundles else 'basic_app' app = FlaskUnchained(name, template_folder=os.path.join( os.path.dirname(__file__), 'templates')) for bundle in bundles: bundle.before_init_app(app) unchained.init_app(app, DEV, bundles, _config_overrides=_config_overrides) for bundle in bundles: bundle.after_init_app(app) return app
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier boolean_operator identifier list expression_statement assignment identifier conditional_expression attribute subscript identifier unary_operator integer identifier identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier identifier identifier keyword_argument identifier identifier for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Creates a "fake" app for use while developing
def build_eir(self): return LowEnergyBeaconHelper.base_eir + [ EIR_Hdr() / EIR_CompleteList16BitServiceUUIDs(svc_uuids=[ EDDYSTONE_UUID]), EIR_Hdr() / EIR_ServiceData16BitUUID() / self ]
module function_definition identifier parameters identifier block return_statement binary_operator attribute identifier identifier list binary_operator call identifier argument_list call identifier argument_list keyword_argument identifier list identifier binary_operator binary_operator call identifier argument_list call identifier argument_list identifier
Builds a list of EIR messages to wrap this frame.
def GenomicRangeFromString(range_string,payload=None,dir=None): m = re.match('^(.+):(\d+)-(\d+)$',range_string) if not m: sys.stderr.write("ERROR bad genomic range string\n"+range_string+"\n") sys.exit() chr = m.group(1) start = int(m.group(2)) end = int(m.group(3)) return GenomicRange(chr,start,end,payload,dir)
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement not_operator identifier block expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator binary_operator string string_start string_content escape_sequence string_end identifier string string_start string_content escape_sequence string_end expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list integer expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list integer expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list integer return_statement call identifier argument_list identifier identifier identifier identifier identifier
Constructor for a GenomicRange object that takes a string
def _clear_cache_synthesizer(self): self.log(u"Clearing synthesizer...") self.synthesizer.clear_cache() self.log(u"Clearing synthesizer... done")
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end
Clear the cache of the synthesizer
def populate_token_attributes(self, response): if 'access_token' in response: self.access_token = response.get('access_token') if 'refresh_token' in response: self.refresh_token = response.get('refresh_token') if 'token_type' in response: self.token_type = response.get('token_type') if 'expires_in' in response: self.expires_in = response.get('expires_in') self._expires_at = time.time() + int(self.expires_in) if 'expires_at' in response: self._expires_at = int(response.get('expires_at')) if 'mac_key' in response: self.mac_key = response.get('mac_key') if 'mac_algorithm' in response: self.mac_algorithm = response.get('mac_algorithm')
module function_definition identifier parameters identifier identifier block if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier binary_operator call attribute identifier identifier argument_list call identifier argument_list attribute identifier identifier if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment attribute identifier identifier call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end
Add attributes from a token exchange response to self.
def _get_first_last(details): if "first_name" in details and "last_name" in details: return details["first_name"], details["last_name"] elif "first_name" in details: lst = details["first_name"].rsplit(" ", 1) if len(lst) == 2: return lst else: return lst[0], "" elif "last_name" in details: return "", details["last_name"] return "", ""
module function_definition identifier parameters identifier block if_statement boolean_operator comparison_operator string string_start string_content string_end identifier comparison_operator string string_start string_content string_end identifier block return_statement expression_list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end elif_clause comparison_operator string string_start string_content string_end identifier block expression_statement assignment identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end integer if_statement comparison_operator call identifier argument_list identifier integer block return_statement identifier else_clause block return_statement expression_list subscript identifier integer string string_start string_end elif_clause comparison_operator string string_start string_content string_end identifier block return_statement expression_list string string_start string_end subscript identifier string string_start string_content string_end return_statement expression_list string string_start string_end string string_start string_end
Gets a user's first and last name from details.
def run_loop(self): self.root_command.prog = '' history_file = self.load_history() rendering.vtmlprint(self.intro) try: self.loop() finally: readline.write_history_file(history_file)
module function_definition identifier parameters identifier block expression_statement assignment attribute attribute identifier identifier identifier string string_start string_end expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list attribute identifier identifier try_statement block expression_statement call attribute identifier identifier argument_list finally_clause block expression_statement call attribute identifier identifier argument_list identifier
Main entry point for running in interactive mode.
def _get_template(settings): puts("\nPick a template\n") template = None while not template: _list_templates(settings) index = raw_input("\nWhich template would you like to use? [1] ") if not index: index = "1" try: index = int(index) - 1 return settings.config["project_templates"][index] except: puts("\"{0}\" isn't a valid option!".format(colored.red("{0}".format(index)))) pass
module function_definition identifier parameters identifier block expression_statement call identifier argument_list string string_start string_content escape_sequence escape_sequence string_end expression_statement assignment identifier none while_statement not_operator identifier block expression_statement call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list string string_start string_content escape_sequence string_end if_statement not_operator identifier block expression_statement assignment identifier string string_start string_content string_end try_statement block expression_statement assignment identifier binary_operator call identifier argument_list identifier integer return_statement subscript subscript attribute identifier identifier string string_start string_content string_end identifier except_clause block expression_statement call identifier argument_list call attribute string string_start string_content escape_sequence escape_sequence string_end identifier argument_list call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier pass_statement
Prompt user to pick template from a list.
def isMasterDegraded(self): if self.acc_monitor: self.acc_monitor.update_time(time.perf_counter()) return self.acc_monitor.is_master_degraded() else: return (self.instances.masterId is not None and (self.isMasterThroughputTooLow() or self.isMasterAvgReqLatencyTooHigh()))
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list return_statement call attribute attribute identifier identifier identifier argument_list else_clause block return_statement parenthesized_expression boolean_operator comparison_operator attribute attribute identifier identifier identifier none parenthesized_expression boolean_operator call attribute identifier identifier argument_list call attribute identifier identifier argument_list
Return whether the master instance is slow.
def _locked(func): def _locking(self, *args, **kwargs): try: self.lock() return func(self, *args, **kwargs) finally: self.unlock() return _locking
module function_definition identifier parameters identifier block function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block try_statement block expression_statement call attribute identifier identifier argument_list return_statement call identifier argument_list identifier list_splat identifier dictionary_splat identifier finally_clause block expression_statement call attribute identifier identifier argument_list return_statement identifier
! Decorator to automatically lock an AccessPort method.
def _target_load(self, load): mp_call = _metaproxy_call(self.opts, 'target_load') return mp_call(self, load)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier string string_start string_content string_end return_statement call identifier argument_list identifier identifier
Verify that the publication is valid and applies to this minion
def queue_call(self, delay, callback, *args, **kwds): if delay is None: self.current.append((callback, args, kwds)) return if delay < 1e9: when = delay + self.clock.now() else: when = delay self.insort_event_right((when, callback, args, kwds))
module function_definition identifier parameters identifier identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block if_statement comparison_operator identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list tuple identifier identifier identifier return_statement if_statement comparison_operator identifier float block expression_statement assignment identifier binary_operator identifier call attribute attribute identifier identifier identifier argument_list else_clause block expression_statement assignment identifier identifier expression_statement call attribute identifier identifier argument_list tuple identifier identifier identifier identifier
Schedule a function call at a specific time in the future.
def run(self): try: transcript = self.fn(*self.args, **self.kwargs) except: traceback.print_exc() exctype, value = sys.exc_info()[:2] self.signals.error.emit((exctype, value, traceback.format_exc())) else: self.signals.result.emit(transcript) finally: self.signals.finished.emit()
module function_definition identifier parameters identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list list_splat attribute identifier identifier dictionary_splat attribute identifier identifier except_clause block expression_statement call attribute identifier identifier argument_list expression_statement assignment pattern_list identifier identifier subscript call attribute identifier identifier argument_list slice integer expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list tuple identifier identifier call attribute identifier identifier argument_list else_clause block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier finally_clause block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list
Initialise the runner function with the passed args, kwargs
def np_counts(self): counts = defaultdict(int) for phrase in self.noun_phrases: counts[phrase] += 1 return counts
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier for_statement identifier attribute identifier identifier block expression_statement augmented_assignment subscript identifier identifier integer return_statement identifier
Dictionary of noun phrase frequencies in this text.
def acquire_auth_token_ticket(self, headers=None): logging.debug('[CAS] Acquiring Auth token ticket') url = self._get_auth_token_tickets_url() text = self._perform_post(url, headers=headers) auth_token_ticket = json.loads(text)['ticket'] logging.debug('[CAS] Acquire Auth token ticket: {}'.format( auth_token_ticket)) return auth_token_ticket
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier expression_statement assignment identifier subscript call attribute identifier identifier argument_list identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier return_statement identifier
Acquire an auth token from the CAS server.
def unit_tangent(self, t=None): assert self.end != self.start dseg = self.end - self.start return dseg/abs(dseg)
module function_definition identifier parameters identifier default_parameter identifier none block assert_statement comparison_operator attribute identifier identifier attribute identifier identifier expression_statement assignment identifier binary_operator attribute identifier identifier attribute identifier identifier return_statement binary_operator identifier call identifier argument_list identifier
returns the unit tangent of the segment at t.
def unzip_file(zip_fname): print("Unzipping {}".format(zip_fname)) with zipfile.ZipFile(zip_fname) as zf: zf.extractall()
module function_definition identifier parameters identifier block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list
Unzip the zip_fname in the current directory.
def digit_to_query_time(digit: str) -> List[int]: if len(digit) > 2: return [int(digit), int(digit) + TWELVE_TO_TWENTY_FOUR] elif int(digit) % 12 == 0: return [0, 1200, 2400] return [int(digit) * HOUR_TO_TWENTY_FOUR, (int(digit) * HOUR_TO_TWENTY_FOUR + TWELVE_TO_TWENTY_FOUR) % HOURS_IN_DAY]
module function_definition identifier parameters typed_parameter identifier type identifier type generic_type identifier type_parameter type identifier block if_statement comparison_operator call identifier argument_list identifier integer block return_statement list call identifier argument_list identifier binary_operator call identifier argument_list identifier identifier elif_clause comparison_operator binary_operator call identifier argument_list identifier integer integer block return_statement list integer integer integer return_statement list binary_operator call identifier argument_list identifier identifier binary_operator parenthesized_expression binary_operator binary_operator call identifier argument_list identifier identifier identifier identifier
Given a digit in the utterance, return a list of the times that it corresponds to.
def as_dict(self): d = MSONable.as_dict(self) d["data"] = self.data.tolist() return d
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment subscript identifier string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list return_statement identifier
Returns dict representations of Xmu object
def truncate(self, path, length, fh=None): "Download existing path, truncate and reupload" try: f = self._getpath(path) except JFS.JFSError: raise OSError(errno.ENOENT, '') if isinstance(f, (JFS.JFSFile, JFS.JFSFolder)) and f.is_deleted(): raise OSError(errno.ENOENT) data = StringIO(f.read()) data.truncate(length) try: self.client.up(path, data) self._dirty(path) return ESUCCESS except: raise OSError(errno.ENOENT, '')
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none block expression_statement string string_start string_content string_end try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier except_clause attribute identifier identifier block raise_statement call identifier argument_list attribute identifier identifier string string_start string_end if_statement boolean_operator call identifier argument_list identifier tuple attribute identifier identifier attribute identifier identifier call attribute identifier identifier argument_list block raise_statement call identifier argument_list attribute identifier identifier expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier except_clause block raise_statement call identifier argument_list attribute identifier identifier string string_start string_end
Download existing path, truncate and reupload
def create_zip(archive, compression, cmd, verbosity, interactive, filenames): try: with zipfile.ZipFile(archive, 'w') as zfile: for filename in filenames: if os.path.isdir(filename): write_directory(zfile, filename) else: zfile.write(filename) except Exception as err: msg = "error creating %s: %s" % (archive, err) raise util.PatoolError(msg) return None
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block try_statement block with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block for_statement identifier identifier block if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call identifier argument_list identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple identifier identifier raise_statement call attribute identifier identifier argument_list identifier return_statement none
Create a ZIP archive with the zipfile Python module.
def crypto_key_path_path(cls, project, location, key_ring, crypto_key_path): return google.api_core.path_template.expand( "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key_path=**}", project=project, location=location, key_ring=key_ring, crypto_key_path=crypto_key_path, )
module function_definition identifier parameters identifier identifier identifier identifier identifier block return_statement call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
Return a fully-qualified crypto_key_path string.