browser/firefox: refactor ff{bookmarks,history}
This commit is contained in:
parent
0021426686
commit
36abb82f63
|
@ -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")
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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":
|
||||
|
|
Loading…
Reference in a new issue