示例#1
0
def test_empty():
    edict = short_id.prefix_dict()
    assert len(edict) == 0
    assert not edict
    assert edict.keys() == []
    assert edict.search("") == []
    assert edict.search("0") == []
    assert raises(KeyError, edict.unique, "a")
    assert edict.shortest("bcd") == "bcd"
示例#2
0
def test_simple():
    indict = short_id.prefix_dict()
    indict["test"] = "me"
    indict["teach"] = "you"
    assert len(indict) == 2
    assert indict
    assert sorted(indict.keys()) == ["teach", "test"]
    assert sorted(indict.search("")) == ["teach", "test"]
    assert sorted(indict.search("t")) == ["teach", "test"]
    assert sorted(indict.search("e")) == []
    assert raises(KeyError, indict.unique, "e")
    assert raises(ValueError, indict.unique, "t")
    assert indict.unique("teach") == "you"
    assert indict.shortest("teach") == "tea"
    assert indict.shortest("pumpkin") == "pumpkin"
示例#3
0
calendar_lookup = {}

def get_object_urlname(davobject):
    """Returns the last component of the url path as the object's name"""
    name = davobject.url.path.rstrip("/")
    name = name if "/" not in name else name[name.rfind("/")+1:]
    return urllib2.unquote(name)

for calendar in calendars:
    name = calendar.name or get_object_urlname(calendar)
    # print (calendar.url.geturl(), name, calendar.id)
    calendar_lookup[name] = calendar

tasks_calendar = calendar_lookup["Tasks"]

tasks = tasks_calendar.events()
task_lookup = short_id.prefix_dict()

for task in tasks:
    task_id = task.id or (get_object_urlname(task).replace(".ics", ""))
    task_lookup[task_id] = task

for task_id in sorted(task_lookup):
    task = task_lookup[task_id]
    task.load()
    # task.instance.prettyPrint()
    vtodo = task.instance.vtodo
    print task_lookup.shortest(task_id), task_id, vtodo.status.value, vtodo.summary.value, vtodo.priority.value

示例#4
0
 def load_tasks(self):
     """loads all tasks in this TaskList into a lookup by id"""
     self._tasks = tasks = short_id.prefix_dict()
     for task in self.tasks():
         task_id = task.id or (get_object_urlname(task).replace(".ics", ""))
         tasks[task_id] = task