Fix up some stuff, migrate to cleaned up chrome tabs

This commit is contained in:
Ryan Holmes
2017-06-12 20:38:00 -04:00
parent ae0da59ed2
commit 9712ec4fbf
3 changed files with 660 additions and 647 deletions

View File

@@ -45,14 +45,14 @@ def __createDirs(path):
def getPyfaRoot():
base = getattr(sys.modules['__main__'], "__file__", sys.executable) if isFrozen() else sys.argv[0]
base = getattr(sys.modules['__main__'], "__file__", sys.executable) if isFrozen() else __file__
root = os.path.dirname(os.path.realpath(os.path.abspath(base)))
root = root
return root
def getDefaultSave():
return str(os.path.expanduser(os.path.join("~", ".pyfa")), sys.getfilesystemencoding())
return os.path.expanduser(os.path.join("~", ".pyfa"))
def defPaths(customSavePath):

View File

@@ -20,6 +20,7 @@
import io
import os.path
import zipfile
from collections import OrderedDict
# noinspection PyPackageRequirements
import wx
@@ -29,23 +30,18 @@ import config
from logbook import Logger
logging = Logger(__name__)
try:
from collections import OrderedDict
except ImportError:
from .utils.compat import OrderedDict
class BitmapLoader(object):
try:
archive = zipfile.ZipFile(os.path.join(config.pyfaPath, 'imgs.zip'), 'r')
logging.info("Using zipped image files.")
except IOError:
except (IOError, TypeError):
logging.info("Using local image files.")
archive = None
cachedBitmaps = OrderedDict()
dontUseCachedBitmaps = False
max_bmps = 500
cached_bitmaps = OrderedDict()
dont_use_cached_bitmaps = False
max_cached_bitmaps = 500
@classmethod
def getStaticBitmap(cls, name, parent, location):
@@ -55,25 +51,25 @@ class BitmapLoader(object):
@classmethod
def getBitmap(cls, name, location):
if cls.dontUseCachedBitmaps:
if cls.dont_use_cached_bitmaps:
img = cls.getImage(name, location)
if img is not None:
return img.ConvertToBitmap()
path = "%s%s" % (name, location)
if len(cls.cachedBitmaps) == cls.max_bmps:
cls.cachedBitmaps.popitem(False)
if len(cls.cached_bitmaps) == cls.max_cached_bitmaps:
cls.cached_bitmaps.popitem(False)
if path not in cls.cachedBitmaps:
if path not in cls.cached_bitmaps:
img = cls.getImage(name, location)
if img is not None:
bmp = img.ConvertToBitmap()
else:
bmp = None
cls.cachedBitmaps[path] = bmp
cls.cached_bitmaps[path] = bmp
else:
bmp = cls.cachedBitmaps[path]
bmp = cls.cached_bitmaps[path]
return bmp

File diff suppressed because it is too large Load Diff