Skip to content

Commit

Permalink
#83 HTML rendering and key --html were implemented for reports crea…
Browse files Browse the repository at this point in the history
…ted by `--limits` key
  • Loading branch information
Tim55667757 committed Nov 21, 2022
1 parent 65a9234 commit 76ec27b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tksbrokerapi/TKSBrokerAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -3907,7 +3907,7 @@ def OverviewLimits(self, show: bool = False) -> dict:
if show:
info = [
"# Withdrawal limits\n\n",
"* **Actual date:** [{} UTC]\n".format(datetime.now(tzutc()).strftime(TKS_PRINT_DATE_TIME_FORMAT)),
"* **Actual on date:** [{} UTC]\n".format(datetime.now(tzutc()).strftime(TKS_PRINT_DATE_TIME_FORMAT)),
"* **Account ID:** [{}]\n".format(self.accountId),
]

Expand Down Expand Up @@ -3949,6 +3949,14 @@ def OverviewLimits(self, show: bool = False) -> dict:

uLogger.info("Client's withdrawal limits was saved to file: [{}]".format(os.path.abspath(self.withdrawalLimitsFile)))

if self.useHTMLReports:
htmlFilePath = self.withdrawalLimitsFile.replace(".md", ".html") if self.withdrawalLimitsFile.endswith(".md") else self.withdrawalLimitsFile + ".html"
header = "Withdrawal limits, account ID: [{}]".format(self.accountId)
with open(htmlFilePath, "w", encoding="UTF-8") as fH:
fH.write(Template(text=MAIN_INFO_TEMPLATE).render(mainTitle=header, commonCSS=COMMON_CSS, markdown=infoText))

uLogger.info("The report has also been converted to an HTML file: [{}]".format(os.path.abspath(htmlFilePath)))

return view

def RequestAccounts(self) -> dict:
Expand Down

0 comments on commit 76ec27b

Please sign in to comment.