Exemplo n.º 1
0
class TestRepo(fake_env.TestFakeFs):

    def setUp(self):
        super(TestRepo, self).setUp()
        default_conf = config.load_default_conf()
        self.repo = Repository(default_conf, create=True)
        self.repo.push_paper(Paper.from_bibentry(fixtures.turing_bibentry))
Exemplo n.º 2
0
class TestRepo(fake_env.TestFakeFs):

    def setUp(self):
        super(TestRepo, self).setUp()
        default_conf = config.load_default_conf()
        self.repo = Repository(default_conf, create=True)
        self.repo.push_paper(Paper.from_bibentry(fixtures.turing_bibentry))
Exemplo n.º 3
0
    def menu_main(self, library="default", tag=None):
        """Present the main menu for the given library.

        Parameters
        ----------
        library : str
            The default library.
        tag : str
            Present only documents with the given tag.

        Returns
        -------
        TODO

        """
        if tag:
            tag_post = f"(<i>{tag}</i>)"
        else:
            tag_post = ""

        menu_ = [
            ("", "Change library", ""),
            ("", "Add publication", ""),
            ("", "Search tags", f"{tag_post}"),
            ("", "Sync. repo(s)", ""),
        ]

        if tag:
            menu_.insert(0, ("", "Show all", ""))

        menu_str = (f"{ico}\t <b>{opt}</b> {inf}\0" for ico, opt, inf in menu_)

        if library == "default":
            conf = self.load_conf(self._default_lib)
        else:
            conf = self.load_conf(library)

        repo = Repository(conf)

        entries = self._gen_menu_entries(repo, tag)
        menu_entries, keys = zip(*entries)

        wofi_disp = chain(menu_str, menu_entries)

        wofi = self._wofi
        wofi.width = 1200
        wofi.height = 700
        selected = wofi.select("Literature", wofi_disp, keep_newlines=True)

        if selected[0] >= len(menu_):
            citekey = keys[selected[0] - len(menu_)]
            self.menu_reference(repo, citekey, tag)
        elif selected[0] != -1 and selected[0] < len(menu_):
            option = menu_[selected[0]][1]
            if option == "Change library":
                self.menu_change_lib(library)
            elif option == "Add publication":
                self.menu_add(repo, library)
            elif option == "Search tags":
                self.menu_tags(repo, library)
            elif option == "Sync. repo(s)":
                pass
            elif option == "Show all":
                self.menu_main(library)
Exemplo n.º 4
0
 def setUp(self):
     super(TestRepo, self).setUp()
     self.repo = Repository(configs.Config(), create=True)
     self.repo.push_paper(Paper.from_bibentry(fixtures.turing_bibentry))