Skip to content

Instantly share code, notes, and snippets.

@linuxcaffe
Forked from wbsch/on-add_inline_tags.py
Last active September 4, 2015 05:53
Show Gist options
  • Save linuxcaffe/4c82977fb3894b1bf6d8 to your computer and use it in GitHub Desktop.
Save linuxcaffe/4c82977fb3894b1bf6d8 to your computer and use it in GitHub Desktop.

Revisions

  1. @wbsch wbsch revised this gist Mar 25, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion on-add_inline_tags.py
    Original file line number Diff line number Diff line change
    @@ -16,7 +16,7 @@

    inline_tags = re.findall(r"(?:\A| )@([^ ]+)", t['description'])
    for newtag in inline_tags:
    if not 'tags' in t:
    if 'tags' not in t:
    t['tags'] = [newtag]
    elif newtag not in t['tags']:
    t['tags'].append(newtag)
  2. @wbsch wbsch revised this gist Mar 25, 2015. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions on-add_inline_tags.py
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    #!/usr/bin/env python
    #
    # PoC for "inline tags", as described in TW-1377
    # https://bug.tasktools.org/browse/TW-1377
    # PoC for "inline tags", as described in TW-1357
    # https://bug.tasktools.org/browse/TW-1357
    #
    # Turns
    # $ task add I saw @bob in the @garden
  3. @wbsch wbsch created this gist Mar 25, 2015.
    25 changes: 25 additions & 0 deletions on-add_inline_tags.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    #!/usr/bin/env python
    #
    # PoC for "inline tags", as described in TW-1377
    # https://bug.tasktools.org/browse/TW-1377
    #
    # Turns
    # $ task add I saw @bob in the @garden
    # Into the equivalent of
    # $ task add I saw bob in the garden +bob +garden

    import json
    import re
    import sys

    t = json.loads(sys.stdin.readline())

    inline_tags = re.findall(r"(?:\A| )@([^ ]+)", t['description'])
    for newtag in inline_tags:
    if not 'tags' in t:
    t['tags'] = [newtag]
    elif newtag not in t['tags']:
    t['tags'].append(newtag)
    t['description'] = re.sub(r"(\A| )@([^ ]+)", r"\1\2", t['description'])

    print(json.dumps(t))