code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def load( cls, name=None, parent_name=None, profile_is_live=False, values=None, defaults=None ) -> "EnvvarProfile": instance = cls( name=name, parent_name=parent_name, profile_is_live=profile_is_live, values=values, defaults=defaults, ) instance._do_load() return instance
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier false default_parameter identifier none default_parameter identifier none type string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list return_statement identifier
Get a loaded frozen instance of a specific profile.
def find_device_by_name(name): if not name: return DEFAULT_DEV with DEV_LOCK: for dev in DEVS: if dev.name == name: return dev return None
module function_definition identifier parameters identifier block if_statement not_operator identifier block return_statement identifier with_statement with_clause with_item identifier block for_statement identifier identifier block if_statement comparison_operator attribute identifier identifier identifier block return_statement identifier return_statement none
Tries to find a board by board name.
def initialize(self): self.time.update(self.components.initial_time()) self.time.stage = 'Initialization' super(Model, self).initialize()
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute attribute identifier identifier identifier string string_start string_content string_end expression_statement call attribute call identifier argument_list identifier identifier identifier argument_list
Initializes the simulation model
def file_exists(self) -> bool: cfg_path = self.file_path assert cfg_path return path.isfile(cfg_path)
module function_definition identifier parameters identifier type identifier block expression_statement assignment identifier attribute identifier identifier assert_statement identifier return_statement call attribute identifier identifier argument_list identifier
Check if the settings file exists or not
def _api_convert_output(return_value): content_type = web.ctx.environ.get('CONTENT_TYPE', 'text/json') if "text/json" in content_type: web.header('Content-Type', 'text/json; charset=utf-8') return json.dumps(return_value) if "text/html" in content_type: web.header('Content-Type', 'text/html; charset=utf-8') dump = yaml.dump(return_value) return "<pre>" + web.websafe(dump) + "</pre>" if "text/yaml" in content_type or \ "text/x-yaml" in content_type or \ "application/yaml" in content_type or \ "application/x-yaml" in content_type: web.header('Content-Type', 'text/yaml; charset=utf-8') dump = yaml.dump(return_value) return dump web.header('Content-Type', 'text/json; charset=utf-8') return json.dumps(return_value)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end return_statement call attribute identifier identifier argument_list identifier if_statement comparison_operator string string_start string_content string_end identifier block expression_statement 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 identifier return_statement binary_operator binary_operator string string_start string_content string_end call attribute identifier identifier argument_list identifier string string_start string_content string_end if_statement boolean_operator boolean_operator boolean_operator comparison_operator string string_start string_content string_end identifier comparison_operator string string_start string_content string_end identifier comparison_operator string string_start string_content string_end identifier comparison_operator string string_start string_content string_end identifier block expression_statement 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 identifier return_statement identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end return_statement call attribute identifier identifier argument_list identifier
Convert the output to what the client asks
def CreateConfigHBuilder(env): action = SCons.Action.Action(_createConfigH, _stringConfigH) sconfigHBld = SCons.Builder.Builder(action=action) env.Append( BUILDERS={'SConfigHBuilder':sconfigHBld} ) for k in list(_ac_config_hs.keys()): env.SConfigHBuilder(k, env.Value(_ac_config_hs[k]))
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier dictionary pair string string_start string_content string_end identifier for_statement identifier call identifier argument_list call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list subscript identifier identifier
Called if necessary just before the building targets phase begins.
def _updateEffects(self, time_passed): for name in self._effects: update_func = getattr( self, '_effectupdate_{}'.format(name.replace("-", "_")), ) update_func(time_passed)
module function_definition identifier parameters identifier identifier block for_statement identifier attribute identifier identifier block expression_statement assignment identifier call identifier argument_list identifier call attribute string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement call identifier argument_list identifier
Update method for the effects handle
def import_keybase(useropt): public_key = None u_bits = useropt.split(':') username = u_bits[0] if len(u_bits) == 1: public_key = cryptorito.key_from_keybase(username) else: fingerprint = u_bits[1] public_key = cryptorito.key_from_keybase(username, fingerprint) if cryptorito.has_gpg_key(public_key['fingerprint']): sys.exit(2) cryptorito.import_gpg_key(public_key['bundle'].encode('ascii')) sys.exit(0)
module function_definition identifier parameters identifier block expression_statement assignment identifier none expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier subscript identifier integer if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier call attribute identifier identifier argument_list identifier else_clause block expression_statement assignment identifier subscript identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier if_statement call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list integer expression_statement call attribute identifier identifier argument_list call attribute subscript identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list integer
Imports a public GPG key from Keybase
def post(self, path, **kwargs): resp = self._session.post(self._url(path), **self._builder(**kwargs)) if 'stream' in kwargs: return resp else: return self._resp_error_check(resp)
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list identifier dictionary_splat call attribute identifier identifier argument_list dictionary_splat identifier if_statement comparison_operator string string_start string_content string_end identifier block return_statement identifier else_clause block return_statement call attribute identifier identifier argument_list identifier
Calls the specified path with the POST method
def full_path(self): with self._mutex: if self._parent: return self._parent.full_path + [self._name] else: return [self._name]
module function_definition identifier parameters identifier block with_statement with_clause with_item attribute identifier identifier block if_statement attribute identifier identifier block return_statement binary_operator attribute attribute identifier identifier identifier list attribute identifier identifier else_clause block return_statement list attribute identifier identifier
The full path of this node.
def decompose(self): self.extract() if len(self.contents) == 0: return current = self.contents[0] while current is not None: next = current.next if isinstance(current, Tag): del current.contents[:] current.parent = None current.previous = None current.previousSibling = None current.next = None current.nextSibling = None current = next
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list if_statement comparison_operator call identifier argument_list attribute identifier identifier integer block return_statement expression_statement assignment identifier subscript attribute identifier identifier integer while_statement comparison_operator identifier none block expression_statement assignment identifier attribute identifier identifier if_statement call identifier argument_list identifier identifier block delete_statement subscript attribute identifier identifier slice expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier none expression_statement assignment identifier identifier
Recursively destroys the contents of this tree.
def inventory(uri, format): base_uri = dtoolcore.utils.sanitise_uri(uri) info = _base_uri_info(base_uri) if format is None: _cmd_line_report(info) elif format == "csv": _csv_tsv_report(info, ",") elif format == "tsv": _csv_tsv_report(info, "\t") elif format == "html": _html_report(info)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement call identifier argument_list identifier elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement call identifier argument_list identifier string string_start string_content string_end elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement call identifier argument_list identifier string string_start string_content escape_sequence string_end elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement call identifier argument_list identifier
Generate an inventory of datasets in a base URI.
def _cache_directory(self): if settings.unit_testing_mode or settings.use_test_cache: return os.path.join(settings.cache_directory.replace("Fortpy", "Fortpy_Testing"), self.py_tag) else: return os.path.join(settings.cache_directory, self.py_tag)
module function_definition identifier parameters identifier block if_statement boolean_operator attribute identifier identifier attribute identifier identifier block return_statement call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end attribute identifier identifier else_clause block return_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier attribute identifier identifier
Returns the full path to the cache directory as specified in settings.
def _interface_to_service(iface): for _service in _get_services(): service_info = pyconnman.ConnService(os.path.join(SERVICE_PATH, _service)) if service_info.get_property('Ethernet')['Interface'] == iface: return _service return None
module function_definition identifier parameters identifier block for_statement identifier call identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier if_statement comparison_operator subscript call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier block return_statement identifier return_statement none
returns the coresponding service to given interface if exists, otherwise return None
def handle_json_GET_neareststops(self, params): schedule = self.server.schedule lat = float(params.get('lat')) lon = float(params.get('lon')) limit = int(params.get('limit')) stops = schedule.GetNearestStops(lat=lat, lon=lon, n=limit) return [StopToTuple(s) for s in stops]
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier return_statement list_comprehension call identifier argument_list identifier for_in_clause identifier identifier
Return a list of the nearest 'limit' stops to 'lat', 'lon
def cache_page(page_cache, page_hash, cache_size): page_cache.append(page_hash) if len(page_cache) > cache_size: page_cache.pop(0)
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list identifier if_statement comparison_operator call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list integer
Add a page to the page cache.
def execute_script(self, sql_script=None, commands=None, split_algo='sql_split', prep_statements=False, dump_fails=True, execute_fails=True, ignored_commands=('DROP', 'UNLOCK', 'LOCK')): ss = Execute(sql_script, split_algo, prep_statements, dump_fails, self) ss.execute(commands, ignored_commands=ignored_commands, execute_fails=execute_fails)
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier string string_start string_content string_end default_parameter identifier false default_parameter identifier true default_parameter identifier true default_parameter 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 assignment identifier call identifier argument_list identifier identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier
Wrapper method for SQLScript class.
def from_dict(cls, eas_from_nios): if not eas_from_nios: return return cls({name: cls._process_value(ib_utils.try_value_to_bool, eas_from_nios[name]['value']) for name in eas_from_nios})
module function_definition identifier parameters identifier identifier block if_statement not_operator identifier block return_statement return_statement call identifier argument_list dictionary_comprehension pair identifier call attribute identifier identifier argument_list attribute identifier identifier subscript subscript identifier identifier string string_start string_content string_end for_in_clause identifier identifier
Converts extensible attributes from the NIOS reply.
def updateColormap(self): if self.imgArgs['lut'] is not None: self.img.setLookupTable(self.imgArgs['lut']) self.img.setLevels(self.imgArgs['levels'])
module function_definition identifier parameters identifier block if_statement comparison_operator subscript attribute identifier identifier string string_start string_content string_end none block expression_statement call attribute attribute identifier identifier identifier argument_list subscript attribute identifier identifier string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list subscript attribute identifier identifier string string_start string_content string_end
Updates the currently colormap accoring to stored settings
def generate_username(self, user_class): m = getattr(user_class, 'generate_username', None) if m: return m() else: max_length = user_class._meta.get_field( self.username_field).max_length return uuid.uuid4().hex[:max_length]
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end none if_statement identifier block return_statement call identifier argument_list else_clause block expression_statement assignment identifier attribute call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier return_statement subscript attribute call attribute identifier identifier argument_list identifier slice identifier
Generate a new username for a user
def from_mediaid(cls, context: InstaloaderContext, mediaid: int): return cls.from_shortcode(context, Post.mediaid_to_shortcode(mediaid))
module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_parameter identifier type identifier block return_statement call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier
Create a post object from a given mediaid
def start_transfer(self): try: if not self.is_done(): faspmanager2.startTransfer(self.get_transfer_id(), None, self.get_transfer_spec(), self) except Exception as ex: self.notify_exception(ex)
module function_definition identifier parameters identifier block try_statement block if_statement not_operator call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list none call attribute identifier identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier
pass the transfer spec to the Aspera sdk and start the transfer
def WriteClientGraphSeries( self, graph_series, client_label, timestamp, cursor=None, ): args = { "client_label": client_label, "report_type": graph_series.report_type.SerializeToDataStore(), "timestamp": mysql_utils.RDFDatetimeToTimestamp(timestamp), "graph_series": graph_series.SerializeToString(), } query = cursor.execute(query, args)
module function_definition identifier parameters identifier identifier identifier identifier default_parameter identifier none block expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list pair string string_start string_content string_end call attribute identifier identifier argument_list identifier pair string string_start string_content string_end call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier
Writes the provided graphs to the DB with the given client label.
def CUnescape(text): def ReplaceHex(m): if len(m.group(1)) & 1: return m.group(1) + 'x0' + m.group(2) return m.group(0) result = _CUNESCAPE_HEX.sub(ReplaceHex, text) if str is bytes: return result.decode('string_escape') result = ''.join(_cescape_highbit_to_str[ord(c)] for c in result) return (result.encode('ascii') .decode('unicode_escape') .encode('raw_unicode_escape'))
module function_definition identifier parameters identifier block function_definition identifier parameters identifier block if_statement binary_operator call identifier argument_list call attribute identifier identifier argument_list integer integer block return_statement binary_operator binary_operator call attribute identifier identifier argument_list integer string string_start string_content string_end call attribute identifier identifier argument_list integer return_statement call attribute identifier identifier argument_list integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier if_statement comparison_operator identifier identifier block return_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute string string_start string_end identifier generator_expression subscript identifier call identifier argument_list identifier for_in_clause identifier identifier return_statement parenthesized_expression call attribute call attribute call attribute identifier identifier argument_list string string_start string_content string_end identifier argument_list string string_start string_content string_end identifier argument_list string string_start string_content string_end
Unescape a text string with C-style escape sequences to UTF-8 bytes.
def _update_callsafety(self, response): if self.ratelimit is not None: self.callsafety['lastcalltime'] = time() self.callsafety['lastlimitremaining'] = int(response.headers.get('X-Rate-Limit-Remaining', 0))
module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end call identifier argument_list expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end call identifier argument_list call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end integer
Update the callsafety data structure
def format_axis(ax, label_padding=2, tick_padding=0, yticks_position='left'): ax.xaxis.set_ticks_position('bottom') ax.yaxis.set_ticks_position(yticks_position) ax.yaxis.set_tick_params(which='both', direction='out', labelsize=fontsize, pad=tick_padding, length=2, width=0.5) ax.xaxis.set_tick_params(which='both', direction='out', labelsize=fontsize, pad=tick_padding, length=2, width=0.5) ax.xaxis.labelpad = label_padding ax.yaxis.labelpad = label_padding ax.xaxis.label.set_size(fontsize) ax.yaxis.label.set_size(fontsize)
module function_definition identifier parameters identifier default_parameter identifier integer default_parameter identifier integer default_parameter identifier string string_start string_content string_end block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement 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 keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier integer keyword_argument identifier float expression_statement 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 keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier integer keyword_argument identifier float expression_statement assignment attribute attribute identifier identifier identifier identifier expression_statement assignment attribute attribute identifier identifier identifier identifier expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier
Set standardized axis formatting for figure.
def deparent_unreachable( reachable, shared ): for id,shares in shared.iteritems(): if id in reachable: filtered = [ x for x in shares if x in reachable ] if len(filtered) != len(shares): shares[:] = filtered
module function_definition identifier parameters identifier identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement comparison_operator identifier identifier block expression_statement assignment identifier list_comprehension identifier for_in_clause identifier identifier if_clause comparison_operator identifier identifier if_statement comparison_operator call identifier argument_list identifier call identifier argument_list identifier block expression_statement assignment subscript identifier slice identifier
Eliminate all parent-links from unreachable objects from reachable objects
def important_dates(year=None): year = datetime.now().year if not year else year data = mlbgame.info.important_dates(year) return mlbgame.info.ImportantDates(data)
module function_definition identifier parameters default_parameter identifier none block expression_statement assignment identifier conditional_expression attribute call attribute identifier identifier argument_list identifier not_operator identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier return_statement call attribute attribute identifier identifier identifier argument_list identifier
Return ImportantDates object that contains MLB important dates
def _geograins(self): from geoid.civick import GVid geo_grains = {} for sl, cls in GVid.sl_map.items(): if '_' not in cls.level: geo_grains[self.stem(cls.level)] = str(cls.nullval().summarize()) return geo_grains
module function_definition identifier parameters identifier block import_from_statement dotted_name identifier identifier dotted_name identifier expression_statement assignment identifier dictionary for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block expression_statement assignment subscript identifier call attribute identifier identifier argument_list attribute identifier identifier call identifier argument_list call attribute call attribute identifier identifier argument_list identifier argument_list return_statement identifier
Create a map geographic area terms to the geo grain GVid values
def map_announce2alias(url): import urlparse for alias, urls in announce.items(): if any(i == url for i in urls): return alias parts = urlparse.urlparse(url) server = urlparse.urlunparse((parts.scheme, parts.netloc, "/", None, None, None)) for alias, urls in announce.items(): if any(i.startswith(server) for i in urls): return alias try: return '.'.join(parts.netloc.split(':')[0].split('.')[-2:]) except IndexError: return parts.netloc
module function_definition identifier parameters identifier block import_statement dotted_name identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement call identifier generator_expression comparison_operator identifier identifier for_in_clause identifier identifier block return_statement identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list tuple attribute identifier identifier attribute identifier identifier string string_start string_content string_end none none none for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement call identifier generator_expression call attribute identifier identifier argument_list identifier for_in_clause identifier identifier block return_statement identifier try_statement block return_statement call attribute string string_start string_content string_end identifier argument_list subscript call attribute subscript call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end integer identifier argument_list string string_start string_content string_end slice unary_operator integer except_clause identifier block return_statement attribute identifier identifier
Get tracker alias for announce URL, and if none is defined, the 2nd level domain.
def on_use_runtime_value_toggled(self, widget, path): try: data_port_id = self.list_store[path][self.ID_STORAGE_ID] self.toggle_runtime_value_usage(data_port_id) except TypeError as e: logger.exception("Error while trying to change the use_runtime_value flag")
module function_definition identifier parameters identifier identifier identifier block try_statement block expression_statement assignment identifier subscript subscript attribute identifier identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list 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
Try to set the use runtime value flag to the newly entered one
def xmoe2_v1_x128(): hparams = xmoe2_v1() hparams.moe_num_experts = [16, 8] hparams.outer_batch_size = 8 hparams.mesh_shape = "b0:8;b1:16" hparams.batch_size = 512 hparams.learning_rate_decay_steps = 16384 return hparams
module function_definition identifier parameters block expression_statement assignment identifier call identifier argument_list expression_statement assignment attribute identifier identifier list integer integer expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier integer return_statement identifier
128 experts, ~25B params - Train for 131072 steps on 8x8.
def _parse_absorption(line, lines): split_line = line.split() energy = float(split_line[0]) re_sigma_xx = float(split_line[1]) re_sigma_zz = float(split_line[2]) absorp_xx = float(split_line[3]) absorp_zz = float(split_line[4]) return {"energy": energy, "re_sigma_xx": re_sigma_xx, "re_sigma_zz": re_sigma_zz, "absorp_xx": absorp_xx, "absorp_zz": absorp_zz}
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list subscript identifier integer expression_statement assignment identifier call identifier argument_list subscript identifier integer expression_statement assignment identifier call identifier argument_list subscript identifier integer expression_statement assignment identifier call identifier argument_list subscript identifier integer expression_statement assignment identifier call identifier argument_list subscript identifier integer return_statement dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier
Parse Energy, Re sigma xx, Re sigma zz, absorp xx, absorp zz
def getargspec(f): spec = getfullargspec(f) return ArgSpec(spec.args, spec.varargs, spec.varkw, spec.defaults)
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier return_statement call identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier
A replacement for inspect.getargspec
def create_api_v4_as(self): return ApiV4As( self.networkapi_url, self.user, self.password, self.user_ldap)
module function_definition identifier parameters identifier block return_statement call identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier
Get an instance of Api As services facade.
def abort(self, err): if _debug: IOQueue._debug("abort %r", err) try: for iocb in self.queue: iocb.ioQueue = None iocb.abort(err) self.queue = [] self.notempty.clear() except ValueError: pass
module function_definition identifier parameters identifier identifier block if_statement identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier try_statement block for_statement identifier attribute identifier identifier block expression_statement assignment attribute identifier identifier none expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier list expression_statement call attribute attribute identifier identifier identifier argument_list except_clause identifier block pass_statement
Abort all of the control blocks in the queue.
def parse_resources(self, resources): self.resources = {} resource_factory = ResourceFactory() for res_id, res_value in resources.items(): r = resource_factory.create_resource(res_id, res_value) if r: if r.resource_type in self.resources: self.resources[r.resource_type].append(r) else: self.resources[r.resource_type] = [r]
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier dictionary expression_statement assignment identifier call identifier argument_list for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier if_statement identifier block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement call attribute subscript attribute identifier identifier attribute identifier identifier identifier argument_list identifier else_clause block expression_statement assignment subscript attribute identifier identifier attribute identifier identifier list identifier
Parses and sets resources in the model using a factory.
def _ycbcr2l(self, mode): self._check_modes(("YCbCr", "YCbCrA")) self.channels = [self.channels[0]] + self.channels[3:] if self.fill_value is not None: self.fill_value = [self.fill_value[0]] + self.fill_value[3:] self.mode = mode
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list tuple string string_start string_content string_end string string_start string_content string_end expression_statement assignment attribute identifier identifier binary_operator list subscript attribute identifier identifier integer subscript attribute identifier identifier slice integer if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier binary_operator list subscript attribute identifier identifier integer subscript attribute identifier identifier slice integer expression_statement assignment attribute identifier identifier identifier
Convert from YCbCr to L.
def camelcase2list(s, lower=False): s = re.findall(r'([A-Z][a-z0-9]+)', s) return [w.lower() for w in s] if lower else s
module function_definition identifier parameters identifier default_parameter identifier false block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement conditional_expression list_comprehension call attribute identifier identifier argument_list for_in_clause identifier identifier identifier identifier
Converts a camelcase string to a list.
def append(self, item): self.beginInsertRows(QtCore.QModelIndex(), self.rowCount(), self.rowCount()) self.items.append(item) self.endInsertRows()
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list
Append item to end of model
def _send_data(self, data): total_sent = 0 while total_sent < len(data): sent = self.socket.send(data[total_sent:].encode("ascii")) if sent == 0: self.close() raise RuntimeError("Socket connection dropped, " "send failed") total_sent += sent
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier integer while_statement comparison_operator identifier call identifier argument_list identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute subscript identifier slice identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier integer block expression_statement call attribute identifier identifier argument_list raise_statement call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end expression_statement augmented_assignment identifier identifier
Send data to the ADB server
def bench(participants=participants, benchmarks=benchmarks, bench_time=BENCH_TIME): mcs = [p.factory() for p in participants] means = [[] for p in participants] stddevs = [[] for p in participants] last_fn = None for benchmark_name, fn, args, kwargs in benchmarks: logger.info('') logger.info('%s', benchmark_name) for i, (participant, mc) in enumerate(zip(participants, mcs)): if 'get' in fn.__name__: last_fn(mc, *args, **kwargs) sw = Stopwatch() while sw.total() < bench_time: with sw.timing(): fn(mc, *args, **kwargs) means[i].append(sw.mean()) stddevs[i].append(sw.stddev()) logger.info(u'%76s: %s', participant.name, sw) last_fn = fn return means, stddevs
module function_definition identifier parameters default_parameter identifier identifier default_parameter identifier identifier default_parameter identifier identifier block expression_statement assignment identifier list_comprehension call attribute identifier identifier argument_list for_in_clause identifier identifier expression_statement assignment identifier list_comprehension list for_in_clause identifier identifier expression_statement assignment identifier list_comprehension list for_in_clause identifier identifier expression_statement assignment identifier none for_statement pattern_list identifier identifier identifier identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier for_statement pattern_list identifier tuple_pattern identifier identifier call identifier argument_list call identifier argument_list identifier identifier block if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block expression_statement call identifier argument_list identifier list_splat identifier dictionary_splat identifier expression_statement assignment identifier call identifier argument_list while_statement comparison_operator call attribute identifier identifier argument_list identifier block with_statement with_clause with_item call attribute identifier identifier argument_list block expression_statement call identifier argument_list identifier list_splat identifier dictionary_splat identifier expression_statement call attribute subscript identifier identifier identifier argument_list call attribute identifier identifier argument_list expression_statement call attribute subscript identifier identifier identifier argument_list call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier identifier expression_statement assignment identifier identifier return_statement expression_list identifier identifier
Do you even lift?
def str_to_num(i, exact_match=True): if not isinstance(i, str): return i try: if not exact_match: return int(i) elif str(int(i)) == i: return int(i) elif str(float(i)) == i: return float(i) else: pass except ValueError: pass return i
module function_definition identifier parameters identifier default_parameter identifier true block if_statement not_operator call identifier argument_list identifier identifier block return_statement identifier try_statement block if_statement not_operator identifier block return_statement call identifier argument_list identifier elif_clause comparison_operator call identifier argument_list call identifier argument_list identifier identifier block return_statement call identifier argument_list identifier elif_clause comparison_operator call identifier argument_list call identifier argument_list identifier identifier block return_statement call identifier argument_list identifier else_clause block pass_statement except_clause identifier block pass_statement return_statement identifier
Attempts to convert a str to either an int or float
def md5_digest(instr): return salt.utils.stringutils.to_unicode( hashlib.md5(salt.utils.stringutils.to_bytes(instr)).hexdigest() )
module function_definition identifier parameters identifier block return_statement call attribute attribute attribute identifier identifier identifier identifier argument_list call attribute call attribute identifier identifier argument_list call attribute attribute attribute identifier identifier identifier identifier argument_list identifier identifier argument_list
Generate an md5 hash of a given string.
def commit(*args, **kwargs): delayed_queue = get_queue() try: while delayed_queue: queue, args, kwargs = delayed_queue.pop(0) queue.original_enqueue_call(*args, **kwargs) finally: clear()
module function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list try_statement block while_statement identifier block expression_statement assignment pattern_list identifier identifier identifier call attribute identifier identifier argument_list integer expression_statement call attribute identifier identifier argument_list list_splat identifier dictionary_splat identifier finally_clause block expression_statement call identifier argument_list
Processes all jobs in the delayed queue.
def attention_lm_moe_24b_diet(): hparams = attention_lm_moe_large_diet() hparams.moe_hidden_sizes = "12288" hparams.moe_num_experts = 1024 hparams.batch_size = 4096 return hparams
module function_definition identifier parameters block expression_statement assignment identifier call identifier argument_list expression_statement assignment attribute identifier identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier integer return_statement identifier
Unnecessarily large model with 24B params - because we can.
def list_subdomains(self, domain, limit=None, offset=None): uri = "/domains?name=%s" % domain.name page_qs = self._get_pagination_qs(limit, offset) if page_qs: uri = "%s&%s" % (uri, page_qs[1:]) return self._list_subdomains(uri, domain.id)
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier binary_operator string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier if_statement identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple identifier subscript identifier slice integer return_statement call attribute identifier identifier argument_list identifier attribute identifier identifier
Returns a list of all subdomains of the specified domain.
def SvcStop(self) -> None: self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) win32event.SetEvent(self.h_stop_event)
module function_definition identifier parameters identifier type none block expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier
Called when the service is being shut down.
def args_to_int(mapping, argument): if isinstance(argument, int): if argument == 0: return 0 deprecation('passing extensions and flags as constants is deprecated') return argument elif isinstance(argument, (tuple, list)): return reduce(op.or_, [mapping[n] for n in set(argument) if n in mapping], 0) raise TypeError('argument must be a list of strings or an int')
module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier identifier block if_statement comparison_operator identifier integer block return_statement integer expression_statement call identifier argument_list string string_start string_content string_end return_statement identifier elif_clause call identifier argument_list identifier tuple identifier identifier block return_statement call identifier argument_list attribute identifier identifier list_comprehension subscript identifier identifier for_in_clause identifier call identifier argument_list identifier if_clause comparison_operator identifier identifier integer raise_statement call identifier argument_list string string_start string_content string_end
Convert list of strings to an int using a mapping.
def normalize_so_name(name): if "cpython" in name: return os.path.splitext(os.path.splitext(name)[0])[0] if name == "timemodule.so": return "time" return os.path.splitext(name)[0]
module function_definition identifier parameters identifier block if_statement comparison_operator string string_start string_content string_end identifier block return_statement subscript call attribute attribute identifier identifier identifier argument_list subscript call attribute attribute identifier identifier identifier argument_list identifier integer integer if_statement comparison_operator identifier string string_start string_content string_end block return_statement string string_start string_content string_end return_statement subscript call attribute attribute identifier identifier identifier argument_list identifier integer
Handle different types of python installations
def label(self): if self.valuetype_class.is_label(): return self for c in self.table.columns: if c.parent == self.name and c.valuetype_class.is_label(): return c return None
module function_definition identifier parameters identifier block if_statement call attribute attribute identifier identifier identifier argument_list block return_statement identifier for_statement identifier attribute attribute identifier identifier identifier block if_statement boolean_operator comparison_operator attribute identifier identifier attribute identifier identifier call attribute attribute identifier identifier identifier argument_list block return_statement identifier return_statement none
Return first child of the column that is marked as a label. Returns self if the column is a label
def _get_repo_info(alias, repos_cfg=None, root=None): try: meta = dict((repos_cfg or _get_configured_repos(root=root)).items(alias)) meta['alias'] = alias for key, val in six.iteritems(meta): if val in ['0', '1']: meta[key] = int(meta[key]) == 1 elif val == 'NONE': meta[key] = None return meta except (ValueError, configparser.NoSectionError): return {}
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none block try_statement block expression_statement assignment identifier call identifier argument_list call attribute parenthesized_expression boolean_operator identifier call identifier argument_list keyword_argument identifier identifier identifier argument_list identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list identifier block if_statement comparison_operator identifier list string string_start string_content string_end string string_start string_content string_end block expression_statement assignment subscript identifier identifier comparison_operator call identifier argument_list subscript identifier identifier integer elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement assignment subscript identifier identifier none return_statement identifier except_clause tuple identifier attribute identifier identifier block return_statement dictionary
Get one repo meta-data.
def surface_areas(self): e_1 = self.v[self.f[:, 1]] - self.v[self.f[:, 0]] e_2 = self.v[self.f[:, 2]] - self.v[self.f[:, 0]] cross_products = np.array([e_1[:, 1]*e_2[:, 2] - e_1[:, 2]*e_2[:, 1], e_1[:, 2]*e_2[:, 0] - e_1[:, 0]*e_2[:, 2], e_1[:, 0]*e_2[:, 1] - e_1[:, 1]*e_2[:, 0]]).T return (0.5)*((cross_products**2.).sum(axis=1)**0.5)
module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator subscript attribute identifier identifier subscript attribute identifier identifier slice integer subscript attribute identifier identifier subscript attribute identifier identifier slice integer expression_statement assignment identifier binary_operator subscript attribute identifier identifier subscript attribute identifier identifier slice integer subscript attribute identifier identifier subscript attribute identifier identifier slice integer expression_statement assignment identifier attribute call attribute identifier identifier argument_list list binary_operator binary_operator subscript identifier slice integer subscript identifier slice integer binary_operator subscript identifier slice integer subscript identifier slice integer binary_operator binary_operator subscript identifier slice integer subscript identifier slice integer binary_operator subscript identifier slice integer subscript identifier slice integer binary_operator binary_operator subscript identifier slice integer subscript identifier slice integer binary_operator subscript identifier slice integer subscript identifier slice integer identifier return_statement binary_operator parenthesized_expression float parenthesized_expression binary_operator call attribute parenthesized_expression binary_operator identifier float identifier argument_list keyword_argument identifier integer float
returns the surface area of each face
def make_default_logger(name=INTERNAL_LOGGER_NAME, level=logging.INFO, fmt='%(asctime)s - %(name)s - %(levelname)s - %(message)s'): logger = logging.getLogger(name) logger.setLevel(level) if not logger.handlers: handler = logging.StreamHandler(sys.stderr) handler.setLevel(level) formatter = logging.Formatter(fmt) handler.setFormatter(formatter) logger.addHandler(handler) return logger
module function_definition identifier parameters default_parameter identifier identifier default_parameter identifier attribute identifier identifier default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier if_statement not_operator attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Create a logger with the default configuration
def _initIndexDir(self): if not os.path.exists(self.logdir): os.mkdir(self.logdir) dprint(1, "created", self.logdir) Purr.RenderIndex.initIndexDir(self.logdir)
module function_definition identifier parameters identifier block if_statement not_operator call attribute attribute identifier identifier identifier argument_list attribute identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call identifier argument_list integer string string_start string_content string_end attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier
makes sure purrlog directory is properly set up
def MakeDeployableBinary(self, template_path, output_path): context = self.context + ["Client Context"] utils.EnsureDirExists(os.path.dirname(output_path)) client_config_data = self.GetClientConfig(context) shutil.copyfile(template_path, output_path) zip_file = zipfile.ZipFile(output_path, mode="a") zip_info = zipfile.ZipInfo(filename="config.yaml") zip_file.writestr(zip_info, client_config_data) zip_file.close() return output_path
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier binary_operator attribute identifier identifier list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list return_statement identifier
This will add the config to the client template.
def clean_pred(self, pred, ignore_warning=False): original_pred = pred pred = pred.lower().strip() if 'http' in pred: pred = pred.split('/')[-1] elif ':' in pred: if pred[-1] != ':': pred = pred.split(':')[-1] else: if not ignore_warning: exit('Not a valid predicate: ' + original_pred + '. Needs to be an iri "/" or curie ":".') return pred
module function_definition identifier parameters identifier identifier default_parameter identifier false block expression_statement assignment identifier identifier expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment identifier subscript call attribute identifier identifier argument_list string string_start string_content string_end unary_operator integer elif_clause comparison_operator string string_start string_content string_end identifier block if_statement comparison_operator subscript identifier unary_operator integer string string_start string_content string_end block expression_statement assignment identifier subscript call attribute identifier identifier argument_list string string_start string_content string_end unary_operator integer else_clause block if_statement not_operator identifier block expression_statement call identifier argument_list binary_operator binary_operator string string_start string_content string_end identifier string string_start string_content string_end return_statement identifier
Takes the predicate and returns the suffix, lower case, stripped version
def append_note(self, player, text): note = self._find_note(player) note.text += text
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement augmented_assignment attribute identifier identifier identifier
Append text to an already existing note.
def call_with_retry(func: Callable, exceptions, max_retries: int, logger: Logger, *args, **kwargs): attempt = 0 while True: try: return func(*args, **kwargs) except exceptions as e: attempt += 1 if attempt >= max_retries: raise delay = exponential_backoff(attempt, cap=60) logger.warning('%s: retrying in %s', e, delay) time.sleep(delay.total_seconds())
module function_definition identifier parameters typed_parameter identifier type identifier identifier typed_parameter identifier type identifier typed_parameter identifier type identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier integer while_statement true block try_statement block return_statement call identifier argument_list list_splat identifier dictionary_splat identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement augmented_assignment identifier integer if_statement comparison_operator identifier identifier block raise_statement expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier integer expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list
Call a function and retry it on failure.
def score_small_straight_yahztee(dice: List[int]) -> int: global CONSTANT_SCORES_YAHTZEE dice_set = set(dice) if _are_two_sets_equal({1, 2, 3, 4}, dice_set) or \ _are_two_sets_equal({2, 3, 4, 5}, dice_set) or \ _are_two_sets_equal({3, 4, 5, 6}, dice_set): return CONSTANT_SCORES_YAHTZEE[Category.SMALL_STRAIGHT] return 0
module function_definition identifier parameters typed_parameter identifier type generic_type identifier type_parameter type identifier type identifier block global_statement identifier expression_statement assignment identifier call identifier argument_list identifier if_statement boolean_operator boolean_operator call identifier argument_list set integer integer integer integer identifier line_continuation call identifier argument_list set integer integer integer integer identifier line_continuation call identifier argument_list set integer integer integer integer identifier block return_statement subscript identifier attribute identifier identifier return_statement integer
Small straight scoring according to regular yahtzee rules
def shortname(inputid): parsed_id = urllib.parse.urlparse(inputid) if parsed_id.fragment: return parsed_id.fragment.split(u"/")[-1] return parsed_id.path.split(u"/")[-1]
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement attribute identifier identifier block return_statement subscript call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end unary_operator integer return_statement subscript call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end unary_operator integer
Returns the last segment of the provided fragment or path.
def sequence_to_graph(G, seq, color='black'): for x in seq: if x.endswith("_1"): G.node(x, color=color, width="0.1", shape="circle", label="") else: G.node(x, color=color) for a, b in pairwise(seq): G.edge(a, b, color=color)
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end block for_statement identifier identifier block if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_end else_clause block expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier for_statement pattern_list identifier identifier call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier identifier keyword_argument identifier identifier
Automatically construct graph given a sequence of characters.
def pb2dict(obj): adict = {} if not obj.IsInitialized(): return None for field in obj.DESCRIPTOR.fields: if not getattr(obj, field.name): continue if not field.label == FD.LABEL_REPEATED: if not field.type == FD.TYPE_MESSAGE: adict[field.name] = getattr(obj, field.name) else: value = pb2dict(getattr(obj, field.name)) if value: adict[field.name] = value else: if field.type == FD.TYPE_MESSAGE: adict[field.name] = \ [pb2dict(v) for v in getattr(obj, field.name)] else: adict[field.name] = [v for v in getattr(obj, field.name)] return adict
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary if_statement not_operator call attribute identifier identifier argument_list block return_statement none for_statement identifier attribute attribute identifier identifier identifier block if_statement not_operator call identifier argument_list identifier attribute identifier identifier block continue_statement if_statement not_operator comparison_operator attribute identifier identifier attribute identifier identifier block if_statement not_operator comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment subscript identifier attribute identifier identifier call identifier argument_list identifier attribute identifier identifier else_clause block expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier attribute identifier identifier if_statement identifier block expression_statement assignment subscript identifier attribute identifier identifier identifier else_clause block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment subscript identifier attribute identifier identifier line_continuation list_comprehension call identifier argument_list identifier for_in_clause identifier call identifier argument_list identifier attribute identifier identifier else_clause block expression_statement assignment subscript identifier attribute identifier identifier list_comprehension identifier for_in_clause identifier call identifier argument_list identifier attribute identifier identifier return_statement identifier
Takes a ProtoBuf Message obj and convertes it to a dict.
def print_tally(self): self.update_count = self.upload_count - self.create_count if self.test_run: print("Test run complete with the following results:") print("Skipped {0}. Created {1}. Updated {2}. Deleted {3}.".format( self.skip_count, self.create_count, self.update_count, self.delete_count))
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier binary_operator attribute identifier identifier attribute identifier identifier if_statement attribute identifier identifier block expression_statement call identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier
Prints the final tally to stdout.
def black(cls): "Make the text foreground color black." wAttributes = cls._get_text_attributes() wAttributes &= ~win32.FOREGROUND_MASK cls._set_text_attributes(wAttributes)
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement augmented_assignment identifier unary_operator attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier
Make the text foreground color black.
def ranker(self, X, meta): total_score = X.sum(axis=1).transpose() total_score = np.squeeze(np.asarray(total_score)) ranks = total_score.argsort() ranks = ranks[::-1] sorted_meta = [meta[r] for r in ranks] sorted_X = X[ranks] return (sorted_X, sorted_meta)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list keyword_argument identifier integer identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier subscript identifier slice unary_operator integer expression_statement assignment identifier list_comprehension subscript identifier identifier for_in_clause identifier identifier expression_statement assignment identifier subscript identifier identifier return_statement tuple identifier identifier
Sort the place features list by the score of its relevance.
def show_loadbalancer(self, lbaas_loadbalancer, **_params): return self.get(self.lbaas_loadbalancer_path % (lbaas_loadbalancer), params=_params)
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block return_statement call attribute identifier identifier argument_list binary_operator attribute identifier identifier parenthesized_expression identifier keyword_argument identifier identifier
Fetches information for a load balancer.
def list_build_configurations_for_product(id=None, name=None, page_size=200, page_index=0, sort="", q=""): data = list_build_configurations_for_product_raw(id, name, page_size, page_index, sort, q) if data: return utils.format_json_list(data)
module function_definition identifier parameters default_parameter identifier none default_parameter identifier none default_parameter identifier integer default_parameter identifier integer default_parameter identifier string string_start string_end default_parameter identifier string string_start string_end block expression_statement assignment identifier call identifier argument_list identifier identifier identifier identifier identifier identifier if_statement identifier block return_statement call attribute identifier identifier argument_list identifier
List all BuildConfigurations associated with the given Product.
def using_bzr(cwd): try: bzr_log = shell_out(["bzr", "log"], cwd=cwd) return True except (CalledProcessError, OSError): return False
module function_definition identifier parameters identifier block try_statement block expression_statement assignment identifier call identifier argument_list list string string_start string_content string_end string string_start string_content string_end keyword_argument identifier identifier return_statement true except_clause tuple identifier identifier block return_statement false
Test whether the directory cwd is contained in a bazaar repository.
def google(rest): "Look up a phrase on google" API_URL = 'https://www.googleapis.com/customsearch/v1?' try: key = pmxbot.config['Google API key'] except KeyError: return "Configure 'Google API key' in config" custom_search = '004862762669074674786:hddvfu0gyg0' params = dict( key=key, cx=custom_search, q=rest.strip(), ) url = API_URL + urllib.parse.urlencode(params) resp = requests.get(url) resp.raise_for_status() results = resp.json() hit1 = next(iter(results['items'])) return ' - '.join(( urllib.parse.unquote(hit1['link']), hit1['title'], ))
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end try_statement block expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end except_clause identifier block return_statement string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier call attribute identifier identifier argument_list expression_statement assignment identifier binary_operator identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list call identifier argument_list subscript identifier string string_start string_content string_end return_statement call attribute string string_start string_content string_end identifier argument_list tuple call attribute attribute identifier identifier identifier argument_list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end
Look up a phrase on google
def create(self, data, refresh=False): self.__model__.create(self.__five9__, data) if refresh: return self.read(data[self.__model__.__name__]) else: return self.new(data)
module function_definition identifier parameters identifier identifier default_parameter identifier false block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier if_statement identifier block return_statement call attribute identifier identifier argument_list subscript identifier attribute attribute identifier identifier identifier else_clause block return_statement call attribute identifier identifier argument_list identifier
Create the data on the remote, optionally refreshing.
def run_aggregation_by_slug(request, slug): sa = get_object_or_404(Aggregation, slug=slug) sa.execute_now = True sa.save() messages.success(request, _("Saved aggregation executed.")) return HttpResponseRedirect( reverse( 'djmongo_browse_saved_aggregations_w_params', args=( sa.database_name, sa.collection_name)))
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier expression_statement assignment attribute identifier identifier true expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier call identifier argument_list string string_start string_content string_end return_statement call identifier argument_list call identifier argument_list string string_start string_content string_end keyword_argument identifier tuple attribute identifier identifier attribute identifier identifier
Run Aggregation By Slug
def _call(self, x, out=None): if out is None: return x * self.multiplicand elif not self.__range_is_field: if self.__domain_is_field: out.lincomb(x, self.multiplicand) else: out.assign(self.multiplicand * x) else: raise ValueError('can only use `out` with `LinearSpace` range')
module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement comparison_operator identifier none block return_statement binary_operator identifier attribute identifier identifier elif_clause not_operator attribute identifier identifier block if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list binary_operator attribute identifier identifier identifier else_clause block raise_statement call identifier argument_list string string_start string_content string_end
Multiply ``x`` and write to ``out`` if given.
def setOverlayWidthInMeters(self, ulOverlayHandle, fWidthInMeters): fn = self.function_table.setOverlayWidthInMeters result = fn(ulOverlayHandle, fWidthInMeters) return result
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier return_statement identifier
Sets the width of the overlay quad in meters. By default overlays are rendered on a quad that is 1 meter across
def _next_page(self): if self._last_page_seen: raise StopIteration new, self._last_page_seen = self.conn.query_multiple(self.object_type, self._next_page_index, self.url_params, self.query_params) self._next_page_index += 1 if len(new) == 0: self._last_page_seen = True else: self._results += new
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block raise_statement identifier expression_statement assignment pattern_list identifier attribute identifier identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement augmented_assignment attribute identifier identifier integer if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment attribute identifier identifier true else_clause block expression_statement augmented_assignment attribute identifier identifier identifier
Fetch the next page of the query.
def trips_process_text(): if request.method == 'OPTIONS': return {} response = request.body.read().decode('utf-8') body = json.loads(response) text = body.get('text') tp = trips.process_text(text) return _stmts_from_proc(tp)
module function_definition identifier parameters block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block return_statement dictionary expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement call identifier argument_list identifier
Process text with TRIPS and return INDRA Statements.
def path(self): if self.dataset is self: return '' else: return self.dataset.path + '/' + self.name
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier identifier block return_statement string string_start string_end else_clause block return_statement binary_operator binary_operator attribute attribute identifier identifier identifier string string_start string_content string_end attribute identifier identifier
Return the full path to the Group, including any parent Groups.
def add_data_file(data_files, target, source): for t, f in data_files: if t == target: break else: data_files.append((target, [])) f = data_files[-1][1] if source not in f: f.append(source)
module function_definition identifier parameters identifier identifier identifier block for_statement pattern_list identifier identifier identifier block if_statement comparison_operator identifier identifier block break_statement else_clause block expression_statement call attribute identifier identifier argument_list tuple identifier list expression_statement assignment identifier subscript subscript identifier unary_operator integer integer if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier
Add an entry to data_files
def pass_session_attributes(self): for key, value in six.iteritems(self.request.session.attributes): self.response.sessionAttributes[key] = value
module function_definition identifier parameters identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list attribute attribute attribute identifier identifier identifier identifier block expression_statement assignment subscript attribute attribute identifier identifier identifier identifier identifier
Copies request attributes to response
def create_permission(self): return Permission( self.networkapi_url, self.user, self.password, self.user_ldap)
module function_definition identifier parameters identifier block return_statement call identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier
Get an instance of permission services facade.
def start_led_flash(self, on, off): if not self._led_flashing: self._led_flash = (on, off) self._led_flashing = True self._control()
module function_definition identifier parameters identifier identifier identifier block if_statement not_operator attribute identifier identifier block expression_statement assignment attribute identifier identifier tuple identifier identifier expression_statement assignment attribute identifier identifier true expression_statement call attribute identifier identifier argument_list
Starts flashing the LED.
def validate_object_action(self, action_name, obj=None): action_method = getattr(self, action_name) if not getattr(action_method, 'detail', False) and action_name not in ('update', 'partial_update', 'destroy'): return validators = getattr(self, action_name + '_validators', []) for validator in validators: validator(obj or self.get_object())
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment identifier call identifier argument_list identifier identifier if_statement boolean_operator not_operator call identifier argument_list identifier string string_start string_content string_end false 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 return_statement expression_statement assignment identifier call identifier argument_list identifier binary_operator identifier string string_start string_content string_end list for_statement identifier identifier block expression_statement call identifier argument_list boolean_operator identifier call attribute identifier identifier argument_list
Execute validation for actions that are related to particular object
def get(self, **kwargs): "What kind of arguments should be pass here" kwargs.setdefault('limit', 1) return self._first(self.gather(**kwargs))
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end integer return_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list dictionary_splat identifier
What kind of arguments should be pass here
def __get_depth(root): if root is None: return 0 left = __get_depth(root.left) right = __get_depth(root.right) if abs(left-right) > 1 or -1 in [left, right]: return -1 return 1 + max(left, right)
module function_definition identifier parameters identifier block if_statement comparison_operator identifier none block return_statement integer expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier if_statement boolean_operator comparison_operator call identifier argument_list binary_operator identifier identifier integer comparison_operator unary_operator integer list identifier identifier block return_statement unary_operator integer return_statement binary_operator integer call identifier argument_list identifier identifier
return 0 if unbalanced else depth + 1
def material_formula(self): try: form = self.header.formula except IndexError: form = 'No formula provided' return "".join(map(str, form))
module function_definition identifier parameters identifier block try_statement block expression_statement assignment identifier attribute attribute identifier identifier identifier except_clause identifier block expression_statement assignment identifier string string_start string_content string_end return_statement call attribute string string_start string_end identifier argument_list call identifier argument_list identifier identifier
Returns chemical formula of material from feff.inp file
def compile_state_usage(self): err = [] top = self.get_top() err += self.verify_tops(top) if err: return err matches = self.top_matches(top) state_usage = {} for saltenv, states in self.avail.items(): env_usage = { 'used': [], 'unused': [], 'count_all': 0, 'count_used': 0, 'count_unused': 0 } env_matches = matches.get(saltenv) for state in states: env_usage['count_all'] += 1 if state in env_matches: env_usage['count_used'] += 1 env_usage['used'].append(state) else: env_usage['count_unused'] += 1 env_usage['unused'].append(state) state_usage[saltenv] = env_usage return state_usage
module function_definition identifier parameters identifier block expression_statement assignment identifier list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement augmented_assignment identifier call attribute identifier identifier argument_list identifier if_statement identifier block return_statement identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier dictionary for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block expression_statement assignment identifier dictionary pair string string_start string_content string_end list pair string string_start string_content string_end list pair string string_start string_content string_end integer pair string string_start string_content string_end integer pair string string_start string_content string_end integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier for_statement identifier identifier block expression_statement augmented_assignment subscript identifier string string_start string_content string_end integer if_statement comparison_operator identifier identifier block expression_statement augmented_assignment subscript identifier string string_start string_content string_end integer expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list identifier else_clause block expression_statement augmented_assignment subscript identifier string string_start string_content string_end integer expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list identifier expression_statement assignment subscript identifier identifier identifier return_statement identifier
Return all used and unused states for the minion based on the top match data
def dkim_sign(message, dkim_domain=None, dkim_key=None, dkim_selector=None, dkim_headers=None): try: import dkim except ImportError: pass else: if dkim_domain and dkim_key: sig = dkim.sign(message, dkim_selector, dkim_domain, dkim_key, include_headers=dkim_headers) message = sig + message return message
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none block try_statement block import_statement dotted_name identifier except_clause identifier block pass_statement else_clause block if_statement boolean_operator identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier identifier keyword_argument identifier identifier expression_statement assignment identifier binary_operator identifier identifier return_statement identifier
Return signed email message if dkim package and settings are available.
def sdmethod(meth): sd = singledispatch(meth) def wrapper(obj, *args, **kwargs): return sd.dispatch(args[0].__class__)(obj, *args, **kwargs) wrapper.register = sd.register wrapper.dispatch = sd.dispatch wrapper.registry = sd.registry wrapper._clear_cache = sd._clear_cache functools.update_wrapper(wrapper, meth) return wrapper
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block return_statement call call attribute identifier identifier argument_list attribute subscript identifier integer identifier argument_list identifier list_splat identifier dictionary_splat identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier return_statement identifier
This is a hack to monkey patch sdproperty to work as expected with instance methods.
def _backtracking(problem, assignment, domains, variable_chooser, values_sorter, inference=True): from simpleai.search.arc import arc_consistency_3 if len(assignment) == len(problem.variables): return assignment pending = [v for v in problem.variables if v not in assignment] variable = variable_chooser(problem, pending, domains) values = values_sorter(problem, assignment, variable, domains) for value in values: new_assignment = deepcopy(assignment) new_assignment[variable] = value if not _count_conflicts(problem, new_assignment): new_domains = deepcopy(domains) new_domains[variable] = [value] if not inference or arc_consistency_3(new_domains, problem.constraints): result = _backtracking(problem, new_assignment, new_domains, variable_chooser, values_sorter, inference=inference) if result: return result return None
module function_definition identifier parameters identifier identifier identifier identifier identifier default_parameter identifier true block import_from_statement dotted_name identifier identifier identifier dotted_name identifier if_statement comparison_operator call identifier argument_list identifier call identifier argument_list attribute identifier identifier block return_statement identifier expression_statement assignment identifier list_comprehension identifier for_in_clause identifier attribute identifier identifier if_clause comparison_operator identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier identifier identifier for_statement identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment subscript identifier identifier identifier if_statement not_operator call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment subscript identifier identifier list identifier if_statement boolean_operator not_operator identifier call identifier argument_list identifier attribute identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier identifier identifier identifier keyword_argument identifier identifier if_statement identifier block return_statement identifier return_statement none
Internal recursive backtracking algorithm.
def display(self): table_list = [] table_list.append(("Text","Orig. Text","Start time","End time", "Phonetic")) for unit in self.unit_list: table_list.append((unit.text, "/".join(unit.original_text), unit.start_time, unit.end_time, unit.phonetic_representation)) print_table(table_list)
module function_definition identifier parameters identifier block expression_statement assignment identifier list expression_statement call attribute identifier identifier argument_list tuple string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list tuple attribute identifier identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement call identifier argument_list identifier
Pretty-prints the ParsedResponse to the screen.
def extra_funcs(*funcs): def extra_funcs_decorator(real_func): def wrapper(*args, **kwargs): return real_func(*args, **kwargs) wrapper.extra_funcs = list(funcs) wrapper.source = inspect.getsource(real_func) wrapper.name = real_func.__name__ return wrapper return extra_funcs_decorator
module function_definition identifier parameters list_splat_pattern identifier block function_definition identifier parameters identifier block function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block return_statement call identifier argument_list list_splat identifier dictionary_splat identifier expression_statement assignment attribute identifier identifier call identifier argument_list identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier attribute identifier identifier return_statement identifier return_statement identifier
Decorator which adds extra functions to be downloaded to the pyboard.
def dict_to_object(d): top = type('CreateSendModel', (object,), d) seqs = tuple, list, set, frozenset for i, j in d.items(): if isinstance(j, dict): setattr(top, i, dict_to_object(j)) elif isinstance(j, seqs): setattr(top, i, type(j)(dict_to_object(sj) if isinstance(sj, dict) else sj for sj in j)) else: setattr(top, i, j) return top
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list string string_start string_content string_end tuple identifier identifier expression_statement assignment identifier expression_list identifier identifier identifier identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement call identifier argument_list identifier identifier block expression_statement call identifier argument_list identifier identifier call identifier argument_list identifier elif_clause call identifier argument_list identifier identifier block expression_statement call identifier argument_list identifier identifier call call identifier argument_list identifier generator_expression conditional_expression call identifier argument_list identifier call identifier argument_list identifier identifier identifier for_in_clause identifier identifier else_clause block expression_statement call identifier argument_list identifier identifier identifier return_statement identifier
Recursively converts a dict to an object
def stop(self): self._flush() filesize = self.file.tell() super(BLFWriter, self).stop() header = [b"LOGG", FILE_HEADER_SIZE, APPLICATION_ID, 0, 0, 0, 2, 6, 8, 1] header.extend([filesize, self.uncompressed_size, self.count_of_objects, 0]) header.extend(timestamp_to_systemtime(self.start_timestamp)) header.extend(timestamp_to_systemtime(self.stop_timestamp)) with open(self.file.name, "r+b") as f: f.write(FILE_HEADER_STRUCT.pack(*header))
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute call identifier argument_list identifier identifier identifier argument_list expression_statement assignment identifier list string string_start string_content string_end identifier identifier integer integer integer integer integer integer integer expression_statement call attribute identifier identifier argument_list list identifier attribute identifier identifier attribute identifier identifier integer expression_statement call attribute identifier identifier argument_list call identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list attribute identifier identifier with_statement with_clause with_item as_pattern call identifier argument_list attribute attribute identifier identifier 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 list_splat identifier
Stops logging and closes the file.
def print_message(self, message, verbosity_needed=1): if self.args.verbosity >= verbosity_needed: print(message)
module function_definition identifier parameters identifier identifier default_parameter identifier integer block if_statement comparison_operator attribute attribute identifier identifier identifier identifier block expression_statement call identifier argument_list identifier
Prints the message, if verbosity is high enough.
def search_first(self, *criterion, **kwargs): query = self._query(*criterion) query = self._order_by(query, **kwargs) query = self._filter(query, **kwargs) query = self._paginate(query, **kwargs) return query.first()
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 expression_statement assignment identifier call attribute identifier identifier argument_list identifier dictionary_splat identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier dictionary_splat identifier return_statement call attribute identifier identifier argument_list
Returns the first match based on criteria or None.
def _set_min_value(self, min_value): if self._transformation is not None: if min_value is not None: try: _ = self._transformation.forward(min_value) except FloatingPointError: raise ValueError("The provided minimum %s cannot be transformed with the transformation %s which " "is defined for the parameter %s" % (min_value, type(self._transformation), self.path)) self._external_min_value = min_value if self._external_min_value is not None and self.value < self._external_min_value: warnings.warn("The current value of the parameter %s (%s) " "was below the new minimum %s." % (self.name, self.value, self._external_min_value), exceptions.RuntimeWarning) self.value = self._external_min_value
module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier none block if_statement comparison_operator identifier none block try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier except_clause identifier block raise_statement call identifier argument_list binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end tuple identifier call identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier identifier if_statement boolean_operator comparison_operator attribute identifier identifier none comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end tuple attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier
Sets current minimum allowed value
def _assemble_complex(stmt): member_strs = [_assemble_agent_str(m) for m in stmt.members] stmt_str = member_strs[0] + ' binds ' + _join_list(member_strs[1:]) return _make_sentence(stmt_str)
module function_definition identifier parameters identifier block expression_statement assignment identifier list_comprehension call identifier argument_list identifier for_in_clause identifier attribute identifier identifier expression_statement assignment identifier binary_operator binary_operator subscript identifier integer string string_start string_content string_end call identifier argument_list subscript identifier slice integer return_statement call identifier argument_list identifier
Assemble Complex statements into text.
def open_window(path): if 'pathlib' in modules: try: call(["open", "-R", str(Path(str(path)))]) except FileNotFoundError: Popen(r'explorer /select,' + str(Path(str(path)))) else: print('pathlib module must be installed to execute open_window function')
module function_definition identifier parameters identifier block if_statement comparison_operator string string_start string_content string_end identifier block try_statement block expression_statement call identifier argument_list list string string_start string_content string_end string string_start string_content string_end call identifier argument_list call identifier argument_list call identifier argument_list identifier except_clause identifier block expression_statement call identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list call identifier argument_list call identifier argument_list identifier else_clause block expression_statement call identifier argument_list string string_start string_content string_end
Open path in finder or explorer window
def _register_task(self, output_type, rule, union_rules): func = Function(self._to_key(rule.func)) self._native.lib.tasks_task_begin(self._tasks, func, self._to_type(output_type), rule.cacheable) for selector in rule.input_selectors: self._native.lib.tasks_add_select(self._tasks, self._to_type(selector)) def add_get_edge(product, subject): self._native.lib.tasks_add_get(self._tasks, self._to_type(product), self._to_type(subject)) for the_get in rule.input_gets: union_members = union_rules.get(the_get.subject_declared_type, None) if union_members: for union_member in union_members: add_get_edge(the_get.product, union_member) else: add_get_edge(the_get.product, the_get.subject_declared_type) self._native.lib.tasks_task_end(self._tasks)
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list attribute identifier identifier identifier call attribute identifier identifier argument_list identifier attribute identifier identifier for_statement identifier attribute identifier identifier block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list attribute identifier identifier call attribute identifier identifier argument_list identifier function_definition identifier parameters identifier identifier block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list attribute identifier identifier call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier for_statement identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier none if_statement identifier block for_statement identifier identifier block expression_statement call identifier argument_list attribute identifier identifier identifier else_clause block expression_statement call identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list attribute identifier identifier
Register the given TaskRule with the native scheduler.
def update(self, cache): self.cache['delims'] = cache.get('delims') self.cache['opts'].update(cache.get('opts')) self.cache['rset'].update(cache.get('rset')) self.cache['mix'].update(cache.get('mix')) map(self.set_var, cache['ctx'].values())
module function_definition identifier parameters identifier identifier block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute subscript attribute identifier identifier string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute subscript attribute identifier identifier string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute subscript attribute identifier identifier string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list attribute identifier identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list
Update self cache from other.