From 095dbc61bde76ec6f7a772e18163022bdd946fc9 Mon Sep 17 00:00:00 2001 From: demskeq8 Date: Wed, 20 Mar 2024 07:54:27 +0100 Subject: [PATCH] [SMO] ves-collector: support blob in schemaReference new: schemaReference": "https://forge.3gpp.org/rep/sa5/MnS/blob/..." schemaReference": "https://forge.3gpp.org/rep/sa5/MnS/raw/..." Issue-ID: OAM-402 Change-Id: I0dfb240ed53cfd6a0bc103547fb576ac2da002ff Signed-off-by: demskeq8 --- solution/smo/oam/ves-collector/install.py | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/solution/smo/oam/ves-collector/install.py b/solution/smo/oam/ves-collector/install.py index 412437e..eb1dc6b 100644 --- a/solution/smo/oam/ves-collector/install.py +++ b/solution/smo/oam/ves-collector/install.py @@ -26,17 +26,20 @@ class Installer: def __init__(self, url, branch, dstFolder) -> None: self.downloadUrl = url self.publicUrlFormat = self.createPublicUrlFormat(url, branch) - print(f'fmt={self.publicUrlFormat}') + for key,value in self.publicUrlFormat.items(): + print(f'fmt={key}->{value}') self.branch = branch self.baseFolder = dstFolder self.subfolder = self.createSubFolder(url, branch) - def createPublicUrlFormat(self, url:str, branch:str)->str: + def createPublicUrlFormat(self, url:str, branch:str)->dict: + fmt: dict = {} if url.endswith('.git'): url = url[:-4] if url.startswith('git@'): url = 'https://'+url[4:] - fmt=url+'/raw/'+branch+'/{}' + fmt["raw"]=url+'/raw/'+branch+'/{}' + fmt["blob"]=url+'/blob/'+branch+'/{}' return fmt def createSubFolder(self, gitUrl:str, branch:str) -> str: regex = r"^[^\/]+\/\/(.*)$" @@ -115,14 +118,15 @@ class Installer: files = self.getFilesFiltered() for file in files: print(file) - pubUrl = self.publicUrlFormat.format(file) - if self.urlAlreadyInData(data,pubUrl): - print(f'entry with url {pubUrl} already exists. ignoring') - continue - data.append({ - 'publicURL': pubUrl, - 'localURL': f'{self.subfolder}/{file}' - }) + for key,value in self.publicUrlFormat.items(): + pubUrl = value.format(file) + if self.urlAlreadyInData(data,pubUrl): + print(f'entry with url {pubUrl} already exists. ignoring') + continue + data.append({ + 'publicURL': pubUrl, + 'localURL': f'{self.subfolder}/{file}' + }) with open(schemaMapFile,'w') as fp: json.dump(data,fp) @@ -167,4 +171,4 @@ for item in config: dlBranch = item['branch'] installer = Installer(dlRepo, dlBranch, dstPath) installer.download() - installer.createSchemaMap() \ No newline at end of file + installer.createSchemaMap() -- 2.16.6