Ejemplo n.º 1
0
    def testTemplate(self):
        pluginklass = PluginManager.get_plugin_class('calendar')
        plugin = pluginklass()
        plugin.preferences['namespace'] = Path('Calendar')

        notebook = tests.new_notebook()
        plugin.extend(notebook)

        dumper = get_dumper('wiki')

        zim.datetimetz.FIRST_DAY_OF_WEEK = \
         zim.datetimetz.MONDAY
        for path in (
                Path('Calendar:2012'),
                Path('Calendar:2012:04:27'),
                Path('Calendar:2012:Week 17'),
                Path('Calendar:2012:04'),
        ):
            tree = notebook.get_template(path)
            lines = dumper.dump(tree)
            #~ print lines
            self.assertTrue(not 'Created' in ''.join(lines))  # No fall back
            if 'Week' in path.name:
                days = [l for l in lines if l.startswith('=== ')]
                self.assertEqual(len(days), 7)
Ejemplo n.º 2
0
    def read_task_from_selection(self, buffer=None):
        if not buffer:
            buffer = self.window.pageview.textview.get_buffer()
        task = {}

        lines = get_dumper("wiki").dump(buffer.get_parsetree(buffer.get_selection_bounds()))
        match = taskAnchorTreeRe.match("".join(lines))
        if match:
            task = {"id": match.group(2),
                    "title": match.group(3).split("\n", 1)[0],
                    "status": "completed" if match.group(1).startswith("[*]") else "needsAction"
                    }
        else:
            try:
                task["title"] = lines[0].strip()
            except IndexError:
                task["title"] = ""
        if self.preferences["include_start_date"]:
            m = start_date_in_title.match(task["title"])
            if m:
                # ex: 'test 13 _{//>2020-06-03//}' (start date in 'small' markup)
                task["due"] = m[2]  # → "2020-06-03"
                task["title"] = (m[1] + m[4]).replace("_{////}", "").rstrip()  # → "test 13"
        task["notes"] = "".join(lines[1:])

        buffer.delete(*buffer.get_selection_bounds())  # cuts the task
        return task
Ejemplo n.º 3
0
	def testTemplate(self):
		pluginklass = PluginManager.get_plugin_class('calendar')
		plugin = pluginklass()
		plugin.preferences['namespace'] = Path('Calendar')

		notebook = tests.new_notebook()
		plugin.extend(notebook)

		dumper = get_dumper('wiki')

		zim.datetimetz.FIRST_DAY_OF_WEEK = \
			zim.datetimetz.MONDAY
		for path in (
			Path('Calendar:2012'),
			Path('Calendar:2012:04:27'),
			Path('Calendar:2012:Week 17'),
			Path('Calendar:2012:04'),
		):
			tree = notebook.get_template(path)
			lines = dumper.dump(tree)
			#~ print lines
			self.assertTrue(not 'Created' in ''.join(lines)) # No fall back
			if 'Week' in path.name:
				days = [l for l in lines if l.startswith('=== ')]
				self.assertEqual(len(days), 7)
Ejemplo n.º 4
0
    def on_submit_time_for_all_projects(self):
        lines = get_dumper('plain').dump(self.pageview.get_parsetree())
        entries = ProjectsList.parse_journal_day(lines)

        cursor_position = self.pageview.get_cursor_pos()

        self.pageview.set_cursor_pos(0)
        self.pageview.find('@zp')

        for entry in entries:
            if entry.is_new():
                CheckEntryDialog(self, entry, entries).run()
            self.pageview.find_next()

        self.pageview.set_cursor_pos(cursor_position)
        self.pageview.hide_find()
        pass
Ejemplo n.º 5
0
	def testTemplate(self):
		plugin = PluginManager.load_plugin('journal')

		notebook = self.setUpNotebook()

		dumper = get_dumper('wiki')

		zim.datetimetz.FIRST_DAY_OF_WEEK = \
			zim.datetimetz.MONDAY
		for path in (
			Path('Journal:2012'),
			Path('Journal:2012:04:27'),
			Path('Journal:2012:Week 17'),
			Path('Journal:2012:04'),
		):
			tree = notebook.get_template(path)
			lines = dumper.dump(tree)
			#~ print lines
			self.assertTrue(not 'Created' in ''.join(lines)) # No fall back
			if 'Week' in path.name:
				days = [l for l in lines if l.startswith('=== ')]
				self.assertEqual(len(days), 7)