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
|
from lib.FirefoxProfile import FirefoxProfile
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
with FirefoxProfile.default() as ff:
|
||||||
ff = FirefoxProfile.default()
|
|
||||||
choice = FzfPrompt().prompt(ff.bookmarks())
|
choice = FzfPrompt().prompt(ff.bookmarks())
|
||||||
if choice:
|
if choice:
|
||||||
ff.open("http" + choice[0].split(", http")[1])
|
ff.browse("http" + choice[0].split(", http")[1])
|
||||||
else:
|
else:
|
||||||
print("Aborted")
|
print("Aborted")
|
||||||
|
|
|
@ -4,10 +4,9 @@ from pyfzf import FzfPrompt
|
||||||
from lib.FirefoxProfile import FirefoxProfile
|
from lib.FirefoxProfile import FirefoxProfile
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
with FirefoxProfile.default() as ff:
|
||||||
ff = FirefoxProfile.default()
|
|
||||||
choice = FzfPrompt().prompt(ff.history())
|
choice = FzfPrompt().prompt(ff.history())
|
||||||
if choice:
|
if choice:
|
||||||
ff.open("http" + choice[0].split(", http")[1])
|
ff.browse("http" + choice[0].split(", http")[1])
|
||||||
else:
|
else:
|
||||||
print("Aborted")
|
print("Aborted")
|
||||||
|
|
|
@ -13,6 +13,12 @@ class FirefoxProfile:
|
||||||
self.db = sqlite.connect(dbfile)
|
self.db = sqlite.connect(dbfile)
|
||||||
self.cur = self.db.cursor()
|
self.cur = self.db.cursor()
|
||||||
|
|
||||||
|
def __enter__(self):
|
||||||
|
return FirefoxProfile.default()
|
||||||
|
|
||||||
|
def __exit__(self, _, __, ___):
|
||||||
|
self.close()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def default():
|
def default():
|
||||||
dbfile = None
|
dbfile = None
|
||||||
|
@ -59,7 +65,7 @@ class FirefoxProfile:
|
||||||
result.append(key)
|
result.append(key)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def open(self, url):
|
def browse(self, url):
|
||||||
if _platform.startswith("linux"):
|
if _platform.startswith("linux"):
|
||||||
os.system('xdg-open "{}"'.format(url))
|
os.system('xdg-open "{}"'.format(url))
|
||||||
elif _platform == "darwin":
|
elif _platform == "darwin":
|
||||||
|
|
Loading…
Reference in a new issue