ATLAS Offline Software
Functions | Variables
diff-jobo-cfg Namespace Reference

Functions

def dump_seq (seq)
 
def cxx_sort (dpp)
 
def load_cfg_file (fname)
 
def dict_diff (ref, chk)
 
def cmp_component_db (ref, chk, verbose=True)
 

Variables

 __author__
 
 parser
 
 usage
 
 _add
 
 dest
 
 help
 
 action
 
 default
 
 options
 
 args
 
 ref_fname
 
 chk_fname
 
 ref_db
 
 chk_db
 
 sc
 

Function Documentation

◆ cmp_component_db()

def diff-jobo-cfg.cmp_component_db (   ref,
  chk,
  verbose = True 
)
compare 2 dicts of components
dicts are of the form:
 { 'comp_type' : <name of component>,
   'cxx_type'  : <C++ type of the component>,
   'props' : { 'property-name' : 'property-value', }
   }

Definition at line 79 of file diff-jobo-cfg.py.

79 def cmp_component_db(ref, chk, verbose=True):
80  """ compare 2 dicts of components
81  dicts are of the form:
82  { 'comp_type' : <name of component>,
83  'cxx_type' : <C++ type of the component>,
84  'props' : { 'property-name' : 'property-value', }
85  }
86  """
87  common_keys = []
88  ref_keys = set(ref.keys())
89  chk_keys = set(chk.keys())
90 
91  common_keys = ref_keys & chk_keys
92  ref_only_keys = ref_keys - chk_keys
93  chk_only_keys = chk_keys - ref_keys
94 
95  print ("::: components in both files: [%5s]" % (len(common_keys),))
96  print ("::: components in ref only: [%5s]" % (len(ref_only_keys),))
97  if len(ref_only_keys)>0:
98  dump_seq(ref_only_keys)
99  print ("="*80)
100  print ("::: components in chk only: [%5s]" % (len(chk_only_keys),))
101  if len(chk_only_keys)>0:
102  dump_seq(chk_only_keys)
103  print ("="*80)
104 
105  diff = []
106  for comp_name in common_keys:
107  comp_ref = ref[comp_name]
108  comp_chk = chk[comp_name]
109 
110  ref_props = sorted([(k,v) for k,v in comp_ref['props'].iteritems()])
111  chk_props = sorted([(k,v) for k,v in comp_chk['props'].iteritems()])
112  if ref_props != chk_props:
113  diff.append((comp_name, ref_props, chk_props,
114  dict_diff(ref=comp_ref['props'],
115  chk=comp_chk['props'])))
116  pass
117 
118  print ("::: components with different properties: [%5s]" % (len(diff),))
119  for name, ref_props, chk_props, diff_props in diff:
120  print ("::: - component: [%s]" % (name,))
121  for prop_name, prop_value in diff_props.iteritems():
122  ref_value = prop_value[0]
123  chk_value = prop_value[1]
124  if isinstance(ref_value, list):
125  ref_value = sorted(ref_value)
126  if isinstance(chk_value, list):
127  chk_value = sorted(chk_value)
128 
129  if isinstance(ref_value, list) and isinstance(chk_value, list):
130  dref_value = set(ref_value) - set(chk_value)
131  dchk_value = set(chk_value) - set(ref_value)
132  ref_value = sorted(list(dref_value))
133  chk_value = sorted(list(dchk_value))
134  print ("-%s: %r" %(prop_name, ref_value,))
135  print ("+%s: %r" %(prop_name, chk_value,))
136 
137 
138  if (len(ref_only_keys) > 0 or
139  len(chk_only_keys) > 0 or
140  len(diff) > 0):
141  return 1
142  return 0
143 

◆ cxx_sort()

def diff-jobo-cfg.cxx_sort (   dpp)

Definition at line 31 of file diff-jobo-cfg.py.

31 def cxx_sort(dpp):
32  from collections import defaultdict
33  cxx_dpp = defaultdict(list)
34 
35  for k,v in dpp.iteritems():
36  #print (v['cxx_type'])
37  cxx_dpp[v['cxx_type']].append({k:v})
38 
39  for k,v in cxx_dpp.iteritems():
40  print ('---',k)
41  for vv in v:
42  print ('------',vv.keys())
43  print ('---------',vv.values())#['comp_type']
44  return cxx_dpp
45 

◆ dict_diff()

def diff-jobo-cfg.dict_diff (   ref,
  chk 
)
Return a dict of keys that differ with another config object.  If a value is
    not found in one fo the configs, it will be represented by KEYNOTFOUND.
    @param ref:   First dictionary to diff.
    @param chk:   Second dicationary to diff.
    @return diff:   Dict of Key => (ref.val, chk.val)

