Unnamed: 0
int64
0
389k
code
stringlengths
26
79.6k
docstring
stringlengths
1
46.9k
379,100
def get_response(self, method, endpoint, headers=None, json=None, params=None, data=None): logger.debug("Parameters for get_response:") logger.debug("\t - endpoint: %s", endpoint) logger.debug("\t - method: %s", method) logger.debug("\t - headers: %s", headers) ...
Returns the response from the requested endpoint with the requested method :param method: str. one of the methods accepted by Requests ('POST', 'GET', ...) :param endpoint: str. the relative endpoint to access :param params: (optional) Dictionary or bytes to be sent in the query string f...
379,101
def convert_to_ns(self, value): parsed = self.parse_uri(value) try: rtn_val = "%s_%s" % (self.uri_dict[parsed[0]], parsed[1]) except KeyError: rtn_val = self.pyhttp(value) return rtn_val
converts a value to the prefixed rdf ns equivalent. If not found returns the value as is args: value: the value to convert
379,102
def get_by_id(self, webhook, params={}, **options): path = "/webhooks/%s" % (webhook) return self.client.get(path, params, **options)
Returns the full record for the given webhook. Parameters ---------- webhook : {Id} The webhook to get. [params] : {Object} Parameters for the request
379,103
def get_huisnummer_by_id(self, id): def creator(): res = crab_gateway_request( self.client, , id ) if res == None: raise GatewayResourceNotFoundException() return Huisnummer( res.HuisnummerId, ...
Retrieve a `huisnummer` by the Id. :param integer id: the Id of the `huisnummer` :rtype: :class:`Huisnummer`
379,104
def flatter(x, k=1): if k == 0: return x x = x.toarray() if sps.issparse(x) else np.asarray(x) if len(x.shape) - abs(k) < 2: return x.flatten() k += np.sign(k) if k > 0: return np.reshape(x, (-1,) + x.shape[k:]) else: return np.reshape(x, x.shape[:k] + (-1,))
flatter(x) yields a numpy array equivalent to x but whose first dimension has been flattened. flatter(x, k) yields a numpy array whose first k dimensions have been flattened; if k is negative, the last k dimensions are flattened. If np.inf or -np.inf is passed, then this is equivalent to flattest(x). No...
379,105
def op_nodes(self, op=None): nodes = [] for node in self._multi_graph.nodes(): if node.type == "op": if op is None or isinstance(node.op, op): nodes.append(node) return nodes
Get the list of "op" nodes in the dag. Args: op (Type): Instruction subclass op nodes to return. if op=None, return all op nodes. Returns: list[DAGNode]: the list of node ids containing the given op.
379,106
def raw(request): foos = foobar_models.Foo.objects.all() return HttpResponse(tree.xml(foos), mimetype=)
shows untransformed hierarchical xml output
379,107
def is_valid(self, tree): conano_plaintext = etree.tostring(tree, encoding=, method=) token_str_list = conano_plaintext.split() for i, plain_token in enumerate(token_str_list): graph_token = self.node[self.tokens[i]][self.ns+] if ensure_unicode(plain_token) != gr...
returns true, iff the order of the tokens in the graph are the same as in the Conano file (converted to plain text).
379,108
def write_to_disk( manifest_root_dir: Optional[Path] = None, manifest_name: Optional[str] = None, prettify: Optional[bool] = False, ) -> Manifest: return _write_to_disk(manifest_root_dir, manifest_name, prettify)
Write the active manifest to disk Defaults - Writes manifest to cwd unless Path is provided as manifest_root_dir. - Writes manifest with a filename of Manifest[version].json unless a desired manifest name (which must end in json) is provided as manifest_name. - Writes the minified manifest version t...
379,109
def build(self, builder): params = dict(OID=self.oid, Name=self.name, DataType=self.datatype.value) if self.sas_format_name is not None: params["SASFormatName"] = self.sas_format_name builder.start("CodeList", params) for item in self.codelist_items: ite...
Build XML by appending to builder
379,110
def get_imgid(self, img): imgid = img.filename() hdr = self.get_header(img) if in hdr: return hdr[] if in hdr: return hdr[] if not imgid: imgid = repr(img) return imgid
Obtain a unique identifier of the image. Parameters ---------- img : astropy.io.fits.HDUList Returns ------- str: Identification of the image
379,111
def build_assert(cls: Type[_Block], nodes: List[ast.stmt], min_line_number: int) -> _Block: return cls(filter_assert_nodes(nodes, min_line_number), LineType._assert)
Assert block is all nodes that are after the Act node. Note: The filtering is *still* running off the line number of the Act node, when instead it should be using the last line of the Act block.
379,112
def from_indra_pickle(path: str, name: Optional[str] = None, version: Optional[str] = None, description: Optional[str] = None, authors: Optional[str] = None, contact: Optional[str] = None, ...
Import a model from :mod:`indra`. :param path: Path to pickled list of :class:`indra.statements.Statement` :param name: The name for the BEL graph :param version: The version of the BEL graph :param description: The description of the graph :param authors: The authors of this graph :param conta...
379,113
def write(self, oprot): oprot.write_struct_begin() if self.pp_images_dir_path is not None: oprot.write_field_begin(name=, type=11, id=None) oprot.write_string(self.pp_images_dir_path) oprot.write_field_end() if self.pp_install_dir_path is not None:...
Write this object to the given output protocol and return self. :type oprot: thryft.protocol._output_protocol._OutputProtocol :rtype: pastpy.gen.database.impl.dbf.dbf_database_configuration.DbfDatabaseConfiguration
379,114
def _get_value(self): x, y = self._point.x, self._point.y self._px, self._py = self._item_point.canvas.get_matrix_i2i(self._item_point, self._item_target).transform_point(x, y) return self._px, self._py
Return two delegating variables. Each variable should contain a value attribute with the real value.
379,115
def prune_influence_map_subj_obj(self): def get_rule_info(r): result = {} for ann in self.model.annotations: if ann.subject == r: if ann.predicate == : result[] = ann.object elif ann.predicate == : ...
Prune influence map to include only edges where the object of the upstream rule matches the subject of the downstream rule.
379,116
def translation(language): global _translations if language not in _translations: _translations[language] = Translations(language) return _translations[language]
Return a translation object in the default 'django' domain.
379,117
def ServiceWorker_inspectWorker(self, versionId): assert isinstance(versionId, (str,) ), "Argument must be of type str. Received type: " % type( versionId) subdom_funcs = self.synchronous_command(, versionId=versionId) return subdom_funcs
Function path: ServiceWorker.inspectWorker Domain: ServiceWorker Method name: inspectWorker Parameters: Required arguments: 'versionId' (type: string) -> No description No return value.
379,118
def RegisterParser(cls, parser_class): parser_name = parser_class.NAME.lower() if parser_name in cls._parser_classes: raise KeyError(.format( parser_class.NAME)) cls._parser_classes[parser_name] = parser_class
Registers a parser class. The parser classes are identified based on their lower case name. Args: parser_class (type): parser class (subclass of BaseParser). Raises: KeyError: if parser class is already set for the corresponding name.
379,119
def is_cnpj(numero, estrito=False): try: cnpj(digitos(numero) if not estrito else numero) return True except NumeroCNPJError: pass return False
Uma versão conveniente para usar em testes condicionais. Apenas retorna verdadeiro ou falso, conforme o argumento é validado. :param bool estrito: Padrão ``False``, indica se apenas os dígitos do número deverão ser considerados. Se verdadeiro, potenciais caracteres que formam a máscara serão re...
379,120
def is_any_type_set(sett: Set[Type]) -> bool: return len(sett) == 1 and is_any_type(min(sett))
Helper method to check if a set of types is the {AnyObject} singleton :param sett: :return:
379,121
def purge(**kwargs): * ret = {: [], : True} for name in list_(show_all=True, return_yaml=False): if name == : continue if name.startswith(): continue if in kwargs and kwargs[]: ret[] = True ret[].append(.format(name)) ...
Purge all the jobs currently scheduled on the minion CLI Example: .. code-block:: bash salt '*' schedule.purge
379,122
def _tokenize_latex(self, exp): tokens = [] prevexp = "" while exp: t, exp = self._get_next_token(exp) if t.strip() != "": tokens.append(t) if prevexp == exp: break prevexp = exp return tokens
Internal method to tokenize latex
379,123
def to_json(self): capsule = {} capsule["Hierarchy"] = [] for ( dying, (persistence, surviving, saddle), ) in self.merge_sequence.items(): capsule["Hierarchy"].append( { "Dying": dying, "...
Writes the complete Morse-Smale merge hierarchy to a string object. @ Out, a string object storing the entire merge hierarchy of all minima and maxima.
379,124
def get_tagged_version(self): tags = list(self.get_tags()) if in tags and not self.is_modified(): tags = self.get_parent_tags() versions = self.__versions_from_tags(tags) return self.__best_version(versions)
Get the version of the local working set as a StrictVersion or None if no viable tag exists. If the local working set is itself the tagged commit and the tip and there are no local modifications, use the tag on the parent changeset.
379,125
def sed(regexpr, repl, force=False, recursive=False, dpath_list=None, fpath_list=None, verbose=None, include_patterns=None, exclude_patterns=[]): if include_patterns is None: include_patterns = [, , , , , , , , , , ] if dpath_list is None: dpath_list = [os.getcwd()] ...
Python implementation of sed. NOT FINISHED searches and replaces text in files Args: regexpr (str): regx patterns to find repl (str): text to replace force (bool): recursive (bool): dpath_list (list): directories to search (defaults to cwd)
379,126
def from_list(cls, l): if len(l) == 3: x, y, z = map(float, l) return cls(x, y, z) elif len(l) == 2: x, y = map(float, l) return cls(x, y) else: raise AttributeError
Return a Point instance from a given list
379,127
def add_formats_by_name(self, rfmt_list): for fmt in rfmt_list: if fmt == "json": self.add_report_format(JSONReportFormat) elif fmt in ("txt", "text"): self.add_report_format(TextReportFormat) elif fmt in ("htm", "html"): ...
adds formats by short label descriptors, such as 'txt', 'json', or 'html'
379,128
def view_indexes(self, done=None): ret = [] if done is None: done = set() idx = 0 while idx < self.count(): if not idx in done: break idx += 1 while idx < self.count(): w = self.wp(idx...
return a list waypoint indexes in view order
379,129
def cell_fate(data, groupby=, disconnected_groups=None, self_transitions=False, n_neighbors=None, copy=False): adata = data.copy() if copy else data logg.info(, r=True) n_neighbors = 10 if n_neighbors is None else n_neighbors _adata = adata.copy() vgraph = VelocityGraph(_adata, n_neighbors=n_n...
Computes individual cell endpoints Arguments --------- data: :class:`~anndata.AnnData` Annotated data matrix. groupby: `str` (default: `'clusters'`) Key to which to assign the fates. disconnected_groups: list of `str` (default: `None`) Which groups to treat as disconnected f...
379,130
def _add_document(self, doc_id, conn=None, nosave=False, score=1.0, payload=None, replace=False, partial=False, language=None, **fields): if conn is None: conn = self.redis if partial: replace = True args = [self.ADD_CMD, self.index_name, ...
Internal add_document used for both batch and single doc indexing
379,131
def info_authn(self): authz_header = request.headers.get(, ) if (not authz_header.startswith()): return False token = authz_header[7:] return self.access_token_valid( token, "info_authn: Authorization header")
Check to see if user if authenticated for info.json. Must have Authorization header with value that has the form "Bearer TOKEN", where TOKEN is an appropriate and valid access token.
379,132
def get_queryset(self): try: date = ElectionDay.objects.get(date=self.kwargs["date"]) except Exception: raise APIException( "No elections on {}.".format(self.kwargs["date"]) ) division_ids = [] normal_elections = date.election...
Returns a queryset of all states holding a non-special election on a date.
379,133
def _iter_path(pointer): _check_status(pointer.status) data = pointer.data num_data = pointer.num_data points_per_type = PATH_POINTS_PER_TYPE position = 0 while position < num_data: path_data = data[position] path_type = path_data.header.type points = () for ...
Take a cairo_path_t * pointer and yield ``(path_operation, coordinates)`` tuples. See :meth:`Context.copy_path` for the data structure.
379,134
def store_text_cursor_anchor(self): self.__text_cursor_anchor = (self.textCursor(), self.horizontalScrollBar().sliderPosition(), self.verticalScrollBar().sliderPosition()) return True
Stores the document cursor anchor. :return: Method success. :rtype: bool
379,135
def chi_squareds(self, p=None): if len(self._set_xdata)==0 or len(self._set_ydata)==0: return None if p is None: p = self.results[0] rs = self.studentized_residuals(p) if rs == None: return None cs = [] for r in rs: cs.appen...
Returns a list of chi squared for each data set. Also uses ydata_massaged. p=None means use the fit results
379,136
def _post_login_page(self, login_url): data = {"login": self.username, "_58_password": self.password} try: raw_res = yield from self._session.post(login_url, data=data, ...
Login to HydroQuebec website.
379,137
def get_datastream_data(self, datastream, options): response_format=None if options and in options and options[] is not None: response_format = options[] options[] = None url = + str(datastream) + response = self.http.downstream(url, response_format)...
Get input data for the datastream :param datastream: string :param options: dict
379,138
def get_source(self, name): path = self.get_filename(name) try: source_bytes = self.get_data(path) except OSError as exc: e = _ImportError(, name=name) e.__cause__ = exc raise e return decode_source(sou...
Concrete implementation of InspectLoader.get_source.
379,139
def get_active_services(): with win32.OpenSCManager( dwDesiredAccess = win32.SC_MANAGER_ENUMERATE_SERVICE ) as hSCManager: return [ entry for entry in win32.EnumServicesStatusEx(hSCManager, dwServiceType = win32.SERVICE_WIN32, ...
Retrieve a list of all active system services. @see: L{get_services}, L{start_service}, L{stop_service}, L{pause_service}, L{resume_service} @rtype: list( L{win32.ServiceStatusProcessEntry} ) @return: List of service status descriptors.
379,140
def _decode_datetime(obj): if in obj: obj = datetime.datetime.strptime(obj[].decode(), "%Y%m%dT%H:%M:%S.%f") return obj
Decode a msgpack'ed datetime.
379,141
def copy(self, extra=None): if extra is None: extra = dict() that = copy.copy(self) that._paramMap = {} that._defaultParamMap = {} return self._copyValues(that, extra)
Creates a copy of this instance with the same uid and some extra params. The default implementation creates a shallow copy using :py:func:`copy.copy`, and then copies the embedded and extra parameters over and returns the copy. Subclasses should override this method if the default approa...
379,142
def _consolidate_auth(ssh_password=None, ssh_pkey=None, ssh_pkey_password=None, allow_agent=True, host_pkey_directories=None, logger=None): ssh_loaded_pkeys = SSHTunnelForwa...
Get sure authentication information is in place. ``ssh_pkey`` may be of classes: - ``str`` - in this case it represents a private key file; public key will be obtained from it - ``paramiko.Pkey`` - it will be transparently added to loaded keys
379,143
def get_mac_acl_for_intf_input_interface_type(self, **kwargs): config = ET.Element("config") get_mac_acl_for_intf = ET.Element("get_mac_acl_for_intf") config = get_mac_acl_for_intf input = ET.SubElement(get_mac_acl_for_intf, "input") interface_type = ET.SubElement(input,...
Auto Generated Code
379,144
def adjust_worker_number_by_load(self): if self.interrupted: logger.debug("Trying to adjust worker number. Ignoring because we are stopping.") return to_del = [] logger.debug("checking worker count." " Currently: %d workers, min per module :...
Try to create the minimum workers specified in the configuration :return: None
379,145
def clone(self, into=None): chroot_clone = self._chroot.clone(into=into) clone = self.__class__( chroot=chroot_clone, interpreter=self._interpreter, pex_info=self._pex_info.copy(), preamble=self._preamble, copy=self._copy) clone.set_shebang(self._shebang) clone._distri...
Clone this PEX environment into a new PEXBuilder. :keyword into: (optional) An optional destination directory to clone this PEXBuilder into. If not specified, a temporary directory will be created. Clones PEXBuilder into a new location. This is useful if the PEXBuilder has been frozen and rendered...
379,146
def pdf_case_report(institute_id, case_name): institute_obj, case_obj = institute_and_case(store, institute_id, case_name) data = controllers.case_report_content(store, institute_obj, case_obj) if current_app.config.get(): data[] = controllers.coverage_report_contents(store, institute_ob...
Download a pdf report for a case
379,147
def get_user_shell(): try: pw_shell = pwd.getpwuid(os.geteuid()).pw_shell except KeyError: pw_shell = None return pw_shell or
For commands executed directly via an SSH command-line, SSH looks up the user's shell via getpwuid() and only defaults to /bin/sh if that field is missing or empty.
379,148
def _ige(message, key, iv, operation="decrypt"): message = bytes(message) if len(key) != 32: raise ValueError("key must be 32 bytes long (was " + str(len(key)) + " bytes)") if len(iv) != 32: raise ValueError("iv must be 32 bytes long (was " + ...
Given a key, given an iv, and message do whatever operation asked in the operation field. Operation will be checked for: "decrypt" and "encrypt" strings. Returns the message encrypted/decrypted. message must be a multiple by 16 bytes (for division in 16 byte blocks) key must be 32 byte iv ...
379,149
def add_line(self, p1, p2, char_length): p1_id = self.get_point_id(p1, char_length) p2_id = self.get_point_id(p2, char_length) self.Lines.append((p1_id, p2_id)) return len(self.Lines)
Add a line to the list. Check if the nodes already exist, and add them if not. Return the line index (1-indixed, starting with 1)
379,150
def enumerate_device_serials(vid=FT232H_VID, pid=FT232H_PID): try: ctx = None ctx = ftdi.new() device_list = None count, device_list = ftdi.usb_find_all(ctx, vid, pid) if count < 0: raise RuntimeError(.format(count, ftdi.get_error_string(sel...
Return a list of all FT232H device serial numbers connected to the machine. You can use these serial numbers to open a specific FT232H device by passing it to the FT232H initializer's serial parameter.
379,151
def install_napps(cls, napps): mgr = NAppsManager() for napp in napps: mgr.set_napp(*napp) LOG.info(, mgr.napp_id) if not mgr.is_installed(): try: cls.install_napp(mgr) if not mgr.is_enabled(): ...
Install local or remote NApps. This method is recursive, it will install each napps and your dependencies.
379,152
def _get_vars(self): if self.vars is None: self.vars = {} if type(self.vars) not in [dict, list]: raise errors.AnsibleError(" section must contain only key/value pairs") vars = {} if type(self.vars) == list: for item in self.vars:...
load the vars section from a play, accounting for all sorts of variable features including loading from yaml files, prompting, and conditional includes of the first file found in a list.
379,153
def _format_info(self): info = % ( self.info.get(), self.info.get(), ) if self.info.get(, None): info += % ( self.info.get(), self.info.get(), ) else: info += if self.info.get(, None): info += % ( self.info.get(), self.info.get(), self.info.get() ) return in...
Generate info line for GNTP Message :return string:
379,154
def as_text(self): from leonardo.templatetags.leonardo_tags import _render_content request = get_anonymous_request(self) content = try: for region in [region.key for region in self._feincms_all_regions]: content += .joi...
Fetch and render all regions For search and test purposes just a prototype
379,155
def get_index(table, field_name, op, value): None counter = 0 for row in table: dict_row = convert_to_dict(row) if do_op(dict_row.get(field_name, None), op, value): return counter counter += 1 return None
Returns the index of the first list entry that matches. If no matches are found, it returns None NOTE: it is not returning a list. It is returning an integer in range 0..LEN(target) NOTE: both 'None' and 0 evaluate as False in python. So, if you are checking for a None being returned, be explicit. "i...
379,156
def infer_shape(self, node, input_shapes): if isinstance(self.operator, Functional): return [()] else: return [tuple(native(si) for si in self.operator.range.shape)]
Return a list of output shapes based on ``input_shapes``. This method is optional. It allows to compute the shape of the output without having to evaluate. Parameters ---------- node : `theano.gof.graph.Apply` The node of this Op in the computation graph. in...
379,157
def update_kwargs(kwargs, *updates): for update in updates: if not update: continue for key, val in six.iteritems(update): u_item = resolve_value(val) if u_item is None: continue if key in ( or ): kwargs[key] = u_it...
Utility function for merging multiple keyword arguments, depending on their type: * Non-existent keys are added. * Existing lists or tuples are extended, but not duplicating entries. The keywords ``command`` and ``entrypoint`` are however simply overwritten. * Nested dictionaries are updated, overrid...
379,158
def _get_audio_sample_bit(self, audio_abs_path): sample_bit = int( subprocess.check_output( ( ).format(audio_abs_path, "Precision"), shell=True, universal_newlines=True).rstrip()) return sample_bit
Parameters ---------- audio_abs_path : str Returns ------- sample_bit : int
379,159
def get_slack_channels(self, token): ret = salt.utils.slack.query( function=, api_key=token, return channels
Get all channel names from Slack
379,160
def duration(self, value): if value == self._defaults[] and in self._values: del self._values[] else: self._values[] = value
The duration property. Args: value (string). the property value.
379,161
def _on_cluster_discovery(self, future): LOGGER.debug(, future) common.maybe_raise_exception(future) nodes = future.result() for node in nodes: name = .format(node.ip, node.port) if name in self._cluster: LOGGER.debug(, ...
Invoked when the Redis server has responded to the ``CLUSTER_NODES`` command. :param future: The future containing the response from Redis :type future: tornado.concurrent.Future
379,162
def get_plat_specifier(): import setuptools import distutils plat_name = distutils.util.get_platform() plat_specifier = ".%s-%s" % (plat_name, sys.version[0:3]) if hasattr(sys, ): plat_specifier += return plat_specifier
Standard platform specifier used by distutils
379,163
def _get_asset_content(self, asset_id, asset_content_type_str=None, asset_content_id=None): rm = self.my_osid_object._get_provider_manager() if in self.my_osid_object._my_map: if self.my_osid_object._proxy is not None: als = rm.get_asset_lookup_session_for_repositor...
stub
379,164
def ROC_AUC_analysis(adata,groupby,group=None, n_genes=100): if group is None: pass name_list = list() for j, k in enumerate(adata.uns[]): if j >= n_genes: break name_list.append(adata.uns[][j][group]) groups = groups_order, groups_mask...
Calculate correlation matrix. Calculate a correlation matrix for genes strored in sample annotation using rank_genes_groups.py Parameters ---------- adata : :class:`~anndata.AnnData` Annotated data matrix. groupby : `str` The ...
379,165
def authorize(self, callback=None, state=None, **kwargs): params = dict(self.request_token_params) or {} params.update(**kwargs) if self.request_token_url: token = self.generate_request_token(callback)[0] url = % ( self.expand_url(self.authorize...
Returns a redirect response to the remote authorization URL with the signed callback given. :param callback: a redirect url for the callback :param state: an optional value to embed in the OAuth request. Use this if you want to pass around application ...
379,166
def flush(self): messages = [] while self._packets: p = self._packets.popleft() try: msg = decode(p) except ProtocolError: self._messages = messages raise messages.append(m...
flush() -> List of decoded messages. Decodes the packets in the internal buffer. This enables the continuation of the processing of received packets after a :exc:`ProtocolError` has been handled. :return: A (possibly empty) list of decoded messages from the buffered pack...
379,167
def Close(self): if not self._connection: raise RuntimeError() self._connection.commit() self._connection.close() self._connection = None self._cursor = None self.filename = None self.read_only = None
Closes the database file. Raises: RuntimeError: if the database is not opened.
379,168
def graphviz_parser(preprocessor, tag, markup): m = DOT_BLOCK_RE.search(markup) if m: code = m.group() program = m.group().strip() output = run_graphviz(program, code) return % base64.b64encode(output).decode() else: raise Valu...
Simple Graphviz parser
379,169
def _set_minimum_links(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: t = YANGDynClass(v,base=RestrictedClassType(base_type=RestrictedClassType(base_type=long, restriction_dict={: []}, int_size=32), restriction_dict={: [u]}), default=RestrictedClassType(base_type=long, rest...
Setter method for minimum_links, mapped from YANG variable /interface/port_channel/minimum_links (uint32) If this variable is read-only (config: false) in the source YANG file, then _set_minimum_links is considered as a private method. Backends looking to populate this variable should do so via calling ...
379,170
def disconnect(self, si, logger, vcenter_data_model, vm_uuid, network_name=None, vm=None): logger.debug("Disconnect Interface VM: Network: ...".format(vm_uuid, network_name or "ALL")) if vm is None: vm = self.pyvmomi_service.find_by_uuid(si, vm_uuid) if not vm: ...
disconnect network adapter of the vm. If 'network_name' = None - disconnect ALL interfaces :param <str> si: :param logger: :param VMwarevCenterResourceModel vcenter_data_model: :param <str> vm_uuid: the uuid of the vm :param <str | None> network_name: the name of the specific net...
379,171
def traverse_pagination(response, endpoint, content_filter_query, query_params): results = response.get(, []) page = 1 while response.get(): page += 1 response = endpoint().post(content_filter_query, **dict(query_params, page=page)) results += respon...
Traverse a paginated API response and extracts and concatenates "results" returned by API. Arguments: response (dict): API response object. endpoint (Slumber.Resource): API endpoint object. content_filter_query (dict): query parameters used to filter catalog results. ...
379,172
def configure_api(app): from heman.api.empowering import resources as empowering_resources from heman.api.cch import resources as cch_resources from heman.api.form import resources as form_resources from heman.api import ApiCatchall for resource in empowering_resources: api.add_re...
Configure API Endpoints.
379,173
def end_of_month(val): if type(val) == date: val = datetime.fromordinal(val.toordinal()) if val.month == 12: return start_of_month(val).replace(year=val.year + 1, month=1) \ - timedelta(microseconds=1) else: return start_of_month(val).replace(month=val.month + 1) ...
Return a new datetime.datetime object with values that represent a end of a month. :param val: Date to ... :type val: datetime.datetime | datetime.date :rtype: datetime.datetime
379,174
def _get_labels(self, y): y = np.asarray(y) assert y.ndim == 1 labels = np.unique(y).tolist() oh = np.zeros((y.size, len(labels)), dtype=float) for i, label in enumerate(y): oh[i, labels.index(label)] = 1. return oh
Construct pylearn2 dataset labels. Parameters ---------- y : array_like, optional Labels.
379,175
def decode(data_url): metadata, data = data_url.rsplit(, 1) _, metadata = metadata.split(, 1) parts = metadata.split() if parts[-1] == : data = b64decode(data) else: data = unquote(data) for part in parts: if part.startswith("charset="): data = data.deco...
Decode DataURL data
379,176
def http(self): if self._use_cached_http and hasattr(self._local, ): return self._local.http if self._http_replay is not None: http = self._http_replay else: http = _build_http() authorized_http = google_auth_httplib2.AuthorizedHt...
A thread local instance of httplib2.Http. Returns: httplib2.Http: An Http instance authorized by the credentials.
379,177
def os_version(self, value): if value == self._defaults[] and in self._values: del self._values[] else: self._values[] = value
The os_version property. Args: value (string). the property value.
379,178
def get_allowed_operations(resource, subresouce_path): uri = get_subresource_path_by(resource, subresouce_path) response = resource._conn.get(path=uri) return response.headers[]
Helper function to get the HTTP allowed methods. :param resource: ResourceBase instance from which the path is loaded. :param subresource_path: JSON field to fetch the value from. Either a string, or a list of strings in case of a nested field. :returns: A list of allowed HTTP methods.
379,179
def convert_to_dataset(obj, *, group="posterior", coords=None, dims=None): inference_data = convert_to_inference_data(obj, group=group, coords=coords, dims=dims) dataset = getattr(inference_data, group, None) if dataset is None: raise ValueError( "Can not extract {group} from {obj}!...
Convert a supported object to an xarray dataset. This function is idempotent, in that it will return xarray.Dataset functions unchanged. Raises `ValueError` if the desired group can not be extracted. Note this goes through a DataInference object. See `convert_to_inference_data` for more details. Raise...
379,180
def thresholdForIdentity(identity, colors): for threshold, _ in colors: if identity >= threshold: return threshold raise ValueError()
Get the best identity threshold for a specific identity value. @param identity: A C{float} nucleotide identity. @param colors: A C{list} of (threshold, color) tuples, where threshold is a C{float} and color is a C{str} to be used as a cell background. This is as returned by C{parseColors}. ...
379,181
def datetime_to_time(date, time): if (255 in date) or (255 in time): raise RuntimeError("specific date and time required") time_tuple = ( date[0]+1900, date[1], date[2], time[0], time[1], time[2], 0, 0, -1, ) return _mktime(time_tuple)
Take the date and time 4-tuples and return the time in seconds since the epoch as a floating point number.
379,182
def del_character(self, name): self.query.del_character(name) self.del_graph(name) del self.character[name]
Remove the Character from the database entirely. This also deletes all its history. You'd better be sure.
379,183
def truncate_table(self, tablename): self.get(tablename).remove() self.db.commit()
SQLite3 doesn't support direct truncate, so we just use delete here
379,184
def lookup(parser, var, context, resolve=True, apply_filters=True): if resolve: try: return Variable(var).resolve(context) except VariableDoesNotExist: if apply_filters and var.find() > -1: return parser.compile_filter(var).resolve(context) re...
Try to resolve the varialbe in a context If ``resolve`` is ``False``, only string variables are returned
379,185
def from_value(value): if isinstance(value, PagingParams): return value if isinstance(value, AnyValueMap): return PagingParams.from_map(value) map = AnyValueMap.from_value(value) return PagingParams.from_map(map)
Converts specified value into PagingParams. :param value: value to be converted :return: a newly created PagingParams.
379,186
def try_log_part(self, context=None, with_start_message=True): if context is None: context = {} self.__counter += 1 if time.time() - self.__begin_time > self.__part_log_time_seconds: self.__begin_time = time.time() context[] = self.__counter ...
Залогировать, если пришло время из part_log_time_minutes :return: boolean Возвращает True если лог был записан
379,187
def set_sample_weight(pipeline_steps, sample_weight=None): sample_weight_dict = {} if not isinstance(sample_weight, type(None)): for (pname, obj) in pipeline_steps: if inspect.getargspec(obj.fit).args.count(): step_sw = pname + sample_weight_dict[step_sw...
Recursively iterates through all objects in the pipeline and sets sample weight. Parameters ---------- pipeline_steps: array-like List of (str, obj) tuples from a scikit-learn pipeline or related object sample_weight: array-like List of sample weight Returns ------- sample_w...
379,188
def File(self, name, directory = None, create = 1): return self._lookup(name, directory, File, create)
Look up or create a File node with the specified name. If the name is a relative path (begins with ./, ../, or a file name), then it is looked up relative to the supplied directory node, or to the top level directory of the FS (supplied at construction time) if no directory is supplied....
379,189
def mmatch(expr, delimiter, greedy, search_type, regex_match=False, exact_match=False, opts=None): greedygreedy if not opts: opts = __opts__ ckminions = salt.utils.minions.CkMinions(opts) return ckminions._check_cache_minions(ex...
Helper function to search for minions in master caches If 'greedy' return accepted minions that matched by the condition or absent in the cache. If not 'greedy' return the only minions have cache data and matched by the condition.
379,190
def flavor_list(request): try: return api.nova.flavor_list(request) except Exception: exceptions.handle(request, _()) return []
Utility method to retrieve a list of flavors.
379,191
def getDetailInfo(self, CorpNum, ItemCode, MgtKey): if MgtKey == None or MgtKey == "": raise PopbillException(-99999999, "관리번호가 입력되지 않았습니다.") if ItemCode == None or ItemCode == "": raise PopbillException(-99999999, "명세서 종류 코드가 입력되지 않았습니다.") return self._h...
전자명세서 상세정보 확인 args CorpNum : 팝빌회원 사업자번호 ItemCode : 명세서 종류 코드 [121 - 거래명세서], [122 - 청구서], [123 - 견적서], [124 - 발주서], [125 - 입금표], [126 - 영수증] MgtKey : 파트너 문서관리번호 return 문서 상세정보 object ...
379,192
def find_file( self, folder_id, basename, limit = 500 ): .partN search_folder = self.client.folder( folder_id = folder_id ) offset = 0 search_items = search_folder.get_items( limit = limit, offset = offset ) found_files = [] while len(search_items) > 0: files ...
Finds a file based on a box path Returns a list of file IDs Returns multiple file IDs if the file was split into parts with the extension '.partN' (where N is an integer)
379,193
def fetch_session_start_times(data_dir, pivot, session_dates): session_start_times = SessionStartTimesDataset() df = session_start_times.fetch(pivot, session_dates) save_to_csv(df, data_dir, "session-start-times") log.info("Dates requested:", len(session_dates)) found = pd.to_datetime(df[], fo...
:param data_dir: (str) directory in which the output file will be saved :param pivot: (int) congressperson document to use as a pivot for scraping the data :param session_dates: (list) datetime objects to fetch the start times for
379,194
def generate_sinusoidal_lightcurve( times, mags=None, errs=None, paramdists={ :sps.uniform(loc=0.04,scale=500.0), :[2,10], :sps.uniform(loc=0.1,scale=0.9), :0.0, }, magsarefluxes=False ): periodfourierorderamplitudephiof...
This generates fake sinusoidal light curves. This can be used for a variety of sinusoidal variables, e.g. RRab, RRc, Cepheids, Miras, etc. The functions that generate these model LCs below implement the following table:: ## FOURIER PARAMS FOR SINUSOIDAL VARIABLES # # type fo...
379,195
def get_clamav_conf(filename): if os.path.isfile(filename): return ClamavConfig(filename) log.warn(LOG_PLUGIN, "No ClamAV config file found at %r.", filename)
Initialize clamav configuration.
379,196
def waitForSlotEvent(self, flags=0): tmp = 0 (rv, slot) = self.lib.C_WaitForSlotEvent(flags, tmp) if rv != CKR_OK: raise PyKCS11Error(rv) return slot
C_WaitForSlotEvent :param flags: 0 (default) or `CKF_DONT_BLOCK` :type flags: integer :return: slot :rtype: integer
379,197
def unique_id(self): chain = self.parent.parent.id residue = self.parent.id return chain, residue, self.id
Creates a unique ID for the `Atom` based on its parents. Returns ------- unique_id : (str, str, str) (polymer.id, residue.id, atom.id)
379,198
def parse_ical(vcal): vcal = vcal.replace(, ).replace(, ) vevents = vcal.split() del(vevents[0]) events = [] for vevent in vevents: event = {} for line in vevent.split(): line = line.split(, 1) key = line[0].lower() if len(line) <= 1 or key ==...
Parse Opencast schedule iCalendar file and return events as dict
379,199
def stage_http_request(self, conn_id, version, url, target, method, headers, payload): self._http_request_version = version self._http_request_conn_id = conn_id self._http_request_url = url self._http_request_target = target self._http...
Set request HTTP information including url, headers, etc.