UseCases.FileSysObjects.createAndUseSearchLists.from_literal package

Submodules

UseCases.FileSysObjects.createAndUseSearchLists.from_literal.CallCase module

Create a plist, find a matching relative filepathname in directory tree.

class UseCases.FileSysObjects.createAndUseSearchLists.from_literal.CallCase.UseCase(methodName='runTest')[source]

Bases: unittest.case.TestCase

testCase000()[source]

The scope of the start node is literal(L).

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/b0/c/a/b0/c/F')
    spath  = testdata.mypath
    spath += any_sub_path
    
    # 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')
    

Module contents