Added verbose option for settings file

This commit is contained in:
Oliver 2016-05-15 15:47:28 +10:00
parent af3abc16ef
commit 05739d7e5f
2 changed files with 10 additions and 2 deletions

View File

@ -25,7 +25,7 @@ class BomPref:
self.numberRows = True #add row-numbers to BoM output self.numberRows = True #add row-numbers to BoM output
#read KiBOM preferences from file #read KiBOM preferences from file
def Read(self, file): def Read(self, file, verbose=False):
file = os.path.abspath(file) file = os.path.abspath(file)
if not os.path.exists(file) or not os.path.isfile(file): if not os.path.exists(file) or not os.path.isfile(file):
print("{f} is not a valid file!".format(f=file)) print("{f} is not a valid file!".format(f=file))
@ -47,6 +47,14 @@ class BomPref:
if self.SECTION_IGNORE in cf.sections(): if self.SECTION_IGNORE in cf.sections():
self.ignore = [i for i in cf.options(self.SECTION_IGNORE)] self.ignore = [i for i in cf.options(self.SECTION_IGNORE)]
if verbose:
print("Preferences:")
print(self.OPT_IGNORE_DNF + ' = ' + str(self.ignoreDNF))
print(self.OPT_NUMBER_ROWS + ' = ' + str(self.numberRows))
for i in self.ignore:
print("Ignoring column '" + i + "'")
#write KiBOM preferences to file #write KiBOM preferences to file
def Write(self, file): def Write(self, file):
file = os.path.abspath(file) file = os.path.abspath(file)

View File

@ -80,7 +80,7 @@ numberRows = True
pref_file = os.path.join(os.path.dirname(input_file) , ".bom") pref_file = os.path.join(os.path.dirname(input_file) , ".bom")
pref = BomPref() pref = BomPref()
pref.Read(pref_file) pref.Read(pref_file, verbose=True)
#write preference file back out (first run will generate a file with default preferences) #write preference file back out (first run will generate a file with default preferences)
pref.Write(pref_file) pref.Write(pref_file)