aepp 0.5.1__py3-none-any.whl → 0.5.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
aepp/datatypemanager.py CHANGED
@@ -36,7 +36,7 @@ class DataTypeManager:
36
36
  schemaAPI:'Schema'=None,
37
37
  config: Union[dict,ConnectObject] = aepp.config.config_object,
38
38
  description:str="",
39
- localFolder:str=None,
39
+ localFolder:str|list|None=None,
40
40
  sandbox:str=None,
41
41
  **kwargs
42
42
  )->None:
@@ -65,10 +65,13 @@ class DataTypeManager:
65
65
  elif config is not None and localFolder is None:
66
66
  self.schemaAPI = Schema(config=config)
67
67
  elif localFolder is not None:
68
- self.localfolder = Path(localFolder)
69
- self.datatypeFolder = self.localfolder / 'datatype'
70
- self.datatypeGlobalFolder = self.datatypeFolder / 'global'
71
- if self.localfolder.exists() is False:
68
+ if isinstance(localFolder, str):
69
+ self.localfolder = [Path(localFolder)]
70
+ elif isinstance(localFolder, list):
71
+ self.localfolder = [Path(folder) for folder in localFolder]
72
+ self.datatypeFolder = [folder / 'datatype' for folder in self.localfolder]
73
+ self.datatypeGlobalFolder = [folder / 'global' for folder in self.datatypeFolder]
74
+ if any([folder.exists() is False for folder in self.localfolder]):
72
75
  raise Exception(f"The local folder {self.localfolder} does not exist. Please create it and extract your sandbox before using it.")
73
76
  self.schemaAPI = None
74
77
  if self.schemaAPI is not None:
@@ -99,20 +102,32 @@ class DataTypeManager:
99
102
  self.dataType = self.schemaAPI.getDataType(dataType['$id'],full=False)
100
103
  self.EDITABLE = True
101
104
  elif self.localfolder is not None:
102
- for dataTypeFile in self.datatypeFolder.glob(f"*.json"):
103
- tmp_def = json.load(FileIO(dataTypeFile))
104
- if tmp_def.get('$id') == dataType.get('$id') or tmp_def.get('meta:altId') == dataType.get('meta:altId'):
105
- self.dataType = tmp_def
105
+ found = False
106
+ for folder in self.datatypeFolder:
107
+ for dataTypeFile in folder.glob(f"*.json"):
108
+ tmp_def = json.load(FileIO(dataTypeFile))
109
+ if tmp_def.get('$id') == dataType.get('$id') or tmp_def.get('meta:altId') == dataType.get('meta:altId'):
110
+ self.dataType = tmp_def
111
+ found = True
112
+ break
113
+ if found:
114
+ break
106
115
  self.EDITABLE = False
107
116
  else:
108
117
  if self.schemaAPI is not None:
109
118
  self.dataType = self.schemaAPI.getDataType(dataType['$id'],full=True)
110
119
  self.EDITABLE = True
111
120
  elif self.localfolder is not None:
112
- for dataTypeFile in self.datatypeGlobalFolder.glob("*.json"):
113
- tmp_def = json.load(FileIO(dataTypeFile))
114
- if tmp_def.get('$id') == dataType.get('$id') or tmp_def.get('meta:altId') == dataType.get('meta:altId') or tmp_def.get('title') == dataType.get('title'):
115
- self.dataType = tmp_def
121
+ found = False
122
+ for folder in self.datatypeGlobalFolder:
123
+ for dataTypeFile in folder.glob("*.json"):
124
+ tmp_def = json.load(FileIO(dataTypeFile))
125
+ if tmp_def.get('$id') == dataType.get('$id') or tmp_def.get('meta:altId') == dataType.get('meta:altId') or tmp_def.get('title') == dataType.get('title'):
126
+ self.dataType = tmp_def
127
+ found = True
128
+ break
129
+ if found:
130
+ break
116
131
  self.EDITABLE = False
117
132
  elif type(dataType) == str:
118
133
  if self.tenantId[1:] in dataType:
@@ -122,10 +137,16 @@ class DataTypeManager:
122
137
  raise ValueError(f"Cannot find the data type with id {dataType} in the schema API.")
123
138
  self.EDITABLE = True
124
139
  elif self.localfolder is not None:
