Python-json-config-reader 0.0.1__tar.gz → 0.0.2__tar.gz

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.
@@ -11,7 +11,6 @@ def load_config(path: str):
11
11
  loaded_data = yaml.safe_load(context)
12
12
  else:
13
13
  print("Error file type")
14
- if not loaded_data: raise FileNotFoundError()
15
14
  return loaded_data
16
15
  except FileNotFoundError:
17
16
  dump_config(path, {})
@@ -20,20 +19,19 @@ def load_config(path: str):
20
19
 
21
20
  def dump_config(path: str, data: dict):
22
21
  try:
22
+ #
23
+ dictionary = path.replace("\\","/")
24
+ dictionary = dictionary.split("/")
25
+ dictionary = ''.join(dictionary[:-1])
26
+ if not os.path.exists(dictionary):
27
+ os.makedirs(dictionary)
28
+ #
23
29
  with open(path, "w", encoding="utf-8") as file:
24
30
  if path[-4:] == "json":
25
31
  file.write(_dict_to_json(data))
26
32
  elif path[-4:] == "yaml":
27
33
  yaml.safe_dump(data, file)
28
34
  else: print("Error file type")
29
- except FileNotFoundError:
30
- dictionary = path.split("/")
31
- now_path = ""
32
- for dicts in dictionary[:-1]:
33
- try: os.mkdir(f"{now_path}{dicts}/")
34
- except: pass
35
- now_path+=dicts+"/"
36
- dump_config(path = path, data = data)
37
35
  except: traceback.print_exc()
38
36
 
39
37
  def _dict_to_json(data,level=0):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Python-json-config-reader
3
- Version: 0.0.1
3
+ Version: 0.0.2
4
4
  Summary: A reader for yaml and json file in python
5
5
  Author-email: Sugar51243 <1733682365@qq.com>
6
6
  License: MIT License
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Python-json-config-reader
3
- Version: 0.0.1
3
+ Version: 0.0.2
4
4
  Summary: A reader for yaml and json file in python
5
5
  Author-email: Sugar51243 <1733682365@qq.com>
6
6
  License: MIT License
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "Python-json-config-reader"
7
- version = "0.0.1"
7
+ version = "0.0.2"
8
8
  authors = [
9
9
  { name="Sugar51243", email="1733682365@qq.com" },
10
10
  ]