Fix number of character printed in `[...]' entries - stahg-gopher - Static Mercurial page generator for gopher HTML hg clone https://bitbucket.org/iamleot/stahg-gopher DIR Log DIR Files DIR Refs DIR README DIR LICENSE --- DIR changeset 3e46cc4d7540c16a90764ddb64d3ede84dbb4809 DIR parent 992fba0fe82e9f919c265767f0548e62c0bbbc69 HTML Author: Leonardo Taccari <iamleot@gmail.com> Date: Mon, 13 May 2019 00:06:34 Fix number of character printed in `[...]' entries The gph_escape_entry() should be done after formatting, not before! (otherwise possible escaping character are counted as well!) Diffstat: stahg-gopher.py | 17 +++++++++-------- 1 files changed, 9 insertions(+), 8 deletions(-) --- diff -r 992fba0fe82e -r 3e46cc4d7540 stahg-gopher.py --- a/stahg-gopher.py Sun May 12 22:49:44 2019 +0200 +++ b/stahg-gopher.py Mon May 13 00:06:34 2019 +0200 @@ -187,10 +187,11 @@ file=f) break print('[1|{desc}|{path}|server|port]'.format( - desc='{date:16} {commit_message:40} {author}'.format( - date=e.date.strftime('%Y-%m-%d %H:%M'), - commit_message=gph_escape_entry(shorten(e.desc.decode(), 40)), - author=author_name(e.author.decode())), + desc=gph_escape_entry( + '{date:16} {commit_message:40} {author}'.format( + date=e.date.strftime('%Y-%m-%d %H:%M'), + commit_message=shorten(e.desc.decode(), 40), + author=author_name(e.author.decode()))), path='{base_path}/commit/{changeset}.gph'.format( base_path=bp, changeset=e.node.decode())), file=f) @@ -210,12 +211,12 @@ for e in self.client.manifest(rev=b'tip'): print('[1|{desc}|{path}|server|port]'.format( - desc='{mode:10} {name:68}'.format( + desc=gph_escape_entry('{mode:10} {name:68}'.format( mode=stat.filemode(int(e[1].decode(), base=8)), - name=gph_escape_entry(e[4].decode())), - path='{base_path}/file/{file}.gph'.format( + name=e[4].decode())), + path=gph_escape_entry('{base_path}/file/{file}.gph'.format( base_path=bp, - file=gph_escape_entry(e[4].decode()))), file=f) + file=e[4].decode()))), file=f) def refs(self):