125
- for dataTypeFile in self.datatypeFolder.glob("*.json"):
126
- tmp_def = json.load(FileIO(dataTypeFile))
127
- if tmp_def.get('$id') == dataType or tmp_def.get('meta:altId') == dataType or tmp_def.get('title') == dataType:
128
- self.dataType = tmp_def
140
+ found = False
141
+ for folder in self.datatypeFolder:
142
+ for dataTypeFile in folder.glob("*.json"):
143
+ tmp_def = json.load(FileIO(dataTypeFile))
144
+ if tmp_def.get('$id') == dataType or tmp_def.get('meta:altId') == dataType or tmp_def.get('title') == dataType:
145
+ self.dataType = tmp_def
146
+ found = True
147
+ break
148
+ if found:
149
+ break
129
150
  self.EDITABLE = False
130
151
  else:
131
152
  raise Exception("You try to retrieve the datatype definition from the id, but no API or localFolder has been passed as a parameter.")
@@ -136,10 +157,16 @@ class DataTypeManager:
136
157
  raise ValueError(f"Cannot find the data type with id {dataType} in the schema API.")
137
158
  self.EDITABLE = True
138
159
  elif self.localfolder is not None:
139
- for dataTypeFile in self.datatypeGlobalFolder.glob("*.json"):
140
- tmp_def = json.load(FileIO(dataTypeFile))
141
- if tmp_def.get('$id') == dataType or tmp_def.get('meta:altId') == dataType or tmp_def.get('title') == dataType:
142
- self.dataType = tmp_def
160
+ found = False
161
+ for folder in self.datatypeGlobalFolder:
162
+ for dataTypeFile in folder.glob("*.json"):
163
+ tmp_def = json.load(FileIO(dataTypeFile))
164
+ if tmp_def.get('$id') == dataType or tmp_def.get('meta:altId') == dataType or tmp_def.get('title') == dataType:
165
+ self.dataType = tmp_def
166
+ found = True
167
+ break
168
+ if found:
169
+ break
143
170
  self.EDITABLE = False
144
171
  else:
145
172
  raise Exception("You try to retrieve the datatype definition from the id, but no API or localFolder has been passed as a parameter.")
@@ -181,12 +208,18 @@ class DataTypeManager:
181
208
  self.dataTypeManagers[dt_manager.title] = dt_manager
182
209
  elif self.localfolder is not None:
183
210
  for dt in dataTypes: ## today only searching custom data types in local folder
184
- for dataTypeFile in self.datatypeFolder.glob("*.json"):
185
- tmp_def = json.load(FileIO(dataTypeFile))
186
- if tmp_def.get('$id') == dt or tmp_def.get('meta:altId') == dt or tmp_def.get('title') == dt:
187
- dt_manager = DataTypeManager(dataType=tmp_def,localFolder=self.localfolder,tenantId=self.tenantId,sandbox=self.sandbox)
188
- self.dataTypes[dt_manager.id] = dt_manager.title
189
- self.dataTypeManagers[dt_manager.title] = dt_manager
211
+ found = False
212
+ for folder in self.datatypeFolder:
213
+ for dataTypeFile in folder.glob("*.json"):
214
+ tmp_def = json.load(FileIO(dataTypeFile))
215
+ if tmp_def.get('$id') == dt or tmp_def.get('meta:altId') == dt or tmp_def.get('title') == dt:
216
+ dt_manager = DataTypeManager(dataType=tmp_def,localFolder=self.localfolder,tenantId=self.tenantId,sandbox=self.sandbox)
217
+ self.dataTypes[dt_manager.id] = dt_manager.title
218
+ self.dataTypeManagers[dt_manager.title] = dt_manager
219
+ found = True
220
+ break
221
+ if found:
222
+ break
190
223
  if title is not None:
191
224
  self.dataType['title'] = title
192
225
  self.title = title
aepp/deletion.py CHANGED
@@ -20,11 +20,11 @@ from aepp import connector
20
20
 
21
21
  class Deletion:
22
22
  """
23
- This class regroups differet methods and combine some to clean and delete artefact from Adobe Experience Platform.
23
+ This class regroups differet methods and combine some to clean and delete artifact from Adobe Experience Platform.
24
24
  Supported in this class:
25
- - Deleting datasets (and associated artefacts)
26
- - Deleteting dataflows (and associated artefacts)
27
- - Deleting schemas (and associated artefacts)
25
+ - Deleting datasets (and associated artifacts)
26
+ - Deleteting dataflows (and associated artifacts)
27
+ - Deleting schemas (and associated artifacts)
28
28
  - Deleting audiences
29
29
  """
