code stringlengths 1 18.2k |
|---|
def get_transcripts(self): """ a list of the transcripts in the locus""" txs = [] for pays in [x.payload for x in self.g.get_nodes()]: for pay in pays: txs.append(pay) return txs |
def partition_loci(self,verbose=False): """ break the locus up into unconnected loci :return: list of loci :rtype: TranscriptLoci[] """ self.g.merge_cycles() #sys.stderr.write(self.g.get_report()+"\n") gs = self.g.partition_graph(verbose=verbose) tls = [] # makea list of transcript loci for g in gs: tl = TranscriptLoci... |
def add_transcript(self,tx): """Add a transcript to the locus :param tx: transcript to add :type tx: Transcript """ for y in [x.payload for x in self.g.get_nodes()]: if tx.id in [z.id for z in y]: sys.stderr.write("WARNING tx is already in graph\n") return True # transcript isn't part of graph yet n = seqtools.graph.No... |
= eo.is_subset() if r == 2 or r == 1: self.g.add_edge(seqtools.graph.Edge(n,n2),verbose=False) if r == 3 or r == 1: self.g.add_edge(seqtools.graph.Edge(n2,n),verbose=False) elif self.merge_rules.get_merge_type() == 'is_full_overlap': if eo.is_full_overlap(): self.g.add_edge(seqtools.graph.Edge(n,n2),verbose=False) self... |
def get_transcript(self,exon_bounds='max'): """Return a representative transcript object""" out = Transcript() out.junctions = [x.get_junction() for x in self.junction_groups] # check for single exon transcript if len(out.junctions) == 0: leftcoord = min([x.exons[0].range.start for x in self.transcripts]) rightcoord = ... |
if y] if len(right_exons) == 0: sys.stderr.write("ERROR no right exon\n") sys.exit() e_right = Exon(GenomicRange(out.junctions[-1].right.chr,\ out.junctions[-1].right.end,\ max([x.range.end for x in right_exons]))) e_right.set_left_junc(out.junctions[-1]) out.exons.append(e_right) return out |
def download(url, filename): """download and extract file.""" logger.info("Downloading %s", url) request = urllib2.Request(url) request.add_header('User-Agent', 'caelum/0.1 +https://github.com/nrcharles/caelum') opener = urllib2.build_opener() local_file = open(filename, 'w') local_file.write(opener.open(request).read(... |
def download_extract(url): """download and extract file.""" logger.info("Downloading %s", url) request = urllib2.Request(url) request.add_header('User-Agent', 'caelum/0.1 +https://github.com/nrcharles/caelum') opener = urllib2.build_opener() with tempfile.TemporaryFile(suffix='.zip', dir=env.WEATHER_DATA_PATH) \ as loc... |
def parse_noaa_line(line): """Parse NOAA stations. This is an old list, the format is: NUMBER NAME & STATE/COUNTRY LAT LON ELEV (meters) 010250 TROMSO NO 6941N 01855E 10 """ station = {} station['station_name'] = line[7:51].strip() station['station_code'] = line[0:6] station['CC'] = line[55:57] station['ELEV(m)'] = int... |
def closest_noaa(latitude, longitude): """Find closest station from the old list.""" with open(env.SRC_PATH + '/inswo-stns.txt') as index: index.readline() # header index.readline() # whitespace min_dist = 9999 station_name = '' station_name = '' for line in index: try: i = parse_noaa_line(line) new_dist = great_circle... |
def closest_eere(latitude, longitude): """Find closest station from the new(er) list. Warning: There may be some errors with smaller non US stations. Args: latitude (float) longitude (float) Returns: tuple (station_code (str), station_name (str)) """ with open(env.SRC_PATH + '/eere_meta.csv') as eere_meta: stations = c... |
def eere_station(station_code): """Station information. Args: station_code (str): station code. Returns (dict): station information """ with open(env.SRC_PATH + '/eere_meta.csv') as eere_meta: stations = csv.DictReader(eere_meta) for station in stations: if station['station_code'] == station_code: return station raise ... |
def get_log_entries(self): """Gets the log entry list resulting from a search. return: (osid.logging.LogEntryList) - the log entry list raise: IllegalState - list already retrieved *compliance: mandatory -- This method must be implemented.* """ if self.retrieved: raise errors.IllegalState('List has already been retriev... |
def get_logs(self): """Gets the log list resulting from a search. return: (osid.logging.LogList) - the log list raise: IllegalState - list already retrieved *compliance: mandatory -- This method must be implemented.* """ if self.retrieved: raise errors.IllegalState('List has already been retrieved.') self.retrieved = T... |
def get_object(self, queryset=None): """ Returns the object the view is displaying. """ if queryset is None: queryset = self.get_queryset() # Take a GET parameter instead of URLConf variable. try: pk = long(self.request.GET[self.pk_url_kwarg]) except (KeyError, ValueError): raise Http404("Invalid Parameters") queryset ... |
def init(cloud_url): """ Choose a cloud server to use. Sets CLOUD_URL as the cloud server to use and sets up replication of global databases from that cloud server if a local database is already initialized (via `openag db init`). """ old_cloud_url = config["cloud_server"]["url"] if old_cloud_url and old_cloud_url != c... |
def show(): """ Shows the URL of the current cloud server or throws an error if no cloud server is selected """ utils.check_for_cloud_server() click.echo("Using cloud server at \"{}\"".format( config["cloud_server"]["url"] )) if config["cloud_server"]["username"]: click.echo( "Logged in as user \"{}\"".format(config["c... |
def deinit(ctx): """ Detach from the current cloud server """ utils.check_for_cloud_server() if config["local_server"]["url"]: utils.cancel_global_db_replication() if config["cloud_server"]["username"]: ctx.invoke(logout_user) config["cloud_server"]["url"] = None |
def invoke(self, ns, request_name, params={}, simplify=False): """ Invokes zimbra method using established authentication session. @param req: zimbra request @parm params: request params @param simplify: True to return python object, False to return xml struct @return: zimbra response @raise AuthException: if authentic... |
def can_transfer(self): """ bool: :const:`True` if :attr:`address` can transfer the edition :attr:`edition_number` of :attr:`piece_address` else :const:`False`. """ # 1. The address needs to own the edition chain = BlockchainSpider.chain(self._tree, self.edition_number) if len(chain) == 0: self.reason = 'The edition nu... |
def can_unconsign(self): """ bool: :const:`True` if :attr:`address` can unconsign the edition :attr:`edition_number` of :attr:`piece_address` else :const:`False`. If the last transaction is a consignment of the edition to the user. """ chain = BlockchainSpider.chain(self._tree, self.edition_number) if len(chain) == 0: ... |
def can_register(self): """ bool: :const:`True` if :attr:`address` can register the edition :attr:`edition_number` of :attr:`piece_address` else :const:`False`. In order to register an edition: 1. The master piece needs to be registered. 2. The number of editions needs to be registered. 3. The :attr:`edition_number` sh... |
number_editions: self.reason = 'You can only register {} editions. You are trying to register edition {}'.format(number_editions, self.edition_number) return False if self.edition_number in self._tree: self.reason = 'Edition number {} is already registered in the blockchain'. format(self.edition_number) return False re... |
def can_editions(self): """ bool: :const:`True` if :attr:`address` can register the number of editions of :attr:`piece_address` else :const:`False`. In order to register the number of editions: 1. There needs to a least one transaction for the :attr:`piece_address` (the registration of the master edition). 2. A piece w... |
def relative_to_all(features, groups, bin_edges, weight_func, use_orig_distr, group_ids, num_groups, return_networkx_graph, out_weights_path): """ Computes the given function (aka weight or distance) between histogram from each of the groups to a "grand histogram" derived from all groups. Parameters ---------- features... |
groups array (of length 1000) could have numbers 1 to 100 (number of unique values) specifying which element belongs to which cortical patch. Grouping with numerical values (contiguous from 1 to num_patches) is strongly recommended for simplicity, but this could also be a list of strings of length p, in which case a tu... |
two groups/ROIs/nodes directly. Example: ``diff_in_medians = lambda x, y: abs(np.median(x)-np.median(y))`` This option is valid only when weight_method is a valid callable, which must take two inputs (possibly of different lengths) and return a single scalar. group_ids : list List of unique group ids to construct the n... |
------ ValueError If one or more of the arrays are empty. """ # notice the use of all features without regard to group membership hist_whole = compute_histogram(features, bin_edges, use_orig_distr) # to identify the central node capturing distribution from all roi's whole_node = 'whole' if return_networkx_graph: graph ... |
def add_filter(self, filter_or_string, *args, **kwargs): """ Appends a filter. """ self.filters.append(build_filter(filter_or_string, *args, **kwargs)) return self |
def and_filter(self, filter_or_string, *args, **kwargs): """ Adds a list of :class:`~es_fluent.filters.core.And` clauses, automatically generating :class:`~es_fluent.filters.core.And` filter if it does not exist. """ and_filter = self.find_filter(And) if and_filter is None: and_filter = And() self.filters.append(and_fi... |
def or_filter(self, filter_or_string, *args, **kwargs): """ Adds a list of :class:`~es_fluent.filters.core.Or` clauses, automatically generating the an :class:`~es_fluent.filters.core.Or` filter if it does not exist. """ or_filter = self.find_filter(Or) if or_filter is None: or_filter = Or() self.filters.append(or_filt... |
def find_filter(self, filter_cls): """ Find or create a filter instance of the provided ``filter_cls``. If it is found, use remaining arguments to augment the filter otherwise create a new instance of the desired type and add it to the current :class:`~es_fluent.builder.QueryBuilder` accordingly. """ for filter_instanc... |
def to_query(self): """ Iterates over all filters and converts them to an Elastic HTTP API suitable query. Note: each :class:`~es_fluent.filters.Filter` is free to set it's own filter dictionary. ESFluent does not attempt to guard against filters that may clobber one another. If you wish to ensure that filters are isol... |
def determinize(m): """Determinizes a finite automaton.""" if not m.is_finite(): raise TypeError("machine must be a finite automaton") transitions = collections.defaultdict(lambda: collections.defaultdict(set)) alphabet = set() for transition in m.get_transitions(): [[lstate], read] = transition.lhs [[rstate]] = transi... |
= collections.defaultdict(set) for lstate in lstates: for read in alphabet: dtransitions[read] |= transitions[lstate][(read,)] for read in alphabet: rstates = Set(eclosure(dtransitions[read])) dm.add_transition([[lstates], read], [[rstates]]) frontier.add(rstates) accept_states = set(m.get_accept_states()) for states i... |
def equivalent(m1, m2): """Hopcroft-Karp algorithm.""" if not m1.is_finite() and m1.is_deterministic(): raise TypeError("machine must be a deterministic finite automaton") if not m2.is_finite() and m2.is_deterministic(): raise TypeError("machine must be a deterministic finite automaton") # Index transitions. We use tup... |
s2) s.append((s1, s2)) while len(s) > 0: q1, q2 = s.pop() for a in alphabet: r1 = u[d[q1,a]] r2 = u[d[q2,a]] if r1 != r2: union(r1, r2) s.append((r1, r2)) cls = {} f = ( {(1, q) for q in m1.get_accept_states()} | {(2, q) for q in m2.get_accept_states()} ) for q in u: if u[q] not in cls: cls[u[q]] = q in f elif (q in f)... |
def match(self, other): """Returns true iff self (as a pattern) matches other (as a configuration). Note that this is asymmetric: other is allowed to have symbols that aren't found in self.""" if len(self) != len(other): raise ValueError() for s1, s2 in zip(self, other): i = s2.position - s1.position if i < 0: return F... |
def has_cell(self, s): """Tests whether store `s` is a cell, that is, it uses exactly one cell, and there can take on only a finite number of states).""" for t in self.transitions: if len(t.lhs[s]) != 1: return False if len(t.rhs[s]) != 1: return False if t.lhs[s].position != 0: return False if t.rhs[s].position != 0: ... |
def has_stack(self, s): """Tests whether store `s` is a stack, that is, it never moves from position 0.""" for t in self.transitions: if t.lhs[s].position != 0: return False if t.rhs[s].position != 0: return False return True |
def has_readonly(self, s): """Tests whether store `s` is read-only.""" for t in self.transitions: if list(t.lhs[s]) != list(t.rhs[s]): return False return True |
def is_finite(self): """Tests whether machine is a finite automaton.""" return (self.num_stores == 2 and self.state == 0 and self.has_cell(0) and self.input == 1 and self.has_input(1)) |
def is_pushdown(self): """Tests whether machine is a pushdown automaton.""" return (self.num_stores == 3 and self.state == 0 and self.has_cell(0) and self.input == 1 and self.has_input(1) and self.has_stack(2)) |
def is_deterministic(self): """Tests whether machine is deterministic.""" # naive quadratic algorithm patterns = [t.lhs for t in self.transitions] + list(self.accept_configs) for i, t1 in enumerate(patterns): for t2 in patterns[:i]: match = True for in1, in2 in zip(t1, t2): i = max(-in1.position, -in2.position) while i... |
def get_relationship(self, relationship_id): """Gets the ``Relationship`` specified by its ``Id``. arg: relationship_id (osid.id.Id): the ``Id`` of the ``Relationship`` to retrieve return: (osid.relationship.Relationship) - the returned ``Relationship`` raise: NotFound - no ``Relationship`` found with the given ``Id`` ... |
def get_relationships_by_ids(self, relationship_ids): """Gets a ``RelationshipList`` corresponding to the given ``IdList``. arg: relationship_ids (osid.id.IdList): the list of ``Ids`` to retrieve return: (osid.relationship.RelationshipList) - the returned ``Relationship list`` raise: NotFound - an ``Id`` was not found ... |
def get_relationships_by_genus_type(self, relationship_genus_type): """Gets a ``RelationshipList`` corresponding to the given relationship genus ``Type`` which does not include relationships of types derived from the specified ``Type``. arg: relationship_genus_type (osid.type.Type): a relationship genus type return: (o... |
def get_relationships_on_date(self, from_, to): """Gets a ``RelationshipList`` effective during the entire given date range inclusive but not confined to the date range. arg: from (osid.calendaring.DateTime): starting date arg: to (osid.calendaring.DateTime): ending date return: (osid.relationship.RelationshipList) - t... |
def get_relationships_for_source(self, source_id): """Gets a ``RelationshipList`` corresponding to the given peer ``Id``. arg: source_id (osid.id.Id): a peer ``Id`` return: (osid.relationship.RelationshipList) - the relationships raise: NullArgument - ``source_id`` is ``null`` raise: OperationFailed - unable to complet... |
def get_relationships_for_source_on_date(self, source_id, from_, to): """Gets a ``RelationshipList`` corresponding to the given peer ``Id`` and effective during the entire given date range inclusive but not confined to the date range. arg: source_id (osid.id.Id): a peer ``Id`` arg: from (osid.calendaring.DateTime): sta... |
def get_relationships_by_genus_type_for_source_on_date(self, source_id, relationship_genus_type, from_, to): """Gets a ``RelationshipList`` corresponding to the given peer ``Id`` and relationship genus ``Type`` and effective during the entire given date range inclusive but not confined to the date range. arg: source_id... |
def get_relationships_for_destination_on_date(self, destination_id, from_, to): """Gets a ``RelationshipList`` corresponding to the given peer ``Id`` with a starting effective date in the given range inclusive. arg: destination_id (osid.id.Id): a peer ``Id`` arg: from (osid.calendaring.DateTime): starting date arg: to ... |
def get_relationships(self): """Gets all ``Relationships``. return: (osid.relationship.RelationshipList) - a list of ``Relationships`` raise: OperationFailed - unable to complete request raise: PermissionDenied - authorization failure *compliance: mandatory -- This method must be implemented.* """ # Implemented from te... |
def get_relationships_by_query(self, relationship_query): """Gets a list of ``Relationships`` matching the given relationship query. arg: relationship_query (osid.relationship.RelationshipQuery): the relationship query return: (osid.relationship.RelationshipList) - the returned ``RelationshipList`` raise: NullArgument ... |
else: result = [] return objects.RelationshipList(result, runtime=self._runtime, proxy=self._proxy) |
def get_relationship_form_for_create(self, source_id, destination_id, relationship_record_types): """Gets the relationship form for creating new relationships. A new form should be requested for each create transaction. arg: source_id (osid.id.Id): ``Id`` of a peer arg: destination_id (osid.id.Id): ``Id`` of the relate... |
ABCType if not isinstance(source_id, ABCId): raise errors.InvalidArgument('argument is not a valid OSID Id') if not isinstance(destination_id, ABCId): raise errors.InvalidArgument('argument is not a valid OSID Id') for arg in relationship_record_types: if not isinstance(arg, ABCType): raise errors.InvalidArgument('one ... |
def create_relationship(self, relationship_form): """Creates a new ``Relationship``. arg: relationship_form (osid.relationship.RelationshipForm): the form for this ``Relationship`` return: (osid.relationship.Relationship) - the new ``Relationship`` raise: IllegalState - ``relationship_form`` already used in a create tr... |
raise errors.Unsupported('relationship_form did not originate from this session') if not relationship_form.is_valid(): raise errors.InvalidArgument('one or more of the form elements is invalid') insert_result = collection.insert_one(relationship_form._my_map) self._forms[relationship_form.get_id().get_identifier()] = C... |
def update_relationship(self, relationship_form): """Updates an existing relationship. arg: relationship_form (osid.relationship.RelationshipForm): the form containing the elements to be updated raise: IllegalState - ``relationship_form`` already used in an update transaction raise: InvalidArgument - the form contains ... |
from this session') if not relationship_form.is_valid(): raise errors.InvalidArgument('one or more of the form elements is invalid') collection.save(relationship_form._my_map) self._forms[relationship_form.get_id().get_identifier()] = UPDATED # Note: this is out of spec. The OSIDs don't require an object to be returned... |
def delete_relationship(self, relationship_id): """Deletes a ``Relationship``. arg: relationship_id (osid.id.Id): the ``Id`` of the ``Relationship`` to remove raise: NotFound - ``relationship_id`` not found raise: NullArgument - ``relationship_id`` is ``null`` raise: OperationFailed - unable to complete request raise: ... |
def alias_relationship(self, relationship_id, alias_id): """Adds an ``Id`` to a ``Relationship`` for the purpose of creating compatibility. The primary ``Id`` of the ``Relationship`` is determined by the provider. The new ``Id`` performs as an alias to the primary ``Id``. If the alias is a pointer to another relationsh... |
def can_create_family_with_record_types(self, family_record_types): """Tests if this user can create a single ``Family`` using the desired record types. While ``RelationshipManager.getFamilyRecordTypes()`` can be used to examine which records are supported, this method tests which record(s) are required for creating a ... |
None: return self._catalog_session.can_create_catalog_with_record_types(catalog_record_types=family_record_types) return True |
def update_family(self, family_form): """Updates an existing family. arg: family_form (osid.relationship.FamilyForm): the form containing the elements to be updated raise: IllegalState - ``family_form`` already used in an update transaction raise: InvalidArgument - the form contains an invalid value raise: NullArgument... |
update transaction') except KeyError: raise errors.Unsupported('family_form did not originate from this session') if not family_form.is_valid(): raise errors.InvalidArgument('one or more of the form elements is invalid') collection.save(family_form._my_map) # save is deprecated - change to replace_one self._forms[famil... |
def alias_family(self, family_id, alias_id): """Adds an ``Id`` to a ``Family`` for the purpose of creating compatibility. The primary ``Id`` of the ``Family`` is determined by the provider. The new ``Id`` performs as an alias to the primary ``Id``. If the alias is a pointer to another family, it is reassigned to the gi... |
def get_root_families(self): """Gets the root families in the family hierarchy. A node with no parents is an orphan. While all family ``Ids`` are known to the hierarchy, an orphan does not appear in the hierarchy unless explicitly added as a root node or child of another node. return: (osid.relationship.FamilyList) - t... |
def has_parent_families(self, family_id): """Tests if the ``Family`` has any parents. arg: family_id (osid.id.Id): the ``Id`` of a family return: (boolean) - ``true`` if the family has parents, ``false`` otherwise raise: NotFound - ``family_id`` is not found raise: NullArgument - ``family_id`` is ``null`` raise: Operat... |
def is_parent_of_family(self, id_, family_id): """Tests if an ``Id`` is a direct parent of a family. arg: id (osid.id.Id): an ``Id`` arg: family_id (osid.id.Id): the ``Id`` of a family return: (boolean) - ``true`` if this ``id`` is a parent of ``family_id,`` ``false`` otherwise raise: NotFound - ``family_id`` is not fo... |
def get_parent_family_ids(self, family_id): """Gets the parent ``Ids`` of the given family. arg: family_id (osid.id.Id): the ``Id`` of a family return: (osid.id.IdList) - the parent ``Ids`` of the family raise: NotFound - ``family_id`` is not found raise: NullArgument - ``family_id`` is ``null`` raise: OperationFailed ... |
def get_parent_families(self, family_id): """Gets the parent families of the given ``id``. arg: family_id (osid.id.Id): the ``Id`` of the ``Family`` to query return: (osid.relationship.FamilyList) - the parent families of the ``id`` raise: NotFound - a ``Family`` identified by ``Id is`` not found raise: NullArgument - ... |
def is_ancestor_of_family(self, id_, family_id): """Tests if an ``Id`` is an ancestor of a family. arg: id (osid.id.Id): an ``Id`` arg: family_id (osid.id.Id): the ``Id`` of a family return: (boolean) - ``true`` if this ``id`` is an ancestor of ``family_id,`` ``false`` otherwise raise: NotFound - ``family_id`` is not f... |
def has_child_families(self, family_id): """Tests if a family has any children. arg: family_id (osid.id.Id): the ``Id`` of a family return: (boolean) - ``true`` if the ``family_id`` has children, ``false`` otherwise raise: NotFound - ``family_id`` is not found raise: NullArgument - ``family_id`` is ``null`` raise: Oper... |
def is_child_of_family(self, id_, family_id): """Tests if a family is a direct child of another. arg: id (osid.id.Id): an ``Id`` arg: family_id (osid.id.Id): the ``Id`` of a family return: (boolean) - ``true`` if the ``id`` is a child of ``family_id,`` ``false`` otherwise raise: NotFound - ``family_id`` is not found ra... |
def get_child_family_ids(self, family_id): """Gets the child ``Ids`` of the given family. arg: family_id (osid.id.Id): the ``Id`` to query return: (osid.id.IdList) - the children of the family raise: NotFound - ``family_id`` is not found raise: NullArgument - ``family_id`` is ``null`` raise: OperationFailed - unable to... |
def get_child_families(self, family_id): """Gets the child families of the given ``id``. arg: family_id (osid.id.Id): the ``Id`` of the ``Family`` to query return: (osid.relationship.FamilyList) - the child families of the ``id`` raise: NotFound - a ``Family`` identified by ``Id is`` not found raise: NullArgument - ``f... |
def is_descendant_of_family(self, id_, family_id): """Tests if an ``Id`` is a descendant of a family. arg: id (osid.id.Id): an ``Id`` arg: family_id (osid.id.Id): the ``Id`` of a family return: (boolean) - ``true`` if the ``id`` is a descendant of the ``family_id,`` ``false`` otherwise raise: NotFound - ``family_id`` i... |
def get_family_nodes(self, family_id, ancestor_levels, descendant_levels, include_siblings): """Gets a portion of the hierarchy for the given family. arg: family_id (osid.id.Id): the ``Id`` to query arg: ancestor_levels (cardinal): the maximum number of ancestor levels to include. A value of 0 returns no parents in the... |
osid.resource.BinHierarchySession.get_bin_nodes return objects.FamilyNode(self.get_family_node_ids( family_id=family_id, ancestor_levels=ancestor_levels, descendant_levels=descendant_levels, include_siblings=include_siblings)._my_map, runtime=self._runtime, proxy=self._proxy) |
def add_root_family(self, family_id): """Adds a root family. arg: family_id (osid.id.Id): the ``Id`` of a family raise: AlreadyExists - ``family_id`` is already in hierarchy raise: NotFound - ``family_id`` not found raise: NullArgument - ``family_id`` is ``null`` raise: OperationFailed - unable to complete request rais... |
def remove_root_family(self, family_id): """Removes a root family. arg: family_id (osid.id.Id): the ``Id`` of a family raise: NotFound - ``family_id`` not a root raise: NullArgument - ``family_id`` is ``null`` raise: OperationFailed - unable to complete request raise: PermissionDenied - authorization failure *complianc... |
def add_child_family(self, family_id, child_id): """Adds a child to a family. arg: family_id (osid.id.Id): the ``Id`` of a family arg: child_id (osid.id.Id): the ``Id`` of the new child raise: AlreadyExists - ``family_id`` is already a parent of ``child_id`` raise: NotFound - ``family_id`` or ``child_id`` not found rai... |
def remove_child_family(self, family_id, child_id): """Removes a child from a family. arg: family_id (osid.id.Id): the ``Id`` of a family arg: child_id (osid.id.Id): the ``Id`` of the new child raise: NotFound - ``family_id`` not a parent of ``child_id`` raise: NullArgument - ``family_id`` or ``child_id`` is ``null`` r... |
def remove_child_families(self, family_id): """Removes all children from a family. arg: family_id (osid.id.Id): the ``Id`` of a family raise: NotFound - ``family_id`` not in hierarchy raise: NullArgument - ``family_id`` is ``null`` raise: OperationFailed - unable to complete request raise: PermissionDenied - authorizat... |
def env(key, default=None, required=False): """ Retrieves environment variables and returns Python natives. The (optional) default will be returned if the environment variable does not exist. """ try: value = os.environ[key] return ast.literal_eval(value) except (SyntaxError, ValueError): return value except KeyError: ... |
def prepare_geojson(geojson): """ Modifies incoming GeoJSON to make it Elastic friendly. This means: 1. CW orientation of polygons. 2. Re-casting of Features and FeatureCollections to Geometry and GeometryCollections. """ # TODO CW orientation. geojson = deepcopy(geojson) if geojson["type"] == "Feature": geojson = geoj... |
def to_query(self): """ Returns a json-serializable representation. """ return { "geo_shape": { self.name: { "indexed_shape": { "index": self.index_name, "type": self.doc_type, "id": self.shape_id, "path": self.path } } } } |
def get_catalog(self): """Gets the ``Catalog`` at this node. return: (osid.cataloging.Catalog) - the catalog represented by this node *compliance: mandatory -- This method must be implemented.* """ if self._lookup_session is None: mgr = get_provider_manager('CATALOGING', runtime=self._runtime, proxy=self._proxy) self._... |
def get_parent_catalog_nodes(self): """Gets the parents of this catalog. return: (osid.cataloging.CatalogNodeList) - the parents of the ``id`` *compliance: mandatory -- This method must be implemented.* """ parent_catalog_nodes = [] for node in self._my_map['parentNodes']: parent_catalog_nodes.append(CatalogNode( node.... |
def get_next_parameters(self, n=None): """Gets the next set of ``Parameters`` in this list which must be less than or equal to the return from ``available()``. arg: n (cardinal): the number of ``Parameter`` elements requested which must be less than or equal to ``available()`` return: (osid.configuration.Parameter) - a... |
< n: try: next_list.append(self.next()) except: # Need to specify exceptions here raise OperationFailed() x = x + 1 return next_list |
def data_attrs(mapitem): """ Generate the data-... attributes for a mapitem. """ data_attrs = {} try: data_attrs['marker-detail-api-url'] = reverse('fluentcms-googlemaps-marker-detail') except NoReverseMatch: pass data_attrs.update(mapitem.get_map_options()) return mark_safe(u''.join([ format_html(u' data-{0}="{1}"', k... |
def get_grade_system_query_session(self): """Gets the ``OsidSession`` associated with the grade system query service. return: (osid.grading.GradeSystemQuerySession) - a ``GradeSystemQuerySession`` raise: OperationFailed - unable to complete request raise: Unimplemented - ``supports_grade_system_query()`` is ``false`` *... |
def get_grade_system_query_session_for_gradebook(self, gradebook_id): """Gets the ``OsidSession`` associated with the grade system query service for the given gradebook. arg: gradebook_id (osid.id.Id): the ``Id`` of the gradebook return: (osid.grading.GradeSystemQuerySession) - ``a GradeSystemQuerySession`` raise: NotF... |
def get_grade_system_admin_session(self): """Gets the ``OsidSession`` associated with the grade system administration service. return: (osid.grading.GradeSystemAdminSession) - a ``GradeSystemAdminSession`` raise: OperationFailed - unable to complete request raise: Unimplemented - ``supports_grade_system_admin()`` is ``... |
def get_grade_entry_query_session(self): """Gets the ``OsidSession`` associated with the grade entry query service. return: (osid.grading.GradeEntryQuerySession) - a ``GradeEntryQuerySession`` raise: OperationFailed - unable to complete request raise: Unimplemented - ``supports_grade_entry_query()`` is ``false`` *compl... |
def get_grade_entry_query_session_for_gradebook(self, gradebook_id): """Gets the ``OsidSession`` associated with the grade entry query service for the given gradebook. arg: gradebook_id (osid.id.Id): the ``Id`` of the gradebook return: (osid.grading.GradeEntryQuerySession) - ``a GradeEntryQuerySession`` raise: NotFound... |
def get_grade_entry_admin_session(self): """Gets the ``OsidSession`` associated with the grade entry administration service. return: (osid.grading.GradeEntryAdminSession) - a ``GradeEntryAdminSession`` raise: OperationFailed - unable to complete request raise: Unimplemented - ``supports_grade_entry_admin()`` is ``false... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.