minimize pyside package install
correct line endings to satisfy Lord Travis
This commit is contained in:
parent
1e3cc95e37
commit
537028f88f
@ -52,7 +52,7 @@ install:
|
|||||||
if [ ${QT} == 'pyqt' ]; then
|
if [ ${QT} == 'pyqt' ]; then
|
||||||
travis_retry sudo apt-get -qq -y install python-qt4 python-qt4-gl;
|
travis_retry sudo apt-get -qq -y install python-qt4 python-qt4-gl;
|
||||||
else
|
else
|
||||||
travis_retry sudo apt-get -qq -y install python-pyside python-pyside.qtopengl;
|
travis_retry sudo apt-get -qq -y install python-pyside.qtcore python-pyside.qtgui python-pyside.qtsvg python-pyside.qtopengl;
|
||||||
fi;
|
fi;
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
|
@ -1,52 +1,52 @@
|
|||||||
## Definitions helpful in frozen environments (eg py2exe)
|
## Definitions helpful in frozen environments (eg py2exe)
|
||||||
import os, sys, zipfile
|
import os, sys, zipfile
|
||||||
|
|
||||||
def listdir(path):
|
def listdir(path):
|
||||||
"""Replacement for os.listdir that works in frozen environments."""
|
"""Replacement for os.listdir that works in frozen environments."""
|
||||||
if not hasattr(sys, 'frozen'):
|
if not hasattr(sys, 'frozen'):
|
||||||
return os.listdir(path)
|
return os.listdir(path)
|
||||||
|
|
||||||
(zipPath, archivePath) = splitZip(path)
|
(zipPath, archivePath) = splitZip(path)
|
||||||
if archivePath is None:
|
if archivePath is None:
|
||||||
return os.listdir(path)
|
return os.listdir(path)
|
||||||
|
|
||||||
with zipfile.ZipFile(zipPath, "r") as zipobj:
|
with zipfile.ZipFile(zipPath, "r") as zipobj:
|
||||||
contents = zipobj.namelist()
|
contents = zipobj.namelist()
|
||||||
results = set()
|
results = set()
|
||||||
for name in contents:
|
for name in contents:
|
||||||
# components in zip archive paths are always separated by forward slash
|
# components in zip archive paths are always separated by forward slash
|
||||||
if name.startswith(archivePath) and len(name) > len(archivePath):
|
if name.startswith(archivePath) and len(name) > len(archivePath):
|
||||||
name = name[len(archivePath):].split('/')[0]
|
name = name[len(archivePath):].split('/')[0]
|
||||||
results.add(name)
|
results.add(name)
|
||||||
return list(results)
|
return list(results)
|
||||||
|
|
||||||
def isdir(path):
|
def isdir(path):
|
||||||
"""Replacement for os.path.isdir that works in frozen environments."""
|
"""Replacement for os.path.isdir that works in frozen environments."""
|
||||||
if not hasattr(sys, 'frozen'):
|
if not hasattr(sys, 'frozen'):
|
||||||
return os.path.isdir(path)
|
return os.path.isdir(path)
|
||||||
|
|
||||||
(zipPath, archivePath) = splitZip(path)
|
(zipPath, archivePath) = splitZip(path)
|
||||||
if archivePath is None:
|
if archivePath is None:
|
||||||
return os.path.isdir(path)
|
return os.path.isdir(path)
|
||||||
with zipfile.ZipFile(zipPath, "r") as zipobj:
|
with zipfile.ZipFile(zipPath, "r") as zipobj:
|
||||||
contents = zipobj.namelist()
|
contents = zipobj.namelist()
|
||||||
archivePath = archivePath.rstrip('/') + '/' ## make sure there's exactly one '/' at the end
|
archivePath = archivePath.rstrip('/') + '/' ## make sure there's exactly one '/' at the end
|
||||||
for c in contents:
|
for c in contents:
|
||||||
if c.startswith(archivePath):
|
if c.startswith(archivePath):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def splitZip(path):
|
def splitZip(path):
|
||||||
"""Splits a path containing a zip file into (zipfile, subpath).
|
"""Splits a path containing a zip file into (zipfile, subpath).
|
||||||
If there is no zip file, returns (path, None)"""
|
If there is no zip file, returns (path, None)"""
|
||||||
components = os.path.normpath(path).split(os.sep)
|
components = os.path.normpath(path).split(os.sep)
|
||||||
for index, component in enumerate(components):
|
for index, component in enumerate(components):
|
||||||
if component.endswith('.zip'):
|
if component.endswith('.zip'):
|
||||||
zipPath = os.sep.join(components[0:index+1])
|
zipPath = os.sep.join(components[0:index+1])
|
||||||
archivePath = ''.join([x+'/' for x in components[index+1:]])
|
archivePath = ''.join([x+'/' for x in components[index+1:]])
|
||||||
return (zipPath, archivePath)
|
return (zipPath, archivePath)
|
||||||
else:
|
else:
|
||||||
return (path, None)
|
return (path, None)
|
||||||
|
|
||||||
|
|
@ -1,127 +1,127 @@
|
|||||||
# Copyright (c) 2009 Raymond Hettinger
|
# Copyright (c) 2009 Raymond Hettinger
|
||||||
#
|
#
|
||||||
# Permission is hereby granted, free of charge, to any person
|
# Permission is hereby granted, free of charge, to any person
|
||||||
# obtaining a copy of this software and associated documentation files
|
# obtaining a copy of this software and associated documentation files
|
||||||
# (the "Software"), to deal in the Software without restriction,
|
# (the "Software"), to deal in the Software without restriction,
|
||||||
# including without limitation the rights to use, copy, modify, merge,
|
# including without limitation the rights to use, copy, modify, merge,
|
||||||
# publish, distribute, sublicense, and/or sell copies of the Software,
|
# publish, distribute, sublicense, and/or sell copies of the Software,
|
||||||
# and to permit persons to whom the Software is furnished to do so,
|
# and to permit persons to whom the Software is furnished to do so,
|
||||||
# subject to the following conditions:
|
# subject to the following conditions:
|
||||||
#
|
#
|
||||||
# The above copyright notice and this permission notice shall be
|
# The above copyright notice and this permission notice shall be
|
||||||
# included in all copies or substantial portions of the Software.
|
# included in all copies or substantial portions of the Software.
|
||||||
#
|
#
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
# OTHER DEALINGS IN THE SOFTWARE.
|
# OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
from UserDict import DictMixin
|
from UserDict import DictMixin
|
||||||
|
|
||||||
class OrderedDict(dict, DictMixin):
|
class OrderedDict(dict, DictMixin):
|
||||||
|
|
||||||
def __init__(self, *args, **kwds):
|
def __init__(self, *args, **kwds):
|
||||||
if len(args) > 1:
|
if len(args) > 1:
|
||||||
raise TypeError('expected at most 1 arguments, got %d' % len(args))
|
raise TypeError('expected at most 1 arguments, got %d' % len(args))
|
||||||
try:
|
try:
|
||||||
self.__end
|
self.__end
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
self.clear()
|
self.clear()
|
||||||
self.update(*args, **kwds)
|
self.update(*args, **kwds)
|
||||||
|
|
||||||
def clear(self):
|
def clear(self):
|
||||||
self.__end = end = []
|
self.__end = end = []
|
||||||
end += [None, end, end] # sentinel node for doubly linked list
|
end += [None, end, end] # sentinel node for doubly linked list
|
||||||
self.__map = {} # key --> [key, prev, next]
|
self.__map = {} # key --> [key, prev, next]
|
||||||
dict.clear(self)
|
dict.clear(self)
|
||||||
|
|
||||||
def __setitem__(self, key, value):
|
def __setitem__(self, key, value):
|
||||||
if key not in self:
|
if key not in self:
|
||||||
end = self.__end
|
end = self.__end
|
||||||
curr = end[1]
|
curr = end[1]
|
||||||
curr[2] = end[1] = self.__map[key] = [key, curr, end]
|
curr[2] = end[1] = self.__map[key] = [key, curr, end]
|
||||||
dict.__setitem__(self, key, value)
|
dict.__setitem__(self, key, value)
|
||||||
|
|
||||||
def __delitem__(self, key):
|
def __delitem__(self, key):
|
||||||
dict.__delitem__(self, key)
|
dict.__delitem__(self, key)
|
||||||
key, prev, next = self.__map.pop(key)
|
key, prev, next = self.__map.pop(key)
|
||||||
prev[2] = next
|
prev[2] = next
|
||||||
next[1] = prev
|
next[1] = prev
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
end = self.__end
|
end = self.__end
|
||||||
curr = end[2]
|
curr = end[2]
|
||||||
while curr is not end:
|
while curr is not end:
|
||||||
yield curr[0]
|
yield curr[0]
|
||||||
curr = curr[2]
|
curr = curr[2]
|
||||||
|
|
||||||
def __reversed__(self):
|
def __reversed__(self):
|
||||||
end = self.__end
|
end = self.__end
|
||||||
curr = end[1]
|
curr = end[1]
|
||||||
while curr is not end:
|
while curr is not end:
|
||||||
yield curr[0]
|
yield curr[0]
|
||||||
curr = curr[1]
|
curr = curr[1]
|
||||||
|
|
||||||
def popitem(self, last=True):
|
def popitem(self, last=True):
|
||||||
if not self:
|
if not self:
|
||||||
raise KeyError('dictionary is empty')
|
raise KeyError('dictionary is empty')
|
||||||
if last:
|
if last:
|
||||||
key = reversed(self).next()
|
key = reversed(self).next()
|
||||||
else:
|
else:
|
||||||
key = iter(self).next()
|
key = iter(self).next()
|
||||||
value = self.pop(key)
|
value = self.pop(key)
|
||||||
return key, value
|
return key, value
|
||||||
|
|
||||||
def __reduce__(self):
|
def __reduce__(self):
|
||||||
items = [[k, self[k]] for k in self]
|
items = [[k, self[k]] for k in self]
|
||||||
tmp = self.__map, self.__end
|
tmp = self.__map, self.__end
|
||||||
del self.__map, self.__end
|
del self.__map, self.__end
|
||||||
inst_dict = vars(self).copy()
|
inst_dict = vars(self).copy()
|
||||||
self.__map, self.__end = tmp
|
self.__map, self.__end = tmp
|
||||||
if inst_dict:
|
if inst_dict:
|
||||||
return (self.__class__, (items,), inst_dict)
|
return (self.__class__, (items,), inst_dict)
|
||||||
return self.__class__, (items,)
|
return self.__class__, (items,)
|
||||||
|
|
||||||
def keys(self):
|
def keys(self):
|
||||||
return list(self)
|
return list(self)
|
||||||
|
|
||||||
setdefault = DictMixin.setdefault
|
setdefault = DictMixin.setdefault
|
||||||
update = DictMixin.update
|
update = DictMixin.update
|
||||||
pop = DictMixin.pop
|
pop = DictMixin.pop
|
||||||
values = DictMixin.values
|
values = DictMixin.values
|
||||||
items = DictMixin.items
|
items = DictMixin.items
|
||||||
iterkeys = DictMixin.iterkeys
|
iterkeys = DictMixin.iterkeys
|
||||||
itervalues = DictMixin.itervalues
|
itervalues = DictMixin.itervalues
|
||||||
iteritems = DictMixin.iteritems
|
iteritems = DictMixin.iteritems
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
if not self:
|
if not self:
|
||||||
return '%s()' % (self.__class__.__name__,)
|
return '%s()' % (self.__class__.__name__,)
|
||||||
return '%s(%r)' % (self.__class__.__name__, self.items())
|
return '%s(%r)' % (self.__class__.__name__, self.items())
|
||||||
|
|
||||||
def copy(self):
|
def copy(self):
|
||||||
return self.__class__(self)
|
return self.__class__(self)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def fromkeys(cls, iterable, value=None):
|
def fromkeys(cls, iterable, value=None):
|
||||||
d = cls()
|
d = cls()
|
||||||
for key in iterable:
|
for key in iterable:
|
||||||
d[key] = value
|
d[key] = value
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
if isinstance(other, OrderedDict):
|
if isinstance(other, OrderedDict):
|
||||||
if len(self) != len(other):
|
if len(self) != len(other):
|
||||||
return False
|
return False
|
||||||
for p, q in zip(self.items(), other.items()):
|
for p, q in zip(self.items(), other.items()):
|
||||||
if p != q:
|
if p != q:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
return dict.__eq__(self, other)
|
return dict.__eq__(self, other)
|
||||||
|
|
||||||
def __ne__(self, other):
|
def __ne__(self, other):
|
||||||
return not self == other
|
return not self == other
|
||||||
|
@ -1,26 +1,26 @@
|
|||||||
"""
|
"""
|
||||||
Allows easy loading of pixmaps used in UI elements.
|
Allows easy loading of pixmaps used in UI elements.
|
||||||
Provides support for frozen environments as well.
|
Provides support for frozen environments as well.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os, sys, pickle
|
import os, sys, pickle
|
||||||
from ..functions import makeQImage
|
from ..functions import makeQImage
|
||||||
from ..Qt import QtGui
|
from ..Qt import QtGui
|
||||||
if sys.version_info[0] == 2:
|
if sys.version_info[0] == 2:
|
||||||
from . import pixmapData_2 as pixmapData
|
from . import pixmapData_2 as pixmapData
|
||||||
else:
|
else:
|
||||||
from . import pixmapData_3 as pixmapData
|
from . import pixmapData_3 as pixmapData
|
||||||
|
|
||||||
|
|
||||||
def getPixmap(name):
|
def getPixmap(name):
|
||||||
"""
|
"""
|
||||||
Return a QPixmap corresponding to the image file with the given name.
|
Return a QPixmap corresponding to the image file with the given name.
|
||||||
(eg. getPixmap('auto') loads pyqtgraph/pixmaps/auto.png)
|
(eg. getPixmap('auto') loads pyqtgraph/pixmaps/auto.png)
|
||||||
"""
|
"""
|
||||||
key = name+'.png'
|
key = name+'.png'
|
||||||
data = pixmapData.pixmapData[key]
|
data = pixmapData.pixmapData[key]
|
||||||
if isinstance(data, basestring) or isinstance(data, bytes):
|
if isinstance(data, basestring) or isinstance(data, bytes):
|
||||||
pixmapData.pixmapData[key] = pickle.loads(data)
|
pixmapData.pixmapData[key] = pickle.loads(data)
|
||||||
arr = pixmapData.pixmapData[key]
|
arr = pixmapData.pixmapData[key]
|
||||||
return QtGui.QPixmap(makeQImage(arr, alpha=True))
|
return QtGui.QPixmap(makeQImage(arr, alpha=True))
|
||||||
|
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
from PyQt4 import QtGui
|
from PyQt4 import QtGui
|
||||||
import os, pickle, sys
|
import os, pickle, sys
|
||||||
|
|
||||||
path = os.path.abspath(os.path.split(__file__)[0])
|
path = os.path.abspath(os.path.split(__file__)[0])
|
||||||
pixmaps = {}
|
pixmaps = {}
|
||||||
for f in os.listdir(path):
|
for f in os.listdir(path):
|
||||||
if not f.endswith('.png'):
|
if not f.endswith('.png'):
|
||||||
continue
|
continue
|
||||||
print(f)
|
print(f)
|
||||||
img = QtGui.QImage(os.path.join(path, f))
|
img = QtGui.QImage(os.path.join(path, f))
|
||||||
ptr = img.bits()
|
ptr = img.bits()
|
||||||
ptr.setsize(img.byteCount())
|
ptr.setsize(img.byteCount())
|
||||||
arr = np.asarray(ptr).reshape(img.height(), img.width(), 4).transpose(1,0,2)
|
arr = np.asarray(ptr).reshape(img.height(), img.width(), 4).transpose(1,0,2)
|
||||||
pixmaps[f] = pickle.dumps(arr)
|
pixmaps[f] = pickle.dumps(arr)
|
||||||
ver = sys.version_info[0]
|
ver = sys.version_info[0]
|
||||||
fh = open(os.path.join(path, 'pixmapData_%d.py' %ver), 'w')
|
fh = open(os.path.join(path, 'pixmapData_%d.py' %ver), 'w')
|
||||||
fh.write("import numpy as np; pixmapData=%s" % repr(pixmaps))
|
fh.write("import numpy as np; pixmapData=%s" % repr(pixmaps))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user