code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def ReadUntil(self, expected_ids, *finish_ids): while True: cmd_id, header, data = self.Read(expected_ids + finish_ids) yield cmd_id, header, data if cmd_id in finish_ids: break
module function_definition identifier parameters identifier identifier list_splat_pattern identifier block while_statement true block expression_statement assignment pattern_list identifier identifier identifier call attribute identifier identifier argument_list binary_operator identifier identifier expression_statement yield expression_list identifier identifier identifier if_statement comparison_operator identifier identifier block break_statement
Useful wrapper around Read.
def _removeReceiver(receiver): if not sendersBack: return False backKey = id(receiver) try: backSet = sendersBack.pop(backKey) except KeyError: return False else: for senderkey in backSet: try: signals = list(connections[senderkey].keys()) except KeyError: pass else: for signal in signals: try: receivers = connections[senderkey][signal] except KeyError: pass else: try: receivers.remove( receiver ) except Exception: pass _cleanupConnections(senderkey, signal)
module function_definition identifier parameters identifier block if_statement not_operator identifier block return_statement false expression_statement assignment identifier call identifier argument_list identifier try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier except_clause identifier block return_statement false else_clause block for_statement identifier identifier block try_statement block expression_statement assignment identifier call identifier argument_list call attribute subscript identifier identifier identifier argument_list except_clause identifier block pass_statement else_clause block for_statement identifier identifier block try_statement block expression_statement assignment identifier subscript subscript identifier identifier identifier except_clause identifier block pass_statement else_clause block try_statement block expression_statement call attribute identifier identifier argument_list identifier except_clause identifier block pass_statement expression_statement call identifier argument_list identifier identifier
Remove receiver from connections.
def format_path(p, quote_spaces=False): if b'\n' in p: p = re.sub(b'\n', b'\\n', p) quote = True else: quote = p[0] == b'"' or (quote_spaces and b' ' in p) if quote: extra = GIT_FAST_IMPORT_NEEDS_EXTRA_SPACE_AFTER_QUOTE and b' ' or b'' p = b'"' + p + b'"' + extra return p
module function_definition identifier parameters identifier default_parameter identifier false block if_statement comparison_operator string string_start string_content escape_sequence string_end identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end string string_start string_content escape_sequence string_end identifier expression_statement assignment identifier true else_clause block expression_statement assignment identifier boolean_operator comparison_operator subscript identifier integer string string_start string_content string_end parenthesized_expression boolean_operator identifier comparison_operator string string_start string_content string_end identifier if_statement identifier block expression_statement assignment identifier boolean_operator boolean_operator identifier string string_start string_content string_end string string_start string_end expression_statement assignment identifier binary_operator binary_operator binary_operator string string_start string_content string_end identifier string string_start string_content string_end identifier return_statement identifier
Format a path in utf8, quoting it if necessary.
def mutate(self,p_i,func_set,term_set): self.point_mutate(p_i,func_set,term_set)
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier identifier
point mutation, addition, removal
def apply(self, styler): return styler.format(self.formatter, *self.args, **self.kwargs)
module function_definition identifier parameters identifier identifier block return_statement call attribute identifier identifier argument_list attribute identifier identifier list_splat attribute identifier identifier dictionary_splat attribute identifier identifier
Apply Summary over Pandas Styler
def parse_def(self, text): self.__init__() if not is_start_of_function(text): return self.func_indent = get_indent(text) text = text.strip() text = text.replace('\r\n', '') text = text.replace('\n', '') return_type_re = re.search(r'->[ ]*([a-zA-Z0-9_,()\[\] ]*):$', text) if return_type_re: self.return_type_annotated = return_type_re.group(1) text_end = text.rfind(return_type_re.group(0)) else: self.return_type_annotated = None text_end = len(text) pos_args_start = text.find('(') + 1 pos_args_end = text.rfind(')', pos_args_start, text_end) self.args_text = text[pos_args_start:pos_args_end] args_list = self.split_args_text_to_list(self.args_text) if args_list is not None: self.has_info = True self.split_arg_to_name_type_value(args_list)
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list if_statement not_operator call identifier argument_list identifier block return_statement expression_statement assignment attribute identifier identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content escape_sequence escape_sequence string_end string string_start string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end string string_start string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list integer expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list integer else_clause block expression_statement assignment attribute identifier identifier none expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list string string_start string_content string_end integer expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier expression_statement assignment attribute identifier identifier subscript identifier slice identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier if_statement comparison_operator identifier none block expression_statement assignment attribute identifier identifier true expression_statement call attribute identifier identifier argument_list identifier
Parse the function definition text.
def list_releases(): response = requests.get(PYPI_URL.format(package=PYPI_PACKAGE_NAME)) if response: data = response.json() releases_dict = data.get('releases', {}) if releases_dict: for version, release in releases_dict.items(): release_formats = [] published_on_date = None for fmt in release: release_formats.append(fmt.get('packagetype')) published_on_date = fmt.get('upload_time') release_formats = ' | '.join(release_formats) print('{:<10}{:>15}{:>25}'.format(version, published_on_date, release_formats)) else: print('No releases found for {}'.format(PYPI_PACKAGE_NAME)) else: print('Package "{}" not found on Pypi.org'.format(PYPI_PACKAGE_NAME))
module function_definition identifier parameters block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier identifier if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end dictionary if_statement identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement assignment identifier list expression_statement assignment identifier none for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier 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 identifier identifier identifier else_clause block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier else_clause block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier
Lists all releases published on pypi.
def compile_protos(): if not os.path.exists(os.path.join(THIS_DIRECTORY, "makefile.py")): return subprocess.check_call( ["python", "makefile.py", "--clean"], cwd=THIS_DIRECTORY)
module function_definition identifier parameters block if_statement not_operator call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end block return_statement expression_statement 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 keyword_argument identifier identifier
Builds necessary assets from sources.
async def exist(self, key, param=None): identity = self._gen_identity(key, param) return await self.client.exists(identity)
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier return_statement await call attribute attribute identifier identifier identifier argument_list identifier
see if specific identity exists
def csp_header(csp={}): _csp = csp_default().read() _csp.update(csp) _header = '' if 'report-only' in _csp and _csp['report-only'] is True: _header = 'Content-Security-Policy-Report-Only' else: _header = 'Content-Security-Policy' if 'report-only' in _csp: del _csp['report-only'] _headers = {_header: create_csp_header(_csp)} def decorator(f): @wraps(f) def decorated_function(*args, **kwargs): resp = make_response(f(*args, **kwargs)) h = resp.headers for header, value in _headers.items(): h[header] = value return resp return decorated_function return decorator
module function_definition identifier parameters default_parameter identifier dictionary block expression_statement assignment identifier call attribute call identifier argument_list identifier argument_list expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier string string_start string_end if_statement boolean_operator comparison_operator string string_start string_content string_end identifier comparison_operator subscript identifier string string_start string_content string_end true block expression_statement assignment identifier string string_start string_content string_end else_clause block expression_statement assignment identifier string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end identifier block delete_statement subscript identifier string string_start string_content string_end expression_statement assignment identifier dictionary pair identifier call identifier argument_list identifier function_definition identifier parameters identifier block decorated_definition decorator call identifier argument_list identifier function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list call identifier argument_list list_splat identifier dictionary_splat identifier expression_statement assignment identifier attribute identifier identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement assignment subscript identifier identifier identifier return_statement identifier return_statement identifier return_statement identifier
Decorator to include csp header on app.route wrapper
def switch_schema(task, kwargs, **kw): from .compat import get_public_schema_name, get_tenant_model old_schema = (connection.schema_name, connection.include_public_schema) setattr(task, '_old_schema', old_schema) schema = ( get_schema_name_from_task(task, kwargs) or get_public_schema_name() ) if connection.schema_name == schema: return if connection.schema_name != get_public_schema_name(): connection.set_schema_to_public() if schema == get_public_schema_name(): return tenant = get_tenant_model().objects.get(schema_name=schema) connection.set_tenant(tenant, include_public=True)
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block import_from_statement relative_import import_prefix dotted_name identifier dotted_name identifier dotted_name identifier expression_statement assignment identifier tuple attribute identifier identifier attribute identifier identifier expression_statement call identifier argument_list identifier string string_start string_content string_end identifier expression_statement assignment identifier parenthesized_expression boolean_operator call identifier argument_list identifier identifier call identifier argument_list if_statement comparison_operator attribute identifier identifier identifier block return_statement if_statement comparison_operator attribute identifier identifier call identifier argument_list block expression_statement call attribute identifier identifier argument_list if_statement comparison_operator identifier call identifier argument_list block return_statement expression_statement assignment identifier call attribute attribute call identifier argument_list identifier identifier argument_list keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier true
Switches schema of the task, before it has been run.
def sliding_window(seq, lookahead): it = itertools.chain(iter(seq), ' ' * lookahead) window_size = lookahead + 1 result = tuple(itertools.islice(it, window_size)) if len(result) == window_size: yield result for elem in it: result = result[1:] + (elem,) yield result
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list identifier binary_operator string string_start string_content string_end identifier expression_statement assignment identifier binary_operator identifier integer expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list identifier identifier if_statement comparison_operator call identifier argument_list identifier identifier block expression_statement yield identifier for_statement identifier identifier block expression_statement assignment identifier binary_operator subscript identifier slice integer tuple identifier expression_statement yield identifier
Create a sliding window with the specified number of lookahead characters.
def parse_datetime(record: str) -> Optional[datetime]: format_strings = {8: '%Y%m%d', 12: '%Y%m%d%H%M', 14: '%Y%m%d%H%M%S'} if record == '': return None return datetime.strptime(record.strip(), format_strings[len(record.strip())])
module function_definition identifier parameters typed_parameter identifier type identifier type generic_type identifier type_parameter type identifier block expression_statement assignment identifier dictionary pair integer string string_start string_content string_end pair integer string string_start string_content string_end pair integer string string_start string_content string_end if_statement comparison_operator identifier string string_start string_end block return_statement none return_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list subscript identifier call identifier argument_list call attribute identifier identifier argument_list
Parse a datetime string into a python datetime object
def combineColumns(cols): 'Return Column object formed by joining fields in given columns.' return Column("+".join(c.name for c in cols), getter=lambda col,row,cols=cols,ch=' ': ch.join(c.getDisplayValue(row) for c in cols))
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end return_statement call identifier argument_list call attribute string string_start string_content string_end identifier generator_expression attribute identifier identifier for_in_clause identifier identifier keyword_argument identifier lambda lambda_parameters identifier identifier default_parameter identifier identifier default_parameter identifier string string_start string_content string_end call attribute identifier identifier generator_expression call attribute identifier identifier argument_list identifier for_in_clause identifier identifier
Return Column object formed by joining fields in given columns.
def execute(self): cluster_name = self.params.cluster creator = make_creator(self.params.config, storage_path=self.params.storage) try: cluster = creator.load_cluster(cluster_name) except (ClusterNotFound, ConfigurationError) as err: log.error("Cannot stop cluster `%s`: %s", cluster_name, err) return os.EX_NOINPUT if not self.params.yes: confirm_or_abort( "Do you want really want to stop cluster `{cluster_name}`?" .format(cluster_name=cluster_name), msg="Aborting upon user request.") print("Destroying cluster `%s` ..." % cluster_name) cluster.stop(force=self.params.force, wait=self.params.wait)
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list attribute attribute identifier identifier identifier keyword_argument identifier attribute attribute identifier identifier identifier try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier except_clause as_pattern tuple identifier identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier return_statement attribute identifier identifier if_statement not_operator attribute attribute identifier identifier identifier block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end expression_statement call identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier attribute attribute identifier identifier identifier
Stops the cluster if it's running.
def _checkpath(self, path): if path.startswith("/") or ".." in path or path.strip() != path: raise NotFoundException()
module function_definition identifier parameters identifier identifier block if_statement boolean_operator boolean_operator call attribute identifier identifier argument_list string string_start string_content string_end comparison_operator string string_start string_content string_end identifier comparison_operator call attribute identifier identifier argument_list identifier block raise_statement call identifier argument_list
Checks that a given path is valid. If it's not, raises NotFoundException
def overlap(r1: 'Rectangle', r2: 'Rectangle'): h_overlaps = (r1.left <= r2.right) and (r1.right >= r2.left) v_overlaps = (r1.bottom >= r2.top) and (r1.top <= r2.bottom) return h_overlaps and v_overlaps
module function_definition identifier parameters typed_parameter identifier type string string_start string_content string_end typed_parameter identifier type string string_start string_content string_end block expression_statement assignment identifier boolean_operator parenthesized_expression comparison_operator attribute identifier identifier attribute identifier identifier parenthesized_expression comparison_operator attribute identifier identifier attribute identifier identifier expression_statement assignment identifier boolean_operator parenthesized_expression comparison_operator attribute identifier identifier attribute identifier identifier parenthesized_expression comparison_operator attribute identifier identifier attribute identifier identifier return_statement boolean_operator identifier identifier
Overlapping rectangles overlap both horizontally & vertically
def remove_experiment(self, id): if id in self.experiments: self.experiments.pop(id) self.write_file()
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list
remove an experiment by id
def human_uuid(): return base64.b32encode( hashlib.sha1(uuid.uuid4().bytes).digest()).lower().strip('=')
module function_definition identifier parameters block return_statement call attribute call attribute call attribute identifier identifier argument_list call attribute call attribute identifier identifier argument_list attribute call attribute identifier identifier argument_list identifier identifier argument_list identifier argument_list identifier argument_list string string_start string_content string_end
Returns a good UUID for using as a human readable string.
def pt2leaf(self, x): if self.leafnode: return self else: if x[self.split_dim] < self.split_value: return self.lower.pt2leaf(x) else: return self.greater.pt2leaf(x)
module function_definition identifier parameters identifier identifier block if_statement attribute identifier identifier block return_statement identifier else_clause block if_statement comparison_operator subscript identifier attribute identifier identifier attribute identifier identifier block return_statement call attribute attribute identifier identifier identifier argument_list identifier else_clause block return_statement call attribute attribute identifier identifier identifier argument_list identifier
Get the leaf which domain contains x.
def save(self, *args, **kwargs): letter = getattr(self, "block_letter", None) if letter and len(letter) >= 1: self.block_letter = letter[:1].upper() + letter[1:] super(EighthBlock, self).save(*args, **kwargs)
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end none if_statement boolean_operator identifier comparison_operator call identifier argument_list identifier integer block expression_statement assignment attribute identifier identifier binary_operator call attribute subscript identifier slice integer identifier argument_list subscript identifier slice integer expression_statement call attribute call identifier argument_list identifier identifier identifier argument_list list_splat identifier dictionary_splat identifier
Capitalize the first letter of the block name.
def sequence_length(fasta): sequences = SeqIO.parse(fasta, "fasta") records = {record.id: len(record) for record in sequences} return records
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier dictionary_comprehension pair attribute identifier identifier call identifier argument_list identifier for_in_clause identifier identifier return_statement identifier
return a dict of the lengths of sequences in a fasta file
def _escape_jid(jid): jid = six.text_type(jid) jid = re.sub(r"'*", "", jid) return jid
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end identifier return_statement identifier
Do proper formatting of the jid
def _populate_permissions(resources, content_type_id): from django.contrib.auth.models import Permission db_perms = [perm.codename for perm in Permission.objects.all()] for resource in resources: perms = [perm for perm in resource.access_controller.get_perm_names(resource) if perm not in db_perms] for perm in perms: _save_new_permission(perm, content_type_id)
module function_definition identifier parameters identifier identifier block import_from_statement dotted_name identifier identifier identifier identifier dotted_name identifier expression_statement assignment identifier list_comprehension attribute identifier identifier for_in_clause identifier call attribute attribute identifier identifier identifier argument_list for_statement identifier identifier block expression_statement assignment identifier list_comprehension identifier for_in_clause identifier call attribute attribute identifier identifier identifier argument_list identifier if_clause comparison_operator identifier identifier for_statement identifier identifier block expression_statement call identifier argument_list identifier identifier
Add all missing permissions to the database.
def timeit(func): @wraps(func) def wrapped_func(*args, **kwargs): start = timer() result = func(*args, **kwargs) cost = timer() - start logger.debug('<method: %s> finished in %2.2f sec' % (func.__name__, cost)) return result return wrapped_func
module function_definition identifier parameters identifier block decorated_definition decorator call identifier argument_list identifier function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call identifier argument_list list_splat identifier dictionary_splat identifier expression_statement assignment identifier binary_operator call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple attribute identifier identifier identifier return_statement identifier return_statement identifier
Decorator that logs the cost time of a function.
def type_converter(text): if text.isdigit(): return int(text), int try: return float(text), float except ValueError: return text, STRING_TYPE
module function_definition identifier parameters identifier block if_statement call attribute identifier identifier argument_list block return_statement expression_list call identifier argument_list identifier identifier try_statement block return_statement expression_list call identifier argument_list identifier identifier except_clause identifier block return_statement expression_list identifier identifier
I convert strings into integers, floats, and strings!
def call(self, command, *args): if not command: return try: res = self.registered[command]['function'](self, *args) return Response('local', res, None) except KeyError: res, err = self.client.call(command, *args) return Response('remote', res, err, self.client.is_multi()) except Exception as e: return Response('local', res, str(e))
module function_definition identifier parameters identifier identifier list_splat_pattern identifier block if_statement not_operator identifier block return_statement try_statement block expression_statement assignment identifier call subscript subscript attribute identifier identifier identifier string string_start string_content string_end argument_list identifier list_splat identifier return_statement call identifier argument_list string string_start string_content string_end identifier none except_clause identifier block expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list identifier list_splat identifier return_statement call identifier argument_list string string_start string_content string_end identifier identifier call attribute attribute identifier identifier identifier argument_list except_clause as_pattern identifier as_pattern_target identifier block return_statement call identifier argument_list string string_start string_content string_end identifier call identifier argument_list identifier
Execute local OR remote command and show response
def on_disconnect(self, code, stream_name, reason): logger.error('Disconnect message: %s %s %s', code, stream_name, reason) return True
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier identifier return_statement true
Called when a disconnect is received
def visit_importfrom(self, node, parent): names = [(alias.name, alias.asname) for alias in node.names] newnode = nodes.ImportFrom( node.module or "", names, node.level or None, getattr(node, "lineno", None), getattr(node, "col_offset", None), parent, ) self._import_from_nodes.append(newnode) return newnode
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier list_comprehension tuple attribute identifier identifier attribute identifier identifier for_in_clause identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list boolean_operator attribute identifier identifier string string_start string_end identifier boolean_operator attribute identifier identifier none call identifier argument_list identifier string string_start string_content string_end none call identifier argument_list identifier string string_start string_content string_end none identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement identifier
visit an ImportFrom node by returning a fresh instance of it
def append(self, request, response): request = self._before_record_request(request) if not request: return response = copy.deepcopy(response) response = self._before_record_response(response) if response is None: return self.data.append((request, response)) self.dirty = True
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement not_operator identifier block return_statement expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block return_statement expression_statement call attribute attribute identifier identifier identifier argument_list tuple identifier identifier expression_statement assignment attribute identifier identifier true
Add a request, response pair to this cassette
def locked(self, lock): _LOGGER.debug("Setting the lock: %s", lock) value = struct.pack('BB', PROP_LOCK, bool(lock)) self._conn.make_request(PROP_WRITE_HANDLE, value)
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list 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 identifier call identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier
Locks or unlocks the thermostat.
def run_command_on_master( command, username=None, key_path=None, noisy=True ): return run_command(shakedown.master_ip(), command, username, key_path, noisy)
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier true block return_statement call identifier argument_list call attribute identifier identifier argument_list identifier identifier identifier identifier
Run a command on the Mesos master
def beginning_of_history(self): u self.history_cursor = 0 if len(self.history) > 0: self.l_buffer = self.history[0]
module function_definition identifier parameters identifier block expression_statement identifier expression_statement assignment attribute identifier identifier integer if_statement comparison_operator call identifier argument_list attribute identifier identifier integer block expression_statement assignment attribute identifier identifier subscript attribute identifier identifier integer
u'''Move to the first line in the history.
def getSampleTypeTitles(self): sample_types = self.getSampleTypes() sample_type_titles = map(lambda obj: obj.Title(), sample_types) if not sample_type_titles: return [""] return sample_type_titles
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list lambda lambda_parameters identifier call attribute identifier identifier argument_list identifier if_statement not_operator identifier block return_statement list string string_start string_end return_statement identifier
Returns a list of sample type titles
def _setup_versioned_lib_variables(env, **kw): tool = None try: tool = kw['tool'] except KeyError: pass use_soname = False try: use_soname = kw['use_soname'] except KeyError: pass if use_soname: if tool == 'sunlink': env['_SHLIBVERSIONFLAGS'] = '$SHLIBVERSIONFLAGS -h $_SHLIBSONAME' env['_LDMODULEVERSIONFLAGS'] = '$LDMODULEVERSIONFLAGS -h $_LDMODULESONAME' else: env['_SHLIBVERSIONFLAGS'] = '$SHLIBVERSIONFLAGS -Wl,-soname=$_SHLIBSONAME' env['_LDMODULEVERSIONFLAGS'] = '$LDMODULEVERSIONFLAGS -Wl,-soname=$_LDMODULESONAME' env['_SHLIBSONAME'] = '${ShLibSonameGenerator(__env__,TARGET)}' env['_LDMODULESONAME'] = '${LdModSonameGenerator(__env__,TARGET)}' env['ShLibSonameGenerator'] = SCons.Tool.ShLibSonameGenerator env['LdModSonameGenerator'] = SCons.Tool.LdModSonameGenerator else: env['_SHLIBVERSIONFLAGS'] = '$SHLIBVERSIONFLAGS' env['_LDMODULEVERSIONFLAGS'] = '$LDMODULEVERSIONFLAGS' env['LDMODULEVERSIONFLAGS'] = '$SHLIBVERSIONFLAGS'
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier none try_statement block expression_statement assignment identifier subscript identifier string string_start string_content string_end except_clause identifier block pass_statement expression_statement assignment identifier false try_statement block expression_statement assignment identifier subscript identifier string string_start string_content string_end except_clause identifier block pass_statement if_statement identifier block if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_content string_end else_clause block expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end attribute attribute identifier identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end attribute attribute identifier identifier identifier else_clause block expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_content string_end
Setup all variables required by the versioning machinery
def load_profile(self, profile_name): data = self.storage.get_user_profiles(profile_name) for x in data.get_user_views(): self._graph.add_edge(int(x[0]), int(x[1]), {'weight': float(x[2])}) self.all_records[int(x[1])] += 1 return self._graph
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier for_statement identifier call attribute identifier identifier argument_list block expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list subscript identifier integer call identifier argument_list subscript identifier integer dictionary pair string string_start string_content string_end call identifier argument_list subscript identifier integer expression_statement augmented_assignment subscript attribute identifier identifier call identifier argument_list subscript identifier integer integer return_statement attribute identifier identifier
Load user profiles from file.
async def _write_ssl(self): pending = lib.BIO_ctrl_pending(self.write_bio) if pending > 0: result = lib.BIO_read(self.write_bio, self.write_cdata, len(self.write_cdata)) await self.transport._send(ffi.buffer(self.write_cdata)[0:result]) self.__tx_bytes += result self.__tx_packets += 1
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier if_statement comparison_operator identifier integer block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier call identifier argument_list attribute identifier identifier expression_statement await call attribute attribute identifier identifier identifier argument_list subscript call attribute identifier identifier argument_list attribute identifier identifier slice integer identifier expression_statement augmented_assignment attribute identifier identifier identifier expression_statement augmented_assignment attribute identifier identifier integer
Flush outgoing data which OpenSSL put in our BIO to the transport.
def remove_network_profile(self, obj, params): self._logger.debug("delete profile: %s", params.ssid) str_buf = create_unicode_buffer(params.ssid) ret = self._wlan_delete_profile(self._handle, obj['guid'], str_buf) self._logger.debug("delete result %d", ret)
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier subscript identifier string string_start string_content string_end identifier expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier
Remove the specified AP profile.
def interm_size(self) -> Sequence[Shape]: return self._sizes(self._compiler.rddl.interm_size)
module function_definition identifier parameters identifier type generic_type identifier type_parameter type identifier block return_statement call attribute identifier identifier argument_list attribute attribute attribute identifier identifier identifier identifier
Returns the MDP intermediate state size.
def update(self, rows): if len(rows) == 0: return sql, sql_args = self.get_update_sql(rows) cursor = self.get_cursor() cursor.execute(sql, sql_args)
module function_definition identifier parameters identifier identifier block if_statement comparison_operator call identifier argument_list identifier integer block return_statement expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier identifier
Updates records in the db
def kitchen_delete(backend, kitchen): click.secho('%s - Deleting kitchen %s' % (get_datetime(), kitchen), fg='green') master = 'master' if kitchen.lower() != master.lower(): check_and_print(DKCloudCommandRunner.delete_kitchen(backend.dki, kitchen)) else: raise click.ClickException('Cannot delete the kitchen called %s' % master)
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple call identifier argument_list identifier keyword_argument identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end if_statement comparison_operator call attribute identifier identifier argument_list call attribute identifier identifier argument_list block expression_statement call identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier identifier else_clause block raise_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier
Provide the name of the kitchen to delete
def match_tokens(expected_tokens): if isinstance(expected_tokens, Token): def _grammar_func(tokens): try: next_token = next(iter(tokens)) except StopIteration: return if next_token == expected_tokens: return TokenMatch(None, next_token.value, (next_token,)) elif isinstance(expected_tokens, tuple): match_len = len(expected_tokens) def _grammar_func(tokens): upcoming = tuple(itertools.islice(tokens, match_len)) if upcoming == expected_tokens: return TokenMatch(None, None, upcoming) else: raise TypeError( "'expected_tokens' must be an instance of Token or a tuple " "thereof. Got %r." % expected_tokens) return _grammar_func
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier identifier block function_definition identifier parameters identifier block try_statement block expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier except_clause identifier block return_statement if_statement comparison_operator identifier identifier block return_statement call identifier argument_list none attribute identifier identifier tuple identifier elif_clause call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list identifier function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list identifier identifier if_statement comparison_operator identifier identifier block return_statement call identifier argument_list none none identifier else_clause 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 return_statement identifier
Generate a grammar function that will match 'expected_tokens' only.
def on_modified(self, event): path = event.src_path if path not in self.saw: self.saw.add(path) self.recompile(path)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier
Handle a file modified event.
def summary_extra(self): out = { 'errno': 0, 'agent': request.headers.get('User-Agent', ''), 'lang': request.headers.get('Accept-Language', ''), 'method': request.method, 'path': request.path, } user_id = self.user_id() if user_id is None: user_id = '' out['uid'] = user_id request_id = g.get('_request_id', None) if request_id is not None: out['rid'] = request_id start_timestamp = g.get('_start_timestamp', None) if start_timestamp is not None: out['t'] = int(1000 * (time.time() - start_timestamp)) return out
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end integer pair string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_end pair string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_end pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier none block expression_statement assignment identifier string string_start string_end expression_statement assignment subscript identifier 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 none if_statement comparison_operator identifier none block expression_statement assignment subscript identifier 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 none if_statement comparison_operator identifier none block expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list binary_operator integer parenthesized_expression binary_operator call attribute identifier identifier argument_list identifier return_statement identifier
Build the extra data for the summary logger.
def add_task(self, command, name=None, **kwargs): logger.debug('Adding task with command {0} to job {1}'.format(command, self.name)) if not self.state.allow_change_graph: raise DagobahError("job's graph is immutable in its current state: %s" % self.state.status) if name is None: name = command new_task = Task(self, command, name, **kwargs) self.tasks[name] = new_task self.add_node(name) self.commit()
module function_definition identifier parameters identifier identifier default_parameter identifier none dictionary_splat_pattern 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 attribute attribute identifier identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end attribute attribute identifier identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier identifier dictionary_splat identifier expression_statement assignment subscript attribute identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list
Adds a new Task to the graph with no edges.
def list(self): queue = self._get_queue() if queue is None: raise QueueDoesntExist output = self.check_output('%s' % shell_escape(queue / 'commands/list')) job_id, info = None, None for line in output.splitlines(): line = line.decode('utf-8') if line.startswith(' '): key, value = line[4:].split(': ', 1) info[key] = value else: if job_id is not None: yield job_id, info job_id = line info = {} if job_id is not None: yield job_id, info
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier none block raise_statement identifier expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list binary_operator identifier string string_start string_content string_end expression_statement assignment pattern_list identifier identifier expression_list none none for_statement identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment pattern_list identifier identifier call attribute subscript identifier slice integer identifier argument_list string string_start string_content string_end integer expression_statement assignment subscript identifier identifier identifier else_clause block if_statement comparison_operator identifier none block expression_statement yield expression_list identifier identifier expression_statement assignment identifier identifier expression_statement assignment identifier dictionary if_statement comparison_operator identifier none block expression_statement yield expression_list identifier identifier
Lists the jobs on the server.
def ends_with_path_separator(self, file_path): if is_int_type(file_path): return False file_path = make_string_path(file_path) return (file_path and file_path not in (self.path_separator, self.alternative_path_separator) and (file_path.endswith(self._path_separator(file_path)) or self.alternative_path_separator is not None and file_path.endswith( self._alternative_path_separator(file_path))))
module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier block return_statement false expression_statement assignment identifier call identifier argument_list identifier return_statement parenthesized_expression boolean_operator boolean_operator identifier comparison_operator identifier tuple attribute identifier identifier attribute identifier identifier parenthesized_expression boolean_operator call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier boolean_operator comparison_operator attribute identifier identifier none call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier
Return True if ``file_path`` ends with a valid path separator.
def ls(self, src, extra_args=[]): src = [self._full_hdfs_path(x) for x in src] output = self._getStdOutCmd([self._hadoop_cmd, 'fs', '-ls'] + extra_args + src, True) return self._transform_ls_output(output, self.hdfs_url)
module function_definition identifier parameters identifier identifier default_parameter identifier list block expression_statement assignment identifier list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator binary_operator list attribute identifier identifier string string_start string_content string_end string string_start string_content string_end identifier identifier true return_statement call attribute identifier identifier argument_list identifier attribute identifier identifier
List files in a directory
def find_command_class(possible_command_names): for command_name in possible_command_names: if hasattr(ALL_COMMANDS_MODULE, command_name): command_module = getattr(ALL_COMMANDS_MODULE, command_name) command_class_hierarchy = getmembers(command_module, isclass) command_class_tuple = list(filter(_not_base_class, command_class_hierarchy))[0] return command_class_tuple[1] return None
module function_definition identifier parameters identifier block for_statement identifier identifier block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier subscript call identifier argument_list call identifier argument_list identifier identifier integer return_statement subscript identifier integer return_statement none
Try to find a class for one of the given command names.
def lambda_vpc_execution_statements(): return [ Statement( Effect=Allow, Resource=['*'], Action=[ ec2.CreateNetworkInterface, ec2.DescribeNetworkInterfaces, ec2.DeleteNetworkInterface, ] ) ]
module function_definition identifier parameters block return_statement list call identifier argument_list keyword_argument identifier identifier keyword_argument identifier list string string_start string_content string_end keyword_argument identifier list attribute identifier identifier attribute identifier identifier attribute identifier identifier
Allow Lambda to manipuate EC2 ENIs for VPC support.
def dump(self, f, indent=''): if self.__unit is None: print(("%s%s %s" % (indent, self.__name, self.__value)).rstrip(), file=f) else: print(("%s%s [%s] %s" % (indent, self.__name, self.__unit, self.__value)).rstrip(), file=f)
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_end block if_statement comparison_operator attribute identifier identifier none block expression_statement call identifier argument_list call attribute parenthesized_expression binary_operator string string_start string_content string_end tuple identifier attribute identifier identifier attribute identifier identifier identifier argument_list keyword_argument identifier identifier else_clause block expression_statement call identifier argument_list call attribute parenthesized_expression binary_operator string string_start string_content string_end tuple identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier identifier argument_list keyword_argument identifier identifier
Dump this keyword to a file-like object
def flatten(self, shallow=None): return self._wrap(self._flatten(self.obj, shallow))
module function_definition identifier parameters identifier default_parameter identifier none block return_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier identifier
Return a completely flattened version of an array.
def convert_bool(string): if string == 'True': return True, True elif string == 'False': return True, False else: return False, False
module function_definition identifier parameters identifier block if_statement comparison_operator identifier string string_start string_content string_end block return_statement expression_list true true elif_clause comparison_operator identifier string string_start string_content string_end block return_statement expression_list true false else_clause block return_statement expression_list false false
Check whether string is boolean.
def output_list(self, category): print('{} users:'.format(category)) for user in getattr(self.sub, category): print(' {}'.format(user))
module function_definition identifier parameters identifier identifier block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier for_statement identifier call identifier argument_list attribute identifier identifier identifier block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier
Display the list of users in `category`.
def verify_signature(key, qs): unsigned_qs = re.sub(r'&?sig=[^&]*', '', qs) sig = derive_signature(key, unsigned_qs) return urlparse.parse_qs(qs).get("sig", [None])[0] == sig
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end identifier expression_statement assignment identifier call identifier argument_list identifier identifier return_statement comparison_operator subscript call attribute call attribute identifier identifier argument_list identifier identifier argument_list string string_start string_content string_end list none integer identifier
Verifies that the signature in the query string is correct.
def escape(arg): "escape shell special characters" slash = '\\' special = '"$' arg = arg.replace(slash, slash+slash) for c in special: arg = arg.replace(c, slash+c) return '"' + arg + '"'
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier string string_start string_content escape_sequence string_end expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier binary_operator identifier identifier for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier binary_operator identifier identifier return_statement binary_operator binary_operator string string_start string_content string_end identifier string string_start string_content string_end
escape shell special characters
def try_friends(self, others): befriended = False k = int(10*self['openness']) shuffle(others) for friend in islice(others, k): if friend == self: continue if friend.befriend(self): self.befriend(friend, force=True) self.debug('Hooray! new friend: {}'.format(friend.id)) befriended = True else: self.debug('{} does not want to be friends'.format(friend.id)) return befriended
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier false expression_statement assignment identifier call identifier argument_list binary_operator integer subscript identifier string string_start string_content string_end expression_statement call identifier argument_list identifier for_statement identifier call identifier argument_list identifier identifier block if_statement comparison_operator identifier identifier block continue_statement if_statement call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier true expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement assignment identifier true else_clause block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier return_statement identifier
Look for random agents around me and try to befriend them
def add_ip_to_net(networks, host): for network in networks: if host['ipaddr'] in network['network']: network['hosts'].append(host) return
module function_definition identifier parameters identifier identifier block for_statement identifier identifier block if_statement comparison_operator subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end block expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list identifier return_statement
Add hosts from ipplan to networks object.
def delete_port_precommit(self, context): if self._is_supported_deviceowner(context.current): vlan_segment, vxlan_segment = self._get_segments( context.top_bound_segment, context.bottom_bound_segment) vni = self._port_action_vxlan(context.current, vxlan_segment, self._delete_nve_db) if vxlan_segment else 0 self._port_action_vlan(context.current, vlan_segment, self._delete_nxos_db, vni)
module function_definition identifier parameters identifier identifier block if_statement call attribute identifier identifier argument_list attribute identifier identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement assignment identifier conditional_expression call attribute identifier identifier argument_list attribute identifier identifier identifier attribute identifier identifier identifier integer expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier attribute identifier identifier identifier
Delete port pre-database commit event.
def wet_records(wet_filepath): if wet_filepath.endswith('.gz'): fopen = gzip.open else: fopen = tf.gfile.GFile with fopen(wet_filepath) as f: for record in wet_records_from_file_obj(f): yield record
module function_definition identifier parameters identifier block if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier attribute identifier identifier else_clause block expression_statement assignment identifier attribute attribute identifier identifier identifier 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 yield identifier
Generate WETRecords from filepath.
def close(self): if not (yield from super().close()): return False self.acpi_shutdown = False yield from self.stop() for adapter in self._ethernet_adapters: if adapter is not None: for nio in adapter.ports.values(): if nio and isinstance(nio, NIOUDP): self.manager.port_manager.release_udp_port(nio.lport, self._project) for udp_tunnel in self._local_udp_tunnels.values(): self.manager.port_manager.release_udp_port(udp_tunnel[0].lport, self._project) self.manager.port_manager.release_udp_port(udp_tunnel[1].lport, self._project) self._local_udp_tunnels = {}
module function_definition identifier parameters identifier block if_statement not_operator parenthesized_expression yield call attribute call identifier argument_list identifier argument_list block return_statement false expression_statement assignment attribute identifier identifier false expression_statement yield call attribute identifier identifier argument_list for_statement identifier attribute identifier identifier block if_statement comparison_operator identifier none block for_statement identifier call attribute attribute identifier identifier identifier argument_list block if_statement boolean_operator identifier call identifier argument_list identifier identifier block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list attribute identifier identifier attribute identifier identifier for_statement identifier call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list attribute subscript identifier integer identifier attribute identifier identifier expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list attribute subscript identifier integer identifier attribute identifier identifier expression_statement assignment attribute identifier identifier dictionary
Closes this QEMU VM.
def processing_blocks(self): pb_list = ProcessingBlockList() return json.dumps(dict(active=pb_list.active, completed=pb_list.completed, aborted=pb_list.aborted))
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list return_statement call attribute identifier identifier argument_list call identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier
Return the a JSON dict encoding the PBs known to SDP.
def stemming_processor(words): stem = PorterStemmer().stem for word in words: word = stem(word, 0, len(word)-1) yield word
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute call identifier argument_list identifier for_statement identifier identifier block expression_statement assignment identifier call identifier argument_list identifier integer binary_operator call identifier argument_list identifier integer expression_statement yield identifier
Porter Stemmer word processor
def _set_worker_thread_level(self): bthread_logger = logging.getLogger( 'google.cloud.logging.handlers.transports.background_thread') if self.debug_thread_worker: bthread_logger.setLevel(logging.DEBUG) else: bthread_logger.setLevel(logging.INFO)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list attribute identifier identifier
Sets logging level of the background logging thread to DEBUG or INFO
def on_batch_end(self, last_loss, epoch, num_batch, **kwargs:Any)->None: "Test if `last_loss` is NaN and interrupts training." if self.stop: return True if torch.isnan(last_loss): print (f'Epoch/Batch ({epoch}/{num_batch}): Invalid loss, terminating training.') return {'stop_epoch': True, 'stop_training': True, 'skip_validate': True}
module function_definition identifier parameters identifier identifier identifier identifier typed_parameter dictionary_splat_pattern identifier type identifier type none block expression_statement string string_start string_content string_end if_statement attribute identifier identifier block return_statement true if_statement call attribute identifier identifier argument_list identifier block expression_statement call identifier argument_list string string_start string_content interpolation identifier string_content interpolation identifier string_content string_end return_statement dictionary pair string string_start string_content string_end true pair string string_start string_content string_end true pair string string_start string_content string_end true
Test if `last_loss` is NaN and interrupts training.
def lock(self): component = self.component while True: if isinstance( component, smartcard.pcsc.PCSCCardConnection.PCSCCardConnection): hresult = SCardBeginTransaction(component.hcard) if 0 != hresult: raise CardConnectionException( 'Failed to lock with SCardBeginTransaction: ' + SCardGetErrorMessage(hresult)) else: pass break if hasattr(component, 'component'): component = component.component else: break
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier while_statement true block if_statement call identifier argument_list identifier attribute attribute attribute identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier if_statement comparison_operator integer identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list identifier else_clause block pass_statement break_statement if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment identifier attribute identifier identifier else_clause block break_statement
Lock card with SCardBeginTransaction.
def items_at(self, depth): if depth < 1: yield ROOT, self elif depth == 1: for key, value in self.items(): yield key, value else: for dict_tree in self.values(): for key, value in dict_tree.items_at(depth - 1): yield key, value
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier integer block expression_statement yield expression_list identifier identifier elif_clause comparison_operator identifier integer block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement yield expression_list identifier identifier else_clause block for_statement identifier call attribute identifier identifier argument_list block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list binary_operator identifier integer block expression_statement yield expression_list identifier identifier
Iterate items at specified depth.
def download_from_category(category_name, output_path, width): file_names = get_category_files_from_api(category_name) files_to_download = izip_longest(file_names, [], fillvalue=width) download_files_if_not_in_manifest(files_to_download, output_path)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier list keyword_argument identifier identifier expression_statement call identifier argument_list identifier identifier
Download files of a given category.
def rp_module_level_in_stack(): from traceback import extract_stack from rootpy import _ROOTPY_SOURCE_PATH modlevel_files = [filename for filename, _, func, _ in extract_stack() if func == "<module>"] return any(path.startswith(_ROOTPY_SOURCE_PATH) for path in modlevel_files)
module function_definition identifier parameters block import_from_statement dotted_name identifier dotted_name identifier import_from_statement dotted_name identifier dotted_name identifier expression_statement assignment identifier list_comprehension identifier for_in_clause pattern_list identifier identifier identifier identifier call identifier argument_list if_clause comparison_operator identifier string string_start string_content string_end return_statement call identifier generator_expression call attribute identifier identifier argument_list identifier for_in_clause identifier identifier
Returns true if we're during a rootpy import
def _forward_mode(self, *args): f_val, f_diff = self.f._forward_mode(*args) g_val, g_diff = self.g._forward_mode(*args) val = f_val + g_val diff = f_diff + g_diff return val, diff
module function_definition identifier parameters identifier list_splat_pattern identifier block expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list list_splat identifier expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list list_splat identifier expression_statement assignment identifier binary_operator identifier identifier expression_statement assignment identifier binary_operator identifier identifier return_statement expression_list identifier identifier
Forward mode differentiation for a sum
def user_default_add_related_pks(self, obj): if not hasattr(obj, '_votes_pks'): obj._votes_pks = list(obj.votes.values_list('pk', flat=True))
module function_definition identifier parameters identifier identifier block if_statement not_operator call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment attribute identifier identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier true
Add related primary keys to a User instance.
def dry_run(command, dry_run): if not dry_run: cmd_parts = command.split(' ') return local[cmd_parts[0]](cmd_parts[1:]) else: log.info('Dry run of %s, skipping' % command) return True
module function_definition identifier parameters identifier identifier block if_statement not_operator identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end return_statement call subscript identifier subscript identifier integer argument_list subscript identifier slice integer else_clause block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier return_statement true
Executes a shell command unless the dry run option is set
def create_node_group(self): self.create_stack( self.node_group_name, 'amazon-eks-nodegroup.yaml', capabilities=['CAPABILITY_IAM'], parameters=define_parameters( ClusterName=self.cluster_name, ClusterControlPlaneSecurityGroup=self.security_groups, Subnets=self.subnet_ids, VpcId=self.vpc_ids, KeyName=self.ssh_key_name, NodeAutoScalingGroupMaxSize="1", NodeVolumeSize="100", NodeImageId="ami-0a54c984b9f908c81", NodeGroupName=f"{self.name} OnDemand Nodes" ) )
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier string string_start string_content string_end keyword_argument identifier list string string_start string_content string_end keyword_argument identifier call identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start interpolation attribute identifier identifier string_content string_end
Create on-demand node group on Amazon EKS.
def execute_command_by_uuid(self, tab_uuid, command): if command[-1] != '\n': command += '\n' try: tab_uuid = uuid.UUID(tab_uuid) page_index, = ( index for index, t in enumerate(self.get_notebook().iter_terminals()) if t.get_uuid() == tab_uuid ) except ValueError: pass else: terminals = self.get_notebook().get_terminals_for_page(page_index) for current_vte in terminals: current_vte.feed_child(command)
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator subscript identifier unary_operator integer string string_start string_content escape_sequence string_end block expression_statement augmented_assignment identifier string string_start string_content escape_sequence string_end try_statement 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 except_clause identifier block pass_statement else_clause block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list identifier for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier
Execute the `command' in the tab whose terminal has the `tab_uuid' uuid
def generate_drone_plugin(self): example = {} example['pipeline'] = {} example['pipeline']['appname'] = {} example['pipeline']['appname']['image'] = "" example['pipeline']['appname']['secrets'] = "" for key, value in self.spec.items(): if value['type'] in (dict, list): kvalue = f"\'{json.dumps(value.get('example', ''))}\'" else: kvalue = f"{value.get('example', '')}" example['pipeline']['appname'][key.lower()] = kvalue print(yaml.dump(example, default_flow_style=False))
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary expression_statement assignment subscript identifier string string_start string_content string_end dictionary expression_statement assignment subscript subscript identifier string string_start string_content string_end string string_start string_content string_end dictionary expression_statement assignment subscript subscript subscript identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_end expression_statement assignment subscript subscript subscript identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_end for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block if_statement comparison_operator subscript identifier string string_start string_content string_end tuple identifier identifier block expression_statement assignment identifier string string_start string_content escape_sequence interpolation call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end string_content escape_sequence string_end else_clause block expression_statement assignment identifier string string_start interpolation call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end string_end expression_statement assignment subscript subscript subscript identifier string string_start string_content string_end string string_start string_content string_end call attribute identifier identifier argument_list identifier expression_statement call identifier argument_list call attribute identifier identifier argument_list identifier keyword_argument identifier false
Generate a sample drone plugin configuration
def setSample(self, sample): if not isinstance(sample, RDD): raise TypeError("samples should be a RDD, received %s" % type(sample)) self._sample = sample
module function_definition identifier parameters identifier identifier block if_statement not_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list identifier expression_statement assignment attribute identifier identifier identifier
Set sample points from the population. Should be a RDD
def render_form(form, **kwargs): renderer_cls = get_form_renderer(**kwargs) return renderer_cls(form, **kwargs).render()
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list dictionary_splat identifier return_statement call attribute call identifier argument_list identifier dictionary_splat identifier identifier argument_list
Render a form to a Bootstrap layout
def _set_original_fields(instance): original_fields = {} def _set_original_field(instance, field): if instance.pk is None: original_fields[field] = None else: if isinstance(instance._meta.get_field(field), ForeignKey): original_fields[field] = getattr(instance, '{0}_id'.format(field)) else: original_fields[field] = getattr(instance, field) for field in getattr(instance, '_tracked_fields', []): _set_original_field(instance, field) for field in getattr(instance, '_tracked_related_fields', {}).keys(): _set_original_field(instance, field) instance._original_fields = original_fields instance._original_fields['pk'] = instance.pk
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment subscript identifier identifier none else_clause block if_statement call identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier block expression_statement assignment subscript identifier identifier call identifier argument_list identifier call attribute string string_start string_content string_end identifier argument_list identifier else_clause block expression_statement assignment subscript identifier identifier call identifier argument_list identifier identifier for_statement identifier call identifier argument_list identifier string string_start string_content string_end list block expression_statement call identifier argument_list identifier identifier for_statement identifier call attribute call identifier argument_list identifier string string_start string_content string_end dictionary identifier argument_list block expression_statement call identifier argument_list identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier
Save fields value, only for non-m2m fields.
def doublec(self, j): if j < 1 or self.b[j] != self.b[j-1]: return False return self.cons(j)
module function_definition identifier parameters identifier identifier block if_statement boolean_operator comparison_operator identifier integer comparison_operator subscript attribute identifier identifier identifier subscript attribute identifier identifier binary_operator identifier integer block return_statement false return_statement call attribute identifier identifier argument_list identifier
True iff j, j-1 contains double consonant
def _setup_container(container_name): for meth in (database.load_container, load_new_labware, _load_weird_container): log.debug( f"Trying to load container {container_name} via {meth.__name__}") try: container = meth(container_name) if meth == _load_weird_container: container.properties['type'] = container_name log.info(f"Loaded {container_name} from {meth.__name__}") break except (ValueError, KeyError): log.info(f"{container_name} not in {meth.__name__}") else: raise KeyError(f"Unknown labware {container_name}") container_x, container_y, container_z = container._coordinates if container_z == 0 and 'height' in container[0].properties: container_z = container[0].properties['height'] from opentrons.util.vector import Vector container._coordinates = Vector( container_x, container_y, container_z) return container
module function_definition identifier parameters identifier block for_statement identifier tuple attribute identifier identifier identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content interpolation identifier string_content interpolation attribute identifier identifier string_end try_statement block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier identifier block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list string string_start string_content interpolation identifier string_content interpolation attribute identifier identifier string_end break_statement except_clause tuple identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start interpolation identifier string_content interpolation attribute identifier identifier string_end else_clause block raise_statement call identifier argument_list string string_start string_content interpolation identifier string_end expression_statement assignment pattern_list identifier identifier identifier attribute identifier identifier if_statement boolean_operator comparison_operator identifier integer comparison_operator string string_start string_content string_end attribute subscript identifier integer identifier block expression_statement assignment identifier subscript attribute subscript identifier integer identifier string string_start string_content string_end import_from_statement dotted_name identifier identifier identifier dotted_name identifier expression_statement assignment attribute identifier identifier call identifier argument_list identifier identifier identifier return_statement identifier
Try and find a container in a variety of methods
def peer_relation_id(): md = metadata() section = md.get('peers') if section: for key in section: relids = relation_ids(key) if relids: return relids[0] return None
module function_definition identifier parameters block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement identifier block for_statement identifier identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement identifier block return_statement subscript identifier integer return_statement none
Get the peers relation id if a peers relation has been joined, else None.
def solve_cast(expr, vars): lhs = solve(expr.lhs, vars).value t = solve(expr.rhs, vars).value if t is None: raise errors.EfilterTypeError( root=expr, query=expr.source, message="Cannot find type named %r." % expr.rhs.value) if not isinstance(t, type): raise errors.EfilterTypeError( root=expr.rhs, query=expr.source, message="%r is not a type and cannot be used with 'cast'." % (t,)) try: cast_value = t(lhs) except TypeError: raise errors.EfilterTypeError( root=expr, query=expr.source, message="Invalid cast %s -> %s." % (type(lhs), t)) return Result(cast_value, ())
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute call identifier argument_list attribute identifier identifier identifier identifier expression_statement assignment identifier attribute call identifier argument_list attribute identifier identifier identifier identifier if_statement comparison_operator identifier none block raise_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier binary_operator string string_start string_content string_end attribute attribute identifier identifier identifier if_statement not_operator call identifier argument_list identifier identifier block raise_statement call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier binary_operator string string_start string_content string_end tuple identifier try_statement block expression_statement assignment identifier call identifier argument_list identifier except_clause identifier block raise_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier binary_operator string string_start string_content string_end tuple call identifier argument_list identifier identifier return_statement call identifier argument_list identifier tuple
Get cast LHS to RHS.
def strseq(object, convert, join=joinseq): if type(object) in [types.ListType, types.TupleType]: return join(map(lambda o, c=convert, j=join: strseq(o, c, j), object)) else: return convert(object)
module function_definition identifier parameters identifier identifier default_parameter identifier identifier block if_statement comparison_operator call identifier argument_list identifier list attribute identifier identifier attribute identifier identifier block return_statement call identifier argument_list call identifier argument_list lambda lambda_parameters identifier default_parameter identifier identifier default_parameter identifier identifier call identifier argument_list identifier identifier identifier identifier else_clause block return_statement call identifier argument_list identifier
Recursively walk a sequence, stringifying each element.
def config_profile_fwding_mode_get(self, profile_name): profile_params = self._config_profile_get(profile_name) fwd_cli = 'fabric forwarding mode proxy-gateway' if profile_params and fwd_cli in profile_params['configCommands']: return 'proxy-gateway' else: return 'anycast-gateway'
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier string string_start string_content string_end if_statement boolean_operator identifier comparison_operator identifier subscript identifier string string_start string_content string_end block return_statement string string_start string_content string_end else_clause block return_statement string string_start string_content string_end
Return forwarding mode of given config profile.
def refreshUi( self ): widget = self.uiContentsTAB.currentWidget() is_content = isinstance(widget, QWebView) if is_content: self._currentContentsIndex = self.uiContentsTAB.currentIndex() history = widget.page().history() else: history = None self.uiBackACT.setEnabled(is_content and history.canGoBack()) self.uiForwardACT.setEnabled(is_content and history.canGoForward()) self.uiHomeACT.setEnabled(is_content) self.uiNewTabACT.setEnabled(is_content) self.uiCopyTextACT.setEnabled(is_content) self.uiCloseTabACT.setEnabled(is_content and self.uiContentsTAB.count() > 2) for i in range(1, self.uiContentsTAB.count()): widget = self.uiContentsTAB.widget(i) self.uiContentsTAB.setTabText(i, widget.title())
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call identifier argument_list identifier identifier if_statement identifier block expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list else_clause block expression_statement assignment identifier none expression_statement call attribute attribute identifier identifier identifier argument_list boolean_operator identifier call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list boolean_operator identifier call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list boolean_operator identifier comparison_operator call attribute attribute identifier identifier identifier argument_list integer for_statement identifier call identifier argument_list integer call attribute attribute identifier identifier identifier argument_list block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier call attribute identifier identifier argument_list
Refreshes the interface based on the current settings.
def and_next(e): def match_and_next(s, grm=None, pos=0): try: e(s, grm, pos) except PegreError as ex: raise PegreError('Positive lookahead failed', pos) else: return PegreResult(s, Ignore, (pos, pos)) return match_and_next
module function_definition identifier parameters identifier block function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier integer block try_statement block expression_statement call identifier argument_list identifier identifier identifier except_clause as_pattern identifier as_pattern_target identifier block raise_statement call identifier argument_list string string_start string_content string_end identifier else_clause block return_statement call identifier argument_list identifier identifier tuple identifier identifier return_statement identifier
Create a PEG function for positive lookahead.
def _get_conn(profile): DEFAULT_BASE_URL = _construct_uri(profile) or 'http://localhost:5984' server = couchdb.Server() if profile['database'] not in server: server.create(profile['database']) return server
module function_definition identifier parameters identifier block expression_statement assignment identifier boolean_operator call identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator subscript identifier string string_start string_content string_end identifier block expression_statement call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end return_statement identifier
Get a connection to CouchDB
def process(self, event): logger.info(f"{self}: put {event.src_path}") self.queue.put(os.path.basename(event.src_path))
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start interpolation identifier string_content interpolation attribute identifier identifier string_end expression_statement call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list attribute identifier identifier
Put and process tasks in queue.
def sort_key(val): return numpy.sum((max(val)+1)**numpy.arange(len(val)-1, -1, -1)*val)
module function_definition identifier parameters identifier block return_statement call attribute identifier identifier argument_list binary_operator binary_operator parenthesized_expression binary_operator call identifier argument_list identifier integer call attribute identifier identifier argument_list binary_operator call identifier argument_list identifier integer unary_operator integer unary_operator integer identifier
Sort key for sorting keys in grevlex order.
def ensure_permission_set_tree_cached(user): if hasattr(user, CACHED_PSET_PROPERTY_KEY): return try: setattr( user, CACHED_PSET_PROPERTY_KEY, _get_permission_set_tree(user)) except ObjectDoesNotExist: pass
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier identifier block return_statement try_statement block expression_statement call identifier argument_list identifier identifier call identifier argument_list identifier except_clause identifier block pass_statement
Helper to cache permission set tree on user instance
def extract_words(string): return re.findall(r'[%s]+[%s\.]*[%s]+' % (A, A, A), string, flags=FLAGS)
module function_definition identifier parameters identifier block return_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier identifier identifier keyword_argument identifier identifier
Extract all alphabetic syllabified forms from 'string'.
def generate(length): if not isinstance(length, int) or length < 2: raise TypeError('length must be a positive integer greater than 1.') digits = [random.randint(1, 9)] for i in range(length-2): digits.append(random.randint(0, 9)) digits.append(get_check_digit(''.join(map(str, digits)))) return ''.join(map(str, digits))
module function_definition identifier parameters identifier block if_statement boolean_operator not_operator call identifier argument_list identifier identifier comparison_operator identifier integer block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier list call attribute identifier identifier argument_list integer integer for_statement identifier call identifier argument_list binary_operator identifier integer block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list integer integer expression_statement call attribute identifier identifier argument_list call identifier argument_list call attribute string string_start string_end identifier argument_list call identifier argument_list identifier identifier return_statement call attribute string string_start string_end identifier argument_list call identifier argument_list identifier identifier
Generates random and valid card number which is returned as a string.
def setdirs(outfiles): for k in outfiles: fname=outfiles[k] dname= os.path.dirname(fname) if not os.path.isdir(dname): os.mkdir(dname)
module function_definition identifier parameters identifier block for_statement identifier identifier block expression_statement assignment identifier subscript identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier
Create the directories if need be
def bk_white(cls): "Make the text background color white." wAttributes = cls._get_text_attributes() wAttributes &= ~win32.BACKGROUND_MASK wAttributes |= win32.BACKGROUND_GREY cls._set_text_attributes(wAttributes)
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement augmented_assignment identifier unary_operator attribute identifier identifier expression_statement augmented_assignment identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier
Make the text background color white.
def position_input(obj, visible=False): if not obj.generic_position.all(): ObjectPosition.objects.create(content_object=obj) return {'obj': obj, 'visible': visible, 'object_position': obj.generic_position.all()[0]}
module function_definition identifier parameters identifier default_parameter identifier false block if_statement not_operator call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier return_statement dictionary 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 subscript call attribute attribute identifier identifier identifier argument_list integer
Template tag to return an input field for the position of the object.
def add_new(self, command): self.queue[self.next_key] = command self.queue[self.next_key]['status'] = 'queued' self.queue[self.next_key]['returncode'] = '' self.queue[self.next_key]['stdout'] = '' self.queue[self.next_key]['stderr'] = '' self.queue[self.next_key]['start'] = '' self.queue[self.next_key]['end'] = '' self.next_key += 1 self.write()
module function_definition identifier parameters identifier identifier block expression_statement assignment subscript attribute identifier identifier attribute identifier identifier identifier expression_statement assignment subscript subscript attribute identifier identifier attribute identifier identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment subscript subscript attribute identifier identifier attribute identifier identifier string string_start string_content string_end string string_start string_end expression_statement assignment subscript subscript attribute identifier identifier attribute identifier identifier string string_start string_content string_end string string_start string_end expression_statement assignment subscript subscript attribute identifier identifier attribute identifier identifier string string_start string_content string_end string string_start string_end expression_statement assignment subscript subscript attribute identifier identifier attribute identifier identifier string string_start string_content string_end string string_start string_end expression_statement assignment subscript subscript attribute identifier identifier attribute identifier identifier string string_start string_content string_end string string_start string_end expression_statement augmented_assignment attribute identifier identifier integer expression_statement call attribute identifier identifier argument_list
Add a new entry to the queue.
def add_mapping(self, data, name=None): from .mappings import DocumentObjectField from .mappings import NestedObject from .mappings import ObjectField if isinstance(data, (DocumentObjectField, ObjectField, NestedObject)): self.mappings[data.name] = data.as_dict() return if name: self.mappings[name] = data return if isinstance(data, dict): self.mappings.update(data) elif isinstance(data, list): for d in data: if isinstance(d, dict): self.mappings.update(d) elif isinstance(d, DocumentObjectField): self.mappings[d.name] = d.as_dict() else: name, data = d self.add_mapping(data, name)
module function_definition identifier parameters identifier identifier default_parameter identifier none block import_from_statement relative_import import_prefix dotted_name identifier dotted_name identifier import_from_statement relative_import import_prefix dotted_name identifier dotted_name identifier import_from_statement relative_import import_prefix dotted_name identifier dotted_name identifier if_statement call identifier argument_list identifier tuple identifier identifier identifier block expression_statement assignment subscript attribute identifier identifier attribute identifier identifier call attribute identifier identifier argument_list return_statement if_statement identifier block expression_statement assignment subscript attribute identifier identifier identifier identifier return_statement if_statement call identifier argument_list identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier elif_clause call identifier argument_list identifier identifier block for_statement identifier identifier block if_statement call identifier argument_list identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier elif_clause call identifier argument_list identifier identifier block expression_statement assignment subscript attribute identifier identifier attribute identifier identifier call attribute identifier identifier argument_list else_clause block expression_statement assignment pattern_list identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier
Add a new mapping
def btc_make_p2wpkh_address( pubkey_hex ): pubkey_hex = keylib.key_formatting.compress(pubkey_hex) hash160_bin = hashing.bin_hash160(pubkey_hex.decode('hex')) return segwit_addr_encode(hash160_bin)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end return_statement call identifier argument_list identifier
Make a p2wpkh address from a hex pubkey
def _get_inline_translations(self, request, language_code, obj=None): inline_instances = self.get_inline_instances(request, obj=obj) for inline in inline_instances: if issubclass(inline.model, TranslatableModelMixin): fk = inline.get_formset(request, obj).fk rel_name = 'master__{0}'.format(fk.name) filters = { 'language_code': language_code, rel_name: obj } for translations_model in inline.model._parler_meta.get_all_models(): qs = translations_model.objects.filter(**filters) if obj is not None: qs = qs.using(obj._state.db) yield inline, qs
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier for_statement identifier identifier block if_statement call identifier argument_list attribute identifier identifier identifier block expression_statement assignment identifier attribute call attribute identifier identifier argument_list identifier identifier identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair identifier identifier for_statement identifier call attribute attribute attribute identifier identifier identifier identifier argument_list block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list dictionary_splat identifier if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list attribute attribute identifier identifier identifier expression_statement yield expression_list identifier identifier
Fetch the inline translations
def _fix_path(): import os import sys all_paths = os.environ.get('PYTHONPATH').split(os.pathsep) for path_dir in all_paths: dev_appserver_path = os.path.join(path_dir, 'dev_appserver.py') if os.path.exists(dev_appserver_path): logging.debug('Found appengine SDK on path!') google_appengine = os.path.dirname(os.path.realpath(dev_appserver_path)) sys.path.append(google_appengine) dev_appserver = __import__('dev_appserver') sys.path.extend(dev_appserver.EXTRA_PATHS) return
module function_definition identifier parameters block import_statement dotted_name identifier import_statement dotted_name identifier expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier argument_list attribute identifier identifier for_statement identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier return_statement
Finds the google_appengine directory and fixes Python imports to use it.