diff options
| author | yum <yum.food.vr@gmail.com> | 2023-08-10 13:48:08 -0700 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2023-08-10 13:51:33 -0700 |
| commit | 5f33e4efdaa5cdb3773d7eb111b1f74b74721f29 (patch) | |
| tree | 5788859cbf0dbfa721241eab9118990f3c39beb8 /Scripts | |
| parent | 4337cb33939e43af1ed479bf87cb9390bcbae8b1 (diff) | |
Fix user-reported bug in generate_shader.py
Specify file encoding when generating shaders.
Diffstat (limited to 'Scripts')
| -rw-r--r-- | Scripts/generate_shader.py | 6 | ||||
| -rw-r--r-- | Scripts/libunity.py | 10 |
2 files changed, 7 insertions, 9 deletions
diff --git a/Scripts/generate_shader.py b/Scripts/generate_shader.py index 2348141..80f6704 100644 --- a/Scripts/generate_shader.py +++ b/Scripts/generate_shader.py @@ -100,7 +100,7 @@ def generateLetterAccessor(nbytes: int, nrows: int, ncols: int, prefix: str = "" def applyLineMacro(old_path: str, new_path: str, macro: str, replacement: str) -> bool: new_lines = [] times_applied = 0 - with open(old_path, 'r') as f: + with open(old_path, 'r', encoding="utf-8") as f: for line in f: if line[-1] == '\n': line = line[0:len(line)-1] @@ -109,13 +109,11 @@ def applyLineMacro(old_path: str, new_path: str, macro: str, replacement: str) - times_applied += 1 else: new_lines.append(line) - with open(new_path, 'w') as f: + with open(new_path, 'w', encoding="utf-8") as f: f.write('\n'.join(new_lines)) return times_applied if __name__ == "__main__": - sys.stdout.reconfigure(encoding="utf-8") - print("args: {}".format(" ".join(sys.argv))) parser = argparse.ArgumentParser() diff --git a/Scripts/libunity.py b/Scripts/libunity.py index 3fd1011..9168057 100644 --- a/Scripts/libunity.py +++ b/Scripts/libunity.py @@ -223,7 +223,7 @@ class Metadata: path = path + ".meta" self.guid = None - with open(path, "r") as f: + with open(path, "r", encoding="utf-8") as f: for line in f: if line.startswith("guid"): self.guid = line.split()[1] @@ -239,7 +239,7 @@ class Metadata: self.persist(path, guid_map) def persist(self, path, guid_map): - with open(path, "w") as f: + with open(path, "w", encoding="utf-8") as f: f.write(str(self)) guid_map[self.guid] = path @@ -856,11 +856,11 @@ class UnityAnimator(): new_anim_path = "OFF_{}".format(os.path.basename(animation_path)) new_anim_path = "{}/{}".format(generated_anim_dir, new_anim_path) - with open(new_anim_path, "w") as f: + with open(new_anim_path, "w", encoding="utf-8") as f: f.write(str(anim)) meta = Metadata() - with open(new_anim_path + ".meta", "w") as f: + with open(new_anim_path + ".meta", "w", encoding="utf-8") as f: f.write(str(meta)) def generateOffAnimationsAnimStates(self, guid_map, generated_anim_dir): @@ -1086,7 +1086,7 @@ class UnityParser: def parseFile(self, yaml_file): yaml_str = "" - with open(yaml_file, "r") as f: + with open(yaml_file, "r", encoding="utf-8") as f: yaml_str = f.read() return self.parse(yaml_str) |
