code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def from_timestamp( timestamp, tz=UTC ): dt = _datetime.datetime.utcfromtimestamp(timestamp) dt = datetime( dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second, dt.microsecond ) if tz is not UTC or tz != "UTC": dt = dt.in_timezone(tz) return dt
module function_definition identifier parameters identifier default_parameter identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier if_statement boolean_operator comparison_operator identifier identifier comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement identifier
Create a DateTime instance from a timestamp.
def _GetSubFlowNetworkLimit(self): subflow_network_limit = None if self.runner_args.per_client_network_limit_bytes: subflow_network_limit = self.runner_args.per_client_network_limit_bytes if self.runner_args.network_bytes_limit: remaining_network_quota = ( self.runner_args.network_bytes_limit - self.context.network_bytes_sent) if subflow_network_limit is None: subflow_network_limit = remaining_network_quota else: subflow_network_limit = min(subflow_network_limit, remaining_network_quota) return subflow_network_limit
module function_definition identifier parameters identifier block expression_statement assignment identifier none if_statement attribute attribute identifier identifier identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier if_statement attribute attribute identifier identifier identifier block expression_statement assignment identifier parenthesized_expression binary_operator attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier identifier else_clause block expression_statement assignment identifier call identifier argument_list identifier identifier return_statement identifier
Get current network limit for subflows.
def run(options, http_req_handler = HttpReqHandler): global _HTTP_SERVER for x in ('server_version', 'sys_version'): if _OPTIONS.get(x) is not None: setattr(http_req_handler, x, _OPTIONS[x]) _HTTP_SERVER = threading_tcp_server.KillableThreadingHTTPServer( _OPTIONS, (_OPTIONS['listen_addr'], _OPTIONS['listen_port']), http_req_handler, name = "httpdis") for name, cmd in _COMMANDS.iteritems(): if cmd.at_start: LOG.info("at_start: %r", name) cmd.at_start(options) LOG.info("will now serve") while not _KILLED: try: _HTTP_SERVER.serve_until_killed() except (socket.error, select.error), why: if errno.EINTR == why[0]: LOG.debug("interrupted system call") elif errno.EBADF == why[0] and _KILLED: LOG.debug("server close") else: raise LOG.info("exiting")
module function_definition identifier parameters identifier default_parameter identifier identifier block global_statement identifier for_statement identifier tuple string string_start string_content string_end string string_start string_content string_end block if_statement comparison_operator call attribute identifier identifier argument_list identifier none block expression_statement call identifier argument_list identifier identifier subscript identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier tuple subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end identifier keyword_argument identifier string string_start string_content string_end for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end while_statement not_operator identifier block try_statement block expression_statement call attribute identifier identifier argument_list except_clause tuple attribute identifier identifier attribute identifier identifier identifier block if_statement comparison_operator attribute identifier identifier subscript identifier integer block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end elif_clause boolean_operator comparison_operator attribute identifier identifier subscript identifier integer identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end else_clause block raise_statement expression_statement call attribute identifier identifier argument_list string string_start string_content string_end
Start and execute the server
def _unmarshall_reader(self, file_, d): return util.unmarshall_config_reader(file_, d, self._get_config_type())
module function_definition identifier parameters identifier identifier identifier block return_statement call attribute identifier identifier argument_list identifier identifier call attribute identifier identifier argument_list
Unmarshall a file into a `dict`.
def _to_spans(x): if isinstance(x, Candidate): return [_to_span(m) for m in x] elif isinstance(x, Mention): return [x.context] elif isinstance(x, TemporarySpanMention): return [x] else: raise ValueError(f"{type(x)} is an invalid argument type")
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier identifier block return_statement list_comprehension call identifier argument_list identifier for_in_clause identifier identifier elif_clause call identifier argument_list identifier identifier block return_statement list attribute identifier identifier elif_clause call identifier argument_list identifier identifier block return_statement list identifier else_clause block raise_statement call identifier argument_list string string_start interpolation call identifier argument_list identifier string_content string_end
Convert a Candidate, Mention, or Span to a list of spans.
def expected_param_keys(self): expected_keys = [] r = re.compile('%\(([^\)]+)\)s') for block in self.keys(): for key in self[block].keys(): s = self[block][key] if type(s)!=str: continue md = re.search(r, s) while md is not None: k = md.group(1) if k not in expected_keys: expected_keys.append(k) s = s[md.span()[1]:] md = re.search(r, s) return expected_keys
module function_definition identifier parameters identifier block expression_statement assignment identifier list expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end for_statement identifier call attribute identifier identifier argument_list block for_statement identifier call attribute subscript identifier identifier identifier argument_list block expression_statement assignment identifier subscript subscript identifier identifier identifier if_statement comparison_operator call identifier argument_list identifier identifier block continue_statement expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier while_statement comparison_operator identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list integer if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier subscript identifier slice subscript call attribute identifier identifier argument_list integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier return_statement identifier
returns a list of params that this ConfigTemplate expects to receive
def confirm_input(user_input): if isinstance(user_input, list): user_input = ''.join(user_input) try: u_inp = user_input.lower().strip() except AttributeError: u_inp = user_input if u_inp in ('q', 'quit', 'exit'): sys.exit() if u_inp in ('y', 'yes'): return True return False
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute string string_start string_end identifier argument_list identifier try_statement block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list except_clause identifier block expression_statement assignment identifier identifier if_statement comparison_operator identifier tuple 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 if_statement comparison_operator identifier tuple string string_start string_content string_end string string_start string_content string_end block return_statement true return_statement false
Check user input for yes, no, or an exit signal.
def replace(html, replacements=None): if not replacements: return html html = HTMLFragment(html) for r in replacements: r.replace(html) return unicode(html)
module function_definition identifier parameters identifier default_parameter identifier none block if_statement not_operator identifier block return_statement identifier expression_statement assignment identifier call identifier argument_list identifier for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement call identifier argument_list identifier
Performs replacements on given HTML string.
def textFromHTML(html): cleaner = lxml.html.clean.Cleaner(scripts=True) cleaned = cleaner.clean_html(html) return lxml.html.fromstring(cleaned).text_content()
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list keyword_argument identifier true expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement call attribute call attribute attribute identifier identifier identifier argument_list identifier identifier argument_list
Cleans and parses text from the given HTML.
def _template(node_id, value=None): "Check if a template is assigned to it and render that with the value" result = [] select_template_from_node = fetch_query_string('select_template_from_node.sql') try: result = db.execute(text(select_template_from_node), node_id=node_id) template_result = result.fetchone() result.close() if template_result and template_result['name']: template = template_result['name'] if isinstance(value, dict): return render_template(template, **value) else: return render_template(template, value=value) except DatabaseError as err: current_app.logger.error("DatabaseError: %s", err) return value
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement string string_start string_content string_end expression_statement assignment identifier list expression_statement assignment identifier call identifier argument_list string string_start string_content string_end try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list 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 if_statement boolean_operator identifier subscript identifier string string_start string_content string_end block expression_statement assignment identifier subscript identifier string string_start string_content string_end if_statement call identifier argument_list identifier identifier block return_statement call identifier argument_list identifier dictionary_splat identifier else_clause block return_statement call identifier argument_list identifier keyword_argument identifier identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier return_statement identifier
Check if a template is assigned to it and render that with the value
def list(self, search_opts=None): query = base.get_query_string(search_opts) return self._list('/plugins%s' % query, 'plugins')
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier string string_start string_content string_end
Get a list of Plugins.
def read_tuple_ticks(self, symbol, start, end): if end is None: end=sys.maxint session=self.getReadSession()() try: rows=session.query(Tick).filter(and_(Tick.symbol == symbol, Tick.time >= int(start), Tick.time < int(end))) finally: self.getReadSession().remove() return [self.__sqlToTupleTick(row) for row in rows]
module function_definition identifier parameters identifier identifier identifier identifier block if_statement comparison_operator identifier none block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call call attribute identifier identifier argument_list argument_list try_statement block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier identifier argument_list call identifier argument_list comparison_operator attribute identifier identifier identifier comparison_operator attribute identifier identifier call identifier argument_list identifier comparison_operator attribute identifier identifier call identifier argument_list identifier finally_clause block expression_statement call attribute call attribute identifier identifier argument_list identifier argument_list return_statement list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier identifier
read ticks as tuple
def main(args): global logging, log args = parse_args(args) logging.basicConfig(format=LOG_FORMAT, level=logging.DEBUG if args.verbose else logging.INFO, stream=sys.stdout) df = cat_tweets(path=args.path, verbosity=args.verbose + 1, numtweets=args.numtweets, ignore_suspicious=False) log.info('Combined {} tweets'.format(len(df))) df = drop_nan_columns(df) save_tweets(df, path=args.path, filename=args.tweetfile) geo = get_geo(df, path=args.path, filename=args.geofile) log.info("Combined {} tweets into a single file {} and set asside {} geo tweets in {}".format( len(df), args.tweetfile, len(geo), args.geofile)) return df, geo
module function_definition identifier parameters identifier block global_statement identifier identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier conditional_expression attribute identifier identifier attribute identifier identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier binary_operator attribute identifier identifier integer keyword_argument identifier attribute identifier identifier keyword_argument identifier false 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 expression_statement assignment identifier call identifier argument_list identifier expression_statement call identifier argument_list identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier 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 attribute identifier identifier call identifier argument_list identifier attribute identifier identifier return_statement expression_list identifier identifier
API with args object containing configuration parameters
def prepare_fabric_fw(self, tenant_id, fw_dict, is_fw_virt, result): try: with self.mutex_lock: ret = self._prepare_fabric_fw_internal(tenant_id, fw_dict, is_fw_virt, result) except Exception as exc: LOG.error("Exception raised in create fabric %s", str(exc)) return False return ret
module function_definition identifier parameters identifier identifier identifier identifier identifier block try_statement block with_statement with_clause with_item attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list identifier return_statement false return_statement identifier
Top level routine to prepare the fabric.
def create_url(url_protocol, host, api, url_params): is_batch = url_params.pop("batch", None) apis = url_params.pop("apis", None) version = url_params.pop("version", None) or url_params.pop("v", None) method = url_params.pop('method', None) host_url_seg = url_protocol + "://%s" % host api_url_seg = "/%s" % api batch_url_seg = "/batch" if is_batch else "" method_url_seg = "/%s" % method if method else "" params = {} if apis: params["apis"] = ",".join(apis) if version: params["version"] = version url = host_url_seg + api_url_seg + batch_url_seg + method_url_seg if params: url += "?" + urlencode(params) return url
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end none expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end none expression_statement assignment identifier boolean_operator call attribute identifier identifier argument_list string string_start string_content string_end none call attribute identifier identifier argument_list string string_start string_content string_end none expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end none expression_statement assignment identifier binary_operator identifier binary_operator string string_start string_content string_end identifier expression_statement assignment identifier binary_operator string string_start string_content string_end identifier expression_statement assignment identifier conditional_expression string string_start string_content string_end identifier string string_start string_end expression_statement assignment identifier conditional_expression binary_operator string string_start string_content string_end identifier identifier string string_start string_end expression_statement assignment identifier dictionary if_statement identifier block expression_statement assignment subscript identifier string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list identifier if_statement identifier block expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment identifier binary_operator binary_operator binary_operator identifier identifier identifier identifier if_statement identifier block expression_statement augmented_assignment identifier binary_operator string string_start string_content string_end call identifier argument_list identifier return_statement identifier
Generate the proper url for sending off data for analysis
def fields(self) -> GraphQLFieldMap: try: fields = resolve_thunk(self._fields) except GraphQLError: raise except Exception as error: raise TypeError(f"{self.name} fields cannot be resolved: {error}") if not isinstance(fields, dict) or not all( isinstance(key, str) for key in fields ): raise TypeError( f"{self.name} fields must be a dict with field names as keys" " or a function which returns such an object." ) if not all( isinstance(value, GraphQLField) or is_output_type(value) for value in fields.values() ): raise TypeError( f"{self.name} fields must be GraphQLField or output type objects." ) return { name: value if isinstance(value, GraphQLField) else GraphQLField(value) for name, value in fields.items() }
module function_definition identifier parameters identifier type identifier block try_statement block expression_statement assignment identifier call identifier argument_list attribute identifier identifier except_clause identifier block raise_statement except_clause as_pattern identifier as_pattern_target identifier block raise_statement call identifier argument_list string string_start interpolation attribute identifier identifier string_content interpolation identifier string_end if_statement boolean_operator not_operator call identifier argument_list identifier identifier not_operator call identifier generator_expression call identifier argument_list identifier identifier for_in_clause identifier identifier block raise_statement call identifier argument_list concatenated_string string string_start interpolation attribute identifier identifier string_content string_end string string_start string_content string_end if_statement not_operator call identifier generator_expression boolean_operator call identifier argument_list identifier identifier call identifier argument_list identifier for_in_clause identifier call attribute identifier identifier argument_list block raise_statement call identifier argument_list string string_start interpolation attribute identifier identifier string_content string_end return_statement dictionary_comprehension pair identifier conditional_expression identifier call identifier argument_list identifier identifier call identifier argument_list identifier for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list
Get provided fields, wrapping them as GraphQLFields if needed.
def stop(self): self._done() if self._server: self._server.stop() self._server = None log.info('Stop!')
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier none expression_statement call attribute identifier identifier argument_list string string_start string_content string_end
Stop all tasks, and the local proxy server if it's running.
def cfset_to_set(cfset): count = cf.CFSetGetCount(cfset) buffer = (c_void_p * count)() cf.CFSetGetValues(cfset, byref(buffer)) return set([cftype_to_value(c_void_p(buffer[i])) for i in range(count)])
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call parenthesized_expression binary_operator identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier call identifier argument_list identifier return_statement call identifier argument_list list_comprehension call identifier argument_list call identifier argument_list subscript identifier identifier for_in_clause identifier call identifier argument_list identifier
Convert CFSet to python set.
def accel_increase_transparency(self, *args): transparency = self.settings.styleBackground.get_int('transparency') if int(transparency) - 2 > 0: self.settings.styleBackground.set_int('transparency', int(transparency) - 2) return True
module function_definition identifier parameters identifier list_splat_pattern identifier block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator binary_operator call identifier argument_list identifier integer integer block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end binary_operator call identifier argument_list identifier integer return_statement true
Callback to increase transparency.
def visit_emptynode(self, node, parent): return nodes.EmptyNode( getattr(node, "lineno", None), getattr(node, "col_offset", None), parent )
module function_definition identifier parameters identifier identifier identifier block return_statement call attribute identifier identifier argument_list call identifier argument_list identifier string string_start string_content string_end none call identifier argument_list identifier string string_start string_content string_end none identifier
visit an EmptyNode node by returning a fresh instance of it
def jtosparse(j): data = j.flatten().tolist() nobs, nf, nargs = j.shape indices = zip(*[(r, c) for n in xrange(nobs) for r in xrange(n * nf, (n + 1) * nf) for c in xrange(n * nargs, (n + 1) * nargs)]) return csr_matrix((data, indices), shape=(nobs * nf, nobs * nargs))
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list expression_statement assignment pattern_list identifier identifier identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list list_splat list_comprehension tuple identifier identifier for_in_clause identifier call identifier argument_list identifier for_in_clause identifier call identifier argument_list binary_operator identifier identifier binary_operator parenthesized_expression binary_operator identifier integer identifier for_in_clause identifier call identifier argument_list binary_operator identifier identifier binary_operator parenthesized_expression binary_operator identifier integer identifier return_statement call identifier argument_list tuple identifier identifier keyword_argument identifier tuple binary_operator identifier identifier binary_operator identifier identifier
Generate sparse matrix coordinates from 3-D Jacobian.
def fixcode(**kwargs): repo_dir = Path(__file__).parent.absolute() source_dir = Path(repo_dir, package.__name__) if source_dir.exists(): print("Source code locate at: '%s'." % source_dir) print("Auto pep8 all python file ...") source_dir.autopep8(**kwargs) else: print("Source code directory not found!") unittest_dir = Path(repo_dir, "tests") if unittest_dir.exists(): print("Unittest code locate at: '%s'." % unittest_dir) print("Auto pep8 all python file ...") unittest_dir.autopep8(**kwargs) else: print("Unittest code directory not found!") print("Complete!")
module function_definition identifier parameters dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute attribute call identifier argument_list identifier identifier identifier argument_list expression_statement assignment identifier call identifier argument_list identifier attribute identifier identifier if_statement call attribute identifier identifier argument_list block expression_statement call identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement call identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list dictionary_splat identifier else_clause block expression_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end if_statement call attribute identifier identifier argument_list block expression_statement call identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement call identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list dictionary_splat identifier else_clause block expression_statement call identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list string string_start string_content string_end
auto pep8 format all python file in ``source code`` and ``tests`` dir.
def _rpc_action_stmt(self, stmt: Statement, sctx: SchemaContext) -> None: self._handle_child(RpcActionNode(), stmt, sctx)
module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_parameter identifier type identifier type none block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier identifier
Handle rpc or action statement.
def loads(cls, s): with closing(StringIO(s)) as fileobj: return cls.load(fileobj)
module function_definition identifier parameters identifier identifier block with_statement with_clause with_item as_pattern call identifier argument_list call identifier argument_list identifier as_pattern_target identifier block return_statement call attribute identifier identifier argument_list identifier
Load an instance of this class from YAML.
def repo_values(self): branches = [] commits = {} m_helper = Tools() status = m_helper.repo_branches(self.parentApp.repo_value['repo']) if status[0]: branches = status[1] status = m_helper.repo_commits(self.parentApp.repo_value['repo']) if status[0]: r_commits = status[1] for commit in r_commits: commits[commit[0]] = commit[1] else: return status else: return status return branches, commits
module function_definition identifier parameters identifier block expression_statement assignment identifier list expression_statement assignment identifier dictionary expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list subscript attribute attribute identifier identifier identifier string string_start string_content string_end if_statement subscript identifier integer block expression_statement assignment identifier subscript identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list subscript attribute attribute identifier identifier identifier string string_start string_content string_end if_statement subscript identifier integer block expression_statement assignment identifier subscript identifier integer for_statement identifier identifier block expression_statement assignment subscript identifier subscript identifier integer subscript identifier integer else_clause block return_statement identifier else_clause block return_statement identifier return_statement expression_list identifier identifier
Set the appropriate repo dir and get the branches and commits of it
def getTemplateInstruments(self): items = dict() templates = self._get_worksheet_templates_brains() for template in templates: template_obj = api.get_object(template) uid_template = api.get_uid(template_obj) instrument = template_obj.getInstrument() uid_instrument = "" if instrument: uid_instrument = api.get_uid(instrument) items[uid_template] = uid_instrument return json.dumps(items)
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier string string_start string_end if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment subscript identifier identifier identifier return_statement call attribute identifier identifier argument_list identifier
Returns worksheet templates as JSON
def find_files(folder): files = [i for i in os.listdir(folder) if i.startswith("left")] files.sort() for i in range(len(files)): insert_string = "right{}".format(files[i * 2][4:]) files.insert(i * 2 + 1, insert_string) files = [os.path.join(folder, filename) for filename in files] return files
module function_definition identifier parameters identifier block expression_statement assignment identifier list_comprehension identifier for_in_clause identifier call attribute identifier identifier argument_list identifier if_clause call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list for_statement identifier call identifier argument_list call identifier argument_list identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list subscript subscript identifier binary_operator identifier integer slice integer expression_statement call attribute identifier identifier argument_list binary_operator binary_operator identifier integer integer identifier expression_statement assignment identifier list_comprehension call attribute attribute identifier identifier identifier argument_list identifier identifier for_in_clause identifier identifier return_statement identifier
Discover stereo photos and return them as a pairwise sorted list.
def os_application_version_set(package): application_version = get_upstream_version(package) if not application_version: application_version_set(os_release(package)) else: application_version_set(application_version)
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement not_operator identifier block expression_statement call identifier argument_list call identifier argument_list identifier else_clause block expression_statement call identifier argument_list identifier
Set version of application for Juju 2.0 and later
def _write(self, session, openFile, replaceParamFile): targets = self.targetParameters openFile.write('%s\n' % self.numParameters) for target in targets: openFile.write('%s %s\n' % (target.targetVariable, target.varFormat))
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content escape_sequence string_end attribute identifier identifier for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content escape_sequence string_end tuple attribute identifier identifier attribute identifier identifier
Replace Param File Write to File Method
def profile(length=25): from werkzeug.contrib.profiler import ProfilerMiddleware app.wsgi_app = ProfilerMiddleware(app.wsgi_app, restrictions=[length]) app.run()
module function_definition identifier parameters default_parameter identifier integer block import_from_statement dotted_name identifier identifier identifier dotted_name identifier expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier keyword_argument identifier list identifier expression_statement call attribute identifier identifier argument_list
Start the application under the code profiler
def generate(env): env['BUILDERS']['RMIC'] = RMICBuilder env['RMIC'] = 'rmic' env['RMICFLAGS'] = SCons.Util.CLVar('') env['RMICCOM'] = '$RMIC $RMICFLAGS -d ${TARGET.attributes.java_lookupdir} -classpath ${SOURCE.attributes.java_classdir} ${SOURCES.attributes.java_classname}' env['JAVACLASSSUFFIX'] = '.class'
module function_definition identifier parameters identifier block expression_statement assignment subscript subscript identifier string string_start string_content string_end string string_start string_content string_end identifier expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list string string_start string_end expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_content string_end
Add Builders and construction variables for rmic to an Environment.
def read_settings(self): extent = setting('user_extent', None, str) if extent: extent = QgsGeometry.fromWkt(extent) if not extent.isGeosValid(): extent = None crs = setting('user_extent_crs', None, str) if crs: crs = QgsCoordinateReferenceSystem(crs) if not crs.isValid(): crs = None mode = setting('analysis_extents_mode', HAZARD_EXPOSURE_VIEW) if crs and extent and mode == HAZARD_EXPOSURE_BOUNDINGBOX: self.extent.set_user_extent(extent, crs) self.extent.show_rubber_bands = setting( 'showRubberBands', False, bool) self.zoom_to_impact_flag = setting('setZoomToImpactFlag', True, bool) self.hide_exposure_flag = setting('setHideExposureFlag', False, bool)
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list string string_start string_content string_end none identifier if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement not_operator call attribute identifier identifier argument_list block expression_statement assignment identifier none expression_statement assignment identifier call identifier argument_list string string_start string_content string_end none identifier if_statement identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement not_operator call attribute identifier identifier argument_list block expression_statement assignment identifier none expression_statement assignment identifier call identifier argument_list string string_start string_content string_end identifier if_statement boolean_operator boolean_operator identifier identifier comparison_operator identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement assignment attribute attribute identifier identifier identifier call identifier argument_list string string_start string_content string_end false identifier expression_statement assignment attribute identifier identifier call identifier argument_list string string_start string_content string_end true identifier expression_statement assignment attribute identifier identifier call identifier argument_list string string_start string_content string_end false identifier
Set the IF state from QSettings.
def repeat_str(state): if state == const.REPEAT_STATE_OFF: return 'Off' if state == const.REPEAT_STATE_TRACK: return 'Track' if state == const.REPEAT_STATE_ALL: return 'All' return 'Unsupported'
module function_definition identifier parameters identifier block if_statement comparison_operator identifier attribute identifier identifier block return_statement string string_start string_content string_end if_statement comparison_operator identifier attribute identifier identifier block return_statement string string_start string_content string_end if_statement comparison_operator identifier attribute identifier identifier block return_statement string string_start string_content string_end return_statement string string_start string_content string_end
Convert internal API repeat state to string.
def action_approve(self): for rec in self: if rec.state not in ['draft', 'to approve']: raise UserError( _("Can't approve page in '%s' state.") % rec.state) if not rec.am_i_approver: raise UserError(_( 'You are not authorized to do this.\r\n' 'Only approvers with these groups can approve this: ' ) % ', '.join( [g.display_name for g in rec.page_id.approver_group_ids])) rec.write({ 'state': 'approved', 'approved_date': fields.datetime.now(), 'approved_uid': self.env.uid, }) rec.page_id._compute_history_head() rec.message_post( subtype='mt_comment', body=_( 'Change request has been approved by %s.' ) % (self.env.user.name) ) rec.page_id.message_post( subtype='mt_comment', body=_( 'New version of the document %s approved.' ) % (rec.page_id.name) )
module function_definition identifier parameters identifier block for_statement identifier identifier block if_statement comparison_operator attribute identifier identifier list string string_start string_content string_end string string_start string_content string_end block raise_statement call identifier argument_list binary_operator call identifier argument_list string string_start string_content string_end attribute identifier identifier if_statement not_operator attribute identifier identifier block raise_statement call identifier argument_list binary_operator call identifier argument_list concatenated_string string string_start string_content escape_sequence escape_sequence string_end string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list list_comprehension attribute identifier identifier for_in_clause identifier attribute attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list pair string string_start string_content string_end attribute attribute identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier binary_operator call identifier argument_list string string_start string_content string_end parenthesized_expression attribute attribute attribute identifier identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier binary_operator call identifier argument_list string string_start string_content string_end parenthesized_expression attribute attribute identifier identifier identifier
Set a change request as approved.
def tokenize(string, language=None, escape='___'): string = string.lower() if len(string) and not string[-1].isalnum(): character = string[-1] string = string[:-1] + ' ' + character string = string.replace('(', ' ( ') string = string.replace(')', ' ) ') if language: words = mathwords.words_for_language(language) for phrase in words: escaped_phrase = phrase.replace(' ', escape) string = string.replace(phrase, escaped_phrase) tokens = string.split() for index, token in enumerate(tokens): tokens[index] = token.replace(escape, ' ') return tokens
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement boolean_operator call identifier argument_list identifier not_operator call attribute subscript identifier unary_operator integer identifier argument_list block expression_statement assignment identifier subscript identifier unary_operator integer expression_statement assignment identifier binary_operator binary_operator subscript identifier slice unary_operator integer string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list for_statement pattern_list identifier identifier call identifier argument_list identifier block expression_statement assignment subscript identifier identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end return_statement identifier
Given a string, return a list of math symbol tokens
def stop_recording(self): self._stop_recording.set() with self._source_lock: self._source.stop() self._recording = False
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list with_statement with_clause with_item attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier false
Stop recording from the audio source.
def _from_dict(cls, _dict): args = {} if 'word_count' in _dict: args['word_count'] = _dict.get('word_count') else: raise ValueError( 'Required property \'word_count\' not present in TranslationResult JSON' ) if 'character_count' in _dict: args['character_count'] = _dict.get('character_count') else: raise ValueError( 'Required property \'character_count\' not present in TranslationResult JSON' ) if 'translations' in _dict: args['translations'] = [ Translation._from_dict(x) for x in (_dict.get('translations')) ] else: raise ValueError( 'Required property \'translations\' not present in TranslationResult JSON' ) return cls(**args)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary 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 call attribute identifier identifier argument_list string string_start string_content string_end else_clause block raise_statement call identifier argument_list string string_start string_content escape_sequence escape_sequence string_end 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 call attribute identifier identifier argument_list string string_start string_content string_end else_clause block raise_statement call identifier argument_list string string_start string_content escape_sequence escape_sequence string_end 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 list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier parenthesized_expression call attribute identifier identifier argument_list string string_start string_content string_end else_clause block raise_statement call identifier argument_list string string_start string_content escape_sequence escape_sequence string_end return_statement call identifier argument_list dictionary_splat identifier
Initialize a TranslationResult object from a json dictionary.
def get(self, filepath): try: res = self.fs.get_file_details(filepath) res = res.to_dict() self.write(res) except OSError: raise tornado.web.HTTPError(404)
module function_definition identifier parameters identifier identifier block try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier except_clause identifier block raise_statement call attribute attribute identifier identifier identifier argument_list integer
Get file details for the specified file.
def find(self, resource_id, query=None, **kwargs): if query is None: query = {} return self.client._get( self._url(resource_id), query, **kwargs )
module function_definition identifier parameters identifier identifier default_parameter identifier none dictionary_splat_pattern identifier block if_statement comparison_operator identifier none block expression_statement assignment identifier dictionary return_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list identifier identifier dictionary_splat identifier
Gets a single resource.
def _control_line(self, line): if line > float(self.LINE_LAST_PIXEL): return int(self.LINE_LAST_PIXEL) elif line < float(self.LINE_FIRST_PIXEL): return int(self.LINE_FIRST_PIXEL) else: return line
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier call identifier argument_list attribute identifier identifier block return_statement call identifier argument_list attribute identifier identifier elif_clause comparison_operator identifier call identifier argument_list attribute identifier identifier block return_statement call identifier argument_list attribute identifier identifier else_clause block return_statement identifier
Control the asked line is ok
def add(self, path): path = os.path.abspath(path) if not os.path.exists(path): return if path in sys.path: return if self.index is not None: sys.path.insert(self.index, path) self.index += 1 else: sys.path.append(path)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block return_statement if_statement comparison_operator identifier attribute identifier identifier block return_statement if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier expression_statement augmented_assignment attribute identifier identifier integer else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Add the given path to the decided place in sys.path
def create_notifications(users, notification_model, notification_type, related_object): Notification = notification_model additional = related_object.__dict__ if related_object else '' notification_text = TEXTS[notification_type] % additional for user in users: n = Notification( to_user=user, type=notification_type, text=notification_text ) if related_object: n.related_object = related_object n.save()
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier identifier expression_statement assignment identifier conditional_expression attribute identifier identifier identifier string string_start string_end expression_statement assignment identifier binary_operator subscript identifier identifier identifier for_statement identifier identifier block expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier if_statement identifier block expression_statement assignment attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list
create notifications in a background job to avoid slowing down users
def getNorthSouthClone(self, i): north = self.getAdjacentClone(i, south=False) south = self.getAdjacentClone(i) return north, south
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier false expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement expression_list identifier identifier
Returns the adjacent clone name from both sides.
def import_class(klass): mod = __import__(klass.rpartition('.')[0]) for segment in klass.split('.')[1:-1]: mod = getattr(mod, segment) return getattr(mod, klass.rpartition('.')[2])
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list subscript call attribute identifier identifier argument_list string string_start string_content string_end integer for_statement identifier subscript call attribute identifier identifier argument_list string string_start string_content string_end slice integer unary_operator integer block expression_statement assignment identifier call identifier argument_list identifier identifier return_statement call identifier argument_list identifier subscript call attribute identifier identifier argument_list string string_start string_content string_end integer
Import the named class and return that class
def send_request(cls, sock, working_dir, command, *arguments, **environment): for argument in arguments: cls.write_chunk(sock, ChunkType.ARGUMENT, argument) for item_tuple in environment.items(): cls.write_chunk(sock, ChunkType.ENVIRONMENT, cls.ENVIRON_SEP.join(cls._decode_unicode_seq(item_tuple))) cls.write_chunk(sock, ChunkType.WORKING_DIR, working_dir) cls.write_chunk(sock, ChunkType.COMMAND, command)
module function_definition identifier parameters identifier identifier identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier identifier for_statement identifier call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier identifier
Send the initial Nailgun request over the specified socket.
def parse_period(period: str): period = period.split(" - ") date_from = Datum() if len(period[0]) == 10: date_from.from_iso_date_string(period[0]) else: date_from.from_iso_long_date(period[0]) date_from.start_of_day() date_to = Datum() if len(period[1]) == 10: date_to.from_iso_date_string(period[1]) else: date_to.from_iso_long_date(period[1]) date_to.end_of_day() return date_from.value, date_to.value
module function_definition identifier parameters typed_parameter identifier type identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list if_statement comparison_operator call identifier argument_list subscript identifier integer integer block expression_statement call attribute identifier identifier argument_list subscript identifier integer else_clause block expression_statement call attribute identifier identifier argument_list subscript identifier integer expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list if_statement comparison_operator call identifier argument_list subscript identifier integer integer block expression_statement call attribute identifier identifier argument_list subscript identifier integer else_clause block expression_statement call attribute identifier identifier argument_list subscript identifier integer expression_statement call attribute identifier identifier argument_list return_statement expression_list attribute identifier identifier attribute identifier identifier
parses period from date range picker. The received values are full ISO date
def _time_request(self, uri, method, **kwargs): start_time = time.time() resp, body = self.request(uri, method, **kwargs) self.times.append(("%s %s" % (method, uri), start_time, time.time())) return resp, body
module function_definition identifier parameters identifier identifier identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier identifier dictionary_splat identifier expression_statement call attribute attribute identifier identifier identifier argument_list tuple binary_operator string string_start string_content string_end tuple identifier identifier identifier call attribute identifier identifier argument_list return_statement expression_list identifier identifier
Wraps the request call and records the elapsed time.
def Eg(self, **kwargs): return self.unstrained.Eg(**kwargs) + self.Eg_strain_shift(**kwargs)
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block return_statement binary_operator call attribute attribute identifier identifier identifier argument_list dictionary_splat identifier call attribute identifier identifier argument_list dictionary_splat identifier
Returns the strain-shifted bandgap, ``Eg``.
def reloadCompletedMeasurements(self): from pathlib import Path reloaded = [self.load(x.resolve()) for x in Path(self.dataDir).glob('*/*/*') if x.is_dir()] logger.info('Reloaded ' + str(len(reloaded)) + ' completed measurements') self.completeMeasurements = [x for x in reloaded if x is not None and x.status == MeasurementStatus.COMPLETE] self.failedMeasurements = [x for x in reloaded if x is not None and x.status == MeasurementStatus.FAILED]
module function_definition identifier parameters identifier block import_from_statement dotted_name identifier dotted_name identifier expression_statement assignment identifier list_comprehension call attribute identifier identifier argument_list call attribute identifier identifier argument_list for_in_clause identifier call attribute call identifier argument_list attribute identifier identifier identifier argument_list string string_start string_content string_end if_clause call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list binary_operator binary_operator string string_start string_content string_end call identifier argument_list call identifier argument_list identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier list_comprehension identifier for_in_clause identifier identifier if_clause boolean_operator comparison_operator identifier none comparison_operator attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier list_comprehension identifier for_in_clause identifier identifier if_clause boolean_operator comparison_operator identifier none comparison_operator attribute identifier identifier attribute identifier identifier
Reloads the completed measurements from the backing store.
def draw_lines(self, callback): from MAVProxy.modules.mavproxy_map import mp_slipmap self.draw_callback = callback self.draw_line = [] self.map.add_object(mp_slipmap.SlipDefaultPopup(None))
module function_definition identifier parameters identifier identifier block import_from_statement dotted_name identifier identifier identifier dotted_name identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier list expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list none
draw a series of connected lines on the map, calling callback when done
def not_query(expression): compiled_expression = compile_query(expression) def _not(index, expression=compiled_expression): all_keys = index.get_all_keys() returned_keys = expression(index) return [key for key in all_keys if key not in returned_keys] return _not
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier 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 identifier argument_list identifier return_statement list_comprehension identifier for_in_clause identifier identifier if_clause comparison_operator identifier identifier return_statement identifier
Apply logical not operator to expression.
def nelect(self): site_symbols = list(set(self.poscar.site_symbols)) nelect = 0. for ps in self.potcar: if ps.element in site_symbols: site_symbols.remove(ps.element) nelect += self.structure.composition.element_composition[ ps.element] * ps.ZVAL if self.use_structure_charge: return nelect - self.structure.charge else: return nelect
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list call identifier argument_list attribute attribute identifier identifier identifier expression_statement assignment identifier float for_statement identifier attribute identifier identifier block if_statement comparison_operator attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement augmented_assignment identifier binary_operator subscript attribute attribute attribute identifier identifier identifier identifier attribute identifier identifier attribute identifier identifier if_statement attribute identifier identifier block return_statement binary_operator identifier attribute attribute identifier identifier identifier else_clause block return_statement identifier
Gets the default number of electrons for a given structure.
def reset_max_values(self): self._max_values = {} for k in self._max_values_list: self._max_values[k] = 0.0
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier dictionary for_statement identifier attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier float
Reset the maximum values dict.
def avail_sizes(call=None): if call == 'action': raise SaltCloudSystemExit( 'The avail_sizes function must be called with ' '-f or --function, or with the --list-sizes option' ) conn = get_conn() data = conn.list_role_sizes() ret = {} for item in data.role_sizes: ret[item.name] = object_to_dict(item) return ret
module function_definition identifier parameters default_parameter identifier none block if_statement comparison_operator identifier string string_start string_content string_end block raise_statement call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier dictionary for_statement identifier attribute identifier identifier block expression_statement assignment subscript identifier attribute identifier identifier call identifier argument_list identifier return_statement identifier
Return a list of sizes from Azure
def num_failures(self): min_time = time.time() - self.window while self.failures and self.failures[0] < min_time: self.failures.popleft() return len(self.failures)
module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list attribute identifier identifier while_statement boolean_operator attribute identifier identifier comparison_operator subscript attribute identifier identifier integer identifier block expression_statement call attribute attribute identifier identifier identifier argument_list return_statement call identifier argument_list attribute identifier identifier
Return the number of failures in the window.
def cli(ctx, hostname, username, password, config_dir, https): ctx.is_root = True ctx.user_values_entered = False ctx.config_dir = os.path.abspath(os.path.expanduser(config_dir)) ctx.config = load_config(ctx) ctx.hostname = hostname ctx.username = username ctx.password = password ctx.https = https ctx.wva = None
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block expression_statement assignment attribute identifier identifier true expression_statement assignment attribute identifier identifier false expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier call identifier argument_list identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier none
Command-line interface for interacting with a WVA device
def _rand1(self): "generate a single random sample" Z = _unwhiten_cf(self._S_cf, self._genA()) return Z.dot(Z.T)
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier call identifier argument_list attribute identifier identifier call attribute identifier identifier argument_list return_statement call attribute identifier identifier argument_list attribute identifier identifier
generate a single random sample
def __initialize(self, resp): raw_data = xmltodict.parse(resp.content) root_key = list(raw_data.keys())[0] self.raw_data = raw_data.get(root_key) self.__initializeFromRaw()
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier subscript call identifier argument_list call attribute identifier identifier argument_list integer expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list
Initialize from the response
def cache_key(self, repo: str, branch: str, task: Task, git_repo: Repo) -> str: return "{repo}_{branch}_{hash}_{task}".format(repo=self.repo_id(repo), branch=branch, hash=self.current_git_hash(repo, branch, git_repo), task=task.hash)
module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier type identifier block return_statement call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier call attribute identifier identifier argument_list identifier identifier identifier keyword_argument identifier attribute identifier identifier
Returns the key used for storing results in cache.
def info(): try: platform_info = { 'system': platform.system(), 'release': platform.release(), } except IOError: platform_info = { 'system': 'Unknown', 'release': 'Unknown', } implementation_info = _implementation() urllib3_info = {'version': urllib3.__version__} chardet_info = {'version': chardet.__version__} pyopenssl_info = { 'version': None, 'openssl_version': '', } if OpenSSL: pyopenssl_info = { 'version': OpenSSL.__version__, 'openssl_version': '%x' % OpenSSL.SSL.OPENSSL_VERSION_NUMBER, } cryptography_info = { 'version': getattr(cryptography, '__version__', ''), } idna_info = { 'version': getattr(idna, '__version__', ''), } system_ssl = ssl.OPENSSL_VERSION_NUMBER system_ssl_info = { 'version': '%x' % system_ssl if system_ssl is not None else '' } return { 'platform': platform_info, 'implementation': implementation_info, 'system_ssl': system_ssl_info, 'using_pyopenssl': pyopenssl is not None, 'pyOpenSSL': pyopenssl_info, 'urllib3': urllib3_info, 'chardet': chardet_info, 'cryptography': cryptography_info, 'idna': idna_info, 'requests': { 'version': requests_version, }, }
module function_definition identifier parameters block try_statement block expression_statement assignment identifier dictionary pair string string_start string_content string_end call attribute identifier identifier argument_list pair string string_start string_content string_end call attribute identifier identifier argument_list except_clause identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier dictionary pair string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end none pair string string_start string_content string_end string string_start string_end if_statement identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end binary_operator string string_start string_content string_end attribute attribute identifier identifier identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end call identifier argument_list identifier string string_start string_content string_end string string_start string_end expression_statement assignment identifier dictionary pair string string_start string_content string_end call identifier argument_list identifier string string_start string_content string_end string string_start string_end expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end conditional_expression binary_operator string string_start string_content string_end identifier comparison_operator identifier none string string_start string_end 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 comparison_operator identifier none 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 pair string string_start string_content string_end dictionary pair string string_start string_content string_end identifier
Generate information for a bug report.
def write_dfile(self): f_in = self.tempfiles.get_tempfile(prefix="bmds-", suffix=".(d)") with open(f_in, "w") as f: f.write(self.as_dfile()) return f_in
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end 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 identifier identifier argument_list return_statement identifier
Write the generated d_file to a temporary file.
def command(state, args): args = parser.parse_args(args[1:]) if args.complete: query.files.delete_regexp_complete(state.db) else: if args.aid is None: parser.print_help() else: aid = state.results.parse_aid(args.aid, default_key='db') query.files.delete_regexp(state.db, aid)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier slice integer if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier else_clause block if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute identifier identifier argument_list else_clause block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier keyword_argument identifier string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier
Unregister watching regexp for an anime.
def insert_line_above(self, copy_margin=True): if copy_margin: insert = self.document.leading_whitespace_in_current_line + '\n' else: insert = '\n' self.cursor_position += self.document.get_start_of_line_position() self.insert_text(insert) self.cursor_position -= 1
module function_definition identifier parameters identifier default_parameter identifier true block if_statement identifier block expression_statement assignment identifier binary_operator attribute attribute identifier identifier identifier string string_start string_content escape_sequence string_end else_clause block expression_statement assignment identifier string string_start string_content escape_sequence string_end expression_statement augmented_assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier expression_statement augmented_assignment attribute identifier identifier integer
Insert a new line above the current one.
def make(cls, vol): if isinstance(vol, cls): return vol elif vol is None: return None else: return cls(vol, None)
module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier identifier block return_statement identifier elif_clause comparison_operator identifier none block return_statement none else_clause block return_statement call identifier argument_list identifier none
Convert uuid to Volume, if necessary.
def _suicide_when_without_parent(self, parent_pid): while True: time.sleep(5) try: os.kill(parent_pid, 0) except OSError: self.stop() log.warning('The parent is not alive, exiting.') os._exit(999)
module function_definition identifier parameters identifier identifier block while_statement true block expression_statement call attribute identifier identifier argument_list integer try_statement block expression_statement call attribute identifier identifier argument_list identifier integer except_clause identifier block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list integer
Kill this process when the parent died.
def selectnotin(table, field, value, complement=False): return select(table, field, lambda v: v not in value, complement=complement)
module function_definition identifier parameters identifier identifier identifier default_parameter identifier false block return_statement call identifier argument_list identifier identifier lambda lambda_parameters identifier comparison_operator identifier identifier keyword_argument identifier identifier
Select rows where the given field is not a member of the given value.
def write_output(self, data, args=None, filename=None, label=None): if args: if not args.outlog: return 0 if not filename: filename=args.outlog lastpath = '' with open(str(filename), 'w') as output_file: for entry in data['entries']: if args.label: if entry['source_path'] == lastpath: output_file.write(entry['raw_text'] + '\n') elif args.label == 'fname': output_file.write('======== ' + \ entry['source_path'].split('/')[-1] + \ ' >>>>\n' + entry['raw_text'] + '\n') elif args.label == 'fpath': output_file.write('======== ' + \ entry['source_path'] + \ ' >>>>\n' + entry['raw_text'] + '\n') else: output_file.write(entry['raw_text'] + '\n') lastpath = entry['source_path']
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none block if_statement identifier block if_statement not_operator attribute identifier identifier block return_statement integer if_statement not_operator identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier string string_start string_end with_statement with_clause with_item as_pattern call identifier argument_list call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block for_statement identifier subscript identifier string string_start string_content string_end block if_statement attribute identifier identifier block if_statement comparison_operator subscript identifier string string_start string_content string_end identifier block expression_statement call attribute identifier identifier argument_list binary_operator subscript identifier string string_start string_content string_end string string_start string_content escape_sequence string_end elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list binary_operator binary_operator binary_operator binary_operator string string_start string_content string_end line_continuation subscript call attribute subscript identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end unary_operator integer string string_start string_content escape_sequence string_end subscript identifier string string_start string_content string_end string string_start string_content escape_sequence string_end elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list binary_operator binary_operator binary_operator binary_operator string string_start string_content string_end line_continuation subscript identifier string string_start string_content string_end string string_start string_content escape_sequence string_end subscript identifier string string_start string_content string_end string string_start string_content escape_sequence string_end else_clause block expression_statement call attribute identifier identifier argument_list binary_operator subscript identifier string string_start string_content string_end string string_start string_content escape_sequence string_end expression_statement assignment identifier subscript identifier string string_start string_content string_end
Write log data to a log file
def create_html(s1, s2, output='test.html'): html = difflib.HtmlDiff().make_file(s1.split(), s2.split()) with open(output, 'w') as f: f.write(html)
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list call attribute identifier identifier argument_list call attribute 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 identifier
creates basic html based on the diff of 2 strings
def fulfill(self, value): assert self._state==self.PENDING self._state=self.FULFILLED; self.value = value for callback in self._callbacks: try: callback(value) except Exception: pass self._callbacks = []
module function_definition identifier parameters identifier identifier block assert_statement comparison_operator attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier identifier for_statement identifier attribute identifier identifier block try_statement block expression_statement call identifier argument_list identifier except_clause identifier block pass_statement expression_statement assignment attribute identifier identifier list
Fulfill the promise with a given value.
def count(self, *criterion, **kwargs): query = self._query(*criterion) query = self._filter(query, **kwargs) return query.count()
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list list_splat identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier dictionary_splat identifier return_statement call attribute identifier identifier argument_list
Count the number of models matching some criterion.
def _with_context(self, *args, **kwargs): context = dict(args[0] if args else self.env.context, **kwargs) return self.with_env(self.env(context=context))
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list conditional_expression subscript identifier integer identifier attribute attribute identifier identifier identifier dictionary_splat identifier return_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier identifier
As the `with_context` class method but for recordset.
def create_space(self): cur = self._conn.cursor() cur.executescript(SQL_MODEL) self._conn.commit() cur.close() return
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list return_statement
Set up a new table space for the first time
def fixed_interval_scheduler(interval): start = time.time() next_tick = start while True: next_tick += interval yield next_tick
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier identifier while_statement true block expression_statement augmented_assignment identifier identifier expression_statement yield identifier
A scheduler that ticks at fixed intervals of "interval" seconds
def save(self, model_filename, optimizer_filename): serializers.save_hdf5(model_filename, self.model) serializers.save_hdf5(optimizer_filename, self.optimizer)
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier
Save the state of the model & optimizer to disk
def health_check(cls): try: assert isinstance(settings.MIDDLEWARES, list) except AssertionError: yield HealthCheckFail( '00005', 'The "MIDDLEWARES" configuration key should be assigned ' 'to a list', ) return for m in settings.MIDDLEWARES: try: c = import_class(m) except (TypeError, ValueError, AttributeError, ImportError): yield HealthCheckFail( '00005', f'Cannot import middleware "{m}"', ) else: if not issubclass(c, BaseMiddleware): yield HealthCheckFail( '00005', f'Middleware "{m}" does not implement ' f'"BaseMiddleware"', )
module function_definition identifier parameters identifier block try_statement block assert_statement call identifier argument_list attribute identifier identifier identifier except_clause identifier block expression_statement yield call identifier argument_list string string_start string_content string_end concatenated_string string string_start string_content string_end string string_start string_content string_end return_statement for_statement identifier attribute identifier identifier block try_statement block expression_statement assignment identifier call identifier argument_list identifier except_clause tuple identifier identifier identifier identifier block expression_statement yield call identifier argument_list string string_start string_content string_end string string_start string_content interpolation identifier string_content string_end else_clause block if_statement not_operator call identifier argument_list identifier identifier block expression_statement yield call identifier argument_list string string_start string_content string_end concatenated_string string string_start string_content interpolation identifier string_content string_end string string_start string_content string_end
Checks that the configuration makes sense.
def _AddFieldPaths(node, prefix, field_mask): if not node: field_mask.paths.append(prefix) return for name in sorted(node): if prefix: child_path = prefix + '.' + name else: child_path = name _AddFieldPaths(node[name], child_path, field_mask)
module function_definition identifier parameters identifier identifier identifier block if_statement not_operator identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement for_statement identifier call identifier argument_list identifier block if_statement identifier block expression_statement assignment identifier binary_operator binary_operator identifier string string_start string_content string_end identifier else_clause block expression_statement assignment identifier identifier expression_statement call identifier argument_list subscript identifier identifier identifier identifier
Adds the field paths descended from node to field_mask.
def _extrn_path(self, url, saltenv, cachedir=None): url_data = urlparse(url) if salt.utils.platform.is_windows(): netloc = salt.utils.path.sanitize_win_path(url_data.netloc) else: netloc = url_data.netloc netloc = netloc.split('@')[-1] if cachedir is None: cachedir = self.opts['cachedir'] elif not os.path.isabs(cachedir): cachedir = os.path.join(self.opts['cachedir'], cachedir) if url_data.query: file_name = '-'.join([url_data.path, url_data.query]) else: file_name = url_data.path if len(file_name) > MAX_FILENAME_LENGTH: file_name = salt.utils.hashutils.sha256_digest(file_name) return salt.utils.path.join( cachedir, 'extrn_files', saltenv, netloc, file_name )
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none block expression_statement assignment identifier call identifier argument_list identifier if_statement call attribute attribute attribute identifier identifier identifier identifier argument_list block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list attribute identifier identifier else_clause block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier subscript call attribute identifier identifier argument_list string string_start string_content string_end unary_operator integer if_statement comparison_operator identifier none block expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end elif_clause not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list subscript attribute identifier identifier string string_start string_content string_end identifier if_statement attribute identifier identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list list attribute identifier identifier attribute identifier identifier else_clause block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list identifier return_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier string string_start string_content string_end identifier identifier identifier
Return the extrn_filepath for a given url
def _ask_questionnaire(): answers = {} print(info_header) pprint(questions.items()) for question, default in questions.items(): response = _ask(question, default, str(type(default)), show_hint=True) if type(default) == unicode and type(response) != str: response = response.decode('utf-8') answers[question] = response return answers
module function_definition identifier parameters block expression_statement assignment identifier dictionary expression_statement call identifier argument_list identifier expression_statement call identifier argument_list call attribute identifier identifier argument_list for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call identifier argument_list identifier identifier call identifier argument_list call identifier argument_list identifier keyword_argument identifier true if_statement boolean_operator comparison_operator call identifier argument_list identifier identifier comparison_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 expression_statement assignment subscript identifier identifier identifier return_statement identifier
Asks questions to fill out a HFOS plugin template
def frombits(cls, bits): return cls.frombitsets(map(cls.BitSet.frombits, bits))
module function_definition identifier parameters identifier identifier block return_statement call attribute identifier identifier argument_list call identifier argument_list attribute attribute identifier identifier identifier identifier
Series from binary string arguments.
def check_validity(self): if not isinstance(self.pianoroll, np.ndarray): raise TypeError("`pianoroll` must be a numpy array.") if not (np.issubdtype(self.pianoroll.dtype, np.bool_) or np.issubdtype(self.pianoroll.dtype, np.number)): raise TypeError("The data type of `pianoroll` must be np.bool_ or " "a subdtype of np.number.") if self.pianoroll.ndim != 2: raise ValueError("`pianoroll` must have exactly two dimensions.") if self.pianoroll.shape[1] != 128: raise ValueError("The length of the second axis of `pianoroll` " "must be 128.") if not isinstance(self.program, int): raise TypeError("`program` must be int.") if self.program < 0 or self.program > 127: raise ValueError("`program` must be in between 0 to 127.") if not isinstance(self.is_drum, bool): raise TypeError("`is_drum` must be bool.") if not isinstance(self.name, string_types): raise TypeError("`name` must be a string.")
module function_definition identifier parameters identifier block if_statement not_operator call identifier argument_list attribute identifier identifier attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end if_statement not_operator parenthesized_expression boolean_operator call attribute identifier identifier argument_list attribute attribute identifier identifier identifier attribute identifier identifier call attribute identifier identifier argument_list attribute attribute identifier identifier identifier attribute identifier identifier block raise_statement call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end if_statement comparison_operator attribute attribute identifier identifier identifier integer block raise_statement call identifier argument_list string string_start string_content string_end if_statement comparison_operator subscript attribute attribute identifier identifier identifier integer integer block raise_statement call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end if_statement not_operator call identifier argument_list attribute identifier identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end if_statement boolean_operator comparison_operator attribute identifier identifier integer comparison_operator attribute identifier identifier integer block raise_statement call identifier argument_list string string_start string_content string_end if_statement not_operator call identifier argument_list attribute identifier identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end if_statement not_operator call identifier argument_list attribute identifier identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end
Raise error if any invalid attribute found.
def check_transaction(self, code): response = self.get(url=self.config.TRANSACTION_URL % code) return PagSeguroNotificationResponse(response.content, self.config)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier binary_operator attribute attribute identifier identifier identifier identifier return_statement call identifier argument_list attribute identifier identifier attribute identifier identifier
check a transaction by its code
def _has_z(self, kwargs): return ((self._type == 1 or self._type ==2) and (('z' in kwargs) or (self._element_z in kwargs)))
module function_definition identifier parameters identifier identifier block return_statement parenthesized_expression boolean_operator parenthesized_expression boolean_operator comparison_operator attribute identifier identifier integer comparison_operator attribute identifier identifier integer parenthesized_expression boolean_operator parenthesized_expression comparison_operator string string_start string_content string_end identifier parenthesized_expression comparison_operator attribute identifier identifier identifier
Returns True if type is 1 or 2 and z is explicitly defined in kwargs.
def _delete(self, bits, pos): assert 0 <= pos <= self.len assert pos + bits <= self.len if not pos: self._truncatestart(bits) return if pos + bits == self.len: self._truncateend(bits) return if pos > self.len - pos - bits: end = self._slice(pos + bits, self.len) assert self.len - pos > 0 self._truncateend(self.len - pos) self._append(end) return start = self._slice(0, pos) self._truncatestart(pos + bits) self._prepend(start) return
module function_definition identifier parameters identifier identifier identifier block assert_statement comparison_operator integer identifier attribute identifier identifier assert_statement comparison_operator binary_operator identifier identifier attribute identifier identifier if_statement not_operator identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement if_statement comparison_operator binary_operator identifier identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement if_statement comparison_operator identifier binary_operator binary_operator attribute identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator identifier identifier attribute identifier identifier assert_statement comparison_operator binary_operator attribute identifier identifier identifier integer expression_statement call attribute identifier identifier argument_list binary_operator attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement expression_statement assignment identifier call attribute identifier identifier argument_list integer identifier expression_statement call attribute identifier identifier argument_list binary_operator identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement
Delete bits at pos.
def assert_subset(self, subset, superset, failure_message='Expected collection "{}" to be a subset of "{}'): assertion = lambda: set(subset).issubset(set(superset)) failure_message = unicode(failure_message).format(superset, subset) self.webdriver_assert(assertion, failure_message)
module function_definition identifier parameters identifier identifier identifier default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier lambda call attribute call identifier argument_list identifier identifier argument_list call identifier argument_list identifier expression_statement assignment identifier call attribute call identifier argument_list identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier
Asserts that a superset contains all elements of a subset
def _sec_to_readable(t): t = datetime(1, 1, 1) + timedelta(seconds=t) t = '{0:02d}:{1:02d}.{2:03d}'.format( t.hour * 60 + t.minute, t.second, int(round(t.microsecond / 1000.))) return t
module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator call identifier argument_list integer integer integer call identifier argument_list keyword_argument identifier identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list binary_operator binary_operator attribute identifier identifier integer attribute identifier identifier attribute identifier identifier call identifier argument_list call identifier argument_list binary_operator attribute identifier identifier float return_statement identifier
Convert a number of seconds to a more readable representation.
def __redraw_loop(self): self.queue_draw() self.__drawing_queued = self.tweener and self.tweener.has_tweens() return self.__drawing_queued
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier boolean_operator attribute identifier identifier call attribute attribute identifier identifier identifier argument_list return_statement attribute identifier identifier
loop until there is nothing more to tween
def list_backends(self, service_id, version_number): content = self._fetch("/service/%s/version/%d/backend" % (service_id, version_number)) return map(lambda x: FastlyBackend(self, x), content)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier return_statement call identifier argument_list lambda lambda_parameters identifier call identifier argument_list identifier identifier identifier
List all backends for a particular service and version.
def to_json(obj): i = StringIO.StringIO() w = Writer(i, encoding='UTF-8') w.write_value(obj) return i.getvalue()
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list
Return a json string representing the python object obj.
def users(self): return Users(url="%s/users" % self.root, securityHandler=self._securityHandler, proxy_url=self._proxy_url, proxy_port=self._proxy_port)
module function_definition identifier parameters identifier block return_statement call identifier argument_list keyword_argument identifier binary_operator string string_start string_content string_end attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier
Provides access to all user resources
def abort_request(self, request): self.timedout = True try: request.cancel() except error.AlreadyCancelled: return
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier true try_statement block expression_statement call attribute identifier identifier argument_list except_clause attribute identifier identifier block return_statement
Called to abort request on timeout
def filter_directories(self): index = self.get_index('.spyproject') if index is not None: self.setRowHidden(index.row(), index.parent(), True)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list true
Filter the directories to show
def load_all_from_directory(self, directory_path): datas = [] for root, folders, files in os.walk(directory_path): for f in files: datas.append(self.load_from_file(os.path.join(root, f))) return datas
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list for_statement pattern_list identifier identifier identifier call attribute identifier identifier argument_list identifier block for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier return_statement identifier
Return a list of dict from a directory containing files
def _remove_decoration(self): if self._deco is not None: self.editor.decorations.remove(self._deco) self._deco = None
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier none
Removes the word under cursor's decoration
def GetRDFValueType(self): result = self.attribute_type for field_name in self.field_names: try: result = result.type_infos.get(field_name).type except AttributeError: raise AttributeError("Invalid attribute %s" % field_name) return result
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier for_statement identifier attribute identifier identifier block try_statement block expression_statement assignment identifier attribute call attribute attribute identifier identifier identifier argument_list identifier identifier except_clause identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier return_statement identifier
Returns this attribute's RDFValue class.
def _fitImg(self, img): img = imread(img, 'gray') if self.bg is not None: img = cv2.subtract(img, self.bg) if self.lens is not None: img = self.lens.correct(img, keepSize=True) (H, _, _, _, _, _, _, n_matches) = self.findHomography(img) H_inv = self.invertHomography(H) s = self.obj_shape fit = cv2.warpPerspective(img, H_inv, (s[1], s[0])) return fit, img, H, H_inv, n_matches
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier attribute identifier identifier if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier true expression_statement assignment tuple_pattern identifier identifier identifier identifier identifier identifier identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier tuple subscript identifier integer subscript identifier integer return_statement expression_list identifier identifier identifier identifier identifier
fit perspective and size of the input image to the reference image
def all_regions(self): regions = [] for sq in self._bam.header["SQ"]: regions.append((sq["SN"], 1, int(sq["LN"]))) return regions
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier subscript attribute attribute identifier identifier identifier 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 integer call identifier argument_list subscript identifier string string_start string_content string_end return_statement identifier
Get a tuple of all chromosome, start and end regions.
def _process_metadata_response(topics, zk, default_min_isr): not_in_sync_partitions = [] for topic_name, partitions in topics.items(): min_isr = get_min_isr(zk, topic_name) or default_min_isr if min_isr is None: continue for metadata in partitions.values(): cur_isr = len(metadata.isr) if cur_isr < min_isr: not_in_sync_partitions.append({ 'isr': cur_isr, 'min_isr': min_isr, 'topic': metadata.topic, 'partition': metadata.partition, }) return not_in_sync_partitions
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier list for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement assignment identifier boolean_operator call identifier argument_list identifier identifier identifier if_statement comparison_operator identifier none block continue_statement for_statement identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call identifier argument_list attribute identifier identifier if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list 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 attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier return_statement identifier
Returns not in sync partitions.
def add_space(window): row, col = window.getyx() _, max_cols = window.getmaxyx() n_cols = max_cols - col - 1 if n_cols <= 0: return window.addstr(row, col, ' ')
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list expression_statement assignment identifier binary_operator binary_operator identifier identifier integer if_statement comparison_operator identifier integer block return_statement expression_statement call attribute identifier identifier argument_list identifier identifier string string_start string_content string_end
Shortcut for adding a single space to a window at the current position
def filelist2html(lst, fldr, hasHeader='N'): txt = '<TABLE width=100% border=0>' numRows = 1 if lst: for l in lst: if hasHeader == 'Y': if numRows == 1: td_begin = '<TH>' td_end = '</TH>' else: td_begin = '<TD>' td_end = '</TD>' else: td_begin = '<TD>' td_end = '</TD>' numRows += 1 txt += '<TR>' if type(l) is str: txt += td_begin + link_file(l, fldr) + td_end elif type(l) is list: txt += td_begin for i in l: txt+= link_file(i, fldr) + '; ' txt += td_end else: txt += td_begin + str(l) + td_end txt += '</TR>\n' txt += '</TABLE><BR>\n' return txt
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier integer if_statement identifier block for_statement identifier identifier block if_statement comparison_operator identifier string string_start string_content string_end block if_statement comparison_operator identifier integer block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end else_clause block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end else_clause block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end expression_statement augmented_assignment identifier integer expression_statement augmented_assignment identifier string string_start string_content string_end if_statement comparison_operator call identifier argument_list identifier identifier block expression_statement augmented_assignment identifier binary_operator binary_operator identifier call identifier argument_list identifier identifier identifier elif_clause comparison_operator call identifier argument_list identifier identifier block expression_statement augmented_assignment identifier identifier for_statement identifier identifier block expression_statement augmented_assignment identifier binary_operator call identifier argument_list identifier identifier string string_start string_content string_end expression_statement augmented_assignment identifier identifier else_clause block expression_statement augmented_assignment identifier binary_operator binary_operator identifier call identifier argument_list identifier identifier expression_statement augmented_assignment identifier string string_start string_content escape_sequence string_end expression_statement augmented_assignment identifier string string_start string_content escape_sequence string_end return_statement identifier
formats a standard filelist to htmk using table formats
def fields(self): return ( self.locus, self.offset_start, self.offset_end, self.alignment_key)
module function_definition identifier parameters identifier block return_statement tuple attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier
Fields that should be considered for our notion of object equality.