30
30
  loggingEnabled = False
@@ -83,14 +83,14 @@ class Deletion:
83
83
  def __repr__self(self):
84
84
  return f"Deletion(config={self.config})"
85
85
 
86
- def deleteDataset(self,datasetId: str,associatedArtefacts:bool=False) -> dict:
86
+ def deleteDataset(self,datasetId: str,associatedArtifacts:bool=False) -> dict:
87
87
  """
88
- Delete a dataset and all associated artefacts (dataflows, schemas, data connections).
88
+ Delete a dataset and all associated artifacts (dataflows, schemas, data connections).
89
89
  Arguments:
90
90
  datasetId : REQUIRED : The identifier of the dataset to delete.
91
- associatedArtefacts : OPTIONAL : If set to True, all associated artefacts (dataflows, schemas) will also be deleted (default False).
92
- Note : Deleting associated arterfacts option will be pass down to other methods called within this method. So Field Groups, Data Type could be impacted.
93
- In case, it is not possible to delete artefacts, it will be silently ignored and returns in the output dictionary.
91
+ associatedArtifacts : OPTIONAL : If set to True, all associated artifacts (dataflows, schemas) will also be deleted (default False).
92
+ Note : Deleting associated artifacts option will be pass down to other methods called within this method. So Field Groups, Data Type could be impacted.
93
+ In case, it is not possible to delete artifacts, it will be silently ignored and returns in the output dictionary.
94
94
  """
95
95
  result = {}
96
96
  from aepp import catalog
@@ -100,7 +100,7 @@ class Deletion:
100
100
  schemaRef = datasetInfo.get('schemaRef',{}).get('id',None)
101
101
  res = cat.deleteDataSet(datasetId=datasetId)
102
102
  result['dataset'] = res
103
- if associatedArtefacts:
103
+ if associatedArtifacts:
104
104
  # Deleting associated dataflows
105
105
  result['flows'] = {'connections':{}, 'flows': {}}
106
106
  from aepp import flowservice
@@ -113,21 +113,21 @@ class Deletion:
113
113
  flows = flow.getFlows()
114
114
  list_flowIds = [f['id'] for f in flows if f.get('sourceConnectionIds',[""])[0] in list_source_dataflowsIds or f.get('targetConnectionIds',[""])[0] in list_target_dataflowsIds]
115
115
  for flowId in list_flowIds:
116
- res_flow = self.deleteDataFlow(flowId=flowId, associatedArtefacts=associatedArtefacts)
116
+ res_flow = self.deleteDataFlow(flowId=flowId, associatedArtifacts=associatedArtifacts)
117
117
  result['flows']['flows'][flowId] = res_flow
118
118
  # Deleting associated schema
119
119
  if schemaRef is not None:
120
- result['schema'] = self.deleteSchema(schemaId=schemaRef, associatedArtefacts=associatedArtefacts)
120
+ result['schema'] = self.deleteSchema(schemaId=schemaRef, associatedArtifacts=associatedArtifacts)
121
121
  return result
122
122
 
123
- def deleteSchema(self,schemaId: str,associatedArtefacts:bool=False) -> dict:
123
+ def deleteSchema(self,schemaId: str,associatedArtifacts:bool=False) -> dict:
124
124
  """
125
- Delete a schema and possibly all associated artefacts.
125
+ Delete a schema and possibly all associated artifacts.
126
126
  Arguments:
127
127
  schemaId : REQUIRED : The identifier of the schema to delete.
128
- associatedArtefacts : OPTIONAL : If set to True, all associated artefacts (fieldGroup, datatype) will also be deleted (default False).
129
- Note : Deleting associated arterfacts option will be pass down to other methods called within this method. So Field Groups, Data Type could be impacted.
130
- In case, it is not possible to delete artefacts, it will be silently ignored and returns in the output dictionary.
128
+ associatedArtifacts : OPTIONAL : If set to True, all associated artifacts (fieldGroup, datatype) will also be deleted (default False).
129
+ Note : Deleting associated artifacts option will be pass down to other methods called within this method. So Field Groups, Data Type could be impacted.
130
+ In case, it is not possible to delete artifacts, it will be silently ignored and returns in the output dictionary.
131
131
  """
132
132
  result = {'fieldGroup': {}, 'schema': {} , 'datatypes':{} }
133
133
  from aepp import schema, schemamanager
@@ -135,7 +135,7 @@ class Deletion:
135
135
  schemaInfo = schemamanager.SchemaManager(schemaId,config=self.config)
136
136
  res = sch.deleteSchema(schemaId=schemaId)
137
137
  result['schema'] = res
138
- if associatedArtefacts:
138
+ if associatedArtifacts:
139
139
  for fieldgroupId, fieldgroupName in schemaInfo.fieldGroups.items():
140
140
  myFG = schemaInfo.getFieldGroupManager(fieldgroupName)
141
141
  datatypes = myFG.dataTypes
@@ -146,12 +146,12 @@ class Deletion:
146
146
  result['fieldGroupName'][fieldgroupId] = res_fg
147
147
  return result
148
148
 
149
- def deleteDataFlow(self,flowId: str,associatedArtefacts:bool=False) -> dict:
149
+ def deleteDataFlow(self,flowId: str,associatedArtifacts:bool=False) -> dict:
150
150
  """
151
- Delete a dataflow and possibly all associated artefacts.
151
+ Delete a dataflow and possibly all associated artifacts.
152
152
  Arguments:
153
153
  flowId : REQUIRED : The identifier of the dataflow to delete.
154
- associatedArtefacts : OPTIONAL : If set to True, all associated artefacts (source and target) will also be deleted (default False).
154
+ associatedArtifacts : OPTIONAL : If set to True, all associated artifacts (source and target) will also be deleted (default False).
155
155
  Note : The base connection will be identified and returned but not deleted. It can contains other dataflows still actives."""
156
156
  result = {'flow': {}, 'targetConnection': {},'sourceConnection':{}, 'baseConnection': {} }
157
157
  from aepp import flowservice
@@ -163,7 +163,7 @@ class Deletion:
163
163
  result['baseConnection'] = baseConn
164
164
  res = flow.deleteFlow(flowId=flowId)
165
165
  result['response_flow'] = res
166
- if associatedArtefacts:
166
+ if associatedArtifacts:
167
167
  for sourceConnectionId in sourceConnectionIds:
168
168
  res_sc = flow.deleteSourceConnection(connectionId=sourceConnectionId)
169
169
  result["response_sourceConn"] = res_sc
aepp/fieldgroupmanager.py CHANGED
@@ -39,7 +39,7 @@ class FieldGroupManager:
39
39
  config: Union[dict,ConnectObject] = aepp.config.config_object,
40
40
  description:str="powered by aepp",
41
41
  full:bool=None,
42
- localFolder:str=None,
42
+ localFolder:str | list | None=None,
43
43
  sandbox:str=None,
44
44
  **kwargs
45
45
  )->None:
@@ -71,13 +71,16 @@ class FieldGroupManager:
71
71
  elif config is not None and localFolder is None:
72
72
  self.schemaAPI = Schema(config=config)
73
73
  elif localFolder is not None:
74
- self.localfolder = Path(localFolder)
75
- self.datatypeFolder = self.localfolder / 'datatype'
76
- self.datatypeGlobalFolder = self.datatypeFolder / 'global'
77
- self.fieldgroupFolder = self.localfolder / 'fieldgroup'
78
- self.fieldgroupGlobalFolder = self.fieldgroupFolder / 'global'
79
- self.descriptorFolder = self.localfolder / 'descriptor'
80
- if self.localfolder.exists() is False:
74
+ if isinstance(localFolder, str):
75
+ self.localfolder = [Path(localFolder)]
76
+ elif isinstance(localFolder, list):
77
+ self.localfolder = [Path(folder) for folder in localFolder]
78
+ self.datatypeFolder = [folder / 'datatype' for folder in self.localfolder]
79
+ self.datatypeGlobalFolder = [folder / 'global' for folder in self.datatypeFolder]
80
+ self.fieldgroupFolder = [folder / 'fieldgroup' for folder in self.localfolder]
81
+ self.fieldgroupGlobalFolder = [folder / 'global' for folder in self.fieldgroupFolder]
82
+ self.descriptorFolder = [folder / 'descriptor' for folder in self.localfolder]
83
+ if any([folder.exists() is False for folder in self.localfolder]):
81
84
  raise Exception(f"The local folder {self.localfolder} does not exist. Please create it and extract your sandbox before using it.")
