|
ATLAS Offline Software
|
|
def | __setattr__ (self, k, v) |
| raise AttributeError( "CfgItemList' object has no attribute '%s'" % ( attr ) ) More...
|
|
def | __delattr__ (self, attr) |
|
def | __bool__ (self) |
|
def | removeItem (self, item) |
|
def | removeAllItems (self, item) |
|
def | remove (self, items) |
|
def | removeAll (self) |
|
def | clear (self) |
|
def | setup (self) |
|
def | getProperties (self) |
|
def | _addItem (self, i) |
|
def | add (self, arg) |
|
def | has_item (self, item) |
|
def | allowWildCard (self, allow) |
|
def | __call__ (self, key=None) |
|
def | list (self, key=None) |
|
def | dict (self) |
|
def | __repr__ (self) |
|
def | __str__ (self, indent=0, headerLastIndentUnit=Configurable.indentUnit) |
|
def | name (self) |
|
def | children (self) |
|
def | allChildren (self) |
|
def | items (self) |
| for l in self.keys(): yield self[l] More...
|
|
def | clear (self, label=None) |
|
def | write (self, fileName, label) |
|
def | read (self, fileName, label) |
|
def | loadKeyStoreFromPoolFile (keyStore, pool_file, label='transient', items_type='eventdata') |
|
def | keystore_diff (ref, chk, labels=None, ofile=None) |
|
◆ __bool__()
def python.KeyStore.__bool__ |
( |
|
self | ) |
|
◆ __call__()
def python.KeyStore.__call__ |
( |
|
self, |
|
|
|
key = None |
|
) |
| |
Definition at line 302 of file KeyStore.py.
304 items =
set( [ i
for i
in self._items
if i.startswith(key+
"#") ] )
306 items =
set( self._items )
307 for c
in self._children:
309 for i
in c.list( key ):
311 except AttributeError
as err:
314 items = [ i
for i
in items ]
◆ __delattr__()
def python.KeyStore.__delattr__ |
( |
|
self, |
|
|
|
attr |
|
) |
| |
Definition at line 201 of file KeyStore.py.
202 for c
in self._children:
204 self._children.
remove( c )
◆ __repr__()
def python.KeyStore.__repr__ |
( |
|
self | ) |
|
Definition at line 329 of file KeyStore.py.
330 return '<%s/%s at %s>' % (self.__class__.__name__,self._name,
◆ __setattr__()
def python.KeyStore.__setattr__ |
( |
|
self, |
|
|
|
k, |
|
|
|
v |
|
) |
| |
raise AttributeError( "CfgItemList' object has no attribute '%s'" % ( attr ) )
Definition at line 190 of file KeyStore.py.
191 if k
in CfgItemList.__slots__:
193 for c
in self.children():
195 return setattr(c, k, v)
198 except AttributeError:
◆ __str__()
def python.KeyStore.__str__ |
( |
|
self, |
|
|
|
indent = 0 , |
|
|
|
headerLastIndentUnit = Configurable.indentUnit |
|
) |
| |
Definition at line 333 of file KeyStore.py.
334 headerLastIndentUnit=Configurable.indentUnit ):
336 indentStr = indent * Configurable.indentUnit
338 title =
"%s/%s" % ( self.__class__.__name__, self._name )
342 headerIndent = (indent-1)*Configurable.indentUnit \
343 + headerLastIndentUnit
347 rep = Configurable._printHeader( headerIndent, title )
351 props = self.getProperties()
354 rep += indentStr +
'| ' + os.linesep
358 for p
in props.keys():
359 nameWidth=
max(nameWidth,len(p))
360 for p, v
in props.items():
362 prefix = indentStr +
'|-%-*s' % (nameWidth,p)
364 if msg.isEnabledFor( logging.DEBUG ):
365 address =
' @%11s' % hex(
id(v))
370 line = prefix +
' = ' + strVal
372 rep += line + os.linesep
374 for cfg
in self.allChildren():
375 rep += cfg.__str__( indent + 1,
'|=' ) + os.linesep
378 rep += Configurable._printFooter( indentStr, title )
◆ _addItem()
def python.KeyStore._addItem |
( |
|
self, |
|
|
|
i |
|
) |
| |
|
private |
Definition at line 259 of file KeyStore.py.
260 if i.count(
"*" ) <= 0:
261 if i
not in self._items:
263 elif (self._allowWildCard
or _allowedTriggerKeys.match(i)):
264 if i
not in self._items:
267 msg.warning(
"Attempt to add an invalid element: '%s'", i )
268 msg.warning(
" ==> Ignoring invalid element: '%s'", i )
◆ add()
def python.KeyStore.add |
( |
|
self, |
|
|
|
arg |
|
) |
| |
Definition at line 271 of file KeyStore.py.
271 def add( self, arg ):
272 if isinstance(arg, (list, tuple) ):
275 elif isinstance(arg, str):
277 elif isinstance(arg, dict):
280 if not isinstance(new[k], (list,tuple)):
282 self.add( [
'%s#%s' % (k,e)
for e
in new[k] ] )
284 msg.error(
"Could not add '%r' of type '%s'", arg,
type(arg) )
◆ allChildren()
def python.KeyStore.allChildren |
( |
|
self | ) |
|
Definition at line 387 of file KeyStore.py.
389 for c
in self._children:
391 children += c.allChildren()
◆ allowWildCard()
def python.KeyStore.allowWildCard |
( |
|
self, |
|
|
|
allow |
|
) |
| |
Definition at line 299 of file KeyStore.py.
300 self._allowWildCard = allow
◆ children()
def python.KeyStore.children |
( |
|
self | ) |
|
◆ clear() [1/2]
def python.KeyStore.clear |
( |
|
self | ) |
|
◆ clear() [2/2]
def python.KeyStore.clear |
( |
|
self, |
|
|
|
label = None |
|
) |
| |
Definition at line 527 of file KeyStore.py.
527 def clear(self, label = None):
528 if label
is not None:
◆ dict()
def python.KeyStore.dict |
( |
|
self | ) |
|
Definition at line 321 of file KeyStore.py.
322 props = self.getProperties()
323 for c
in self._children:
324 props.update( c.dict() )
325 for k
in props.keys():
326 props[k] =
sorted(props[k])
◆ getProperties()
def python.KeyStore.getProperties |
( |
|
self | ) |
|
Definition at line 247 of file KeyStore.py.
249 for item
in self._items:
250 cppType = item.split(
"#")[0]
251 sgKey = item.replace( cppType+
"#",
'' )
253 if sgKey
not in props[cppType]:
254 props[cppType].
append( sgKey )
256 props[cppType] = [ sgKey ]
◆ has_item()
def python.KeyStore.has_item |
( |
|
self, |
|
|
|
item |
|
) |
| |
Definition at line 287 of file KeyStore.py.
288 from fnmatch
import fnmatchcase
as match
289 for i
in self._items:
294 for c
in self._children:
295 if c.has_item( item ):
◆ items()
def python.KeyStore.items |
( |
|
self | ) |
|
◆ keystore_diff()
def python.KeyStore.keystore_diff |
( |
|
ref, |
|
|
|
chk, |
|
|
|
labels = None , |
|
|
|
ofile = None |
|
) |
| |
Helper function to print the 'diff' of two KeyStores `ref` and `chk` into
the file-like object `ofile` (default value: sys.stdout)
`ref` and `chk` can either be :
- @c KeyStore.CfgKeyStore instances or,
- strings being the names of the _already created_
@c KeyStore.CfgKeyStore instances
@param `labels` the list of labels (default: CfgKeyStore.Labels) to compare
between the two CfgKeyStores
Definition at line 637 of file KeyStore.py.
639 Helper function to print the 'diff' of two KeyStores `ref` and `chk` into
640 the file-like object `ofile` (default value: sys.stdout)
641 `ref` and `chk` can either be :
642 - @c KeyStore.CfgKeyStore instances or,
643 - strings being the names of the _already created_
644 @c KeyStore.CfgKeyStore instances
645 @param `labels` the list of labels (default: CfgKeyStore.Labels) to compare
646 between the two CfgKeyStores
648 if isinstance (ref, str):
649 if ref
not in CfgKeyStore.instances:
651 (
'invalid `ref` argument (non existing instance name [%s])'%\
653 ref = CfgKeyStore.instances [ref]
655 if isinstance (chk, str):
656 if chk
not in CfgKeyStore.instances:
658 (
'invalid `chk` argument (non existing instance name [%s])'%\
660 chk = CfgKeyStore.instances [chk]
663 labels = CfgKeyStore.__slots__[
'Labels']
664 elif isinstance (labels, str):
665 labels = [l.strip()
for l
in labels.split()
if l.strip() !=
'']
672 if ref
is chk
or ref == chk:
676 ref_content = sorted (ref[label].
list())
677 chk_content = sorted (chk[label].
list())
678 if len(ref_content) != len(chk_content):
679 diff.append (
"- len(ref[%s]) == %i" % (label,len(ref_content)))
680 diff.append (
"+ len(chk[%s]) == %i" % (label,len(chk_content)))
681 for r
in ref_content:
682 if r
not in chk_content:
683 diff.append (
"- ref[%s] : %s" % (label, r))
684 for c
in chk_content:
685 if c
not in ref_content:
686 diff.append (
"+ chk[%s] : %s" % (label, c))
691 map (ofile.writelines, (d
for d
in os.linesep.join(diff)))
◆ list()
def python.KeyStore.list |
( |
|
self, |
|
|
|
key = None |
|
) |
| |
◆ loadKeyStoreFromPoolFile()
def python.KeyStore.loadKeyStoreFromPoolFile |
( |
|
keyStore, |
|
|
|
pool_file, |
|
|
|
label = 'transient' , |
|
|
|
items_type = 'eventdata' |
|
) |
| |
Helper function to create a CfgKeyStore of name `keyStore` from the
content of the POOL file `pool_file` (a python string).
The content of the POOL file will be stored into the label `label`
Definition at line 609 of file KeyStore.py.
611 items_type='eventdata'):
613 Helper function to create a CfgKeyStore of name `keyStore` from the
614 content of the POOL file `pool_file` (a python string).
615 The content of the POOL file will be stored into the label `label`
617 if not isinstance(keyStore, str):
618 raise ValueError(
"argument 0 (`keyStore`) should be string")
619 if not isinstance(pool_file, str):
620 raise ValueError(
"argument 1 (`pool_file`) should be string")
621 if not isinstance(label, str):
622 raise ValueError(
"argument 2 (`label`) should be string")
624 from PyUtils.PoolFile
import extract_items
625 item_list = [
'%s#%s'%(name,key)
628 items_type=items_type)
630 ks = CfgKeyStore(keyStore)
631 ks_label = getattr(ks, label)
633 ks_label.add (item_list)
◆ name()
def python.KeyStore.name |
( |
|
self | ) |
|
◆ read()
def python.KeyStore.read |
( |
|
self, |
|
|
|
fileName, |
|
|
|
label |
|
) |
| |
Definition at line 588 of file KeyStore.py.
588 def read( self, fileName, label ):
591 from AthenaCommon.Include
import FindFile,optionsPath
593 name = osp.expanduser( osp.expandvars( fileName ) )
594 name =
FindFile( name, optionsPath, os.R_OK )
596 name =
FindFile( osp.basename(fileName), optionsPath, os.R_OK )
597 uri =
open( name,
'r' )
598 mod = imp.load_source( uri.name[:-3], uri.name, uri )
601 fill = inspect.getmembers(
602 mod,
lambda o: inspect.isfunction(o)
and (o.__name__ ==
'_fill')
◆ remove()
def python.KeyStore.remove |
( |
|
self, |
|
|
|
items |
|
) |
| |
Definition at line 226 of file KeyStore.py.
226 def remove( self, items ):
230 self._children = [ e
for e
in self._children
if e
not in items ]
◆ removeAll()
def python.KeyStore.removeAll |
( |
|
self | ) |
|
Definition at line 232 of file KeyStore.py.
233 self.remove( self._children )
◆ removeAllItems()
def python.KeyStore.removeAllItems |
( |
|
self, |
|
|
|
item |
|
) |
| |
Definition at line 220 of file KeyStore.py.
221 self.removeItem( item )
222 for c
in self._children:
223 c.removeAllItems( item )
◆ removeItem()
def python.KeyStore.removeItem |
( |
|
self, |
|
|
|
item |
|
) |
| |
◆ setup()
def python.KeyStore.setup |
( |
|
self | ) |
|
Definition at line 239 of file KeyStore.py.
240 msg.debug(
'setup of Output ItemList: %s', self._name )
241 if msg.isEnabledFor( logging.VERBOSE ):
242 msg.verbose(
'layout of sequence: %s\n%s', self._name,
str(self) )
244 for child
in self.children():
◆ write()
def python.KeyStore.write |
( |
|
self, |
|
|
|
fileName, |
|
|
|
label |
|
) |
| |
Definition at line 562 of file KeyStore.py.
562 def write( self, fileName, label ):
565 from pprint
import pprint
566 from datetime
import datetime
567 from io
import StringIO
569 pprint( item.dict(), stream = buf )
571 out =
open( os.path.expanduser(os.path.expandvars(fileName)),
'w' )
572 out.writelines( os.linesep.join( [
573 "## autogenerated at [%s]" %
str(datetime.now()),
575 "## method filling an item-list with some data",
576 "def _fill( item ):",
577 " item.add(",
"%s )" % buf.getvalue(),
583 except Exception
as e:
584 print (
"Py:Error :",e)
◆ __all__
list python.KeyStore.__all__ |
|
private |
Initial value: 1 = [
"CfgItemList",
"CfgKeyStore",
2 "loadKeyStoreFromPoolFile",
Definition at line 10 of file KeyStore.py.
◆ __author__
string python.KeyStore.__author__ = 'Sebastien Binet <binet@cern.ch>' |
|
private |
◆ __version__
string python.KeyStore.__version__ = '$Revision: 1.11 $' |
|
private |
◆ _allowedTriggerKeys
python.KeyStore._allowedTriggerKeys = re.compile( r"(?P<KlassName>.*?)#HLTAutoKey.*\*$" ) |
|
private |
◆ _allowWildCard
python.KeyStore._allowWildCard |
|
private |
◆ _children
python.KeyStore._children |
|
private |
◆ _items
◆ msg
python.KeyStore.msg = logging.getLogger( 'CfgItemList' ) |
IovVectorMap_t read(const Folder &theFolder, const SelectionCriterion &choice, const unsigned int limit=10)
def __call__(self, key=None)
def __str__(self, indent=0, headerLastIndentUnit=Configurable.indentUnit)
def __setattr__(self, k, v)
raise AttributeError( "CfgItemList' object has no attribute '%s'" % ( attr ) )
def clear(self, label=None)
def items(self)
for l in self.keys(): yield self[l]
def removeAllItems(self, item)
def __delattr__(self, attr)
def write(self, fileName, label)
std::string repr(PyObject *o)
returns the string representation of a python object equivalent of calling repr(o) in python
bool add(const std::string &hname, TKey *tobj)
def removeItem(self, item)
def keystore_diff(ref, chk, labels=None, ofile=None)
std::vector< typename T::value_type > sorted(T begin, T end)
Helper function to create a sorted vector from an unsorted one.
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
std::string join(const std::vector< std::string > &v, const char c=',')
def loadKeyStoreFromPoolFile(keyStore, pool_file, label='transient', items_type='eventdata')
def extract_items(pool_file, verbose=True, items_type='eventdata')
def allowWildCard(self, allow)
bool match(std::string s1, std::string s2)
match the individual directories of two strings