Exemplo n.º 1
0
def add_todo(args):
    """Add a new item to the list of things todo."""
    if str(args) == args:
        line = args
    elif len(args) >= 1:
        line = concat(args, " ")
    else:
        line = prompt("Add:")

    prepend = CONFIG["PRE_DATE"]
    l = len([1 for l in iter_todos()]) + 1
    pri_re = re.compile("(\([A-X]\))")

    if pri_re.match(line) and prepend:
        line = pri_re.sub(concat(["\g<1>", datetime.now().strftime(" %Y-%m-%d ")]), line)
    elif prepend:
        line = concat([datetime.now().strftime("%Y-%m-%d "), line])

    with open(CONFIG["TODO_FILE"], "a") as fd:
        fd.write(concat([line, "\n"]))

    s = "TODO: '{0}' added on line {1}.".format(line, l)
    print(s)
    if CONFIG["USE_GIT"]:
        _git_commit([CONFIG["TODO_FILE"]], s)
    return l
Exemplo n.º 2
0
def add_todo(args):
    """Add a new item to the list of things todo."""
    if str(args) == args:
        line = args
    elif len(args) >= 1:
        line = concat(args, " ")
    else:
        line = prompt("Add:")

    prepend = CONFIG["PRE_DATE"]
    l = len([1 for l in iter_todos()]) + 1
    pri_re = re.compile('(\([A-X]\))')

    if pri_re.match(line) and prepend:
        line = pri_re.sub(
            concat(["\g<1>", datetime.now().strftime(" %Y-%m-%d ")]), line)
    elif prepend:
        line = concat([datetime.now().strftime("%Y-%m-%d "), line])

    with open(CONFIG["TODO_FILE"], "a") as fd:
        fd.write(concat([line, "\n"]))

    s = "TODO: '{0}' added on line {1}.".format(line, l)
    print(s)
    if CONFIG["USE_GIT"]:
        _git_commit([CONFIG["TODO_FILE"]], s)
    return l
Exemplo n.º 3
0
 def count_matches(self, regexp=None):
     count = 0
     for line in todo.iter_todos():
         if regexp == None or re.match(regexp, line):
             count += 1
     return count
Exemplo n.º 4
0
 def count_matches(self, regexp=None):
     count = 0
     for line in todo.iter_todos():
         if regexp == None or re.match(regexp, line):
             count += 1
     return count