caoscrawler.utils module#

caoscrawler.utils.MissingImport(name: str, hint: str = '', err: Exception | None = None) type#

Factory with dummy classes, which may be assigned to variables but never used.

caoscrawler.utils.get_by_name_and_role(name: str, recordtype: str | None = None, roles: list[str] = ['ENTITY']) Entity#

Cached retrieve by name while prioritising based on entity type. ToDo: Rewrite once new query functions are merged. Or even move to get_entity_by.

Parameters:
  • name (str) – The name of the record to retrieve

  • recordtype (str, optional) – Limit results to a given recordtype

  • roles (list[str], default ["ENTITY"]) – List of the roles to check, in order.

Returns:

entity – Retrieved entity.

Return type:

db.Entity

Return a link adress which is basically {host_url}/Shared/{filename}.

Use urllib.parse.join and os.path.join to prevent missing or extra / and the like.

caoscrawler.utils.has_parent(entity: Entity, name: str)#

A simple check, whether a parent with the given name exists.

There is a similar, however more complex function in package caosdb.