Column Format is now working for both summary and item details. Load function passes client name to the client_Specific_Tabs function in ClientSpecific.py. This will allow any client customization to be done outside of the main program (in theory. I haven't actually tested this yet).
This commit is contained in:
56
main.py
56
main.py
@@ -1,10 +1,9 @@
|
||||
import requests
|
||||
from bs4 import BeautifulSoup as bs
|
||||
# import csv
|
||||
from openpyxl import workbook
|
||||
from openpyxl.styles import Font
|
||||
|
||||
from WriteReport import *
|
||||
from ClientSpecific import *
|
||||
|
||||
bold = Font(bold=True)
|
||||
|
||||
@@ -42,11 +41,8 @@ def Release_Ticket(ticket, URL, HOST):
|
||||
response = requests.post(url=URL, data=ReleaseTicket, headers=headers).text
|
||||
print("released ticket "+ticket)
|
||||
|
||||
def Westfield():
|
||||
print("Westfield")
|
||||
exit()
|
||||
|
||||
def Run_Report(ticket, URL, HOST, REPORT_FIELDS, wb, ws, ws2, DETAIL_REPORT_FIELDS, columnFormat, SSheader):
|
||||
def Run_Report(ticket, URL, HOST, REPORT_FIELDS, wb, ws, ws2, DETAIL_REPORT_FIELDS, summary_columnFormat, summary_SSheader, detail_columnFormat, detail_SSheader):
|
||||
|
||||
ExternalID = []
|
||||
id = []
|
||||
@@ -82,7 +78,8 @@ def Run_Report(ticket, URL, HOST, REPORT_FIELDS, wb, ws, ws2, DETAIL_REPORT_FIEL
|
||||
y = bs(report, "lxml")
|
||||
|
||||
# Opens report file and writes each row
|
||||
Write_Report(y, ws, columnFormat, SSheader)
|
||||
sheet = ws
|
||||
Write_Report(y, summary_columnFormat, summary_SSheader, sheet)
|
||||
|
||||
# Grabs all the Order IDs from Column A
|
||||
for cell in ws['A']:
|
||||
@@ -197,7 +194,8 @@ def Run_Report(ticket, URL, HOST, REPORT_FIELDS, wb, ws, ws2, DETAIL_REPORT_FIEL
|
||||
|
||||
|
||||
# Opens report file and writes each row
|
||||
Detail_Write_Report(y, ws)
|
||||
sheet = ws2
|
||||
Write_Report(y, detail_columnFormat, detail_SSheader, sheet)
|
||||
|
||||
# Finalize Spreadsheet and save
|
||||
|
||||
@@ -225,6 +223,7 @@ def loadMenu():
|
||||
detail_headers = []
|
||||
CLIENT_COLUMN_FORMAT = []
|
||||
COLUMN_FORMAT = []
|
||||
detail_columnformat = []
|
||||
|
||||
# Open the config file
|
||||
with open(ConfigFile) as f:
|
||||
@@ -292,12 +291,11 @@ def loadMenu():
|
||||
|
||||
option = int(input())
|
||||
|
||||
if ClientName[option] == "Westfield":
|
||||
Westfield()
|
||||
client_Specific_Tabs(ClientName[option])
|
||||
|
||||
columnformat = dict.fromkeys(headers[option])
|
||||
summary_columnformat = dict.fromkeys(headers[option])
|
||||
|
||||
# Get specific Column Types for chosen client
|
||||
# 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]:
|
||||
@@ -305,10 +303,27 @@ def loadMenu():
|
||||
for g in x.find_all('summarytab'):
|
||||
for z in g.find_all('columnformat'):
|
||||
CLIENT_COLUMN_FORMAT.append(z.text)
|
||||
# set Column Types Header Dictionary
|
||||
# set Summary Column Types Header Dictionary
|
||||
count = 0
|
||||
for key in columnformat:
|
||||
columnformat[key] = CLIENT_COLUMN_FORMAT[count]
|
||||
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
|
||||
@@ -322,10 +337,9 @@ def loadMenu():
|
||||
|
||||
# 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, columnformat, headers[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():
|
||||
@@ -337,12 +351,14 @@ def main():
|
||||
ws = URL_HOST[4]
|
||||
ws2 = URL_HOST[5]
|
||||
DETAIL_REPORT_FIELDS = URL_HOST[6]
|
||||
columnFormat = URL_HOST[7]
|
||||
summary_columnFormat = URL_HOST[7]
|
||||
|
||||
SSheader = URL_HOST[8]
|
||||
summary_SSheader = URL_HOST[8]
|
||||
detail_columnFormat = URL_HOST[9]
|
||||
detail_SSheader = URL_HOST[10]
|
||||
|
||||
ticket = Obtain_Ticket(URL, HOST)
|
||||
Run_Report(ticket, URL, HOST, REPORT_FIELDS, wb, ws, ws2, DETAIL_REPORT_FIELDS, columnFormat, SSheader)
|
||||
Run_Report(ticket, URL, HOST, REPORT_FIELDS, wb, ws, ws2, DETAIL_REPORT_FIELDS, summary_columnFormat, summary_SSheader, detail_columnFormat, detail_SSheader)
|
||||
Release_Ticket(ticket, URL, HOST)
|
||||
|
||||
main()
|
||||
Reference in New Issue
Block a user