Definition at line 59 of file diff-jobo-cfg.py.

59 def dict_diff(ref, chk):
60  """ Return a dict of keys that differ with another config object. If a value is
61  not found in one fo the configs, it will be represented by KEYNOTFOUND.
62  @param ref: First dictionary to diff.
63  @param chk: Second dicationary to diff.
64  @return diff: Dict of Key => (ref.val, chk.val)
65  """
66  diff = {}
67  # Check all keys in ref dict
68  for k in ref.iterkeys():
69  if not (k in chk):
70  diff[k] = (ref[k], '<KEYNOTFOUND>')
71  elif (ref[k] != chk[k]):
72  diff[k] = (ref[k], chk[k])
73  # Check all keys in chk dict to find missing
74  for k in chk.iterkeys():
75  if not (k in ref):
76  diff[k] = ('<KEYNOTFOUND>', chk[k])
77  return diff
78 

◆ dump_seq()

def diff-jobo-cfg.dump_seq (   seq)

Definition at line 26 of file diff-jobo-cfg.py.

26 def dump_seq(seq):
27  for i in seq:
28  print (i)
29  pass
30 

◆ load_cfg_file()

def diff-jobo-cfg.load_cfg_file (   fname)
return the dictionary of components and their properties

Definition at line 46 of file diff-jobo-cfg.py.

46 def load_cfg_file(fname):
47  """return the dictionary of components and their properties
48  """
49  comps_db = {}
50  try:
51  import shelve
52  comps_db = shelve.open(fname, 'r')
53  return comps_db['all-cfgs']
54  except Exception:
55  from past.builtins import execfile
56  execfile(fname, comps_db)
57  return comps_db['d']
58 

Variable Documentation

◆ __author__

diff-jobo-cfg.__author__
private

Definition at line 19 of file diff-jobo-cfg.py.

◆ _add

diff-jobo-cfg._add
private

Definition at line 149 of file diff-jobo-cfg.py.

◆ action

diff-jobo-cfg.action

Definition at line 168 of file diff-jobo-cfg.py.

◆ args

diff-jobo-cfg.args

Definition at line 174 of file diff-jobo-cfg.py.

◆ chk_db

diff-jobo-cfg.chk_db

Definition at line 197 of file diff-jobo-cfg.py.

◆ chk_fname

diff-jobo-cfg.chk_fname

Definition at line 180 of file diff-jobo-cfg.py.

◆ default

diff-jobo-cfg.default

Definition at line 170 of file diff-jobo-cfg.py.

◆ dest

diff-jobo-cfg.dest

Definition at line 153 of file diff-jobo-cfg.py.

◆ help

diff-jobo-cfg.help

Definition at line 154 of file diff-jobo-cfg.py.

◆ options

diff-jobo-cfg.options

Definition at line 174 of file diff-jobo-cfg.py.

◆ parser

diff-jobo-cfg.parser

Definition at line 146 of file diff-jobo-cfg.py.

◆ ref_db

diff-jobo-cfg.ref_db

Definition at line 194 of file diff-jobo-cfg.py.

◆ ref_fname

diff-jobo-cfg.ref_fname

Definition at line 177 of file diff-jobo-cfg.py.

◆ sc

diff-jobo-cfg.sc

Definition at line 200 of file diff-jobo-cfg.py.

◆ usage

diff-jobo-cfg.usage

Definition at line 147 of file diff-jobo-cfg.py.

python.Bindings.iteritems
iteritems
Definition: Control/AthenaPython/python/Bindings.py:812
dumpHVPathFromNtuple.append
bool append
Definition: dumpHVPathFromNtuple.py:91
diff-jobo-cfg.dict_diff
def dict_diff(ref, chk)
Definition: diff-jobo-cfg.py:59
diff-jobo-cfg.dump_seq
def dump_seq(seq)
Definition: diff-jobo-cfg.py:26
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
DerivationFramework::TriggerMatchingUtils::sorted
std::vector< typename T::value_type > sorted(T begin, T end)
Helper function to create a sorted vector from an unsorted one.
CxxUtils::set
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.
Definition: bitmask.h:224
diff-jobo-cfg.cxx_sort
def cxx_sort(dpp)
Definition: diff-jobo-cfg.py:31
diff-jobo-cfg.load_cfg_file
def load_cfg_file(fname)
Definition: diff-jobo-cfg.py:46
diff-jobo-cfg.cmp_component_db
def cmp_component_db(ref, chk, verbose=True)
Definition: diff-jobo-cfg.py:79