Index adds XML client names to a drop down. Added a pretty submit button that doesn't do anything.

Started reworking main.py. Broke loadMenu out into LoadClient to get just client names, and ClientConfig, which will load xml for only the selected client.
This commit is contained in:
Dan Dembinski
2019-06-28 15:53:00 -04:00
parent ecb9757fb5
commit bde35b86ac
2 changed files with 147 additions and 124 deletions

258
main.py
View File

@@ -261,8 +261,6 @@ def loadClients():
ConfigFile = "../StorefrontUtilitiesConfig.xml"
ClientName = []
SF_URL = []
SF_HOST = []
# Open the config file
with open(ConfigFile) as f:
@@ -275,136 +273,150 @@ def loadClients():
# print(x.text)
ClientName.append(x.text)
# # Get Storefront API URls
# for x in y.find_all('storefrontapiurl'):
# # print(x)
# SF_URL.append(x.text)
#
# # Get Storefront Host URLs
# for x in SF_URL:
# temp1 = x.split('://')
# temp2 = temp1[1].split('/')
# HOST = (temp2[0])
# SF_HOST.append(HOST)
return ClientName
return(ClientName)
def GetClientConfig(Client):
SF_URL = []
CLIENT_SUMMARY_TAB = []
client_headers = []
SUMMARY_TAB = []
headers =[]
CLIENT_COLUMN_FORMAT = []
COLUMN_FORMAT = []
DETAIL_TAB = []
detail_headers =[]
CLIENT_DETAIL_TAB = []
client_detail_headers = []
REPORT_FIELDS= []
DETAIL_REPORT_FIELDS = []
summary_columnformat = []
detail_columnformat = []
# Loads config file and reads in XML
ConfigFile = "../StorefrontUtilitiesConfig.xml"
# Open the config file
with open(ConfigFile) as f:
r = f.read()
y = bs(r, "lxml")
# Get Storefront API URl
for w in y.find_all('client'):
for x in w.find_all('name'):
if x.text == Client:
SF_URL = x.find_all('storefrontapiurl').text
# Get Storefront Host URL
temp1 = SF_URL.split('://')
temp2 = temp1[1].split('/')
SF_HOST = (temp2[0])
# Get Monthly Report Summary Fields
for w in y.find_all('client'):
for x in w.find_all('name'):
if x.text == Client:
for x in w.find_all('monthlyreport'):
for g in x.find_all('summarytab'):
for z in g.find_all('columnname'):
z.name = "string"
CLIENT_SUMMARY_TAB.append(z)
client_headers.append(z.text)
SUMMARY_TAB.append(CLIENT_SUMMARY_TAB)
headers.append(client_headers)
CLIENT_SUMMARY_TAB = []
client_headers = []
# Get Monthly Report Column Format
for w in y.find_all('client'):
for x in w.find_all('name'):
if x.text == Client:
for x in w.find_all('monthlyreport'):
for g in x.find_all('summarytab'):
for z in g.find_all('columnformat'):
CLIENT_COLUMN_FORMAT.append(z.text)
COLUMN_FORMAT.append(CLIENT_COLUMN_FORMAT)
CLIENT_COLUMN_FORMAT = []
# Get Monthly Report Item Detail Fields
for w in y.find_all('client'):
for x in w.find_all('name'):
if x.text == Client:
for x in w.find_all('monthlyreport'):
for g in x.find_all('detailtab'):
for z in g.find_all('columnname'):
z.name = "string"
CLIENT_DETAIL_TAB.append(z)
client_detail_headers.append(z.text)
DETAIL_TAB.append(CLIENT_DETAIL_TAB)
detail_headers.append(client_detail_headers)
CLIENT_DETAIL_TAB = []
client_detail_headers = []
# converts summary_tab values to a string, adds everything to the URL_HOST array and returns it
REPORT_FIELDS = '\n'.join(map(str, SUMMARY_TAB))
DETAIL_REPORT_FIELDS = '\n'.join(map(str, DETAIL_TAB))
# Get specific Summary Column Types for chosen client
for w in y.find_all('client'):
for x in w.find_all('name'):
if x.text == Client:
for x in w.find_all('monthlyreport'):
for g in x.find_all('summarytab'):
for z in g.find_all('columnformat'):
CLIENT_COLUMN_FORMAT.append(z.text)
summary_columnformat = dict.fromkeys(headers)
# set Summary Column Types Header Dictionary
count = 0
for key in summary_columnformat:
summary_columnformat[key] = CLIENT_COLUMN_FORMAT[count]
count = count + 1
CLIENT_COLUMN_FORMAT = []
# Get specific Detail Column Types for chosen client
for w in y.find_all('client'):
for x in w.find_all('name'):
if x.text == Client:
for x in w.find_all('monthlyreport'):
for g in x.find_all('detailtab'):
for z in g.find_all('columnformat'):
CLIENT_COLUMN_FORMAT.append(z.text)
detail_columnformat = dict.fromkeys(detail_headers)
# set Detail Column Types Header Dictionary
count = 0
for key in detail_columnformat:
detail_columnformat[key] = CLIENT_COLUMN_FORMAT[count]
count = count + 1
# create new report file and add headers based on config file
wb = workbook.Workbook()
ws = wb.active
ws.title = "Order Summary"
ws.append(headers)
ws2 = wb.create_sheet("Item Detail")
ws2.append(detail_headers)
ClientConfig = [SF_URL, SF_HOST, REPORT_FIELDS, DETAIL_REPORT_FIELDS, summary_columnformat, headers, detail_columnformat, detail_headers, wb, ws, ws2]
return ClientConfig
# def loadMenu():
#
# ConfigFile = "StorefrontUtilitiesConfig.xml"
# ClientName = []
# SF_URL = []
# SF_HOST = []
# CLIENT_SUMMARY_TAB = []
# SUMMARY_TAB = []
# headers = []
# client_headers = []
# CLIENT_DETAIL_TAB = []
# DETAIL_TAB = []
# client_detail_headers = []
# detail_headers = []
# CLIENT_COLUMN_FORMAT = []
# COLUMN_FORMAT = []
# detail_columnformat = []
#
#
#
# # Get Monthly Report Summary Fields
# for w in y.find_all('client'):
# for x in w.find_all('monthlyreport'):
# for g in x.find_all('summarytab'):
# for z in g.find_all('columnname'):
# z.name = "string"
# CLIENT_SUMMARY_TAB.append(z)
# client_headers.append(z.text)
# SUMMARY_TAB.append(CLIENT_SUMMARY_TAB)
# headers.append(client_headers)
# CLIENT_SUMMARY_TAB = []
# client_headers = []
#
# # Get Monthly Report Column Format
# for w in y.find_all('client'):
# for x in w.find_all('monthlyreport'):
# for g in x.find_all('summarytab'):
# for z in g.find_all('columnformat'):
# CLIENT_COLUMN_FORMAT.append(z.text)
# COLUMN_FORMAT.append(CLIENT_COLUMN_FORMAT)
# CLIENT_COLUMN_FORMAT = []
#
# # Get Monthly Report Item Detail Fields
# for w in y.find_all('client'):
# for x in w.find_all('monthlyreport'):
# for g in x.find_all('detailtab'):
# for z in g.find_all('columnname'):
# z.name = "string"
# CLIENT_DETAIL_TAB.append(z)
# client_detail_headers.append(z.text)
# DETAIL_TAB.append(CLIENT_DETAIL_TAB)
# detail_headers.append(client_detail_headers)
# CLIENT_DETAIL_TAB = []
# client_detail_headers = []
#
# choice = 0
# for x in ClientName:
# print(choice, x)
# choice = choice + 1
#
# option = int(input())
#
# Since I forgot what this is...It passes ClientName over to ClientSpecific.py to see if they have any custom tabs.
# client_Specific_Tabs(ClientName[option])
#
# summary_columnformat = dict.fromkeys(headers[option])
#
# # Get specific Summary Column Types for chosen client
# for w in y.find_all('client'):
# for x in w.find_all('name'):
# if x.text == ClientName[option]:
# for x in w.find_all('monthlyreport'):
# for g in x.find_all('summarytab'):
# for z in g.find_all('columnformat'):
# CLIENT_COLUMN_FORMAT.append(z.text)
# # set Summary Column Types Header Dictionary
# count = 0
# for key in summary_columnformat:
# summary_columnformat[key] = CLIENT_COLUMN_FORMAT[count]
# count = count + 1
#
# CLIENT_COLUMN_FORMAT = []
# # Get specific Detail Column Types for chosen client
# for w in y.find_all('client'):
# for x in w.find_all('name'):
# if x.text == ClientName[option]:
# for x in w.find_all('monthlyreport'):
# for g in x.find_all('detailtab'):
# for z in g.find_all('columnformat'):
# CLIENT_COLUMN_FORMAT.append(z.text)
#
# detail_columnformat = dict.fromkeys(detail_headers[option])
# # set Detail Column Types Header Dictionary
# count = 0
# for key in detail_columnformat:
# detail_columnformat[key] = CLIENT_COLUMN_FORMAT[count]
# count = count + 1
#
# # create new report file and add headers based on config file
# wb = workbook.Workbook()
# ws = wb.active
# ws.title = "Order Summary"
# ws.append(headers[option])
#
# ws2 = wb.create_sheet("Item Detail")
# ws2.append(detail_headers[option])
#
# # converts summary_tab values to a string, adds everything to the URL_HOST array and returns it
#
# REPORT_FIELDS = '\n'.join(map(str, SUMMARY_TAB[option]))
# DETAIL_REPORT_FIELDS = '\n'.join(map(str, DETAIL_TAB[option]))
# URL_HOST = [SF_URL[option], SF_HOST[option], REPORT_FIELDS, wb, ws, ws2, DETAIL_REPORT_FIELDS, summary_columnformat, headers[option], detail_columnformat, detail_headers[option]]
# return URL_HOST
#
# def main():
# URL_HOST = loadMenu()
# URL = URL_HOST[0]