"...git@transfer.hft-stuttgart.de:m4lab_tv1/user-account.git" did not exist on "7192c302fc8f662b97b1dbea1b904ce45e9bf92b"
Commit 76a8c8b2 authored by Eric Duminil's avatar Eric Duminil
Browse files

Allow space in names, with a warning

parent ce7b378e
Showing with 17 additions and 9 deletions
+17 -9
...@@ -164,15 +164,16 @@ def extract_region(output_dir: Path, location_name: str, wkt_str: str, simstadt_ ...@@ -164,15 +164,16 @@ def extract_region(output_dir: Path, location_name: str, wkt_str: str, simstadt_
f.write(local_wkt) f.write(local_wkt)
with open(params_path, 'w', encoding='utf-8') as f: with open(params_path, 'w', encoding='utf-8') as f:
f.write("--input\n") f.write("--input\n\"")
f.write(','.join(f"{gml.as_posix()}" for gml in gml_inputs)) f.write(','.join(f'{gml.as_posix()}' for gml in gml_inputs))
f.write("\n") f.write("\"\n")
f.write("--output\n") f.write("--output\n")
f.write(f'"{output_file.as_posix()}"\n') f.write(f'"{output_file.as_posix()}"\n')
f.write('--local\n') f.write('--local\n')
f.write("--wkt\n") f.write("--wkt\n")
f.write(f'"{wkt_path.as_posix()}"\n') f.write(f'"{wkt_path.as_posix()}"\n')
result = subprocess.run(['java', '-classpath', f'{region_chooser_libs}', result = subprocess.run(['java', '-classpath', f'{region_chooser_libs}',
'eu.simstadt.regionchooser.RegionChooserCLI', 'eu.simstadt.regionchooser.RegionChooserCLI',
f'@{params_path}' f'@{params_path}'
...@@ -181,9 +182,9 @@ def extract_region(output_dir: Path, location_name: str, wkt_str: str, simstadt_ ...@@ -181,9 +182,9 @@ def extract_region(output_dir: Path, location_name: str, wkt_str: str, simstadt_
capture_output=True, capture_output=True,
check=False check=False
) )
if result.stderr:
logger.error("%s", result.stderr)
if result.returncode != 0: if result.returncode != 0:
if result.stderr:
logger.error("%s", result.stderr)
raise ValueError(f"RegionChooser failed with code {result.returncode}") raise ValueError(f"RegionChooser failed with code {result.returncode}")
logger.info(" DONE!") logger.info(" DONE!")
return output_file return output_file
...@@ -251,7 +252,7 @@ def main(location_name: str, wkt_or_zipcode: str, download_only: bool = False, ...@@ -251,7 +252,7 @@ def main(location_name: str, wkt_or_zipcode: str, download_only: bool = False,
# Validate location name # Validate location name
if ' ' in location_name: if ' ' in location_name:
raise ValueError("Location name should not contain spaces: 'Some City' -> 'SomeCity'") logger.warning("Location contains spaces, some workflows might fail.")
if output_folder: if output_folder:
output_folder = Path(output_folder) output_folder = Path(output_folder)
......
...@@ -9,6 +9,7 @@ import download_LoD2_from_LGL_BW as bw_data ...@@ -9,6 +9,7 @@ import download_LoD2_from_LGL_BW as bw_data
# Just a few buildings in Schwarzwald # Just a few buildings in Schwarzwald
KALTENBRONN_WKT = "POLYGON ((8.4266 48.704415, 8.43926 48.704415, 8.43926 48.709031, 8.4266 48.709031, 8.4266 48.704415))" KALTENBRONN_WKT = "POLYGON ((8.4266 48.704415, 8.43926 48.704415, 8.43926 48.709031, 8.4266 48.709031, 8.4266 48.704415))"
class TestUtils(unittest.TestCase): class TestUtils(unittest.TestCase):
def test_simstadt_is_available(self): def test_simstadt_is_available(self):
self.assertIsNotNone(bw_data.find_simstadt_folder(), self.assertIsNotNone(bw_data.find_simstadt_folder(),
...@@ -59,8 +60,14 @@ class TestGetOpenData(unittest.TestCase): ...@@ -59,8 +60,14 @@ class TestGetOpenData(unittest.TestCase):
self.assertIn("DEBW_B010000BSWW", content) self.assertIn("DEBW_B010000BSWW", content)
def test_get_weird_name(self): def test_get_weird_name(self):
bw_data.main("WëírdNämeß", KALTENBRONN_WKT, weird_name = "WëírdNämeß"
output_folder=self.tempFolder / 'Kaltenbronn.proj') bw_data.main(weird_name, KALTENBRONN_WKT,
output_folder=self.tempFolder / f'{weird_name}.proj')
def test_get_space_in_name(self):
name_with_space = "Two words"
bw_data.main(name_with_space, KALTENBRONN_WKT,
output_folder=self.tempFolder / f'{name_with_space}.proj')
def test_only_download(self): def test_only_download(self):
gml_path = bw_data.main("JustDownload", KALTENBRONN_WKT, download_only=True, gml_path = bw_data.main("JustDownload", KALTENBRONN_WKT, download_only=True,
...@@ -76,7 +83,7 @@ class TestGetOpenData(unittest.TestCase): ...@@ -76,7 +83,7 @@ class TestGetOpenData(unittest.TestCase):
def test_wrong_simstadt(self): def test_wrong_simstadt(self):
self.assertRaisesRegex(ValueError, "RegionChooser failed", bw_data.main, self.assertRaisesRegex(ValueError, "RegionChooser failed", bw_data.main,
"WrongSimStadt", KALTENBRONN_WKT, simstadt_folder="/Surely/Not/Here/", "WrongSimStadt", KALTENBRONN_WKT, simstadt_folder="/Surely/Not/Here/",
output_folder=self.tempFolder / 'WrongSimStadt' output_folder=self.tempFolder / 'WrongSimStadt'
) )
@classmethod @classmethod
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment