Package gavo :: Module rscdesc
[frames] | no frames]

Module rscdesc

source code

Structure definition of resource descriptors.

The stuff they are describing is not a resource in the VO sense (whatever that is) or in the Dublin Core sense, but simply stuff held together by common metadata. If it's got the same creator, the same base title, the same keywords, etc., it's described by one RD.

In the DaCHS, a resource descriptor typically sets up a schema in the database.

Classes
  RD
A resource descriptor.
  RDParseContext
is a parse context for RDs.
  PkgResourcePath
A sentinel class used to mark an RD as coming from pkg_resources.
  CachedException
An exception that occurred while parsing an RD.
Functions
 
canonicalizeRDId(srcId)
returns a standard rd id for srcId.
source code
 
getRDInputStream(srcId)
returns a read-open stream for the XML source of the resource descriptor with srcId.
source code
 
setRDDateTime(rd, inputFile)
guesses a date the resource was updated.
source code
 
getRD(srcId, doQueries=True, restricted=False, useRD=None)
returns a ResourceDescriptor for srcId.
source code
Variables
  USERCONFIG_RD_PATH = u'/home/msdemlei/gavo/etc/userconfig'
  __package__ = 'gavo'
Function Details

canonicalizeRDId(srcId)

source code 

returns a standard rd id for srcId.

srcId may be a file system path, or it may be an "id". The canonical basically is "inputs-relative path without .rd extension". Everything that's not within inputs or doesn't end with .rd is handed through. // is expanded to __system__/. The path to built-in RDs, /resources/inputs, is treated analoguous to inputsDir.

getRDInputStream(srcId)

source code 

returns a read-open stream for the XML source of the resource descriptor with srcId.

srcId is already normalized; that means that absolute paths must point to a file (sans possibly .rd), relative paths are relative to inputsDir or pkg_resources(/resources/inputs).

This function prefers files with .rd to those without, and inputsDir to pkg_resources (the latter allowing the user to override built-in system RDs).

setRDDateTime(rd, inputFile)

source code 

guesses a date the resource was updated.

This uses either the timestamp on inputFile or the rd's import timestamp, whatever is newer.

getRD(srcId, doQueries=True, restricted=False, useRD=None)

source code 

returns a ResourceDescriptor for srcId.

srcId is something like an input-relative path; you'll generally omit the extension (unless it's not the standard .rd).

getRD furnishes the resulting RD with an idmap attribute containing the mapping from id to object collected by the parse context.

The useRD parameter is for _loadRDIntoCache exclusively and is used by it internally. It is strictly an ugly implementation detail.