_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q40500
Protocol._filter_attrs
train
def _filter_attrs(self, feature, request): """ Remove some attributes from the feature and set the geometry to None in the feature based ``attrs`` and the ``no_geom`` parameters. """ if 'attrs' in request.params: attrs = request.params['attrs'].split(',') props = feat...
python
{ "resource": "" }
q40501
Protocol._get_order_by
train
def _get_order_by(self, request): """ Return an SA order_by """ attr = request.params.get('sort', request.params.get('order_by')) if attr is None or not hasattr(self.mapped_class, attr): return None if request.params.get('dir', '').upper() == 'DESC': return desc(g...
python
{ "resource": "" }
q40502
Protocol._query
train
def _query(self, request, filter=None): """ Build a query based on the filter and the request params, and send the query to the database. """ limit = None offset = None if 'maxfeatures' in request.params: limit = int(request.params['maxfeatures']) if 'limi...
python
{ "resource": "" }
q40503
Protocol.count
train
def count(self, request, filter=None): """ Return the number of records matching the given filter. """ if filter is None: filter = create_filter(request, self.mapped_class, self.geom_attr) query = self.Session().query(self.mapped_class) if filter is not None: quer...
python
{ "resource": "" }
q40504
Protocol.read
train
def read(self, request, filter=None, id=None): """ Build a query based on the filter or the idenfier, send the query to the database, and return a Feature or a FeatureCollection. """ ret = None if id is not None: o = self.Session().query(self.mapped_class).get(id) ...
python
{ "resource": "" }
q40505
Protocol.create
train
def create(self, request): """ Read the GeoJSON feature collection from the request body and create new objects in the database. """ if self.readonly: return HTTPMethodNotAllowed(headers={'Allow': 'GET, HEAD'}) collection = loads(request.body, object_hook=GeoJSON.to_insta...
python
{ "resource": "" }
q40506
Protocol.update
train
def update(self, request, id): """ Read the GeoJSON feature from the request body and update the corresponding object in the database. """ if self.readonly: return HTTPMethodNotAllowed(headers={'Allow': 'GET, HEAD'}) session = self.Session() obj = session.query(self.m...
python
{ "resource": "" }
q40507
Protocol.delete
train
def delete(self, request, id): """ Remove the targeted feature from the database """ if self.readonly: return HTTPMethodNotAllowed(headers={'Allow': 'GET, HEAD'}) session = self.Session() obj = session.query(self.mapped_class).get(id) if obj is None: retur...
python
{ "resource": "" }
q40508
uuid_from_kronos_time
train
def uuid_from_kronos_time(time, _type=UUIDType.RANDOM): """ Generate a UUID with the specified time. If `lowest` is true, return the lexicographically first UUID for the specified time. """ return timeuuid_from_time(int(time) + UUID_TIME_OFFSET, type=_type)
python
{ "resource": "" }
q40509
PluginsController.by
train
def by(self, technology): """ Get the plugins registered in PedalPi by technology :param PluginTechnology technology: PluginTechnology identifier """ if technology == PluginTechnology.LV2 \ or str(technology).upper() == PluginTechnology.LV2.value.upper(): ret...
python
{ "resource": "" }
q40510
PluginsController.reload_lv2_plugins_data
train
def reload_lv2_plugins_data(self): """ Search for LV2 audio plugins in the system and extract the metadata needed by pluginsmanager to generate audio plugins. """ plugins_data = self.lv2_builder.lv2_plugins_data() self._dao.save(plugins_data)
python
{ "resource": "" }
q40511
MultiDict.invert
train
def invert(self): ''' Invert by swapping each value with its key. Returns ------- MultiDict Inverted multi-dict. Examples -------- >>> MultiDict({1: {1}, 2: {1,2,3}}, 4: {}).invert() MultiDict({1: {1,2}, 2: {2}, 3: {2}}) ''' ...
python
{ "resource": "" }
q40512
_send_with_auth
train
def _send_with_auth(values, secret_key, url): """Send dictionary of JSON serializable `values` as a POST body to `url` along with `auth_token` that's generated from `secret_key` and `values` scheduler.auth.create_token expects a JSON serializable payload, so we send a dictionary. On the receiving end of the...
python
{ "resource": "" }
q40513
schedule
train
def schedule(code, interval, secret_key=None, url=None): """Schedule a string of `code` to be executed every `interval` Specificying an `interval` of 0 indicates the event should only be run one time and will not be rescheduled. """ if not secret_key: secret_key = default_key() if not url: url = de...
python
{ "resource": "" }
q40514
cancel
train
def cancel(task_id, secret_key=None, url=None): """Cancel scheduled task with `task_id`""" if not secret_key: secret_key = default_key() if not url: url = default_url() url = '%s/cancel' % url values = { 'id': task_id, } return _send_with_auth(values, secret_key, url)
python
{ "resource": "" }
q40515
Teams.get
train
def get(cls, session, team_id): """Return a specific team. Args: session (requests.sessions.Session): Authenticated session. team_id (int): The ID of the team to get. Returns: helpscout.models.Person: A person singleton representing the team, ...
python
{ "resource": "" }
q40516
Teams.get_members
train
def get_members(cls, session, team_or_id): """List the members for the team. Args: team_or_id (helpscout.models.Person or int): Team or the ID of the team to get the folders for. Returns: RequestPaginator(output_type=helpscout.models.Users): Users ...
python
{ "resource": "" }
q40517
write_mzxml
train
def write_mzxml(filename, df, info=None, precision='f'): """ Precision is either f or d. """ for r in df.values: df.columns pass
python
{ "resource": "" }
q40518
MzML.read_binary
train
def read_binary(self, ba, param_groups=None): """ ba - binaryDataArray XML node """ if ba is None: return [] pgr = ba.find('m:referenceableParamGroupRef', namespaces=self.ns) if pgr is not None and param_groups is not None: q = 'm:referenceablePar...
python
{ "resource": "" }
q40519
pretty_memory_info
train
def pretty_memory_info(): ''' Pretty format memory info. Returns ------- str Memory info. Examples -------- >>> pretty_memory_info() '5MB memory usage' ''' process = psutil.Process(os.getpid()) return '{}MB memory usage'.format(int(process.memory_info().rss / 2*...
python
{ "resource": "" }
q40520
invert
train
def invert(series): ''' Swap index with values of series. Parameters ---------- series : ~pandas.Series Series to swap on, must have a name. Returns ------- ~pandas.Series Series after swap. See also -------- pandas.Series.map Joins series ``a -> b`...
python
{ "resource": "" }
q40521
split
train
def split(series): ''' Split values. The index is dropped, but this may change in the future. Parameters ---------- series : ~pandas.Series[~pytil.numpy.ArrayLike] Series with array-like values. Returns ------- ~pandas.Series Series with values split across rows. ...
python
{ "resource": "" }
q40522
equals
train
def equals(series1, series2, ignore_order=False, ignore_index=False, all_close=False, _return_reason=False): ''' Get whether 2 series are equal. ``NaN`` is considered equal to ``NaN`` and `None`. Parameters ---------- series1 : pandas.Series Series to compare. series2 : pandas.Seri...
python
{ "resource": "" }
q40523
assert_equals
train
def assert_equals(actual, expected, ignore_order=False, ignore_index=False, all_close=False): ''' Assert 2 series are equal. Like ``assert equals(series1, series2, ...)``, but with better hints at where the series differ. See `equals` for detailed parameter doc. Parameters ---------- a...
python
{ "resource": "" }
q40524
decompress
train
def decompress(zdata): """ Unserializes an AstonFrame. Parameters ---------- zdata : bytes Returns ------- Trace or Chromatogram """ data = zlib.decompress(zdata) lc = struct.unpack('<L', data[0:4])[0] li = struct.unpack('<L', data[4:8])[0] c = json.loads(data[8:8 ...
python
{ "resource": "" }
q40525
Trace._apply_data
train
def _apply_data(self, f, ts, reverse=False): """ Convenience function for all of the math stuff. """ # TODO: needs to catch np numeric types? if isinstance(ts, (int, float)): d = ts * np.ones(self.shape[0]) elif ts is None: d = None elif np...
python
{ "resource": "" }
q40526
Chromatogram.traces
train
def traces(self): """ Decomposes the Chromatogram into a collection of Traces. Returns ------- list """ traces = [] for v, c in zip(self.values.T, self.columns): traces.append(Trace(v, self.index, name=c)) return traces
python
{ "resource": "" }
q40527
Chromatogram.as_sound
train
def as_sound(self, filename, speed=60, cutoff=50): """ Convert AstonFrame into a WAV file. Parameters ---------- filename : str Name of wavfile to create. speed : float, optional How much to speed up for sound recording, e.g. a value of 60 ...
python
{ "resource": "" }
q40528
Chromatogram.scan
train
def scan(self, t, dt=None, aggfunc=None): """ Returns the spectrum from a specific time. Parameters ---------- t : float dt : float """ idx = (np.abs(self.index - t)).argmin() if dt is None: # only take the spectra at the nearest time...
python
{ "resource": "" }
q40529
CassandraStorage.setup_cassandra
train
def setup_cassandra(self, namespaces): """ Set up a connection to the specified Cassandra cluster and create the specified keyspaces if they dont exist. """ connections_to_shutdown = [] self.cluster = Cluster(self.hosts) for namespace_name in namespaces: keyspace = '%s_%s' % (self.key...
python
{ "resource": "" }
q40530
index
train
def index(environment, start_response, headers): """ Return the status of this Kronos instance + its backends> Doesn't expect any URL parameters. """ response = {'service': 'kronosd', 'version': kronos.__version__, 'id': settings.node['id'], 'storage': {}, ...
python
{ "resource": "" }
q40531
MerkleTree.build
train
def build(self): """Builds the tree from the leaves that have been added. This function populates the tree from the leaves down non-recursively """ self.order = MerkleTree.get_order(len(self.leaves)) n = 2 ** self.order self.nodes = [b''] * 2 * n # populate lowe...
python
{ "resource": "" }
q40532
MerkleTree.get_branch
train
def get_branch(self, i): """Gets a branch associated with leaf i. This will trace the tree from the leaves down to the root, constructing a list of tuples that represent the pairs of nodes all the way from leaf i to the root. :param i: the leaf identifying the branch to retrieve ...
python
{ "resource": "" }
q40533
MerkleTree.verify_branch
train
def verify_branch(leaf, branch, root): """This will verify that the given branch fits the given leaf and root It calculates the hash of the leaf, and then verifies that one of the bottom level nodes in the branch matches the leaf hash. Then it calculates the hash of the two nodes on the...
python
{ "resource": "" }
q40534
Model.save
train
def save(self): """Save this entry. If the entry does not have an :attr:`id`, a new id will be assigned, and the :attr:`id` attribute set accordingly. Pre-save processing of the fields saved can be done by overriding the :meth:`prepare_save` method. Additional actions ...
python
{ "resource": "" }
q40535
Manager.get_many
train
def get_many(self, ids): """Get several entries at once.""" return [self.instance(id, **fields) for id, fields in zip(ids, self.api.mget(ids))]
python
{ "resource": "" }
q40536
Manager.create
train
def create(self, **fields): """Create new entry.""" entry = self.instance(**fields) entry.save() return entry
python
{ "resource": "" }
q40537
generous_parse_uri
train
def generous_parse_uri(uri): """Return a urlparse.ParseResult object with the results of parsing the given URI. This has the same properties as the result of parse_uri. When passed a relative path, it determines the absolute path, sets the scheme to file, the netloc to localhost and returns a parse of ...
python
{ "resource": "" }
q40538
get_config_value
train
def get_config_value(key, config_path=None, default=None): """Get a configuration value. Preference: 1. From environment 2. From JSON configuration file supplied in ``config_path`` argument 3. The default supplied to the function :param key: name of lookup value :param config_path: path to...
python
{ "resource": "" }
q40539
timestamp
train
def timestamp(datetime_obj): """Return Unix timestamp as float. The number of seconds that have elapsed since January 1, 1970. """ start_of_time = datetime.datetime(1970, 1, 1) diff = datetime_obj - start_of_time return diff.total_seconds()
python
{ "resource": "" }
q40540
name_is_valid
train
def name_is_valid(name): """Return True if the dataset name is valid. The name can only be 80 characters long. Valid characters: Alpha numeric characters [0-9a-zA-Z] Valid special characters: - _ . """ # The name can only be 80 characters long. if len(name) > MAX_NAME_LENGTH: return...
python
{ "resource": "" }
q40541
BaseStorageBroker.get_admin_metadata
train
def get_admin_metadata(self): """Return the admin metadata as a dictionary.""" logger.debug("Getting admin metdata") text = self.get_text(self.get_admin_metadata_key()) return json.loads(text)
python
{ "resource": "" }
q40542
BaseStorageBroker.get_manifest
train
def get_manifest(self): """Return the manifest as a dictionary.""" logger.debug("Getting manifest") text = self.get_text(self.get_manifest_key()) return json.loads(text)
python
{ "resource": "" }
q40543
BaseStorageBroker.put_admin_metadata
train
def put_admin_metadata(self, admin_metadata): """Store the admin metadata.""" logger.debug("Putting admin metdata") text = json.dumps(admin_metadata) key = self.get_admin_metadata_key() self.put_text(key, text)
python
{ "resource": "" }
q40544
BaseStorageBroker.put_manifest
train
def put_manifest(self, manifest): """Store the manifest.""" logger.debug("Putting manifest") text = json.dumps(manifest, indent=2, sort_keys=True) key = self.get_manifest_key() self.put_text(key, text)
python
{ "resource": "" }
q40545
BaseStorageBroker.put_readme
train
def put_readme(self, content): """Store the readme descriptive metadata.""" logger.debug("Putting readme") key = self.get_readme_key() self.put_text(key, content)
python
{ "resource": "" }
q40546
BaseStorageBroker.update_readme
train
def update_readme(self, content): """Update the readme descriptive metadata.""" logger.debug("Updating readme") key = self.get_readme_key() # Back up old README content. backup_content = self.get_readme_content() backup_key = key + "-{}".format( timestamp(dat...
python
{ "resource": "" }
q40547
BaseStorageBroker.put_overlay
train
def put_overlay(self, overlay_name, overlay): """Store the overlay.""" logger.debug("Putting overlay: {}".format(overlay_name)) key = self.get_overlay_key(overlay_name) text = json.dumps(overlay, indent=2) self.put_text(key, text)
python
{ "resource": "" }
q40548
BaseStorageBroker.item_properties
train
def item_properties(self, handle): """Return properties of the item with the given handle.""" logger.debug("Getting properties for handle: {}".format(handle)) properties = { 'size_in_bytes': self.get_size_in_bytes(handle), 'utc_timestamp': self.get_utc_timestamp(handle), ...
python
{ "resource": "" }
q40549
BaseStorageBroker._document_structure
train
def _document_structure(self): """Document the structure of the dataset.""" logger.debug("Documenting dataset structure") key = self.get_structure_key() text = json.dumps(self._structure_parameters, indent=2, sort_keys=True) self.put_text(key, text) key = self.get_dtool_...
python
{ "resource": "" }
q40550
DiskStorageBroker.list_dataset_uris
train
def list_dataset_uris(cls, base_uri, config_path): """Return list containing URIs in location given by base_uri.""" parsed_uri = generous_parse_uri(base_uri) uri_list = [] path = parsed_uri.path if IS_WINDOWS: path = unix_to_windows_path(parsed_uri.path, parsed_uri....
python
{ "resource": "" }
q40551
DiskStorageBroker.put_text
train
def put_text(self, key, text): """Put the text into the storage associated with the key.""" with open(key, "w") as fh: fh.write(text)
python
{ "resource": "" }
q40552
DiskStorageBroker.get_utc_timestamp
train
def get_utc_timestamp(self, handle): """Return the UTC timestamp.""" fpath = self._fpath_from_handle(handle) datetime_obj = datetime.datetime.utcfromtimestamp( os.stat(fpath).st_mtime ) return timestamp(datetime_obj)
python
{ "resource": "" }
q40553
DiskStorageBroker.get_hash
train
def get_hash(self, handle): """Return the hash.""" fpath = self._fpath_from_handle(handle) return DiskStorageBroker.hasher(fpath)
python
{ "resource": "" }
q40554
is_parans_exp
train
def is_parans_exp(istr): """ Determines if an expression is a valid function "call" """ fxn = istr.split('(')[0] if (not fxn.isalnum() and fxn != '(') or istr[-1] != ')': return False plevel = 1 for c in '('.join(istr[:-1].split('(')[1:]): if c == '(': plevel += 1...
python
{ "resource": "" }
q40555
parse_ion_string
train
def parse_ion_string(istr, analyses, twin=None): """ Recursive string parser that handles "ion" strings. """ if istr.strip() == '': return Trace() # remove (unnessary?) pluses from the front # TODO: plus should be abs? istr = istr.lstrip('+') # invert it if preceded by a minus...
python
{ "resource": "" }
q40556
_validate_and_get_value
train
def _validate_and_get_value(options, options_name, key, _type): """ Check that `options` has a value for `key` with type `_type`. Return that value. `options_name` is a string representing a human-readable name for `options` to be used when printing errors. """ if isinstance(options, dict): has = lambda...
python
{ "resource": "" }
q40557
validate_event_and_assign_id
train
def validate_event_and_assign_id(event): """ Ensure that the event has a valid time. Assign a random UUID based on the event time. """ event_time = event.get(TIMESTAMP_FIELD) if event_time is None: event[TIMESTAMP_FIELD] = event_time = epoch_time_to_kronos_time(time.time()) elif type(event_time) not ...
python
{ "resource": "" }
q40558
validate_stream
train
def validate_stream(stream): """ Check that the stream name is well-formed. """ if not STREAM_REGEX.match(stream) or len(stream) > MAX_STREAM_LENGTH: raise InvalidStreamName(stream)
python
{ "resource": "" }
q40559
validate_storage_settings
train
def validate_storage_settings(storage_class, settings): """ Given a `storage_class` and a dictionary of `settings` to initialize it, this method verifies that all the settings are valid. """ if not isinstance(settings, dict): raise ImproperlyConfigured( '{}: storage class settings must be a dict'....
python
{ "resource": "" }
q40560
BaseModel.from_api
train
def from_api(cls, **kwargs): """Create a new instance from API arguments. This will switch camelCase keys into snake_case for instantiation. It will also identify any ``Instance`` or ``List`` properties, and instantiate the proper objects using the values. The end result being ...
python
{ "resource": "" }
q40561
BaseModel.to_api
train
def to_api(self): """Return a dictionary to send to the API. Returns: dict: Mapping representing this object that can be sent to the API. """ vals = {} for attribute, attribute_type in self._props.items(): prop = getattr(self, attribute) ...
python
{ "resource": "" }
q40562
BaseModel._to_api_value
train
def _to_api_value(self, attribute_type, value): """Return a parsed value for the API.""" if not value: return None if isinstance(attribute_type, properties.Instance): return value.to_api() if isinstance(attribute_type, properties.List): return self....
python
{ "resource": "" }
q40563
BaseModel._parse_api_value_list
train
def _parse_api_value_list(self, values): """Return a list field compatible with the API.""" try: return [v.to_api() for v in values] # Not models except AttributeError: return list(values)
python
{ "resource": "" }
q40564
BaseModel._parse_property
train
def _parse_property(cls, name, value): """Parse a property received from the API into an internal object. Args: name (str): Name of the property on the object. value (mixed): The unparsed API value. Raises: HelpScoutValidationException: In the event that the...
python
{ "resource": "" }
q40565
BaseModel._parse_property_list
train
def _parse_property_list(prop, value): """Parse a list property and return a list of the results.""" attributes = [] for v in value: try: attributes.append( prop.prop.instance_class.from_api(**v), ) except AttributeError...
python
{ "resource": "" }
q40566
BaseModel._to_snake_case
train
def _to_snake_case(string): """Return a snake cased version of the input string. Args: string (str): A camel cased string. Returns: str: A snake cased string. """ sub_string = r'\1_\2' string = REGEX_CAMEL_FIRST.sub(sub_string, string) re...
python
{ "resource": "" }
q40567
BaseModel._to_camel_case
train
def _to_camel_case(string): """Return a camel cased version of the input string. Args: string (str): A snake cased string. Returns: str: A camel cased string. """ components = string.split('_') return '%s%s' % ( components[0], ...
python
{ "resource": "" }
q40568
TrigramsDB.save
train
def save(self, output=None): """ Save the database to a file. If ``output`` is not given, the ``dbfile`` given in the constructor is used. """ if output is None: if self.dbfile is None: return output = self.dbfile with open(output,...
python
{ "resource": "" }
q40569
TrigramsDB.generate
train
def generate(self, **kwargs): """ Generate some text from the database. By default only 70 words are generated, but you can change this using keyword arguments. Keyword arguments: - ``wlen``: maximum length (words) - ``words``: a list of words to use to begin th...
python
{ "resource": "" }
q40570
TrigramsDB._load
train
def _load(self): """ Load the database from its ``dbfile`` if it has one """ if self.dbfile is not None: with open(self.dbfile, 'r') as f: self._db = json.loads(f.read()) else: self._db = {}
python
{ "resource": "" }
q40571
TrigramsDB._get
train
def _get(self, word1, word2): """ Return a possible next word after ``word1`` and ``word2``, or ``None`` if there's no possibility. """ key = self._WSEP.join([self._sanitize(word1), self._sanitize(word2)]) key = key.lower() if key not in self._db: retu...
python
{ "resource": "" }
q40572
TrigramsDB._insert
train
def _insert(self, trigram): """ Insert a trigram in the DB """ words = list(map(self._sanitize, trigram)) key = self._WSEP.join(words[:2]).lower() next_word = words[2] self._db.setdefault(key, []) # we could use a set here, but sets are not serializables...
python
{ "resource": "" }
q40573
planetType
train
def planetType(temperature, mass, radius): """ Returns the planet type as 'temperatureType massType' """ if mass is not np.nan: sizeType = planetMassType(mass) elif radius is not np.nan: sizeType = planetRadiusType(radius) else: return None return '{0} {1}'.format(plane...
python
{ "resource": "" }
q40574
split_array_like
train
def split_array_like(df, columns=None): #TODO rename TODO if it's not a big performance hit, just make them arraylike? We already indicated the column explicitly (sort of) so... ''' Split cells with array-like values along row axis. Column names are maintained. The index is dropped. Parameters ---...
python
{ "resource": "" }
q40575
equals
train
def equals(df1, df2, ignore_order=set(), ignore_indices=set(), all_close=False, _return_reason=False): ''' Get whether 2 data frames are equal. ``NaN`` is considered equal to ``NaN`` and `None`. Parameters ---------- df1 : ~pandas.DataFrame Data frame to compare. df2 : ~pandas.Data...
python
{ "resource": "" }
q40576
_try_mask_first_row
train
def _try_mask_first_row(row, values, all_close, ignore_order): ''' mask first row in 2d array values : 2d masked array Each row is either fully masked or not masked at all ignore_order : bool Ignore column order Return whether masked a row. If False, masked nothing. ''' for...
python
{ "resource": "" }
q40577
_try_mask_row
train
def _try_mask_row(row1, row2, all_close, ignore_order): ''' if each value in row1 matches a value in row2, mask row2 row1 1d array row2 1d masked array whose mask is all False ignore_order : bool Ignore column order all_close : bool compare with np.isclose instea...
python
{ "resource": "" }
q40578
_try_mask_first_value
train
def _try_mask_first_value(value, row, all_close): ''' mask first value in row value1 : ~typing.Any row : 1d masked array all_close : bool compare with np.isclose instead of == Return whether masked a value ''' # Compare value to row for i, value2 in enumerate(row): ...
python
{ "resource": "" }
q40579
_value_equals
train
def _value_equals(value1, value2, all_close): ''' Get whether 2 values are equal value1, value2 : ~typing.Any all_close : bool compare with np.isclose instead of == ''' if value1 is None: value1 = np.nan if value2 is None: value2 = np.nan are_floats = np.can_cas...
python
{ "resource": "" }
q40580
assert_equals
train
def assert_equals(df1, df2, ignore_order=set(), ignore_indices=set(), all_close=False, _return_reason=False): ''' Assert 2 data frames are equal A more verbose form of ``assert equals(df1, df2, ...)``. See `equals` for an explanation of the parameters. Parameters ---------- df1 : ~pandas.DataF...
python
{ "resource": "" }
q40581
is_equal_strings_ignore_case
train
def is_equal_strings_ignore_case(first, second): """The function compares strings ignoring case""" if first and second: return first.upper() == second.upper() else: return not (first or second)
python
{ "resource": "" }
q40582
Dataset.find_dimension_by_name
train
def find_dimension_by_name(self, dim_name): """the method searching dimension with a given name""" for dim in self.dimensions: if is_equal_strings_ignore_case(dim.name, dim_name): return dim return None
python
{ "resource": "" }
q40583
Dataset.find_dimension_by_id
train
def find_dimension_by_id(self, dim_id): """the method searching dimension with a given id""" for dim in self.dimensions: if is_equal_strings_ignore_case(dim.id, dim_id): return dim return None
python
{ "resource": "" }
q40584
DatasetUpload.save_to_json
train
def save_to_json(self): """The method saves DatasetUpload to json from object""" requestvalues = { 'DatasetId': self.dataset, 'Name': self.name, 'Description': self.description, 'Source': self.source, 'PubDate': self.publication_date, ...
python
{ "resource": "" }
q40585
Proxy.keyspace
train
def keyspace(self, keyspace): """ Convenient, consistent access to a sub-set of all keys. """ if FORMAT_SPEC.search(keyspace): return KeyspacedProxy(self, keyspace) else: return KeyspacedProxy(self, self._keyspaces[keyspace])
python
{ "resource": "" }
q40586
dircmp.phase3
train
def phase3(self): """ Find out differences between common files. Ensure we are using content comparison with shallow=False. """ fcomp = filecmp.cmpfiles(self.left, self.right, self.common_files, shallow=False) self.same_files, self.diff_fi...
python
{ "resource": "" }
q40587
ElasticSearchStorage._insert
train
def _insert(self, namespace, stream, events, configuration): """ `namespace` acts as db for different streams `stream` is the name of a stream and `events` is a list of events to insert. """ index = self.index_manager.get_index(namespace) start_dts_to_add = set() def actions(): fo...
python
{ "resource": "" }
q40588
TraceFile.scan
train
def scan(self, t, dt=None, aggfunc=None): """ Returns the spectrum from a specific time or range of times. """ return self.data.scan(t, dt, aggfunc)
python
{ "resource": "" }
q40589
_generate_storage_broker_lookup
train
def _generate_storage_broker_lookup(): """Return dictionary of available storage brokers.""" storage_broker_lookup = dict() for entrypoint in iter_entry_points("dtool.storage_brokers"): StorageBroker = entrypoint.load() storage_broker_lookup[StorageBroker.key] = StorageBroker return stor...
python
{ "resource": "" }
q40590
_get_storage_broker
train
def _get_storage_broker(uri, config_path): """Helper function to enable use lookup of appropriate storage brokers.""" uri = dtoolcore.utils.sanitise_uri(uri) storage_broker_lookup = _generate_storage_broker_lookup() parsed_uri = dtoolcore.utils.generous_parse_uri(uri) StorageBroker = storage_broker_...
python
{ "resource": "" }
q40591
_admin_metadata_from_uri
train
def _admin_metadata_from_uri(uri, config_path): """Helper function for getting admin metadata.""" uri = dtoolcore.utils.sanitise_uri(uri) storage_broker = _get_storage_broker(uri, config_path) admin_metadata = storage_broker.get_admin_metadata() return admin_metadata
python
{ "resource": "" }
q40592
_is_dataset
train
def _is_dataset(uri, config_path): """Helper function for determining if a URI is a dataset.""" uri = dtoolcore.utils.sanitise_uri(uri) storage_broker = _get_storage_broker(uri, config_path) return storage_broker.has_admin_metadata()
python
{ "resource": "" }
q40593
generate_admin_metadata
train
def generate_admin_metadata(name, creator_username=None): """Return admin metadata as a dictionary.""" if not dtoolcore.utils.name_is_valid(name): raise(DtoolCoreInvalidNameError()) if creator_username is None: creator_username = dtoolcore.utils.getuser() datetime_obj = datetime.datet...
python
{ "resource": "" }
q40594
_generate_uri
train
def _generate_uri(admin_metadata, base_uri): """Return dataset URI. :param admin_metadata: dataset administrative metadata :param base_uri: base URI from which to derive dataset URI :returns: dataset URI """ name = admin_metadata["name"] uuid = admin_metadata["uuid"] # storage_broker_lo...
python
{ "resource": "" }
q40595
copy
train
def copy(src_uri, dest_base_uri, config_path=None, progressbar=None): """Copy a dataset to another location. :param src_uri: URI of dataset to be copied :param dest_base_uri: base of URI for copy target :param config_path: path to dtool configuration file :returns: URI of new dataset """ da...
python
{ "resource": "" }
q40596
copy_resume
train
def copy_resume(src_uri, dest_base_uri, config_path=None, progressbar=None): """Resume coping a dataset to another location. Items that have been copied to the destination and have the same size as in the source dataset are skipped. All other items are copied across and the dataset is frozen. :par...
python
{ "resource": "" }
q40597
_BaseDataSet.update_name
train
def update_name(self, new_name): """Update the name of the proto dataset. :param new_name: the new name of the proto dataset """ if not dtoolcore.utils.name_is_valid(new_name): raise(DtoolCoreInvalidNameError()) self._admin_metadata['name'] = new_name if se...
python
{ "resource": "" }
q40598
_BaseDataSet._put_overlay
train
def _put_overlay(self, overlay_name, overlay): """Store overlay so that it is accessible by the given name. :param overlay_name: name of the overlay :param overlay: overlay must be a dictionary where the keys are identifiers in the dataset :raises: TypeError if t...
python
{ "resource": "" }
q40599
_BaseDataSet.generate_manifest
train
def generate_manifest(self, progressbar=None): """Return manifest generated from knowledge about contents.""" items = dict() if progressbar: progressbar.label = "Generating manifest" for handle in self._storage_broker.iter_item_handles(): key = dtoolcore.utils.g...
python
{ "resource": "" }