diff --git a/Validate.py b/Validate.py index fc02e15a..57718dec 100644 --- a/Validate.py +++ b/Validate.py @@ -10,7 +10,7 @@ import textwrap import os, sys, re import difflib from collections import defaultdict -from betools import CmdLine, visitDir +from betools import CmdLine, visitDir, ruler, head ############################################################################### @@ -204,26 +204,6 @@ class OutputTags: return iter(self.tags) -# def path_ends_with(fullPath, partialPath): -# path = list(reversed(fullPath.parts)) -# for i, part in enumerate(reversed(partialPath.parts)): -# if not part is path[i]: -# return False -# return True - -# Path.ends_with = path_ends_with # extension method to Path - -def ruler(arg=None, sep="_", print_=False, width=60): - if arg: - result = "[ {} ]".format(str(arg)).center(width, sep) + "\n" - else: - result = "".center(width, sep) + "\n" - if print_: - print(result) - else: - return result - -def head(arg=None, sep="_", width=60): ruler(arg, sep, True, width) class Result: """ @@ -317,7 +297,7 @@ def discoverOutputTags(): @CmdLine("f", "fillin") def fillInUnexcludedOutput(): """ - Find the files that aren't explicitly excluded AND have no OUTPUT:, show them and their output. + Find the files that aren't explicitly excluded AND have no 'Output:'. Show them and their output. """ results = [r for r in [Result.create(jfp) for jfp in RunFiles.base.rglob("*.java")] if r] assert len(results), "Must run runall.ps1 first" diff --git a/betools/__init__.py b/betools/__init__.py index 1067dd2e..2aedbf63 100644 --- a/betools/__init__.py +++ b/betools/__init__.py @@ -1,5 +1,6 @@ # https://github.com/pypa/sampleproject/blob/master/setup.py -__all__ = ["CmdLine", "visitDir"] +__all__ = ["CmdLine", "visitDir", "ruler", "head"] from betools.cmdline import CmdLine from betools.visitdir import visitDir +from betools.ruler import ruler, head diff --git a/betools/__pycache__/__init__.cpython-34.pyc b/betools/__pycache__/__init__.cpython-34.pyc deleted file mode 100644 index 007a58c7..00000000 Binary files a/betools/__pycache__/__init__.cpython-34.pyc and /dev/null differ diff --git a/betools/__pycache__/cmdline.cpython-34.pyc b/betools/__pycache__/cmdline.cpython-34.pyc deleted file mode 100644 index c9fe20b8..00000000 Binary files a/betools/__pycache__/cmdline.cpython-34.pyc and /dev/null differ diff --git a/betools/__pycache__/visitdir.cpython-34.pyc b/betools/__pycache__/visitdir.cpython-34.pyc deleted file mode 100644 index ae3debb7..00000000 Binary files a/betools/__pycache__/visitdir.cpython-34.pyc and /dev/null differ diff --git a/betools/ruler.py b/betools/ruler.py new file mode 100644 index 00000000..0a02f899 --- /dev/null +++ b/betools/ruler.py @@ -0,0 +1,18 @@ +#! python +""" +ruler() generates a string ruler with embedded text +head() does the same thing but prints it +""" + +def ruler(arg=None, sep="_", print_=False, width=60): + if arg: + result = "[ {} ]".format(str(arg)).center(width, sep) + "\n" + else: + result = "".center(width, sep) + "\n" + if print_: + print(result) + else: + return result + +def head(arg=None, sep="_", width=60): ruler(arg, sep, True, width) +