82
85
  self.schemaAPI = None
83
86
  if self.schemaAPI is not None:
@@ -95,9 +98,11 @@ class FieldGroupManager:
95
98
  if fieldGroup.get('meta:tenantNamespace') is not None:
96
99
  self.tenantId = fieldGroup.get('meta:tenantNamespace')
97
100
  elif self.localfolder is not None:
98
- config_json = json.load(FileIO(self.localfolder / 'config.json'))
99
- if config_json.get('tenantId',None) is not None:
100
- self.tenantId = config_json.get('tenantId')
101
+ for folder in self.localfolder:
102
+ config_json = json.load(FileIO(folder / 'config.json'))
103
+ if config_json.get('tenantId',None) is not None:
104
+ self.tenantId = config_json.get('tenantId')
105
+ break
101
106
  else:### Should not be a problem as the element without a tenantId are not supposed to change
102
107
  self.tenantId = " "
103
108
  if fieldGroup is not None:
@@ -126,28 +131,40 @@ class FieldGroupManager:
126
131
  self.fieldGroup = tmp_def
127
132
  self.EDITABLE = False
128
133
  elif self.localfolder is not None:
129
- for json_file in self.fieldgroupFolder.glob('*.json'):
130
- tmp_def = json.load(FileIO(json_file))
131
- if tmp_def.get('$id') == fieldGroup['$id'] or tmp_def.get('meta:altId') == fieldGroup.get('meta:altId') or tmp_def.get('title') == fieldGroup.get('title'):
132
- self.fieldGroup = tmp_def
133
- if self.tenantId[1:] in self.fieldGroup.get('$id'): ## custom field group
134
- if '/datatypes/' in str(self.fieldGroup):
135
- dataTypeSearch = f"(https://ns.adobe.com/{self.tenantId[1:]}/datatypes/[0-9a-z]+?)'"
136
- dataTypes = re.findall(dataTypeSearch,str(self.fieldGroup))
137
- for dt in dataTypes:
138
- dt_manager = DataTypeManager(dt,localFolder=self.localfolder,sandbox=self.sandbox,tenantId=self.tenantId)
139
- self.dataTypes[dt_manager.id] = dt_manager.title
140
- self.dataTypeManagers[dt_manager.title] = dt_manager
141
- else: ## OOTB field group
142
- if 'properties' in self.fieldGroup.keys():
143
- self.fieldGroup['definitions'] = self.fieldGroup['properties']
144
- if self.fieldGroup == {}:
145
- for json_file in self.fieldgroupGlobalFolder.glob('*.json'):
134
+ found = False
135
+ for folder in self.fieldgroupFolder:
136
+ for json_file in folder.glob('*.json'):
146
137
  tmp_def = json.load(FileIO(json_file))
147
138
  if tmp_def.get('$id') == fieldGroup['$id'] or tmp_def.get('meta:altId') == fieldGroup.get('meta:altId') or tmp_def.get('title') == fieldGroup.get('title'):
148
139
  self.fieldGroup = tmp_def
149
- if 'properties' in self.fieldGroup.keys():
150
- self.fieldGroup['definitions'] = self.fieldGroup['properties']
140
+ if self.tenantId[1:] in self.fieldGroup.get('$id'): ## custom field group
141
+ if '/datatypes/' in str(self.fieldGroup):
142
+ dataTypeSearch = f"(https://ns.adobe.com/{self.tenantId[1:]}/datatypes/[0-9a-z]+?)'"
143
+ dataTypes = re.findall(dataTypeSearch,str(self.fieldGroup))
144
+ for dt in dataTypes:
145
+ dt_manager = DataTypeManager(dt,localFolder=self.localfolder,sandbox=self.sandbox,tenantId=self.tenantId)
146
+ self.dataTypes[dt_manager.id] = dt_manager.title
147
+ self.dataTypeManagers[dt_manager.title] = dt_manager
148
+ else: ## OOTB field group
149
+ if 'properties' in self.fieldGroup.keys():
150
+ self.fieldGroup['definitions'] = self.fieldGroup['properties']
151
+ found = True
152
+ break
153
+ if found:
154
+ break
155
+ if self.fieldGroup == {}:
156
+ found = False
157
+ for folder in self.fieldgroupGlobalFolder:
158
+ for json_file in folder.glob('*.json'):
159
+ tmp_def = json.load(FileIO(json_file))
160
+ if tmp_def.get('$id') == fieldGroup['$id'] or tmp_def.get('meta:altId') == fieldGroup.get('meta:altId') or tmp_def.get('title') == fieldGroup.get('title'):
161
+ self.fieldGroup = tmp_def
162
+ if 'properties' in self.fieldGroup.keys():
163
+ self.fieldGroup['definitions'] = self.fieldGroup['properties']
164
+ found = True
165
+ break
166
+ if found:
167
+ break
151
168
  self.EDITABLE = False
