Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_update_textures_none(dummy_noappearance):
with pytest.raises(errors.InvalidOperation):
dummy_noappearance.update_textures_location('somepath', relative=True)
t["image"] = os.path.join(apath, f)
else:
apath = os.path.abspath(new_loc)
if not os.path.isdir(apath):
raise NotADirectoryError("%s does not exits" % apath)
elif relative:
rpath = os.path.relpath(apath, os.path.dirname(self.path))
for t in self.j["appearance"]["textures"]:
f = os.path.basename(t["image"])
t["image"] = os.path.join(rpath, f)
else:
for t in self.j["appearance"]["textures"]:
f = os.path.basename(t["image"])
t["image"] = os.path.join(apath, f)
else:
raise InvalidOperation("Cannot update textures in a city model without textures")
curr_path = self.path
try:
self.path = jpath
for t in self.j["appearance"]["textures"]:
f = os.path.basename(t["image"])
curr_path = os.path.join(curr_loc, f)
shutil.copy(curr_path, apath)
# update the location relative to the CityJSON file
self.update_textures_location(apath, relative=True)
print("Textures copied to", apath)
except IOError:
raise
finally:
self.path = curr_path
else:
raise InvalidOperation("Cannot copy textures from a city model without textures")