UseCases.FileSysObjects.createAndUseSearchLists.from_glob package¶
Submodules¶
UseCases.FileSysObjects.createAndUseSearchLists.from_glob.CallCase module¶
Create a plist, find a matching relative filepathname in directory tree.
-
class
UseCases.FileSysObjects.createAndUseSearchLists.from_glob.CallCase.
UseCase
(methodName='runTest')[source]¶ Bases:
unittest.case.TestCase
-
testCase100
()[source]¶ The scope of the start node is literal+glob(LG).
Calling elementary functions.
Data:
see 'testdata.examples'
refer also to the manual [filesystem-elements-as-objects]
Call:
import testdata import filesysobjects.FileSysObjects # start of upward search - file is converted into it's containing directory node s = os.sep any_sub_path = os.path.normpath('examples/a/b[0-9]/c/?/b?/*c/F*') spath = testdata.mypath spath += any_sub_path spath = glob.glob(spath) assert len(spath) == 1 spath = spath[0] # # should result in the same single entry as the previous case for: # # any_sub_path = os.path.normpath('examples/a/b0/c/a/b0/c/F') # # Here an empty list is used for search only. The function adds # entries to the provided list storage, thus e.g. to 'sys.path' too. _plist = [] # 0. build a search path list - if not yet available # adds each directory from spath to its matching # subnode "a/b" # setUpperTreeSearchPath(spath,os.path.normpath('a/b0'), _plist) # 1. make it canonical - optional, here just a demo clearPath(_plist,**{'redundant':True,'shrink':True}) # and clear them immediately # 2.a. find the requested entry rp = findRelPathInSearchPath("F[0-5]*",_plist) # 2.b. find the requested entry - here as demo with a relative path rp = findRelPathInSearchPath("c/*/b0/F[0-5]*",_plist)
Result:
expected = os.path.normpath(testdata.mypath+'/examples/a/b0/c/a/b0/F1')
-