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/__init__.py CHANGED
@@ -165,7 +165,7 @@ def __titleSafe__(text: str) -> str:
165
165
  return text
166
166
 
167
167
 
168
- def extractSandboxArtefacts(
168
+ def extractSandboxArtifacts(
169
169
  sandbox: 'ConnectObject' = None,
170
170
  localFolder: Union[str, Path] = None,
171
171
  region: str = "nld2",
@@ -310,20 +310,20 @@ def extractSandboxArtefacts(
310
310
  with open(f"{audiencePath / safe_name}.json",'w') as f:
311
311
  json.dump(el,f,indent=2)
312
312
 
313
- def extractSandboxArtefact(
313
+ def extractSandboxArtifact(
314
314
  sandbox: 'ConnectObject' = None,
315
315
  localFolder: Union[str, Path] = None,
316
- artefact: str = None,
317
- artefactType: str = None,
316
+ artifact: str = None,
317
+ artifactType: str = None,
318
318
  region: str = "nld2",
319
319
  ):
320
320
  """
321
- Export a single artefact and its dependencies from the sandbox.
321
+ Export a single artifact and its dependencies from the sandbox.
322
322
  Arguments:
323
323
  sandbox: REQUIRED: the instance of a ConnectObject that contains the sandbox information and connection.
324
324
  localFolder: OPTIONAL: the local folder where to extract the sandbox. If not provided, it will use the current working directory and name the folder the name of the sandbox.
325
- artefact: REQUIRED: the id or the name of the artefact to export.
326
- artefactType: REQUIRED: the type of artefact to export. Possible values are: 'class','schema','fieldgroup','datatype','descriptor','dataset','identity','mergepolicy',audience'
325
+ artifact: REQUIRED: the id or the name of the artifact to export.
326
+ artifactType: REQUIRED: the type of artifact to export. Possible values are: 'class','schema','fieldgroup','datatype','descriptor','dataset','identity','mergepolicy',audience'
327
327
  region: OPTIONAL: the region of the sandbox (default: nld2). This is used to fetch the correct API endpoints for the identities.
328
328
  Possible values: "va7","aus5", "can2", "ind2"
329
329
  """
@@ -348,24 +348,24 @@ def extractSandboxArtefact(
348
348
  from aepp import schema, catalog, identity
349
349
  sch = schema.Schema(config=sandbox)
350
350
  cat = catalog.Catalog(config=sandbox)
351
- if artefactType == 'class':
352
- __extractClass__(artefact,completePath,sandbox)
353
- elif artefactType == 'schema':
354
- __extractSchema__(artefact,completePath,sandbox,region)
355
- elif artefactType == 'fieldgroup':
356
- __extractFieldGroup__(artefact,completePath,sandbox)
357
- elif artefactType == 'datatype':
358
- __extractDataType__(artefact,completePath,sandbox)
359
- elif artefactType == 'dataset':
360
- __extractDataset__(artefact,completePath,sandbox,region)
361
- elif artefactType == 'identity':
362
- __extractIdentity__(artefact,region,completePath,sandbox)
363
- elif artefactType == 'mergepolicy':
364
- __extractMergePolicy__(artefact,completePath,sandbox)
365
- elif artefactType == 'audience':
366
- __extractAudience__(artefact,completePath,sandbox)
351
+ if artifactType == 'class':
352
+ __extractClass__(artifact,completePath,sandbox)
353
+ elif artifactType == 'schema':
354
+ __extractSchema__(artifact,completePath,sandbox,region)
355
+ elif artifactType == 'fieldgroup':
356
+ __extractFieldGroup__(artifact,completePath,sandbox)
357
+ elif artifactType == 'datatype':
358
+ __extractDataType__(artifact,completePath,sandbox)
359
+ elif artifactType == 'dataset':
360
+ __extractDataset__(artifact,completePath,sandbox,region)
361
+ elif artifactType == 'identity':
362
+ __extractIdentity__(artifact,region,completePath,sandbox)
363
+ elif artifactType == 'mergepolicy':
364
+ __extractMergePolicy__(artifact,completePath,sandbox)
365
+ elif artifactType == 'audience':
366
+ __extractAudience__(artifact,completePath,sandbox)
367
367
  else:
368
- raise ValueError("artefactType not recognized")
368
+ raise ValueError("artifactType not recognized")
369
369
 
370
370
  def __extractClass__(classEl: str,folder: Union[str, Path] = None,sandbox: 'ConnectObject' = None):
371
371
  classPath = Path(folder) / 'class'
aepp/__version__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.5.1"
1
+ __version__ = "0.5.2"
aepp/classmanager.py CHANGED
@@ -23,7 +23,7 @@ class ClassManager:
23
23
  schemaAPI:'Schema'=None,
24
24
  config: Union[dict,ConnectObject] = aepp.config.config_object,
25
25
  description: str = 'power by aepp',
26
- localFolder:str=None,
26
+ localFolder:str | list | None = None,
27
27
  sandbox:str=None,
28
28
  **kwargs
29
29
  )->None:
@@ -48,13 +48,16 @@ class ClassManager:
48
48
  elif config is not None and localFolder is None:
49
49
  self.schemaAPI = Schema(config=config)
50
50
  elif localFolder is not None:
51
- self.localfolder = Path(localFolder)
52
- if self.localfolder.exists() is False:
51
+ if isinstance(localFolder, str):
52
+ self.localfolder = [Path(localFolder)]
53
+ elif isinstance(localFolder, list):
54
+ self.localfolder = [Path(lf) for lf in localFolder]
55
+ if any([folder.exists() is False for folder in self.localfolder]):
53
56
  raise Exception(f"The local folder {self.localfolder} does not exist. Please create it and extract your sandbox before using it.")
54
57
  self.schemaAPI = None
55
- self.classFolder = self.localfolder / 'class'
56
- self.behavFolder = self.localfolder / 'behaviour'
57
- if self.classFolder.exists() is False:
58
+ self.classFolder = [folder / 'class' for folder in self.localfolder]
59
+ self.behavFolder = [folder / 'behaviour' for folder in self.localfolder]
60
+ if any([folder.exists() is False for folder in self.classFolder]):
58
61
  raise Exception(f"The local folder {self.classFolder} does not exist. Please create it and extract your sandbox before using it.")
59
62
  else:
60
63
  raise Exception("You need to provide a schemaAPI instance or a config object to connect to the API or a local folder to use the local storage")
@@ -71,9 +74,11 @@ class ClassManager:
71
74
  elif type(aepclass) == dict:
72
75
  self.tenantId = aepclass.get('meta:tenantNamespace'," ")
73
76
  elif self.localfolder is not None:
74
- config_json = json.load(FileIO(self.localfolder / 'config.json'))
75
- if config_json.get('tenantId',None) is not None:
76
- self.tenantId = config_json.get('tenantId')
77
+ for folder in self.localfolder:
78
+ config_json = json.load(FileIO(folder / 'config.json'))
79
+ if config_json.get('tenantId',None) is not None:
80
+ self.tenantId = config_json.get('tenantId')
81
+ break
77
82
  else:
78
83
  self.tenantId = " "
79
84
  if type(aepclass) == dict:
@@ -82,10 +87,15 @@ class ClassManager:
82
87
  self.aepclass = self.schemaAPI.getClass(aepclass['$id'],full=False,xtype='xed')
83
88
  self.EDITABLE = True
84
89
  elif self.localfolder is not None:
85
- for json_file in self.classFolder.glob('*.json'):
86
- tmp_def = json.load(FileIO(json_file))
87
- if tmp_def.get('$id') == aepclass['$id']:
88
- self.aepclass = tmp_def
90
+ found = False
91
+ for folder in self.classFolder:
92
+ for json_file in folder.glob('*.json'):
93
+ tmp_def = json.load(FileIO(json_file))
94
+ if tmp_def.get('$id') == aepclass['$id']:
95
+ self.aepclass = tmp_def
96
+ found = True
97
+ break
98
+ if found:
89
99
  break
90
100
  self.EDITABLE = False
91
101
  elif self.tenantId[1:] not in aepclass['$id']:
@@ -93,10 +103,15 @@ class ClassManager:
93
103
  self.aepclass = self.schemaAPI.getClass(aepclass['$id'],full=True,xtype='xed')
94
104
  self.EDITABLE = False
95
105
  elif self.localfolder is not None:
96
- for json_file in self.classFolder.glob('*.json'):
97
- tmp_def = json.load(FileIO(json_file))
98
- if tmp_def.get('$id') == aepclass['$id']:
99
- self.aepclass = tmp_def
106
+ found = False
107
+ for folder in self.classFolder:
108
+ for json_file in folder.glob('*.json'):
109
+ tmp_def = json.load(FileIO(json_file))
110
+ if tmp_def.get('$id') == aepclass['$id']:
111
+ self.aepclass = tmp_def
112
+ found = True
113
+ break
114
+ if found:
100
115
  break
101
116
  self.EDITABLE = False
102
117
  self.__setAttributes__(self.aepclass)
@@ -106,20 +121,30 @@ class ClassManager:
106
121
  self.aepclass = self.schemaAPI.getClass(aepclass,full=False,xtype='xed')
107
122
  self.EDITABLE = True
108
123
  elif self.localfolder is not None:
109
- for json_file in self.classFolder.glob('*.json'):
110
- tmp_def = json.load(FileIO(json_file))
111
- if tmp_def.get('$id') == aepclass or tmp_def.get('meta:altId') == aepclass:
112
- self.aepclass = tmp_def
124
+ found = False
125
+ for folder in self.classFolder:
126
+ for json_file in folder.glob('*.json'):
127
+ tmp_def = json.load(FileIO(json_file))
128
+ if tmp_def.get('$id') == aepclass or tmp_def.get('meta:altId') == aepclass:
129
+ self.aepclass = tmp_def
130
+ found = True
131
+ break
132
+ if found:
113
133
  break
114
134
  self.EDITABLE = False
115
135
  else:
116
136
  if self.schemaAPI is not None:
117
137
  self.aepclass = self.schemaAPI.getClass(aepclass,full=True,xtype='xed')
118
138
  elif self.localfolder is not None:
119
- for json_file in self.classFolder.glob('*.json'):
120
- tmp_def = json.load(FileIO(json_file))
121
- if tmp_def.get('$id') == aepclass or tmp_def.get('meta:altId') == aepclass:
122
- self.aepclass = tmp_def
139
+ found = False
140
+ for folder in self.classFolder:
141
+ for json_file in folder.glob('*.json'):
142
+ tmp_def = json.load(FileIO(json_file))
143
+ if tmp_def.get('$id') == aepclass or tmp_def.get('meta:altId') == aepclass:
144
+ self.aepclass = tmp_def
145
+ found = True
146
+ break
147
+ if found:
123
148
  break
124
149
  self.EDITABLE = False
125
150
  self.__setAttributes__(self.aepclass)
@@ -168,10 +193,15 @@ class ClassManager:
168
193
  if self.schemaAPI is not None:
169
194
  self.behaviorDefinition = self.schemaAPI.getBehavior(behavId,full=True,xtype='xed')
170
195
  elif self.localfolder is not None:
171
- for json_file in self.behavFolder.glob('*.json'):
172
- tmp_def = json.load(FileIO(json_file))
173
- if tmp_def.get('$id') == behavId:
174
- self.behaviorDefinition = tmp_def
196
+ found = False
197
+ for folder in self.behavFolder:
198
+ for json_file in folder.glob('*.json'):
199
+ tmp_def = json.load(FileIO(json_file))
200
+ if tmp_def.get('$id') == behavId:
201
+ self.behaviorDefinition = tmp_def
202
+ found = True
203
+ break
204
+ if found:
175
205
  break
176
206
  self.requiredFields = set()
177
207