rusackas commented on code in PR #45607:
URL: https://github.com/apache/superset/pull/45607#discussion_r4367599054


##########
superset-frontend/plugins/plugin-chart-country-map/scripts/build_maps.py:
##########
@@ -0,0 +1,173 @@
+#!/usr/bin/env python3
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""Regenerates plugin-chart-country-map's GeoJSON files, countries.ts and
+docs/data/countries.json from upstream Natural Earth + community geo
+data - the script equivalent of running every cell in
+`Country Map GeoJSON Generator.ipynb` top to bottom.
+
+By default writes to the same repo-relative locations the notebook
+always has (../src/countries/, ../src/countries.ts,
+../../../../docs/data/countries.json), so `git diff` after a run shows
+exactly what changed - override --out-dir/--countries-ts-path/
+--docs-json-path to redirect output elsewhere for a non-destructive
+dry run.
+
+Usage:
+    python3 build_maps.py
+    python3 build_maps.py --preview --out-dir /tmp/maps-out \\
+        --countries-ts-path /tmp/maps-out/countries.ts \\
+        --docs-json-path /tmp/maps-out/countries.json
+    python3 build_maps.py --countries france,turkey  # just these modules
+"""
+
+from __future__ import annotations
+
+import argparse
+import json
+import os
+import sys
+
+import geopandas as gpd
+
+_SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
+sys.path.insert(0, _SCRIPT_DIR)
+
+from maps.assemble import purged_countries, resolve_all, validate_catalog  # 
noqa: E402
+from maps.context import BuildContext  # noqa: E402
+from maps.countries import REGISTRY  # noqa: E402
+from maps.data import load_natural_earth  # noqa: E402
+from maps.output import save_geojson  # noqa: E402
+from maps.preview import build_contact_sheet, render_preview  # noqa: E402
+from maps.ts_writer import write_countries_ts, write_docs_json  # noqa: E402
+
+_DEFAULT_OUT_DIR = os.path.join(_SCRIPT_DIR, "..", "src", "countries")
+_DEFAULT_COUNTRIES_TS_PATH = os.path.join(_SCRIPT_DIR, "..", "src", 
"countries.ts")
+_DEFAULT_DOCS_JSON_PATH = os.path.join(
+    _SCRIPT_DIR, "..", "..", "..", "..", "docs", "data", "countries.json"
+)
+
+
+def _parse_args() -> argparse.Namespace:
+    parser = argparse.ArgumentParser(description=__doc__)
+    parser.add_argument("--data-dir", 
default=os.path.expanduser("~/Downloads"))
+    parser.add_argument("--out-dir", default=_DEFAULT_OUT_DIR)
+    parser.add_argument("--countries-ts-path", 
default=_DEFAULT_COUNTRIES_TS_PATH)
+    parser.add_argument("--docs-json-path", default=_DEFAULT_DOCS_JSON_PATH)
+    parser.add_argument(
+        "--countries",
+        help="Comma-separated subset of registered module NAMEs to run "
+        "(default: all registered). The ~190 plain catalog entries that "
+        "don't need a module are always included.",

Review Comment:
   Good catch. Reworded the `--countries` help so it says the plain entries are 
only included when the flag is omitted, and that a subset build writes just the 
named modules.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to