All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UpdateCoreServices.py
Go to the documentation of this file.
1 #!/usr/bin/env python2
2 
3 import sys, re
4 
5 import SerialSubstitution
6 from SerialSubstitution import AddProcessor, RunSubstitutor
7 
8 
9 ################################################################################
10 if __name__ == "__main__":
11 
12  #############################################################################
13  # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
14  # FHiCL configuration
15  #
17 
18  Subst.AddFileType("fcl")
19 
20  Subst.AddSimplePattern("LArProperties:", "LArPropertiesService:")
21  Subst.AddSimplePattern(".LArProperties.", ".LArPropertiesService.")
22  Subst.AddSimplePattern("DetectorProperties:", "DetectorPropertiesService:")
23  Subst.AddSimplePattern(".DetectorProperties.", ".DetectorPropertiesService.")
24  Subst.AddSimplePattern("TimeService:", "DetectorClocksService:")
25  Subst.AddSimplePattern(".TimeService.", ".DetectorClocksService.")
26  Subst.AddSimplePattern("timeservice", "detectorclocks")
27  Subst.AddSimplePattern(".LArPropertiesService.Efield:", ".DetectorPropertiesService.Efield:")
28  Subst.AddSimplePattern(".LArPropertiesService.Electronlifetime:", ".DetectorPropertiesService.Electronlifetime:")
29  Subst.AddSimplePattern(".LArPropertiesService.Temperature:", ".DetectorPropertiesService.Temperature:")
30 
31  Subst.AddSimplePattern("IChannelStatusService:", "ChannelStatusService:")
32  Subst.AddSimplePattern(".IChannelStatusService.", ".ChannelStatusService.")
33 
34  Subst.AddSimplePattern("IDetPedestalService:", "DetPedestalService:")
35  Subst.AddSimplePattern(".IDetPedestalService.", ".DetPedestalService.")
36 
37  # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
38  # CMakeLists.txt
39  #
41 
42  Subst.AddFileNamePattern("CMakeLists.txt")
43 
44  Subst.AddRegExRemoveLine(r"^\s*(LArProperties|DetectorProperties|DetectorClocks|TimeService)_service\s*(#.*)?$")
45 
46 
47  # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
48  # art module source code
49  #
50  # We need to choose whether to turn an include directive of Utilities/OldCoreService.h
51  # into including the art service interface header or the service provider interface header.
52  # In this special context, we deal with a module that definitely need to access
53  # the service, even when it also needs the provider.
54  # Since the provider is included by the service anyway, our choice is set.
55  #
57 
58  Subst.AddFileNamePattern(".*_module\.cc")
59 
60  # Utilities/ => DetectorInfoServices/
61  Subst.AddWord ("Utilities/LArProperties.h", "DetectorInfoServices/LArPropertiesService.h")
62  Subst.AddWord ("Utilities/DetectorProperties.h", "DetectorInfoServices/DetectorPropertiesService.h")
63  Subst.AddWord ("Utilities/DetectorClocks.h", "DetectorInfoServices/DetectorClocksService.h")
64  Subst.AddWord ("Utilities/RunHistory.h", "DetectorInfoServices/RunHistoryService.h")
65  Subst.AddWord ("Utilities/TimeService.h", "DetectorInfoServices/DetectorClocksService.h")
66 
67  # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
68  # C++ source code
69  #
71 
72  Subst.AddFileType("h", "cc", "cpp", "cxx")
73 
74  # DataProviders/ => DetectorInfo/
75  Subst.AddWord ("DataProviders/", "DetectorInfo/")
76 
77  # Utilities/ => DetectorInfo/
78  Subst.AddWord ("Utilities/LArProperties.h", "DetectorInfo/LArProperties.h")
79  Subst.AddWord ("Utilities/DetectorProperties.h", "DetectorInfo/DetectorProperties.h")
80  Subst.AddWord ("Utilities/DetectorClocks.h", "DetectorInfo/DetectorClocks.h")
81  Subst.AddWord ("Utilities/RunHistory.h", "DetectorInfo/RunHistory.h")
82  Subst.AddWord ("Utilities/ElecClock.h", "DetectorInfo/ElecClock.h")
83  Subst.AddWord ("Utilities/DetectorClocksExceptions.h", "DetectorInfo/DetectorClocksExceptions.h")
84  Subst.AddWord ("Utilities/ClockConstants.h", "DetectorInfo/ClockConstants.h")
85 
86  # Utilities/ => DetectorInfoServices/
87  Subst.AddWord ("Utilities/LArPropertiesService.h", "DetectorInfoServices/LArPropertiesService.h")
88  Subst.AddWord ("Utilities/DetectorPropertiesService.h", "DetectorInfoServices/DetectorPropertiesService.h")
89  Subst.AddWord ("Utilities/DetectorClocksService.h", "DetectorInfoServices/DetectorClocksService.h")
90  Subst.AddWord ("Utilities/TimeService.h", "DetectorInfoServices/DetectorClocksService.h")
91  Subst.AddWord ("Utilities/RunHistoryService.h", "DetectorInfoServices/RunHistoryService.h")
92  Subst.AddWord ("Utilities/LArPropertiesServiceStandard.h", "DetectorInfoServices/LArPropertiesServiceStandard.h")
93  Subst.AddWord ("Utilities/DetectorPropertiesServiceStandard.h", "DetectorInfoServices/DetectorPropertiesServiceStandard.h")
94  Subst.AddWord ("Utilities/DetectorClocksServiceStandard.h", "DetectorInfoServices/DetectorClocksServiceStandard.h")
95  Subst.AddWord ("Utilities/RunHistoryServiceStandard.h", "DetectorInfoServices/RunHistoryServiceStandard.h")
96 
97  # Xxx => XxxService
98  Subst.AddWord ("util::LArProperties", "detinfo::LArPropertiesService")
99  Subst.AddWord ("util::DetectorProperties", "detinfo::DetectorPropertiesService")
100  Subst.AddWord ("util::DetectorClocks", "detinfo::DetectorClocksService")
101  Subst.AddWord ("util::TimeService", "detinfo::DetectorClocksService")
102 
103  # dataprov:: => detinfo::
104  Subst.AddWord ("dataprov", "detinfo")
105 
106  # util:: => detinfo:: (for relocated libraries)
107  Subst.AddWord ("util::ElecClock", "detinfo::ElecClock")
108  Subst.AddWord ("util::DetectorClocksException", "detinfo::DetectorClocksException")
109  Subst.AddWord ("util::kTIME_MAX", "detinfo::kTIME_MAX")
110  Subst.AddRegExPattern(r"util::kDEFAULT_(FREQUENCY|FRAME_PERIOD|FREQUENCY_OPTICAL|FREQUENCY_TPC|FREQUENCY_TRIGGER|FREQUENCY_EXTERNAL|MC_CLOCK_T0|TRIG_OFFSET_TPC)",
111  r"detinfo::\1")
112 
113  # util:: => detinfo:: (for code in the middle of the changes)
114  Subst.AddWord ("util::LArPropertiesService", "detinfo::LArPropertiesService")
115  Subst.AddWord ("util::DetectorPropertiesService", "detinfo::DetectorPropertiesService")
116  Subst.AddWord ("util::DetectorClocksService", "detinfo::DetectorClocksService")
117  Subst.AddWord ("util::RunHistoryService", "detinfo::RunHistoryService")
118  Subst.AddWord ("util::LArPropertiesServiceStandard", "detinfo::LArPropertiesServiceStandard")
119  Subst.AddWord ("util::DetectorPropertiesServiceStandard", "detinfo::DetectorPropertiesServiceStandard")
120  Subst.AddWord ("util::DetectorClocksServiceStandard", "detinfo::DetectorClocksServiceStandard")
121  Subst.AddWord ("util::RunHistoryServiceStandard", "detinfo::RunHistoryServiceStandard")
122  Subst.AddWord ("util::DetectorClocks", "detinfo::DetectorClocksService") # should not happen
123 
124  # art::ServiceHandle becomes lar::providerFrom
125  Subst.AddRegExPattern(r"art::ServiceHandle\s*<\s*detinfo::(LArProperties|DetectorProperties|DetectorClocks)Service\s*>\s*(\w*)\s*;",
126  r"auto const* \2 = lar::providerFrom<detinfo::\1Service>();");
127 
128 
129  # IChannelStatusService => ChannelStatusService
130  Subst.AddWord ("IChannelStatusService", "ChannelStatusService")
131 
132  # IChannelStatusProvider => ChannelStatus
133  Subst.AddWord ("IChannelStatusProvider", "ChannelStatusProvider")
134 
135  # IDetPedestalService => DetPedestalService
136  Subst.AddWord ("IDetPedestalService", "DetPedestalService")
137 
138  # IDetPedestalProvider => DetPedestal
139  Subst.AddWord ("IDetPedestalProvider", "DetPedestalProvider")
140 
141  # functions moved
143  # adds heuristics to suppress warning if the code has already been changed
144  def __init__(self):
145  self.pattern = r"(\w*)(\.|->)(Efield|ElectronLifetime|DriftVelocity|BirksCorrection|ModBoxCorrection|Temperature|Density|Eloss|ElossVar)\s*\("
146  self.regex = re.compile(self.pattern)
147  def search(self, s):
148  match = self.regex.search(s)
149  if not match: return None
150  varname = match.group(1).lower()
151  if 'detp' in varname:
152  return None
153  return match
154  # search()
155  # class WarningMoveMembers
156 
157  Subst.AddWarningPattern(WarningMoveMembers(),
158  r"Note: LArProperties::\3() has moved to DetectorProperties/DetectorPropertiesService")
159 
160 
161  # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
162  #############################################################################
163 
164  sys.exit(RunSubstitutor())
165 #