152
169
  else: ## if definitions key not present
153
170
  if 'properties' in self.fieldGroup.keys():
@@ -166,19 +183,24 @@ class FieldGroupManager:
166
183
  self.fieldGroup = self.schemaAPI.getFieldGroup(self.fieldGroup['$id'],full=True)
167
184
  self.EDITABLE = True
168
185
  elif self.localfolder is not None: ## looking into local folder
169
- for json_file in self.fieldgroupFolder.glob('*.json'): ## only custom Field groups: TO DO check for OOTB FG without definition
170
- tmp_def = json.load(FileIO(json_file))
171
- if tmp_def.get('$id') == fieldGroup['$id'] or tmp_def.get('meta:altId') == fieldGroup.get('meta:altId') or tmp_def.get('title') == fieldGroup.get('title'):
172
- self.fieldGroup = tmp_def
173
- if self.tenantId[1:] in self.fieldGroup.get('$id'): ## custom field group
174
- if '/datatypes/' in str(self.fieldGroup):
175
- dataTypeSearch = f"(https://ns.adobe.com/{self.tenantId[1:]}/datatypes/[0-9a-z]+?)'"
176
- dataTypes = re.findall(dataTypeSearch,str(self.fieldGroup))
177
- for dt in dataTypes:
178
- dt_manager = DataTypeManager(dt,localFolder=self.localfolder,sandbox=self.sandbox,tenantId=self.tenantId)
179
- self.dataTypes[dt_manager.id] = dt_manager.title
180
- self.dataTypeManagers[dt_manager.title] = dt_manager
181
-
186
+ found = False
187
+ for folder in self.fieldgroupFolder:
188
+ for json_file in folder.glob('*.json'): ## only custom Field groups: TO DO check for OOTB FG without definition
189
+ tmp_def = json.load(FileIO(json_file))
190
+ if tmp_def.get('$id') == fieldGroup['$id'] or tmp_def.get('meta:altId') == fieldGroup.get('meta:altId') or tmp_def.get('title') == fieldGroup.get('title'):
191
+ self.fieldGroup = tmp_def
192
+ if self.tenantId[1:] in self.fieldGroup.get('$id'): ## custom field group
193
+ if '/datatypes/' in str(self.fieldGroup):
194
+ dataTypeSearch = f"(https://ns.adobe.com/{self.tenantId[1:]}/datatypes/[0-9a-z]+?)'"
195
+ dataTypes = re.findall(dataTypeSearch,str(self.fieldGroup))
196
+ for dt in dataTypes:
197
+ dt_manager = DataTypeManager(dt,localFolder=self.localfolder,sandbox=self.sandbox,tenantId=self.tenantId)
198
+ self.dataTypes[dt_manager.id] = dt_manager.title
199
+ self.dataTypeManagers[dt_manager.title] = dt_manager
200
+ found = True
201
+ break
202
+ if found:
203
+ break
182
204
  else:
183
205
  raise ValueError("The field group definition provided does not contains the 'definitions' key. Please check the field group.")
184
206
  else:
@@ -208,26 +230,38 @@ class FieldGroupManager:
208
230
  self.fieldGroup = tmp_def
209
231
  self.EDITABLE = False
210
232
  elif self.localfolder is not None:
