Skip to content
Snippets Groups Projects
Commit cd3c37e8 authored by Thomas Bock's avatar Thomas Bock :speech_balloon:
Browse files

clean up some fns

parent 94d9f65a
No related merge requests found
...@@ -82,7 +82,6 @@ def get_last_cert(cal_docs): ...@@ -82,7 +82,6 @@ def get_last_cert(cal_docs):
if last_cert and last_year: if last_cert and last_year:
return "{}\\,PTB\\,{}".format(last_cert, last_year[-2:]) return "{}\\,PTB\\,{}".format(last_cert, last_year[-2:])
def sort_by_pressure(cal_docs): def sort_by_pressure(cal_docs):
"""Sort caldocs by pressure in order to get the result tables """Sort caldocs by pressure in order to get the result tables
in the correct order""" in the correct order"""
...@@ -150,8 +149,8 @@ def get_measurement_data(cal_docs): ...@@ -150,8 +149,8 @@ def get_measurement_data(cal_docs):
gas = get_gas(doc) gas = get_gas(doc)
result_type = get_result_type(doc) result_type = get_result_type(doc)
res = doc.get("Calibration", {}).get("Result", {}) meas_data = doc.get("Calibration", {}).get("Result", {}).get("MeasurementData")
meas_data = res.get("MeasurementData")
if meas_data is None: if meas_data is None:
continue continue
if not gas in measurement_data: if not gas in measurement_data:
...@@ -166,11 +165,11 @@ def get_device(cal_docs): ...@@ -166,11 +165,11 @@ def get_device(cal_docs):
for i, doc in enumerate(cal_docs): for i, doc in enumerate(cal_docs):
pass pass
dev["Text"] = doc.get("Calibration", {}).get("CustomerObject", {}).get("Text", { empty_txt = {"shipping": "",
"shipping": "", "specials": "",}
"specials": ""
}) dev["Text"] = doc.get("Calibration", {}).get("CustomerObject", {}).get("Text", empty_txt)
dev_setup = doc.get("Calibration", {}).get("CustomerObject", {}).get("Setup",{}) dev_setup = doc.get("Calibration", {}).get("CustomerObject", {}).get("Setup", {})
dev["Setup"] = safe_device_setup(dev_setup) dev["Setup"] = safe_device_setup(dev_setup)
dev["DeviceClass"] = doc.get("Calibration", {}).get("CustomerObject", {}).get("Class","") dev["DeviceClass"] = doc.get("Calibration", {}).get("CustomerObject", {}).get("Class","")
...@@ -198,8 +197,8 @@ def get_titlepage(cal_docs, countries, maintainers): ...@@ -198,8 +197,8 @@ def get_titlepage(cal_docs, countries, maintainers):
title = { title = {
"ShortYear":get_current_year(short=True), "ShortYear":get_current_year(short=True),
"FullYear": get_current_year(), "FullYear": get_current_year(),
"CertificateDate": get_current_date(), "CertificateDate": get_current_date(),}
}
fs_val = 0.0 fs_val = 0.0
fs_unit = "Pa" fs_unit = "Pa"
...@@ -503,24 +502,20 @@ def dcc_analysis_software(cal_docs): ...@@ -503,24 +502,20 @@ def dcc_analysis_software(cal_docs):
doc = cal_docs[-1] doc = cal_docs[-1]
name, release = get_analysis_software(doc) name, release = get_analysis_software(doc)
if name: if name:
return {"name":[{"lang":"en", return {"name": [{"lang":"en", "content": [name]}],
"content": [name]}], "release": release}
"release":release}
def dcc_result_software(cal_docs): def dcc_result_software(cal_docs):
doc = cal_docs[-1] doc = cal_docs[-1]
name, release = get_result_software(doc) name, release = get_result_software(doc)
if name: if name:
return {"name":[{"lang":"en", return {"name":[{"lang":"en", "content": [name]}],
"content": [name]}], "release": release}
"release":release}
def dcc_cal_software(cal_docs): def dcc_cal_software(cal_docs):
doc = cal_docs[-1] doc = cal_docs[-1]
return {"name":[{"lang": "en", "content": ["cal (generation of json-dcc)"]}],
return {"name":[{"lang":"en", "release": git_cmd(get_config_dict()).describe()}
"content":["cal (generation of json-dcc)"]}],
"release":git_cmd(get_config_dict()).describe()}
def dcc_customer(cal_docs, countries): def dcc_customer(cal_docs, countries):
doc = cal_docs[-1] doc = cal_docs[-1]
...@@ -529,15 +524,13 @@ def dcc_customer(cal_docs, countries): ...@@ -529,15 +524,13 @@ def dcc_customer(cal_docs, countries):
contact = customer.get("Contact", {}) contact = customer.get("Contact", {})
lang = get_lang(doc) lang = get_lang(doc)
return {"name":[{"lang": lang,
"content": [customer.get("Name")]}], return {"name":[{"lang": lang, "content": [customer.get("Name")]}],
"eMail":contact.get("Email"), "eMail": contact.get("Email"),
"location":{ "location":{"street": adr.get("Street"),
"street":adr.get("Street"), "postCode": adr.get("Zipcode"),
#"streetNo": "", "city": adr.get("Town"),
"postCode": adr.get("Zipcode"), "countryCode": adr.get("Land").upper()}}
"city":adr.get("Town"),
"countryCode":adr.get("Land").upper()}}
def dcc_calibration_object_description(cal_docs, secs): def dcc_calibration_object_description(cal_docs, secs):
doc = cal_docs[-1] doc = cal_docs[-1]
...@@ -545,8 +538,8 @@ def dcc_calibration_object_description(cal_docs, secs): ...@@ -545,8 +538,8 @@ def dcc_calibration_object_description(cal_docs, secs):
item_descr = [] item_descr = []
for i, m in enumerate(secs): for i, m in enumerate(secs):
if m.get("DccAssigment", "none") == "item": if m.get("DccAssigment", "none") == "item":
item_descr.append({"lang":lang, item_descr.append({"lang":lang, "content":dcc_strip_content(m.get("Paragraph"))})
"content":dcc_strip_content(m.get("Paragraph"))})
return item_descr return item_descr
def meas_date_begin_end(cal_docs): def meas_date_begin_end(cal_docs):
...@@ -572,7 +565,7 @@ def format_fs_value(v): ...@@ -572,7 +565,7 @@ def format_fs_value(v):
return "{:.1e}".format(v) return "{:.1e}".format(v)
def should_skipped(doc): def should_skipped(doc):
return doc.get("Calibration", {}).get("Result",{}).get("Skip", False) return doc.get("Calibration", {}).get("Result", {}).get("Skip", False)
def get_analysis_software(doc): def get_analysis_software(doc):
aux = doc.get("Calibration", {}).get("Analysis").get("AuxValues") aux = doc.get("Calibration", {}).get("Analysis").get("AuxValues")
...@@ -624,25 +617,20 @@ def get_customer(doc, countries): ...@@ -624,25 +617,20 @@ def get_customer(doc, countries):
short_land = adr.get("Land") short_land = adr.get("Land")
lang = get_lang(doc) lang = get_lang(doc)
cust = { return {"Name": escape_items(customer.get("Name")),
"Name": escape_items(customer.get("Name")), "AddName": escape_items(customer.get("AddName")),
"AddName": escape_items(customer.get("AddName")), "Street": adr.get("Street"),
"Street": adr.get("Street"), "Town": adr.get("Town"),
"Town": adr.get("Town"), "Zipcode": adr.get("Zipcode"),
"Zipcode": adr.get("Zipcode"), "Land": countries.get(short_land, {}).get(lang, {}).get("short", short_land),
"Land": countries.get(short_land, {}).get(lang, {}).get("short", short_land), "CountryCode": short_land.upper(),
"CountryCode": short_land.upper(), "ContactName": contact.get("Name"),
"ContactName": contact.get("Name"), "ContactPhone": contact.get("Phone"),
"ContactPhone": contact.get("Phone"), "Email": contact.get("Email"),}
"Email": contact.get("Email"),
}
return cust
def get_reference_no(doc): def get_reference_no(doc):
ref_no = doc.get("Calibration",{}).get("Presettings",{}).get("ReferenceNo", "-")
# "[[?|{ref_no}|7.5-1.6-YY-Anz.IG-Anz.Ges.]]".format(ref_no=ref_no) # "[[?|{ref_no}|7.5-1.6-YY-Anz.IG-Anz.Ges.]]".format(ref_no=ref_no)
return ref_no return doc.get("Calibration",{}).get("Presettings",{}).get("ReferenceNo", "-")
def get_certificate(doc): def get_certificate(doc):
return doc.get("Calibration",{}).get("Certificate") return doc.get("Calibration",{}).get("Certificate")
...@@ -658,8 +646,6 @@ def make_meas_date_title(begin_date, end_date, lang): ...@@ -658,8 +646,6 @@ def make_meas_date_title(begin_date, end_date, lang):
return m_str.format(d_from=begin_date, d_to = end_date) return m_str.format(d_from=begin_date, d_to = end_date)
def get_std(doc): def get_std(doc):
""" """
.. code:: .. code::
...@@ -734,4 +720,4 @@ def get_current_year(short=False): ...@@ -734,4 +720,4 @@ def get_current_year(short=False):
return y return y
def get_current_date(short=False): def get_current_date(short=False):
return "{}".format(datetime.datetime.today().date()) return "{}".format(datetime.datetime.today().date())
...@@ -27,7 +27,6 @@ konstante Gastemperatur von $T_1=$ ...@@ -27,7 +27,6 @@ konstante Gastemperatur von $T_1=$
((*-for result_type, measurement_data in MeasurementData[gas].items()*)) ((*-for result_type, measurement_data in MeasurementData[gas].items()*))
((*if gas == "N2"*)) ((*if gas == "N2"*))
((*if measurement_data.TemperatureCorrection == "yes"*)) ((*if measurement_data.TemperatureCorrection == "yes"*))
(((measurement_data.NormTemperature))). (((measurement_data.NormTemperature))).
((*endif*)) ((*endif*))
((*endif*)) ((*endif*))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment