Skip to content

Commit 302bdb5

Browse files
committed
mesh: make replaceInplace more robust
avoid "input() already active" error. allow utf8 material names
1 parent 31b4ae0 commit 302bdb5

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

io_ogre/ogre/mesh.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -829,15 +829,15 @@ def duplicate_object(scene, name, copyobj):
829829

830830
# todo: Very ugly, find better way
831831
def replaceInplace(f,searchExp,replaceExp):
832-
import fileinput
833-
for line in fileinput.input(f, inplace=1):
832+
import fileinput
833+
834+
with fileinput.FileInput(f, inplace=True, encoding="utf-8") as file:
835+
for line in file:
834836
if searchExp in line:
835837
line = line.replace(searchExp,replaceExp)
836838
sys.stdout.write(line)
837-
fileinput.close() # reported by jakob
838839

839840
replaceInplace(target_file, '__TO_BE_REPLACED_VERTEX_COUNT__' + '"', str(numverts) + '"' )#+ ' ' * (ls - lr))
840-
del(replaceInplace)
841841

842842
# Start .mesh.xml to .mesh convertion tool
843843
util.xml_convert(target_file, has_uvs=dotextures)

0 commit comments

Comments
 (0)