fdi.pal package
Subpackages
Submodules
fdi.pal.comparable module
fdi.pal.context module
- class fdi.pal.context.AbstractContext(*args, **kwds)[源代码]
基类:
object
A special kind of Product that can hold references to other Products.
This abstract product introduces the lazy loading and saving of references to Products or ProductRefs that it is holding. It remembers its state. http://herschel.esac.esa.int/hcss-doc-15.0/load/hcss_drm/api/herschel/ia/pal/Context.html
Sets
rule
toNone
ifzInfo
does not haverefs
, else tozInfo['refs']
.- addRule(rule)[源代码]
Add to the rule that controls the products to be added into the context. The new rule will be old rule AND added rule.
- applyRule(*args)[源代码]
returns True if the input ProductRef passes rule.
If
refs
is not specified inzInfo
return True. If ``zInfo[‘refs’] is empty, return True.Subclasses can override this method according to what is written in zInfo.
- getAllRefs(recursive, includeContexts)[源代码]
Provides a set of the unique references stored in this context.
- hasDirtyReferences(storage)[源代码]
Returns a logical to specify whether this context has dirty references or not.
- isValid()[源代码]
Provides a mechanism to ensure whether it is valid to store this context in its current state.
- readDataset(storage, table, defaultPoolId)[源代码]
Reads a dataset with information within this context that is normally not accessible from the normal Product interface.
- property refs
Property
- refsChanged()[源代码]
Indicates that the references have been changed in memory, which marks this context as dirty.
- class fdi.pal.context.Context(*args, **kwds)[源代码]
基类:
fdi.pal.context.AbstractContext
,fdi.dataset.baseproduct.BaseProduct
See docstring of AbstractContext.
- applyRule(*args)[源代码]
returns True if the input ProductRef passes rule.
Default behavior is return the superclass.applyRule() result.
Subclasses can override this method according to what is written in zInfo.
- getAllRefs(recursive=False, includeContexts=True, seen=None)[源代码]
Provides a set of the unique references stored in this Context.
This includes references that are contexts, but not the contents of these subcontexts. This is equivalent to getAllRefs(recursive=false, includeContexts= true). recursive - if true, include references in subcontexts includeContexts - if true, include references to contexts, not including this one
- class fdi.pal.context.MapContext(*args, **kwds)[源代码]
-
Allows grouping Products into a map of (String, ProductRef) pairs. New entries can be added if they comply to the adding rules of this context. The default behaviour is to allow adding any (String,ProductRef) given that
rule
is not set.An example:
image = ImageProduct(description="hi") spectrum = SpectrumProduct(description="there") simple = Product(description="everyone") context=MapContext() context.refs.put("x",ProductRef(image)) context.refs.put("y",ProductRef(spectrum)) context.refs.put("z",ProductRef(simple)) print context.refs.size() # 3 print context.refs.get('x').product.description # hi print context.refs.get('y').product.description # there print context.refs.get('z').product.description # everyone
It is possible to insert a ProductRef at a specific key in the MapContext. The same insertion behaviour is followed as for a Python dict, in that if there is already an existing ProductRef for the given key, that ProductRef is replaced with the new one:
product4=SpectrumProduct(description="everybody") context.refs.put("y", ProductRef(product4)) product5=SpectrumProduct(description="here") context.refs.put("a", ProductRef(product5)) print context.refs.get('x').product.description # hi print context.refs.get('y').product.description # everybody print context.refs.get('z').product.description # everyone print context.refs.get('a').product.description # here
Note that the rules are only applied when putting an entry to the map!
Be aware that
the put() method of the map view may throw a ContextRuleException if the data added to the context violates the rules applied to the context.
the put() method of the map view may throw a ValueError if either of the arguments to the put() method are null.
- BaseProduct–Product
AbstractContext——Contex———MapContext
- addRule(rule)[源代码]
Add to the rule that controls the products to be added into the context. The new rule will be old rule AND added rule.
- applyRule(key, ref)[源代码]
returns True if the input key name and ProductRef pass rule.
Default behavior is return True if the fully qualified class name of the product which ref refers to equals
zInfo['refs'][key]
, OR the superclass.applyRule() result.Subclasses can override this method according to what is written in zInfo.
- class fdi.pal.context.RefContainer(**kwds)[源代码]
-
A map where Rules of its owner Context are applied when put(k,v) is called, and the owner MapContext’s ID can be put to v’s parents list.
Implemented as an ODict that RefContainer has a _STID when json.loads’ed. A MapContext has a _data, which has a refs:RefContainer, which has a datap, which has a name:ProductRef. when used as context.refs.get(‘x’).product.description, the RefContainer is called with get() or __getitem__(), which calls superclass composite’s __getitem__()
- property owner
Property
- put(key, ref)
set label-ref pair after validating then add parent to the ref
- setOwner(owner)[源代码]
records who owns this container.
Due to reason described in __setitem__ doc, existing refs will be set again upon owner set
- string(level=0, tablefmt='grid', **kwds)
- level
default=0,
- keyval
default=`None`. If set to a string, ODict class name is not shown and a label of given string is shown with each key as ‘label key:
- ‘.
- tablefmt
=’rst’, tablefmt1=’simple’, tablefmt2=’simple’, matprint=None, trans=True, heavy=True
- toString(level=0, tablefmt='grid', **kwds)[源代码]
- level
default=0,
- keyval
default=`None`. If set to a string, ODict class name is not shown and a label of given string is shown with each key as ‘label key:
- ‘.
- tablefmt
=’rst’, tablefmt1=’simple’, tablefmt2=’simple’, matprint=None, trans=True, heavy=True
fdi.pal.definable module
- class fdi.pal.definable.Definable(**kwds)[源代码]
基类:
object
for items being able to be defined with a Definition.
- getDefinition()[源代码]
Returns the definition associated to this definable item. mh: adopting http://herschel.esac.esa.int/hcss-doc-15.0/load/hcss_drm/api/index.html?herschel/ia/pal/ProductRef.html but parameterize definition does not seem worth it given the few numbers of implemented definitions
fdi.pal.dicthk module
- class fdi.pal.dicthk.DictHk(**kwds)[源代码]
-
Definition of services provided by a product storage supporting versioning.
- getTags(urn=None)[源代码]
Get all of the tags that map to a given URN. Get all known tags if urn is not specified. mh: returns an iterator.
- getUrn(tag)[源代码]
Gets the URNs corresponding to the given tag. Returns an empty list if tag does not exist.
fdi.pal.httpclientpool module
- class fdi.pal.httpclientpool.HttpClientPool(**kwds)[源代码]
基类:
fdi.pal.productpool.ProductPool
the pool will save all products on a remote server.
Initialize connection to the remote server. creates file structure if there isn’t one. if there is, read and populate house-keeping records. create persistent files on server if not exist.
- __init__(**kwds)[源代码]
Initialize connection to the remote server. creates file structure if there isn’t one. if there is, read and populate house-keeping records. create persistent files on server if not exist.
- getProductClasses(**kwds)[源代码]
Returns all Product classes found in this pool. mh: returns an iterator.
- getTags(**kwds)[源代码]
Get all of the tags that map to a given URN. Get all known tags if urn is not specified. mh: returns an iterator.
- getUrn(**kwds)[源代码]
Gets the URNs corresponding to the given tag. Returns an empty list if tag does not exist.
- removeAll(**kwds)[源代码]
Remove all pool data (self, products) and all pool meta data (self, descriptors, indices, etc.).
- schematicLoad(resourcetype, index, start=None, end=None, serialize_out=False)[源代码]
does the scheme-specific part of loadProduct.
- schematicRemove(urn=None, resourcetype=None, index=None)[源代码]
does the scheme-specific part of removal.
urn or (resourcetype, index)
- schematicSave(products, tag=None, geturnobjs=False, serialize_out=False, **kwds)[源代码]
does the media-specific saving to remote server.
- fdi.pal.httpclientpool.parseApiArgs1(all_args, serialize_out=False)[源代码]
parse the command path to get positional and keywords arguments.
all_args: a list of path segments for the args list.
fdi.pal.httppool module
- class fdi.pal.httppool.HttpPool(**kwds)[源代码]
基类:
fdi.pal.localpool.LocalPool
the pool will save all products locally on the host Http server.
creates file structure if there isn’t one. if there is, read and populate house-keeping records. create persistent files if not exist.
fdi.pal.localpool module
- class fdi.pal.localpool.LocalPool(makenew=True, **kwds)[源代码]
基类:
fdi.pal.productpool.ManagedPool
the pool will save all products in local computer.
- Makenew
when the pool does not exist, make a new one (
``True`
; default) or throws PoolNotFoundError (`False`
).
creates file structure if there isn’t one. if there is, read and populate house-keeping records. create persistent files if not exist.
- __init__(makenew=True, **kwds)[源代码]
creates file structure if there isn’t one. if there is, read and populate house-keeping records. create persistent files if not exist.
- doLoad(resourcetype, index, start=None, end=None, serialize_out=False)[源代码]
does the action of loading.
serialize_out: if True returns contents in serialized form.
- doSave(resourcetype, index, data, tag=None, serialize_in=True, **kwds)[源代码]
does the media-specific saving.
index: int
- getHead(ref)[源代码]
Returns the latest version of a given product, belonging to the first pool where the same track id is found.
- getMetaByUrn(urn, resourcetype=None, index=None)[源代码]
Get all of the meta data belonging to a product of a given URN.
mh: returns an iterator.
- readHK(hktype=None, serialize_out=False)[源代码]
loads and returns the housekeeping data
hktype: one of ‘classes’, ‘tags’, ‘urns’ to return. default is None to return alldirs serialize_out: if True return serialized form. Default is false.
- setMetaByUrn(start, end, urn)[源代码]
Sets the location of the meta data of the specified data to the given URN.
- Data
usually serialized Product.
- setup()[源代码]
Sets up LocalPool interals.
Make sure that self._poolname and self._poolurl are present.
- writeJsonmmap(fp, data, serialize_in=True, serialize_out=False, close=False, check_time=False, meta_location=False, **kwds)[源代码]
write data in JSON from mmap file at fp.
register the file. Leave file open by default close. data: to be serialized and saved. serialize_out: if True returns contents in serialized form. :check_time: to check if file has not been written since we did last time. Default False. :meta_location: return the start and end offsets of metadata in data JSON. Default False. :return: int bytes written. If meta_location is
`True`
, adding int int start and end point offsets of metadata in seriaized data.
fdi.pal.mempool module
- class fdi.pal.mempool.MemPool(**kwds)[源代码]
基类:
fdi.pal.productpool.ManagedPool
the pool will save all products in memory.
creates data structure if there isn’t one. if there is, read and populate house-keeping records. create persistent files if not exist.
- __init__(**kwds)[源代码]
creates data structure if there isn’t one. if there is, read and populate house-keeping records. create persistent files if not exist.
- doLoad(resourcetype, index, start=0, end=0, serialize_out=False)[源代码]
does the action of loadProduct. note that the index is given as a string.
- doSave(resourcetype, index, data, tag=None, serialize_in=True, **kwds)[源代码]
does the media-specific saving
- getHead(ref)[源代码]
Returns the latest version of a given product, belonging to the first pool where the same track id is found.
- getMetaByUrn(urn, resourcetype=None, index=None)[源代码]
Get all of the meta data belonging to a product of a given URN.
- readHK(hktype=None, serialize_in=True, serialize_out=False)[源代码]
loads and returns the housekeeping data
hktype: one of ‘classes’, ‘tags’, ‘urns’ to return. default is None to return alldirs serialize_out: if True return serialized form. Default is false.
- setMetaByUrn(data, urn)[源代码]
Sets the location of the meta data of the specified data to the given URN.
- Data
usually unserialized Product.
fdi.pal.poolmanager module
- class fdi.pal.poolmanager.PoolManager[源代码]
基类:
object
This class provides the means to reference ProductPool objects without having to hard-code the type of pool. For example, it could be desired to easily switch from one pool type to another.
This is done by calling the getPool() method, which will return an existing pool or create a new one if necessary.
- PlacePaths = {'file': '/tmp', 'http': '127.0.0.1:9883/fdi/v0.12', 'https': '127.0.0.1:9883/fdi/v0.12', 'mem': '/', 'server': '/tmp/data'}
- classmethod getPool(poolname=None, poolurl=None, pool=None, makenew=True, **kwds)[源代码]
returns an instance of pool according to name or path of the pool.
Returns the pool object if the pool is registered. Creates the pool if it does not already exist. the same poolname-path always get the same pool. Http pools will be registered on the sserver side.
Pools registered are kept as long as the last reference remains. When the last is gone the pool gets :meth;`removed` d.
- poolname
name of the pool.
- poolurl
if given the poolpath, scheme, place will be derived from it. if not given for making a new pool (i.e. when poolname is not a registered pool name..
- If poolname is missing it is derived from poolurl; if poolurl is also absent, ValueError will be raised.
- makenew
when the pool does not exist, make a new one (
``True`
; default) or throws PoolNotFoundError (`False`
).- kwds
passed to pool instanciation arg-list.
- Returns
the pool object.
- classmethod isLoaded(poolname)[源代码]
Whether an item with the given id has been loaded (cached).
- 返回
the number of remaining week references if the pool is loaded. Returns 0 if poolname is not found in _GlobalPoolList or weakref count is 0.
fdi.pal.productpool module
- class fdi.pal.productpool.ManagedPool(**kwds)[源代码]
基类:
fdi.pal.productpool.ProductPool
,fdi.pal.dicthk.DictHk
A ProductPool that manages its internal house keeping.
Creates and initializes a productpool.
poolname: if provided will override that in poolurl.
poolurl: needed to initialize.
- doLoad(resourcetype, index, start=None, end=None, serialize_out=False)[源代码]
to be implemented by subclasses to do the action of loading
- doSave(resourcetype, index, data, tag=None, serialize_in=True, **kwds)[源代码]
to be implemented by subclasses to do the action of saving
- getMetaByUrn(urn, resourcetype=None, index=None)[源代码]
Get all of the meta data belonging to a product of a given URN.
mh: returns an iterator.
- getPoolpath()[源代码]
Gets the poolpath of this pool.
poolpath is usually derived from poolurl received from
PoolManager
during initialization.
- meta_filter(q, typename=None, reflist=None, urnlist=None, snlist=None)[源代码]
returns filtered collection using the query.
q is a MetaQuery valid inputs: typename and ns list; productref list; urn list
- prod_filter(q, cls=None, reflist=None, urnlist=None, snlist=None)[源代码]
returns filtered collection using the query.
q: an AbstractQuery. valid inputs: cls and ns list; productref list; urn list
- saveOne(prd, tag, geturnobjs, serialize_in, serialize_out, res, kwds)[源代码]
Save one product.
- Res
list of result.
- Serialize_out
if True returns contents in serialized form.
- schematicLoad(resourcetype, index, start=None, end=None, serialize_out=False)[源代码]
do the scheme-specific loading
- schematicSave(products, tag=None, geturnobjs=False, serialize_in=True, serialize_out=False, **kwds)[源代码]
do the scheme-specific saving.
- Serialize_out
if True returns contents in serialized form.
- setMetaByUrn(start, end, urn)[源代码]
Sets the location of the meta data of the specified data to the given URN.
- Data
usually un/serialized Product.
- setup()[源代码]
- Sets up interal machiney of this Pool,
but only if self._poolname and self._poolurl are present, and other pre-requisits are met.
Subclasses should implement own setup(), and make sure that self._poolname and self._poolurl are present with ``
if <pre-requisit not met>: return True if super().setup(): return True
# super().setup() has done its things by now. <do setup> return False
- ``
returns: True if not both self._poolname and self._poolurl are present.
- class fdi.pal.productpool.ProductPool(poolname='', poolurl='', **kwds)[源代码]
基类:
fdi.pal.definable.Definable
,fdi.pal.taggable.Taggable
,fdi.pal.versionable.Versionable
A mechanism that can store and retrieve Products.
A product pool should not be used directly by users. The general user should access data in a ProductPool through a ProductStorage instance.
When implementing a ProductPool, the following rules need to be applied:
Pools must guarantee that a Product saved via the pool saveProduct(Product) method is stored persistently, and that method returns a unique identifier (URN). If it is not possible to save a Product, an IOException shall be raised.
A saved Product can be retrieved using the loadProduct(Urn) method, using as the argument the same URN that assigned to that Product in the earlier saveProduct(Product) call. No other Product shall be retrievable by that same URN. If this is not possible, an IOException or GeneralSecurityException is raised.
Pools should not implement functionality currently implemented in the core package. Specifically, it should not address functionality provided in the Context abstract class, and it should not implement versioning/cloning support.
Creates and initializes a productpool.
poolname: if provided will override that in poolurl.
poolurl: needed to initialize.
- __init__(poolname='', poolurl='', **kwds)[源代码]
Creates and initializes a productpool.
poolname: if provided will override that in poolurl.
poolurl: needed to initialize.
- getDefinition()[源代码]
Returns pool definition info which contains pool type and other pool specific configuration parameters
- getUrnId()[源代码]
Get the identifier of this pool used to build URN, usually it’s same as id returned by getId().
- loadProduct(urn, serialize_out=False)[源代码]
Loads a Product belonging to specified URN.
serialize_out: if True returns contents in serialized form.
- property poolname
for property getter
- property poolurl
for property getter
- removeAll()[源代码]
Remove all pool data (self, products) and all pool meta data (self, descriptors, indices, etc.).
- saveProduct(product, tag=None, geturnobjs=False, serialize_in=True, serialize_out=False, **kwds)[源代码]
Saves specified product and returns the designated ProductRefs or URNs.
Saves a product or a list of products to the pool, possibly under the supplied tag, and returns the reference (or a list of references if the input is a list of products), or Urns if geturnobjs is True.
See pal document for pool structure.
serialize_out: if True returns contents in serialized form.
- schematicLoad(resourcetype, index, start=None, end=None, serialize_out=False)[源代码]
to be implemented by subclasses to do the scheme-specific loading
- schematicRemove(urn=None, resourcetype=None, index=None)[源代码]
to be implemented by subclasses to do the scheme-specific removing
- schematicSave(products, tag=None, geturnobjs=False, serialize_in=True, serialize_out=False, **kwds)[源代码]
to be implemented by subclasses to do the scheme-specific saving
- schematicSelect(query, results=None)[源代码]
to be implemented by subclasses to do the scheme-specific querying.
- select(query, variable='m', ptype=<class 'fdi.dataset.product.Product'>, results=None)[源代码]
Returns a list of references to products that match the specified query.
- setup()[源代码]
- Sets up interal machiney of this Pool,
but only if self._poolname and self._poolurl are present, and other pre-requisits are met.
Subclasses should implement own setup(), and make sure that self._poolname and self._poolurl are present with ``
if <pre-requisit not met>: return True if super().setup(): return True
# super().setup() has done its things by now. <do setup> return False
- ``
returns: True if not both self._poolname and self._poolurl are present.
fdi.pal.productref module
- class fdi.pal.productref.ProductRef(urn=None, poolname=None, product=None, meta=None, **kwds)[源代码]
基类:
fdi.dataset.metadataholder.MetaDataHolder
,fdi.dataset.eq.DeepcmpEqual
,fdi.dataset.serializable.Serializable
,fdi.pal.comparable.Comparable
A lightweight reference to a product that is stored in a ProductPool or in memory.
Urn can be the string or URNobject.
Poolname if given overrides the pool name in urn, and causes metadata to be loaded from pool, unless this prodref points to a mempool. If meta is given, it will be used instead of that from poolname. A productref created from a single product will result in a memory pool urn, and the metadata won’t be loaded.
- __init__(urn=None, poolname=None, product=None, meta=None, **kwds)[源代码]
Urn can be the string or URNobject.
Poolname if given overrides the pool name in urn, and causes metadata to be loaded from pool, unless this prodref points to a mempool. If meta is given, it will be used instead of that from poolname. A productref created from a single product will result in a memory pool urn, and the metadata won’t be loaded.
- equals(o, verbose=False)[源代码]
true if o is a non-null ProductRef, with the same Product type than this one, and:
urns and products are null in both refs, or nurs are equal and products are null, or # <– mh urns are null in both refs, and their products are equal, or urns and products are equal in both refs
- getHash()[源代码]
Returns a code number for the product; actually its MD5 signature. This allows checking whether a product already exists in a pool or not.
- getParents()[源代码]
Return the in-memory parent context products of this reference.
That is, the contexts in program memory that contain this product reference object. A context that contains a different product reference object pointing to the same URN is not a parent of this product reference.
Furthermore, it should be understood that this method does not return the parent contexts of the product pointed to by this reference as stored in any underlying pool or storage.
Returns: the parents
- getProduct()[源代码]
Get the product that this reference points to.
If the product is a Context, it is kept internally, so further accesses don’t need to ask the storage for loading it again. Otherwise, the product is returned but the internal reference remains null, so every call to this method involves a request to the storage.
This way, heavy products are not kept in memory after calling this method, thus maintaining the ProductRef a lighweight reference to the target product.
In case of a Context, if it is wanted to free the reference, call unload().
Returns: the product
- getSize()[源代码]
Returns the estimated size(in bytes) of the product in memory.
Useful for providing this information for a user that wants to download the product from a remote site. Returns: the size in bytes
- property meta
Property
- property parents
property
- property product
- setParents(parents)[源代码]
Sets the in-memory parent context products of this reference.
- 参数
parents –
- setUrnObj(urnobj, poolname=None, meta=None)[源代码]
sets urn
A productref created from a single product will result in a memory pool urn, and the metadata won’t be loaded.
urnobj: Urn a URN object. poolname: str if given overrides the pool name in urn, and causes metadata to be loaded from pool. meta: MetaData If is given, it will be used instead of that from poolname.
- string(level=0, **kwds)
- unload()[源代码]
Clear the cached meta and frees internal reference to the product, so it can be garbage collected.
- property urn
Property
- property urnobj
Property
fdi.pal.productstorage module
- class fdi.pal.productstorage.ProductStorage(pool=None, poolurl=None, **kwds)[源代码]
基类:
object
Logical store created from a pool or a poolURL.
Every instanciation with the same pool will result in a new instance of ProdStorage.
Gets the storage “control pannel” for pool with specifed name.
pool: if is a string will be taken as a poolname. if is a pool object will be registered with its name, poolurl: is sent to the PoolManager with poolname to get the pool object.
- __init__(pool=None, poolurl=None, **kwds)[源代码]
Gets the storage “control pannel” for pool with specifed name.
pool: if is a string will be taken as a poolname. if is a pool object will be registered with its name, poolurl: is sent to the PoolManager with poolname to get the pool object.
- getHead(ref)[源代码]
Returns the latest version of a given product, belonging to the first pool where the same track id is found.
- getMeta(urn)[源代码]
Get the metadata belonging to the writable pool that associated to a given URN. returns an ODict.
- getTags(urn)[源代码]
Get the tags belonging to the writable pool that associated to a given URN. returns an iterator.
- getUrnFromTag(tag)[源代码]
Get the URN belonging to the writable pool that is associated to a given tag.
- load(urnortag)[源代码]
Loads a product with a URN or a list of products with a tag, from the (writeable) pool.
It always creates new ProductRefs. :return: productref if there is only one. A
`list`
of`ProductRefs`
. urnortag: urn or tag
- register(poolname=None, poolurl=None, pool=None, **kwds)[源代码]
Registers the given pools to the storage.
- save(product, tag=None, poolname=None, geturnobjs=False, **kwds)[源代码]
saves to the writable pool if it has been registered.
product: can be one or a list of prpoducts. poolName: if the named pool is not registered, registers and saves. geturnobjs: mh: returns UrnObjs if geturnobjs is True. kwds: options passed to json.dump() for localpools. Returns: one or a list of productref with storage info.
fdi.pal.query module
- class fdi.pal.query.AbstractQuery(product=<class 'fdi.dataset.product.Product'>, variable='p', where='', allVersions=False, **kwds)[源代码]
-
provides default implementations for the pal storage query.
creates an AbstractQuery with product variable name, query string or function.
product: type (Class or ‘Card’ name) of the products to be queried. where: the query string.
- class fdi.pal.query.MetaQuery(product=<class 'fdi.dataset.product.Product'>, where='', allVersions=False, **kwds)[源代码]
基类:
fdi.pal.query.AbstractQuery
Meta data query formulates a query on the meta data of a Product.
Typically this type of query is faster than a full query on the Product Access Layer.
creates an MetaQuery with a query string or function.
product: type (Class or ‘Card’ name) of the products to be queried. where: the query string. ‘where’ is a query string or function that returns True or False. In the query string variable name is ‘m’ for a MetaData type, as in
m = product.meta
.- __init__(product=<class 'fdi.dataset.product.Product'>, where='', allVersions=False, **kwds)[源代码]
creates an MetaQuery with a query string or function.
product: type (Class or ‘Card’ name) of the products to be queried. where: the query string. ‘where’ is a query string or function that returns True or False. In the query string variable name is ‘m’ for a MetaData type, as in
m = product.meta
.
fdi.pal.taggable module
- class fdi.pal.taggable.Taggable(**kwds)[源代码]
基类:
object
Definition of services provided by a product storage supporting tagging.
- getTags(urn=None)[源代码]
Get all of the tags that map to a given URN. Get all known tags if urn is not specified. mh: returns an iterator.
fdi.pal.urn module
- class fdi.pal.urn.Urn(urn=None, poolname=None, cls=None, index=None, poolurl=None, **kwds)[源代码]
基类:
fdi.dataset.eq.DeepcmpEqual
,fdi.dataset.serializable.Serializable
,fdi.pal.comparable.Comparable
The object representation of the product URN string.
The memory consumed by sets of this object are much less than sets of URN strings.
Only when the class types in URN string are not in classpath, the urn object will consume equals or a little more than URN string as the object has to hold the original urn string. However this should be considered as exceptional cases.
Using this object representation also help to avoid parsing cost of URN string. URN string should be immutable.
About_URN
The Universial Resource Name (URN) string has this format:
urn:<poolname>:<resourcetype>:<serialnumber>
where
- <poolname>
Also called poolID. Its requirements is like that to a file name and a URL segment, having only printable characters excluding ``
, ``%
,?
,*
,=
,/
.- <resourcetype>
class name of the data item (usually
Product
)- <serialnumber>
internal index for a certain <resourcetype>.
The
poolname
in a URN is a label. Some examples:Storage Pools (subclasses of
ProductPool
) are where data item reside. The PoolURL is used to give practical information of a pool, such as a poolname, its location, and its access scheme. It is designed to be a local set-up detail that is supposed to be hidden from pool users. Data processing software use ``URN``s to refer to products, without specifying pool location. The poolID in a URN could be aLocalPool
on the development laptop and aHTTPClientPool
on the production cloud.Creates the URN object with the urn string or components.
give urn and optional poolurl, or all poolname, cls, index arguments. if urn is given and pool, class, etc are also specified, the latter are ignored. else the URN object is constructed from them. Urn(u) will make a Urn object out of u.
All arguements are None by default.
- __init__(urn=None, poolname=None, cls=None, index=None, poolurl=None, **kwds)[源代码]
Creates the URN object with the urn string or components.
give urn and optional poolurl, or all poolname, cls, index arguments. if urn is given and pool, class, etc are also specified, the latter are ignored. else the URN object is constructed from them. Urn(u) will make a Urn object out of u.
All arguements are None by default.
- property place
- property pool
returns the poolname.
- string(level=0, **kwds)
- property urn
property
- class fdi.pal.urn.UrnUtils[源代码]
基类:
object
- fdi.pal.urn.makeUrn(poolname, typename, index)[源代码]
assembles a URN with infos of the pool, the resource type, and the index
index: int or string
- fdi.pal.urn.parseUrn(urn)[源代码]
Checks the URN string is valid in its form and splits it.
A Product URN has several segment. For example if the urn is
urn:mypool/v2:proj1.product:322
* poolname, also called poolURN or poolID, optionally path-like:mypool/v2
, * resource type (usually class) nameproj1.product
, * index number322
,returns poolname, resourceclass, index. if urn is None or empty returns (None,None,None)
- fdi.pal.urn.parse_poolurl(url, poolhint=None)[源代码]
Disassambles a pool URL.
A Pool URL is It is generated to desribe . For example:
input: * url: to be decomposed. * poolhint: A urn or a poolname (the first distinctive substring) needs to be given if the poolname has more than one level.
returns: poolpath, scheme, place, poolname. returns (None, None,None,None) if url is None or empty.
About_poolURL
The
PoolURL
format is in the form of a URL that preceeds its poolname part:<scheme>://<place><poolpath>/<poolname>
- <scheme>
Implementation protocol including
file
forLocalPool
,mem
forMemPool
,http
,https
forHttpclientPool
.- <place>
IP:port such as``192.168.5.6:8080`` for
http
andhttps
schemes, or an empty string forfile
andmem
schemes.- <poolname>
same as in URN.
- <poolpath>
The part between
place
and an optionalpoolhint
:- <username>
- <password>
For
file
orserver
schemes, e.g. poolpath is/c:/tmp
inhttp://localhost:9000/c:/tmp/mypool/
withpoolhint
keyword arguement ofparse_poolurl()
not given, or given asmypool
(ormyp
ormy
…).For
http
andhttps
schemes, it is e.g./0.6/tmp
inhttps://10.0.0.114:5000/v0.6/tmp/mypool
withpoolhint
keyword arguement not given, or given asmypool
(ormyp` or 'my' ...). The meaning of poolpath is subject to interpretation by the server. In the preceeding example the poolpath has an API version. :meth:`ProductPool.transformpath` is used to map it further. Note that trailing blank and ``/
are ignored, and stripped in the output.
Examples:
file:///tmp/mydata for pool
`mydata`
file:///d:/data/test2–v2 for pool
test2--v2
mem:///dummy for pool
dummy
https://10.0.0.114:5000/v0.6/obs for a httpclientpool
obs
server:///tmp/data/0.4/test for a pool
test
used on a server.