mirror of
https://github.com/KrisKennaway/ii-vision.git
synced 2025-03-12 11:32:13 +00:00
Create data dir before writing to it
This commit is contained in:
parent
4529bc3c74
commit
97403ab431
@ -1,6 +1,5 @@
|
|||||||
import bz2
|
|
||||||
import functools
|
import functools
|
||||||
import pickle
|
import os
|
||||||
import sys
|
import sys
|
||||||
from typing import Iterable, Type
|
from typing import Iterable, Type
|
||||||
|
|
||||||
@ -17,7 +16,7 @@ import screen
|
|||||||
|
|
||||||
|
|
||||||
PIXEL_CHARS = "0123456789ABCDEF"
|
PIXEL_CHARS = "0123456789ABCDEF"
|
||||||
|
DATA_DIR = "transcoder/data"
|
||||||
|
|
||||||
def pixel_char(i: int) -> str:
|
def pixel_char(i: int) -> str:
|
||||||
return PIXEL_CHARS[i]
|
return PIXEL_CHARS[i]
|
||||||
@ -184,12 +183,17 @@ def make_edit_distance(
|
|||||||
"""Write file containing (D)HGR edit distance matrix for a palette."""
|
"""Write file containing (D)HGR edit distance matrix for a palette."""
|
||||||
|
|
||||||
dist = compute_edit_distance(edp, bitmap_cls, nominal_colours)
|
dist = compute_edit_distance(edp, bitmap_cls, nominal_colours)
|
||||||
data = "transcoder/data/%s_palette_%d_edit_distance.npz" % (
|
data = "%s/%s_palette_%d_edit_distance.npz" % (
|
||||||
bitmap_cls.NAME, pal.ID.value)
|
DATA_DIR, bitmap_cls.NAME, pal.ID.value)
|
||||||
np.savez_compressed(data, edit_distance=dist)
|
np.savez_compressed(data, edit_distance=dist)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
try:
|
||||||
|
os.mkdir(DATA_DIR, mode=0o755)
|
||||||
|
except FileExistsError:
|
||||||
|
pass
|
||||||
|
|
||||||
for p in palette.PALETTES.values():
|
for p in palette.PALETTES.values():
|
||||||
print("Processing palette %s" % p)
|
print("Processing palette %s" % p)
|
||||||
edp = compute_substitute_costs(p)
|
edp = compute_substitute_costs(p)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user