dumpmap: create directories if needed

This commit is contained in:
Laura Klünder 2016-09-24 16:48:37 +02:00
parent 6e65f8b8bd
commit 9a5cbd5ba7

View file

@ -105,6 +105,10 @@ class MapdataWriter:
def do_write_packages(self): def do_write_packages(self):
for file_path, content in self.write: for file_path, content in self.write:
full_file_path = os.path.join(settings.MAP_ROOT, file_path) full_file_path = os.path.join(settings.MAP_ROOT, file_path)
try:
os.makedirs(os.path.join(os.path.split(full_file_path)[:-1]))
except os.error:
pass
if content is not None: if content is not None:
with open(full_file_path, 'w') as f: with open(full_file_path, 'w') as f:
f.write(content) f.write(content)