Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@gatesphere
Last active December 27, 2015 09:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gatesphere/7306696 to your computer and use it in GitHub Desktop.
Save gatesphere/7306696 to your computer and use it in GitHub Desktop.
Using nodewatch.py for productivity
import datetime
import operator
from dateutil.relativedelta import relativedelta # do a 'pip install python-dateutil' for this
@language python
<< imports >>
@others
categoryname = 'LTD: 04 Due This Month'
today = datetime.date.today() + relativedelta(months=1)
tasks = get_tasks_by_date(today, comparator=operator.le)
c.theNodewatchController.add(categoryname, tasks)
@language python
<< imports >>
@others
categoryname = 'LTD: 03 Due This Week'
today = datetime.date.today() + relativedelta(days=7)
tasks = get_tasks_by_date(today, comparator=operator.le)
c.theNodewatchController.add(categoryname, tasks)
@language python
<< imports >>
@others
categoryname = 'LTD: 01 Due Today'
today = datetime.date.today()
tasks = get_tasks_by_date(today, comparator=operator.eq)
c.theNodewatchController.add(categoryname, tasks)
@language python
<< imports >>
@others
categoryname = 'LTD: 02 Due Tomorrow'
today = datetime.date.today() + relativedelta(days=1)
tasks = get_tasks_by_date(today, comparator=operator.eq)
c.theNodewatchController.add(categoryname, tasks)
@language python
<< imports >>
@others
categoryname = 'LTD: 00 Past Due'
today = datetime.date.today()
tasks = get_tasks_by_date(today, comparator=operator.lt)
c.theNodewatchController.add(categoryname, tasks)
## workhorse
def get_tasks_by_date(date, comparator=operator.lt):
n = []
for v in c.all_unique_nodes():
duedate = c.cleo.getat(v, 'duedate')
nextworkdate = c.cleo.getat(v, 'nextworkdate')
priority = c.cleo.getat(v, 'priority')
if priority: priority = int(priority)
if (((duedate and comparator(duedate,date)) or
(nextworkdate and comparator(nextworkdate,date)))
and priority != 100):
n.append(v)
return n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment