6b66edfd46
Fixed bugs / style issues to please Lord Travis Squashed commit of the following: commitf25048a1e1
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Sun Mar 30 02:40:47 2014 -0400 syntax commitcc8b69695a
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Sun Mar 30 02:36:49 2014 -0400 add size check, diff style check commit5d5ea065a4
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Sun Mar 30 02:16:05 2014 -0400 travis fix commitb154c6d997
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Sun Mar 30 02:09:41 2014 -0400 travis, flake colored output commit46921dcd87
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Wed Mar 26 12:37:54 2014 -0400 fix pyside+py3 bugs to satisfy CI commit1d30f3c5c7
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Wed Mar 26 11:13:18 2014 -0400 fix py3 tests commit426578fa4c
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Wed Mar 26 07:39:19 2014 -0400 fix pytest install commit88a13c1a71
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Wed Mar 26 00:29:29 2014 -0400 qt5 updates commit51995488cc
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Wed Mar 26 00:16:04 2014 -0400 correct py.test command for py3 commite2b02fbcbd
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Tue Mar 25 23:50:38 2014 -0400 fix 2nd install test commit4b3e3ee04a
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Tue Mar 25 23:31:31 2014 -0400 syntax error commit250eabdb34
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Tue Mar 25 23:13:42 2014 -0400 look for py.test3 commit9f9bca47c1
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Tue Mar 25 22:54:19 2014 -0400 fix syntax commit0a871c6f36
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Tue Mar 25 22:47:58 2014 -0400 output pip build log commitdbce58d8cd
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Tue Mar 25 22:38:55 2014 -0400 no comments allowed between shall lines commitb79c06121d
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Tue Mar 25 20:56:35 2014 -0400 another pip try commit09f4f5d82a
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Tue Mar 25 13:36:09 2014 -0400 pip correction commit0eedb5c18e
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Tue Mar 25 13:29:00 2014 -0400 correct py version output commitd9fd039be2
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Tue Mar 25 11:55:43 2014 -0400 apt checks commitcf95ccef86
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Tue Mar 25 10:23:10 2014 -0400 alternate pip install method commitbee0bcddfe
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Mon Mar 24 23:51:45 2014 -0400 correct deps install commit963a4211fc
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Mon Mar 24 23:47:30 2014 -0400 fixes commit0c86cd1dc2
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Mon Mar 24 23:31:06 2014 -0400 permission fix commit5d04ef53b8
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Mon Mar 24 23:30:19 2014 -0400 Fix py.test version selection commitb0e6c7cb94
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Mon Mar 24 23:25:34 2014 -0400 try another pyqt5 install method commit422a792866
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Mon Mar 24 23:12:36 2014 -0400 syntax error commit533133905a
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Mon Mar 24 23:04:37 2014 -0400 fixes commit8d65211ba4
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Mon Mar 24 22:40:18 2014 -0400 Add Qt5 test minor fixes commit4484efaefe
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Mon Mar 24 22:31:56 2014 -0400 use correct py.test for python version commit5d2441a29b
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Mon Mar 24 22:24:27 2014 -0400 add setup tests commit9291db64f2
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Mon Mar 24 21:48:43 2014 -0400 fix py3-pyqt install commita7aa675c5a
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Mon Mar 24 21:31:33 2014 -0400 travis tests commite71cd2b23a
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Mon Mar 24 21:17:15 2014 -0400 more corrections commit527df3bca8
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Mon Mar 24 20:56:01 2014 -0400 travis corrections commit87d65cac4a
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Mon Mar 24 20:48:02 2014 -0400 Add flake tests Correct style in a few files to please Lord Travis commit537028f88f
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Mon Mar 24 17:36:24 2014 -0400 minimize pyside package install correct line endings to satisfy Lord Travis commit1e3cc95e37
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Mon Mar 24 17:23:03 2014 -0400 enable pyside, line ending check fix test commitd7df4517f9
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Mon Mar 24 17:12:06 2014 -0400 syntax fix commit1ad77a2155
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Mon Mar 24 17:00:30 2014 -0400 alt. pytest install commit5edcc02072
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Mon Mar 24 16:52:33 2014 -0400 Added initial travis.yml
52 lines
1.8 KiB
Python
52 lines
1.8 KiB
Python
## Definitions helpful in frozen environments (eg py2exe)
|
|
import os, sys, zipfile
|
|
|
|
def listdir(path):
|
|
"""Replacement for os.listdir that works in frozen environments."""
|
|
if not hasattr(sys, 'frozen'):
|
|
return os.listdir(path)
|
|
|
|
(zipPath, archivePath) = splitZip(path)
|
|
if archivePath is None:
|
|
return os.listdir(path)
|
|
|
|
with zipfile.ZipFile(zipPath, "r") as zipobj:
|
|
contents = zipobj.namelist()
|
|
results = set()
|
|
for name in contents:
|
|
# components in zip archive paths are always separated by forward slash
|
|
if name.startswith(archivePath) and len(name) > len(archivePath):
|
|
name = name[len(archivePath):].split('/')[0]
|
|
results.add(name)
|
|
return list(results)
|
|
|
|
def isdir(path):
|
|
"""Replacement for os.path.isdir that works in frozen environments."""
|
|
if not hasattr(sys, 'frozen'):
|
|
return os.path.isdir(path)
|
|
|
|
(zipPath, archivePath) = splitZip(path)
|
|
if archivePath is None:
|
|
return os.path.isdir(path)
|
|
with zipfile.ZipFile(zipPath, "r") as zipobj:
|
|
contents = zipobj.namelist()
|
|
archivePath = archivePath.rstrip('/') + '/' ## make sure there's exactly one '/' at the end
|
|
for c in contents:
|
|
if c.startswith(archivePath):
|
|
return True
|
|
return False
|
|
|
|
|
|
def splitZip(path):
|
|
"""Splits a path containing a zip file into (zipfile, subpath).
|
|
If there is no zip file, returns (path, None)"""
|
|
components = os.path.normpath(path).split(os.sep)
|
|
for index, component in enumerate(components):
|
|
if component.endswith('.zip'):
|
|
zipPath = os.sep.join(components[0:index+1])
|
|
archivePath = ''.join([x+'/' for x in components[index+1:]])
|
|
return (zipPath, archivePath)
|
|
else:
|
|
return (path, None)
|
|
|
|
|