示例#1
0
文件: base.py 项目: anujkumar93/stor
    def __new__(cls, path):
        if cls is Path:
            if not hasattr(path, 'startswith'):
                raise TypeError('must be a string like')
            if utils.is_dx_path(path):
                cls = utils.find_dx_class(path)
            elif utils.is_swift_path(path):
                from stor.swift import SwiftPath

                cls = SwiftPath
            elif utils.is_s3_path(path):
                from stor.s3 import S3Path

                cls = S3Path
            elif os.path == ntpath:
                from stor.windows import WindowsPath

                cls = WindowsPath
            elif os.path == posixpath:
                from stor.posix import PosixPath

                cls = PosixPath
            else:  # pragma: no cover
                assert False, 'path is not compatible with stor'
        return text_type.__new__(cls, path)
示例#2
0
def _convert_swiftstack(path, bucket=None):
    path = stor.Path(path)
    if utils.is_swift_path(path):
        if not bucket:
            # TODO (jtratner): print help here
            raise ValueError('--bucket is required for swift paths')
        return swiftstack.swift_to_s3(path, bucket=bucket)
    elif utils.is_s3_path(path):
        return swiftstack.s3_to_swift(path)
    else:
        raise ValueError("invalid path for conversion: '%s'" % path)