Example #1
0
    def test_init(self, tmpdir):
        """Test if creating a line parser correctly reads its file."""
        (tmpdir / 'file').write('one\ntwo\n')
        lineparser = lineparsermod.LineParser(str(tmpdir), 'file')
        assert lineparser.data == ['one', 'two']

        (tmpdir / 'file').write_binary(b'\xfe\n\xff\n')
        lineparser = lineparsermod.LineParser(str(tmpdir), 'file', binary=True)
        assert lineparser.data == [b'\xfe', b'\xff']
Example #2
0
    def _init_lineparser(self):
        bookmarks_directory = os.path.join(standarddir.config(), 'bookmarks')
        os.makedirs(bookmarks_directory, exist_ok=True)

        bookmarks_subdir = os.path.join('bookmarks', 'urls')
        self._lineparser = lineparser.LineParser(standarddir.config(),
                                                 bookmarks_subdir,
                                                 parent=self)
Example #3
0
    def __init__(self, parent=None, *, line_parser=None):
        super().__init__(parent)

        if line_parser:
            self._lineparser = line_parser
        else:
            self._lineparser = lineparser.LineParser(
                standarddir.data(), 'cookies', binary=True, parent=self)
        self.parse_cookies()
        config.instance.changed.connect(self._on_cookies_store_changed)
        objreg.get('save-manager').add_saveable(
            'cookies', self.save, self.changed,
            config_opt='content.cookies.store')
Example #4
0
 def _init_lineparser(self):
     self._lineparser = lineparser.LineParser(standarddir.config(),
                                              'quickmarks',
                                              parent=self)
Example #5
0
 def lineparser(self, tmpdir):
     """Fixture to get a LineParser for tests."""
     lp = lineparsermod.LineParser(str(tmpdir), 'file')
     lp.save()
     return lp