From 240bd8de379332a5c1ac0490ab37b22fc93154bc Mon Sep 17 00:00:00 2001 From: Cayenne Date: Wed, 4 Apr 2012 09:28:23 -0400 Subject: [PATCH] Use cross-platform paths 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. --- kanji-colorize.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/kanji-colorize.py b/kanji-colorize.py index f8ebed0..cda87ba 100755 --- a/kanji-colorize.py +++ b/kanji-colorize.py @@ -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)): @@ -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) @@ -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)