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']
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)
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')
def _init_lineparser(self): self._lineparser = lineparser.LineParser(standarddir.config(), 'quickmarks', parent=self)
def lineparser(self, tmpdir): """Fixture to get a LineParser for tests.""" lp = lineparsermod.LineParser(str(tmpdir), 'file') lp.save() return lp