Skip to content

Commit 75fe445

Browse files
Add seq types for second condition of object type in __dict_2_obj
1 parent 212345c commit 75fe445

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

jsonconfigparser.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import json
22
from os import path
3+
from typing import Any
34
from schema import Schema, SchemaError
45

56
class Config(object):
@@ -38,18 +39,16 @@ def __get_file_buff(cls, path_file:str):
3839
raise ConfigFileOpenReadError(str(e))
3940

4041
@classmethod
41-
def __dict_2_obj(cls, data:any):
42+
def __dict_2_obj(cls, data: Any):
4243
_type = type(data)
4344

4445
if _type is dict:
4546
obj = object.__new__(cls)
46-
for key in data:
47-
setattr(obj, key, cls.__dict_2_obj(data[key]))
47+
for key, value in data.items():
48+
setattr(obj, key, cls.__dict_2_obj(value))
4849
return obj
49-
if _type is list:
50-
for i in range(len(data)):
51-
data[i] = cls.__dict_2_obj(data[i])
52-
return data
50+
if _type in (list, set, tuple):
51+
return list(map(lambda value: cls.__dict_2_obj(value), data))
5352
else:
5453
return data
5554

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="python-json-config-parser",
8-
version="1.0.6",
8+
version="1.0.7",
99
author="Bruno Silva de Andrade",
1010
author_email="brunojf.andrade@gmail.com",
1111
description="Project created to given the possibility of create dynamics Json config files",

0 commit comments

Comments
 (0)