Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
tedi committed Jul 25, 2020
1 parent febd249 commit 575fed4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 20 deletions.
24 changes: 5 additions & 19 deletions buildutil/iniparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,17 @@ def read(self, section, key):
ini.read(self.iniPathFile)

# Validate
if section == "":
section = "DEFAULT"

if section is None:
if section == "" or section is None:
section = "DEFAULT"

if key == "" or key is None:
return


if key == "" or key is None:
return

# Get configuration
rv = None
try:
rv = ini[section][key]
#rv = ini.get(section, key)
rv = ini.get(section, key)
except Exception as e:
#raise(e)
#print(f"{section} {key}")
rv = None


Expand All @@ -68,8 +58,6 @@ def read(self, section, key):
rv = True
elif rv == "False":
rv = False
#elif rv == "None":
# rv = None
else:
try:
return int(rv)
Expand All @@ -92,10 +80,7 @@ def write(self, section, key, value, update=True):
ini.read(self.iniPathFile)

# Validate
if section == "":
section = "DEFAULT"

if section is None:
if section == "" or section is None:
section = "DEFAULT"

if key == "" or key is None:
Expand Down Expand Up @@ -133,6 +118,7 @@ def write(self, section, key, value, update=True):

#print(f"Wrote: [{section_key}] = '{value}")


def __str__(self):
rv = ""
try:
Expand Down Expand Up @@ -187,7 +173,7 @@ def main():
# Read back
rv = parser.read(section, key)

# Validate
# Validate
if rv != value:
raise Exception("FAILLURE!!")

Expand Down
2 changes: 1 addition & 1 deletion buildutil/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "v0.0.1-6"
__version__ = "v0.0.1-7"
__author__ = "Kanelis Elias"
__email__ = "hkanelhs@yahoo.gr"
__license__ = "MIT"

0 comments on commit 575fed4

Please sign in to comment.