Beispiel #1
0
        srcdir, src, origname = cls._find(srcpath)
        if src:
            dest[tgtname] = src
            del srcdir[origname]
        else:
            raise OSError("[Errno 2] No such file or directory: '%s'" % source)

    ######################################################################
    # Folders only
    @classmethod
    def get_names(cls, reference):
        path = str(reference.path)
        parent, item, name = cls._find(path)
        if item is None:
            raise OSError("[Errno 2] No such file or directory: '%s'" %
                          reference)
        if item.is_file:
            raise OSError("[Errno 20] Not a directory '%s'" % reference)
        return item.keys()


register_file_system('mem', MemFS)

# python's urlparse.urlsplit doesn't know anything about mem urls, so we have
# to force it to parse query strings and fragments by adding the mem scheme
# to urlparse's internal arrays
import urlparse

urlparse.uses_fragment.append('mem')
urlparse.uses_query.append('mem')
Beispiel #2
0
            dst = target.path.resolve2(source.path[-1])
            dst = unicode(dst)

        try:
            rename(src, dst)
        except OSError:
            copy(src, dst)
            cls.remove(src)


    ######################################################################
    # Folders only
    @classmethod
    def get_names(cls, reference):
        path = unicode(reference.path)
        try:
            names = listdir(path)
            to_unicode = True
        except UnicodeEncodeError:
            names = listdir(path.encode('utf-8'))
            to_unicode = False
        if to_unicode:
            if names and isinstance(names[0], str):
                names = [n.decode('utf-8') for n in names]
        return names
        



register_file_system('file', FileFS)
Beispiel #3
0
        # If target is a folder, move inside it
        if isdir(dst):
            dst = target.path.resolve2(source.path[-1])
            dst = unicode(dst)

        try:
            rename(src, dst)
        except OSError:
            copy(src, dst)
            cls.remove(src)

    ######################################################################
    # Folders only
    @classmethod
    def get_names(cls, reference):
        path = unicode(reference.path)
        try:
            names = listdir(path)
            to_unicode = True
        except UnicodeEncodeError:
            names = listdir(path.encode('utf-8'))
            to_unicode = False
        if to_unicode:
            if names and isinstance(names[0], str):
                names = [n.decode('utf-8') for n in names]
        return names


register_file_system('file', FileFS)
Beispiel #4
0
        srcpath = str(source.path)
        srcdir, src, origname = cls._find(srcpath)
        if src:
            dest[tgtname] = src
            del srcdir[origname]
        else:
            raise OSError("[Errno 2] No such file or directory: '%s'" % source)

    ######################################################################
    # Folders only
    @classmethod
    def get_names(cls, reference):
        path = str(reference.path)
        parent, item, name = cls._find(path)
        if item is None:
            raise OSError("[Errno 2] No such file or directory: '%s'" % reference)
        if item.is_file:
            raise OSError("[Errno 20] Not a directory '%s'" % reference)
        return item.keys()


register_file_system('mem', MemFS)

# python's urlparse.urlsplit doesn't know anything about mem urls, so we have
# to force it to parse query strings and fragments by adding the mem scheme
# to urlparse's internal arrays
import urlparse
urlparse.uses_fragment.append('mem')
urlparse.uses_query.append('mem')