211
- for json_file in self.fieldgroupFolder.glob('*.json'):
212
- tmp_def = json.load(FileIO(json_file))
213
- if tmp_def.get('$id') == fieldGroup or tmp_def.get('meta:altId') == fieldGroup or tmp_def.get('title') == fieldGroup:
214
- self.fieldGroup = tmp_def
215
- if tmp_def.get('meta:tenantNamespace',None) is not None:
216
- self.tenantId = tmp_def.get('meta:tenantNamespace')
217
- if '/datatypes/' in str(self.fieldGroup):
218
- dataTypeSearch = f"(https://ns.adobe.com/{self.tenantId[1:]}/datatypes/[0-9a-z]+?)'"
219
- dataTypes = re.findall(dataTypeSearch,str(self.fieldGroup.get('definitions')))
220
- for file in self.datatypeFolder.glob('*.json'):
221
- tmp_def = json.load(FileIO(file))
222
- if tmp_def.get('$id') in dataTypes or tmp_def.get('meta:altId') in dataTypes:
223
- dt_manager = DataTypeManager(tmp_def,localFolder=self.localfolder,sandbox=self.sandbox,tenantId=self.tenantId)
224
- self.dataTypes[dt_manager.id] = dt_manager.title
225
- self.dataTypeManagers[dt_manager.title] = dt_manager
226
- if self.fieldGroup == {}: ## looking into the global folder
227
- for json_file in self.fieldgroupGlobalFolder.glob('*.json'):
233
+ found = False
234
+ for folder in self.fieldgroupFolder:
235
+ for json_file in folder.glob('*.json'):
228
236
  tmp_def = json.load(FileIO(json_file))
229
237
  if tmp_def.get('$id') == fieldGroup or tmp_def.get('meta:altId') == fieldGroup or tmp_def.get('title') == fieldGroup:
230
- self.fieldGroup = tmp_def
238
+ self.fieldGroup = tmp_def
239
+ if tmp_def.get('meta:tenantNamespace',None) is not None:
240
+ self.tenantId = tmp_def.get('meta:tenantNamespace')
241
+ if '/datatypes/' in str(self.fieldGroup):
242
+ dataTypeSearch = f"(https://ns.adobe.com/{self.tenantId[1:]}/datatypes/[0-9a-z]+?)'"
243
+ dataTypes = re.findall(dataTypeSearch,str(self.fieldGroup.get('definitions')))
244
+ for file in self.datatypeFolder.glob('*.json'):
245
+ tmp_def = json.load(FileIO(file))
246
+ if tmp_def.get('$id') in dataTypes or tmp_def.get('meta:altId') in dataTypes:
247
+ dt_manager = DataTypeManager(tmp_def,localFolder=self.localfolder,sandbox=self.sandbox,tenantId=self.tenantId)
248
+ self.dataTypes[dt_manager.id] = dt_manager.title
249
+ self.dataTypeManagers[dt_manager.title] = dt_manager
250
+ found = True
251
+ break
252
+ if found:
253
+ break
254
+ if self.fieldGroup == {}: ## looking into the global folder
255
+ found = False
256
+ for folder in self.fieldgroupGlobalFolder:
257
+ for json_file in folder.glob('*.json'):
258
+ tmp_def = json.load(FileIO(json_file))
259
+ if tmp_def.get('$id') == fieldGroup or tmp_def.get('meta:altId') == fieldGroup or tmp_def.get('title') == fieldGroup:
260
+ self.fieldGroup = tmp_def
261
+ found = True
262
+ break
263
+ if found:
264
+ break
231
265
  else:
232
266
  raise ValueError("the element pass is not a field group definition")
233
267
  else:
@@ -1689,10 +1723,11 @@ class FieldGroupManager:
1689
1723
  res = self.schemaAPI.getDescriptors(prop=f"xdm:sourceSchema=={self.id}")
1690
1724
  elif self.localfolder is not None:
1691
1725
  res = []
1692
- for json_file in self.descriptorFolder.glob('*.json'):
1693
- tmp_def = json.load(FileIO(json_file))
1694
- if tmp_def.get('xdm:sourceSchema') == self.id:
1695
- res.append(tmp_def)
1726
+ for folder in self.descriptorFolder:
1727
+ for json_file in folder.glob('*.json'):
1728
+ tmp_def = json.load(FileIO(json_file))
1729
+ if tmp_def.get('xdm:sourceSchema') == self.id:
1730
+ res.append(tmp_def)
1696
1731
  else:
1697
1732
  raise Exception("Require a schema API connection or local folder. Pass the instance of a Schema class or import a configuration file.")
1698
1733
  return res