12 Module to configure the persistency type in GaudiPython.
15 __author__ =
"Marco Clemencic <marco.clemencic@cern.ch>"
20 Base class for exceptions in PersistencyHelper.
28 Exception raised if the persistency type is not known to the module.
32 super(UnknownPersistency, self).
__init__(
"Unknown persistency type %r" % type_)
42 Return the PersistencyHerper implementing the given persistency type.
44 for i
in _implementations:
52 Function to extend the list of known helpers.
54 New helpers are added to the top of the list.
56 _implementations.insert(0, instance)
60 def __init__(self, filename, opt, svc, sel=None, collection=None, fun=None):
62 Class to hold/manipulate the file description.
64 @param filename: name of the file
65 @param opt: option (READ/CREATE/RECREATE/WRITE)
66 @param svc: conversion service (or selector)
67 @param sel: selection expression
68 @param collection: collection
69 @param fun: selection class
80 Return a list of pairs describing the instance.
93 Return the string representation of the file description to be passed
96 return " ".join([
"%s='%s'" % (k, v)
for k, v
in self.
__data__()
if v])
101 Base class for extensions to persistency configuration in GaudiPython.
106 Define the type of persistencies supported by the instance.
112 Returns True if the current instance understands the requested
115 return typ
in self.
types
120 Implementation of PersistencyHelper based on Gaudi::RootCnvSvc.
127 Declare the type of supported persistencies to the base class.
129 super(RootPersistency, self).
__init__(
130 [
"ROOT",
"POOL_ROOT",
"RootCnvSvc",
"Gaudi::RootCnvSvc"]
140 appMgr.service(
"Gaudi::RootCnvSvc/RootCnvSvc")
141 eps = appMgr.service(
"EventPersistencySvc")
142 eps.CnvServices += [
"RootCnvSvc"]
147 Translate a list of file names in a list of input descriptions.
149 The optional parameters 'collection', 'sel' and 'fun' should be used to
150 configure Event Tag Collection inputs.
152 @param filenames: the list of files
156 if isinstance(filenames, str):
157 filenames = [filenames]
161 [(k, kwargs[k])
for k
in [
"collection",
"sel",
"fun"]
if k
in kwargs]
165 svc =
"Gaudi::RootCnvSvc"
167 svc =
"Gaudi::RootEvtSelector"
168 return [str(
FileDescription(f,
"READ", svc, **fileargs))
for f
in filenames]
172 Translate a filename in an output description.
174 @param filenames: the list of files
175 @param lun: Logical Unit for Event Tag Collection outputs (optional)
179 retval = str(
FileDescription(filename,
"RECREATE",
"Gaudi::RootCnvSvc"))
181 retval =
"%s %s" % (kwargs[
"lun"], retval)