moved ruler to betools

This commit is contained in:
Bruce Eckel 2015-05-10 18:41:41 -07:00
parent 6d8a577071
commit 6888cf95ec
6 changed files with 22 additions and 23 deletions

View File

@ -10,7 +10,7 @@ import textwrap
import os, sys, re import os, sys, re
import difflib import difflib
from collections import defaultdict 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) 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: class Result:
""" """
@ -317,7 +297,7 @@ def discoverOutputTags():
@CmdLine("f", "fillin") @CmdLine("f", "fillin")
def fillInUnexcludedOutput(): 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] 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" assert len(results), "Must run runall.ps1 first"

View File

@ -1,5 +1,6 @@
# https://github.com/pypa/sampleproject/blob/master/setup.py # https://github.com/pypa/sampleproject/blob/master/setup.py
__all__ = ["CmdLine", "visitDir"] __all__ = ["CmdLine", "visitDir", "ruler", "head"]
from betools.cmdline import CmdLine from betools.cmdline import CmdLine
from betools.visitdir import visitDir from betools.visitdir import visitDir
from betools.ruler import ruler, head

18
betools/ruler.py Normal file
View File

@ -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)