12 Module to configure the persistency type in GaudiPython.
14 __author__ =
"Marco Clemencic <marco.clemencic@cern.ch>"
19 Base class for exceptions in PersistencyHelper.
27 Exception raised if the persistency type is not known to the module.
31 super(UnknownPersistency, self).
__init__(
"Unknown persistency type %r" % type_)
41 Return the PersistencyHerper implementing the given persistency type.
43 for i
in _implementations:
51 Function to extend the list of known helpers.
53 New helpers are added to the top of the list.
55 _implementations.insert(0, instance)
59 def __init__(self, filename, opt, svc, sel=None, collection=None, fun=None):
61 Class to hold/manipulate the file description.
63 @param filename: name of the file
64 @param opt: option (READ/CREATE/RECREATE/WRITE)
65 @param svc: conversion service (or selector)
66 @param sel: selection expression
67 @param collection: collection
68 @param fun: selection class
79 Return a list of pairs describing the instance.
92 Return the string representation of the file description to be passed
95 return " ".join([
"%s='%s'" % (k, v)
for k, v
in self.
__data__()
if v])
100 Base class for extensions to persistency configuration in GaudiPython.
105 Define the type of persistencies supported by the instance.
111 Returns True if the current instance understands the requested
114 return typ
in self.
types
119 Implementation of PersistencyHelper based on Gaudi::RootCnvSvc.
126 Declare the type of supported persistencies to the base class.
128 super(RootPersistency, self).
__init__(
129 [
"ROOT",
"POOL_ROOT",
"RootCnvSvc",
"Gaudi::RootCnvSvc"]
139 appMgr.service(
"Gaudi::RootCnvSvc/RootCnvSvc")
140 eps = appMgr.service(
"EventPersistencySvc")
141 eps.CnvServices += [
"RootCnvSvc"]
146 Translate a list of file names in a list of input descriptions.
148 The optional parameters 'collection', 'sel' and 'fun' should be used to
149 configure Event Tag Collection inputs.
151 @param filenames: the list of files
155 if type(filenames)
is str:
156 filenames = [filenames]
160 [(k, kwargs[k])
for k
in [
"collection",
"sel",
"fun"]
if k
in kwargs]
164 svc =
"Gaudi::RootCnvSvc"
166 svc =
"Gaudi::RootEvtSelector"
167 return [str(
FileDescription(f,
"READ", svc, **fileargs))
for f
in filenames]
171 Translate a filename in an output description.
173 @param filenames: the list of files
174 @param lun: Logical Unit for Event Tag Collection outputs (optional)
178 retval = str(
FileDescription(filename,
"RECREATE",
"Gaudi::RootCnvSvc"))
180 retval =
"%s %s" % (kwargs[
"lun"], retval)