From 74b296f07a76d6c1f01c5fcfe295cd97e1f43150 Mon Sep 17 00:00:00 2001 From: luna-cant-code <223513004+luna-cant-code@users.noreply.github.com> Date: Wed, 3 Dec 2025 18:35:07 +0100 Subject: [PATCH 01/11] created VBN and Swiss feed files --- scripts/ch-opentransport-colors.lua | 0 scripts/de-VBN-colors.lua | 205 ++++++++++++++++++++++++++++ src/generate_colors_CH.py | 171 +++++++++++++++++++++++ src/generate_colors_VBN.py | 171 +++++++++++++++++++++++ 4 files changed, 547 insertions(+) create mode 100644 scripts/ch-opentransport-colors.lua create mode 100644 scripts/de-VBN-colors.lua create mode 100644 src/generate_colors_CH.py create mode 100644 src/generate_colors_VBN.py diff --git a/scripts/ch-opentransport-colors.lua b/scripts/ch-opentransport-colors.lua new file mode 100644 index 000000000..e69de29bb diff --git a/scripts/de-VBN-colors.lua b/scripts/de-VBN-colors.lua new file mode 100644 index 000000000..66e3f751d --- /dev/null +++ b/scripts/de-VBN-colors.lua @@ -0,0 +1,205 @@ +-- autogenerated by generate_colors.py +-- SPDX-FileCopyrightText: contributors of https://github.com/Traewelling/line-colors +-- SPDX-License-Identifier: CC0-1.0 + +local colors = { + ["Braunschweiger Verkehrs-GmbH"] = { + ["1"] = { color = 0xe2000a, text_color = 0xffffff }, + ["10"] = { color = 0xe2000a, text_color = 0xffffff }, + ["1E"] = { color = 0xe2000a, text_color = 0xffffff }, + ["2"] = { color = 0x93c019, text_color = 0xffffff }, + ["2E"] = { color = 0x93c019, text_color = 0xffffff }, + ["3"] = { color = 0x006430, text_color = 0xffffff }, + ["3E"] = { color = 0x006430, text_color = 0xffffff }, + ["4"] = { color = 0x009ee2, text_color = 0xffffff }, + ["411"] = { color = 0xb1a85c, text_color = 0xffffff }, + ["412"] = { color = 0x009ee2, text_color = 0xffffff }, + ["413"] = { color = 0x00953e, text_color = 0xffffff }, + ["414"] = { color = 0x5ac5f1, text_color = 0xffffff }, + ["416"] = { color = 0xf39100, text_color = 0xffffff }, + ["417"] = { color = 0x9b9c9c, text_color = 0xffffff }, + ["418"] = { color = 0xd35c9e, text_color = 0xffffff }, + ["419"] = { color = 0x0068b3, text_color = 0xffffff }, + ["420"] = { color = 0x6e6e6d, text_color = 0xffffff }, + ["421"] = { color = 0xc14d96, text_color = 0xffffff }, + ["422"] = { color = 0x9b0600, text_color = 0xffffff }, + ["423"] = { color = 0x9b0600, text_color = 0xffffff }, + ["424"] = { color = 0xe0b500, text_color = 0xffffff }, + ["426"] = { color = 0x804796, text_color = 0xffffff }, + ["427"] = { color = 0x70ba6e, text_color = 0xffffff }, + ["430"] = { color = 0x6e6e6d, text_color = 0xffffff }, + ["431"] = { color = 0xebc56b, text_color = 0xffffff }, + ["433"] = { color = 0xec6da6, text_color = 0xffffff }, + ["434"] = { color = 0xa20600, text_color = 0xffffff }, + ["435"] = { color = 0xe2000a, text_color = 0xffffff }, + ["436"] = { color = 0x0f3f93, text_color = 0xffffff }, + ["437"] = { color = 0x9b9c9c, text_color = 0xffffff }, + ["445"] = { color = 0x8bbd1d, text_color = 0xffffff }, + ["450"] = { color = 0x6e6e6d, text_color = 0xffffff }, + ["454"] = { color = 0xffd000, text_color = 0xffffff }, + ["455"] = { color = 0x9b9c9c, text_color = 0xffffff }, + ["464"] = { color = 0x9b9c9c, text_color = 0xffffff }, + ["465"] = { color = 0xe94d33, text_color = 0xffffff }, + ["466"] = { color = 0xe94d33, text_color = 0xffffff }, + ["471"] = { color = 0x23318a, text_color = 0xffffff }, + ["480"] = { color = 0x6e6e6d, text_color = 0xffffff }, + ["481"] = { color = 0x9b9c9c, text_color = 0xffffff }, + ["482"] = { color = 0x8bbd1d, text_color = 0xffffff }, + ["4E"] = { color = 0x009ee2, text_color = 0xffffff }, + ["5"] = { color = 0xf39100, text_color = 0xffffff }, + ["5E"] = { color = 0xf39100, text_color = 0xffffff }, + }, + ["HarzBus GbR"] = { + ["650"] = { color = 0x9f5292, text_color = 0xffffff }, + ["655"] = { color = 0x42aa61, text_color = 0xffffff }, + ["810"] = { color = 0xca1413, text_color = 0xffffff }, + ["821"] = { color = 0x846fac, text_color = 0xffffff }, + ["822"] = { color = 0xed760b, text_color = 0xffffff }, + ["830"] = { color = 0x9a246c, text_color = 0xffffff }, + ["831"] = { color = 0x009eb5, text_color = 0xffffff }, + ["832"] = { color = 0x663904, text_color = 0xffffff }, + ["833"] = { color = 0x005ca1, text_color = 0xffffff }, + ["834"] = { color = 0x005ca1, text_color = 0xffffff }, + ["836"] = { color = 0x78348a, text_color = 0xffffff }, + ["840"] = { color = 0x005a9f, text_color = 0xffffff }, + ["841"] = { color = 0x007e3b, text_color = 0xffffff }, + ["850"] = { color = 0x9271ae, text_color = 0xffffff }, + ["851"] = { color = 0x895079, text_color = 0xffffff }, + ["852"] = { color = 0x975500, text_color = 0xffffff }, + ["860"] = { color = 0x007e3b, text_color = 0xffffff }, + ["861"] = { color = 0x975500, text_color = 0xffffff }, + }, + ["Kraftverkehrsgesellschaft mbH Braunschweig"] = { + ["360"] = { color = 0xffffff, text_color = 0xb5579a }, + ["370"] = { color = 0xffffff, text_color = 0xe61381 }, + ["371"] = { color = 0xffffff, text_color = 0xfadd04 }, + ["372"] = { color = 0xffffff, text_color = 0xc8c8cc }, + ["380"] = { color = 0xffffff, text_color = 0xfadd04 }, + ["381"] = { color = 0xffffff, text_color = 0xb9cd29 }, + ["382"] = { color = 0xffffff, text_color = 0x9b2425 }, + ["383"] = { color = 0xffffff, text_color = 0x00a0e1 }, + ["384"] = { color = 0xffffff, text_color = 0x008640 }, + ["385"] = { color = 0xffffff, text_color = 0xbe7e20 }, + ["386"] = { color = 0xffffff, text_color = 0xbdddd0 }, + ["387"] = { color = 0xffffff, text_color = 0xe61381 }, + ["388"] = { color = 0xffffff, text_color = 0xfadd04 }, + ["390"] = { color = 0xffffff, text_color = 0xf1a1bc }, + ["391"] = { color = 0xffffff, text_color = 0xe11d25 }, + ["392"] = { color = 0xffffff, text_color = 0x0854a1 }, + ["393"] = { color = 0xffffff, text_color = 0xe11d25 }, + ["394"] = { color = 0xffffff, text_color = 0xf4981b }, + ["395"] = { color = 0xffffff, text_color = 0xb5579a }, + ["396"] = { color = 0xffffff, text_color = 0x3c3386 }, + ["397"] = { color = 0xffffff, text_color = 0xb9cd29 }, + ["398"] = { color = 0xffffff, text_color = 0x008640 }, + ["399"] = { color = 0xffffff, text_color = 0x008640 }, + ["601"] = { color = 0xffffff, text_color = 0xec1f25 }, + ["602"] = { color = 0xffffff, text_color = 0xec1f25 }, + ["603"] = { color = 0xffffff, text_color = 0x00adef }, + ["604"] = { color = 0xffffff, text_color = 0x6ab145 }, + ["606"] = { color = 0xffffff, text_color = 0xf48221 }, + ["607"] = { color = 0xffffff, text_color = 0xa868ab }, + ["608"] = { color = 0xffffff, text_color = 0xea028c }, + ["609"] = { color = 0xffffff, text_color = 0xea028c }, + ["610"] = { color = 0xffffff, text_color = 0xf48221 }, + ["611"] = { color = 0xffffff, text_color = 0x2c3192 }, + ["612"] = { color = 0xffffff, text_color = 0xf5d90e }, + ["613"] = { color = 0xffffff, text_color = 0xb66f35 }, + ["614"] = { color = 0xffffff, text_color = 0xb1345b }, + ["615"] = { color = 0xffffff, text_color = 0x007236 }, + ["616"] = { color = 0xffffff, text_color = 0xf499a4 }, + ["618"] = { color = 0xffffff, text_color = 0x01b9be }, + ["619"] = { color = 0xffffff, text_color = 0x772b90 }, + ["620"] = { color = 0xffffff, text_color = 0x006cb8 }, + ["621"] = { color = 0xffffff, text_color = 0x7e8285 }, + ["626"] = { color = 0xffffff, text_color = 0x7e8285 }, + ["627"] = { color = 0xffffff, text_color = 0x7e8285 }, + ["628"] = { color = 0xffffff, text_color = 0x7e8285 }, + ["630"] = { color = 0xffffff, text_color = 0x00a551 }, + ["640"] = { color = 0xffffff, text_color = 0x009183 }, + ["710"] = { color = 0xffffff, text_color = 0xf6d68f }, + ["740"] = { color = 0xffffff, text_color = 0xf59031 }, + ["750"] = { color = 0xffffff, text_color = 0xfab15d }, + ["790"] = { color = 0xffffff, text_color = 0xfbc335 }, + ["791"] = { color = 0xffffff, text_color = 0xb1d23d }, + ["792"] = { color = 0xffffff, text_color = 0x6cbf5b }, + ["793"] = { color = 0xffffff, text_color = 0x00b3bd }, + ["794"] = { color = 0xffffff, text_color = 0x2993d1 }, + ["795"] = { color = 0xffffff, text_color = 0x50b7e8 }, + ["796"] = { color = 0xffffff, text_color = 0x146b8b }, + ["797"] = { color = 0xffffff, text_color = 0x778ec8 }, + ["799"] = { color = 0xffffff, text_color = 0x72ccd4 }, + ["820"] = { color = 0xffffff, text_color = 0x00a551 }, + ["871"] = { color = 0xffffff, text_color = 0x00adef }, + ["873"] = { color = 0xffffff, text_color = 0xf9a61b }, + ["874"] = { color = 0xffffff, text_color = 0xeb106e }, + ["875"] = { color = 0xffffff, text_color = 0x9d005e }, + ["879"] = { color = 0xffffff, text_color = 0xec1f25 }, + }, + ["Stadtbus Goslar GmbH"] = { + ["801"] = { color = 0xfc9400, text_color = 0xffffff }, + ["802"] = { color = 0xac2f8a, text_color = 0xffffff }, + ["803"] = { color = 0x0aa2e3, text_color = 0xffffff }, + ["804"] = { color = 0x292174, text_color = 0xffffff }, + ["805"] = { color = 0x735c30, text_color = 0xffffff }, + ["806"] = { color = 0x0a6031, text_color = 0xffffff }, + }, + ["Verkehrsbetriebe Bachstein"] = { + ["151"] = { color = 0x009de2, text_color = 0xffffff }, + ["153"] = { color = 0xe20715, text_color = 0xffffff }, + ["160"] = { color = 0x009340, text_color = 0xffffff }, + ["161"] = { color = 0x312681, text_color = 0xffffff }, + ["162"] = { color = 0xf09100, text_color = 0xffffff }, + ["163"] = { color = 0xe5007c, text_color = 0xffffff }, + ["165"] = { color = 0xdfdb00, text_color = 0xffffff }, + ["335"] = { color = 0x94be1f, text_color = 0xffffff }, + ["650"] = { color = 0xa05292, text_color = 0xffffff }, + ["656"] = { color = 0x28225c, text_color = 0xffffff }, + ["658"] = { color = 0xe5213d, text_color = 0xffffff }, + ["660"] = { color = 0xf39200, text_color = 0xffffff }, + ["750"] = { color = 0xe2000e, text_color = 0xffffff }, + ["751"] = { color = 0x2e2482, text_color = 0xffffff }, + ["752"] = { color = 0x00953f, text_color = 0xffffff }, + ["753"] = { color = 0x35a9e0, text_color = 0xffffff }, + ["754"] = { color = 0xf39100, text_color = 0xffffff }, + ["755"] = { color = 0xdddb00, text_color = 0xffffff }, + ["756"] = { color = 0xe5007c, text_color = 0xffffff }, + ["757"] = { color = 0x82348b, text_color = 0xffffff }, + }, + ["Verkehrsgesellschaft Landkreis Gifhorn mbH"] = { + ["100"] = { color = 0xe7372a, text_color = 0x191919 }, + ["101"] = { color = 0x91009b, text_color = 0x191919 }, + ["102"] = { color = 0x955e42, text_color = 0x191919 }, + ["103"] = { color = 0xffacf2, text_color = 0x191919 }, + ["105"] = { color = 0xff9518, text_color = 0x191919 }, + ["108"] = { color = 0xf0ea2c, text_color = 0x191919 }, + ["111"] = { color = 0x5fdaef, text_color = 0x191919 }, + ["140"] = { color = 0x66d8c7, text_color = 0x191919 }, + ["141"] = { color = 0x65ff8c, text_color = 0x191919 }, + ["164"] = { color = 0xb3d04b, text_color = 0x191919 }, + ["170"] = { color = 0x90d6ab, text_color = 0x191919 }, + ["175"] = { color = 0xab91f8, text_color = 0x191919 }, + ["191"] = { color = 0x379e90, text_color = 0x191919 }, + }, + ["Wolfsburger Verkehrs-GmbH"] = { + ["201"] = { color = 0xe44b48, text_color = 0xffffff }, + ["202"] = { color = 0x2cbca9, text_color = 0xffffff }, + ["203"] = { color = 0x6558a6, text_color = 0xffffff }, + ["204"] = { color = 0xe7b011, text_color = 0xffffff }, + ["211"] = { color = 0x00bee8, text_color = 0xffffff }, + ["212"] = { color = 0xf4822a, text_color = 0xffffff }, + ["213"] = { color = 0x229a9f, text_color = 0xffffff }, + ["215"] = { color = 0x25b34b, text_color = 0xffffff }, + ["216"] = { color = 0xa4ce3a, text_color = 0xffffff }, + ["218"] = { color = 0x0082c5, text_color = 0xffffff }, + ["221"] = { color = 0x900f11, text_color = 0xffffff }, + ["222"] = { color = 0x006d70, text_color = 0xffffff }, + ["223"] = { color = 0x42357a, text_color = 0xffffff }, + ["224"] = { color = 0xc25d2b, text_color = 0xffffff }, + ["225"] = { color = 0x0d7a31, text_color = 0xffffff }, + ["226"] = { color = 0x779b29, text_color = 0xffffff }, + ["227"] = { color = 0x064d80, text_color = 0xffffff }, + ["230"] = { color = 0x00944e, text_color = 0xffffff }, + }, +} +return colors diff --git a/src/generate_colors_CH.py b/src/generate_colors_CH.py new file mode 100644 index 000000000..ee309e9af --- /dev/null +++ b/src/generate_colors_CH.py @@ -0,0 +1,171 @@ +#!/usr/bin/env python3 +# SPDX-FileCopyrightText: Levin Baumann +# +# SPDX-License-Identifier: AGPL-3.0-or-later +# +# generate_colors.py - Generate Lua table of line colors from Traewelling line-colors CSV +# adapted for VBN GTFS feed by luna-cant-code (GitHub) + + +import csv +import logging +import os +import re +import sys +import requests +from typing import Dict, Any + +## URL = "https://raw.githubusercontent.com/Traewelling/line-colors/refs/heads/main/line-colors.csv" +URL = "https://raw.githubusercontent.com/luna-cant-code/line-colors/refs/heads/feed-transition/line-colors-CH.csv" +OUTPUT = "scripts/de-VBN-colors.lua" + +HEX_RE = re.compile(r"^[0-9A-Fa-f]{3}([0-9A-Fa-f]{3})?$") + + +def fetch_csv(url: str) -> str: + logging.info("Fetching CSV from %s", url) + try: + resp = requests.get(url, timeout=15) + resp.raise_for_status() + return resp.text + except requests.RequestException: + logging.exception("Error while fetching CSV from %s", url) + raise + + +def _find_key(row_keys, desired: str): + """Return the actual key in row_keys whose stripped form equals desired. + + This makes the parser tolerant to CSVs that have leading/trailing spaces + in header names (e.g. ' delfiAgencyName'). + """ + for k in row_keys: + if k is not None and k.strip() == desired: + return k + return None + + +def normalize_hex(s: str) -> str: + if s is None: + return "" + s = s.strip().lstrip('#') + if s == "": + return "" + if len(s) == 3 and HEX_RE.match(s): + # expand short form like 'f0c' -> 'ff00cc' + return ''.join([c * 2 for c in s]).lower() + if len(s) == 6 and HEX_RE.match(s): + return s.lower() + # invalid value + logging.warning("Invalid hex color encountered: %r", s) + return "" + + +def parse_colors(csv_text: str) -> Dict[str, Dict[str, Dict[str, Any]]]: + lines = csv_text.splitlines() + reader = csv.DictReader(lines, skipinitialspace=False) + + # Identify header keys we need (tolerate leading/trailing whitespace) + header = reader.fieldnames or [] + key_agency = _find_key(header, 'delfiAgencyName') or _find_key(header, ' delfiAgencyName') +## key_agency = _find_key(header, 'GTFSAgencyName') or _find_key(header, ' GTFSAgencyName') + key_line = _find_key(header, 'lineName') + key_bg = _find_key(header, 'backgroundColor') + key_text = _find_key(header, 'textColor') + key_border = _find_key(header, 'borderColor') + + if not (key_agency and key_line and key_bg and key_text): + logging.error("CSV is missing expected headers. Found: %r", header) + raise ValueError("CSV missing required headers") + + colors: Dict[str, Dict[str, Dict[str, Any]]] = {} + + for row in reader: + agency = (row.get(key_agency) or "").strip() + line_name = (row.get(key_line) or "").strip() + line_name = line_name.replace(" ", "") + background = normalize_hex(row.get(key_bg) or "") + text = normalize_hex(row.get(key_text) or "") + border = normalize_hex(row.get(key_border) or "") + + # Skip rows without a line name or delfi agency + if line_name == "" or agency == "": + continue + + # If background is white or missing, use border color if available, + # since motis only supports background and text colors + if border and (background == "" or background.lower() == "ffffff"): + background = border + text = "ffffff" + + # If any color is still missing, skip this entry + if background == "" or text == "": + logging.warning("Skipping entry for agency %r, line %r due to missing colors", agency, line_name) + continue + + colors.setdefault(agency, {})[line_name] = { + 'color': background, + 'textColor': text + } + + return colors + + +def _escape_lua_string(s: str) -> str: + return s.replace('\\', '\\\\').replace('"', '\\"') + + +def write_lua_table(colors: Dict[str, Dict[str, Dict[str, Any]]], out_path: str) -> None: + logging.info("Writing Lua table to %s", out_path) + dirpath = os.path.dirname(out_path) + if dirpath and not os.path.exists(dirpath): + os.makedirs(dirpath) + + with open(out_path, 'w', encoding='utf-8') as f: + f.write('-- autogenerated by generate_colors.py\n') + f.write('-- SPDX-FileCopyrightText: contributors of https://github.com/Traewelling/line-colors\n') + f.write('-- SPDX-License-Identifier: CC0-1.0\n\n') + f.write('local colors = {\n') + + # Sort agencies for deterministic output + for agency in sorted(colors.keys()): + safe_agency = _escape_lua_string(agency) + f.write(f' ["{safe_agency}"] = {{\n') + for line_name in sorted(colors[agency].keys()): + safe_line = _escape_lua_string(line_name) + info = colors[agency][line_name] + # convert hex string to 0x... numeric literal + bg = info.get('color', '000000') + text = info.get('textColor', '000000') + # ensure 6-digit hex + if len(bg) == 3: + bg = ''.join([c * 2 for c in bg]) + if len(text) == 3: + text = ''.join([c * 2 for c in text]) + + f.write(f' ["{safe_line}"] = {{ color = 0x{bg}, text_color = 0x{text} }},\n') + f.write(' },\n') + + f.write('}\n') + f.write('return colors\n') + + logging.info("Wrote %d agencies to %s", len(colors), out_path) + + +def main(): + logging.basicConfig(level=logging.WARNING, + format='%(levelname)s: %(message)s') + + try: + csv_text = fetch_csv(URL) + colors = parse_colors(csv_text) + write_lua_table(colors, OUTPUT) + except Exception as e: + logging.exception("Failed to generate colors: %s", e) + return 2 + + return 0 + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/src/generate_colors_VBN.py b/src/generate_colors_VBN.py new file mode 100644 index 000000000..cddce8881 --- /dev/null +++ b/src/generate_colors_VBN.py @@ -0,0 +1,171 @@ +#!/usr/bin/env python3 +# SPDX-FileCopyrightText: Levin Baumann +# +# SPDX-License-Identifier: AGPL-3.0-or-later +# +# generate_colors.py - Generate Lua table of line colors from Traewelling line-colors CSV +# adapted for VBN GTFS feed by luna-cant-code (GitHub) + + +import csv +import logging +import os +import re +import sys +import requests +from typing import Dict, Any + +## URL = "https://raw.githubusercontent.com/Traewelling/line-colors/refs/heads/main/line-colors.csv" +URL = "https://raw.githubusercontent.com/luna-cant-code/line-colors/refs/heads/feed-transition/line-colors-VBN.csv" +OUTPUT = "scripts/de-VBN-colors.lua" + +HEX_RE = re.compile(r"^[0-9A-Fa-f]{3}([0-9A-Fa-f]{3})?$") + + +def fetch_csv(url: str) -> str: + logging.info("Fetching CSV from %s", url) + try: + resp = requests.get(url, timeout=15) + resp.raise_for_status() + return resp.text + except requests.RequestException: + logging.exception("Error while fetching CSV from %s", url) + raise + + +def _find_key(row_keys, desired: str): + """Return the actual key in row_keys whose stripped form equals desired. + + This makes the parser tolerant to CSVs that have leading/trailing spaces + in header names (e.g. ' delfiAgencyName'). + """ + for k in row_keys: + if k is not None and k.strip() == desired: + return k + return None + + +def normalize_hex(s: str) -> str: + if s is None: + return "" + s = s.strip().lstrip('#') + if s == "": + return "" + if len(s) == 3 and HEX_RE.match(s): + # expand short form like 'f0c' -> 'ff00cc' + return ''.join([c * 2 for c in s]).lower() + if len(s) == 6 and HEX_RE.match(s): + return s.lower() + # invalid value + logging.warning("Invalid hex color encountered: %r", s) + return "" + + +def parse_colors(csv_text: str) -> Dict[str, Dict[str, Dict[str, Any]]]: + lines = csv_text.splitlines() + reader = csv.DictReader(lines, skipinitialspace=False) + + # Identify header keys we need (tolerate leading/trailing whitespace) + header = reader.fieldnames or [] + key_agency = _find_key(header, 'delfiAgencyName') or _find_key(header, ' delfiAgencyName') +## key_agency = _find_key(header, 'GTFSAgencyName') or _find_key(header, ' GTFSAgencyName') + key_line = _find_key(header, 'lineName') + key_bg = _find_key(header, 'backgroundColor') + key_text = _find_key(header, 'textColor') + key_border = _find_key(header, 'borderColor') + + if not (key_agency and key_line and key_bg and key_text): + logging.error("CSV is missing expected headers. Found: %r", header) + raise ValueError("CSV missing required headers") + + colors: Dict[str, Dict[str, Dict[str, Any]]] = {} + + for row in reader: + agency = (row.get(key_agency) or "").strip() + line_name = (row.get(key_line) or "").strip() + line_name = line_name.replace(" ", "") + background = normalize_hex(row.get(key_bg) or "") + text = normalize_hex(row.get(key_text) or "") + border = normalize_hex(row.get(key_border) or "") + + # Skip rows without a line name or delfi agency + if line_name == "" or agency == "": + continue + + # If background is white or missing, use border color if available, + # since motis only supports background and text colors + if border and (background == "" or background.lower() == "ffffff"): + background = border + text = "ffffff" + + # If any color is still missing, skip this entry + if background == "" or text == "": + logging.warning("Skipping entry for agency %r, line %r due to missing colors", agency, line_name) + continue + + colors.setdefault(agency, {})[line_name] = { + 'color': background, + 'textColor': text + } + + return colors + + +def _escape_lua_string(s: str) -> str: + return s.replace('\\', '\\\\').replace('"', '\\"') + + +def write_lua_table(colors: Dict[str, Dict[str, Dict[str, Any]]], out_path: str) -> None: + logging.info("Writing Lua table to %s", out_path) + dirpath = os.path.dirname(out_path) + if dirpath and not os.path.exists(dirpath): + os.makedirs(dirpath) + + with open(out_path, 'w', encoding='utf-8') as f: + f.write('-- autogenerated by generate_colors.py\n') + f.write('-- SPDX-FileCopyrightText: contributors of https://github.com/Traewelling/line-colors\n') + f.write('-- SPDX-License-Identifier: CC0-1.0\n\n') + f.write('local colors = {\n') + + # Sort agencies for deterministic output + for agency in sorted(colors.keys()): + safe_agency = _escape_lua_string(agency) + f.write(f' ["{safe_agency}"] = {{\n') + for line_name in sorted(colors[agency].keys()): + safe_line = _escape_lua_string(line_name) + info = colors[agency][line_name] + # convert hex string to 0x... numeric literal + bg = info.get('color', '000000') + text = info.get('textColor', '000000') + # ensure 6-digit hex + if len(bg) == 3: + bg = ''.join([c * 2 for c in bg]) + if len(text) == 3: + text = ''.join([c * 2 for c in text]) + + f.write(f' ["{safe_line}"] = {{ color = 0x{bg}, text_color = 0x{text} }},\n') + f.write(' },\n') + + f.write('}\n') + f.write('return colors\n') + + logging.info("Wrote %d agencies to %s", len(colors), out_path) + + +def main(): + logging.basicConfig(level=logging.WARNING, + format='%(levelname)s: %(message)s') + + try: + csv_text = fetch_csv(URL) + colors = parse_colors(csv_text) + write_lua_table(colors, OUTPUT) + except Exception as e: + logging.exception("Failed to generate colors: %s", e) + return 2 + + return 0 + + +if __name__ == '__main__': + sys.exit(main()) From 8deae89474ccfe749939b12b5c546030e5ddfec0 Mon Sep 17 00:00:00 2001 From: luna-cant-code <223513004+luna-cant-code@users.noreply.github.com> Date: Wed, 3 Dec 2025 18:36:36 +0100 Subject: [PATCH 02/11] tested swiss file successfully --- scripts/ch-opentransport-colors.lua | 163 ++++++++++++++++++++++++++++ src/generate_colors_CH.py | 2 +- 2 files changed, 164 insertions(+), 1 deletion(-) diff --git a/scripts/ch-opentransport-colors.lua b/scripts/ch-opentransport-colors.lua index e69de29bb..9637ddc1e 100644 --- a/scripts/ch-opentransport-colors.lua +++ b/scripts/ch-opentransport-colors.lua @@ -0,0 +1,163 @@ +-- autogenerated by generate_colors.py +-- SPDX-FileCopyrightText: contributors of https://github.com/Traewelling/line-colors +-- SPDX-License-Identifier: CC0-1.0 + +local colors = { + ["Autobus AG Liestal"] = { + ["70"] = { color = 0xffdd00, text_color = 0x000000 }, + ["71"] = { color = 0x95c11f, text_color = 0xffffff }, + ["72"] = { color = 0x5a6f85, text_color = 0xffffff }, + ["74"] = { color = 0xa36009, text_color = 0xffffff }, + ["75"] = { color = 0x7b77b6, text_color = 0xffffff }, + ["76"] = { color = 0x00a7a6, text_color = 0xffffff }, + ["78"] = { color = 0xf39200, text_color = 0x000000 }, + ["80"] = { color = 0xe4032e, text_color = 0xffffff }, + ["81"] = { color = 0xf088b6, text_color = 0x000000 }, + ["82"] = { color = 0x13a538, text_color = 0xffffff }, + ["83"] = { color = 0x0094d2, text_color = 0xffffff }, + }, + ["Baselland Transport"] = { + ["10"] = { color = 0xfec800, text_color = 0x000000 }, + ["105"] = { color = 0xbec2c3, text_color = 0x000000 }, + ["106"] = { color = 0xbec2c3, text_color = 0x000000 }, + ["107"] = { color = 0xbec2c3, text_color = 0x000000 }, + ["108"] = { color = 0xbec2c3, text_color = 0x000000 }, + ["109"] = { color = 0xbec2c3, text_color = 0x000000 }, + ["11"] = { color = 0xe7000e, text_color = 0xffffff }, + ["110"] = { color = 0xbec2c3, text_color = 0x000000 }, + ["17"] = { color = 0x00a1e5, text_color = 0xffffff }, + ["19"] = { color = 0x7c217d, text_color = 0xffffff }, + ["37"] = { color = 0xcfd0d0, text_color = 0x000000 }, + ["47"] = { color = 0xadafaf, text_color = 0x000000 }, + ["58"] = { color = 0xadafaf, text_color = 0x000000 }, + ["59"] = { color = 0xadafaf, text_color = 0x000000 }, + ["60"] = { color = 0xcfd0d0, text_color = 0x000000 }, + ["61"] = { color = 0xadafaf, text_color = 0x000000 }, + ["62"] = { color = 0xadafaf, text_color = 0x000000 }, + ["64"] = { color = 0xcfd0d0, text_color = 0x000000 }, + ["65"] = { color = 0xadafaf, text_color = 0x000000 }, + ["66"] = { color = 0xadafaf, text_color = 0x000000 }, + ["92"] = { color = 0xbec2c3, text_color = 0x000000 }, + ["93"] = { color = 0xbec2c3, text_color = 0x000000 }, + ["E11"] = { color = 0xe7000e, text_color = 0xffffff }, + }, + ["Basler Verkehrsbetriebe"] = { + ["1"] = { color = 0x7c4425, text_color = 0xffffff }, + ["14"] = { color = 0xf17900, text_color = 0xffffff }, + ["15"] = { color = 0x00943d, text_color = 0xffffff }, + ["16"] = { color = 0xa6c700, text_color = 0x000000 }, + ["2"] = { color = 0xa47e42, text_color = 0xffffff }, + ["21"] = { color = 0x00a192, text_color = 0xffffff }, + ["3"] = { color = 0x364093, text_color = 0xffffff }, + ["30"] = { color = 0xadafaf, text_color = 0x000000 }, + ["31"] = { color = 0xadafaf, text_color = 0x000000 }, + ["32"] = { color = 0xadafaf, text_color = 0x000000 }, + ["33"] = { color = 0xcfd0d0, text_color = 0x000000 }, + ["34"] = { color = 0xadafaf, text_color = 0x000000 }, + ["35"] = { color = 0xcfd0d0, text_color = 0x000000 }, + ["36"] = { color = 0xadafaf, text_color = 0x000000 }, + ["38"] = { color = 0xcfd0d0, text_color = 0x000000 }, + ["42"] = { color = 0xcfd0d0, text_color = 0x000000 }, + ["45"] = { color = 0xadafaf, text_color = 0x000000 }, + ["46"] = { color = 0xcfd0d0, text_color = 0x000000 }, + ["47"] = { color = 0xcfd0d0, text_color = 0x000000 }, + ["48"] = { color = 0xadafaf, text_color = 0x000000 }, + ["50"] = { color = 0xcfd0d0, text_color = 0x000000 }, + ["6"] = { color = 0x0068b2, text_color = 0xffffff }, + ["8"] = { color = 0xed6aa4, text_color = 0xffffff }, + }, + ["Funiculaire Neuchâtel-Université - Neuchâtel-Gare"] = { + ["110"] = { color = 0x7dcdbe, text_color = 0xffffff }, + }, + ["PostAuto AG"] = { + ["100"] = { color = 0xffcc00, text_color = 0x000000 }, + ["101"] = { color = 0xffcc00, text_color = 0x000000 }, + ["102"] = { color = 0xffcc00, text_color = 0x000000 }, + ["103"] = { color = 0xffcc00, text_color = 0x000000 }, + ["104"] = { color = 0xffcc00, text_color = 0x000000 }, + ["111"] = { color = 0xffcc00, text_color = 0x000000 }, + ["112"] = { color = 0xffcc00, text_color = 0x000000 }, + ["113"] = { color = 0xffcc00, text_color = 0x000000 }, + ["114"] = { color = 0xffcc00, text_color = 0x000000 }, + ["115"] = { color = 0xffcc00, text_color = 0x000000 }, + ["116"] = { color = 0xffcc00, text_color = 0x000000 }, + ["117"] = { color = 0xffcc00, text_color = 0x000000 }, + ["118"] = { color = 0xffcc00, text_color = 0x000000 }, + ["119"] = { color = 0xffcc00, text_color = 0x000000 }, + ["133"] = { color = 0xffcc00, text_color = 0x000000 }, + ["134"] = { color = 0xffcc00, text_color = 0x000000 }, + ["135"] = { color = 0xffcc00, text_color = 0x000000 }, + ["136"] = { color = 0xffcc00, text_color = 0x000000 }, + ["137"] = { color = 0xffcc00, text_color = 0x000000 }, + ["139"] = { color = 0xffcc00, text_color = 0x000000 }, + ["141"] = { color = 0xffcc00, text_color = 0x000000 }, + ["142"] = { color = 0xffcc00, text_color = 0x000000 }, + ["143"] = { color = 0xffcc00, text_color = 0x000000 }, + ["144"] = { color = 0xffcc00, text_color = 0x000000 }, + ["149"] = { color = 0xffcc00, text_color = 0x000000 }, + ["67"] = { color = 0xffcc00, text_color = 0x000000 }, + ["68"] = { color = 0xffcc00, text_color = 0x000000 }, + ["69"] = { color = 0xffcc00, text_color = 0x000000 }, + ["73"] = { color = 0xffcc00, text_color = 0x000000 }, + ["77"] = { color = 0xffcc00, text_color = 0x000000 }, + ["84"] = { color = 0xffcc00, text_color = 0x000000 }, + ["85"] = { color = 0xffcc00, text_color = 0x000000 }, + ["86"] = { color = 0xffcc00, text_color = 0x000000 }, + ["88"] = { color = 0xffcc00, text_color = 0x000000 }, + ["89"] = { color = 0xffcc00, text_color = 0x000000 }, + ["90"] = { color = 0xffcc00, text_color = 0x000000 }, + ["94"] = { color = 0xffcc00, text_color = 0x000000 }, + ["99"] = { color = 0xffcc00, text_color = 0x000000 }, + }, + ["Service d'automobiles TRN (vr)"] = { + ["422"] = { color = 0xd682b5, text_color = 0xffffff }, + ["423"] = { color = 0x00854c, text_color = 0xffffff }, + ["425"] = { color = 0xe6007e, text_color = 0xffffff }, + ["426"] = { color = 0x4696d2, text_color = 0xffffff }, + ["590"] = { color = 0xe30613, text_color = 0xffffff }, + ["591"] = { color = 0x00854c, text_color = 0xffffff }, + }, + ["Transports Publics Neuchâtelois SA"] = { + ["111"] = { color = 0xd7e141, text_color = 0x000000 }, + ["112"] = { color = 0x009155, text_color = 0xffffff }, + }, + ["Transports Publics Neuchâtelois SA (cmn)"] = { + ["R15"] = { color = 0x7dcdbe, text_color = 0x000000 }, + ["R22"] = { color = 0x78af41, text_color = 0xffffff }, + ["R24"] = { color = 0xd282b4, text_color = 0xffffff }, + }, + ["Transports Publics Neuchâtelois SA (rvt)"] = { + ["R21"] = { color = 0x912891, text_color = 0xffffff }, + }, + ["Transports Publics Neuchâtelois SA (tc)"] = { + ["301"] = { color = 0x312783, text_color = 0xffffff }, + ["302"] = { color = 0xe30613, text_color = 0xffffff }, + ["303"] = { color = 0xdedd26, text_color = 0x000000 }, + ["304"] = { color = 0x00854c, text_color = 0xffffff }, + ["310"] = { color = 0xd682b5, text_color = 0xffffff }, + ["311"] = { color = 0xef7d00, text_color = 0xffffff }, + ["312"] = { color = 0x951b81, text_color = 0xffffff }, + ["341"] = { color = 0x423e8d, text_color = 0xffffff }, + ["342"] = { color = 0xe30613, text_color = 0xffffff }, + ["343"] = { color = 0x912891, text_color = 0xffffff }, + ["352"] = { color = 0xe30613, text_color = 0xffffff }, + ["353"] = { color = 0xdedd26, text_color = 0x000000 }, + ["354"] = { color = 0x00854c, text_color = 0xffffff }, + ["360"] = { color = 0x4a96d2, text_color = 0xffffff }, + ["361"] = { color = 0x8acbc1, text_color = 0x000000 }, + ["370"] = { color = 0xe6007e, text_color = 0xffffff }, + }, + ["Transports Publics Neuchâtelois SA (tn)"] = { + ["101"] = { color = 0x312783, text_color = 0xffffff }, + ["102"] = { color = 0x4a96d2, text_color = 0xffffff }, + ["106"] = { color = 0xd682b5, text_color = 0xffffff }, + ["107"] = { color = 0xe30613, text_color = 0xffffff }, + ["108"] = { color = 0x00854c, text_color = 0xffffff }, + ["109"] = { color = 0x951b81, text_color = 0xffffff }, + ["120"] = { color = 0xef7d00, text_color = 0xffffff }, + ["121"] = { color = 0x95c11f, text_color = 0xffffff }, + ["122"] = { color = 0x8acbc1, text_color = 0x000000 }, + ["421"] = { color = 0xdedd26, text_color = 0x000000 }, + }, +} +return colors diff --git a/src/generate_colors_CH.py b/src/generate_colors_CH.py index ee309e9af..364c6763f 100644 --- a/src/generate_colors_CH.py +++ b/src/generate_colors_CH.py @@ -17,7 +17,7 @@ ## URL = "https://raw.githubusercontent.com/Traewelling/line-colors/refs/heads/main/line-colors.csv" URL = "https://raw.githubusercontent.com/luna-cant-code/line-colors/refs/heads/feed-transition/line-colors-CH.csv" -OUTPUT = "scripts/de-VBN-colors.lua" +OUTPUT = "scripts/ch-opentransport-colors.lua" HEX_RE = re.compile(r"^[0-9A-Fa-f]{3}([0-9A-Fa-f]{3})?$") From 222ae0d29193999c15b67e951a2feee6f8c95811 Mon Sep 17 00:00:00 2001 From: luna-cant-code <223513004+luna-cant-code@users.noreply.github.com> Date: Wed, 3 Dec 2025 18:40:09 +0100 Subject: [PATCH 03/11] made scripts a bit prettier for roll-out --- src/generate_colors_CH.py | 7 +++---- src/generate_colors_VBN.py | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/generate_colors_CH.py b/src/generate_colors_CH.py index 364c6763f..e8216cb24 100644 --- a/src/generate_colors_CH.py +++ b/src/generate_colors_CH.py @@ -15,8 +15,7 @@ import requests from typing import Dict, Any -## URL = "https://raw.githubusercontent.com/Traewelling/line-colors/refs/heads/main/line-colors.csv" -URL = "https://raw.githubusercontent.com/luna-cant-code/line-colors/refs/heads/feed-transition/line-colors-CH.csv" +URL = "https://raw.githubusercontent.com/Traewelling/line-colors/refs/heads/main/line-colors-CH.csv" OUTPUT = "scripts/ch-opentransport-colors.lua" HEX_RE = re.compile(r"^[0-9A-Fa-f]{3}([0-9A-Fa-f]{3})?$") @@ -67,8 +66,8 @@ def parse_colors(csv_text: str) -> Dict[str, Dict[str, Dict[str, Any]]]: # Identify header keys we need (tolerate leading/trailing whitespace) header = reader.fieldnames or [] - key_agency = _find_key(header, 'delfiAgencyName') or _find_key(header, ' delfiAgencyName') -## key_agency = _find_key(header, 'GTFSAgencyName') or _find_key(header, ' GTFSAgencyName') +## key_agency = _find_key(header, 'delfiAgencyName') or _find_key(header, ' delfiAgencyName') // Left for transition purposes + key_agency = _find_key(header, 'GTFSAgencyName') or _find_key(header, ' GTFSAgencyName') key_line = _find_key(header, 'lineName') key_bg = _find_key(header, 'backgroundColor') key_text = _find_key(header, 'textColor') diff --git a/src/generate_colors_VBN.py b/src/generate_colors_VBN.py index cddce8881..b34e63b33 100644 --- a/src/generate_colors_VBN.py +++ b/src/generate_colors_VBN.py @@ -15,8 +15,7 @@ import requests from typing import Dict, Any -## URL = "https://raw.githubusercontent.com/Traewelling/line-colors/refs/heads/main/line-colors.csv" -URL = "https://raw.githubusercontent.com/luna-cant-code/line-colors/refs/heads/feed-transition/line-colors-VBN.csv" +URL = "https://raw.githubusercontent.com/Traewelling/line-colors/refs/heads/main/line-colors-VBN.csv" OUTPUT = "scripts/de-VBN-colors.lua" HEX_RE = re.compile(r"^[0-9A-Fa-f]{3}([0-9A-Fa-f]{3})?$") @@ -67,8 +66,8 @@ def parse_colors(csv_text: str) -> Dict[str, Dict[str, Dict[str, Any]]]: # Identify header keys we need (tolerate leading/trailing whitespace) header = reader.fieldnames or [] - key_agency = _find_key(header, 'delfiAgencyName') or _find_key(header, ' delfiAgencyName') -## key_agency = _find_key(header, 'GTFSAgencyName') or _find_key(header, ' GTFSAgencyName') +## key_agency = _find_key(header, 'delfiAgencyName') or _find_key(header, ' delfiAgencyName') // left for transition purposes + key_agency = _find_key(header, 'GTFSAgencyName') or _find_key(header, ' GTFSAgencyName') key_line = _find_key(header, 'lineName') key_bg = _find_key(header, 'backgroundColor') key_text = _find_key(header, 'textColor') From 023f97400e32237aefa1e2f725cb4acfcb5687d8 Mon Sep 17 00:00:00 2001 From: luna-cant-code <223513004+luna-cant-code@users.noreply.github.com> Date: Wed, 3 Dec 2025 20:53:14 +0100 Subject: [PATCH 04/11] added VBN script (really unsure though) and added said script to de.json (even unsurer) --- feeds/de.json | 1 + scripts/de-VBN.lua | 73 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 scripts/de-VBN.lua diff --git a/feeds/de.json b/feeds/de.json index dc64753e3..77b6cabab 100644 --- a/feeds/de.json +++ b/feeds/de.json @@ -83,6 +83,7 @@ "http-options": { "fetch-interval-days": 1 }, + "script": "de-VBN.lua", "license": { "spdx-identifier": "CC-BY-SA-4.0" } diff --git a/scripts/de-VBN.lua b/scripts/de-VBN.lua new file mode 100644 index 000000000..444948b75 --- /dev/null +++ b/scripts/de-VBN.lua @@ -0,0 +1,73 @@ +-- SPDX-FileCopyrightText: Felix Gündling +-- SPDX-License-Identifier: AGPL-3.0-or-later + +local colors = require 'scripts.de-VBN-colors' + +function is_number(str) + return not (str == "" or str:find("%D")) +end + +function remove_leading_zeros(str) + return string.format("%d", tonumber(str)) +end + +-- routes from international operators that need their display names fixed +-- { source route type, route name } + +-- i reckon, the intl_name_map thing could be deleted, couldn't see that in VBN data +--local intl_name_map = { +-- { 102, "EC" }, +-- { 102, "IC" }, +-- { 101, "ICE" }, +-- { 102, "NJ" }, +-- { 101, "RJ" }, +-- { 102, "RJX" }, +-- { 101, "THA" }, +--} + +--not sure about that but i don't think leaving it uncommented breaks anything + +function process_trip(trip) + if trip:get_route():get_agency():get_name() == 'DB Fernverkehr AG' and is_number(trip:get_short_name()) then + -- Format trip_short_name=`00123` to train number 123 + if trip:get_route():get_route_type() == 101 then + trip:set_short_name('ICE ' .. remove_leading_zeros(trip:get_short_name())) + trip:set_display_name(trip:get_short_name()) + elseif trip:get_route():get_route_type() == 102 then + trip:set_short_name('IC ' .. remove_leading_zeros(trip:get_short_name())) + trip:set_display_name(trip:get_short_name()) + end + else + -- international operators without line names in the route short name + for _,m in ipairs(intl_name_map) do + if trip:get_route():get_route_type() == m[1] and trip:get_route():get_short_name() == m[2] then + trip:set_short_name(trip:get_route():get_short_name() .. ' ' .. remove_leading_zeros(trip:get_short_name())) + trip:set_display_name(trip:get_short_name()) + end + end + end + + if trip:get_route():get_route_type() == 106 and is_number(trip:get_short_name()) then + trip:set_display_name(trip:get_route():get_short_name() .. ' (' .. remove_leading_zeros(trip:get_short_name()) .. ')') + end +end + +function process_agency(agency) + if agency:get_url() == "https://www.delfi.de" then + agency:set_url("") + end +end + +function process_route(route) + local agency_name = route:get_agency():get_name() + local route_name = route:get_short_name() + -- remove spaces from route name for matching + route_name = route_name:gsub("%s+", "") + local original_route_color = route:get_color() + local original_route_text_color = route:get_text_color() + if (original_route_color == 0 or original_route_text_color == 0) and colors[agency_name] and colors[agency_name][route_name] then + local colors = colors[agency_name][route_name] + route:set_color(colors.color) + route:set_text_color(colors.text_color) + end +end From 873b1b42fb307dffb392095a398f3b658f72b71d Mon Sep 17 00:00:00 2001 From: luna-cant-code <223513004+luna-cant-code@users.noreply.github.com> Date: Thu, 4 Dec 2025 12:06:22 +0100 Subject: [PATCH 05/11] fixed an oopsie (worked in wrong repo) --- scripts/ch-opentransport-colors.lua | 163 -------------- scripts/de-VBN-colors.lua | 205 ----------------- src/generate_colors_combined.py | 329 ++++++++++++++++++++++++++++ 3 files changed, 329 insertions(+), 368 deletions(-) create mode 100644 src/generate_colors_combined.py diff --git a/scripts/ch-opentransport-colors.lua b/scripts/ch-opentransport-colors.lua index 9637ddc1e..e69de29bb 100644 --- a/scripts/ch-opentransport-colors.lua +++ b/scripts/ch-opentransport-colors.lua @@ -1,163 +0,0 @@ --- autogenerated by generate_colors.py --- SPDX-FileCopyrightText: contributors of https://github.com/Traewelling/line-colors --- SPDX-License-Identifier: CC0-1.0 - -local colors = { - ["Autobus AG Liestal"] = { - ["70"] = { color = 0xffdd00, text_color = 0x000000 }, - ["71"] = { color = 0x95c11f, text_color = 0xffffff }, - ["72"] = { color = 0x5a6f85, text_color = 0xffffff }, - ["74"] = { color = 0xa36009, text_color = 0xffffff }, - ["75"] = { color = 0x7b77b6, text_color = 0xffffff }, - ["76"] = { color = 0x00a7a6, text_color = 0xffffff }, - ["78"] = { color = 0xf39200, text_color = 0x000000 }, - ["80"] = { color = 0xe4032e, text_color = 0xffffff }, - ["81"] = { color = 0xf088b6, text_color = 0x000000 }, - ["82"] = { color = 0x13a538, text_color = 0xffffff }, - ["83"] = { color = 0x0094d2, text_color = 0xffffff }, - }, - ["Baselland Transport"] = { - ["10"] = { color = 0xfec800, text_color = 0x000000 }, - ["105"] = { color = 0xbec2c3, text_color = 0x000000 }, - ["106"] = { color = 0xbec2c3, text_color = 0x000000 }, - ["107"] = { color = 0xbec2c3, text_color = 0x000000 }, - ["108"] = { color = 0xbec2c3, text_color = 0x000000 }, - ["109"] = { color = 0xbec2c3, text_color = 0x000000 }, - ["11"] = { color = 0xe7000e, text_color = 0xffffff }, - ["110"] = { color = 0xbec2c3, text_color = 0x000000 }, - ["17"] = { color = 0x00a1e5, text_color = 0xffffff }, - ["19"] = { color = 0x7c217d, text_color = 0xffffff }, - ["37"] = { color = 0xcfd0d0, text_color = 0x000000 }, - ["47"] = { color = 0xadafaf, text_color = 0x000000 }, - ["58"] = { color = 0xadafaf, text_color = 0x000000 }, - ["59"] = { color = 0xadafaf, text_color = 0x000000 }, - ["60"] = { color = 0xcfd0d0, text_color = 0x000000 }, - ["61"] = { color = 0xadafaf, text_color = 0x000000 }, - ["62"] = { color = 0xadafaf, text_color = 0x000000 }, - ["64"] = { color = 0xcfd0d0, text_color = 0x000000 }, - ["65"] = { color = 0xadafaf, text_color = 0x000000 }, - ["66"] = { color = 0xadafaf, text_color = 0x000000 }, - ["92"] = { color = 0xbec2c3, text_color = 0x000000 }, - ["93"] = { color = 0xbec2c3, text_color = 0x000000 }, - ["E11"] = { color = 0xe7000e, text_color = 0xffffff }, - }, - ["Basler Verkehrsbetriebe"] = { - ["1"] = { color = 0x7c4425, text_color = 0xffffff }, - ["14"] = { color = 0xf17900, text_color = 0xffffff }, - ["15"] = { color = 0x00943d, text_color = 0xffffff }, - ["16"] = { color = 0xa6c700, text_color = 0x000000 }, - ["2"] = { color = 0xa47e42, text_color = 0xffffff }, - ["21"] = { color = 0x00a192, text_color = 0xffffff }, - ["3"] = { color = 0x364093, text_color = 0xffffff }, - ["30"] = { color = 0xadafaf, text_color = 0x000000 }, - ["31"] = { color = 0xadafaf, text_color = 0x000000 }, - ["32"] = { color = 0xadafaf, text_color = 0x000000 }, - ["33"] = { color = 0xcfd0d0, text_color = 0x000000 }, - ["34"] = { color = 0xadafaf, text_color = 0x000000 }, - ["35"] = { color = 0xcfd0d0, text_color = 0x000000 }, - ["36"] = { color = 0xadafaf, text_color = 0x000000 }, - ["38"] = { color = 0xcfd0d0, text_color = 0x000000 }, - ["42"] = { color = 0xcfd0d0, text_color = 0x000000 }, - ["45"] = { color = 0xadafaf, text_color = 0x000000 }, - ["46"] = { color = 0xcfd0d0, text_color = 0x000000 }, - ["47"] = { color = 0xcfd0d0, text_color = 0x000000 }, - ["48"] = { color = 0xadafaf, text_color = 0x000000 }, - ["50"] = { color = 0xcfd0d0, text_color = 0x000000 }, - ["6"] = { color = 0x0068b2, text_color = 0xffffff }, - ["8"] = { color = 0xed6aa4, text_color = 0xffffff }, - }, - ["Funiculaire Neuchâtel-Université - Neuchâtel-Gare"] = { - ["110"] = { color = 0x7dcdbe, text_color = 0xffffff }, - }, - ["PostAuto AG"] = { - ["100"] = { color = 0xffcc00, text_color = 0x000000 }, - ["101"] = { color = 0xffcc00, text_color = 0x000000 }, - ["102"] = { color = 0xffcc00, text_color = 0x000000 }, - ["103"] = { color = 0xffcc00, text_color = 0x000000 }, - ["104"] = { color = 0xffcc00, text_color = 0x000000 }, - ["111"] = { color = 0xffcc00, text_color = 0x000000 }, - ["112"] = { color = 0xffcc00, text_color = 0x000000 }, - ["113"] = { color = 0xffcc00, text_color = 0x000000 }, - ["114"] = { color = 0xffcc00, text_color = 0x000000 }, - ["115"] = { color = 0xffcc00, text_color = 0x000000 }, - ["116"] = { color = 0xffcc00, text_color = 0x000000 }, - ["117"] = { color = 0xffcc00, text_color = 0x000000 }, - ["118"] = { color = 0xffcc00, text_color = 0x000000 }, - ["119"] = { color = 0xffcc00, text_color = 0x000000 }, - ["133"] = { color = 0xffcc00, text_color = 0x000000 }, - ["134"] = { color = 0xffcc00, text_color = 0x000000 }, - ["135"] = { color = 0xffcc00, text_color = 0x000000 }, - ["136"] = { color = 0xffcc00, text_color = 0x000000 }, - ["137"] = { color = 0xffcc00, text_color = 0x000000 }, - ["139"] = { color = 0xffcc00, text_color = 0x000000 }, - ["141"] = { color = 0xffcc00, text_color = 0x000000 }, - ["142"] = { color = 0xffcc00, text_color = 0x000000 }, - ["143"] = { color = 0xffcc00, text_color = 0x000000 }, - ["144"] = { color = 0xffcc00, text_color = 0x000000 }, - ["149"] = { color = 0xffcc00, text_color = 0x000000 }, - ["67"] = { color = 0xffcc00, text_color = 0x000000 }, - ["68"] = { color = 0xffcc00, text_color = 0x000000 }, - ["69"] = { color = 0xffcc00, text_color = 0x000000 }, - ["73"] = { color = 0xffcc00, text_color = 0x000000 }, - ["77"] = { color = 0xffcc00, text_color = 0x000000 }, - ["84"] = { color = 0xffcc00, text_color = 0x000000 }, - ["85"] = { color = 0xffcc00, text_color = 0x000000 }, - ["86"] = { color = 0xffcc00, text_color = 0x000000 }, - ["88"] = { color = 0xffcc00, text_color = 0x000000 }, - ["89"] = { color = 0xffcc00, text_color = 0x000000 }, - ["90"] = { color = 0xffcc00, text_color = 0x000000 }, - ["94"] = { color = 0xffcc00, text_color = 0x000000 }, - ["99"] = { color = 0xffcc00, text_color = 0x000000 }, - }, - ["Service d'automobiles TRN (vr)"] = { - ["422"] = { color = 0xd682b5, text_color = 0xffffff }, - ["423"] = { color = 0x00854c, text_color = 0xffffff }, - ["425"] = { color = 0xe6007e, text_color = 0xffffff }, - ["426"] = { color = 0x4696d2, text_color = 0xffffff }, - ["590"] = { color = 0xe30613, text_color = 0xffffff }, - ["591"] = { color = 0x00854c, text_color = 0xffffff }, - }, - ["Transports Publics Neuchâtelois SA"] = { - ["111"] = { color = 0xd7e141, text_color = 0x000000 }, - ["112"] = { color = 0x009155, text_color = 0xffffff }, - }, - ["Transports Publics Neuchâtelois SA (cmn)"] = { - ["R15"] = { color = 0x7dcdbe, text_color = 0x000000 }, - ["R22"] = { color = 0x78af41, text_color = 0xffffff }, - ["R24"] = { color = 0xd282b4, text_color = 0xffffff }, - }, - ["Transports Publics Neuchâtelois SA (rvt)"] = { - ["R21"] = { color = 0x912891, text_color = 0xffffff }, - }, - ["Transports Publics Neuchâtelois SA (tc)"] = { - ["301"] = { color = 0x312783, text_color = 0xffffff }, - ["302"] = { color = 0xe30613, text_color = 0xffffff }, - ["303"] = { color = 0xdedd26, text_color = 0x000000 }, - ["304"] = { color = 0x00854c, text_color = 0xffffff }, - ["310"] = { color = 0xd682b5, text_color = 0xffffff }, - ["311"] = { color = 0xef7d00, text_color = 0xffffff }, - ["312"] = { color = 0x951b81, text_color = 0xffffff }, - ["341"] = { color = 0x423e8d, text_color = 0xffffff }, - ["342"] = { color = 0xe30613, text_color = 0xffffff }, - ["343"] = { color = 0x912891, text_color = 0xffffff }, - ["352"] = { color = 0xe30613, text_color = 0xffffff }, - ["353"] = { color = 0xdedd26, text_color = 0x000000 }, - ["354"] = { color = 0x00854c, text_color = 0xffffff }, - ["360"] = { color = 0x4a96d2, text_color = 0xffffff }, - ["361"] = { color = 0x8acbc1, text_color = 0x000000 }, - ["370"] = { color = 0xe6007e, text_color = 0xffffff }, - }, - ["Transports Publics Neuchâtelois SA (tn)"] = { - ["101"] = { color = 0x312783, text_color = 0xffffff }, - ["102"] = { color = 0x4a96d2, text_color = 0xffffff }, - ["106"] = { color = 0xd682b5, text_color = 0xffffff }, - ["107"] = { color = 0xe30613, text_color = 0xffffff }, - ["108"] = { color = 0x00854c, text_color = 0xffffff }, - ["109"] = { color = 0x951b81, text_color = 0xffffff }, - ["120"] = { color = 0xef7d00, text_color = 0xffffff }, - ["121"] = { color = 0x95c11f, text_color = 0xffffff }, - ["122"] = { color = 0x8acbc1, text_color = 0x000000 }, - ["421"] = { color = 0xdedd26, text_color = 0x000000 }, - }, -} -return colors diff --git a/scripts/de-VBN-colors.lua b/scripts/de-VBN-colors.lua index 66e3f751d..e69de29bb 100644 --- a/scripts/de-VBN-colors.lua +++ b/scripts/de-VBN-colors.lua @@ -1,205 +0,0 @@ --- autogenerated by generate_colors.py --- SPDX-FileCopyrightText: contributors of https://github.com/Traewelling/line-colors --- SPDX-License-Identifier: CC0-1.0 - -local colors = { - ["Braunschweiger Verkehrs-GmbH"] = { - ["1"] = { color = 0xe2000a, text_color = 0xffffff }, - ["10"] = { color = 0xe2000a, text_color = 0xffffff }, - ["1E"] = { color = 0xe2000a, text_color = 0xffffff }, - ["2"] = { color = 0x93c019, text_color = 0xffffff }, - ["2E"] = { color = 0x93c019, text_color = 0xffffff }, - ["3"] = { color = 0x006430, text_color = 0xffffff }, - ["3E"] = { color = 0x006430, text_color = 0xffffff }, - ["4"] = { color = 0x009ee2, text_color = 0xffffff }, - ["411"] = { color = 0xb1a85c, text_color = 0xffffff }, - ["412"] = { color = 0x009ee2, text_color = 0xffffff }, - ["413"] = { color = 0x00953e, text_color = 0xffffff }, - ["414"] = { color = 0x5ac5f1, text_color = 0xffffff }, - ["416"] = { color = 0xf39100, text_color = 0xffffff }, - ["417"] = { color = 0x9b9c9c, text_color = 0xffffff }, - ["418"] = { color = 0xd35c9e, text_color = 0xffffff }, - ["419"] = { color = 0x0068b3, text_color = 0xffffff }, - ["420"] = { color = 0x6e6e6d, text_color = 0xffffff }, - ["421"] = { color = 0xc14d96, text_color = 0xffffff }, - ["422"] = { color = 0x9b0600, text_color = 0xffffff }, - ["423"] = { color = 0x9b0600, text_color = 0xffffff }, - ["424"] = { color = 0xe0b500, text_color = 0xffffff }, - ["426"] = { color = 0x804796, text_color = 0xffffff }, - ["427"] = { color = 0x70ba6e, text_color = 0xffffff }, - ["430"] = { color = 0x6e6e6d, text_color = 0xffffff }, - ["431"] = { color = 0xebc56b, text_color = 0xffffff }, - ["433"] = { color = 0xec6da6, text_color = 0xffffff }, - ["434"] = { color = 0xa20600, text_color = 0xffffff }, - ["435"] = { color = 0xe2000a, text_color = 0xffffff }, - ["436"] = { color = 0x0f3f93, text_color = 0xffffff }, - ["437"] = { color = 0x9b9c9c, text_color = 0xffffff }, - ["445"] = { color = 0x8bbd1d, text_color = 0xffffff }, - ["450"] = { color = 0x6e6e6d, text_color = 0xffffff }, - ["454"] = { color = 0xffd000, text_color = 0xffffff }, - ["455"] = { color = 0x9b9c9c, text_color = 0xffffff }, - ["464"] = { color = 0x9b9c9c, text_color = 0xffffff }, - ["465"] = { color = 0xe94d33, text_color = 0xffffff }, - ["466"] = { color = 0xe94d33, text_color = 0xffffff }, - ["471"] = { color = 0x23318a, text_color = 0xffffff }, - ["480"] = { color = 0x6e6e6d, text_color = 0xffffff }, - ["481"] = { color = 0x9b9c9c, text_color = 0xffffff }, - ["482"] = { color = 0x8bbd1d, text_color = 0xffffff }, - ["4E"] = { color = 0x009ee2, text_color = 0xffffff }, - ["5"] = { color = 0xf39100, text_color = 0xffffff }, - ["5E"] = { color = 0xf39100, text_color = 0xffffff }, - }, - ["HarzBus GbR"] = { - ["650"] = { color = 0x9f5292, text_color = 0xffffff }, - ["655"] = { color = 0x42aa61, text_color = 0xffffff }, - ["810"] = { color = 0xca1413, text_color = 0xffffff }, - ["821"] = { color = 0x846fac, text_color = 0xffffff }, - ["822"] = { color = 0xed760b, text_color = 0xffffff }, - ["830"] = { color = 0x9a246c, text_color = 0xffffff }, - ["831"] = { color = 0x009eb5, text_color = 0xffffff }, - ["832"] = { color = 0x663904, text_color = 0xffffff }, - ["833"] = { color = 0x005ca1, text_color = 0xffffff }, - ["834"] = { color = 0x005ca1, text_color = 0xffffff }, - ["836"] = { color = 0x78348a, text_color = 0xffffff }, - ["840"] = { color = 0x005a9f, text_color = 0xffffff }, - ["841"] = { color = 0x007e3b, text_color = 0xffffff }, - ["850"] = { color = 0x9271ae, text_color = 0xffffff }, - ["851"] = { color = 0x895079, text_color = 0xffffff }, - ["852"] = { color = 0x975500, text_color = 0xffffff }, - ["860"] = { color = 0x007e3b, text_color = 0xffffff }, - ["861"] = { color = 0x975500, text_color = 0xffffff }, - }, - ["Kraftverkehrsgesellschaft mbH Braunschweig"] = { - ["360"] = { color = 0xffffff, text_color = 0xb5579a }, - ["370"] = { color = 0xffffff, text_color = 0xe61381 }, - ["371"] = { color = 0xffffff, text_color = 0xfadd04 }, - ["372"] = { color = 0xffffff, text_color = 0xc8c8cc }, - ["380"] = { color = 0xffffff, text_color = 0xfadd04 }, - ["381"] = { color = 0xffffff, text_color = 0xb9cd29 }, - ["382"] = { color = 0xffffff, text_color = 0x9b2425 }, - ["383"] = { color = 0xffffff, text_color = 0x00a0e1 }, - ["384"] = { color = 0xffffff, text_color = 0x008640 }, - ["385"] = { color = 0xffffff, text_color = 0xbe7e20 }, - ["386"] = { color = 0xffffff, text_color = 0xbdddd0 }, - ["387"] = { color = 0xffffff, text_color = 0xe61381 }, - ["388"] = { color = 0xffffff, text_color = 0xfadd04 }, - ["390"] = { color = 0xffffff, text_color = 0xf1a1bc }, - ["391"] = { color = 0xffffff, text_color = 0xe11d25 }, - ["392"] = { color = 0xffffff, text_color = 0x0854a1 }, - ["393"] = { color = 0xffffff, text_color = 0xe11d25 }, - ["394"] = { color = 0xffffff, text_color = 0xf4981b }, - ["395"] = { color = 0xffffff, text_color = 0xb5579a }, - ["396"] = { color = 0xffffff, text_color = 0x3c3386 }, - ["397"] = { color = 0xffffff, text_color = 0xb9cd29 }, - ["398"] = { color = 0xffffff, text_color = 0x008640 }, - ["399"] = { color = 0xffffff, text_color = 0x008640 }, - ["601"] = { color = 0xffffff, text_color = 0xec1f25 }, - ["602"] = { color = 0xffffff, text_color = 0xec1f25 }, - ["603"] = { color = 0xffffff, text_color = 0x00adef }, - ["604"] = { color = 0xffffff, text_color = 0x6ab145 }, - ["606"] = { color = 0xffffff, text_color = 0xf48221 }, - ["607"] = { color = 0xffffff, text_color = 0xa868ab }, - ["608"] = { color = 0xffffff, text_color = 0xea028c }, - ["609"] = { color = 0xffffff, text_color = 0xea028c }, - ["610"] = { color = 0xffffff, text_color = 0xf48221 }, - ["611"] = { color = 0xffffff, text_color = 0x2c3192 }, - ["612"] = { color = 0xffffff, text_color = 0xf5d90e }, - ["613"] = { color = 0xffffff, text_color = 0xb66f35 }, - ["614"] = { color = 0xffffff, text_color = 0xb1345b }, - ["615"] = { color = 0xffffff, text_color = 0x007236 }, - ["616"] = { color = 0xffffff, text_color = 0xf499a4 }, - ["618"] = { color = 0xffffff, text_color = 0x01b9be }, - ["619"] = { color = 0xffffff, text_color = 0x772b90 }, - ["620"] = { color = 0xffffff, text_color = 0x006cb8 }, - ["621"] = { color = 0xffffff, text_color = 0x7e8285 }, - ["626"] = { color = 0xffffff, text_color = 0x7e8285 }, - ["627"] = { color = 0xffffff, text_color = 0x7e8285 }, - ["628"] = { color = 0xffffff, text_color = 0x7e8285 }, - ["630"] = { color = 0xffffff, text_color = 0x00a551 }, - ["640"] = { color = 0xffffff, text_color = 0x009183 }, - ["710"] = { color = 0xffffff, text_color = 0xf6d68f }, - ["740"] = { color = 0xffffff, text_color = 0xf59031 }, - ["750"] = { color = 0xffffff, text_color = 0xfab15d }, - ["790"] = { color = 0xffffff, text_color = 0xfbc335 }, - ["791"] = { color = 0xffffff, text_color = 0xb1d23d }, - ["792"] = { color = 0xffffff, text_color = 0x6cbf5b }, - ["793"] = { color = 0xffffff, text_color = 0x00b3bd }, - ["794"] = { color = 0xffffff, text_color = 0x2993d1 }, - ["795"] = { color = 0xffffff, text_color = 0x50b7e8 }, - ["796"] = { color = 0xffffff, text_color = 0x146b8b }, - ["797"] = { color = 0xffffff, text_color = 0x778ec8 }, - ["799"] = { color = 0xffffff, text_color = 0x72ccd4 }, - ["820"] = { color = 0xffffff, text_color = 0x00a551 }, - ["871"] = { color = 0xffffff, text_color = 0x00adef }, - ["873"] = { color = 0xffffff, text_color = 0xf9a61b }, - ["874"] = { color = 0xffffff, text_color = 0xeb106e }, - ["875"] = { color = 0xffffff, text_color = 0x9d005e }, - ["879"] = { color = 0xffffff, text_color = 0xec1f25 }, - }, - ["Stadtbus Goslar GmbH"] = { - ["801"] = { color = 0xfc9400, text_color = 0xffffff }, - ["802"] = { color = 0xac2f8a, text_color = 0xffffff }, - ["803"] = { color = 0x0aa2e3, text_color = 0xffffff }, - ["804"] = { color = 0x292174, text_color = 0xffffff }, - ["805"] = { color = 0x735c30, text_color = 0xffffff }, - ["806"] = { color = 0x0a6031, text_color = 0xffffff }, - }, - ["Verkehrsbetriebe Bachstein"] = { - ["151"] = { color = 0x009de2, text_color = 0xffffff }, - ["153"] = { color = 0xe20715, text_color = 0xffffff }, - ["160"] = { color = 0x009340, text_color = 0xffffff }, - ["161"] = { color = 0x312681, text_color = 0xffffff }, - ["162"] = { color = 0xf09100, text_color = 0xffffff }, - ["163"] = { color = 0xe5007c, text_color = 0xffffff }, - ["165"] = { color = 0xdfdb00, text_color = 0xffffff }, - ["335"] = { color = 0x94be1f, text_color = 0xffffff }, - ["650"] = { color = 0xa05292, text_color = 0xffffff }, - ["656"] = { color = 0x28225c, text_color = 0xffffff }, - ["658"] = { color = 0xe5213d, text_color = 0xffffff }, - ["660"] = { color = 0xf39200, text_color = 0xffffff }, - ["750"] = { color = 0xe2000e, text_color = 0xffffff }, - ["751"] = { color = 0x2e2482, text_color = 0xffffff }, - ["752"] = { color = 0x00953f, text_color = 0xffffff }, - ["753"] = { color = 0x35a9e0, text_color = 0xffffff }, - ["754"] = { color = 0xf39100, text_color = 0xffffff }, - ["755"] = { color = 0xdddb00, text_color = 0xffffff }, - ["756"] = { color = 0xe5007c, text_color = 0xffffff }, - ["757"] = { color = 0x82348b, text_color = 0xffffff }, - }, - ["Verkehrsgesellschaft Landkreis Gifhorn mbH"] = { - ["100"] = { color = 0xe7372a, text_color = 0x191919 }, - ["101"] = { color = 0x91009b, text_color = 0x191919 }, - ["102"] = { color = 0x955e42, text_color = 0x191919 }, - ["103"] = { color = 0xffacf2, text_color = 0x191919 }, - ["105"] = { color = 0xff9518, text_color = 0x191919 }, - ["108"] = { color = 0xf0ea2c, text_color = 0x191919 }, - ["111"] = { color = 0x5fdaef, text_color = 0x191919 }, - ["140"] = { color = 0x66d8c7, text_color = 0x191919 }, - ["141"] = { color = 0x65ff8c, text_color = 0x191919 }, - ["164"] = { color = 0xb3d04b, text_color = 0x191919 }, - ["170"] = { color = 0x90d6ab, text_color = 0x191919 }, - ["175"] = { color = 0xab91f8, text_color = 0x191919 }, - ["191"] = { color = 0x379e90, text_color = 0x191919 }, - }, - ["Wolfsburger Verkehrs-GmbH"] = { - ["201"] = { color = 0xe44b48, text_color = 0xffffff }, - ["202"] = { color = 0x2cbca9, text_color = 0xffffff }, - ["203"] = { color = 0x6558a6, text_color = 0xffffff }, - ["204"] = { color = 0xe7b011, text_color = 0xffffff }, - ["211"] = { color = 0x00bee8, text_color = 0xffffff }, - ["212"] = { color = 0xf4822a, text_color = 0xffffff }, - ["213"] = { color = 0x229a9f, text_color = 0xffffff }, - ["215"] = { color = 0x25b34b, text_color = 0xffffff }, - ["216"] = { color = 0xa4ce3a, text_color = 0xffffff }, - ["218"] = { color = 0x0082c5, text_color = 0xffffff }, - ["221"] = { color = 0x900f11, text_color = 0xffffff }, - ["222"] = { color = 0x006d70, text_color = 0xffffff }, - ["223"] = { color = 0x42357a, text_color = 0xffffff }, - ["224"] = { color = 0xc25d2b, text_color = 0xffffff }, - ["225"] = { color = 0x0d7a31, text_color = 0xffffff }, - ["226"] = { color = 0x779b29, text_color = 0xffffff }, - ["227"] = { color = 0x064d80, text_color = 0xffffff }, - ["230"] = { color = 0x00944e, text_color = 0xffffff }, - }, -} -return colors diff --git a/src/generate_colors_combined.py b/src/generate_colors_combined.py new file mode 100644 index 000000000..e3d8954fc --- /dev/null +++ b/src/generate_colors_combined.py @@ -0,0 +1,329 @@ +#!/usr/bin/env python3 +# SPDX-FileCopyrightText: Levin Baumann +# +# SPDX-License-Identifier: AGPL-3.0-or-later +# +# generate_colors.py - Generate Lua table of line colors from Traewelling line-colors CSV +# adapted for VBN GTFS feed by luna-cant-code (GitHub) + + +import csv +import logging +import os +import re +import sys +import requests +from typing import Dict, Any + +def VBN(): + #URL = "https://raw.githubusercontent.com/Traewelling/line-colors/refs/heads/main/line-colors-VBN.csv" + URL = "https://raw.githubusercontent.com/luna-cant-code/line-colors/refs/heads/feed-transition/line-colors-VBN.csv" + OUTPUT = "scripts/de-VBN-colors.lua" + + HEX_RE = re.compile(r"^[0-9A-Fa-f]{3}([0-9A-Fa-f]{3})?$") + + + def fetch_csv(url: str) -> str: + logging.info("Fetching CSV from %s", url) + try: + resp = requests.get(url, timeout=15) + resp.raise_for_status() + return resp.text + except requests.RequestException: + logging.exception("Error while fetching CSV from %s", url) + raise + + + def _find_key(row_keys, desired: str): + """Return the actual key in row_keys whose stripped form equals desired. + + This makes the parser tolerant to CSVs that have leading/trailing spaces + in header names (e.g. ' delfiAgencyName'). + """ + for k in row_keys: + if k is not None and k.strip() == desired: + return k + return None + + + def normalize_hex(s: str) -> str: + if s is None: + return "" + s = s.strip().lstrip('#') + if s == "": + return "" + if len(s) == 3 and HEX_RE.match(s): + # expand short form like 'f0c' -> 'ff00cc' + return ''.join([c * 2 for c in s]).lower() + if len(s) == 6 and HEX_RE.match(s): + return s.lower() + # invalid value + logging.warning("Invalid hex color encountered: %r", s) + return "" + + + def parse_colors(csv_text: str) -> Dict[str, Dict[str, Dict[str, Any]]]: + lines = csv_text.splitlines() + reader = csv.DictReader(lines, skipinitialspace=False) + + # Identify header keys we need (tolerate leading/trailing whitespace) + header = reader.fieldnames or [] + ## key_agency = _find_key(header, 'delfiAgencyName') or _find_key(header, ' delfiAgencyName') // left for transition purposes + key_agency = _find_key(header, 'GTFSAgencyName') or _find_key(header, ' GTFSAgencyName') + key_line = _find_key(header, 'lineName') + key_bg = _find_key(header, 'backgroundColor') + key_text = _find_key(header, 'textColor') + key_border = _find_key(header, 'borderColor') + + if not (key_agency and key_line and key_bg and key_text): + logging.error("CSV is missing expected headers. Found: %r", header) + raise ValueError("CSV missing required headers") + + colors: Dict[str, Dict[str, Dict[str, Any]]] = {} + + for row in reader: + agency = (row.get(key_agency) or "").strip() + line_name = (row.get(key_line) or "").strip() + line_name = line_name.replace(" ", "") + background = normalize_hex(row.get(key_bg) or "") + text = normalize_hex(row.get(key_text) or "") + border = normalize_hex(row.get(key_border) or "") + + # Skip rows without a line name or delfi agency + if line_name == "" or agency == "": + continue + + # If background is white or missing, use border color if available, + # since motis only supports background and text colors + if border and (background == "" or background.lower() == "ffffff"): + background = border + text = "ffffff" + + # If any color is still missing, skip this entry + if background == "" or text == "": + logging.warning("Skipping entry for agency %r, line %r due to missing colors", agency, line_name) + continue + + colors.setdefault(agency, {})[line_name] = { + 'color': background, + 'textColor': text + } + + return colors + + + def _escape_lua_string(s: str) -> str: + return s.replace('\\', '\\\\').replace('"', '\\"') + + + def write_lua_table(colors: Dict[str, Dict[str, Dict[str, Any]]], out_path: str) -> None: + logging.info("Writing Lua table to %s", out_path) + dirpath = os.path.dirname(out_path) + if dirpath and not os.path.exists(dirpath): + os.makedirs(dirpath) + + with open(out_path, 'w', encoding='utf-8') as f: + f.write('-- autogenerated by generate_colors.py\n') + f.write('-- SPDX-FileCopyrightText: contributors of https://github.com/Traewelling/line-colors\n') + f.write('-- SPDX-License-Identifier: CC0-1.0\n\n') + f.write('local colors = {\n') + + # Sort agencies for deterministic output + for agency in sorted(colors.keys()): + safe_agency = _escape_lua_string(agency) + f.write(f' ["{safe_agency}"] = {{\n') + for line_name in sorted(colors[agency].keys()): + safe_line = _escape_lua_string(line_name) + info = colors[agency][line_name] + # convert hex string to 0x... numeric literal + bg = info.get('color', '000000') + text = info.get('textColor', '000000') + # ensure 6-digit hex + if len(bg) == 3: + bg = ''.join([c * 2 for c in bg]) + if len(text) == 3: + text = ''.join([c * 2 for c in text]) + + f.write(f' ["{safe_line}"] = {{ color = 0x{bg}, text_color = 0x{text} }},\n') + f.write(' },\n') + + f.write('}\n') + f.write('return colors\n') + + logging.info("Wrote %d agencies to %s", len(colors), out_path) + + + def main(): + logging.basicConfig(level=logging.WARNING, + format='%(levelname)s: %(message)s') + + try: + csv_text = fetch_csv(URL) + colors = parse_colors(csv_text) + write_lua_table(colors, OUTPUT) + except Exception as e: + logging.exception("Failed to generate colors: %s", e) + return 2 + + return 0 + +def SBB(): + #URL = "https://raw.githubusercontent.com/Traewelling/line-colors/refs/heads/main/line-colors-CH.csv" + URL = "https://raw.githubusercontent.com/luna-cant-code/line-colors/refs/heads/feed-transition/line-colors-CH.csv" + OUTPUT = "scripts/ch-opentransport-colors.lua" + + HEX_RE = re.compile(r"^[0-9A-Fa-f]{3}([0-9A-Fa-f]{3})?$") + + + def fetch_csv(url: str) -> str: + logging.info("Fetching CSV from %s", url) + try: + resp = requests.get(url, timeout=15) + resp.raise_for_status() + return resp.text + except requests.RequestException: + logging.exception("Error while fetching CSV from %s", url) + raise + + + def _find_key(row_keys, desired: str): + """Return the actual key in row_keys whose stripped form equals desired. + + This makes the parser tolerant to CSVs that have leading/trailing spaces + in header names (e.g. ' delfiAgencyName'). + """ + for k in row_keys: + if k is not None and k.strip() == desired: + return k + return None + + + def normalize_hex(s: str) -> str: + if s is None: + return "" + s = s.strip().lstrip('#') + if s == "": + return "" + if len(s) == 3 and HEX_RE.match(s): + # expand short form like 'f0c' -> 'ff00cc' + return ''.join([c * 2 for c in s]).lower() + if len(s) == 6 and HEX_RE.match(s): + return s.lower() + # invalid value + logging.warning("Invalid hex color encountered: %r", s) + return "" + + + def parse_colors(csv_text: str) -> Dict[str, Dict[str, Dict[str, Any]]]: + lines = csv_text.splitlines() + reader = csv.DictReader(lines, skipinitialspace=False) + + # Identify header keys we need (tolerate leading/trailing whitespace) + header = reader.fieldnames or [] + ## key_agency = _find_key(header, 'delfiAgencyName') or _find_key(header, ' delfiAgencyName') // Left for transition purposes + key_agency = _find_key(header, 'GTFSAgencyName') or _find_key(header, ' GTFSAgencyName') + key_line = _find_key(header, 'lineName') + key_bg = _find_key(header, 'backgroundColor') + key_text = _find_key(header, 'textColor') + key_border = _find_key(header, 'borderColor') + + if not (key_agency and key_line and key_bg and key_text): + logging.error("CSV is missing expected headers. Found: %r", header) + raise ValueError("CSV missing required headers") + + colors: Dict[str, Dict[str, Dict[str, Any]]] = {} + + for row in reader: + agency = (row.get(key_agency) or "").strip() + line_name = (row.get(key_line) or "").strip() + line_name = line_name.replace(" ", "") + background = normalize_hex(row.get(key_bg) or "") + text = normalize_hex(row.get(key_text) or "") + border = normalize_hex(row.get(key_border) or "") + + # Skip rows without a line name or delfi agency + if line_name == "" or agency == "": + continue + + # If background is white or missing, use border color if available, + # since motis only supports background and text colors + if border and (background == "" or background.lower() == "ffffff"): + background = border + text = "ffffff" + + # If any color is still missing, skip this entry + if background == "" or text == "": + logging.warning("Skipping entry for agency %r, line %r due to missing colors", agency, line_name) + continue + + colors.setdefault(agency, {})[line_name] = { + 'color': background, + 'textColor': text + } + + return colors + + + def _escape_lua_string(s: str) -> str: + return s.replace('\\', '\\\\').replace('"', '\\"') + + + def write_lua_table(colors: Dict[str, Dict[str, Dict[str, Any]]], out_path: str) -> None: + logging.info("Writing Lua table to %s", out_path) + dirpath = os.path.dirname(out_path) + if dirpath and not os.path.exists(dirpath): + os.makedirs(dirpath) + + with open(out_path, 'w', encoding='utf-8') as f: + f.write('-- autogenerated by generate_colors.py\n') + f.write('-- SPDX-FileCopyrightText: contributors of https://github.com/Traewelling/line-colors\n') + f.write('-- SPDX-License-Identifier: CC0-1.0\n\n') + f.write('local colors = {\n') + + # Sort agencies for deterministic output + for agency in sorted(colors.keys()): + safe_agency = _escape_lua_string(agency) + f.write(f' ["{safe_agency}"] = {{\n') + for line_name in sorted(colors[agency].keys()): + safe_line = _escape_lua_string(line_name) + info = colors[agency][line_name] + # convert hex string to 0x... numeric literal + bg = info.get('color', '000000') + text = info.get('textColor', '000000') + # ensure 6-digit hex + if len(bg) == 3: + bg = ''.join([c * 2 for c in bg]) + if len(text) == 3: + text = ''.join([c * 2 for c in text]) + + f.write(f' ["{safe_line}"] = {{ color = 0x{bg}, text_color = 0x{text} }},\n') + f.write(' },\n') + + f.write('}\n') + f.write('return colors\n') + + logging.info("Wrote %d agencies to %s", len(colors), out_path) + + + def main(): + logging.basicConfig(level=logging.WARNING, + format='%(levelname)s: %(message)s') + + try: + csv_text = fetch_csv(URL) + colors = parse_colors(csv_text) + write_lua_table(colors, OUTPUT) + except Exception as e: + logging.exception("Failed to generate colors: %s", e) + return 2 + + return 0 + +def main(): + VBN() + SBB() + +if __name__ == '__main__': + VBN() + SBB() + sys.exit(main()) From b4b4debafbeebbc053b210616d854ce37beaf0ed Mon Sep 17 00:00:00 2001 From: luna-cant-code <223513004+luna-cant-code@users.noreply.github.com> Date: Thu, 4 Dec 2025 12:49:00 +0100 Subject: [PATCH 06/11] hope this works somehow... --- src/generate_colors_CH.py | 3 ++- src/generate_colors_combined.py | 9 ++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/generate_colors_CH.py b/src/generate_colors_CH.py index e8216cb24..d7de0b553 100644 --- a/src/generate_colors_CH.py +++ b/src/generate_colors_CH.py @@ -15,7 +15,8 @@ import requests from typing import Dict, Any -URL = "https://raw.githubusercontent.com/Traewelling/line-colors/refs/heads/main/line-colors-CH.csv" +#URL = "https://raw.githubusercontent.com/Traewelling/line-colors/refs/heads/main/line-colors-CH.csv" +URL = "https://raw.githubusercontent.com/luna-cant-code/line-colors/refs/heads/feed-transition/line-colors-CH.csv" OUTPUT = "scripts/ch-opentransport-colors.lua" HEX_RE = re.compile(r"^[0-9A-Fa-f]{3}([0-9A-Fa-f]{3})?$") diff --git a/src/generate_colors_combined.py b/src/generate_colors_combined.py index e3d8954fc..d366f7cea 100644 --- a/src/generate_colors_combined.py +++ b/src/generate_colors_combined.py @@ -319,11 +319,10 @@ def main(): return 0 -def main(): - VBN() - SBB() - +#def main(): +# VBN() +# SBB() if __name__ == '__main__': VBN() SBB() - sys.exit(main()) + sys.exit(()) From 197b029602df407390c9f8bd253eb914940b663f Mon Sep 17 00:00:00 2001 From: luna-cant-code <223513004+luna-cant-code@users.noreply.github.com> Date: Thu, 4 Dec 2025 13:38:57 +0100 Subject: [PATCH 07/11] Update generate_colors_combined.py --- src/generate_colors_combined.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/generate_colors_combined.py b/src/generate_colors_combined.py index d366f7cea..bb6bb4e1b 100644 --- a/src/generate_colors_combined.py +++ b/src/generate_colors_combined.py @@ -320,9 +320,9 @@ def main(): return 0 #def main(): -# VBN() -# SBB() -if __name__ == '__main__': VBN() SBB() - sys.exit(()) +#if __name__ == '__main__': +# VBN() +# SBB() +# sys.exit(()) From 2e8c2307f02bc07e11cc0ab0e84cb330e87fec36 Mon Sep 17 00:00:00 2001 From: luna-cant-code <223513004+luna-cant-code@users.noreply.github.com> Date: Thu, 4 Dec 2025 18:35:50 +0100 Subject: [PATCH 08/11] did the thing - combined everything and it's working!!!!!!! --- src/generate_colors_VBN.py | 2 +- src/generate_colors_combined.py | 328 -------------------------------- src/generate_colors_pretty.py | 21 ++ 3 files changed, 22 insertions(+), 329 deletions(-) delete mode 100644 src/generate_colors_combined.py create mode 100644 src/generate_colors_pretty.py diff --git a/src/generate_colors_VBN.py b/src/generate_colors_VBN.py index b34e63b33..e9e452a89 100644 --- a/src/generate_colors_VBN.py +++ b/src/generate_colors_VBN.py @@ -15,7 +15,7 @@ import requests from typing import Dict, Any -URL = "https://raw.githubusercontent.com/Traewelling/line-colors/refs/heads/main/line-colors-VBN.csv" +URL = "https://raw.githubusercontent.com/luna-cant-code/line-colors/refs/heads/feed-transition/line-colors-VBN.csv" OUTPUT = "scripts/de-VBN-colors.lua" HEX_RE = re.compile(r"^[0-9A-Fa-f]{3}([0-9A-Fa-f]{3})?$") diff --git a/src/generate_colors_combined.py b/src/generate_colors_combined.py deleted file mode 100644 index bb6bb4e1b..000000000 --- a/src/generate_colors_combined.py +++ /dev/null @@ -1,328 +0,0 @@ -#!/usr/bin/env python3 -# SPDX-FileCopyrightText: Levin Baumann -# -# SPDX-License-Identifier: AGPL-3.0-or-later -# -# generate_colors.py - Generate Lua table of line colors from Traewelling line-colors CSV -# adapted for VBN GTFS feed by luna-cant-code (GitHub) - - -import csv -import logging -import os -import re -import sys -import requests -from typing import Dict, Any - -def VBN(): - #URL = "https://raw.githubusercontent.com/Traewelling/line-colors/refs/heads/main/line-colors-VBN.csv" - URL = "https://raw.githubusercontent.com/luna-cant-code/line-colors/refs/heads/feed-transition/line-colors-VBN.csv" - OUTPUT = "scripts/de-VBN-colors.lua" - - HEX_RE = re.compile(r"^[0-9A-Fa-f]{3}([0-9A-Fa-f]{3})?$") - - - def fetch_csv(url: str) -> str: - logging.info("Fetching CSV from %s", url) - try: - resp = requests.get(url, timeout=15) - resp.raise_for_status() - return resp.text - except requests.RequestException: - logging.exception("Error while fetching CSV from %s", url) - raise - - - def _find_key(row_keys, desired: str): - """Return the actual key in row_keys whose stripped form equals desired. - - This makes the parser tolerant to CSVs that have leading/trailing spaces - in header names (e.g. ' delfiAgencyName'). - """ - for k in row_keys: - if k is not None and k.strip() == desired: - return k - return None - - - def normalize_hex(s: str) -> str: - if s is None: - return "" - s = s.strip().lstrip('#') - if s == "": - return "" - if len(s) == 3 and HEX_RE.match(s): - # expand short form like 'f0c' -> 'ff00cc' - return ''.join([c * 2 for c in s]).lower() - if len(s) == 6 and HEX_RE.match(s): - return s.lower() - # invalid value - logging.warning("Invalid hex color encountered: %r", s) - return "" - - - def parse_colors(csv_text: str) -> Dict[str, Dict[str, Dict[str, Any]]]: - lines = csv_text.splitlines() - reader = csv.DictReader(lines, skipinitialspace=False) - - # Identify header keys we need (tolerate leading/trailing whitespace) - header = reader.fieldnames or [] - ## key_agency = _find_key(header, 'delfiAgencyName') or _find_key(header, ' delfiAgencyName') // left for transition purposes - key_agency = _find_key(header, 'GTFSAgencyName') or _find_key(header, ' GTFSAgencyName') - key_line = _find_key(header, 'lineName') - key_bg = _find_key(header, 'backgroundColor') - key_text = _find_key(header, 'textColor') - key_border = _find_key(header, 'borderColor') - - if not (key_agency and key_line and key_bg and key_text): - logging.error("CSV is missing expected headers. Found: %r", header) - raise ValueError("CSV missing required headers") - - colors: Dict[str, Dict[str, Dict[str, Any]]] = {} - - for row in reader: - agency = (row.get(key_agency) or "").strip() - line_name = (row.get(key_line) or "").strip() - line_name = line_name.replace(" ", "") - background = normalize_hex(row.get(key_bg) or "") - text = normalize_hex(row.get(key_text) or "") - border = normalize_hex(row.get(key_border) or "") - - # Skip rows without a line name or delfi agency - if line_name == "" or agency == "": - continue - - # If background is white or missing, use border color if available, - # since motis only supports background and text colors - if border and (background == "" or background.lower() == "ffffff"): - background = border - text = "ffffff" - - # If any color is still missing, skip this entry - if background == "" or text == "": - logging.warning("Skipping entry for agency %r, line %r due to missing colors", agency, line_name) - continue - - colors.setdefault(agency, {})[line_name] = { - 'color': background, - 'textColor': text - } - - return colors - - - def _escape_lua_string(s: str) -> str: - return s.replace('\\', '\\\\').replace('"', '\\"') - - - def write_lua_table(colors: Dict[str, Dict[str, Dict[str, Any]]], out_path: str) -> None: - logging.info("Writing Lua table to %s", out_path) - dirpath = os.path.dirname(out_path) - if dirpath and not os.path.exists(dirpath): - os.makedirs(dirpath) - - with open(out_path, 'w', encoding='utf-8') as f: - f.write('-- autogenerated by generate_colors.py\n') - f.write('-- SPDX-FileCopyrightText: contributors of https://github.com/Traewelling/line-colors\n') - f.write('-- SPDX-License-Identifier: CC0-1.0\n\n') - f.write('local colors = {\n') - - # Sort agencies for deterministic output - for agency in sorted(colors.keys()): - safe_agency = _escape_lua_string(agency) - f.write(f' ["{safe_agency}"] = {{\n') - for line_name in sorted(colors[agency].keys()): - safe_line = _escape_lua_string(line_name) - info = colors[agency][line_name] - # convert hex string to 0x... numeric literal - bg = info.get('color', '000000') - text = info.get('textColor', '000000') - # ensure 6-digit hex - if len(bg) == 3: - bg = ''.join([c * 2 for c in bg]) - if len(text) == 3: - text = ''.join([c * 2 for c in text]) - - f.write(f' ["{safe_line}"] = {{ color = 0x{bg}, text_color = 0x{text} }},\n') - f.write(' },\n') - - f.write('}\n') - f.write('return colors\n') - - logging.info("Wrote %d agencies to %s", len(colors), out_path) - - - def main(): - logging.basicConfig(level=logging.WARNING, - format='%(levelname)s: %(message)s') - - try: - csv_text = fetch_csv(URL) - colors = parse_colors(csv_text) - write_lua_table(colors, OUTPUT) - except Exception as e: - logging.exception("Failed to generate colors: %s", e) - return 2 - - return 0 - -def SBB(): - #URL = "https://raw.githubusercontent.com/Traewelling/line-colors/refs/heads/main/line-colors-CH.csv" - URL = "https://raw.githubusercontent.com/luna-cant-code/line-colors/refs/heads/feed-transition/line-colors-CH.csv" - OUTPUT = "scripts/ch-opentransport-colors.lua" - - HEX_RE = re.compile(r"^[0-9A-Fa-f]{3}([0-9A-Fa-f]{3})?$") - - - def fetch_csv(url: str) -> str: - logging.info("Fetching CSV from %s", url) - try: - resp = requests.get(url, timeout=15) - resp.raise_for_status() - return resp.text - except requests.RequestException: - logging.exception("Error while fetching CSV from %s", url) - raise - - - def _find_key(row_keys, desired: str): - """Return the actual key in row_keys whose stripped form equals desired. - - This makes the parser tolerant to CSVs that have leading/trailing spaces - in header names (e.g. ' delfiAgencyName'). - """ - for k in row_keys: - if k is not None and k.strip() == desired: - return k - return None - - - def normalize_hex(s: str) -> str: - if s is None: - return "" - s = s.strip().lstrip('#') - if s == "": - return "" - if len(s) == 3 and HEX_RE.match(s): - # expand short form like 'f0c' -> 'ff00cc' - return ''.join([c * 2 for c in s]).lower() - if len(s) == 6 and HEX_RE.match(s): - return s.lower() - # invalid value - logging.warning("Invalid hex color encountered: %r", s) - return "" - - - def parse_colors(csv_text: str) -> Dict[str, Dict[str, Dict[str, Any]]]: - lines = csv_text.splitlines() - reader = csv.DictReader(lines, skipinitialspace=False) - - # Identify header keys we need (tolerate leading/trailing whitespace) - header = reader.fieldnames or [] - ## key_agency = _find_key(header, 'delfiAgencyName') or _find_key(header, ' delfiAgencyName') // Left for transition purposes - key_agency = _find_key(header, 'GTFSAgencyName') or _find_key(header, ' GTFSAgencyName') - key_line = _find_key(header, 'lineName') - key_bg = _find_key(header, 'backgroundColor') - key_text = _find_key(header, 'textColor') - key_border = _find_key(header, 'borderColor') - - if not (key_agency and key_line and key_bg and key_text): - logging.error("CSV is missing expected headers. Found: %r", header) - raise ValueError("CSV missing required headers") - - colors: Dict[str, Dict[str, Dict[str, Any]]] = {} - - for row in reader: - agency = (row.get(key_agency) or "").strip() - line_name = (row.get(key_line) or "").strip() - line_name = line_name.replace(" ", "") - background = normalize_hex(row.get(key_bg) or "") - text = normalize_hex(row.get(key_text) or "") - border = normalize_hex(row.get(key_border) or "") - - # Skip rows without a line name or delfi agency - if line_name == "" or agency == "": - continue - - # If background is white or missing, use border color if available, - # since motis only supports background and text colors - if border and (background == "" or background.lower() == "ffffff"): - background = border - text = "ffffff" - - # If any color is still missing, skip this entry - if background == "" or text == "": - logging.warning("Skipping entry for agency %r, line %r due to missing colors", agency, line_name) - continue - - colors.setdefault(agency, {})[line_name] = { - 'color': background, - 'textColor': text - } - - return colors - - - def _escape_lua_string(s: str) -> str: - return s.replace('\\', '\\\\').replace('"', '\\"') - - - def write_lua_table(colors: Dict[str, Dict[str, Dict[str, Any]]], out_path: str) -> None: - logging.info("Writing Lua table to %s", out_path) - dirpath = os.path.dirname(out_path) - if dirpath and not os.path.exists(dirpath): - os.makedirs(dirpath) - - with open(out_path, 'w', encoding='utf-8') as f: - f.write('-- autogenerated by generate_colors.py\n') - f.write('-- SPDX-FileCopyrightText: contributors of https://github.com/Traewelling/line-colors\n') - f.write('-- SPDX-License-Identifier: CC0-1.0\n\n') - f.write('local colors = {\n') - - # Sort agencies for deterministic output - for agency in sorted(colors.keys()): - safe_agency = _escape_lua_string(agency) - f.write(f' ["{safe_agency}"] = {{\n') - for line_name in sorted(colors[agency].keys()): - safe_line = _escape_lua_string(line_name) - info = colors[agency][line_name] - # convert hex string to 0x... numeric literal - bg = info.get('color', '000000') - text = info.get('textColor', '000000') - # ensure 6-digit hex - if len(bg) == 3: - bg = ''.join([c * 2 for c in bg]) - if len(text) == 3: - text = ''.join([c * 2 for c in text]) - - f.write(f' ["{safe_line}"] = {{ color = 0x{bg}, text_color = 0x{text} }},\n') - f.write(' },\n') - - f.write('}\n') - f.write('return colors\n') - - logging.info("Wrote %d agencies to %s", len(colors), out_path) - - - def main(): - logging.basicConfig(level=logging.WARNING, - format='%(levelname)s: %(message)s') - - try: - csv_text = fetch_csv(URL) - colors = parse_colors(csv_text) - write_lua_table(colors, OUTPUT) - except Exception as e: - logging.exception("Failed to generate colors: %s", e) - return 2 - - return 0 - -#def main(): - VBN() - SBB() -#if __name__ == '__main__': -# VBN() -# SBB() -# sys.exit(()) diff --git a/src/generate_colors_pretty.py b/src/generate_colors_pretty.py new file mode 100644 index 000000000..003c528cb --- /dev/null +++ b/src/generate_colors_pretty.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python3 +# SPDX-FileCopyrightText: Levin Baumann +# +# SPDX-License-Identifier: AGPL-3.0-or-later +# +# generate_colors.py - Generate Lua table of line colors from Traewelling line-colors CSV + +import sys + +# Import already written scripts as modules +import generate_colors_CH +import generate_colors_VBN + +# Telling Python to do these sequentially. +def main(): + generate_colors_CH.main() + generate_colors_VBN.main() + +# Don't know what that does, but it makes it work. +if __name__ == "__main__": + main() From affe9132220f88f623f858ff4ce1c94d66b2ba43 Mon Sep 17 00:00:00 2001 From: luna-cant-code <223513004+luna-cant-code@users.noreply.github.com> Date: Thu, 4 Dec 2025 18:49:45 +0100 Subject: [PATCH 09/11] adjusted scripts a tiny bit --- scripts/ch-opentransport-colors.lua | 251 ++++++++++++++ scripts/de-VBN-colors.lua | 328 ++++++++++++++++++ ...pretty.py => generate_all_DACH_colours.py} | 4 +- src/generate_colors_CH.py | 1 - 4 files changed, 582 insertions(+), 2 deletions(-) rename src/{generate_colors_pretty.py => generate_all_DACH_colours.py} (86%) diff --git a/scripts/ch-opentransport-colors.lua b/scripts/ch-opentransport-colors.lua index e69de29bb..981fc6266 100644 --- a/scripts/ch-opentransport-colors.lua +++ b/scripts/ch-opentransport-colors.lua @@ -0,0 +1,251 @@ +-- autogenerated by generate_colors.py +-- SPDX-FileCopyrightText: contributors of https://github.com/Traewelling/line-colors +-- SPDX-License-Identifier: CC0-1.0 + +local colors = { + ["Appenzeller Bahnen"] = { + ["S15"] = { color = 0x845534, text_color = 0xffffff }, + ["S20"] = { color = 0xb6522b, text_color = 0xffffff }, + ["S21"] = { color = 0x00908c, text_color = 0xffffff }, + ["S22"] = { color = 0xb80e80, text_color = 0xffffff }, + ["S23"] = { color = 0xc99115, text_color = 0xffffff }, + ["S24"] = { color = 0x3aaa35, text_color = 0xffffff }, + ["S25"] = { color = 0x72a8db, text_color = 0xffffff }, + ["S26"] = { color = 0xb85f5c, text_color = 0xffffff }, + }, + ["Autobus AG Liestal"] = { + ["70"] = { color = 0xffdd00, text_color = 0x000000 }, + ["71"] = { color = 0x95c11f, text_color = 0xffffff }, + ["72"] = { color = 0x5a6f85, text_color = 0xffffff }, + ["74"] = { color = 0xa36009, text_color = 0xffffff }, + ["75"] = { color = 0x7b77b6, text_color = 0xffffff }, + ["76"] = { color = 0x00a7a6, text_color = 0xffffff }, + ["78"] = { color = 0xf39200, text_color = 0x000000 }, + ["80"] = { color = 0xe4032e, text_color = 0xffffff }, + ["81"] = { color = 0xf088b6, text_color = 0x000000 }, + ["82"] = { color = 0x13a538, text_color = 0xffffff }, + ["83"] = { color = 0x0094d2, text_color = 0xffffff }, + }, + ["Automobildienst Appenzeller Bahnen"] = { + ["841"] = { color = 0x000000, text_color = 0xffffff }, + }, + ["BLS AG (bls)"] = { + ["S1"] = { color = 0x50b447, text_color = 0xffffff }, + ["S2"] = { color = 0x1cb1e6, text_color = 0xffffff }, + ["S3"] = { color = 0x8868b3, text_color = 0xffffff }, + ["S31"] = { color = 0xb0aa38, text_color = 0xffffff }, + ["S4"] = { color = 0x53c4af, text_color = 0xffffff }, + ["S44"] = { color = 0x646026, text_color = 0xffffff }, + ["S5"] = { color = 0x881c3f, text_color = 0xffffff }, + ["S51"] = { color = 0x9cc843, text_color = 0xffffff }, + ["S52"] = { color = 0xf7cf39, text_color = 0xffffff }, + ["S6"] = { color = 0x0165b6, text_color = 0xffffff }, + ["S7"] = { color = 0x73c0e8, text_color = 0xffffff }, + ["S77"] = { color = 0x7a84c4, text_color = 0xffffff }, + }, + ["Baselland Transport"] = { + ["10"] = { color = 0xfec800, text_color = 0x000000 }, + ["105"] = { color = 0xbec2c3, text_color = 0x000000 }, + ["106"] = { color = 0xbec2c3, text_color = 0x000000 }, + ["107"] = { color = 0xbec2c3, text_color = 0x000000 }, + ["108"] = { color = 0xbec2c3, text_color = 0x000000 }, + ["109"] = { color = 0xbec2c3, text_color = 0x000000 }, + ["11"] = { color = 0xe7000e, text_color = 0xffffff }, + ["110"] = { color = 0xbec2c3, text_color = 0x000000 }, + ["17"] = { color = 0x00a1e5, text_color = 0xffffff }, + ["19"] = { color = 0x7c217d, text_color = 0xffffff }, + ["37"] = { color = 0xcfd0d0, text_color = 0x000000 }, + ["47"] = { color = 0xadafaf, text_color = 0x000000 }, + ["58"] = { color = 0xadafaf, text_color = 0x000000 }, + ["59"] = { color = 0xadafaf, text_color = 0x000000 }, + ["60"] = { color = 0xcfd0d0, text_color = 0x000000 }, + ["61"] = { color = 0xadafaf, text_color = 0x000000 }, + ["62"] = { color = 0xadafaf, text_color = 0x000000 }, + ["64"] = { color = 0xcfd0d0, text_color = 0x000000 }, + ["65"] = { color = 0xadafaf, text_color = 0x000000 }, + ["66"] = { color = 0xadafaf, text_color = 0x000000 }, + ["92"] = { color = 0xbec2c3, text_color = 0x000000 }, + ["93"] = { color = 0xbec2c3, text_color = 0x000000 }, + ["E11"] = { color = 0xe7000e, text_color = 0xffffff }, + }, + ["Basler Verkehrsbetriebe"] = { + ["1"] = { color = 0x7c4425, text_color = 0xffffff }, + ["14"] = { color = 0xf17900, text_color = 0xffffff }, + ["15"] = { color = 0x00943d, text_color = 0xffffff }, + ["16"] = { color = 0xa6c700, text_color = 0x000000 }, + ["2"] = { color = 0xa47e42, text_color = 0xffffff }, + ["21"] = { color = 0x00a192, text_color = 0xffffff }, + ["3"] = { color = 0x364093, text_color = 0xffffff }, + ["30"] = { color = 0xadafaf, text_color = 0x000000 }, + ["31"] = { color = 0xadafaf, text_color = 0x000000 }, + ["32"] = { color = 0xadafaf, text_color = 0x000000 }, + ["33"] = { color = 0xcfd0d0, text_color = 0x000000 }, + ["34"] = { color = 0xadafaf, text_color = 0x000000 }, + ["35"] = { color = 0xcfd0d0, text_color = 0x000000 }, + ["36"] = { color = 0xadafaf, text_color = 0x000000 }, + ["38"] = { color = 0xcfd0d0, text_color = 0x000000 }, + ["42"] = { color = 0xcfd0d0, text_color = 0x000000 }, + ["45"] = { color = 0xadafaf, text_color = 0x000000 }, + ["46"] = { color = 0xcfd0d0, text_color = 0x000000 }, + ["47"] = { color = 0xcfd0d0, text_color = 0x000000 }, + ["48"] = { color = 0xadafaf, text_color = 0x000000 }, + ["50"] = { color = 0xcfd0d0, text_color = 0x000000 }, + ["6"] = { color = 0x0068b2, text_color = 0xffffff }, + ["8"] = { color = 0xed6aa4, text_color = 0xffffff }, + }, + ["Funiculaire Neuchâtel-Université - Neuchâtel-Gare"] = { + ["110"] = { color = 0x7dcdbe, text_color = 0xffffff }, + }, + ["PostAuto AG"] = { + ["100"] = { color = 0xffcc00, text_color = 0x000000 }, + ["101"] = { color = 0xffcc00, text_color = 0x000000 }, + ["102"] = { color = 0xffcc00, text_color = 0x000000 }, + ["103"] = { color = 0xffcc00, text_color = 0x000000 }, + ["104"] = { color = 0xffcc00, text_color = 0x000000 }, + ["111"] = { color = 0xffcc00, text_color = 0x000000 }, + ["112"] = { color = 0xffcc00, text_color = 0x000000 }, + ["113"] = { color = 0xffcc00, text_color = 0x000000 }, + ["114"] = { color = 0xffcc00, text_color = 0x000000 }, + ["115"] = { color = 0xffcc00, text_color = 0x000000 }, + ["116"] = { color = 0xffcc00, text_color = 0x000000 }, + ["117"] = { color = 0xffcc00, text_color = 0x000000 }, + ["118"] = { color = 0xffcc00, text_color = 0x000000 }, + ["119"] = { color = 0xffcc00, text_color = 0x000000 }, + ["133"] = { color = 0xffcc00, text_color = 0x000000 }, + ["134"] = { color = 0xffcc00, text_color = 0x000000 }, + ["135"] = { color = 0xffcc00, text_color = 0x000000 }, + ["136"] = { color = 0xffcc00, text_color = 0x000000 }, + ["137"] = { color = 0xffcc00, text_color = 0x000000 }, + ["139"] = { color = 0xffcc00, text_color = 0x000000 }, + ["141"] = { color = 0xffcc00, text_color = 0x000000 }, + ["142"] = { color = 0xffcc00, text_color = 0x000000 }, + ["143"] = { color = 0xffcc00, text_color = 0x000000 }, + ["144"] = { color = 0xffcc00, text_color = 0x000000 }, + ["149"] = { color = 0xffcc00, text_color = 0x000000 }, + ["67"] = { color = 0xffcc00, text_color = 0x000000 }, + ["68"] = { color = 0xffcc00, text_color = 0x000000 }, + ["69"] = { color = 0xffcc00, text_color = 0x000000 }, + ["73"] = { color = 0xffcc00, text_color = 0x000000 }, + ["77"] = { color = 0xffcc00, text_color = 0x000000 }, + ["84"] = { color = 0xffcc00, text_color = 0x000000 }, + ["85"] = { color = 0xffcc00, text_color = 0x000000 }, + ["86"] = { color = 0xffcc00, text_color = 0x000000 }, + ["88"] = { color = 0xffcc00, text_color = 0x000000 }, + ["89"] = { color = 0xffcc00, text_color = 0x000000 }, + ["90"] = { color = 0xffcc00, text_color = 0x000000 }, + ["94"] = { color = 0xffcc00, text_color = 0x000000 }, + ["99"] = { color = 0xffcc00, text_color = 0x000000 }, + }, + ["Rhätische Bahn"] = { + ["IR38"] = { color = 0xea8c00, text_color = 0xffffff }, + ["R15"] = { color = 0xc80205, text_color = 0xffffff }, + ["R16"] = { color = 0x438bc3, text_color = 0xffffff }, + ["R19"] = { color = 0xa2bb04, text_color = 0xffffff }, + ["RE1"] = { color = 0x25a9aa, text_color = 0xffffff }, + ["RE13"] = { color = 0x25a9aa, text_color = 0xffffff }, + ["RE2"] = { color = 0xa97400, text_color = 0xffffff }, + ["RE24"] = { color = 0xa97400, text_color = 0xffffff }, + ["RE3"] = { color = 0x25a9aa, text_color = 0xffffff }, + ["RE4"] = { color = 0xa97400, text_color = 0xffffff }, + ["RE6"] = { color = 0x00549d, text_color = 0xffffff }, + ["RE7"] = { color = 0x941680, text_color = 0xffffff }, + ["RE8"] = { color = 0x683419, text_color = 0xffffff }, + ["RE9"] = { color = 0x008a39, text_color = 0xffffff }, + ["S1"] = { color = 0xd40074, text_color = 0xffffff }, + ["S2"] = { color = 0xe8ac00, text_color = 0xffffff }, + }, + ["Schweizerische Bundesbahnen SBB"] = { + ["S1"] = { color = 0x1bb04d, text_color = 0xffffff }, + ["S2"] = { color = 0xf93f27, text_color = 0xffffff }, + ["S3"] = { color = 0xfe7d25, text_color = 0xffffff }, + ["S9"] = { color = 0xa3cf45, text_color = 0xffffff }, + ["S99"] = { color = 0x95b15e, text_color = 0xffffff }, + }, + ["Service d'automobiles TRN (vr)"] = { + ["422"] = { color = 0xd682b5, text_color = 0xffffff }, + ["423"] = { color = 0x00854c, text_color = 0xffffff }, + ["425"] = { color = 0xe6007e, text_color = 0xffffff }, + ["426"] = { color = 0x4696d2, text_color = 0xffffff }, + ["590"] = { color = 0xe30613, text_color = 0xffffff }, + ["591"] = { color = 0x00854c, text_color = 0xffffff }, + }, + ["Transports Publics Neuchâtelois SA"] = { + ["111"] = { color = 0xd7e141, text_color = 0x000000 }, + ["112"] = { color = 0x009155, text_color = 0xffffff }, + }, + ["Transports Publics Neuchâtelois SA (cmn)"] = { + ["R15"] = { color = 0x7dcdbe, text_color = 0x000000 }, + ["R22"] = { color = 0x78af41, text_color = 0xffffff }, + ["R24"] = { color = 0xd282b4, text_color = 0xffffff }, + }, + ["Transports Publics Neuchâtelois SA (rvt)"] = { + ["R21"] = { color = 0x912891, text_color = 0xffffff }, + }, + ["Transports Publics Neuchâtelois SA (tc)"] = { + ["301"] = { color = 0x312783, text_color = 0xffffff }, + ["302"] = { color = 0xe30613, text_color = 0xffffff }, + ["303"] = { color = 0xdedd26, text_color = 0x000000 }, + ["304"] = { color = 0x00854c, text_color = 0xffffff }, + ["310"] = { color = 0xd682b5, text_color = 0xffffff }, + ["311"] = { color = 0xef7d00, text_color = 0xffffff }, + ["312"] = { color = 0x951b81, text_color = 0xffffff }, + ["341"] = { color = 0x423e8d, text_color = 0xffffff }, + ["342"] = { color = 0xe30613, text_color = 0xffffff }, + ["343"] = { color = 0x912891, text_color = 0xffffff }, + ["352"] = { color = 0xe30613, text_color = 0xffffff }, + ["353"] = { color = 0xdedd26, text_color = 0x000000 }, + ["354"] = { color = 0x00854c, text_color = 0xffffff }, + ["360"] = { color = 0x4a96d2, text_color = 0xffffff }, + ["361"] = { color = 0x8acbc1, text_color = 0x000000 }, + ["370"] = { color = 0xe6007e, text_color = 0xffffff }, + }, + ["Transports Publics Neuchâtelois SA (tn)"] = { + ["101"] = { color = 0x312783, text_color = 0xffffff }, + ["102"] = { color = 0x4a96d2, text_color = 0xffffff }, + ["106"] = { color = 0xd682b5, text_color = 0xffffff }, + ["107"] = { color = 0xe30613, text_color = 0xffffff }, + ["108"] = { color = 0x00854c, text_color = 0xffffff }, + ["109"] = { color = 0x951b81, text_color = 0xffffff }, + ["120"] = { color = 0xef7d00, text_color = 0xffffff }, + ["121"] = { color = 0x95c11f, text_color = 0xffffff }, + ["122"] = { color = 0x8acbc1, text_color = 0x000000 }, + ["421"] = { color = 0xdedd26, text_color = 0x000000 }, + }, + ["Verkehrsbetrieb LIECHTENSTEINmobil"] = { + ["11"] = { color = 0xfdc300, text_color = 0x000000 }, + ["12"] = { color = 0x283583, text_color = 0xffffff }, + ["12E"] = { color = 0x6e6ba9, text_color = 0xffffff }, + ["13"] = { color = 0x3fa535, text_color = 0xffffff }, + ["13E"] = { color = 0x3fa535, text_color = 0xffffff }, + ["14"] = { color = 0xcd1719, text_color = 0xffffff }, + ["21"] = { color = 0x007a8c, text_color = 0xffffff }, + ["22"] = { color = 0x6fa8b3, text_color = 0xffffff }, + ["24"] = { color = 0x0095db, text_color = 0xffffff }, + ["26"] = { color = 0xf39200, text_color = 0xffffff }, + ["31"] = { color = 0xed6a5b, text_color = 0xffffff }, + ["32"] = { color = 0xa41753, text_color = 0xffffff }, + ["33"] = { color = 0x944127, text_color = 0xffffff }, + ["35"] = { color = 0xc7b649, text_color = 0xffffff }, + ["36E"] = { color = 0x9e1981, text_color = 0xffffff }, + ["37"] = { color = 0x4a5da7, text_color = 0xffffff }, + ["38"] = { color = 0x4d3078, text_color = 0xffffff }, + ["40"] = { color = 0x7b6a58, text_color = 0xffffff }, + ["44"] = { color = 0xbdbcbc, text_color = 0xffffff }, + ["46"] = { color = 0x35434f, text_color = 0xffffff }, + ["48"] = { color = 0x8b696b, text_color = 0xffffff }, + ["B"] = { color = 0xe64d33, text_color = 0xffffff }, + ["C"] = { color = 0x666666, text_color = 0xffffff }, + ["N1"] = { color = 0x6f6352, text_color = 0xffffff }, + ["N2"] = { color = 0xe64d33, text_color = 0xffffff }, + ["N3"] = { color = 0x80b333, text_color = 0xffffff }, + ["N4"] = { color = 0x666666, text_color = 0xffffff }, + }, + ["Zentralbahn"] = { + ["S4"] = { color = 0xaa2a3f, text_color = 0xffffff }, + ["S41"] = { color = 0x055d80, text_color = 0xffffff }, + ["S44"] = { color = 0xd35d68, text_color = 0xffffff }, + ["S5"] = { color = 0xfb47a3, text_color = 0xffffff }, + ["S55"] = { color = 0xfc87bf, text_color = 0xffffff }, + }, +} +return colors diff --git a/scripts/de-VBN-colors.lua b/scripts/de-VBN-colors.lua index e69de29bb..b089ef705 100644 --- a/scripts/de-VBN-colors.lua +++ b/scripts/de-VBN-colors.lua @@ -0,0 +1,328 @@ +-- autogenerated by generate_colors.py +-- SPDX-FileCopyrightText: contributors of https://github.com/Traewelling/line-colors +-- SPDX-License-Identifier: CC0-1.0 + +local colors = { + ["Braunschweiger Verkehrs-GmbH"] = { + ["1"] = { color = 0xe2000a, text_color = 0xffffff }, + ["10"] = { color = 0xe2000a, text_color = 0xffffff }, + ["1E"] = { color = 0xe2000a, text_color = 0xffffff }, + ["2"] = { color = 0x93c019, text_color = 0xffffff }, + ["2E"] = { color = 0x93c019, text_color = 0xffffff }, + ["3"] = { color = 0x006430, text_color = 0xffffff }, + ["3E"] = { color = 0x006430, text_color = 0xffffff }, + ["4"] = { color = 0x009ee2, text_color = 0xffffff }, + ["411"] = { color = 0xb1a85c, text_color = 0xffffff }, + ["412"] = { color = 0x009ee2, text_color = 0xffffff }, + ["413"] = { color = 0x00953e, text_color = 0xffffff }, + ["414"] = { color = 0x5ac5f1, text_color = 0xffffff }, + ["416"] = { color = 0xf39100, text_color = 0xffffff }, + ["417"] = { color = 0x9b9c9c, text_color = 0xffffff }, + ["418"] = { color = 0xd35c9e, text_color = 0xffffff }, + ["419"] = { color = 0x0068b3, text_color = 0xffffff }, + ["420"] = { color = 0x6e6e6d, text_color = 0xffffff }, + ["421"] = { color = 0xc14d96, text_color = 0xffffff }, + ["422"] = { color = 0x9b0600, text_color = 0xffffff }, + ["423"] = { color = 0x9b0600, text_color = 0xffffff }, + ["424"] = { color = 0xe0b500, text_color = 0xffffff }, + ["426"] = { color = 0x804796, text_color = 0xffffff }, + ["427"] = { color = 0x70ba6e, text_color = 0xffffff }, + ["430"] = { color = 0x6e6e6d, text_color = 0xffffff }, + ["431"] = { color = 0xebc56b, text_color = 0xffffff }, + ["433"] = { color = 0xec6da6, text_color = 0xffffff }, + ["434"] = { color = 0xa20600, text_color = 0xffffff }, + ["435"] = { color = 0xe2000a, text_color = 0xffffff }, + ["436"] = { color = 0x0f3f93, text_color = 0xffffff }, + ["437"] = { color = 0x9b9c9c, text_color = 0xffffff }, + ["445"] = { color = 0x8bbd1d, text_color = 0xffffff }, + ["450"] = { color = 0x6e6e6d, text_color = 0xffffff }, + ["454"] = { color = 0xffd000, text_color = 0xffffff }, + ["455"] = { color = 0x9b9c9c, text_color = 0xffffff }, + ["464"] = { color = 0x9b9c9c, text_color = 0xffffff }, + ["465"] = { color = 0xe94d33, text_color = 0xffffff }, + ["466"] = { color = 0xe94d33, text_color = 0xffffff }, + ["471"] = { color = 0x23318a, text_color = 0xffffff }, + ["480"] = { color = 0x6e6e6d, text_color = 0xffffff }, + ["481"] = { color = 0x9b9c9c, text_color = 0xffffff }, + ["482"] = { color = 0x8bbd1d, text_color = 0xffffff }, + ["4E"] = { color = 0x009ee2, text_color = 0xffffff }, + ["5"] = { color = 0xf39100, text_color = 0xffffff }, + ["5E"] = { color = 0xf39100, text_color = 0xffffff }, + }, + ["Bremer Straßenbahn AG"] = { + ["1"] = { color = 0x00a54f, text_color = 0xffffff }, + ["10"] = { color = 0x15258e, text_color = 0xffffff }, + ["14"] = { color = 0x8bc63e, text_color = 0xffffff }, + ["1E"] = { color = 0x00a54f, text_color = 0xffffff }, + ["1S"] = { color = 0x00a54f, text_color = 0xffffff }, + ["2"] = { color = 0x0166b3, text_color = 0xffffff }, + ["20"] = { color = 0x8bc63e, text_color = 0xffffff }, + ["21"] = { color = 0x00aeef, text_color = 0xffffff }, + ["22"] = { color = 0xa69dcd, text_color = 0xffffff }, + ["24"] = { color = 0x951b81, text_color = 0xffffff }, + ["25"] = { color = 0x009640, text_color = 0xffffff }, + ["26"] = { color = 0xe30613, text_color = 0xffffff }, + ["27"] = { color = 0xef7d00, text_color = 0xffffff }, + ["28"] = { color = 0xffcc00, text_color = 0x000000 }, + ["29"] = { color = 0x95c11f, text_color = 0xffffff }, + ["3"] = { color = 0x00aeef, text_color = 0xffffff }, + ["31"] = { color = 0x95c11f, text_color = 0xffffff }, + ["33"] = { color = 0xffcc00, text_color = 0x000000 }, + ["34"] = { color = 0xffcc00, text_color = 0x000000 }, + ["37"] = { color = 0x951b81, text_color = 0xffffff }, + ["38"] = { color = 0xffcc00, text_color = 0x000000 }, + ["39"] = { color = 0xffcc00, text_color = 0x000000 }, + ["4"] = { color = 0xee1d23, text_color = 0xffffff }, + ["40"] = { color = 0xe30613, text_color = 0xffffff }, + ["41"] = { color = 0xe30613, text_color = 0xffffff }, + ["41S"] = { color = 0xe30613, text_color = 0xffffff }, + ["42"] = { color = 0xffcc00, text_color = 0x000000 }, + ["44"] = { color = 0xef7d00, text_color = 0xffffff }, + ["4S"] = { color = 0xee1d23, text_color = 0xffffff }, + ["5"] = { color = 0x00aab8, text_color = 0xffffff }, + ["52"] = { color = 0x94c01f, text_color = 0xffffff }, + ["55"] = { color = 0xffcc00, text_color = 0x000000 }, + ["57"] = { color = 0xef7d00, text_color = 0xffffff }, + ["58"] = { color = 0xef7d00, text_color = 0xffffff }, + ["5S"] = { color = 0x00aab8, text_color = 0xffffff }, + ["6"] = { color = 0xfeca0a, text_color = 0x000000 }, + ["61"] = { color = 0x009fe3, text_color = 0xffffff }, + ["62"] = { color = 0x009640, text_color = 0xffffff }, + ["63"] = { color = 0x312783, text_color = 0xffffff }, + ["63S"] = { color = 0x312783, text_color = 0xffffff }, + ["65"] = { color = 0x94c01f, text_color = 0xffffff }, + ["66"] = { color = 0x94c01f, text_color = 0xffffff }, + ["6E"] = { color = 0xfeca0a, text_color = 0x000000 }, + ["8"] = { color = 0x8bc63e, text_color = 0xffffff }, + ["80"] = { color = 0x94c01f, text_color = 0xffffff }, + ["81"] = { color = 0x009640, text_color = 0xffffff }, + ["82"] = { color = 0xef7d00, text_color = 0xffffff }, + ["90"] = { color = 0x312783, text_color = 0xffffff }, + ["91"] = { color = 0x009fe3, text_color = 0xffffff }, + ["92"] = { color = 0x009fe3, text_color = 0xffffff }, + ["93"] = { color = 0xffcc00, text_color = 0x000000 }, + ["94"] = { color = 0xe30613, text_color = 0xffffff }, + ["95"] = { color = 0xef7d00, text_color = 0xffffff }, + ["96"] = { color = 0x951b81, text_color = 0xffffff }, + ["98"] = { color = 0x009640, text_color = 0xffffff }, + }, + ["HarzBus GbR"] = { + ["650"] = { color = 0x9f5292, text_color = 0xffffff }, + ["655"] = { color = 0x42aa61, text_color = 0xffffff }, + ["810"] = { color = 0xca1413, text_color = 0xffffff }, + ["821"] = { color = 0x846fac, text_color = 0xffffff }, + ["822"] = { color = 0xed760b, text_color = 0xffffff }, + ["830"] = { color = 0x9a246c, text_color = 0xffffff }, + ["831"] = { color = 0x009eb5, text_color = 0xffffff }, + ["832"] = { color = 0x663904, text_color = 0xffffff }, + ["833"] = { color = 0x005ca1, text_color = 0xffffff }, + ["834"] = { color = 0x005ca1, text_color = 0xffffff }, + ["836"] = { color = 0x78348a, text_color = 0xffffff }, + ["840"] = { color = 0x005a9f, text_color = 0xffffff }, + ["841"] = { color = 0x007e3b, text_color = 0xffffff }, + ["850"] = { color = 0x9271ae, text_color = 0xffffff }, + ["851"] = { color = 0x895079, text_color = 0xffffff }, + ["852"] = { color = 0x975500, text_color = 0xffffff }, + ["860"] = { color = 0x007e3b, text_color = 0xffffff }, + ["861"] = { color = 0x975500, text_color = 0xffffff }, + }, + ["Kraftverkehrsgesellschaft mbH Braunschweig"] = { + ["360"] = { color = 0xffffff, text_color = 0xb5579a }, + ["370"] = { color = 0xffffff, text_color = 0xe61381 }, + ["371"] = { color = 0xffffff, text_color = 0xfadd04 }, + ["372"] = { color = 0xffffff, text_color = 0xc8c8cc }, + ["380"] = { color = 0xffffff, text_color = 0xfadd04 }, + ["381"] = { color = 0xffffff, text_color = 0xb9cd29 }, + ["382"] = { color = 0xffffff, text_color = 0x9b2425 }, + ["383"] = { color = 0xffffff, text_color = 0x00a0e1 }, + ["384"] = { color = 0xffffff, text_color = 0x008640 }, + ["385"] = { color = 0xffffff, text_color = 0xbe7e20 }, + ["386"] = { color = 0xffffff, text_color = 0xbdddd0 }, + ["387"] = { color = 0xffffff, text_color = 0xe61381 }, + ["388"] = { color = 0xffffff, text_color = 0xfadd04 }, + ["390"] = { color = 0xffffff, text_color = 0xf1a1bc }, + ["391"] = { color = 0xffffff, text_color = 0xe11d25 }, + ["392"] = { color = 0xffffff, text_color = 0x0854a1 }, + ["393"] = { color = 0xffffff, text_color = 0xe11d25 }, + ["394"] = { color = 0xffffff, text_color = 0xf4981b }, + ["395"] = { color = 0xffffff, text_color = 0xb5579a }, + ["396"] = { color = 0xffffff, text_color = 0x3c3386 }, + ["397"] = { color = 0xffffff, text_color = 0xb9cd29 }, + ["398"] = { color = 0xffffff, text_color = 0x008640 }, + ["399"] = { color = 0xffffff, text_color = 0x008640 }, + ["601"] = { color = 0xffffff, text_color = 0xec1f25 }, + ["602"] = { color = 0xffffff, text_color = 0xec1f25 }, + ["603"] = { color = 0xffffff, text_color = 0x00adef }, + ["604"] = { color = 0xffffff, text_color = 0x6ab145 }, + ["606"] = { color = 0xffffff, text_color = 0xf48221 }, + ["607"] = { color = 0xffffff, text_color = 0xa868ab }, + ["608"] = { color = 0xffffff, text_color = 0xea028c }, + ["609"] = { color = 0xffffff, text_color = 0xea028c }, + ["610"] = { color = 0xffffff, text_color = 0xf48221 }, + ["611"] = { color = 0xffffff, text_color = 0x2c3192 }, + ["612"] = { color = 0xffffff, text_color = 0xf5d90e }, + ["613"] = { color = 0xffffff, text_color = 0xb66f35 }, + ["614"] = { color = 0xffffff, text_color = 0xb1345b }, + ["615"] = { color = 0xffffff, text_color = 0x007236 }, + ["616"] = { color = 0xffffff, text_color = 0xf499a4 }, + ["618"] = { color = 0xffffff, text_color = 0x01b9be }, + ["619"] = { color = 0xffffff, text_color = 0x772b90 }, + ["620"] = { color = 0xffffff, text_color = 0x006cb8 }, + ["621"] = { color = 0xffffff, text_color = 0x7e8285 }, + ["626"] = { color = 0xffffff, text_color = 0x7e8285 }, + ["627"] = { color = 0xffffff, text_color = 0x7e8285 }, + ["628"] = { color = 0xffffff, text_color = 0x7e8285 }, + ["630"] = { color = 0xffffff, text_color = 0x00a551 }, + ["640"] = { color = 0xffffff, text_color = 0x009183 }, + ["710"] = { color = 0xffffff, text_color = 0xf6d68f }, + ["740"] = { color = 0xffffff, text_color = 0xf59031 }, + ["750"] = { color = 0xffffff, text_color = 0xfab15d }, + ["790"] = { color = 0xffffff, text_color = 0xfbc335 }, + ["791"] = { color = 0xffffff, text_color = 0xb1d23d }, + ["792"] = { color = 0xffffff, text_color = 0x6cbf5b }, + ["793"] = { color = 0xffffff, text_color = 0x00b3bd }, + ["794"] = { color = 0xffffff, text_color = 0x2993d1 }, + ["795"] = { color = 0xffffff, text_color = 0x50b7e8 }, + ["796"] = { color = 0xffffff, text_color = 0x146b8b }, + ["797"] = { color = 0xffffff, text_color = 0x778ec8 }, + ["799"] = { color = 0xffffff, text_color = 0x72ccd4 }, + ["820"] = { color = 0xffffff, text_color = 0x00a551 }, + ["871"] = { color = 0xffffff, text_color = 0x00adef }, + ["873"] = { color = 0xffffff, text_color = 0xf9a61b }, + ["874"] = { color = 0xffffff, text_color = 0xeb106e }, + ["875"] = { color = 0xffffff, text_color = 0x9d005e }, + ["879"] = { color = 0xffffff, text_color = 0xec1f25 }, + }, + ["NordWestBahn"] = { + ["RS1"] = { color = 0x00448b, text_color = 0xffffff }, + ["RS2"] = { color = 0xe89023, text_color = 0xffffff }, + ["RS3"] = { color = 0x93bf30, text_color = 0xffffff }, + ["RS30"] = { color = 0x4faf3b, text_color = 0xffffff }, + ["RS4"] = { color = 0xe2000b, text_color = 0xffffff }, + ["RS6"] = { color = 0x899bb9, text_color = 0xffffff }, + }, + ["Stadtbus Goslar GmbH"] = { + ["801"] = { color = 0xfc9400, text_color = 0xffffff }, + ["802"] = { color = 0xac2f8a, text_color = 0xffffff }, + ["803"] = { color = 0x0aa2e3, text_color = 0xffffff }, + ["804"] = { color = 0x292174, text_color = 0xffffff }, + ["805"] = { color = 0x735c30, text_color = 0xffffff }, + ["806"] = { color = 0x0a6031, text_color = 0xffffff }, + }, + ["Verkehrsbetriebe Bachstein"] = { + ["151"] = { color = 0x009de2, text_color = 0xffffff }, + ["153"] = { color = 0xe20715, text_color = 0xffffff }, + ["160"] = { color = 0x009340, text_color = 0xffffff }, + ["161"] = { color = 0x312681, text_color = 0xffffff }, + ["162"] = { color = 0xf09100, text_color = 0xffffff }, + ["163"] = { color = 0xe5007c, text_color = 0xffffff }, + ["165"] = { color = 0xdfdb00, text_color = 0xffffff }, + ["335"] = { color = 0x94be1f, text_color = 0xffffff }, + ["650"] = { color = 0xa05292, text_color = 0xffffff }, + ["656"] = { color = 0x28225c, text_color = 0xffffff }, + ["658"] = { color = 0xe5213d, text_color = 0xffffff }, + ["660"] = { color = 0xf39200, text_color = 0xffffff }, + ["750"] = { color = 0xe2000e, text_color = 0xffffff }, + ["751"] = { color = 0x2e2482, text_color = 0xffffff }, + ["752"] = { color = 0x00953f, text_color = 0xffffff }, + ["753"] = { color = 0x35a9e0, text_color = 0xffffff }, + ["754"] = { color = 0xf39100, text_color = 0xffffff }, + ["755"] = { color = 0xdddb00, text_color = 0xffffff }, + ["756"] = { color = 0xe5007c, text_color = 0xffffff }, + ["757"] = { color = 0x82348b, text_color = 0xffffff }, + }, + ["Verkehrsgesellschaft Landkreis Gifhorn mbH"] = { + ["100"] = { color = 0xe7372a, text_color = 0x191919 }, + ["101"] = { color = 0x91009b, text_color = 0x191919 }, + ["102"] = { color = 0x955e42, text_color = 0x191919 }, + ["103"] = { color = 0xffacf2, text_color = 0x191919 }, + ["105"] = { color = 0xff9518, text_color = 0x191919 }, + ["108"] = { color = 0xf0ea2c, text_color = 0x191919 }, + ["111"] = { color = 0x5fdaef, text_color = 0x191919 }, + ["140"] = { color = 0x66d8c7, text_color = 0x191919 }, + ["141"] = { color = 0x65ff8c, text_color = 0x191919 }, + ["164"] = { color = 0xb3d04b, text_color = 0x191919 }, + ["170"] = { color = 0x90d6ab, text_color = 0x191919 }, + ["175"] = { color = 0xab91f8, text_color = 0x191919 }, + ["191"] = { color = 0x379e90, text_color = 0x191919 }, + }, + ["Wolfsburger Verkehrs-GmbH"] = { + ["201"] = { color = 0xe44b48, text_color = 0xffffff }, + ["202"] = { color = 0x2cbca9, text_color = 0xffffff }, + ["203"] = { color = 0x6558a6, text_color = 0xffffff }, + ["204"] = { color = 0xe7b011, text_color = 0xffffff }, + ["211"] = { color = 0x00bee8, text_color = 0xffffff }, + ["212"] = { color = 0xf4822a, text_color = 0xffffff }, + ["213"] = { color = 0x229a9f, text_color = 0xffffff }, + ["215"] = { color = 0x25b34b, text_color = 0xffffff }, + ["216"] = { color = 0xa4ce3a, text_color = 0xffffff }, + ["218"] = { color = 0x0082c5, text_color = 0xffffff }, + ["221"] = { color = 0x900f11, text_color = 0xffffff }, + ["222"] = { color = 0x006d70, text_color = 0xffffff }, + ["223"] = { color = 0x42357a, text_color = 0xffffff }, + ["224"] = { color = 0xc25d2b, text_color = 0xffffff }, + ["225"] = { color = 0x0d7a31, text_color = 0xffffff }, + ["226"] = { color = 0x779b29, text_color = 0xffffff }, + ["227"] = { color = 0x064d80, text_color = 0xffffff }, + ["230"] = { color = 0x00944e, text_color = 0xffffff }, + }, + ["üstra Hannoversche Verkehrsbetriebe AG"] = { + ["1"] = { color = 0xff2e3e, text_color = 0xffffff }, + ["10"] = { color = 0x6dc248, text_color = 0xffffff }, + ["100"] = { color = 0xfb3199, text_color = 0xffffff }, + ["11"] = { color = 0xffac2e, text_color = 0xffffff }, + ["12"] = { color = 0x6dc248, text_color = 0xffffff }, + ["120"] = { color = 0xff9027, text_color = 0xffffff }, + ["121"] = { color = 0x95cc45, text_color = 0xffffff }, + ["122"] = { color = 0x95cc45, text_color = 0xffffff }, + ["123"] = { color = 0xfc87bf, text_color = 0xffffff }, + ["124"] = { color = 0x95cc45, text_color = 0xffffff }, + ["125"] = { color = 0xff2e17, text_color = 0xffffff }, + ["126"] = { color = 0xff2e17, text_color = 0xffffff }, + ["127"] = { color = 0xffbe32, text_color = 0xffffff }, + ["128"] = { color = 0xaf2a21, text_color = 0xffffff }, + ["129"] = { color = 0xfc5cac, text_color = 0xffffff }, + ["13"] = { color = 0x0073c0, text_color = 0xffffff }, + ["130"] = { color = 0x95cc45, text_color = 0xffffff }, + ["133"] = { color = 0xffbe32, text_color = 0xffffff }, + ["134"] = { color = 0x3ebc6d, text_color = 0xffffff }, + ["135"] = { color = 0x3ebc6d, text_color = 0xffffff }, + ["136"] = { color = 0xaf2a21, text_color = 0xffffff }, + ["137"] = { color = 0xff9027, text_color = 0xffffff }, + ["17"] = { color = 0x6dc248, text_color = 0xffffff }, + ["2"] = { color = 0xff2e3e, text_color = 0xffffff }, + ["200"] = { color = 0xfc87bf, text_color = 0xffffff }, + ["253"] = { color = 0xff9027, text_color = 0xffffff }, + ["254"] = { color = 0x35ccf6, text_color = 0xffffff }, + ["267"] = { color = 0x3ebc6d, text_color = 0xffffff }, + ["3"] = { color = 0x0073c0, text_color = 0xffffff }, + ["330"] = { color = 0xffbe32, text_color = 0xffffff }, + ["340"] = { color = 0xff2e17, text_color = 0xffffff }, + ["341"] = { color = 0x3ebc6d, text_color = 0xffffff }, + ["345"] = { color = 0xffbe32, text_color = 0xffffff }, + ["346"] = { color = 0x903da0, text_color = 0xffffff }, + ["347"] = { color = 0xff9027, text_color = 0xffffff }, + ["348"] = { color = 0xfc87bf, text_color = 0xffffff }, + ["363"] = { color = 0xff9027, text_color = 0xffffff }, + ["371"] = { color = 0x0155ae, text_color = 0xffffff }, + ["372"] = { color = 0x35ccf6, text_color = 0xffffff }, + ["373"] = { color = 0xff9027, text_color = 0xffffff }, + ["390"] = { color = 0x95cc45, text_color = 0xffffff }, + ["4"] = { color = 0xffac2e, text_color = 0xffffff }, + ["420"] = { color = 0xfc87bf, text_color = 0xffffff }, + ["450"] = { color = 0xffbe32, text_color = 0xffffff }, + ["470"] = { color = 0xfc87bf, text_color = 0xffffff }, + ["480"] = { color = 0x3ebc6d, text_color = 0xffffff }, + ["5"] = { color = 0xffac2e, text_color = 0xffffff }, + ["581"] = { color = 0x903da0, text_color = 0xffffff }, + ["6"] = { color = 0xffac2e, text_color = 0xffffff }, + ["610"] = { color = 0x3ebc6d, text_color = 0xffffff }, + ["611"] = { color = 0xaf2a21, text_color = 0xffffff }, + ["631"] = { color = 0x95cc45, text_color = 0xffffff }, + ["7"] = { color = 0x0073c0, text_color = 0xffffff }, + ["8"] = { color = 0xff2e3e, text_color = 0xffffff }, + ["800"] = { color = 0x35ccf6, text_color = 0xffffff }, + ["9"] = { color = 0x0073c0, text_color = 0xffffff }, + }, +} +return colors diff --git a/src/generate_colors_pretty.py b/src/generate_all_DACH_colours.py similarity index 86% rename from src/generate_colors_pretty.py rename to src/generate_all_DACH_colours.py index 003c528cb..1d4d7d68c 100644 --- a/src/generate_colors_pretty.py +++ b/src/generate_all_DACH_colours.py @@ -8,12 +8,14 @@ import sys # Import already written scripts as modules +import generate_colors import generate_colors_CH import generate_colors_VBN # Telling Python to do these sequentially. def main(): - generate_colors_CH.main() + generate_colors.main() + generate_colors_CH.main() generate_colors_VBN.main() # Don't know what that does, but it makes it work. diff --git a/src/generate_colors_CH.py b/src/generate_colors_CH.py index d7de0b553..4198ed919 100644 --- a/src/generate_colors_CH.py +++ b/src/generate_colors_CH.py @@ -15,7 +15,6 @@ import requests from typing import Dict, Any -#URL = "https://raw.githubusercontent.com/Traewelling/line-colors/refs/heads/main/line-colors-CH.csv" URL = "https://raw.githubusercontent.com/luna-cant-code/line-colors/refs/heads/feed-transition/line-colors-CH.csv" OUTPUT = "scripts/ch-opentransport-colors.lua" From 81508f83871896aefebe3e6eecfec3ada4ec6688 Mon Sep 17 00:00:00 2001 From: luna-cant-code <223513004+luna-cant-code@users.noreply.github.com> Date: Thu, 4 Dec 2025 18:54:12 +0100 Subject: [PATCH 10/11] emptied file a bit so it can load in the "Files changed" view --- scripts/de-VBN-colors.lua | 310 -------------------------------------- 1 file changed, 310 deletions(-) diff --git a/scripts/de-VBN-colors.lua b/scripts/de-VBN-colors.lua index b089ef705..e64aa14d8 100644 --- a/scripts/de-VBN-colors.lua +++ b/scripts/de-VBN-colors.lua @@ -13,316 +13,6 @@ local colors = { ["3E"] = { color = 0x006430, text_color = 0xffffff }, ["4"] = { color = 0x009ee2, text_color = 0xffffff }, ["411"] = { color = 0xb1a85c, text_color = 0xffffff }, - ["412"] = { color = 0x009ee2, text_color = 0xffffff }, - ["413"] = { color = 0x00953e, text_color = 0xffffff }, - ["414"] = { color = 0x5ac5f1, text_color = 0xffffff }, - ["416"] = { color = 0xf39100, text_color = 0xffffff }, - ["417"] = { color = 0x9b9c9c, text_color = 0xffffff }, - ["418"] = { color = 0xd35c9e, text_color = 0xffffff }, - ["419"] = { color = 0x0068b3, text_color = 0xffffff }, - ["420"] = { color = 0x6e6e6d, text_color = 0xffffff }, - ["421"] = { color = 0xc14d96, text_color = 0xffffff }, - ["422"] = { color = 0x9b0600, text_color = 0xffffff }, - ["423"] = { color = 0x9b0600, text_color = 0xffffff }, - ["424"] = { color = 0xe0b500, text_color = 0xffffff }, - ["426"] = { color = 0x804796, text_color = 0xffffff }, - ["427"] = { color = 0x70ba6e, text_color = 0xffffff }, - ["430"] = { color = 0x6e6e6d, text_color = 0xffffff }, - ["431"] = { color = 0xebc56b, text_color = 0xffffff }, - ["433"] = { color = 0xec6da6, text_color = 0xffffff }, - ["434"] = { color = 0xa20600, text_color = 0xffffff }, - ["435"] = { color = 0xe2000a, text_color = 0xffffff }, - ["436"] = { color = 0x0f3f93, text_color = 0xffffff }, - ["437"] = { color = 0x9b9c9c, text_color = 0xffffff }, - ["445"] = { color = 0x8bbd1d, text_color = 0xffffff }, - ["450"] = { color = 0x6e6e6d, text_color = 0xffffff }, - ["454"] = { color = 0xffd000, text_color = 0xffffff }, - ["455"] = { color = 0x9b9c9c, text_color = 0xffffff }, - ["464"] = { color = 0x9b9c9c, text_color = 0xffffff }, - ["465"] = { color = 0xe94d33, text_color = 0xffffff }, - ["466"] = { color = 0xe94d33, text_color = 0xffffff }, - ["471"] = { color = 0x23318a, text_color = 0xffffff }, - ["480"] = { color = 0x6e6e6d, text_color = 0xffffff }, - ["481"] = { color = 0x9b9c9c, text_color = 0xffffff }, - ["482"] = { color = 0x8bbd1d, text_color = 0xffffff }, - ["4E"] = { color = 0x009ee2, text_color = 0xffffff }, - ["5"] = { color = 0xf39100, text_color = 0xffffff }, - ["5E"] = { color = 0xf39100, text_color = 0xffffff }, - }, - ["Bremer Straßenbahn AG"] = { - ["1"] = { color = 0x00a54f, text_color = 0xffffff }, - ["10"] = { color = 0x15258e, text_color = 0xffffff }, - ["14"] = { color = 0x8bc63e, text_color = 0xffffff }, - ["1E"] = { color = 0x00a54f, text_color = 0xffffff }, - ["1S"] = { color = 0x00a54f, text_color = 0xffffff }, - ["2"] = { color = 0x0166b3, text_color = 0xffffff }, - ["20"] = { color = 0x8bc63e, text_color = 0xffffff }, - ["21"] = { color = 0x00aeef, text_color = 0xffffff }, - ["22"] = { color = 0xa69dcd, text_color = 0xffffff }, - ["24"] = { color = 0x951b81, text_color = 0xffffff }, - ["25"] = { color = 0x009640, text_color = 0xffffff }, - ["26"] = { color = 0xe30613, text_color = 0xffffff }, - ["27"] = { color = 0xef7d00, text_color = 0xffffff }, - ["28"] = { color = 0xffcc00, text_color = 0x000000 }, - ["29"] = { color = 0x95c11f, text_color = 0xffffff }, - ["3"] = { color = 0x00aeef, text_color = 0xffffff }, - ["31"] = { color = 0x95c11f, text_color = 0xffffff }, - ["33"] = { color = 0xffcc00, text_color = 0x000000 }, - ["34"] = { color = 0xffcc00, text_color = 0x000000 }, - ["37"] = { color = 0x951b81, text_color = 0xffffff }, - ["38"] = { color = 0xffcc00, text_color = 0x000000 }, - ["39"] = { color = 0xffcc00, text_color = 0x000000 }, - ["4"] = { color = 0xee1d23, text_color = 0xffffff }, - ["40"] = { color = 0xe30613, text_color = 0xffffff }, - ["41"] = { color = 0xe30613, text_color = 0xffffff }, - ["41S"] = { color = 0xe30613, text_color = 0xffffff }, - ["42"] = { color = 0xffcc00, text_color = 0x000000 }, - ["44"] = { color = 0xef7d00, text_color = 0xffffff }, - ["4S"] = { color = 0xee1d23, text_color = 0xffffff }, - ["5"] = { color = 0x00aab8, text_color = 0xffffff }, - ["52"] = { color = 0x94c01f, text_color = 0xffffff }, - ["55"] = { color = 0xffcc00, text_color = 0x000000 }, - ["57"] = { color = 0xef7d00, text_color = 0xffffff }, - ["58"] = { color = 0xef7d00, text_color = 0xffffff }, - ["5S"] = { color = 0x00aab8, text_color = 0xffffff }, - ["6"] = { color = 0xfeca0a, text_color = 0x000000 }, - ["61"] = { color = 0x009fe3, text_color = 0xffffff }, - ["62"] = { color = 0x009640, text_color = 0xffffff }, - ["63"] = { color = 0x312783, text_color = 0xffffff }, - ["63S"] = { color = 0x312783, text_color = 0xffffff }, - ["65"] = { color = 0x94c01f, text_color = 0xffffff }, - ["66"] = { color = 0x94c01f, text_color = 0xffffff }, - ["6E"] = { color = 0xfeca0a, text_color = 0x000000 }, - ["8"] = { color = 0x8bc63e, text_color = 0xffffff }, - ["80"] = { color = 0x94c01f, text_color = 0xffffff }, - ["81"] = { color = 0x009640, text_color = 0xffffff }, - ["82"] = { color = 0xef7d00, text_color = 0xffffff }, - ["90"] = { color = 0x312783, text_color = 0xffffff }, - ["91"] = { color = 0x009fe3, text_color = 0xffffff }, - ["92"] = { color = 0x009fe3, text_color = 0xffffff }, - ["93"] = { color = 0xffcc00, text_color = 0x000000 }, - ["94"] = { color = 0xe30613, text_color = 0xffffff }, - ["95"] = { color = 0xef7d00, text_color = 0xffffff }, - ["96"] = { color = 0x951b81, text_color = 0xffffff }, - ["98"] = { color = 0x009640, text_color = 0xffffff }, - }, - ["HarzBus GbR"] = { - ["650"] = { color = 0x9f5292, text_color = 0xffffff }, - ["655"] = { color = 0x42aa61, text_color = 0xffffff }, - ["810"] = { color = 0xca1413, text_color = 0xffffff }, - ["821"] = { color = 0x846fac, text_color = 0xffffff }, - ["822"] = { color = 0xed760b, text_color = 0xffffff }, - ["830"] = { color = 0x9a246c, text_color = 0xffffff }, - ["831"] = { color = 0x009eb5, text_color = 0xffffff }, - ["832"] = { color = 0x663904, text_color = 0xffffff }, - ["833"] = { color = 0x005ca1, text_color = 0xffffff }, - ["834"] = { color = 0x005ca1, text_color = 0xffffff }, - ["836"] = { color = 0x78348a, text_color = 0xffffff }, - ["840"] = { color = 0x005a9f, text_color = 0xffffff }, - ["841"] = { color = 0x007e3b, text_color = 0xffffff }, - ["850"] = { color = 0x9271ae, text_color = 0xffffff }, - ["851"] = { color = 0x895079, text_color = 0xffffff }, - ["852"] = { color = 0x975500, text_color = 0xffffff }, - ["860"] = { color = 0x007e3b, text_color = 0xffffff }, - ["861"] = { color = 0x975500, text_color = 0xffffff }, - }, - ["Kraftverkehrsgesellschaft mbH Braunschweig"] = { - ["360"] = { color = 0xffffff, text_color = 0xb5579a }, - ["370"] = { color = 0xffffff, text_color = 0xe61381 }, - ["371"] = { color = 0xffffff, text_color = 0xfadd04 }, - ["372"] = { color = 0xffffff, text_color = 0xc8c8cc }, - ["380"] = { color = 0xffffff, text_color = 0xfadd04 }, - ["381"] = { color = 0xffffff, text_color = 0xb9cd29 }, - ["382"] = { color = 0xffffff, text_color = 0x9b2425 }, - ["383"] = { color = 0xffffff, text_color = 0x00a0e1 }, - ["384"] = { color = 0xffffff, text_color = 0x008640 }, - ["385"] = { color = 0xffffff, text_color = 0xbe7e20 }, - ["386"] = { color = 0xffffff, text_color = 0xbdddd0 }, - ["387"] = { color = 0xffffff, text_color = 0xe61381 }, - ["388"] = { color = 0xffffff, text_color = 0xfadd04 }, - ["390"] = { color = 0xffffff, text_color = 0xf1a1bc }, - ["391"] = { color = 0xffffff, text_color = 0xe11d25 }, - ["392"] = { color = 0xffffff, text_color = 0x0854a1 }, - ["393"] = { color = 0xffffff, text_color = 0xe11d25 }, - ["394"] = { color = 0xffffff, text_color = 0xf4981b }, - ["395"] = { color = 0xffffff, text_color = 0xb5579a }, - ["396"] = { color = 0xffffff, text_color = 0x3c3386 }, - ["397"] = { color = 0xffffff, text_color = 0xb9cd29 }, - ["398"] = { color = 0xffffff, text_color = 0x008640 }, - ["399"] = { color = 0xffffff, text_color = 0x008640 }, - ["601"] = { color = 0xffffff, text_color = 0xec1f25 }, - ["602"] = { color = 0xffffff, text_color = 0xec1f25 }, - ["603"] = { color = 0xffffff, text_color = 0x00adef }, - ["604"] = { color = 0xffffff, text_color = 0x6ab145 }, - ["606"] = { color = 0xffffff, text_color = 0xf48221 }, - ["607"] = { color = 0xffffff, text_color = 0xa868ab }, - ["608"] = { color = 0xffffff, text_color = 0xea028c }, - ["609"] = { color = 0xffffff, text_color = 0xea028c }, - ["610"] = { color = 0xffffff, text_color = 0xf48221 }, - ["611"] = { color = 0xffffff, text_color = 0x2c3192 }, - ["612"] = { color = 0xffffff, text_color = 0xf5d90e }, - ["613"] = { color = 0xffffff, text_color = 0xb66f35 }, - ["614"] = { color = 0xffffff, text_color = 0xb1345b }, - ["615"] = { color = 0xffffff, text_color = 0x007236 }, - ["616"] = { color = 0xffffff, text_color = 0xf499a4 }, - ["618"] = { color = 0xffffff, text_color = 0x01b9be }, - ["619"] = { color = 0xffffff, text_color = 0x772b90 }, - ["620"] = { color = 0xffffff, text_color = 0x006cb8 }, - ["621"] = { color = 0xffffff, text_color = 0x7e8285 }, - ["626"] = { color = 0xffffff, text_color = 0x7e8285 }, - ["627"] = { color = 0xffffff, text_color = 0x7e8285 }, - ["628"] = { color = 0xffffff, text_color = 0x7e8285 }, - ["630"] = { color = 0xffffff, text_color = 0x00a551 }, - ["640"] = { color = 0xffffff, text_color = 0x009183 }, - ["710"] = { color = 0xffffff, text_color = 0xf6d68f }, - ["740"] = { color = 0xffffff, text_color = 0xf59031 }, - ["750"] = { color = 0xffffff, text_color = 0xfab15d }, - ["790"] = { color = 0xffffff, text_color = 0xfbc335 }, - ["791"] = { color = 0xffffff, text_color = 0xb1d23d }, - ["792"] = { color = 0xffffff, text_color = 0x6cbf5b }, - ["793"] = { color = 0xffffff, text_color = 0x00b3bd }, - ["794"] = { color = 0xffffff, text_color = 0x2993d1 }, - ["795"] = { color = 0xffffff, text_color = 0x50b7e8 }, - ["796"] = { color = 0xffffff, text_color = 0x146b8b }, - ["797"] = { color = 0xffffff, text_color = 0x778ec8 }, - ["799"] = { color = 0xffffff, text_color = 0x72ccd4 }, - ["820"] = { color = 0xffffff, text_color = 0x00a551 }, - ["871"] = { color = 0xffffff, text_color = 0x00adef }, - ["873"] = { color = 0xffffff, text_color = 0xf9a61b }, - ["874"] = { color = 0xffffff, text_color = 0xeb106e }, - ["875"] = { color = 0xffffff, text_color = 0x9d005e }, - ["879"] = { color = 0xffffff, text_color = 0xec1f25 }, - }, - ["NordWestBahn"] = { - ["RS1"] = { color = 0x00448b, text_color = 0xffffff }, - ["RS2"] = { color = 0xe89023, text_color = 0xffffff }, - ["RS3"] = { color = 0x93bf30, text_color = 0xffffff }, - ["RS30"] = { color = 0x4faf3b, text_color = 0xffffff }, - ["RS4"] = { color = 0xe2000b, text_color = 0xffffff }, - ["RS6"] = { color = 0x899bb9, text_color = 0xffffff }, - }, - ["Stadtbus Goslar GmbH"] = { - ["801"] = { color = 0xfc9400, text_color = 0xffffff }, - ["802"] = { color = 0xac2f8a, text_color = 0xffffff }, - ["803"] = { color = 0x0aa2e3, text_color = 0xffffff }, - ["804"] = { color = 0x292174, text_color = 0xffffff }, - ["805"] = { color = 0x735c30, text_color = 0xffffff }, - ["806"] = { color = 0x0a6031, text_color = 0xffffff }, - }, - ["Verkehrsbetriebe Bachstein"] = { - ["151"] = { color = 0x009de2, text_color = 0xffffff }, - ["153"] = { color = 0xe20715, text_color = 0xffffff }, - ["160"] = { color = 0x009340, text_color = 0xffffff }, - ["161"] = { color = 0x312681, text_color = 0xffffff }, - ["162"] = { color = 0xf09100, text_color = 0xffffff }, - ["163"] = { color = 0xe5007c, text_color = 0xffffff }, - ["165"] = { color = 0xdfdb00, text_color = 0xffffff }, - ["335"] = { color = 0x94be1f, text_color = 0xffffff }, - ["650"] = { color = 0xa05292, text_color = 0xffffff }, - ["656"] = { color = 0x28225c, text_color = 0xffffff }, - ["658"] = { color = 0xe5213d, text_color = 0xffffff }, - ["660"] = { color = 0xf39200, text_color = 0xffffff }, - ["750"] = { color = 0xe2000e, text_color = 0xffffff }, - ["751"] = { color = 0x2e2482, text_color = 0xffffff }, - ["752"] = { color = 0x00953f, text_color = 0xffffff }, - ["753"] = { color = 0x35a9e0, text_color = 0xffffff }, - ["754"] = { color = 0xf39100, text_color = 0xffffff }, - ["755"] = { color = 0xdddb00, text_color = 0xffffff }, - ["756"] = { color = 0xe5007c, text_color = 0xffffff }, - ["757"] = { color = 0x82348b, text_color = 0xffffff }, - }, - ["Verkehrsgesellschaft Landkreis Gifhorn mbH"] = { - ["100"] = { color = 0xe7372a, text_color = 0x191919 }, - ["101"] = { color = 0x91009b, text_color = 0x191919 }, - ["102"] = { color = 0x955e42, text_color = 0x191919 }, - ["103"] = { color = 0xffacf2, text_color = 0x191919 }, - ["105"] = { color = 0xff9518, text_color = 0x191919 }, - ["108"] = { color = 0xf0ea2c, text_color = 0x191919 }, - ["111"] = { color = 0x5fdaef, text_color = 0x191919 }, - ["140"] = { color = 0x66d8c7, text_color = 0x191919 }, - ["141"] = { color = 0x65ff8c, text_color = 0x191919 }, - ["164"] = { color = 0xb3d04b, text_color = 0x191919 }, - ["170"] = { color = 0x90d6ab, text_color = 0x191919 }, - ["175"] = { color = 0xab91f8, text_color = 0x191919 }, - ["191"] = { color = 0x379e90, text_color = 0x191919 }, - }, - ["Wolfsburger Verkehrs-GmbH"] = { - ["201"] = { color = 0xe44b48, text_color = 0xffffff }, - ["202"] = { color = 0x2cbca9, text_color = 0xffffff }, - ["203"] = { color = 0x6558a6, text_color = 0xffffff }, - ["204"] = { color = 0xe7b011, text_color = 0xffffff }, - ["211"] = { color = 0x00bee8, text_color = 0xffffff }, - ["212"] = { color = 0xf4822a, text_color = 0xffffff }, - ["213"] = { color = 0x229a9f, text_color = 0xffffff }, - ["215"] = { color = 0x25b34b, text_color = 0xffffff }, - ["216"] = { color = 0xa4ce3a, text_color = 0xffffff }, - ["218"] = { color = 0x0082c5, text_color = 0xffffff }, - ["221"] = { color = 0x900f11, text_color = 0xffffff }, - ["222"] = { color = 0x006d70, text_color = 0xffffff }, - ["223"] = { color = 0x42357a, text_color = 0xffffff }, - ["224"] = { color = 0xc25d2b, text_color = 0xffffff }, - ["225"] = { color = 0x0d7a31, text_color = 0xffffff }, - ["226"] = { color = 0x779b29, text_color = 0xffffff }, - ["227"] = { color = 0x064d80, text_color = 0xffffff }, - ["230"] = { color = 0x00944e, text_color = 0xffffff }, - }, - ["üstra Hannoversche Verkehrsbetriebe AG"] = { - ["1"] = { color = 0xff2e3e, text_color = 0xffffff }, - ["10"] = { color = 0x6dc248, text_color = 0xffffff }, - ["100"] = { color = 0xfb3199, text_color = 0xffffff }, - ["11"] = { color = 0xffac2e, text_color = 0xffffff }, - ["12"] = { color = 0x6dc248, text_color = 0xffffff }, - ["120"] = { color = 0xff9027, text_color = 0xffffff }, - ["121"] = { color = 0x95cc45, text_color = 0xffffff }, - ["122"] = { color = 0x95cc45, text_color = 0xffffff }, - ["123"] = { color = 0xfc87bf, text_color = 0xffffff }, - ["124"] = { color = 0x95cc45, text_color = 0xffffff }, - ["125"] = { color = 0xff2e17, text_color = 0xffffff }, - ["126"] = { color = 0xff2e17, text_color = 0xffffff }, - ["127"] = { color = 0xffbe32, text_color = 0xffffff }, - ["128"] = { color = 0xaf2a21, text_color = 0xffffff }, - ["129"] = { color = 0xfc5cac, text_color = 0xffffff }, - ["13"] = { color = 0x0073c0, text_color = 0xffffff }, - ["130"] = { color = 0x95cc45, text_color = 0xffffff }, - ["133"] = { color = 0xffbe32, text_color = 0xffffff }, - ["134"] = { color = 0x3ebc6d, text_color = 0xffffff }, - ["135"] = { color = 0x3ebc6d, text_color = 0xffffff }, - ["136"] = { color = 0xaf2a21, text_color = 0xffffff }, - ["137"] = { color = 0xff9027, text_color = 0xffffff }, - ["17"] = { color = 0x6dc248, text_color = 0xffffff }, - ["2"] = { color = 0xff2e3e, text_color = 0xffffff }, - ["200"] = { color = 0xfc87bf, text_color = 0xffffff }, - ["253"] = { color = 0xff9027, text_color = 0xffffff }, - ["254"] = { color = 0x35ccf6, text_color = 0xffffff }, - ["267"] = { color = 0x3ebc6d, text_color = 0xffffff }, - ["3"] = { color = 0x0073c0, text_color = 0xffffff }, - ["330"] = { color = 0xffbe32, text_color = 0xffffff }, - ["340"] = { color = 0xff2e17, text_color = 0xffffff }, - ["341"] = { color = 0x3ebc6d, text_color = 0xffffff }, - ["345"] = { color = 0xffbe32, text_color = 0xffffff }, - ["346"] = { color = 0x903da0, text_color = 0xffffff }, - ["347"] = { color = 0xff9027, text_color = 0xffffff }, - ["348"] = { color = 0xfc87bf, text_color = 0xffffff }, - ["363"] = { color = 0xff9027, text_color = 0xffffff }, - ["371"] = { color = 0x0155ae, text_color = 0xffffff }, - ["372"] = { color = 0x35ccf6, text_color = 0xffffff }, - ["373"] = { color = 0xff9027, text_color = 0xffffff }, - ["390"] = { color = 0x95cc45, text_color = 0xffffff }, - ["4"] = { color = 0xffac2e, text_color = 0xffffff }, - ["420"] = { color = 0xfc87bf, text_color = 0xffffff }, - ["450"] = { color = 0xffbe32, text_color = 0xffffff }, - ["470"] = { color = 0xfc87bf, text_color = 0xffffff }, - ["480"] = { color = 0x3ebc6d, text_color = 0xffffff }, - ["5"] = { color = 0xffac2e, text_color = 0xffffff }, - ["581"] = { color = 0x903da0, text_color = 0xffffff }, - ["6"] = { color = 0xffac2e, text_color = 0xffffff }, - ["610"] = { color = 0x3ebc6d, text_color = 0xffffff }, - ["611"] = { color = 0xaf2a21, text_color = 0xffffff }, - ["631"] = { color = 0x95cc45, text_color = 0xffffff }, - ["7"] = { color = 0x0073c0, text_color = 0xffffff }, - ["8"] = { color = 0xff2e3e, text_color = 0xffffff }, - ["800"] = { color = 0x35ccf6, text_color = 0xffffff }, - ["9"] = { color = 0x0073c0, text_color = 0xffffff }, }, } return colors From beba529b8e421572dd184390b4f2c6395dc0a671 Mon Sep 17 00:00:00 2001 From: luna-cant-code <223513004+luna-cant-code@users.noreply.github.com> Date: Sun, 21 Dec 2025 20:55:57 +0100 Subject: [PATCH 11/11] Update generate_colors_VBN.py --- src/generate_colors_VBN.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/generate_colors_VBN.py b/src/generate_colors_VBN.py index e9e452a89..83e6dee81 100644 --- a/src/generate_colors_VBN.py +++ b/src/generate_colors_VBN.py @@ -15,11 +15,12 @@ import requests from typing import Dict, Any -URL = "https://raw.githubusercontent.com/luna-cant-code/line-colors/refs/heads/feed-transition/line-colors-VBN.csv" +URL = "https://raw.githubusercontent.com/Traewelling/line-colors/refs/heads/main/line-colors-VBN.csv" OUTPUT = "scripts/de-VBN-colors.lua" HEX_RE = re.compile(r"^[0-9A-Fa-f]{3}([0-9A-Fa-f]{3})?$") +# EVERYTHING UNDER THIS COMMENT IS JUST STRAIGHT UP COPIED FROM THE REGULAR generate_colors.py FILE (don't know if this works tbh) def fetch_csv(url: str) -> str: logging.info("Fetching CSV from %s", url)