From b3062a94dc7a4a22341da16f1d821becd92178e0 Mon Sep 17 00:00:00 2001 From: James Campbell Date: Thu, 1 Aug 2019 14:53:18 -0400 Subject: [PATCH] updates --- folders2json/folders2json.py | 2 +- folders2json/functions.py | 24 +++++++++++------------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/folders2json/folders2json.py b/folders2json/folders2json.py index 9a2dae3..c3eec95 100644 --- a/folders2json/folders2json.py +++ b/folders2json/folders2json.py @@ -1,6 +1,6 @@ from .functions import GetFullPathFiles, GetDevices, GenerateJson, prep -__version__ = "1.1.1" +__version__ = "1.1.2" def main(): diff --git a/folders2json/functions.py b/folders2json/functions.py index ace120b..fda0878 100644 --- a/folders2json/functions.py +++ b/folders2json/functions.py @@ -59,19 +59,17 @@ def GenerateJson(deviceiddict, win, fullpathfiles): for item in value: absfullfinal.append(f"file:/{item}") finaldict["urls"] = absfullfinal - partsofpath = Path(fullpathfiles[0]).parts - if len(partsofpath) > 3: - finaldict["metadata"] = { - "objective": partsofpath[0], - "batch": partsofpath[1], - "device": key - } - else: - finaldict["metadata"] = { - "objective": Path(fullpathfiles[1]).parts[0], - "batch": Path(fullpathfiles[1]).parts[1], - "device": key - } + for pathitem in fullpathfiles: + partsofpath = Path(pathitem).parts + if len(partsofpath) > 3 and key in partsofpath: + finaldict["metadata"] = { + "objective": partsofpath[0], + "batch": partsofpath[1], + "device": key + } + break + else: + continue finaldict["params"] = {} if os.path.exists(f"{key}.json"): os.remove(f"{key}.json")