code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def plot_interactive(mergepkl, noisepkl=None, thresh=6.0, thresh_link=7.0, ignoret=None, savehtml=True, url_path='plots'): data = readdata(mergepkl) circleinds = calcinds(data, thresh, ignoret) crossinds = calcinds(data, -1*thresh, ignoret) edgeinds = calcinds(data, thresh_link, ignoret) workdir = os.path.dirname(mergepkl) fileroot = os.path.basename(mergepkl).rstrip('_merge.pkl').lstrip('cands_') logger.info('Total on target time: {} s'.format(calcontime(data, inds=circleinds+crossinds+edgeinds))) if noisepkl: noiseplot = plotnoisecum(noisepkl) else: noiseplot = None combined = plotall(data, circleinds=circleinds, crossinds=crossinds, edgeinds=edgeinds, htmlname=None, noiseplot=noiseplot, url_path=url_path, fileroot=fileroot) if savehtml: output_file(mergepkl.rstrip('.pkl') + '.html') save(combined) else: return combined
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier float default_parameter identifier float default_parameter identifier none default_parameter identifier true default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier binary_operator unary_operator integer identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute call attribute call attribute attribute identifier identifier identifier argument_list identifier identifier argument_list string string_start string_content string_end identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier keyword_argument identifier binary_operator binary_operator identifier identifier identifier if_statement identifier block expression_statement assignment identifier call identifier argument_list identifier else_clause block expression_statement assignment identifier none expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier none keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier if_statement identifier block expression_statement call identifier argument_list binary_operator call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement call identifier argument_list identifier else_clause block return_statement identifier
Backwards compatible function for making interactive candidate summary plot
def preview(self): if hasattr(self, '_url'): url = self._url + '/preview' return self.post(url) else: url = urljoin(recurly.base_uri(), self.collection_path + '/preview') return self.post(url)
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment identifier binary_operator attribute identifier identifier string string_start string_content string_end return_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list binary_operator attribute identifier identifier string string_start string_content string_end return_statement call attribute identifier identifier argument_list identifier
Preview the purchase of this gift card
def _as_in_context(data, ctx): if isinstance(data, nd.NDArray): return data.as_in_context(ctx) elif isinstance(data, (list, tuple)): return [_as_in_context(d, ctx) for d in data] return data
module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier attribute identifier identifier block return_statement call attribute identifier identifier argument_list identifier elif_clause call identifier argument_list identifier tuple identifier identifier block return_statement list_comprehension call identifier argument_list identifier identifier for_in_clause identifier identifier return_statement identifier
Move data into new context.
def decodeUcs2(byteIter, numBytes): userData = [] i = 0 try: while i < numBytes: userData.append(unichr((next(byteIter) << 8) | next(byteIter))) i += 2 except StopIteration: pass return ''.join(userData)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list expression_statement assignment identifier integer try_statement block while_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list binary_operator parenthesized_expression binary_operator call identifier argument_list identifier integer call identifier argument_list identifier expression_statement augmented_assignment identifier integer except_clause identifier block pass_statement return_statement call attribute string string_start string_end identifier argument_list identifier
Decodes UCS2-encoded text from the specified byte iterator, up to a maximum of numBytes
def write_byte(self, address, value): LOGGER.debug("Writing byte %s to device %s!", bin(value), hex(address)) return self.driver.write_byte(address, value)
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list identifier call identifier argument_list identifier return_statement call attribute attribute identifier identifier identifier argument_list identifier identifier
Writes the byte to unaddressed register in a device.
def main(): if len(argv) < 2: targetfile = 'target.y' else: targetfile = argv[1] print 'Parsing ruleset: ' + targetfile, flex_a = Flexparser() mma = flex_a.yyparse(targetfile) print 'OK' print 'Perform minimization on initial automaton:', mma.minimize() print 'OK' print 'Perform StateRemoval on minimal automaton:', state_removal = StateRemoval(mma) mma_regex = state_removal.get_regex() print mma_regex
module function_definition identifier parameters block if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier string string_start string_content string_end else_clause block expression_statement assignment identifier subscript identifier integer print_statement binary_operator string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier print_statement string string_start string_content string_end print_statement string string_start string_content string_end expression_statement call attribute identifier identifier argument_list print_statement string string_start string_content string_end print_statement string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list print_statement identifier
Testing function for DFA _Brzozowski Operation
def path(self): location = self.client.table_location(self.table, self.database) if not location: raise Exception("Couldn't find location for table: {0}".format(str(self))) return location
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier attribute identifier identifier if_statement not_operator identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier return_statement identifier
Returns the path to this table in HDFS.
def _grab_xpath(root, xpath, converter=lambda x: x): elements = root.xpath(xpath) if elements: return converter(str(elements[0])) else: return None
module function_definition identifier parameters identifier identifier default_parameter identifier lambda lambda_parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement identifier block return_statement call identifier argument_list call identifier argument_list subscript identifier integer else_clause block return_statement none
XML convenience - grabs the first element at xpath if present, else returns None.
def stop_listener(self): if self.sock is not None: self.sock.close() self.sock = None self.tracks = {}
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier dictionary
stop listening for packets
def int2str(self, int_value): if self._int2str: return self._int2str[int_value] if not 0 <= int_value < self._num_classes: raise ValueError("Invalid integer class label %d" % int_value) return tf.compat.as_text(str(int_value))
module function_definition identifier parameters identifier identifier block if_statement attribute identifier identifier block return_statement subscript attribute identifier identifier identifier if_statement not_operator comparison_operator integer identifier attribute identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier return_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list identifier
Conversion integer => class name string.
def _setup_output(self, path, force): if os.path.isdir(path) or os.path.isfile(path): if force: logging.warn("Deleting previous file/directory '%s'" % path) if os.path.isfile(path): os.remove(path) else: shutil.rmtree(path) else: raise Exception("Cowardly refusing to overwrite already existing path at %s" % path)
module function_definition identifier parameters identifier identifier identifier block if_statement boolean_operator call attribute attribute identifier identifier identifier argument_list identifier call attribute attribute identifier identifier identifier argument_list identifier block if_statement identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier else_clause block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier
Clear the way for an output to be placed at path
def num_devices(self): c_count = c_uint() _check_return(_NVML.get_function( "nvmlDeviceGetCount_v2")(byref(c_count))) return c_count.value
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list expression_statement call identifier argument_list call call attribute identifier identifier argument_list string string_start string_content string_end argument_list call identifier argument_list identifier return_statement attribute identifier identifier
Get number of devices
def from_nvim(cls, nvim): return cls(nvim._session, nvim.channel_id, nvim.metadata, nvim.types, nvim._decode, nvim._err_cb)
module function_definition identifier parameters identifier identifier block return_statement call identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier
Create a new Nvim instance from an existing instance.
def execute_transactions(conn, statements: Iterable): with conn.cursor() as cursor: for statement in statements: try: cursor.execute(statement) conn.commit() except psycopg2.ProgrammingError: conn.rollback()
module function_definition identifier parameters identifier typed_parameter identifier type identifier block with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list as_pattern_target identifier block for_statement identifier identifier block try_statement block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list except_clause attribute identifier identifier block expression_statement call attribute identifier identifier argument_list
Execute several statements each as a single DB transaction.
def build_acl_port(self, port, enabled=True): "Build the acl for L4 Ports. " if port is not None: if ':' in port: range = port.replace(':', ' ') acl = "range %(range)s " % {'range': range} else: acl = "eq %(port)s " % {'port': port} if not enabled: acl += "inactive" return acl
module function_definition identifier parameters identifier identifier default_parameter identifier true block expression_statement string string_start string_content string_end if_statement comparison_operator identifier none block if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier binary_operator string string_start string_content string_end dictionary pair string string_start string_content string_end identifier else_clause block expression_statement assignment identifier binary_operator string string_start string_content string_end dictionary pair string string_start string_content string_end identifier if_statement not_operator identifier block expression_statement augmented_assignment identifier string string_start string_content string_end return_statement identifier
Build the acl for L4 Ports.
def parse_value(self, value): if not isinstance(value, dict): return value embed_type = self._get_embed_type() return embed_type(**value)
module function_definition identifier parameters identifier identifier block if_statement not_operator call identifier argument_list identifier identifier block return_statement identifier expression_statement assignment identifier call attribute identifier identifier argument_list return_statement call identifier argument_list dictionary_splat identifier
Parse value to proper model type.
def export_project(self): generated_projects = deepcopy(self.generated_projects) self.process_data_for_makefile(self.workspace) generated_projects['path'], generated_projects['files']['makefile'] = self.gen_file_jinja('makefile_armcc.tmpl', self.workspace, 'Makefile', self.workspace['output_dir']['path']) return generated_projects
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment pattern_list subscript identifier string string_start string_content string_end subscript subscript identifier string string_start string_content string_end string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier string string_start string_content string_end subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end return_statement identifier
Processes misc options specific for GCC ARM, and run generator
def update(self, sent): self.offset = sent now = datetime.datetime.now() elapsed = (now - self.startTime).total_seconds() if elapsed > 0: mbps = (sent * 8 / (10 ** 6)) / elapsed else: mbps = None self._display(sent, now, self.name, mbps)
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute parenthesized_expression binary_operator identifier attribute identifier identifier identifier argument_list if_statement comparison_operator identifier integer block expression_statement assignment identifier binary_operator parenthesized_expression binary_operator binary_operator identifier integer parenthesized_expression binary_operator integer integer identifier else_clause block expression_statement assignment identifier none expression_statement call attribute identifier identifier argument_list identifier identifier attribute identifier identifier identifier
Update self and parent with intermediate progress.
def calculate_hash(options): options = sorted(list(options)) sha_hash = sha1() sha_hash.update(''.join(options).encode('utf-8')) return sha_hash.hexdigest()
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list call attribute call attribute string string_start string_end identifier argument_list identifier identifier argument_list string string_start string_content string_end return_statement call attribute identifier identifier argument_list
returns an option_collection_hash given a list of options
def check_service(self): try: service = yield Service.get(self.service_id) except couch.NotFound: raise exceptions.ValidationError('Service {} not found' .format(self.service_id)) if service.service_type != 'repository': raise exceptions.ValidationError('{} is not a repository service' .format(self.service_id)) if service.state != State.approved: raise exceptions.ValidationError('{} is not an approved service' .format(self.service_id))
module function_definition identifier parameters identifier block try_statement block expression_statement assignment identifier yield call attribute identifier identifier argument_list attribute identifier identifier except_clause attribute identifier identifier block raise_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block raise_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier if_statement comparison_operator attribute identifier identifier attribute identifier identifier block raise_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier
Check the service exists and is a repository service
def write_py(self): self._check_dir() self._find_executables() lines = [] lines.append(' ') lines.append("from ctypes import *") lines.append("from ftypes import *") lines.append("from numpy.ctypeslib import load_library, ndpointer") lines.append("from numpy import require") lines.append("from os import path") lines.append("") for execkey in self.uses: self._write_executable_py(execkey, lines) from os import path pypath = path.join(self.dirpath, "{}.py".format(self.module.name.lower())) with open(pypath, 'w') as f: f.write('\n'.join(lines))
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_end for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier import_from_statement dotted_name identifier dotted_name identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier call attribute string string_start string_content string_end identifier argument_list call attribute attribute attribute identifier identifier identifier identifier argument_list with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier
Writes a python module file to the current working directory for the library.
def _parse_sigmak(line, lines): split_line = line.split() energy = float(split_line[0]) re_sigma_xx = float(split_line[1]) im_sigma_xx = float(split_line[2]) re_sigma_zz = float(split_line[3]) im_sigma_zz = float(split_line[4]) return {"energy": energy, "re_sigma_xx": re_sigma_xx, "im_sigma_xx": im_sigma_xx, "re_sigma_zz": re_sigma_zz, "im_sigma_zz": im_sigma_zz}
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list subscript identifier integer expression_statement assignment identifier call identifier argument_list subscript identifier integer expression_statement assignment identifier call identifier argument_list subscript identifier integer expression_statement assignment identifier call identifier argument_list subscript identifier integer expression_statement assignment identifier call identifier argument_list subscript identifier integer 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 identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier
Parse Energy, Re sigma xx, Im sigma xx, Re sigma zz, Im sigma zz
def vt_hash_check(fhash, vt_api): if not is_hash(fhash): return None url = 'https://www.virustotal.com/vtapi/v2/file/report' parameters = {'resource': fhash, 'apikey': vt_api} response = requests.get(url, params=parameters) try: return response.json() except ValueError: return None
module function_definition identifier parameters identifier identifier block if_statement not_operator call identifier argument_list identifier block return_statement none expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier try_statement block return_statement call attribute identifier identifier argument_list except_clause identifier block return_statement none
Checks VirusTotal for occurrences of a file hash
def rank(self, value): i = 0 n = len(self._tree) rank = 0 count = 0 while i < n: cur = self._tree[i] if value < cur: i = 2 * i + 1 continue elif value > cur: rank += self._counts[i] nexti = 2 * i + 2 if nexti < n: rank -= self._counts[nexti] i = nexti continue else: return (rank, count) else: count = self._counts[i] lefti = 2 * i + 1 if lefti < n: nleft = self._counts[lefti] count -= nleft rank += nleft righti = lefti + 1 if righti < n: count -= self._counts[righti] return (rank, count) return (rank, count)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier integer expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier integer expression_statement assignment identifier integer while_statement comparison_operator identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier identifier if_statement comparison_operator identifier identifier block expression_statement assignment identifier binary_operator binary_operator integer identifier integer continue_statement elif_clause comparison_operator identifier identifier block expression_statement augmented_assignment identifier subscript attribute identifier identifier identifier expression_statement assignment identifier binary_operator binary_operator integer identifier integer if_statement comparison_operator identifier identifier block expression_statement augmented_assignment identifier subscript attribute identifier identifier identifier expression_statement assignment identifier identifier continue_statement else_clause block return_statement tuple identifier identifier else_clause block expression_statement assignment identifier subscript attribute identifier identifier identifier expression_statement assignment identifier binary_operator binary_operator integer identifier integer if_statement comparison_operator identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier identifier expression_statement augmented_assignment identifier identifier expression_statement augmented_assignment identifier identifier expression_statement assignment identifier binary_operator identifier integer if_statement comparison_operator identifier identifier block expression_statement augmented_assignment identifier subscript attribute identifier identifier identifier return_statement tuple identifier identifier return_statement tuple identifier identifier
Returns the rank and count of the value in the btree.
def fmt_repr(obj): items = {k: v for k, v in list(obj.__dict__.items())} return "<%s: {%s}>" % (obj.__class__.__name__, pprint.pformat(items, width=1))
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary_comprehension pair identifier identifier for_in_clause pattern_list identifier identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list return_statement binary_operator string string_start string_content string_end tuple attribute attribute identifier identifier identifier call attribute identifier identifier argument_list identifier keyword_argument identifier integer
Return pretty printed string representation of an object.
def _strftime(pattern, time_struct=time.localtime()): try: return time.strftime(pattern, time_struct) except OSError: dt = datetime.datetime.fromtimestamp(_mktime(time_struct)) original = dt.year current = datetime.datetime.now().year dt = dt.replace(year=current) ts = dt.timestamp() if _isdst(dt): ts -= 3600 string = time.strftime(pattern, time.localtime(ts)) string = string.replace(str(current), str(original)) return string
module function_definition identifier parameters identifier default_parameter identifier call attribute identifier identifier argument_list block try_statement block return_statement call attribute identifier identifier argument_list identifier identifier except_clause identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call identifier argument_list identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list if_statement call identifier argument_list identifier block expression_statement augmented_assignment identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list identifier call identifier argument_list identifier return_statement identifier
Custom strftime because Windows is shit again.
def put(self, url, data=None): self.conn.request("PUT", url, data) return self._process_response()
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier identifier return_statement call attribute identifier identifier argument_list
Send a HTTP PUT request to a URL and return the result.
def base_args(parser): generic_args(parser) parser.add_argument('--monochrome', dest='monochrome', help='Whether or not to use colors', action='store_true') parser.add_argument('--metadata', dest='metadata', help='A series of key=value pairs for token metadata.', default='') parser.add_argument('--lease', dest='lease', help='Lease time for intermediary token.', default='10s') parser.add_argument('--reuse-token', dest='reuse_token', help='Whether to reuse the existing token. Note' ' this will cause metadata to not be preserved', action='store_true')
module function_definition identifier parameters identifier block expression_statement call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list 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 string_content string_end expression_statement call attribute identifier identifier argument_list 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 string_end expression_statement call attribute identifier identifier argument_list 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 string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier concatenated_string string string_start string_content string_end string string_start string_content string_end keyword_argument identifier string string_start string_content string_end
Add the generic command line options
def generate_take(out_f, steps, line_prefix): out_f.write( '{0}constexpr inline int take(int n_)\n' '{0}{{\n' '{0} return {1} 0 {2};\n' '{0}}}\n' '\n'.format( line_prefix, ''.join('n_ >= {0} ? {0} : ('.format(s) for s in steps), ')' * len(steps) ) )
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute concatenated_string string string_start string_content escape_sequence string_end string string_start string_content escape_sequence string_end string string_start string_content escape_sequence string_end string string_start string_content escape_sequence string_end string string_start string_content escape_sequence string_end identifier argument_list identifier call attribute string string_start string_end identifier generator_expression call attribute string string_start string_content string_end identifier argument_list identifier for_in_clause identifier identifier binary_operator string string_start string_content string_end call identifier argument_list identifier
Generate the take function
def new_client_stream(self, sock): assert sock newsocket, fromaddr = sock.accept() logger.debug("New connection from" " %s:%s", fromaddr[0], fromaddr[1]) try: ssl_socket = ssl.wrap_socket(newsocket, cert_reqs=ssl.CERT_REQUIRED, server_side=True, certfile=self.certs['cert_file'], keyfile=self.certs['key_file'], ca_certs=self.certs['ca_file'], ssl_version=ssl.PROTOCOL_SSLv23) except (ssl.SSLError, socket.error) as message: logger.error(message) return None return ssl_socket
module function_definition identifier parameters identifier identifier block assert_statement identifier expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end subscript identifier integer subscript identifier integer try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier true keyword_argument identifier subscript attribute identifier identifier string string_start string_content string_end keyword_argument identifier subscript attribute identifier identifier string string_start string_content string_end keyword_argument identifier subscript attribute identifier identifier string string_start string_content string_end keyword_argument identifier attribute identifier identifier except_clause as_pattern tuple attribute identifier identifier attribute identifier identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement none return_statement identifier
Returns a new ssl client stream from bind_socket.
def generate_pingback_content(soup, target, max_length, trunc_char='...'): link = soup.find('a', href=target) content = strip_tags(six.text_type(link.findParent())) index = content.index(link.string) if len(content) > max_length: middle = max_length // 2 start = index - middle end = index + middle if start <= 0: end -= start extract = content[0:end] else: extract = '%s%s' % (trunc_char, content[start:end]) if end < len(content): extract += trunc_char return extract return content
module function_definition identifier parameters identifier identifier identifier default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier if_statement comparison_operator call identifier argument_list identifier identifier block expression_statement assignment identifier binary_operator identifier integer expression_statement assignment identifier binary_operator identifier identifier expression_statement assignment identifier binary_operator identifier identifier if_statement comparison_operator identifier integer block expression_statement augmented_assignment identifier identifier expression_statement assignment identifier subscript identifier slice integer identifier else_clause block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple identifier subscript identifier slice identifier identifier if_statement comparison_operator identifier call identifier argument_list identifier block expression_statement augmented_assignment identifier identifier return_statement identifier return_statement identifier
Generate a description text for the pingback.
def _setup_hypercube(cube, slvr_cfg): mbu.register_default_dimensions(cube, slvr_cfg) cube.register_dimension('beam_lw', 2, description='E Beam cube l width') cube.register_dimension('beam_mh', 2, description='E Beam cube m height') cube.register_dimension('beam_nud', 2, description='E Beam cube nu depth') from montblanc.impl.rime.tensorflow.config import (A, P) def _massage_dtypes(A, T): def _massage_dtype_in_dict(D): new_dict = D.copy() new_dict['dtype'] = mbu.dtype_from_str(D['dtype'], T) return new_dict return [_massage_dtype_in_dict(D) for D in A] dtype = slvr_cfg['dtype'] is_f32 = dtype == 'float' T = { 'ft' : np.float32 if is_f32 else np.float64, 'ct' : np.complex64 if is_f32 else np.complex128, 'int' : int, } cube.register_properties(_massage_dtypes(P, T)) cube.register_arrays(_massage_dtypes(A, T))
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end integer keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end integer keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end integer keyword_argument identifier string string_start string_content string_end import_from_statement dotted_name identifier identifier identifier identifier identifier dotted_name identifier dotted_name identifier function_definition identifier parameters identifier identifier block function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end identifier return_statement identifier return_statement list_comprehension call identifier argument_list identifier for_in_clause identifier identifier expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier comparison_operator identifier string string_start string_content string_end expression_statement assignment identifier dictionary pair string string_start string_content string_end conditional_expression attribute identifier identifier identifier attribute identifier identifier pair string string_start string_content string_end conditional_expression attribute identifier identifier identifier attribute identifier identifier pair string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier identifier
Sets up the hypercube given a solver configuration
def plot_epsilon_residuals(self): fig = plt.figure() ax = fig.add_subplot(111) ax.scatter(range(self.epsilon.size), self.epsilon, c='k', marker='*') ax.axhline(y=0.0) plt.show()
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list integer expression_statement call attribute identifier identifier argument_list call identifier argument_list attribute attribute identifier identifier identifier attribute identifier identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list keyword_argument identifier float expression_statement call attribute identifier identifier argument_list
Plots the epsilon residuals for the variogram fit.
def getEventTypeNameFromEnum(self, eType): fn = self.function_table.getEventTypeNameFromEnum result = fn(eType) return result
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier return_statement identifier
returns the name of an EVREvent enum value
async def wait_until_serving(self) -> None: await asyncio.gather( self._receiving_loop_running.wait(), self._internal_loop_running.wait(), loop=self.event_loop )
module function_definition identifier parameters identifier type none block expression_statement await call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier
Await until the ``Endpoint`` is ready to receive events.
def main(): test_targets = ( [ARCH_I386, MACH_I386_I386_INTEL_SYNTAX, ENDIAN_MONO, "\x55\x89\xe5\xE8\xB8\xFF\xFF\xFF", 0x1000], [ARCH_I386, MACH_X86_64_INTEL_SYNTAX, ENDIAN_MONO, "\x55\x48\x89\xe5\xE8\xA3\xFF\xFF\xFF", 0x1000], [ARCH_ARM, MACH_ARM_2, ENDIAN_LITTLE, "\x04\xe0\x2d\xe5\xED\xFF\xFF\xEB", 0x1000], [ARCH_MIPS, MACH_MIPSISA32, ENDIAN_BIG, "\x0C\x10\x00\x97\x00\x00\x00\x00", 0x1000], [ARCH_POWERPC, MACH_PPC, ENDIAN_BIG, "\x94\x21\xFF\xE8\x7C\x08\x02\xA6", 0x1000], ) for target_arch, target_mach, target_endian, binary, address in test_targets: opcodes = Opcodes(target_arch, target_mach, target_endian) print "\n[+] Architecture %s - Machine %d" % \ (opcodes.architecture_name, opcodes.machine) print "[+] Disassembly:" for vma, size, disasm in opcodes.disassemble(binary, address): print "0x%X (size=%d)\t %s" % (vma, size, disasm)
module function_definition identifier parameters block expression_statement assignment identifier tuple list identifier identifier identifier string string_start string_content escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence string_end integer list identifier identifier identifier string string_start string_content escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence string_end integer list identifier identifier identifier string string_start string_content escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence string_end integer list identifier identifier identifier string string_start string_content escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence string_end integer list identifier identifier identifier string string_start string_content escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence string_end integer for_statement pattern_list identifier identifier identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier identifier print_statement binary_operator string string_start string_content escape_sequence string_end line_continuation tuple attribute identifier identifier attribute identifier identifier print_statement string string_start string_content string_end for_statement pattern_list identifier identifier identifier call attribute identifier identifier argument_list identifier identifier block print_statement binary_operator string string_start string_content escape_sequence string_end tuple identifier identifier identifier
Test case for simple opcode disassembly.
def _trim_dictionary_parameters(self, dict_param): keys = re.findall('(?:[^%]|^)?%\((\w*)\)[a-z]', self.msgid) if not keys and re.findall('(?:[^%]|^)%[a-z]', self.msgid): params = self._copy_param(dict_param) else: params = {} src = {} if isinstance(self.params, dict): src.update(self.params) src.update(dict_param) for key in keys: params[key] = self._copy_param(src[key]) return params
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 attribute identifier identifier if_statement boolean_operator not_operator identifier call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier else_clause block expression_statement assignment identifier dictionary expression_statement assignment identifier dictionary if_statement call identifier argument_list attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier for_statement identifier identifier block expression_statement assignment subscript identifier identifier call attribute identifier identifier argument_list subscript identifier identifier return_statement identifier
Return a dict that only has matching entries in the msgid.
def highlight_keywords(self, event, colored): if self.keyword: highlight = colored.underline(self.keyword) event.message = event.message.replace(self.keyword, highlight) return event
module function_definition identifier parameters identifier identifier identifier block if_statement attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier return_statement identifier
Highlight the keyword in the log statement by drawing an underline
def calculate_width_and_height(url_parts, options): width = options.get('width', 0) has_width = width height = options.get('height', 0) has_height = height flip = options.get('flip', False) flop = options.get('flop', False) if flip: width = width * -1 if flop: height = height * -1 if not has_width and not has_height: if flip: width = "-0" if flop: height = "-0" if width or height: url_parts.append('%sx%s' % (width, height))
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 integer expression_statement assignment identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end integer expression_statement assignment identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end false expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end false if_statement identifier block expression_statement assignment identifier binary_operator identifier unary_operator integer if_statement identifier block expression_statement assignment identifier binary_operator identifier unary_operator integer if_statement boolean_operator not_operator identifier not_operator identifier block if_statement identifier block expression_statement assignment identifier string string_start string_content string_end if_statement identifier block expression_statement assignment identifier string string_start string_content string_end if_statement boolean_operator identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier
Appends width and height information to url
def newNode(name): ret = libxml2mod.xmlNewNode(name) if ret is None:raise treeError('xmlNewNode() failed') return xmlNode(_obj=ret)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block raise_statement call identifier argument_list string string_start string_content string_end return_statement call identifier argument_list keyword_argument identifier identifier
Create a new Node
def save(self, data, dtype_out_time, dtype_out_vert=False, save_files=True, write_to_tar=False): self._update_data_out(data, dtype_out_time) if save_files: self._save_files(data, dtype_out_time) if write_to_tar and self.proj.tar_direc_out: self._write_to_tar(dtype_out_time) logging.info('\t{}'.format(self.path_out[dtype_out_time]))
module function_definition identifier parameters identifier identifier identifier default_parameter identifier false default_parameter identifier true default_parameter identifier false block expression_statement call attribute identifier identifier argument_list identifier identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier identifier if_statement boolean_operator identifier attribute attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list subscript attribute identifier identifier identifier
Save aospy data to data_out attr and to an external file.
def offset(self, offset: int) -> "QuerySet": queryset = self._clone() queryset._offset = offset if self.capabilities.requires_limit and queryset._limit is None: queryset._limit = 1000000 return queryset
module function_definition identifier parameters identifier typed_parameter identifier type identifier type string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier identifier if_statement boolean_operator attribute attribute identifier identifier identifier comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier integer return_statement identifier
Query offset for QuerySet.
def fixUTF8(cls, data): for key in data: if isinstance(data[key], str): data[key] = data[key].encode('utf-8') return data
module function_definition identifier parameters identifier identifier block for_statement identifier identifier block if_statement call identifier argument_list subscript identifier identifier identifier block expression_statement assignment subscript identifier identifier call attribute subscript identifier identifier identifier argument_list string string_start string_content string_end return_statement identifier
Convert all strings to UTF-8
def pastdate(self, prompt, default=None): prompt = prompt if prompt is not None else "Enter a past date" if default is not None: prompt += " [" + default.strftime('%d %m %Y') + "]" prompt += ': ' return self.input(curry(filter_pastdate, default=default), prompt)
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment identifier conditional_expression identifier comparison_operator identifier none string string_start string_content string_end if_statement comparison_operator identifier none block expression_statement augmented_assignment identifier binary_operator binary_operator string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement augmented_assignment identifier string string_start string_content string_end return_statement call attribute identifier identifier argument_list call identifier argument_list identifier keyword_argument identifier identifier identifier
Prompts user to input a date in the past.
def create_user_deliveryserver(self, domainid, data): return self.api_call( ENDPOINTS['userdeliveryservers']['new'], dict(domainid=domainid), body=data)
module function_definition identifier parameters identifier identifier identifier block return_statement call attribute identifier identifier argument_list subscript subscript identifier string string_start string_content string_end string string_start string_content string_end call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier
Create a user delivery server
def inferTM(self, bottomUp, externalInput): self.reset() self.tm.compute(bottomUp, basalInput=externalInput, learn=False) return self.tm.getPredictiveCells()
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier false return_statement call attribute attribute identifier identifier identifier argument_list
Run inference and return the set of predicted cells
def _listen(sockets): while True: (i , o, e) = select.select(sockets.keys(),[],[],1) for socket in i: if isinstance(sockets[socket], Chatroom): data_len = sockets[socket].client.Process(1) if data_len is None or data_len == 0: raise Exception('Disconnected from server') else: raise Exception("Unknown socket type: %s" % repr(sockets[socket]))
module function_definition identifier parameters identifier block while_statement true block expression_statement assignment tuple_pattern identifier identifier identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list list list integer for_statement identifier identifier block if_statement call identifier argument_list subscript identifier identifier identifier block expression_statement assignment identifier call attribute attribute subscript identifier identifier identifier identifier argument_list integer if_statement boolean_operator comparison_operator identifier none comparison_operator identifier integer block raise_statement call identifier argument_list string string_start string_content string_end else_clause block raise_statement call identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list subscript identifier identifier
Main server loop. Listens for incoming events and dispatches them to appropriate chatroom
def _iter_grouped(self): for indices in self._group_indices: yield self._obj.isel(**{self._group_dim: indices})
module function_definition identifier parameters identifier block for_statement identifier attribute identifier identifier block expression_statement yield call attribute attribute identifier identifier identifier argument_list dictionary_splat dictionary pair attribute identifier identifier identifier
Iterate over each element in this group
def _summary_matching_gos(prt, pattern, matching_gos, all_gos): msg = 'Found {N} GO(s) out of {M} matching pattern("{P}")\n' num_gos = len(matching_gos) num_all = len(all_gos) prt.write(msg.format(N=num_gos, M=num_all, P=pattern))
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier string string_start string_content escape_sequence string_end expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
Print summary for get_matching_gos.
def create_file(self, path, content, mode='w', user='root'): self.enable_user(user) return self.ssh_pool.create_file(user, path, content, mode)
module function_definition identifier parameters identifier identifier identifier default_parameter identifier string string_start string_content string_end default_parameter identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list identifier return_statement call attribute attribute identifier identifier identifier argument_list identifier identifier identifier identifier
Create a file on the remote host.
def cache_model(key_params, timeout='default'): def decorator_fn(fn): return CacheModelDecorator().decorate(key_params, timeout, fn) return decorator_fn
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end block function_definition identifier parameters identifier block return_statement call attribute call identifier argument_list identifier argument_list identifier identifier identifier return_statement identifier
Caching decorator for app models in task.perform
def guess_file_encoding(fh, default=DEFAULT_ENCODING): start = fh.tell() detector = chardet.UniversalDetector() while True: data = fh.read(1024 * 10) if not data: detector.close() break detector.feed(data) if detector.done: break fh.seek(start) return normalize_result(detector.result, default=default)
module function_definition identifier parameters identifier default_parameter identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list while_statement true block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator integer integer if_statement not_operator identifier block expression_statement call attribute identifier identifier argument_list break_statement expression_statement call attribute identifier identifier argument_list identifier if_statement attribute identifier identifier block break_statement expression_statement call attribute identifier identifier argument_list identifier return_statement call identifier argument_list attribute identifier identifier keyword_argument identifier identifier
Guess encoding from a file handle.
def layer_norm_compute(x, epsilon, scale, bias, layer_collection=None): params = (scale, bias) epsilon, scale, bias = [cast_like(t, x) for t in [epsilon, scale, bias]] mean = tf.reduce_mean(x, axis=[-1], keepdims=True) variance = tf.reduce_mean( tf.squared_difference(x, mean), axis=[-1], keepdims=True) norm_x = (x - mean) * tf.rsqrt(variance + epsilon) output = norm_x * scale + bias return output
module function_definition identifier parameters identifier identifier identifier identifier default_parameter identifier none block expression_statement assignment identifier tuple identifier identifier expression_statement assignment pattern_list identifier identifier identifier list_comprehension call identifier argument_list identifier identifier for_in_clause identifier list identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier list unary_operator integer keyword_argument identifier true expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier identifier keyword_argument identifier list unary_operator integer keyword_argument identifier true expression_statement assignment identifier binary_operator parenthesized_expression binary_operator identifier identifier call attribute identifier identifier argument_list binary_operator identifier identifier expression_statement assignment identifier binary_operator binary_operator identifier identifier identifier return_statement identifier
Layer norm raw computation.
def clone(self, newname, config_path=None, flags=0, bdevtype=None, bdevdata=None, newsize=0, hookargs=()): args = {} args['newname'] = newname args['flags'] = flags args['newsize'] = newsize args['hookargs'] = hookargs if config_path: args['config_path'] = config_path if bdevtype: args['bdevtype'] = bdevtype if bdevdata: args['bdevdata'] = bdevdata if _lxc.Container.clone(self, **args): return Container(newname, config_path=config_path) else: return False
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier integer default_parameter identifier none default_parameter identifier none default_parameter identifier integer default_parameter identifier tuple block expression_statement assignment identifier dictionary expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier if_statement identifier block expression_statement assignment subscript identifier string string_start string_content string_end identifier if_statement identifier block expression_statement assignment subscript identifier string string_start string_content string_end identifier if_statement identifier block expression_statement assignment subscript identifier string string_start string_content string_end identifier if_statement call attribute attribute identifier identifier identifier argument_list identifier dictionary_splat identifier block return_statement call identifier argument_list identifier keyword_argument identifier identifier else_clause block return_statement false
Clone the current container.
def to_dict(self): return { 'id': self.id, 'type': str(self.type.ver_type), 'controller': canon_ref(self.did, self.controller), **self.type.specification(self.value) }
module function_definition identifier parameters identifier block return_statement dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end call identifier argument_list attribute attribute identifier identifier identifier pair string string_start string_content string_end call identifier argument_list attribute identifier identifier attribute identifier identifier dictionary_splat call attribute attribute identifier identifier identifier argument_list attribute identifier identifier
Return dict representation of public key to embed in DID document.
def add_xref(self, id, xref): if self.xref_graph is None: self.xref_graph = nx.MultiGraph() self.xref_graph.add_edge(xref, id)
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier
Adds an xref to the xref graph
def cli(env, billing_id, datacenter): mgr = SoftLayer.LoadBalancerManager(env.client) if not formatting.confirm("This action will incur charges on your " "account. Continue?"): raise exceptions.CLIAbort('Aborted.') mgr.add_local_lb(billing_id, datacenter=datacenter) env.fout("Load balancer is being created!")
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier if_statement not_operator call attribute identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end block raise_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end
Adds a load balancer given the id returned from create-options.
def serialize_artifact_json_blobs(artifacts): for artifact in artifacts: blob = artifact['blob'] if (artifact['type'].lower() == 'json' and not isinstance(blob, str)): artifact['blob'] = json.dumps(blob) return artifacts
module function_definition identifier parameters identifier block for_statement identifier identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end if_statement parenthesized_expression boolean_operator comparison_operator call attribute subscript identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end not_operator call identifier argument_list identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list identifier return_statement identifier
Ensure that JSON artifact blobs passed as dicts are converted to JSON
def connect(self): if not getattr(self._local, 'conn', None): try: server = self._servers.get() logger.debug('Connecting to %s', server) self._local.conn = ClientTransport(server, self._framed_transport, self._timeout, self._recycle) except (Thrift.TException, socket.timeout, socket.error): logger.warning('Connection to %s failed.', server) self._servers.mark_dead(server) return self.connect() return self._local.conn
module function_definition identifier parameters identifier block if_statement not_operator call identifier argument_list attribute identifier identifier string string_start string_content string_end none block try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment attribute attribute identifier identifier identifier call identifier argument_list identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier except_clause tuple attribute identifier identifier attribute identifier identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list return_statement attribute attribute identifier identifier identifier
Create new connection unless we already have one.
def filter(self, datax, datay): f = np.ones(datax.shape, dtype=bool) for i, p in enumerate(zip(datax, datay)): f[i] = PolygonFilter.point_in_poly(p, self.points) if self.inverted: np.invert(f, f) return f
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier identifier for_statement pattern_list identifier identifier call identifier argument_list call identifier argument_list identifier identifier block expression_statement assignment subscript identifier identifier call attribute identifier identifier argument_list identifier attribute identifier identifier if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier return_statement identifier
Filter a set of datax and datay according to `self.points`
def pop_focus(self, cli): if len(self.focus_stack) > 1: self.focus_stack.pop() else: raise IndexError('Cannot pop last item from the focus stack.')
module function_definition identifier parameters identifier identifier block if_statement comparison_operator call identifier argument_list attribute identifier identifier integer block expression_statement call attribute attribute identifier identifier identifier argument_list else_clause block raise_statement call identifier argument_list string string_start string_content string_end
Pop buffer from the focus stack.
def _format_phone_number(self, value, attr): strict_validation = self.get_field_value( 'strict_phone_validation', default=False ) strict_region = self.get_field_value( 'strict_phone_region', default=strict_validation ) region = self.get_field_value('region', 'US') phone_number_format = self.get_field_value( 'phone_number_format', default=phonenumbers.PhoneNumberFormat.INTERNATIONAL ) stripped_value = re.sub(r'[^\w+]', '', value) try: if not stripped_value.startswith('+') and not strict_region: phone = phonenumbers.parse(stripped_value, region) else: phone = phonenumbers.parse(stripped_value) if (not phonenumbers.is_possible_number(phone) or not phonenumbers.is_valid_number(phone) and strict_validation): raise ValidationError( "The value for {} ({}) is not a valid phone " "number.".format(attr, value) ) return phonenumbers.format_number(phone, phone_number_format) except phonenumbers.phonenumberutil.NumberParseException as exc: if strict_validation or strict_region: raise ValidationError(exc)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier false expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end identifier try_statement block if_statement boolean_operator not_operator call attribute identifier identifier argument_list string string_start string_content string_end not_operator identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement parenthesized_expression boolean_operator not_operator call attribute identifier identifier argument_list identifier boolean_operator not_operator call attribute identifier identifier argument_list identifier identifier block raise_statement call identifier argument_list call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list identifier identifier return_statement call attribute identifier identifier argument_list identifier identifier except_clause as_pattern attribute attribute identifier identifier identifier as_pattern_target identifier block if_statement boolean_operator identifier identifier block raise_statement call identifier argument_list identifier
Format and validate a phone number.
def apply_to(self, A): if A.ndim == 1: A = np.expand_dims(A, axis=0) rows, cols = A.shape A_new = np.hstack([A, np.ones((rows, 1))]) A_new = np.transpose(self.T.dot(np.transpose(A_new))) return A_new[:, 0:cols]
module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier integer block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier integer expression_statement assignment pattern_list identifier identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list list identifier call attribute identifier identifier argument_list tuple identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list identifier return_statement subscript identifier slice slice integer identifier
Apply the coordinate transformation to points in A.
def active_repositories(doc): if doc.get('state') != 'deactivated': for repository_id, repo in doc.get('repositories', {}).items(): if repo.get('state') != 'deactivated': repo['id'] = repository_id repo['organisation_id'] = doc['_id'] yield repository_id, repo
module function_definition identifier parameters identifier block if_statement comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end block for_statement pattern_list identifier identifier call attribute call attribute identifier identifier argument_list string string_start string_content string_end dictionary identifier argument_list block if_statement comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end block expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement yield expression_list identifier identifier
View for getting active repositories
def load_symbols_elf(filename): f = open(filename, 'rb') elffile = ELFFile(f) symbols = [] for section in elffile.iter_sections(): if not isinstance(section, SymbolTableSection): continue if section['sh_entsize'] == 0: logger.warn("Symbol table {} has a sh_entsize of zero.".format(section.name)) continue logger.info("Symbol table {} contains {} entries.".format(section.name, section.num_symbols())) for _, symbol in enumerate(section.iter_symbols()): if describe_symbol_shndx(symbol['st_shndx']) != "UND" and \ describe_symbol_type(symbol['st_info']['type']) == "FUNC": symbols.append((symbol['st_value'], symbol['st_size'], symbol.name)) f.close() symbols_by_addr = { addr: (name, size, True) for addr, size, name in symbols } return symbols_by_addr
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier list for_statement identifier call attribute identifier identifier argument_list block if_statement not_operator call identifier argument_list identifier identifier block continue_statement if_statement comparison_operator subscript identifier string string_start string_content string_end integer block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier continue_statement expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier call attribute identifier identifier argument_list for_statement pattern_list identifier identifier call identifier argument_list call attribute identifier identifier argument_list block if_statement boolean_operator comparison_operator call identifier argument_list subscript identifier string string_start string_content string_end string string_start string_content string_end line_continuation comparison_operator call identifier argument_list subscript subscript identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list tuple subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end attribute identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier dictionary_comprehension pair identifier tuple identifier identifier true for_in_clause pattern_list identifier identifier identifier identifier return_statement identifier
Load the symbol tables contained in the file
def getDeviceRole(self): print '%s call getDeviceRole' % self.port return self.__stripValue(self.__sendCommand(WPANCTL_CMD + 'getprop -v Network:NodeType')[0])
module function_definition identifier parameters identifier block print_statement binary_operator string string_start string_content string_end attribute identifier identifier return_statement call attribute identifier identifier argument_list subscript call attribute identifier identifier argument_list binary_operator identifier string string_start string_content string_end integer
get current device role in Thread Network
def validate_nodepool_name(namespace): if namespace.nodepool_name != "": if len(namespace.nodepool_name) > 12: raise CLIError('--nodepool-name can contain atmost 12 characters') if not namespace.nodepool_name.isalnum(): raise CLIError('--nodepool-name should only contain alphanumeric characters')
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier string string_start string_end block if_statement comparison_operator call identifier argument_list attribute identifier identifier integer block raise_statement call identifier argument_list string string_start string_content string_end if_statement not_operator call attribute attribute identifier identifier identifier argument_list block raise_statement call identifier argument_list string string_start string_content string_end
Validates a nodepool name to be at most 12 characters, alphanumeric only.
def retrieve_asset(self, sid, default_none=False): try: asset = self._asset_cache[sid] if asset is None and not default_none: raise SidsNotFound(sids=[sid]) return asset except KeyError: raise SidsNotFound(sids=[sid])
module function_definition identifier parameters identifier identifier default_parameter identifier false block try_statement block expression_statement assignment identifier subscript attribute identifier identifier identifier if_statement boolean_operator comparison_operator identifier none not_operator identifier block raise_statement call identifier argument_list keyword_argument identifier list identifier return_statement identifier except_clause identifier block raise_statement call identifier argument_list keyword_argument identifier list identifier
Retrieve the Asset for a given sid.
def fopenat(base_fd, path): return os.fdopen(openat(base_fd, path, os.O_RDONLY), 'rb')
module function_definition identifier parameters identifier identifier block return_statement call attribute identifier identifier argument_list call identifier argument_list identifier identifier attribute identifier identifier string string_start string_content string_end
Does openat read-only, then does fdopen to get a file object
def delete_view(self, request, object_id, **kwargs): page = get_object_or_404(Page, pk=object_id) content_model = page.get_content_model() self.check_permission(request, content_model, "delete") return super(PageAdmin, self).delete_view(request, object_id, **kwargs)
module function_definition identifier parameters identifier identifier identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier identifier string string_start string_content string_end return_statement call attribute call identifier argument_list identifier identifier identifier argument_list identifier identifier dictionary_splat identifier
Enforce custom delete permissions for the page instance.
def _get_install_config(): try: data_dir = _get_data_dir() except ValueError: return None config_dir = utils.safe_makedir(os.path.join(data_dir, "config")) return os.path.join(config_dir, "install-params.yaml")
module function_definition identifier parameters block try_statement block expression_statement assignment identifier call identifier argument_list except_clause identifier block return_statement none expression_statement assignment identifier call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end return_statement call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end
Return the YAML configuration file used to store upgrade information.
def _norm_default(x): import scipy.linalg if _blas_is_applicable(x.data): nrm2 = scipy.linalg.blas.get_blas_funcs('nrm2', dtype=x.dtype) norm = partial(nrm2, n=native(x.size)) else: norm = np.linalg.norm return norm(x.data.ravel())
module function_definition identifier parameters identifier block import_statement dotted_name identifier identifier if_statement call identifier argument_list attribute identifier identifier block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier call identifier argument_list attribute identifier identifier else_clause block expression_statement assignment identifier attribute attribute identifier identifier identifier return_statement call identifier argument_list call attribute attribute identifier identifier identifier argument_list
Default Euclidean norm implementation.
def _LogProgressUpdateIfReasonable(self): next_log_time = ( self._time_of_last_status_log + self.SECONDS_BETWEEN_STATUS_LOG_MESSAGES) current_time = time.time() if current_time < next_log_time: return completion_time = time.ctime(current_time + self.EstimateTimeRemaining()) log_message = ( '{0:s} hash analysis plugin running. {1:d} hashes in queue, ' 'estimated completion time {2:s}.'.format( self.NAME, self.hash_queue.qsize(), completion_time)) logger.info(log_message) self._time_of_last_status_log = current_time
module function_definition identifier parameters identifier block expression_statement assignment identifier parenthesized_expression binary_operator attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier identifier block return_statement expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator identifier call attribute identifier identifier argument_list expression_statement assignment identifier parenthesized_expression call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list attribute identifier identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier identifier
Prints a progress update if enough time has passed.
def _subprocess(cmd): log.debug('Running: "%s"', ' '.join(cmd)) try: proc = subprocess.Popen(cmd, stdout=subprocess.PIPE) ret = salt.utils.stringutils.to_unicode(proc.communicate()[0]).strip() retcode = proc.wait() if ret: return ret elif retcode != 1: return True else: return False except OSError as err: log.error(err) return False
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list identifier try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier expression_statement assignment identifier call attribute call attribute attribute attribute identifier identifier identifier identifier argument_list subscript call attribute identifier identifier argument_list integer identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list if_statement identifier block return_statement identifier elif_clause comparison_operator identifier integer block return_statement true else_clause block return_statement false except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement false
Function to standardize the subprocess call
def widget_from_single_value(o): if isinstance(o, string_types): return Text(value=unicode_type(o)) elif isinstance(o, bool): return Checkbox(value=o) elif isinstance(o, Integral): min, max, value = _get_min_max_value(None, None, o) return IntSlider(value=o, min=min, max=max) elif isinstance(o, Real): min, max, value = _get_min_max_value(None, None, o) return FloatSlider(value=o, min=min, max=max) else: return None
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier identifier block return_statement call identifier argument_list keyword_argument identifier call identifier argument_list identifier elif_clause call identifier argument_list identifier identifier block return_statement call identifier argument_list keyword_argument identifier identifier elif_clause call identifier argument_list identifier identifier block expression_statement assignment pattern_list identifier identifier identifier call identifier argument_list none none identifier return_statement call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier elif_clause call identifier argument_list identifier identifier block expression_statement assignment pattern_list identifier identifier identifier call identifier argument_list none none identifier return_statement call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier else_clause block return_statement none
Make widgets from single values, which can be used as parameter defaults.
def _encode_string(string): if not isinstance(string, bytes): string = string.encode('utf8') return ffi.new('char[]', string)
module function_definition identifier parameters identifier block if_statement not_operator call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end return_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier
Return a byte string, encoding Unicode with UTF-8.
def list_probes(): curdir = op.realpath(op.dirname(__file__)) return [op.splitext(fn)[0] for fn in os.listdir(op.join(curdir, 'probes')) if fn.endswith('.prb')]
module function_definition identifier parameters block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier return_statement list_comprehension subscript call attribute identifier identifier argument_list identifier integer for_in_clause identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier string string_start string_content string_end if_clause call attribute identifier identifier argument_list string string_start string_content string_end
Return the list of built-in probes.
def color(self): return self.tty_stream if self.options.color is None \ else self.options.color
module function_definition identifier parameters identifier block return_statement conditional_expression attribute identifier identifier comparison_operator attribute attribute identifier identifier identifier none line_continuation attribute attribute identifier identifier identifier
Whether or not color should be output
def setup_scrollarea(self): self.view = QWidget() self.scene = QGridLayout(self.view) self.scene.setColumnStretch(0, 100) self.scene.setColumnStretch(2, 100) self.scrollarea = QScrollArea() self.scrollarea.setWidget(self.view) self.scrollarea.setWidgetResizable(True) self.scrollarea.setFrameStyle(0) self.scrollarea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.scrollarea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.scrollarea.setSizePolicy(QSizePolicy(QSizePolicy.Ignored, QSizePolicy.Preferred)) self.scrollarea.setVerticalScrollBar(QScrollBar()) return self.scrollarea
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier call identifier argument_list expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list integer integer expression_statement call attribute attribute identifier identifier identifier argument_list integer integer expression_statement assignment attribute identifier identifier call identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list true expression_statement call attribute attribute identifier identifier identifier argument_list integer expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list return_statement attribute identifier identifier
Setup the scrollarea that will contain the FigureThumbnails.
def lenient_add_filter(self, *args, **kwargs): if args and args[0] != "raiseonerror": self.original_add_filter(*args, **kwargs)
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block if_statement boolean_operator identifier comparison_operator subscript identifier integer string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list list_splat identifier dictionary_splat identifier
Disables the raiseonerror filter.
def _unset_required(self): self._required_args = [act for act in self._actions if act.required] for act in self._required_args: act.required = False
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier list_comprehension identifier for_in_clause identifier attribute identifier identifier if_clause attribute identifier identifier for_statement identifier attribute identifier identifier block expression_statement assignment attribute identifier identifier false
Convenience function to turn off required arguments for first parse.
def unblock_events(self): BaseObject.unblock_events(self) for i in range(self._widget.topLevelItemCount()): self._widget.topLevelItem(i).param.blockSignals(False) return self
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list identifier for_statement identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute attribute call attribute attribute identifier identifier identifier argument_list identifier identifier identifier argument_list false return_statement identifier
Special version of unblock_events that loops over all tree elements as well.
def iteryaml(self, *args, **kwargs): from rowgenerators.rowpipe.json import VTEncoder import yaml if 'cls' not in kwargs: kwargs['cls'] = VTEncoder for s in self.iterstruct: yield (yaml.safe_dump(s))
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block import_from_statement dotted_name identifier identifier identifier dotted_name identifier import_statement dotted_name identifier if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end identifier for_statement identifier attribute identifier identifier block expression_statement yield parenthesized_expression call attribute identifier identifier argument_list identifier
Yields the data structures from iterstruct as YAML strings
def load_fw(path): fname = os.path.realpath(path) exists = os.path.isfile(fname) if not exists or not os.access(fname, os.R_OK): _LOGGER.error( 'Firmware path %s does not exist or is not readable', path) return None try: intel_hex = IntelHex() with open(path, 'r') as file_handle: intel_hex.fromfile(file_handle, format='hex') return intel_hex.tobinstr() except (IntelHexError, TypeError, ValueError) as exc: _LOGGER.error( 'Firmware not valid, check the hex file at %s: %s', path, exc) return None
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 attribute identifier identifier identifier argument_list identifier if_statement boolean_operator not_operator identifier not_operator call attribute identifier identifier argument_list identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement none try_statement block expression_statement assignment identifier call identifier argument_list with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end return_statement call attribute identifier identifier argument_list except_clause as_pattern tuple identifier 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 none
Open firmware file and return a binary string.
def reset(cls, *args, **kwargs): cls.local.tchannel = None cls.args = None cls.kwargs = None cls.prepared = False
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment attribute attribute identifier identifier identifier none expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier false
Undo call to prepare, useful for testing.
def buy(ctx, buy_amount, buy_asset, price, sell_asset, order_expiration, account): amount = Amount(buy_amount, buy_asset) price = Price( price, base=sell_asset, quote=buy_asset, bitshares_instance=ctx.bitshares ) print_tx( price.market.buy(price, amount, account=account, expiration=order_expiration) )
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier expression_statement call identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
Buy a specific asset at a certain rate against a base asset
def maybe_encode(value): if isinstance(value, (list, tuple)) and isinstance(value[0], str): return encode(value) return value
module function_definition identifier parameters identifier block if_statement boolean_operator call identifier argument_list identifier tuple identifier identifier call identifier argument_list subscript identifier integer identifier block return_statement call identifier argument_list identifier return_statement identifier
If value is a sequence of strings, encode it
def vboxsf_to_windows(filename, letter='f:'): home = os.path.expanduser('~') filename = os.path.abspath(filename).replace(home, letter) return filename.replace('/', '\\')
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list identifier identifier argument_list identifier identifier return_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content escape_sequence string_end
Convert the Linux path name to a Windows one.
def device_state(device_id): if device_id not in devices: return jsonify(success=False) return jsonify(state=devices[device_id].state)
module function_definition identifier parameters identifier block if_statement comparison_operator identifier identifier block return_statement call identifier argument_list keyword_argument identifier false return_statement call identifier argument_list keyword_argument identifier attribute subscript identifier identifier identifier
Get device state via HTTP GET.
def _create_subnet(self, resource_group_name, subnet_id, vnet_name): subnet_config = {'address_prefix': '10.0.0.0/29'} try: subnet_setup = self.network.subnets.create_or_update( resource_group_name, vnet_name, subnet_id, subnet_config ) except Exception as error: raise AzureCloudException( 'Unable to create subnet: {0}.'.format(error) ) return subnet_setup.result()
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end try_statement block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list identifier identifier identifier identifier except_clause as_pattern identifier as_pattern_target identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier return_statement call attribute identifier identifier argument_list
Create a subnet in the provided vnet and resource group.
def disable_scanners_by_group(self, group): if group == 'all': self.logger.debug('Disabling all scanners') return self.zap.ascan.disable_all_scanners() try: scanner_list = self.scanner_group_map[group] except KeyError: raise ZAPError( 'Invalid group "{0}" provided. Valid groups are: {1}'.format( group, ', '.join(self.scanner_groups) ) ) self.logger.debug('Disabling scanner group {0}'.format(group)) return self.disable_scanners_by_ids(scanner_list)
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier string string_start string_content string_end block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end return_statement call attribute attribute attribute identifier identifier identifier identifier argument_list try_statement block expression_statement assignment identifier subscript attribute identifier identifier identifier except_clause identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier return_statement call attribute identifier identifier argument_list identifier
Disables the scanners in the group if it matches one in the scanner_group_map.
def _highest_degree_variable_chooser(problem, variables, domains): return sorted(variables, key=lambda v: problem.var_degrees[v], reverse=True)[0]
module function_definition identifier parameters identifier identifier identifier block return_statement subscript call identifier argument_list identifier keyword_argument identifier lambda lambda_parameters identifier subscript attribute identifier identifier identifier keyword_argument identifier true integer
Choose the variable that is involved on more constraints.
def __get_wbfmt_usrfld(self, data_nt): if self.ntfld_wbfmt is not None: if isinstance(self.ntfld_wbfmt, str): ntval = getattr(data_nt, self.ntfld_wbfmt, None) if ntval is not None: return self.fmtname2wbfmtobj.get(ntval, None)
module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier none block if_statement call identifier argument_list attribute identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier attribute identifier identifier none if_statement comparison_operator identifier none block return_statement call attribute attribute identifier identifier identifier argument_list identifier none
Return format for text cell from namedtuple field specified by 'ntfld_wbfmt
def render( self, tag, single, between, kwargs ): out = "<%s" % tag for key, value in list( kwargs.items( ) ): if value is not None: key = key.strip('_') if key == 'http_equiv': key = 'http-equiv' elif key == 'accept_charset': key = 'accept-charset' out = "%s %s=\"%s\"" % ( out, key, escape( value ) ) else: out = "%s %s" % ( out, key ) if between is not None: out = "%s>%s</%s>" % ( out, between, tag ) else: if single: out = "%s />" % out else: out = "%s>" % out if self.parent is not None: self.parent.content.append( out ) else: return out
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end identifier for_statement pattern_list identifier identifier call identifier argument_list call attribute identifier identifier argument_list block if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier string string_start string_content string_end elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier binary_operator string string_start string_content escape_sequence escape_sequence string_end tuple identifier identifier call identifier argument_list identifier else_clause block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple identifier identifier identifier else_clause block if_statement identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end identifier else_clause block expression_statement assignment identifier binary_operator string string_start string_content string_end identifier if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier else_clause block return_statement identifier
Append the actual tags to content.
def storage_get(self, key): if not self._module: return self._storage_init() module_name = self._module.module_full_name return self._storage.storage_get(module_name, key)
module function_definition identifier parameters identifier identifier block if_statement not_operator attribute identifier identifier block return_statement expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier attribute attribute identifier identifier identifier return_statement call attribute attribute identifier identifier identifier argument_list identifier identifier
Retrieve a value for the module.
def extract_attribute(module_name, attribute_name): with open('%s/__init__.py' % module_name) as input_file: for line in input_file: if line.startswith(attribute_name): return ast.literal_eval(line.split('=')[1].strip())
module function_definition identifier parameters identifier identifier block with_statement with_clause with_item as_pattern call identifier argument_list binary_operator string string_start string_content string_end identifier as_pattern_target identifier block for_statement identifier identifier block if_statement call attribute identifier identifier argument_list identifier block return_statement call attribute identifier identifier argument_list call attribute subscript call attribute identifier identifier argument_list string string_start string_content string_end integer identifier argument_list
Extract metatdata property from a module
def replace(self, src): "Given some source html substitute and annotated as applicable" for html in self.substitutions.keys(): if src == html: annotation = self.annotation % self.substitutions[src][1] return annotation + self.substitutions[src][0] return src
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end for_statement identifier call attribute attribute identifier identifier identifier argument_list block if_statement comparison_operator identifier identifier block expression_statement assignment identifier binary_operator attribute identifier identifier subscript subscript attribute identifier identifier identifier integer return_statement binary_operator identifier subscript subscript attribute identifier identifier identifier integer return_statement identifier
Given some source html substitute and annotated as applicable
def do_version(): v = ApiPool.ping.model.Version( name=ApiPool().current_server_name, version=ApiPool().current_server_api.get_version(), container=get_container_version(), ) log.info("/version: " + pprint.pformat(v)) return v
module function_definition identifier parameters block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list keyword_argument identifier attribute call identifier argument_list identifier keyword_argument identifier call attribute attribute call identifier argument_list identifier identifier argument_list keyword_argument identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end call attribute identifier identifier argument_list identifier return_statement identifier
Return version details of the running server api
def vclose(L, V): lam, X = 0, [] for k in range(3): lam = lam + V[k] * L[k] beta = np.sqrt(1. - lam**2) for k in range(3): X.append((old_div((V[k] - lam * L[k]), beta))) return X
module function_definition identifier parameters identifier identifier block expression_statement assignment pattern_list identifier identifier expression_list integer list for_statement identifier call identifier argument_list integer block expression_statement assignment identifier binary_operator identifier binary_operator subscript identifier identifier subscript identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator float binary_operator identifier integer for_statement identifier call identifier argument_list integer block expression_statement call attribute identifier identifier argument_list parenthesized_expression call identifier argument_list parenthesized_expression binary_operator subscript identifier identifier binary_operator identifier subscript identifier identifier identifier return_statement identifier
gets the closest vector
def startReceivingBoxes(self, sender): AMP.startReceivingBoxes(self, sender) log.addObserver(self._emit)
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier
Start observing log events for stat events to send.