Initial commit - Selenium automation framework
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def get_enabled_bidding_entries(config):
|
||||
|
||||
bidding_config = config["exchange_bidding"]
|
||||
input_root = Path(bidding_config["input_root"])
|
||||
json_input_root = Path(bidding_config.get("json_input_root", ""))
|
||||
upload_input_root = Path(bidding_config.get("upload_input_root", ""))
|
||||
excel_layout = bidding_config.get("excel_layout", {})
|
||||
entries = bidding_config.get("entries", [])
|
||||
|
||||
resolved_entries = []
|
||||
for entry in entries:
|
||||
if not entry.get("enabled", True):
|
||||
continue
|
||||
|
||||
resolved_entries.append(
|
||||
_resolve_entry_paths(
|
||||
**entry,
|
||||
input_root=input_root,
|
||||
json_input_root=json_input_root,
|
||||
upload_input_root=upload_input_root,
|
||||
excel_layout=excel_layout
|
||||
)
|
||||
)
|
||||
|
||||
return resolved_entries
|
||||
|
||||
|
||||
def get_active_bidding_entry(config):
|
||||
|
||||
bidding_config = config["exchange_bidding"]
|
||||
active_entry_key = bidding_config.get("active_entry_key")
|
||||
|
||||
for entry in get_enabled_bidding_entries(config):
|
||||
if entry["key"] == active_entry_key:
|
||||
return entry
|
||||
|
||||
raise KeyError(
|
||||
f"Active bidding entry '{active_entry_key}' was not found among enabled entries."
|
||||
)
|
||||
|
||||
|
||||
def _resolve_entry_paths(**kwargs):
|
||||
|
||||
entry = dict(kwargs)
|
||||
input_root = entry.pop("input_root")
|
||||
json_input_root = entry.pop("json_input_root")
|
||||
upload_input_root = entry.pop("upload_input_root")
|
||||
excel_layout = entry.pop("excel_layout")
|
||||
|
||||
excel_path = (input_root / entry["excel_file"]).resolve()
|
||||
|
||||
json_path = None
|
||||
if entry.get("json_file"):
|
||||
json_path = (json_input_root / entry["json_file"]).resolve()
|
||||
|
||||
upload_path = None
|
||||
upload_file_name = entry.get("upload_file") or entry.get("excel_file")
|
||||
if upload_file_name:
|
||||
preferred_upload_path = (upload_input_root / upload_file_name).resolve()
|
||||
upload_path = preferred_upload_path if preferred_upload_path.exists() else excel_path
|
||||
|
||||
return {
|
||||
**entry,
|
||||
"excel_path": str(excel_path),
|
||||
"json_path": str(json_path) if json_path else None,
|
||||
"upload_path": str(upload_path) if upload_path else None,
|
||||
"excel_layout": {
|
||||
**excel_layout,
|
||||
**entry.get("excel_layout", {})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user