mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
flake8 : traverse recursively.
This commit is contained in:
parent
8e89dd203c
commit
149496c90c
4 changed files with 197 additions and 151 deletions
|
@ -1,37 +1,42 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
#outdir = '../html'
|
import sys
|
||||||
pysollib_dir = '../'
|
import os
|
||||||
|
import re
|
||||||
import sys, os, re
|
|
||||||
from glob import glob
|
|
||||||
|
|
||||||
import __builtin__
|
import __builtin__
|
||||||
__builtin__._ = lambda x: x
|
|
||||||
__builtin__.n_ = lambda x: x
|
|
||||||
|
|
||||||
try: os.mkdir('html')
|
|
||||||
except: pass
|
|
||||||
try: os.mkdir('html/rules')
|
|
||||||
except: pass
|
|
||||||
|
|
||||||
pysollib_path = os.path.join(sys.path[0], pysollib_dir)
|
|
||||||
sys.path[0] = os.path.normpath(pysollib_path)
|
|
||||||
#print sys.path
|
|
||||||
|
|
||||||
from pysollib.mygettext import fix_gettext
|
from pysollib.mygettext import fix_gettext
|
||||||
fix_gettext()
|
|
||||||
|
|
||||||
import pysollib.games
|
|
||||||
import pysollib.games.special
|
|
||||||
import pysollib.games.ultra
|
|
||||||
import pysollib.games.mahjongg
|
|
||||||
|
|
||||||
from pysollib.gamedb import GAME_DB
|
from pysollib.gamedb import GAME_DB
|
||||||
from pysollib.gamedb import GI
|
from pysollib.gamedb import GI
|
||||||
from pysollib.mfxutil import latin1_to_ascii
|
from pysollib.mfxutil import latin1_to_ascii
|
||||||
|
# outdir = '../html'
|
||||||
|
pysollib_dir = '../'
|
||||||
|
|
||||||
|
|
||||||
|
__builtin__._ = lambda x: x
|
||||||
|
__builtin__.n_ = lambda x: x
|
||||||
|
|
||||||
|
eval('import pysollib.games')
|
||||||
|
eval('import pysollib.games.mahjongg')
|
||||||
|
eval('import pysollib.games.ultra')
|
||||||
|
eval('import pysollib.games.special')
|
||||||
|
|
||||||
|
try:
|
||||||
|
os.mkdir('html')
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
os.mkdir('html/rules')
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
pysollib_path = os.path.join(sys.path[0], pysollib_dir)
|
||||||
|
sys.path[0] = os.path.normpath(pysollib_path)
|
||||||
|
# print sys.path
|
||||||
|
|
||||||
|
fix_gettext()
|
||||||
|
|
||||||
files = [
|
files = [
|
||||||
('credits.html', 'PySol Credits'),
|
('credits.html', 'PySol Credits'),
|
||||||
('ganjifa.html', 'PySol - General Ganjifa Card Rules'),
|
('ganjifa.html', 'PySol - General Ganjifa Card Rules'),
|
||||||
|
@ -45,12 +50,12 @@ files = [
|
||||||
('intro.html', 'PySol - Introduction'),
|
('intro.html', 'PySol - Introduction'),
|
||||||
('license.html', 'PySol Software License'),
|
('license.html', 'PySol Software License'),
|
||||||
('news.html', 'PySol - a Solitaire Game Collection'),
|
('news.html', 'PySol - a Solitaire Game Collection'),
|
||||||
#('rules_alternate.html', 'PySol - a Solitaire Game Collection'),
|
# ('rules_alternate.html', 'PySol - a Solitaire Game Collection'),
|
||||||
#('rules.html', 'PySol - a Solitaire Game Collection'),
|
# ('rules.html', 'PySol - a Solitaire Game Collection'),
|
||||||
]
|
]
|
||||||
|
|
||||||
rules_files = [
|
rules_files = [
|
||||||
#('hanoipuzzle.html', ),
|
# ('hanoipuzzle.html', ),
|
||||||
('mahjongg.html', 'PySol - Rules for Mahjongg'),
|
('mahjongg.html', 'PySol - Rules for Mahjongg'),
|
||||||
('matrix.html', 'PySol - Rules for Matrix'),
|
('matrix.html', 'PySol - Rules for Matrix'),
|
||||||
('pegged.html', 'PySol - Rules for Pegged'),
|
('pegged.html', 'PySol - Rules for Pegged'),
|
||||||
|
@ -67,10 +72,11 @@ main_header = '''<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>%s</title>
|
<title>%s</title>
|
||||||
<meta name="license" content="Distributed under the terms of the GNU General Public License">
|
<meta name="license" content="GNU General Public License">
|
||||||
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
||||||
</head>
|
</head>
|
||||||
<body text="#000000" bgcolor="#F7F3FF" link="#0000FF" vlink="#660099" alink="#FF0000">
|
<body text="#000000" bgcolor="#F7F3FF" link="#0000FF" vlink="#660099"
|
||||||
|
alink="#FF0000">
|
||||||
<img src="images/pysollogo03.gif" alt="">
|
<img src="images/pysollogo03.gif" alt="">
|
||||||
<br>
|
<br>
|
||||||
'''
|
'''
|
||||||
|
@ -85,10 +91,11 @@ rules_header = '''<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>%s</title>
|
<title>%s</title>
|
||||||
<meta name="license" content="Distributed under the terms of the GNU General Public License">
|
<meta name="license" content="GNU General Public License">
|
||||||
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
||||||
</head>
|
</head>
|
||||||
<body text="#000000" bgcolor="#F7F3FF" link="#0000FF" vlink="#660099" alink="#FF0000">
|
<body text="#000000" bgcolor="#F7F3FF" link="#0000FF" vlink="#660099"
|
||||||
|
link="#FF0000">
|
||||||
<img src="../images/pysollogo03.gif" alt="">
|
<img src="../images/pysollogo03.gif" alt="">
|
||||||
<br>
|
<br>
|
||||||
'''
|
'''
|
||||||
|
@ -109,23 +116,26 @@ wikipedia_header = '''<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>%s</title>
|
<title>%s</title>
|
||||||
<meta name="license" content="Distributed under the terms of the GNU Free Documentation License">
|
<meta name="license" content="GNU General Public License">
|
||||||
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
||||||
</head>
|
</head>
|
||||||
<body text="#000000" bgcolor="#F7F3FF" link="#0000FF" vlink="#660099" alink="#FF0000">
|
<body text="#000000" bgcolor="#F7F3FF" link="#0000FF" vlink="#660099"
|
||||||
|
alink="#FF0000">
|
||||||
<img src="../images/pysollogo03.gif" alt="">
|
<img src="../images/pysollogo03.gif" alt="">
|
||||||
<br>
|
<br>
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
||||||
def getGameRulesFilename(n):
|
def getGameRulesFilename(n):
|
||||||
if n.startswith('Mahjongg'): return 'mahjongg.html'
|
if n.startswith('Mahjongg'):
|
||||||
##n = re.sub(r"[\[\(].*$", "", n)
|
return 'mahjongg.html'
|
||||||
|
# n = re.sub(r"[\[\(].*$", "", n)
|
||||||
n = latin1_to_ascii(n)
|
n = latin1_to_ascii(n)
|
||||||
n = re.sub(r"[^\w]", "", n)
|
n = re.sub(r"[^\w]", "", n)
|
||||||
n = n.lower() + ".html"
|
n = n.lower() + ".html"
|
||||||
return n
|
return n
|
||||||
|
|
||||||
|
|
||||||
def gen_main_html():
|
def gen_main_html():
|
||||||
for infile, title in files:
|
for infile, title in files:
|
||||||
outfile = open(os.path.join('html', infile), 'w')
|
outfile = open(os.path.join('html', infile), 'w')
|
||||||
|
@ -136,8 +146,9 @@ def gen_main_html():
|
||||||
s = ''
|
s = ''
|
||||||
print >> outfile, main_footer % s
|
print >> outfile, main_footer % s
|
||||||
|
|
||||||
|
|
||||||
def gen_rules_html():
|
def gen_rules_html():
|
||||||
##ls = glob(os.path.join('rules', '*.html'))
|
# ls = glob(os.path.join('rules', '*.html'))
|
||||||
rules_ls = os.listdir('rules')
|
rules_ls = os.listdir('rules')
|
||||||
rules_ls.sort()
|
rules_ls.sort()
|
||||||
wikipedia_ls = os.listdir('wikipedia')
|
wikipedia_ls = os.listdir('wikipedia')
|
||||||
|
@ -176,11 +187,11 @@ def gen_rules_html():
|
||||||
elif rules_fn in wikipedia_ls:
|
elif rules_fn in wikipedia_ls:
|
||||||
rules_dir = 'wikipedia'
|
rules_dir = 'wikipedia'
|
||||||
else:
|
else:
|
||||||
print 'missing rules for %s (file: %s)' \
|
print('missing rules for %s (file: %s)'
|
||||||
% (gi.name.encode('utf-8'), rules_fn)
|
% (gi.name.encode('utf-8'), rules_fn))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
##print '>>>', rules_fn
|
# print '>>>', rules_fn
|
||||||
|
|
||||||
title = 'PySol - Rules for ' + gi.name
|
title = 'PySol - Rules for ' + gi.name
|
||||||
s = ''
|
s = ''
|
||||||
|
@ -192,18 +203,18 @@ def gen_rules_html():
|
||||||
s = '<a href="../hexadeck.html">General Hex A Deck rules</a>'
|
s = '<a href="../hexadeck.html">General Hex A Deck rules</a>'
|
||||||
elif gi.si.game_type == GI.GT_MUGHAL_GANJIFA:
|
elif gi.si.game_type == GI.GT_MUGHAL_GANJIFA:
|
||||||
s = '<a href="../ganjifa.html">About Ganjifa</a>'
|
s = '<a href="../ganjifa.html">About Ganjifa</a>'
|
||||||
#print '***', gi.name, '***'
|
# print '***', gi.name, '***'
|
||||||
|
|
||||||
rules_list.append((rules_dir, rules_fn, title, s))
|
rules_list.append((rules_dir, rules_fn, title, s))
|
||||||
files_list.append(rules_fn)
|
files_list.append(rules_fn)
|
||||||
#rules_list.append((rules_fn, gi.name))
|
# rules_list.append((rules_fn, gi.name))
|
||||||
print >> out_rules, '<li><a href="rules/%s">%s</a>' \
|
print >> out_rules, '<li><a href="rules/%s">%s</a>' \
|
||||||
% (rules_fn, gi.name.encode('utf-8'))
|
% (rules_fn, gi.name.encode('utf-8'))
|
||||||
for n in gi.altnames:
|
for n in gi.altnames:
|
||||||
altnames.append((n, rules_fn))
|
altnames.append((n, rules_fn))
|
||||||
|
|
||||||
print >> out_rules, '</ul>\n' + \
|
print >> out_rules, '</ul>\n' + \
|
||||||
main_footer % '<a href="index.html">Back to the index</a>'
|
main_footer % '<a href="index.html">Back to the index</a>'
|
||||||
|
|
||||||
# create file of altnames
|
# create file of altnames
|
||||||
out_rules_alt = open(os.path.join('html', 'rules_alternate.html'), 'w')
|
out_rules_alt = open(os.path.join('html', 'rules_alternate.html'), 'w')
|
||||||
|
@ -214,14 +225,14 @@ def gen_rules_html():
|
||||||
print >> out_rules_alt, '<li> <a href="rules/%s">%s</a>' \
|
print >> out_rules_alt, '<li> <a href="rules/%s">%s</a>' \
|
||||||
% (fn, name.encode('utf-8'))
|
% (fn, name.encode('utf-8'))
|
||||||
print >> out_rules_alt, '</ul>\n' + \
|
print >> out_rules_alt, '</ul>\n' + \
|
||||||
main_footer % '<a href="index.html">Back to the index</a>'
|
main_footer % '<a href="index.html">Back to the index</a>'
|
||||||
|
|
||||||
# create rules
|
# create rules
|
||||||
for dir, filename, title, footer in rules_list:
|
for dir, filename, title, footer in rules_list:
|
||||||
outfile = open(os.path.join('html', 'rules', filename), 'w')
|
outfile = open(os.path.join('html', 'rules', filename), 'w')
|
||||||
if dir == 'rules':
|
if dir == 'rules':
|
||||||
print >> outfile, (rules_header % title).encode('utf-8')
|
print >> outfile, (rules_header % title).encode('utf-8')
|
||||||
else: # d == 'wikipedia'
|
else: # d == 'wikipedia'
|
||||||
print >> outfile, (wikipedia_header % title).encode('utf-8')
|
print >> outfile, (wikipedia_header % title).encode('utf-8')
|
||||||
print >> outfile, open(os.path.join(dir, filename)).read()
|
print >> outfile, open(os.path.join(dir, filename)).read()
|
||||||
print >> outfile, rules_footer % footer
|
print >> outfile, rules_footer % footer
|
||||||
|
@ -229,6 +240,3 @@ def gen_rules_html():
|
||||||
|
|
||||||
gen_main_html()
|
gen_main_html()
|
||||||
gen_rules_html()
|
gen_rules_html()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,34 +4,40 @@ import re
|
||||||
|
|
||||||
builder = TAP.Builder()
|
builder = TAP.Builder()
|
||||||
|
|
||||||
|
|
||||||
def plan(plan, plan_param=None):
|
def plan(plan, plan_param=None):
|
||||||
builder.set_plan(plan, plan_param)
|
builder.set_plan(plan, plan_param)
|
||||||
|
|
||||||
|
|
||||||
ok = builder.ok
|
ok = builder.ok
|
||||||
|
|
||||||
|
|
||||||
def diag(comment):
|
def diag(comment):
|
||||||
print "# %s" % re.compile("\n(.)").sub(comment, '\n#\1')
|
print("# %s" % re.compile("\n(.)").sub(comment, '\n#\1'))
|
||||||
|
|
||||||
|
|
||||||
def eq_ok(have, want, comment):
|
def eq_ok(have, want, comment):
|
||||||
okness = have == want
|
okness = have == want
|
||||||
ok(okness, comment)
|
ok(okness, comment)
|
||||||
if not okness:
|
if not okness:
|
||||||
diag("want: %s" % want)
|
diag("want: %s" % want)
|
||||||
diag("have: %s" % have)
|
diag("have: %s" % have)
|
||||||
return okness
|
return okness
|
||||||
|
|
||||||
|
|
||||||
def is_ok(have, want, comment):
|
def is_ok(have, want, comment):
|
||||||
okness = have is want
|
okness = have is want
|
||||||
ok(okness, comment)
|
ok(okness, comment)
|
||||||
if not okness:
|
if not okness:
|
||||||
diag("want id: %s" % id(want))
|
diag("want id: %s" % id(want))
|
||||||
diag("have id: %s" % id(have))
|
diag("have id: %s" % id(have))
|
||||||
return okness
|
return okness
|
||||||
|
|
||||||
|
|
||||||
def isa_ok(object, cls, object_name="the object"):
|
def isa_ok(object, cls, object_name="the object"):
|
||||||
okness = isinstance(object, cls)
|
okness = isinstance(object, cls)
|
||||||
ok(okness, object_name + " is a " + repr(cls))
|
ok(okness, object_name + " is a " + repr(cls))
|
||||||
# if not okness:
|
# if not okness:
|
||||||
# diag("want id: %s" % id(want))
|
# diag("want id: %s" % id(want))
|
||||||
# diag("have id: %s" % id(have))
|
# diag("have id: %s" % id(have))
|
||||||
return okness
|
return okness
|
||||||
|
|
|
@ -3,96 +3,115 @@ import atexit
|
||||||
|
|
||||||
# todo: make written-to stream passable
|
# todo: make written-to stream passable
|
||||||
|
|
||||||
|
|
||||||
class Plan(object):
|
class Plan(object):
|
||||||
def __init__(self, plan, param=None):
|
def __init__(self, plan, param=None):
|
||||||
self.counter = 0
|
self.counter = 0
|
||||||
self.expected_tests = None
|
self.expected_tests = None
|
||||||
self.ended = False
|
self.ended = False
|
||||||
|
|
||||||
if isinstance(plan, int):
|
if isinstance(plan, int):
|
||||||
self.expected_tests = plan
|
self.expected_tests = plan
|
||||||
print "1..%u" % self.expected_tests
|
print("1..%u" % self.expected_tests)
|
||||||
elif plan == "no_plan" or plan == None: 1
|
elif plan == "no_plan" or plan is None:
|
||||||
elif plan == "skip_all":
|
True
|
||||||
print "1..0 # skip %s" % param
|
elif plan == "skip_all":
|
||||||
raise SystemExit(0) # ??? this is what T::B does, but sucks
|
print("1..0 # skip %s" % param)
|
||||||
else:
|
raise SystemExit(0) # ??? this is what T::B does, but sucks
|
||||||
raise TestBadPlan(plan)
|
else:
|
||||||
|
raise TestBadPlan(plan)
|
||||||
|
|
||||||
def increment_counter(self):
|
def increment_counter(self):
|
||||||
self.counter += 1
|
self.counter += 1
|
||||||
|
|
||||||
|
def __del__(self):
|
||||||
|
if self.ended:
|
||||||
|
return
|
||||||
|
self.ended = True
|
||||||
|
if self.expected_tests is None:
|
||||||
|
print("1..%u" % self.counter)
|
||||||
|
elif self.counter != self.expected_tests:
|
||||||
|
print("# Looks like you planned %u tests but ran %u."
|
||||||
|
% (self.expected_tests, self.counter))
|
||||||
|
|
||||||
def __del__(self):
|
|
||||||
if self.ended: return
|
|
||||||
self.ended = True
|
|
||||||
if self.expected_tests is None:
|
|
||||||
print "1..%u" % self.counter
|
|
||||||
elif self.counter != self.expected_tests:
|
|
||||||
print "# Looks like you planned %u tests but ran %u." \
|
|
||||||
% (self.expected_tests, self.counter)
|
|
||||||
|
|
||||||
class Builder(object):
|
class Builder(object):
|
||||||
global_defaults = {
|
global_defaults = {
|
||||||
"_plan": None,
|
"_plan": None,
|
||||||
"current": 1,
|
"current": 1,
|
||||||
"has_plan": False,
|
"has_plan": False,
|
||||||
}
|
}
|
||||||
global_test_builder = global_defaults.copy()
|
global_test_builder = global_defaults.copy()
|
||||||
|
|
||||||
def __init__(self, plan=None, plan_param=None):
|
def __init__(self, plan=None, plan_param=None):
|
||||||
self.__dict__ = self.global_test_builder
|
self.__dict__ = self.global_test_builder
|
||||||
if plan: self.set_plan(plan, plan_param)
|
if plan:
|
||||||
|
self.set_plan(plan, plan_param)
|
||||||
|
|
||||||
@classmethod # XXX: why did this fail?
|
@classmethod # XXX: why did this fail?
|
||||||
def create(cls, plan=None, plan_param=None):
|
def create(cls, plan=None, plan_param=None):
|
||||||
# self = new.instance(cls) # ? this sucks, too
|
# self = new.instance(cls) # ? this sucks, too
|
||||||
self = Builder()
|
self = Builder()
|
||||||
self.__dict__ = self.global_defaults.copy()
|
self.__dict__ = self.global_defaults.copy()
|
||||||
if plan: self.set_plan(plan, plan_param)
|
if plan:
|
||||||
return self
|
self.set_plan(plan, plan_param)
|
||||||
|
return self
|
||||||
|
|
||||||
def set_plan(self, plan, plan_param=None):
|
def set_plan(self, plan, plan_param=None):
|
||||||
if self.get_plan(): raise TestPlannedAlready(plan, plan_param)
|
if self.get_plan():
|
||||||
self._plan = Plan(plan, plan_param)
|
raise TestPlannedAlready(plan, plan_param)
|
||||||
atexit.register(self._plan.__del__)
|
self._plan = Plan(plan, plan_param)
|
||||||
|
atexit.register(self._plan.__del__)
|
||||||
|
|
||||||
def get_plan(self): return self._plan
|
def get_plan(self): return self._plan
|
||||||
|
|
||||||
def ok(self, is_ok, desc=None, skip=None, todo=None):
|
def ok(self, is_ok, desc=None, skip=None, todo=None):
|
||||||
self.get_plan().increment_counter()
|
self.get_plan().increment_counter()
|
||||||
if is_ok: report = "ok"
|
if is_ok:
|
||||||
else: report = "not ok"
|
report = "ok"
|
||||||
|
else:
|
||||||
|
report = "not ok"
|
||||||
|
|
||||||
sys.stdout.write("%s %u" % (report, self.current))
|
sys.stdout.write("%s %u" % (report, self.current))
|
||||||
|
|
||||||
if desc: sys.stdout.write(" - %s" % desc)
|
if desc:
|
||||||
if skip: sys.stdout.write(" # SKIP %s" % skip)
|
sys.stdout.write(" - %s" % desc)
|
||||||
if todo: sys.stdout.write(" # TODO %s" % todo)
|
if skip:
|
||||||
|
sys.stdout.write(" # SKIP %s" % skip)
|
||||||
|
if todo:
|
||||||
|
sys.stdout.write(" # TODO %s" % todo)
|
||||||
|
|
||||||
print
|
print()
|
||||||
|
|
||||||
self.current += 1
|
self.current += 1
|
||||||
|
|
||||||
return is_ok
|
return is_ok
|
||||||
|
|
||||||
|
def reset(self):
|
||||||
|
self.__dict__.clear()
|
||||||
|
for key in self.global_defaults.keys():
|
||||||
|
self.__dict__[key] = self.global_defaults[key]
|
||||||
|
|
||||||
def reset(self):
|
|
||||||
self.__dict__.clear()
|
|
||||||
for key in self.global_defaults.iterkeys():
|
|
||||||
self.__dict__[key] = self.global_defaults[key]
|
|
||||||
|
|
||||||
class TestPlannedAlready(Exception):
|
class TestPlannedAlready(Exception):
|
||||||
def __init__(self, plan, param=None):
|
def __init__(self, plan, param=None):
|
||||||
self.plan = plan
|
self.plan = plan
|
||||||
self.param = param
|
self.param = param
|
||||||
def __str__(self):
|
|
||||||
return "tried to plan twice; second plan: %s, %s" % self.plan, self.param
|
def __str__(self):
|
||||||
|
return (
|
||||||
|
"tried to plan twice; second plan: %s, %s" % self.plan, self.param
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class TestWithoutPlan(Exception):
|
class TestWithoutPlan(Exception):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "tried running tests without a plan"
|
return "tried running tests without a plan"
|
||||||
|
|
||||||
|
|
||||||
class TestBadPlan(Exception):
|
class TestBadPlan(Exception):
|
||||||
def __init__(self, plan):
|
def __init__(self, plan):
|
||||||
self.plan = plan
|
self.plan = plan
|
||||||
def __str__(self):
|
|
||||||
return "didn't understand plan '%s'" % self.plan
|
def __str__(self):
|
||||||
|
return "didn't understand plan '%s'" % self.plan
|
||||||
|
|
|
@ -6,29 +6,42 @@ use warnings;
|
||||||
use Test::More tests => 1;
|
use Test::More tests => 1;
|
||||||
use Test::Differences qw( eq_or_diff );
|
use Test::Differences qw( eq_or_diff );
|
||||||
|
|
||||||
|
use File::Find::Object ();
|
||||||
use String::ShellQuote qw/ shell_quote /;
|
use String::ShellQuote qw/ shell_quote /;
|
||||||
|
|
||||||
my %skip =
|
my %skip =
|
||||||
(
|
(
|
||||||
map { $_ => 1 }
|
map { $_ => 1 }
|
||||||
qw(
|
qw(
|
||||||
./pysollib/games/__init__.py
|
pysollib/games/__init__.py
|
||||||
./pysollib/games/mahjongg/__init__.py
|
pysollib/games/mahjongg/__init__.py
|
||||||
./pysollib/games/mahjongg/mahjongg1.py
|
pysollib/games/mahjongg/mahjongg1.py
|
||||||
./pysollib/games/mahjongg/mahjongg2.py
|
pysollib/games/mahjongg/mahjongg2.py
|
||||||
./pysollib/games/mahjongg/mahjongg3.py
|
pysollib/games/mahjongg/mahjongg3.py
|
||||||
./pysollib/games/special/__init__.py
|
pysollib/games/special/__init__.py
|
||||||
./pysollib/games/ultra/__init__.py
|
pysollib/games/ultra/__init__.py
|
||||||
./pysollib/pysoltk.py
|
pysollib/pysoltk.py
|
||||||
./scripts/all_games.py
|
scripts/all_games.py
|
||||||
./pysollib/tile/ttk.py
|
pysollib/tile/ttk.py
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
# my $cmd = shell_quote( 'flake8', '.' );
|
my $tree = File::Find::Object->new({}, '.');
|
||||||
my $cmd = shell_quote( 'flake8',
|
my @filenames;
|
||||||
sort { $a cmp $b } grep { not exists $skip{$_} } glob('./*.py ./data/*/*/*.py ./scripts/*.py ./tests/board_gen/*.py ./pysollib/*.py ./pysollib/*/{*/*.py,*.py}') );
|
while (my $r = $tree->next_obj)
|
||||||
|
{
|
||||||
|
my $fn = $r->path;
|
||||||
|
if ($fn eq '.git' or $fn eq 'tests/individually-importing')
|
||||||
|
{
|
||||||
|
$tree->prune;
|
||||||
|
}
|
||||||
|
elsif ($fn =~ /\.py\z/ and !exists($skip{$fn}))
|
||||||
|
{
|
||||||
|
push @filenames, $fn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
my $cmd = shell_quote( 'flake8', @filenames);
|
||||||
# diag("<$cmd>");
|
# diag("<$cmd>");
|
||||||
|
|
||||||
# TEST
|
# TEST
|
||||||
|
|
Loading…
Add table
Reference in a new issue