def testPathComponents(self): components = PathComponents( '/some/external/path/to/file.h5/with/internal/path/to/data') assert components.externalPath == '/some/external/path/to/file.h5' assert components.extension == '.h5' assert components.internalPath == '/with/internal/path/to/data' components = PathComponents( '/some/external/path/to/file.h5_crazy_ext.h5/with/internal/path/to/data' ) assert components.externalPath == '/some/external/path/to/file.h5_crazy_ext.h5' assert components.extension == '.h5' assert components.internalPath == '/with/internal/path/to/data' # Everything should work for URLs, too. components = PathComponents( 'http://somehost:8000/path/to/data/with.ext') assert components.externalPath == 'http://somehost:8000/path/to/data/with.ext' assert components.extension == '.ext' assert components.internalPath is None assert components.externalDirectory == 'http://somehost:8000/path/to/data' assert components.filenameBase == 'with' # Try modifying the properties and verify that the total path is updated. components = PathComponents( '/some/external/path/to/file.h5/with/internal/path/to/data') components.extension = '.hdf5' assert components.externalPath == '/some/external/path/to/file.hdf5' assert components.totalPath( ) == '/some/external/path/to/file.hdf5/with/internal/path/to/data' components.filenameBase = 'newbase' assert components.totalPath( ) == '/some/external/path/to/newbase.hdf5/with/internal/path/to/data' components.internalDirectory = 'new/internal/dir' assert components.totalPath( ) == '/some/external/path/to/newbase.hdf5/new/internal/dir/data' components.internalDatasetName = 'newdata' assert components.totalPath( ) == '/some/external/path/to/newbase.hdf5/new/internal/dir/newdata' components.externalDirectory = '/new/extern/dir/' assert components.totalPath( ) == '/new/extern/dir/newbase.hdf5/new/internal/dir/newdata' components.externalDirectory = '/new/extern/dir' assert components.totalPath( ) == '/new/extern/dir/newbase.hdf5/new/internal/dir/newdata' components.externalPath = '/new/externalpath/somefile.h5' assert components.totalPath( ) == '/new/externalpath/somefile.h5/new/internal/dir/newdata' components.filename = 'newfilename.h5' assert components.totalPath( ) == '/new/externalpath/newfilename.h5/new/internal/dir/newdata' components.internalPath = '/new/internal/path/dataset' assert components.totalPath( ) == '/new/externalpath/newfilename.h5/new/internal/path/dataset'
def testPathComponents(self): components = PathComponents("/some/external/path/to/file.h5/with/internal/path/to/data") assert components.externalPath == "/some/external/path/to/file.h5" assert components.extension == ".h5" assert components.internalPath == "/with/internal/path/to/data" components = PathComponents("/some/external/path/to/file.h5_crazy_ext.h5/with/internal/path/to/data") assert components.externalPath == "/some/external/path/to/file.h5_crazy_ext.h5" assert components.extension == ".h5" assert components.internalPath == "/with/internal/path/to/data" components = PathComponents("/some/external/path/to/file.npz_crazy_ext.npz/withInternalPathToData") assert components.externalPath == "/some/external/path/to/file.npz_crazy_ext.npz" assert components.extension == ".npz" assert components.internalPath == "/withInternalPathToData" # Everything should work for URLs, too. components = PathComponents("http://somehost:8000/path/to/data/with.ext") assert components.externalPath == "http://somehost:8000/path/to/data/with.ext" assert components.extension == ".ext" assert components.internalPath is None assert components.externalDirectory == "http://somehost:8000/path/to/data" assert components.filenameBase == "with" # Asterisk should be treated like an ordinary character for component purposes. assert PathComponents("/tmp/hello*.png").totalPath() == "/tmp/hello*.png" # Try modifying the properties and verify that the total path is updated. components = PathComponents("/some/external/path/to/file.h5/with/internal/path/to/data") components.extension = ".hdf5" assert components.externalPath == "/some/external/path/to/file.hdf5" assert components.totalPath() == "/some/external/path/to/file.hdf5/with/internal/path/to/data" components.filenameBase = "newbase" assert components.totalPath() == "/some/external/path/to/newbase.hdf5/with/internal/path/to/data" components.internalDirectory = "new/internal/dir" assert components.totalPath() == "/some/external/path/to/newbase.hdf5/new/internal/dir/data" components.internalDatasetName = "newdata" assert components.totalPath() == "/some/external/path/to/newbase.hdf5/new/internal/dir/newdata" components.externalDirectory = "/new/extern/dir/" assert components.totalPath() == "/new/extern/dir/newbase.hdf5/new/internal/dir/newdata" components.externalDirectory = "/new/extern/dir" assert components.totalPath() == "/new/extern/dir/newbase.hdf5/new/internal/dir/newdata" components.externalPath = "/new/externalpath/somefile.h5" assert components.totalPath() == "/new/externalpath/somefile.h5/new/internal/dir/newdata" components.filename = "newfilename.h5" assert components.totalPath() == "/new/externalpath/newfilename.h5/new/internal/dir/newdata" components.internalPath = "/new/internal/path/dataset" assert components.totalPath() == "/new/externalpath/newfilename.h5/new/internal/path/dataset"
def testPathComponents(self): components = PathComponents("/some/external/path/to/file.h5/with/internal/path/to/data") assert components.externalPath == "/some/external/path/to/file.h5" assert components.extension == ".h5" assert components.internalPath == "/with/internal/path/to/data" components = PathComponents("/some/external/path/to/file.h5_crazy_ext.h5/with/internal/path/to/data") assert components.externalPath == "/some/external/path/to/file.h5_crazy_ext.h5" assert components.extension == ".h5" assert components.internalPath == "/with/internal/path/to/data" # Everything should work for URLs, too. components = PathComponents("http://somehost:8000/path/to/data/with.ext") assert components.externalPath == "http://somehost:8000/path/to/data/with.ext" assert components.extension == ".ext" assert components.internalPath is None assert components.externalDirectory == "http://somehost:8000/path/to/data" assert components.filenameBase == "with" # Asterisk should be treated like an ordinary character for component purposes. assert PathComponents("/tmp/hello*.png").totalPath() == "/tmp/hello*.png" # Try modifying the properties and verify that the total path is updated. components = PathComponents("/some/external/path/to/file.h5/with/internal/path/to/data") components.extension = ".hdf5" assert components.externalPath == "/some/external/path/to/file.hdf5" assert components.totalPath() == "/some/external/path/to/file.hdf5/with/internal/path/to/data" components.filenameBase = "newbase" assert components.totalPath() == "/some/external/path/to/newbase.hdf5/with/internal/path/to/data" components.internalDirectory = "new/internal/dir" assert components.totalPath() == "/some/external/path/to/newbase.hdf5/new/internal/dir/data" components.internalDatasetName = "newdata" assert components.totalPath() == "/some/external/path/to/newbase.hdf5/new/internal/dir/newdata" components.externalDirectory = "/new/extern/dir/" assert components.totalPath() == "/new/extern/dir/newbase.hdf5/new/internal/dir/newdata" components.externalDirectory = "/new/extern/dir" assert components.totalPath() == "/new/extern/dir/newbase.hdf5/new/internal/dir/newdata" components.externalPath = "/new/externalpath/somefile.h5" assert components.totalPath() == "/new/externalpath/somefile.h5/new/internal/dir/newdata" components.filename = "newfilename.h5" assert components.totalPath() == "/new/externalpath/newfilename.h5/new/internal/dir/newdata" components.internalPath = "/new/internal/path/dataset" assert components.totalPath() == "/new/externalpath/newfilename.h5/new/internal/path/dataset"
def testPathComponents(self): components = PathComponents('/some/external/path/to/file.h5/with/internal/path/to/data') assert components.externalPath == '/some/external/path/to/file.h5' assert components.extension == '.h5' assert components.internalPath == '/with/internal/path/to/data' components = PathComponents('/some/external/path/to/file.h5_crazy_ext.h5/with/internal/path/to/data') assert components.externalPath == '/some/external/path/to/file.h5_crazy_ext.h5' assert components.extension == '.h5' assert components.internalPath == '/with/internal/path/to/data' # Everything should work for URLs, too. components = PathComponents('http://somehost:8000/path/to/data/with.ext') assert components.externalPath == 'http://somehost:8000/path/to/data/with.ext' assert components.extension == '.ext' assert components.internalPath is None assert components.externalDirectory == 'http://somehost:8000/path/to/data' assert components.filenameBase == 'with' # Try modifying the properties and verify that the total path is updated. components = PathComponents('/some/external/path/to/file.h5/with/internal/path/to/data') components.extension = '.hdf5' assert components.externalPath == '/some/external/path/to/file.hdf5' assert components.totalPath() == '/some/external/path/to/file.hdf5/with/internal/path/to/data' components.filenameBase = 'newbase' assert components.totalPath() == '/some/external/path/to/newbase.hdf5/with/internal/path/to/data' components.internalDirectory = 'new/internal/dir' assert components.totalPath() == '/some/external/path/to/newbase.hdf5/new/internal/dir/data' components.internalDatasetName = 'newdata' assert components.totalPath() == '/some/external/path/to/newbase.hdf5/new/internal/dir/newdata' components.externalDirectory = '/new/extern/dir/' assert components.totalPath() == '/new/extern/dir/newbase.hdf5/new/internal/dir/newdata' components.externalDirectory = '/new/extern/dir' assert components.totalPath() == '/new/extern/dir/newbase.hdf5/new/internal/dir/newdata' components.externalPath = '/new/externalpath/somefile.h5' assert components.totalPath() == '/new/externalpath/somefile.h5/new/internal/dir/newdata' components.filename = 'newfilename.h5' assert components.totalPath() == '/new/externalpath/newfilename.h5/new/internal/dir/newdata' components.internalPath = '/new/internal/path/dataset' assert components.totalPath() == '/new/externalpath/newfilename.h5/new/internal/path/dataset'
def testPathComponents(self): components = PathComponents( '/some/external/path/to/file.h5/with/internal/path/to/data') assert components.externalPath == '/some/external/path/to/file.h5' assert components.extension == '.h5' assert components.internalPath == '/with/internal/path/to/data' components = PathComponents( '/some/external/path/to/file.h5_crazy_ext.h5/with/internal/path/to/data' ) assert components.externalPath == '/some/external/path/to/file.h5_crazy_ext.h5' assert components.extension == '.h5' assert components.internalPath == '/with/internal/path/to/data' components = PathComponents( '/some/external/path/to/file.npz_crazy_ext.npz/withInternalPathToData' ) assert components.externalPath == '/some/external/path/to/file.npz_crazy_ext.npz' assert components.extension == '.npz' assert components.internalPath == '/withInternalPathToData' # Everything should work for URLs, too. components = PathComponents( 'http://somehost:8000/path/to/data/with.ext') assert components.externalPath == 'http://somehost:8000/path/to/data/with.ext' assert components.extension == '.ext' assert components.internalPath is None assert components.externalDirectory == 'http://somehost:8000/path/to/data' assert components.filenameBase == 'with' # Asterisk should be treated like an ordinary character for component purposes. assert PathComponents( '/tmp/hello*.png').totalPath() == '/tmp/hello*.png' # Try modifying the properties and verify that the total path is updated. components = PathComponents( '/some/external/path/to/file.h5/with/internal/path/to/data') components.extension = '.hdf5' assert components.externalPath == '/some/external/path/to/file.hdf5' assert components.totalPath( ) == '/some/external/path/to/file.hdf5/with/internal/path/to/data' components.filenameBase = 'newbase' assert components.totalPath( ) == '/some/external/path/to/newbase.hdf5/with/internal/path/to/data' components.internalDirectory = 'new/internal/dir' assert components.totalPath( ) == '/some/external/path/to/newbase.hdf5/new/internal/dir/data' components.internalDatasetName = 'newdata' assert components.totalPath( ) == '/some/external/path/to/newbase.hdf5/new/internal/dir/newdata' components.externalDirectory = '/new/extern/dir/' assert components.totalPath( ) == '/new/extern/dir/newbase.hdf5/new/internal/dir/newdata' components.externalDirectory = '/new/extern/dir' assert components.totalPath( ) == '/new/extern/dir/newbase.hdf5/new/internal/dir/newdata' components.externalPath = '/new/externalpath/somefile.h5' assert components.totalPath( ) == '/new/externalpath/somefile.h5/new/internal/dir/newdata' components.filename = 'newfilename.h5' assert components.totalPath( ) == '/new/externalpath/newfilename.h5/new/internal/dir/newdata' components.internalPath = '/new/internal/path/dataset' assert components.totalPath( ) == '/new/externalpath/newfilename.h5/new/internal/path/dataset'