From 085c75ca619da2fe4cb5ae8e8e500ca25fb40fb7 Mon Sep 17 00:00:00 2001 From: Dooho Yi Date: Wed, 15 Sep 2021 23:37:19 +0900 Subject: [PATCH 1/3] update ignore regex --- test_data/.ignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 어떤_파일을_넣을까 From 9184127623c8353836c29c74371f176261a025b5 Mon Sep 17 00:00:00 2001 From: Dooho Yi Date: Thu, 16 Sep 2021 00:17:04 +0900 Subject: [PATCH 2/3] untag in: def thumbnail() --- distribusi/distribusi/distribusi.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/distribusi/distribusi/distribusi.py b/distribusi/distribusi/distribusi.py index 8447722..486d70a 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 = '' From 3add64f5582c43384aca360fe9764628789d347b Mon Sep 17 00:00:00 2001 From: Sewon Ahn Date: Thu, 16 Sep 2021 00:36:52 +0900 Subject: [PATCH 3/3] change alt path --- distribusi/distribusi/distribusi.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/distribusi/distribusi/distribusi.py b/distribusi/distribusi/distribusi.py index 486d70a..fa90980 100644 --- a/distribusi/distribusi/distribusi.py +++ b/distribusi/distribusi/distribusi.py @@ -236,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 = '' @@ -350,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 = '' @@ -358,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)