Ejemplo n.º 1
0
    def open_journal(self, data_dir):
        if not os.path.exists(data_dir):
            logging.warning(
                'The dir %s does not exist. Select a different dir.' %
                data_dir)
            return

        if self.months:
            self.save_to_disk(changing_journal=True)

        logging.info('Opening journal at %r' % data_dir)
        self.dirs.data_dir = data_dir

        self.month = None
        self.months.clear()
        self.frame.search_box.clear()
        self.search_index.clear()

        self.months = storage.load_all_months_from_disk(data_dir)

        # Nothing to save before first day change
        self.load_day(self.actual_date)

        if self.is_first_start and not os.listdir(data_dir) and not self.days:
            self.add_instruction_content()

        # We can't use self.days here since it uses self.save_old_day.
        for month in self.months.values():
            for day in month.days.values():
                self.search_index.add(day.date, day.get_indexed_words())

        self.stats = Statistics(self)

        self.frame.cloud.update(force_update=True)

        self.frame.categories_tree_view.categories = self.categories
        # Add auto-completion for tag search
        self.frame.search_box.set_entries(
            ['#%s' % data.escape_tag(tag) for tag in self.categories])

        self.title = filesystem.get_journal_title(data_dir)

        # Set frame title
        self.set_frame_title()

        # Save the folder for next start
        if not self.dirs.portable:
            self.config['dataDir'] = data_dir
        else:
            rel_data_dir = filesystem.get_relative_path(
                self.dirs.app_dir, data_dir)
            self.config['dataDir'] = rel_data_dir
Ejemplo n.º 2
0
    def open_journal(self, data_dir):
        if not os.path.exists(data_dir):
            logging.warning(
                "The dir %s does not exist. Select a different dir." %
                data_dir)
            return

        if self.months:
            self.save_to_disk(changing_journal=True)

        logging.info("Opening journal at %r" % data_dir)
        self.dirs.data_dir = data_dir

        self.month = None
        self.months.clear()
        self.frame.search_box.clear()
        self.frame.day_text_field.clear_buffers()

        self.months = storage.load_all_months_from_disk(data_dir)

        # Nothing to save before first day change
        self.load_day(self.actual_date)

        if self.is_first_start and not os.listdir(data_dir) and not self.days:
            self.add_instruction_content()

        self.stats = Statistics(self)

        self.frame.cloud.update(force_update=True)

        self.frame.categories_tree_view.categories = self.categories
        self.frame.search_box.set_entries(self.get_escaped_tags())

        self.title = filesystem.get_journal_title(data_dir)

        # Set frame title
        self.set_frame_title()

        # Save the folder for next start
        if not self.dirs.portable:
            self.config["dataDir"] = data_dir
        else:
            rel_data_dir = filesystem.get_relative_path(
                self.dirs.app_dir, data_dir)
            self.config["dataDir"] = rel_data_dir