standalone works with dsw process as seperate function
This commit is contained in:
+17
-10
@@ -105,22 +105,15 @@ def getDate(srcSheet):
|
|||||||
reportDate = tempDate[6:10]+'-'+tempDate[0:2]+'-'+tempDate[3:5]
|
reportDate = tempDate[6:10]+'-'+tempDate[0:2]+'-'+tempDate[3:5]
|
||||||
return reportDate
|
return reportDate
|
||||||
|
|
||||||
def main():
|
def processDsw(file, database):
|
||||||
# get filename and database rom cmdline
|
|
||||||
parser = argparse.ArgumentParser()
|
|
||||||
parser.add_argument("type")
|
|
||||||
parser.add_argument("inFile")
|
|
||||||
parser.add_argument("database")
|
|
||||||
args = parser.parse_args()
|
|
||||||
|
|
||||||
# open the excel sheet for reading
|
# open the excel sheet for reading
|
||||||
srcBook = xlrd.open_workbook(args.inFile)
|
srcBook = xlrd.open_workbook(file)
|
||||||
srcSheet = srcBook.sheet_by_index(0)
|
srcSheet = srcBook.sheet_by_index(0)
|
||||||
|
|
||||||
reportDate = getDate(srcSheet)
|
reportDate = getDate(srcSheet)
|
||||||
|
|
||||||
#open the database
|
#open the database
|
||||||
conn = openDatabase(args.database)
|
conn = openDatabase(database)
|
||||||
if conn == None:
|
if conn == None:
|
||||||
sys.exit('database could not be opened, does it exist')
|
sys.exit('database could not be opened, does it exist')
|
||||||
|
|
||||||
@@ -130,5 +123,19 @@ def main():
|
|||||||
else:
|
else:
|
||||||
extractDsw(srcSheet, conn, reportDate)
|
extractDsw(srcSheet, conn, reportDate)
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
# get filename and database rom cmdline
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument("type")
|
||||||
|
parser.add_argument("inFile")
|
||||||
|
parser.add_argument("database")
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
if args.type == 'dsw':
|
||||||
|
processDsw(args.inFile, args.database)
|
||||||
|
else:
|
||||||
|
print('type not found or not entered')
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user