mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
flake 8
This commit is contained in:
parent
00e0d81ece
commit
d36df25456
2 changed files with 16 additions and 13 deletions
|
@ -46,13 +46,14 @@ __all__ = ['SUITS',
|
||||||
]
|
]
|
||||||
|
|
||||||
# imports
|
# imports
|
||||||
import sys, os
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
# PySol imports
|
# PySol imports
|
||||||
from pysollib.settings import DATA_DIRS, TOOLKIT
|
from pysollib.settings import DATA_DIRS
|
||||||
from pysollib.mfxutil import Image
|
from pysollib.mfxutil import Image
|
||||||
|
|
||||||
from pysollib.mygettext import _, n_
|
from pysollib.mygettext import _
|
||||||
|
|
||||||
# ************************************************************************
|
# ************************************************************************
|
||||||
# * constants
|
# * constants
|
||||||
|
@ -106,7 +107,7 @@ class DataLoader:
|
||||||
if isinstance(filenames, str):
|
if isinstance(filenames, str):
|
||||||
filenames = (filenames,)
|
filenames = (filenames,)
|
||||||
assert isinstance(filenames, (tuple, list))
|
assert isinstance(filenames, (tuple, list))
|
||||||
#$ init path
|
# init path
|
||||||
path = path[:]
|
path = path[:]
|
||||||
head, tail = os.path.split(argv0)
|
head, tail = os.path.split(argv0)
|
||||||
if not head:
|
if not head:
|
||||||
|
@ -123,7 +124,8 @@ class DataLoader:
|
||||||
# check path for valid directories
|
# check path for valid directories
|
||||||
self.path = []
|
self.path = []
|
||||||
for p in path:
|
for p in path:
|
||||||
if not p: continue
|
if not p:
|
||||||
|
continue
|
||||||
np = os.path.abspath(p)
|
np = os.path.abspath(p)
|
||||||
if np and (np not in self.path) and os.path.isdir(np):
|
if np and (np not in self.path) and os.path.isdir(np):
|
||||||
self.path.append(np)
|
self.path.append(np)
|
||||||
|
@ -140,9 +142,9 @@ class DataLoader:
|
||||||
self.dir = p
|
self.dir = p
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
raise OSError(str(argv0)+": DataLoader could not find "+str(filenames))
|
raise OSError(str(argv0)+": DataLoader could not find " +
|
||||||
##print path, self.path, self.dir
|
str(filenames))
|
||||||
|
# print path, self.path, self.dir
|
||||||
|
|
||||||
def __findFile(self, func, filename, subdirs=None, do_raise=1):
|
def __findFile(self, func, filename, subdirs=None, do_raise=1):
|
||||||
if subdirs is None:
|
if subdirs is None:
|
||||||
|
@ -155,7 +157,8 @@ class DataLoader:
|
||||||
if func(f):
|
if func(f):
|
||||||
return f
|
return f
|
||||||
if do_raise:
|
if do_raise:
|
||||||
raise OSError("DataLoader could not find "+filename+" in "+self.dir+" "+str(subdirs))
|
raise OSError("DataLoader could not find "+filename+" in " +
|
||||||
|
self.dir+" "+str(subdirs))
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def findFile(self, filename, subdirs=None):
|
def findFile(self, filename, subdirs=None):
|
||||||
|
@ -166,11 +169,12 @@ class DataLoader:
|
||||||
f = self.__findFile(os.path.isfile, filename+ext, subdirs, 0)
|
f = self.__findFile(os.path.isfile, filename+ext, subdirs, 0)
|
||||||
if f:
|
if f:
|
||||||
return f
|
return f
|
||||||
raise OSError("DataLoader could not find image "+filename+" in "+self.dir+" "+str(subdirs))
|
raise OSError("DataLoader could not find image "+filename +
|
||||||
|
" in "+self.dir+" "+str(subdirs))
|
||||||
|
|
||||||
def findIcon(self, filename=None, subdirs=None):
|
def findIcon(self, filename=None, subdirs=None):
|
||||||
if not filename:
|
if not filename:
|
||||||
##filename = PACKAGE.lower()
|
# filename = PACKAGE.lower()
|
||||||
filename = 'pysol'
|
filename = 'pysol'
|
||||||
root, ext = os.path.splitext(filename)
|
root, ext = os.path.splitext(filename)
|
||||||
if not ext:
|
if not ext:
|
||||||
|
@ -182,4 +186,3 @@ class DataLoader:
|
||||||
|
|
||||||
def findDir(self, filename, subdirs=None):
|
def findDir(self, filename, subdirs=None):
|
||||||
return self.__findFile(os.path.isdir, filename, subdirs)
|
return self.__findFile(os.path.isdir, filename, subdirs)
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ use String::ShellQuote qw/ shell_quote /;
|
||||||
|
|
||||||
# my $cmd = shell_quote( 'flake8', '.' );
|
# my $cmd = shell_quote( 'flake8', '.' );
|
||||||
my $cmd = shell_quote( 'flake8',
|
my $cmd = shell_quote( 'flake8',
|
||||||
grep { not($_ eq './pysollib/pysoltk.py') } glob('./pysollib/[a-s]*.py') );
|
grep { not($_ eq './pysollib/pysoltk.py') } glob('./pysollib/[a-u]*.py') );
|
||||||
|
|
||||||
# TEST
|
# TEST
|
||||||
eq_or_diff( scalar(`$cmd`), '', "flake8 is happy with the code." );
|
eq_or_diff( scalar(`$cmd`), '', "flake8 is happy with the code." );
|
||||||
|
|
Loading…
Add table
Reference in a new issue