Moved report to import.
This commit is contained in:
parent
ae240dd76c
commit
20d7a8fdc7
62
MosReport.py
Normal file
62
MosReport.py
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
def get_report(items):
|
||||||
|
"""Returns plaintext and csv data for given items.
|
||||||
|
*items* is the result of MosDb.get_daily_oa()
|
||||||
|
"""
|
||||||
|
longest_name = 9
|
||||||
|
longest_author = 5
|
||||||
|
for i in items:
|
||||||
|
if len(i["name"]) > longest_name:
|
||||||
|
longest_name = len(i["name"])
|
||||||
|
if len(i["createdBy"]) > longest_author:
|
||||||
|
longest_author = len(i["createdBy"])
|
||||||
|
|
||||||
|
# Output table
|
||||||
|
output_text = ("{:19} | {:" + str(longest_name) + "} | {:" + str(longest_author) + "} | {:>5} | {:>5} | {:>5}\n").format(
|
||||||
|
"Datum",
|
||||||
|
"OnAir-MAZ",
|
||||||
|
"Autor",
|
||||||
|
"LUFS",
|
||||||
|
"LRA",
|
||||||
|
"LDIFF"
|
||||||
|
)
|
||||||
|
output_text += ("{:-<19} | {:-<" + str(longest_name) + "} | {:-<" + str(longest_author) + "} | {:->5} | {:->5} | {:->5}\n").format("", "", "", "", "", "")
|
||||||
|
# Output CSV, use BOM because Excel is ignorant
|
||||||
|
output_csv = "\ufeff"
|
||||||
|
output_csv += "objId,planningId,created,name,createdBy,lufs,lra,ludiff\n"
|
||||||
|
for i in items:
|
||||||
|
lu = i["lu"]
|
||||||
|
if lu is None:
|
||||||
|
lu = "n/a"
|
||||||
|
lra = "-"
|
||||||
|
ldiff = "-"
|
||||||
|
elif lu == -99.0:
|
||||||
|
lu = "-∞"
|
||||||
|
lra = "-"
|
||||||
|
ldiff = "-"
|
||||||
|
else:
|
||||||
|
lu = "{:>5.1f}".format(lu)
|
||||||
|
lra = "{:>5.1f}".format(i["lra"])
|
||||||
|
ldiff = "{:>5.1f}".format(i["ldiff"])
|
||||||
|
|
||||||
|
output_text += ("{} | {:" + str(longest_name) + "} | {:" + str(longest_author) + "} | {:>5} | {:>5} | {:>5}\n").format(
|
||||||
|
i["created"],
|
||||||
|
i["name"],
|
||||||
|
i["createdBy"],
|
||||||
|
lu,
|
||||||
|
lra,
|
||||||
|
ldiff
|
||||||
|
)
|
||||||
|
output_csv += ("{},{},{},\"{}\",\"{}\",{},{},{}").format(
|
||||||
|
i["objId"],
|
||||||
|
i["planningId"],
|
||||||
|
i["created"],
|
||||||
|
i["name"],
|
||||||
|
i["createdBy"],
|
||||||
|
i["lu"],
|
||||||
|
i["lra"],
|
||||||
|
i["ldiff"]
|
||||||
|
) + "\n"
|
||||||
|
return (output_text, output_csv)
|
||||||
|
|
@ -4,6 +4,7 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import MosDb
|
import MosDb
|
||||||
|
import MosReport
|
||||||
|
|
||||||
db = MosDb.MosDb()
|
db = MosDb.MosDb()
|
||||||
|
|
||||||
@ -11,60 +12,7 @@ items = db.get_daily_oa()
|
|||||||
#items = db.get_daily_oa("-1 day")
|
#items = db.get_daily_oa("-1 day")
|
||||||
db.finish()
|
db.finish()
|
||||||
|
|
||||||
longest_name = 9
|
(output_text, output_csv) = MosReport.get_report(items)
|
||||||
longest_author = 5
|
|
||||||
for i in items:
|
|
||||||
if len(i["name"]) > longest_name:
|
|
||||||
longest_name = len(i["name"])
|
|
||||||
if len(i["createdBy"]) > longest_author:
|
|
||||||
longest_author = len(i["createdBy"])
|
|
||||||
|
|
||||||
# Output table
|
|
||||||
output_text = ("{:19} | {:" + str(longest_name) + "} | {:" + str(longest_author) + "} | {:>5} | {:>5} | {:>5}\n").format(
|
|
||||||
"Datum",
|
|
||||||
"OnAir-MAZ",
|
|
||||||
"Autor",
|
|
||||||
"LUFS",
|
|
||||||
"LRA",
|
|
||||||
"LDIFF"
|
|
||||||
)
|
|
||||||
output_text += ("{:-<19} | {:-<" + str(longest_name) + "} | {:-<" + str(longest_author) + "} | {:->5} | {:->5} | {:->5}\n").format("", "", "", "", "", "")
|
|
||||||
# Output CSV, use BOM because Excel is ignorant
|
|
||||||
output_csv = "\ufeff"
|
|
||||||
output_csv += "objId,planningId,created,name,createdBy,lufs,lra,ludiff\n"
|
|
||||||
for i in items:
|
|
||||||
lu = i["lu"]
|
|
||||||
if lu is None:
|
|
||||||
lu = "n/a"
|
|
||||||
lra = "-"
|
|
||||||
ldiff = "-"
|
|
||||||
elif lu == -99.0:
|
|
||||||
lu = "-∞"
|
|
||||||
lra = "-"
|
|
||||||
ldiff = "-"
|
|
||||||
else:
|
|
||||||
lu = "{:>5.1f}".format(lu)
|
|
||||||
lra = "{:>5.1f}".format(i["lra"])
|
|
||||||
ldiff = "{:>5.1f}".format(i["ldiff"])
|
|
||||||
|
|
||||||
output_text += ("{} | {:" + str(longest_name) + "} | {:" + str(longest_author) + "} | {:>5} | {:>5} | {:>5}\n").format(
|
|
||||||
i["created"],
|
|
||||||
i["name"],
|
|
||||||
i["createdBy"],
|
|
||||||
lu,
|
|
||||||
lra,
|
|
||||||
ldiff
|
|
||||||
)
|
|
||||||
output_csv += ("{},{},{},\"{}\",\"{}\",{},{},{}").format(
|
|
||||||
i["objId"],
|
|
||||||
i["planningId"],
|
|
||||||
i["created"],
|
|
||||||
i["name"],
|
|
||||||
i["createdBy"],
|
|
||||||
i["lu"],
|
|
||||||
i["lra"],
|
|
||||||
i["ldiff"]
|
|
||||||
) + "\n"
|
|
||||||
|
|
||||||
print(output_text)
|
print(output_text)
|
||||||
print(output_csv)
|
print(output_csv)
|
||||||
|
18
show_yesterday.py
Executable file
18
show_yesterday.py
Executable file
@ -0,0 +1,18 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import MosDb
|
||||||
|
import MosReport
|
||||||
|
|
||||||
|
db = MosDb.MosDb()
|
||||||
|
|
||||||
|
#items = db.get_daily_oa()
|
||||||
|
items = db.get_daily_oa("-1 day")
|
||||||
|
db.finish()
|
||||||
|
|
||||||
|
(output_text, output_csv) = MosReport.get_report(items)
|
||||||
|
|
||||||
|
print(output_text)
|
||||||
|
print(output_csv)
|
Loading…
x
Reference in New Issue
Block a user