@@ -58,26 +58,27 @@ def find_services_folders(
5858 "./example/" + self .beamline .dom + "-services/services"
5959 ) # TODO: rm hardcoding, map to services.
6060 path = f"{ services_directory } "
61- files = os .listdir (path )
61+ services = os .listdir (path )
6262
6363 # Attempting to match the prefix to the files in the services directory
64- pattern = "^(.*)-(.*)-(.*)"
64+ # TODO: Improve regex
65+ # pattern = "^(.*)-(.*)-(.*)"
6566
6667 for component in self .components :
67- domain : re . Match [ str ] | None = re . match ( pattern , component . P )
68- assert domain is not None , "Empty Prefix Field"
69-
70- for file in files :
71- match = re . match ( pattern , file )
72- if match :
73- if match . group ( 1 ) == domain . group ( 1 ). lower () :
74- if os .path .exists (f"{ path } /{ file } /config/ioc.yaml" ):
75- self .extract_valid_entities (
76- ioc_yaml = f"{ path } /{ file } /config/ioc.yaml" ,
77- component = component ,
78- )
79- else :
80- print (f"No ioc.yaml file for service: { file } " )
68+ if component . service_name is not None :
69+ service_name = component . service_name
70+ else :
71+ # if service_name is not provided, resort to P being the service name
72+ service_name = component . P . lower ( )
73+
74+ for service in services :
75+ if os .path .exists (f"{ path } /{ service_name } /config/ioc.yaml" ):
76+ self .extract_valid_entities (
77+ ioc_yaml = f"{ path } /{ service_name } /config/ioc.yaml" ,
78+ component = component ,
79+ )
80+ else :
81+ print (f"No ioc.yaml file for service: { service } " )
8182
8283 def extract_valid_entities (self , ioc_yaml : str , component : Component ):
8384 """
@@ -86,17 +87,12 @@ def extract_valid_entities(self, ioc_yaml: str, component: Component):
8687
8788 entities : list [dict [str , str ]] = []
8889
89- if component .R is not None :
90- component_match = f"{ component .P } :{ component .R } "
91- else :
92- component_match = component .P
93-
9490 with open (ioc_yaml ) as ioc :
9591 conf = yaml .safe_load (ioc )
9692 entities = conf ["entities" ]
9793 for entity in entities :
9894 if (
99- "P" in entity .keys () and entity ["P" ] == component_match
95+ "P" in entity .keys () and entity ["P" ] == component . prefix
10096 ): # the suffix could be M, could be R
10197 self .valid_entities .append (
10298 Entry (
0 commit comments