From: W. Trevor King Date: Sat, 20 Feb 2010 18:21:25 +0000 (-0500) Subject: Added `be html --min-id-length INT` option X-Git-Tag: 1.0.0~59^2~9 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=b356b3a7628b687a3de9f714102c4fd2a170348b;p=be.git Added `be html --min-id-length INT` option --- diff --git a/libbe/command/html.py b/libbe/command/html.py index 43d4683..1148236 100644 --- a/libbe/command/html.py +++ b/libbe/command/html.py @@ -93,6 +93,11 @@ class HTML (libbe.command.Command): name='export-template-dir', metavar='DIR', default='./default-templates/', completion_callback=libbe.command.util.complete_path)), + libbe.command.Option(name='min-id-length', short_name='l', + help='Attempt to truncate bug and comment IDs to this length. Set to -1 for non-truncated IDs (%default)', + arg=libbe.command.Argument( + name='min-id-length', metavar='INT', + default=-1, type='int')), libbe.command.Option(name='verbose', short_name='v', help='Verbose output, default is %default'), ]) @@ -107,6 +112,7 @@ class HTML (libbe.command.Command): template=params['template-dir'], title=params['title'], index_header=params['index-header'], + min_id_length=params['min-id-length'], verbose=params['verbose'], stdout=self.stdout) html_gen.run(params['output']) @@ -123,8 +129,8 @@ Html = HTML # alias for libbe.command.base.get_command_class() class HTMLGen (object): def __init__(self, bd, template=None, title="Site Title", index_header="Index Header", + min_id_length=-1, verbose=False, encoding=None, stdout=None, - min_id_length=3 ): self.generation_time = time.ctime() self.bd = bd @@ -320,7 +326,7 @@ class HTMLGen (object): >>> h._long_to_linked_user_replacer([bd], 'abc123/a') 'abc/a' >>> h._long_to_linked_user_replacer([bd], 'abc123/a/0123') - 'abc/a/012' + 'abc/a/012' >>> h._long_to_linked_user_replacer([bd], 'x') '#x#' >>> h._long_to_linked_user_replacer([bd], '') diff --git a/libbe/util/id.py b/libbe/util/id.py index 76079e7..9192ac8 100644 --- a/libbe/util/id.py +++ b/libbe/util/id.py @@ -232,6 +232,8 @@ def _truncate(uuid, other_uuids, min_length=3): -------- _expand : inverse """ + if min_length == -1: + return uuid chars = min_length for id in other_uuids: if id == uuid: