Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions scraper/src/maps2zim/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ class Context:
# temporary folder to store temporary assets (e.g. cached API response)
tmp_folder: Path

# folder to fetch / store downloaded assets (can be reused across runs)
assets_folder: Path

# folder where the ZIM will be built
output_folder: Path = Path(os.getenv("MAPS_OUTPUT", "output"))

Expand Down Expand Up @@ -87,6 +90,14 @@ class Context:
NAME, level=logging.DEBUG, log_format=DEFAULT_FORMAT_WITH_THREADS
)

# ------------------------------
# Maps specific arguments
# ------------------------------

# By default, download only monaco area ; specify planet to download the whole
# planet
area: str = "monaco"

@classmethod
def setup(cls, **kwargs: Any):
new_instance = cls(**kwargs)
Expand Down
16 changes: 16 additions & 0 deletions scraper/src/maps2zim/entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ def prepare_context(raw_args: list[str], tmpdir: str) -> None:
dest="tmp_folder",
)

parser.add_argument(
"--assets",
help="Folder folder to fetch / store downloaded assets (can be reused across "
"runs)",
type=Path,
dest="assets_folder",
)

parser.add_argument("--debug", help="Enable verbose output", action="store_true")

parser.add_argument(
Expand Down Expand Up @@ -134,6 +142,11 @@ def prepare_context(raw_args: list[str], tmpdir: str) -> None:
help="Contact information to pass in User-Agent headers",
)

parser.add_argument(
"--area",
help=f"Area to download, either planet or monaco. Default: {Context.area!s}",
)

args = parser.parse_args(raw_args)

# Ignore unset values so they do not override the default specified in Context
Expand All @@ -147,6 +160,9 @@ def prepare_context(raw_args: list[str], tmpdir: str) -> None:
else:
args_dict["tmp_folder"] = Path(tmpdir)

if not args_dict.get("assets_folder", None):
args_dict["assets_folder"] = args_dict["tmp_folder"] / "assets"

args_dict["_current_thread_workitem"] = threading.local()
args_dict["web_session"] = get_session()

Expand Down
Loading