mirror of
https://github.com/tbabej/taskwiki.git
synced 2025-08-19 06:43:06 +02:00
VimwikiTask: Allow short UUIDs and generate them by default
This commit is contained in:
parent
d6595dfe04
commit
ef3b238b79
3 changed files with 9 additions and 3 deletions
|
@ -2,6 +2,7 @@ import re
|
|||
|
||||
# Unnamed building blocks
|
||||
UUID_UNNAMED = r'[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}'
|
||||
UUID_UNNAMED_SHORT = r'[0-9a-fA-F]{8}'
|
||||
DUE_UNNAMED = r'\(\d{4}-\d\d-\d\d( \d\d:\d\d)?\)'
|
||||
SPACE_UNNAMED = r'\s*'
|
||||
NONEMPTY_SPACE_UNNAMED = r'\s+'
|
||||
|
@ -13,13 +14,14 @@ TEXT_FORBIDDEN_SUFFIXES = (
|
|||
r'\(\d{4}-\d\d-\d\d\)', r'\(\d{4}-\d\d-\d\d \d\d:\d\d\)', # Any datetime value
|
||||
r'\(\d{4}-\d\d-\d\d', # Any datetime value
|
||||
UUID_UNNAMED, # Text cannot end with UUID
|
||||
UUID_UNNAMED_SHORT,
|
||||
)
|
||||
|
||||
# Building blocks
|
||||
BRACKET_OPENING = re.escape('* [')
|
||||
BRACKET_CLOSING = re.escape('] ')
|
||||
EMPTY_SPACE = r'(?P<space>\s*)'
|
||||
UUID = r'(?P<uuid>{0})'.format(UUID_UNNAMED)
|
||||
UUID = r'(?P<uuid>{0}|{1})'.format(UUID_UNNAMED, UUID_UNNAMED_SHORT)
|
||||
DUE = r'(?P<due>{0})'.format(DUE_UNNAMED)
|
||||
UUID_COMMENT = '#{0}'.format(UUID)
|
||||
TEXT = r'(?P<text>.+' + ''.join(['(?<!%s)' % suffix for suffix in TEXT_FORBIDDEN_SUFFIXES]) + ')'
|
||||
|
|
|
@ -247,7 +247,7 @@ class VimwikiTask(object):
|
|||
self['description'] if self['description'] else 'TEXT MISSING?',
|
||||
' ' + '!' * self.priority_from_tw_format if self['priority'] else '',
|
||||
' ' + self['due'].strftime(regexp.DATETIME_FORMAT) if self['due'] else '',
|
||||
' #' + self['uuid'] if self['uuid'] else '',
|
||||
' #' + self['uuid'].split('-')[0] if self['uuid'] else '',
|
||||
])
|
||||
|
||||
def find_parent_task(self):
|
||||
|
|
|
@ -109,7 +109,11 @@ class IntegrationTest(object):
|
|||
|
||||
# Find the task and fill in its uuid
|
||||
tasks = self.tw.tasks.filter(description=match.group('desc'))
|
||||
return line.format(uuid=tasks[0]['uuid']) if tasks else line
|
||||
if tasks:
|
||||
# Return {uuid} replaced by short form UUID
|
||||
return line.format(uuid=tasks[0]['uuid'].split('-')[0])
|
||||
else:
|
||||
return line
|
||||
|
||||
# First, run sanity checks
|
||||
self.check_sanity()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue