|
class DefaultFinder(object): |
|
""" Finder are object used in Test to retrieve the target files of the tests |
|
|
|
""" |
|
def __init__(self, **options): |
|
pass |
|
|
|
def find(self, directory): |
|
""" Return object to find |
|
|
|
:param directory: Root Directory to search in |
|
|
|
:returns: Path of xml text files, Path of __cts__.xml files |
|
:rtype: (list, list) |
|
""" |
|
data = glob.glob(os.path.join(directory, "data/*/*/*.xml")) + glob.glob(os.path.join(directory, "data/*/*.xml")) |
|
files, cts = [f for f in data if "__cts__.xml" not in f], [f for f in data if "__cts__.xml" in f] |
|
|
|
# For unit testing and human readable progression |
|
cts.sort() |
|
files.sort() |
|
return files, cts |
|
|
|
|
|
class FilterFinder(DefaultFinder): |
|
""" FilterFinder provide a filtering capacity to DefaultFinder. |
|
|
|
It takes an include option which takes the form of the work urn (*ie.* in urn:cts:latinLit:phi1294.phi002.perseus-lat2 \ |
|
this would be phi1294.phi002.perseus-lat2, cut at any of the points : phi1294, phi1294.phi002, phi1294.phi002.perseus-lat2) |
|
|
|
:param include: Representation of the work urn component (might be from one member down to the version member) |
|
:type include: str |
|
""" |
|
def __init__(self, include, **options): |
|
self.include = include.split(".") |
|
|
|
def find(self, directory): |
|
""" Return object to find |
|
|
|
:param directory: Root Directory to search in |
|
|
|
:returns: Path of xml text files, Path of __cts__.xml files |
|
:rtype: (list, list) |
|
""" |
|
textgroup, work, version = "*", "*", "*.*.*", |
|
if len(self.include) == 3: |
|
version = ".".join(self.include) |
|
if len(self.include) >= 2: |
|
work = self.include[1] |
|
if len(self.include) >= 1: |
|
textgroup = self.include[0] |
|
|
|
cts = glob.glob(os.path.join(directory, "data/{textgroup}/__cts__.xml".format( |
|
textgroup=textgroup |
|
))) + \ |
|
glob.glob(os.path.join(directory, "data/{textgroup}/{work}/__cts__.xml".format( |
|
textgroup=textgroup, work=work |
|
))) |
|
files = glob.glob(os.path.join(directory, "data/{textgroup}/{work}/{version}.xml".format( |
|
textgroup=textgroup, work=work, version=version |
|
))) |
|
# For unit testing and human readable progression |
|
cts.sort() |
|
files.sort() |
|
return files, cts |
This issue is to track what needs to be changed to make HookTest compliant with the new MyCapytain guidelines: https://github.com/Capitains/guidelines. The user will be able to choose whether to use these new guidelines or the old guidelines through the
guidelinesparameter, i.e., choosing3.epidocor3.teiinstead of2.epidocor2.tei.Changes that I see right now need to be made:
__capitains__.xmlfiles instead of__cts__.xmlHookTest/HookTest/test.py
Lines 30 to 94 in c695aad
refsDecl. Here we need to:@nand@xml:baseattributes on the refsDecl element@correspattribute on cRefPattern to make sure it exists and there are no duplicates. Perhaps also that every level has a cRefPattern, i.e., that the number of cRefPattern nodes equals the max depth of a citation in the text.@matchPatternattributes on cRefPattern to make sure that:@matchPattern==@corresp- 1. This should help to avoid the error of using dot to match all and that the@matchPatternis for a different citation level than the one being represented.What have I forgotten here?