ATLAS Offline Software
Loading...
Searching...
No Matches
python.ids Namespace Reference

Classes

class  DefectID
class  DefectIDBitfield
class  DefectsDBIDsNamesMixin

Functions

int choose_new_defect_id (Mapping[Union[str, int], Union[str, int]] existing_map, str defect_name, bool virtual=False)

Variables

 log

Function Documentation

◆ choose_new_defect_id()

int python.ids.choose_new_defect_id ( Mapping[Union[str, int], Union[str,int]] existing_map,
str defect_name,
bool virtual = False )
Function to create a new defect ID.

We're abandoning the mapping of defect names to IDs (Oct 2012).
Hence here we just ask for the first open gap in ID numbers.
It works for virtual IDs as well, though via a bit of an edge case for
when none exist yet.

Definition at line 47 of file ids.py.

48 defect_name: str, virtual: bool = False) -> int:
49 """
50 Function to create a new defect ID.
51
52 We're abandoning the mapping of defect names to IDs (Oct 2012).
53 Hence here we just ask for the first open gap in ID numbers.
54 It works for virtual IDs as well, though via a bit of an edge case for
55 when none exist yet.
56 """
57 existing = sorted(_ for _ in existing_map.values() if not isinstance(_, str))
58 if len(existing) == 0:
59 newid = 0
60 else:
61 newid = None
62 for i, v in enumerate(existing[1:]):
63 if v-existing[i] > 1:
64 newid = existing[i]+1
65 break
66 if newid is None:
67 newid = existing[-1] + 1
68 did = DefectID(newid)
69 did.is_virtual=virtual
70 log.debug("Chose new id: %r", did)
71 return int(did)
72

Variable Documentation

◆ log

python.ids.log

Definition at line 3 of file ids.py.