Extract information from css files to create taginfo.json to list CoMaps as a project
()
| 125 | |
| 126 | |
| 127 | def main() -> None: |
| 128 | ''' |
| 129 | Extract information from css files to create |
| 130 | taginfo.json to list CoMaps as a project |
| 131 | ''' |
| 132 | |
| 133 | # extract color definitons to put into taginfo descriptions |
| 134 | |
| 135 | with open(LIGHTSTYLE_COLORS_FILE, "r", encoding="utf-8") as f: |
| 136 | lightcolor_css: str = f.read() |
| 137 | |
| 138 | lightcolors: dict[str, str] = parse_colors(lightcolor_css) |
| 139 | |
| 140 | with open(DARKSTYLE_COLORS_FILE, "r", encoding="utf-8") as f: |
| 141 | darkcolor_css: str = f.read() |
| 142 | |
| 143 | darkcolors: dict[str, str] = parse_colors(darkcolor_css) |
| 144 | |
| 145 | colors: dict[str, dict] = {'light': lightcolors, 'dark': darkcolors} |
| 146 | |
| 147 | # read mapcss file for getting POIs with icons |
| 148 | with open(MAPCSS_FILE, "r", encoding="utf-8") as f: |
| 149 | mapcss: str = f.read() |
| 150 | |
| 151 | mapcss_tags: list[dict[str, any]] = parse_mapcss(mapcss) |
| 152 | |
| 153 | # read basecss file to get tags w/o POI icons attached |
| 154 | with open(BASECSS_FILE, "r", encoding="utf-8") as f: |
| 155 | basecss: str = f.read() |
| 156 | |
| 157 | basecss_tags: list[dict[str, any]] = parse_mapcss(basecss, colors) |
| 158 | |
| 159 | tags = list = mapcss_tags + basecss_tags |
| 160 | |
| 161 | data: dict[str, any] = { |
| 162 | "data_format": 1, |
| 163 | "data_url": "https://codeberg.org/comaps/comaps/raw/branch/main/data/taginfo.json", |
| 164 | "data_updated": datetime.now(timezone.utc).strftime("%Y%m%dT%H%M%SZ"), |
| 165 | "project": PROJECT_INFO, |
| 166 | "tags": tags |
| 167 | } |
| 168 | |
| 169 | with open(TAGINFO_FILE, "w", encoding="utf-8") as f: |
| 170 | json.dump(data, f, indent=4, ensure_ascii=False) |
| 171 | |
| 172 | print(f"✅ JSON saved to {TAGINFO_FILE}") |
| 173 | |
| 174 | |
| 175 | if __name__ == "__main__": |
no test coverage detected