diff --git a/distribusi/distribusi/distribusi.py b/distribusi/distribusi/distribusi.py index 8447722..fa90980 100644 --- a/distribusi/distribusi/distribusi.py +++ b/distribusi/distribusi/distribusi.py @@ -26,6 +26,15 @@ ignore = Ignore() PATTERN_TAG = re.compile(r"(?P.+?)(?P\#.+)*\.(?P.{1,4}$)") PATTERN_TAG_FOLDER = re.compile(r"(?P.+?)(?P\#.+)\/(?P.+)") +def untag(name): + m = PATTERN_TAG.search(name) + if m: + file_name = m.group('name') + file_ext = m.group('ext') + return (file_name + "." + file_ext) + else: + return name + def caption(image): try: process = subprocess.Popen( @@ -78,7 +87,7 @@ def thumbnail(image, name, args): if args.captions: cap = caption(image) else: - cap = name + cap = untag(name) m = PATTERN_TAG_FOLDER.search(cap) if m: @@ -107,11 +116,7 @@ def div(args, type_, subtype, tag, name, fid): - m = PATTERN_TAG.search(name) - if m: - file_name = m.group('name') - file_ext = m.group('ext') - name = file_name + "." + file_ext + name = untag(name) if args.no_filenames: filename = '' @@ -231,7 +236,8 @@ def render_dir(args, directory): c = caption(relative_path) a = FILE_TYPES[type_].format(quote(relative_path), c, c) # ALT 처리 - alt_path = full_path + ".alt" + src = os.path.splitext(full_path) + alt_path = src[0] + ".alt" if os.path.isfile(alt_path): f = open(alt_path, 'r', encoding='utf-8') alt = '' @@ -345,7 +351,8 @@ def distribusify(args, directory, freg): # noqa c = caption(full_path) a = FILE_TYPES[type_].format(quote(name), c, c) # ALT 처리 - alt_path = full_path + ".alt" + src = os.path.splitext(full_path) + alt_path = src[0] + ".alt" if os.path.isfile(alt_path): f = open(alt_path, 'r', encoding='utf-8') alt = '' @@ -353,6 +360,7 @@ def distribusify(args, directory, freg): # noqa line = f.readline() if not line: break alt = alt + line + ' ' + print("alt: " + alt ) a = FILE_TYPES[type_].format(quote(name), alt, c) diff --git a/test_data/.ignore b/test_data/.ignore index 64512ed..2f3b847 100644 --- a/test_data/.ignore +++ b/test_data/.ignore @@ -12,7 +12,7 @@ participants.html style.css 404.html main.js -.+.alt +.+\.alt$ events 여기에_대해_about_here 어떤_파일을_넣을까