How to use the icalendar.Todo function in icalendar

To help you get started, we’ve selected a few icalendar examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pimutils / todoman / todoman / model.py View on Github external
def serialize(self, original=None):
        """Serialize a Todo into a VTODO."""
        if not original:
            original = icalendar.Todo()
        self.vtodo = original

        for source, target in self.FIELD_MAP.items():
            if getattr(self.todo, source):
                self.set_field(
                    target,
                    self.serialize_field(source, getattr(self.todo, source)),
                )

        return self.vtodo
github agateau / yokadi / yokadi / yical / yical.py View on Github external
def createVTodoFromTask(task):
    """Create a VTodo object from a yokadi task
    @param task: yokadi task (db.Task object)
    @return: ical VTODO (icalendar.Calendar.Todo object)"""
    vTodo = icalendar.Todo()
    vTodo["uid"] = TASK_UID % task.id
    vTodo["related-to"] = PROJECT_UID % task.project.id

    # Add standard attribute
    for yokadiAttribute, icalAttribute in YOKADI_ICAL_ATT_MAPPING.items():
        attr = getattr(task, yokadiAttribute)
        if attr:
            if yokadiAttribute == "urgency":
                attr = icalutils.yokadiUrgencyToIcalPriority(attr)
            if yokadiAttribute == "title":
                attr += " (%s)" % task.id
            vTodo.add(icalAttribute, attr)

    # Add categories from keywords
    categories = []
    if task.keywords:
github nicoe / remhind / remhind / events.py View on Github external
def _get_components_from_ics(self, ics):
        cal = icalendar.Calendar.from_ical(ics.read_text())
        for component in cal.subcomponents:
            if isinstance(component, (icalendar.Event, icalendar.Todo)):
                yield (ics, component)
github ninjatrench / DeveloperHorizon / controller / bitbucket_issues.py View on Github external
def make_todo(issue) -> icalendar.Todo():
    try:
        todo = icalendar.Todo()
        todo['uid'] = issue.get('local_id', None)
        todo['summary'] = issue.get('title', None)
        todo['description'] = str(issue.get('content', None))
        todo['url'] = make_url(issue.get("resource_uri", None))
        todo['created'] = issue.get('utc_created_on', None)
        todo['last-modified'] = issue.get('utc_last_updated', None)
        todo['status'] = 'NEEDS-ACTION'
        todo['emailID'] = ""
        todo['category'] = issue["metadata"].get('kind')
        todo['organizer'] = ""
        return todo

    except Exception as e:
        print(e)
        return None
github agateau / yokadi / yokadi / yical / yical.py View on Github external
def generateCal():
    """Generate an ical calendar from yokadi database
    @return: icalendar.Calendar object"""
    cal = icalendar.Calendar()
    cal.add("prodid", '-//Yokadi calendar //yokadi.github.com//')
    cal.add("version", "2.0")
    # Add projects
    for project in Project.select(Project.q.active == True):
        vTodo = icalendar.Todo()
        vTodo.add("summary", project.name)
        vTodo["uid"] = PROJECT_UID % project.id
        cal.add_component(vTodo)
    # Add tasks
    for task in Task.select(Task.q.status != "done"):
        vTodo = createVTodoFromTask(task)
        cal.add_component(vTodo)

    return cal
github untitaker / watdo / watdo / model.py View on Github external
def dummy_vcal():
    cal = icalendar.Calendar()
    cal.add('prodid', '-//watdo//mimedir.icalendar//EN')
    cal.add('version', '2.0')

    todo = icalendar.Todo()
    todo['uid'] = icalendar.tools.UIDGenerator().uid(host_name='watdo')
    cal.add_component(todo)

    return cal