add CacheFile

This commit is contained in:
Josh Holtrop 2016-06-22 16:53:41 -04:00
parent 77f54ad3b6
commit a09b4e0446
3 changed files with 24 additions and 1 deletions

View File

@ -9,6 +9,6 @@ setup(name = "simplesvnbrowser",
license = "zlib",
packages = ["simplesvnbrowser"],
zip_safe = False,
scripts = ["bin/simple-svn-browser"],
install_requires = ["pyxdg"],
)

View File

@ -0,0 +1,20 @@
import xdg.BaseDirectory
import os
class CacheFile:
params = None
def __init__(self):
if CacheFile.params is None:
CacheFile.params = {}
cfp = self.__cache_file_path()
if os.path.exists(cfp):
with open(cfp, "r") as f:
cache_content = f.read()
exec(cache_content, CacheFile.params)
def __cache_dir(self):
return xdg.BaseDirectory.save_cache_path("simple-svn-browser")
def __cache_file_path(self):
return os.path.join(self.__cache_dir(), "settings")

View File

@ -3,11 +3,14 @@ gi.require_version("Gtk", "3.0")
from gi.repository import Gtk
from .version import VERSION
from .run_svn import run_svn
from .cache_file import CacheFile
class MainWindow(Gtk.Window):
def __init__(self, url):
super().__init__(title = "Simple SVN Browser v%s" % VERSION)
self.cache_file = CacheFile()
top_hbox = Gtk.Box()
address_entry = Gtk.Entry(text = url)
go_button = Gtk.Button(label = "Go")