當前位置: 首頁>>代碼示例>>Python>>正文


Python File.get_relative_path方法代碼示例

本文整理匯總了Python中gio.File.get_relative_path方法的典型用法代碼示例。如果您正苦於以下問題:Python File.get_relative_path方法的具體用法?Python File.get_relative_path怎麽用?Python File.get_relative_path使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在gio.File的用法示例。


在下文中一共展示了File.get_relative_path方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: Folder

# 需要導入模塊: from gio import File [as 別名]
# 或者: from gio.File import get_relative_path [as 別名]

#.........這裏部分代碼省略.........
        g_file = self._get_g_file(uri)
        # XXX g_file_make_directory_with_parents is not yet implemented!!
        _make_directory_with_parents(g_file)


    def get_ctime(self, uri):
        return self._get_xtime(uri, FILE_ATTRIBUTE_TIME_CHANGED)


    def get_mtime(self, uri):
        return self._get_xtime(uri, FILE_ATTRIBUTE_TIME_MODIFIED)


    def get_atime(self, uri):
        return self._get_xtime(uri, FILE_ATTRIBUTE_TIME_ACCESS)


    def get_mimetype(self, uri):
        g_file = self._get_g_file(uri)

        info = g_file.query_info(FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE)
        content_type = info.get_attribute_as_string(
                            FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE)
        return content_type_get_mime_type(content_type)


    def get_size(self, uri):
        g_file = self._get_g_file(uri)
        info = g_file.query_info(FILE_ATTRIBUTE_STANDARD_SIZE)
        return info.get_attribute_uint64(FILE_ATTRIBUTE_STANDARD_SIZE)


    def open(self, uri, mode=READ):
        g_file = self._get_g_file(uri)

        # A directory => a new Folder ?
        if g_file.query_exists() and _is_folder(g_file):
            return Folder(g_file)

        # Get the Stream
        if mode is READ:
            # XXX can we find a better implementation ?
            # The problem is that a GFileInputStream object
            # doesn't implement all the usual functions of "file"
            # by example, there is no get_lines member.
            return StringIO(g_file.read().read())
        elif mode is WRITE:
            return g_file.replace('', False)
        elif mode is APPEND:
            return g_file.append_to()
        # XXX Finish me
        elif mode is READ_WRITE:
            raise NotImplementedError


    def remove(self, uri):
        g_file = self._get_g_file(uri)
        _remove(g_file)


    def copy(self, source, target):
        source = self._get_g_file(source)
        target = self._get_g_file(target)

        # Make the target's parent directory
        _make_directory_with_parents(target.get_parent())

        _copy(source, target)


    def move(self, source, target):
        source = self._get_g_file(source)
        target = self._get_g_file(target)

        # Make the target's parent directory
        _make_directory_with_parents(target.get_parent())

        source.move(target)


    def get_names(self, uri='.'):
        g_file = self._get_g_file(uri)
        return _get_names(g_file)


    def traverse(self, uri):
        g_file = self._get_g_file(uri)
        return _traverse(g_file)


    def get_uri(self, reference='.'):
        g_file = self._get_g_file(reference)
        return g_file.get_uri()


    def get_relative_path(self, uri):
        g_file = self._get_g_file(uri)
        if self._folder is None:
            return g_file.get_path()
        return self._folder.get_relative_path(g_file)
開發者ID:kiniou,項目名稱:blender-smooth-slides,代碼行數:104,代碼來源:vfs.py

示例2: Folder

# 需要導入模塊: from gio import File [as 別名]
# 或者: from gio.File import get_relative_path [as 別名]

#.........這裏部分代碼省略.........
    def open(self, uri, mode=READ):
        g_file = self._get_g_file(uri)

        # A directory => a new Folder ?
        if g_file.query_exists() and _is_folder(g_file):
            return Folder(g_file)

        # Get the Stream
        if mode is READ:
            # XXX can we find a better implementation ?
            # The problem is that a GFileInputStream object
            # doesn't implement all the usual functions of "file"
            # by example, there is no get_lines member.
            return StringIO(g_file.read().read())
        elif mode is WRITE:
            return g_file.replace('', False)
        elif mode is APPEND:
            return g_file.append_to()
        # XXX Finish me
        elif mode is READ_WRITE:
            raise NotImplementedError


    def remove(self, uri):
        g_file = self._get_g_file(uri)
        _remove(g_file)


    def copy(self, source, target):
        source = self._get_g_file(source)
        target = self._get_g_file(target)

        # Make the target's parent directory
        _make_directory_with_parents(target.get_parent())

        _copy(source, target)


    def move(self, source, target):
        source = self._get_g_file(source)
        target = self._get_g_file(target)

        # Make the target's parent directory
        _make_directory_with_parents(target.get_parent())

        source.move(target)


    def get_names(self, uri='.'):
        g_file = self._get_g_file(uri)
        return _get_names(g_file)


    def traverse(self, uri):
        g_file = self._get_g_file(uri)
        return _traverse(g_file)


    def mount_archive(self, uri):
        g_file = self._get_g_file(uri)
        return Archive(g_file)


    def get_uri(self, reference='.'):
        g_file = self._get_g_file(reference)
        return g_file.get_uri()


    def get_relative_path(self, uri):
        g_file = self._get_g_file(uri)
        if self._folder is None:
            return g_file.get_path()
        return self._folder.get_relative_path(g_file)


    #######################################################################
    # Used by itools.handlers
    #######################################################################
    @staticmethod
    def get_basename(reference):
        return get_uri_name(reference)


    @staticmethod
    def get_path(reference):
        return get_uri_path(reference)


    @staticmethod
    def resolve(base, reference):
        return resolve_uri(base, reference)


    @staticmethod
    def resolve2(base, reference):
        return resolve_uri2(base, reference)


    # Resolution method for handler database keys
    normalize_key = get_uri
開發者ID:Nabellaleen,項目名稱:itools,代碼行數:104,代碼來源:vfs.py


注:本文中的gio.File.get_relative_path方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。