Skip to content

Commit

Permalink
Change reading config file logic
Browse files Browse the repository at this point in the history
Changed reading config file logic in Services/ApplicationConfigReader.
Now order of src_folder and dst_folder options in file does not matter.
ApplicationConfigReader readPath method reads only selected option from
file. Changed parameter to option from nr_arr. Modified readSource
and readDestination methods.
  • Loading branch information
SWojcik800 committed Aug 12, 2021
1 parent af72c60 commit ce3601f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions Services/ApplicationConfigReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@ class ApplicationConfigReader:
def __init__(self, configFilePath: str):
self.configFilePath = configFilePath

def readPath(self, arr_nr):
def readPath(self, option):

try:
file = [i.split(' ') for i in open(self.configFilePath)]

except:
return FileNotFoundError

result = file[arr_nr][1].strip()
return result

result = list(filter(lambda x: x[0] == option + ":", file))[0][1]
return result.strip()

def readSource(self):
return self.readPath(0)
return self.readPath("src_folder")

def readDestination(self):
return self.readPath(1)
return self.readPath("dst_folder")

0 comments on commit ce3601f

Please sign in to comment.