Skip to content

Commit

Permalink
Use cross-platform paths
Browse files Browse the repository at this point in the history
The original version used unix paths for source and destination
directories and files.  Now os.path.join and os.path.pardir are used so
that it will work properly on Windows.
  • Loading branch information
cayennes committed Apr 4, 2012
1 parent e339e7e commit 240bd8d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions kanji-colorize.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ def hex_to_unicode_char(match_object):

if (os.path.exists('kanji')):
src_dir = 'kanji'
elif (os.path.exists('kanjivg/kanji')):
src_dir = 'kanjivg/kanji'
elif (os.path.exists('../kanjivg/kanji')):
src_dir = '../kanjivg/kanji'
elif (os.path.exists(os.path.join('kanjivg', 'kanji'))):
src_dir = os.path.join('kanjivg', 'kanji')
elif (os.path.exists(os.path.join(os.path.pardir,'kanjivg','kanji'))):
src_dir = os.path.join(os.path.pardir,'kanjivg','kanji')

dst_dir = 'kanji-colorize-' + mode
if not (os.path.exists(dst_dir)):
Expand All @@ -130,7 +130,7 @@ def hex_to_unicode_char(match_object):

for src_filename in os.listdir(src_dir):
# read original svg
with open(src_dir + '/' + src_filename, 'r') as f:
with open(os.path.join(src_dir, src_filename), 'r') as f:
svg = f.read()
# modify
svg = color_svg(svg)
Expand All @@ -141,5 +141,5 @@ def hex_to_unicode_char(match_object):
dst_filename = convert_file_name(src_filename)
else:
dst_filename = src_filename
with open(dst_dir + '/' + dst_filename, 'w') as f:
with open(os.path.join(dst_dir, dst_filename), 'w') as f:
f.write(svg)

0 comments on commit 240bd8d

Please sign in to comment.