Attempt adding file name to output
This commit is contained in:
parent
bcac814800
commit
259c5bc9b7
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,6 +2,7 @@ env_conf
|
|||||||
include
|
include
|
||||||
*.docx
|
*.docx
|
||||||
git
|
git
|
||||||
|
run.sh
|
||||||
|
|
||||||
# ---> Python
|
# ---> Python
|
||||||
# Byte-compiled / optimized / DLL files
|
# Byte-compiled / optimized / DLL files
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
# Load configuration from file/env variables
|
# Load configuration from file/env variables
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
def load():
|
def load():
|
||||||
|
cfg = {}
|
||||||
toLoad = [
|
toLoad = [
|
||||||
{
|
{
|
||||||
"envname": "DG_IMAP_HOST",
|
"envname": "DG_IMAP_HOST",
|
||||||
@ -36,3 +39,25 @@ def load():
|
|||||||
"filepath": "/owlboard/dgp/gitea/sshport"
|
"filepath": "/owlboard/dgp/gitea/sshport"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
for item in toLoad:
|
||||||
|
filepath = item["filepath"]
|
||||||
|
envname = item["envname"]
|
||||||
|
default = item.get("default")
|
||||||
|
|
||||||
|
# Try to load value from file
|
||||||
|
try:
|
||||||
|
with open(filepath, "r") as file:
|
||||||
|
value = file.read().strip()
|
||||||
|
except FileNotFoundError:
|
||||||
|
# If file doesn't exist, try to get value from environment variable
|
||||||
|
value = os.environ.get(envname)
|
||||||
|
|
||||||
|
# If value is still not found, use the default if provided
|
||||||
|
if value is None and default is not None:
|
||||||
|
value = default
|
||||||
|
|
||||||
|
# Add the value to the cfg dictionary
|
||||||
|
cfg[envname] = value
|
||||||
|
|
||||||
|
return cfg
|
||||||
|
@ -12,12 +12,16 @@ def humanYaml(pis_list):
|
|||||||
for stop in pis['services'][0]['stops']:
|
for stop in pis['services'][0]['stops']:
|
||||||
crs.append(owlboard_connector.convert_tiploc_to_crs(stop))
|
crs.append(owlboard_connector.convert_tiploc_to_crs(stop))
|
||||||
additional_pis += f' - code: "{pis["pis"]}"\n'
|
additional_pis += f' - code: "{pis["pis"]}"\n'
|
||||||
|
additional_pis += f' #headcode: {pis["headcode"]}\n'
|
||||||
|
additional_pis += f' #date: {pis["date"]}\n'
|
||||||
additional_pis += f' stops: [{",".join(crs)}]\n'
|
additional_pis += f' stops: [{",".join(crs)}]\n'
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
print(err)
|
print(err)
|
||||||
elif len(pis['services']) > 1:
|
elif len(pis['services']) > 1:
|
||||||
manual_review += f'## THIS CODE REQUIRES MANUAL VERIFICATION\n'
|
manual_review += f'## THIS CODE REQUIRES MANUAL VERIFICATION\n'
|
||||||
manual_review += f' - code: "{pis["pis"]}"\n'
|
manual_review += f' - code: "{pis["pis"]}"\n'
|
||||||
|
manual_review += f' #headcode: {pis["headcode"]}\n'
|
||||||
|
manual_review += f' #date: {pis["date"]}\n'
|
||||||
for service in pis["services"]:
|
for service in pis["services"]:
|
||||||
crs = []
|
crs = []
|
||||||
if service and service['stops']:
|
if service and service['stops']:
|
||||||
@ -25,4 +29,4 @@ def humanYaml(pis_list):
|
|||||||
crs.append(owlboard_connector.convert_tiploc_to_crs(stop))
|
crs.append(owlboard_connector.convert_tiploc_to_crs(stop))
|
||||||
manual_review += f' stops: [{",".join(crs)}]\n'
|
manual_review += f' stops: [{",".join(crs)}]\n'
|
||||||
|
|
||||||
return additional_pis + manual_review
|
return "FOR REVIEW\n" + additional_pis + manual_review
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import parse_docx, pis_find, owlboard_connector, formatter, gitea_connector
|
import parse_docx, pis_find, owlboard_connector, formatter, gitea_connector
|
||||||
|
|
||||||
import os, sys
|
import os, sys
|
||||||
|
|
||||||
def start():
|
def start():
|
||||||
@ -37,13 +36,17 @@ def start():
|
|||||||
get_detail.append({
|
get_detail.append({
|
||||||
'pis': code['pis'],
|
'pis': code['pis'],
|
||||||
'services': services,
|
'services': services,
|
||||||
'date': code['date']
|
'diagram_file': code['file'],
|
||||||
|
'date': code['date'],
|
||||||
|
'headcode': code['headcode'],
|
||||||
})
|
})
|
||||||
|
|
||||||
details = []
|
details = []
|
||||||
for item in get_detail:
|
for item in get_detail:
|
||||||
detail = {
|
detail = {
|
||||||
'pis': item['pis'],
|
'pis': item['pis'],
|
||||||
|
'headcode': item['headcode'],
|
||||||
|
'date': item['date'],
|
||||||
'services': [],
|
'services': [],
|
||||||
}
|
}
|
||||||
for service in item['services']:
|
for service in item['services']:
|
||||||
@ -65,4 +68,4 @@ def start():
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
start()
|
print("To use local mode, please call `main.py local`")
|
Reference in New Issue
Block a user