browser/firefox: refactor ff{bookmarks,history}

This commit is contained in:
Henrik Lissner 2017-04-09 23:36:06 -04:00
parent 0021426686
commit 36abb82f63
3 changed files with 11 additions and 7 deletions

View file

@ -4,10 +4,9 @@ from pyfzf import FzfPrompt
from lib.FirefoxProfile import FirefoxProfile
if __name__ == '__main__':
ff = FirefoxProfile.default()
with FirefoxProfile.default() as ff:
choice = FzfPrompt().prompt(ff.bookmarks())
if choice:
ff.open("http" + choice[0].split(", http")[1])
ff.browse("http" + choice[0].split(", http")[1])
else:
print("Aborted")

View file

@ -4,10 +4,9 @@ from pyfzf import FzfPrompt
from lib.FirefoxProfile import FirefoxProfile
if __name__ == '__main__':
ff = FirefoxProfile.default()
with FirefoxProfile.default() as ff:
choice = FzfPrompt().prompt(ff.history())
if choice:
ff.open("http" + choice[0].split(", http")[1])
ff.browse("http" + choice[0].split(", http")[1])
else:
print("Aborted")

View file

@ -13,6 +13,12 @@ class FirefoxProfile:
self.db = sqlite.connect(dbfile)
self.cur = self.db.cursor()
def __enter__(self):
return FirefoxProfile.default()
def __exit__(self, _, __, ___):
self.close()
@staticmethod
def default():
dbfile = None
@ -59,7 +65,7 @@ class FirefoxProfile:
result.append(key)
return result
def open(self, url):
def browse(self, url):
if _platform.startswith("linux"):
os.system('xdg-open "{}"'.format(url))
elif _platform == "darwin":