mirror of
https://github.com/enzet/map-machine.git
synced 2025-05-25 06:56:25 +02:00
Rename Röntgen to Map Machine.
This commit is contained in:
parent
38c4e00de3
commit
2bd89a6539
57 changed files with 252 additions and 236 deletions
80
map_machine/workspace.py
Normal file
80
map_machine/workspace.py
Normal file
|
@ -0,0 +1,80 @@
|
|||
"""
|
||||
File and directory path in the project.
|
||||
"""
|
||||
from pathlib import Path
|
||||
|
||||
__author__ = "Sergey Vartanov"
|
||||
__email__ = "me@enzet.ru"
|
||||
|
||||
HERE: Path = Path(__file__).parent
|
||||
|
||||
|
||||
def check_and_create(directory: Path) -> Path:
|
||||
"""Create directory if it doesn't exist and return it."""
|
||||
if not directory.is_dir():
|
||||
directory.mkdir(parents=True, exist_ok=True)
|
||||
return directory
|
||||
|
||||
|
||||
class Workspace:
|
||||
"""
|
||||
Project file and directory paths and generated files and directories.
|
||||
"""
|
||||
|
||||
# Project directories and files, that are the part of the repository.
|
||||
|
||||
SCHEME_PATH: Path = HERE / Path("scheme")
|
||||
DEFAULT_SCHEME_PATH: Path = SCHEME_PATH / "default.yml"
|
||||
ICONS_PATH: Path = HERE / Path("icons/icons.svg")
|
||||
ICONS_CONFIG_PATH: Path = HERE / Path("icons/config.json")
|
||||
GITHUB_TEST_PATH: Path = Path(".github/workflows/test.yml")
|
||||
|
||||
# Generated directories and files.
|
||||
|
||||
MAPCSS_ICONS_DIRECTORY_NAME: str = "icons"
|
||||
|
||||
def __init__(self, output_path: Path) -> None:
|
||||
self.output_path: Path = output_path
|
||||
check_and_create(output_path)
|
||||
|
||||
self._icons_by_id_path: Path = output_path / "icons_by_id"
|
||||
self._icons_by_name_path: Path = output_path / "icons_by_name"
|
||||
self._mapcss_path: Path = output_path / "map_machine_mapcss"
|
||||
self._tile_path: Path = output_path / "tiles"
|
||||
|
||||
def get_icons_by_id_path(self) -> Path:
|
||||
"""Directory for the icon files named by identifiers."""
|
||||
return check_and_create(self._icons_by_id_path)
|
||||
|
||||
def get_icons_by_name_path(self) -> Path:
|
||||
"""Directory for the icon files named by human-readable names."""
|
||||
return check_and_create(self._icons_by_name_path)
|
||||
|
||||
def get_tile_path(self) -> Path:
|
||||
"""Directory for tiles."""
|
||||
return check_and_create(self._tile_path)
|
||||
|
||||
def get_mapcss_path(self) -> Path:
|
||||
"""Directory for MapCSS files."""
|
||||
return check_and_create(self._mapcss_path)
|
||||
|
||||
def get_mapcss_file_path(self) -> Path:
|
||||
"""Directory for MapCSS files."""
|
||||
return self.get_mapcss_path() / "map_machine.mapcss"
|
||||
|
||||
def get_mapcss_icons_path(self) -> Path:
|
||||
"""Directory for icons used by MapCSS file."""
|
||||
return check_and_create(
|
||||
self.get_mapcss_path() / self.MAPCSS_ICONS_DIRECTORY_NAME
|
||||
)
|
||||
|
||||
def get_icon_grid_path(self) -> Path:
|
||||
"""Icon grid path."""
|
||||
return self.output_path / "icon_grid.svg"
|
||||
|
||||
def get_taginfo_file_path(self) -> Path:
|
||||
"""Path to file with project information for Taginfo."""
|
||||
return self.output_path / "map_machine_taginfo.json"
|
||||
|
||||
|
||||
workspace = Workspace(Path("out"))
|
Loading…
Add table
Add a link
Reference in a new issue