Exemple #1
0
def test_journal_title():
    dirs = [
        ("/home/my journal", "my journal"),
        ("/my journal/", "my journal"),
        ("/home/name/Journal", "Journal"),
        ("/home/name/jörnal", "jörnal"),
        ("/", "/"),
    ]
    for path, title in dirs:
        assert get_journal_title(path) == title
Exemple #2
0
def test_journal_title():
    dirs = [
        ('/home/my journal', 'my journal'),
        ('/my journal/', 'my journal'),
        ('/home/name/Journal', 'Journal'),
        ('/home/name/jörnal', 'jörnal'),
        ('/', '/'),
    ]
    for path, title in dirs:
        assert get_journal_title(path) == title
def test_journal_title():
    dirs = [
        ('/home/my journal', 'my journal'),
        ('/my journal/', 'my journal'),
        ('/home/name/Journal', 'Journal'),
        (u'/home/name/jörnal', u'jörnal'),
        ('/', '/'),
    ]
    for path, title in dirs:
        assert get_journal_title(path) == title
Exemple #4
0
def test_journal_title():
    root = os.path.abspath(os.sep)
    dirs = [
        ("/home/my journal", "my journal"),
        ("/my journal/", "my journal"),
        ("/home/name/Journal", "Journal"),
        ("/home/name/jörnal", "jörnal"),
        (root, root),
    ]
    for path, title in dirs:
        assert get_journal_title(path) == title
    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
Exemple #6
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
Exemple #7
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
Exemple #8
0
    def open_journal(self, data_dir, load_files=True):

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

        # Password Protection
        #password = self.config.read('password', '')

        logging.info('Opening journal at %s' % data_dir)

        if not os.path.exists(data_dir):
            logging.warning('The data dir %s does not exist. Select a different dir.'
                        % data_dir)

            self.frame.show_dir_chooser('open', dir_not_found=True)
            return

        data_dir_empty = not os.listdir(data_dir)

        if not load_files and not data_dir_empty:
            msg_part1 = _('The selected folder is not empty.')
            msg_part2 = _('To prevent you from overwriting data, the folder content has been imported into the new journal.')
            self.show_message('%s %s' % (msg_part1, msg_part2), error=False)
        elif load_files and data_dir_empty:
            self.show_message(_('The selected folder is empty. A new journal has been created.'),
                                error=False)

        self.dirs.data_dir = data_dir

        self.month = None
        self.months.clear()

        # We always want to load all files
        if load_files or True:
            self.months = storage.load_all_months_from_disk(data_dir)

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

        self.stats = Statistics(self)

        self.frame.categories_tree_view.categories = self.categories

        if self.is_first_start:
            self.add_instruction_content()

        # Notebook is only on page 1 here, if we are opening a journal the second time
        old_page = self.frame.search_notebook.get_current_page()
        new_page = self.config.read('cloudTabActive', 0)
        # 0 -> 0: search is cleared later
        # 0 -> 1: change to cloud, update automatically
        # 1 -> 0: change to search
        # 1 -> 1: update cloud

        # At tab change, cloud is updated automatically
        self.frame.search_notebook.set_current_page(new_page)
        if new_page == old_page:
            # Without tab change, force update
            self.frame.cloud.update(force_update=True)

        # Reset Search
        self.frame.search_box.clear()

        self.title = filesystem.get_journal_title(data_dir)

        # Set frame title
        if self.title == 'data':
            frame_title = 'RedNotebook'
        else:
            frame_title = 'RedNotebook - ' + self.title
        self.frame.main_frame.set_title(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