当前位置: 首页>>代码示例>>Python>>正文


Python gio.File类代码示例

本文整理汇总了Python中gio.File的典型用法代码示例。如果您正苦于以下问题:Python File类的具体用法?Python File怎么用?Python File使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了File类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __get_search_path_from

	def __get_search_path_from(self, uri):
		self.__manager.response()
		from gio import File
		path = File(uri).get_parse_name()
		path = path.replace(self.__home_folder, "").strip("/\\")
		self.__manager.response()
		return path
开发者ID:mystilleef,项目名称:scribes,代码行数:7,代码来源:DataGenerator.py

示例2: _get_g_file

    def _get_g_file(self, uri):
        if type(uri) is not str:
            raise TypeError, 'unexpected "%s"' % repr(uri)

        # Resolve or not ?

        # Your folder is None => new File
        if self._folder is None:
            g_file = File(uri)
        else:
            # Split the uri
            scheme, authority, path, query, fragment = urlsplit(uri)

            # A scheme or an authority => new File
            # XXX This is not truly exact:
            #     we can have a scheme and a relative path.
            if scheme or authority:
                g_file = File(uri)
            else:
                # Else we resolve the path
                g_file = self._folder.resolve_relative_path(uri)

        # Automount a ftp server ?
        if g_file.get_uri_scheme () == 'ftp':
            # Mount the server
            AnonymousConnection(g_file)

        return g_file
开发者ID:kiniou,项目名称:blender-smooth-slides,代码行数:28,代码来源:vfs.py

示例3: __go_up

	def __go_up(self):
		from gio import File
		gfile = File(self.__folder_uri).get_parent()
		if not gfile: return False
		from gobject import idle_add
		idle_add(self.__manager.emit, "generate-uris", gfile.get_uri())
		return False
开发者ID:mystilleef,项目名称:scribes,代码行数:7,代码来源:PathNavigator.py

示例4: __set_label

	def __set_label(self):
		from gio import File
		uri = self.__editor.uri
		if uri: folder = File(uri).get_parent().get_parse_name()
		if not uri: folder = self.__editor.desktop_folder
		folder = folder.replace(self.__editor.home_folder.rstrip("/"), "~")
		self.__label.set_label(message % folder)
		return False
开发者ID:mystilleef,项目名称:scribes,代码行数:8,代码来源:InfoLabel.py

示例5: __show

	def __show(self, data):
		uri, message = data
		self.__editor.emit("load-error", uri)
		from gio import File
		gfile = File(uri)
		title = _("File: %s") % gfile.get_parse_name()
		self.__editor.show_error(title, message)
		return False
开发者ID:mystilleef,项目名称:scribes,代码行数:8,代码来源:ErrorManager.py

示例6: show_path

def show_path(path):
	"""Open local @path with default viewer"""
	from gio import File
	# Implemented using gtk.show_uri
	gfile = File(path)
	if not gfile:
		return
	url = gfile.get_uri()
	show_url(url)
开发者ID:sagivmalihi,项目名称:kupfer,代码行数:9,代码来源:utils.py

示例7: ColorButton

class ColorButton(object):

	def __init__(self, editor, manager):
		self.__init_attributes(editor, manager)
		self.__set_properties()
		self.__sigid1 = self.__button.connect("color-set", self.__color_set_cb)
		self.__sigid2 = manager.connect("destroy", self.__destroy_cb)
		self.__monitor.connect("changed", self.__changed_cb)
		self.__button.set_property("sensitive", True)

	def __init_attributes(self, editor, manager):
		self.__editor = editor
		self.__manager = manager
		self.__button = manager.gui.get_widget("BracketSelectionColorButton")
		from os.path import join
		preference_folder = join(editor.metadata_folder, "PluginPreferences")
		_path = join(preference_folder, "LexicalScopeHighlight.gdb")
		from gio import File, FILE_MONITOR_NONE
		self.__monitor = File(_path).monitor_file(FILE_MONITOR_NONE, None)
		return

	def __set_properties(self):
		from LexicalScopeHighlightMetadata import get_value
		from gtk.gdk import color_parse
		color = color_parse(get_value())
		self.__button.set_color(color)
		return

	def __destroy(self):
		self.__monitor.cancel()
		self.__editor.disconnect_signal(self.__sigid1, self.__button)
		self.__editor.disconnect_signal(self.__sigid2, self.__manager)
		self.__button.destroy()
		del self
		self = None
		return

	def __color_set_cb(self, *args):
		from LexicalScopeHighlightMetadata import set_value
		color = self.__button.get_color().to_string()
		set_value(color)
		return True

	def __destroy_cb(self, *args):
		self.__destroy()
		return True

	def __changed_cb(self, *args):
		monitor, gfile, otherfile, event = args
		if not (event in (0,2,3)): return False
		self.__button.handler_block(self.__sigid1)
		from LexicalScopeHighlightMetadata import get_value
		from gtk.gdk import color_parse
		color = color_parse(get_value())
		self.__button.set_color(color)
		self.__button.handler_unblock(self.__sigid1)
		return True
开发者ID:mystilleef,项目名称:scribes,代码行数:57,代码来源:BracketSelectionColorButton.py

示例8: __get_display_path_from

	def __get_display_path_from(self, uri):
		self.__manager.response()
		from gio import File
		path = File(uri).get_parent().get_parse_name()
		path = path.replace(self.__home_folder, "").strip("/\\")
		from os.path import split
		self.__manager.response()
		if not path: return split(self.__home_folder)[-1].strip("/\\")
		return path
开发者ID:mystilleef,项目名称:scribes,代码行数:9,代码来源:DataGenerator.py

示例9: __set_label

	def __set_label(self, fileinfo):
		try:
			if not self.__editor.uri: raise AssertionError
			from gio import File
			path = File(self.__editor.uri).get_parent().get_parse_name()
			folder = path.replace(self.__editor.home_folder.rstrip("/"), "~")
			self.__label.set_text(folder)
		except AssertionError:
			self.__label.set_text("Unknown")
		return False
开发者ID:mystilleef,项目名称:scribes,代码行数:10,代码来源:LocationLabel.py

示例10: find_project_root

    def find_project_root(self, path):
        f = File(path)
        project_files = (".git", ".ropeproject", ".bzr", ".hg", ".scribes_project")
        while True:
            if any(f.get_child(r).query_exists() for r in project_files):
                return f.get_uri()

            p = f.get_parent()
            if p:
                f = p
            else:
                return path
开发者ID:baverman,项目名称:scribes-goodies,代码行数:12,代码来源:PluginFixedQuickOpen.py

示例11: new_get_dictionary

        def new_get_dictionary(this, uri):
            title = File(uri).get_basename() if uri else _("Unnamed Document")

            if title.endswith('.py'):
                title = get_python_title(uri)

            return {
                "normal": title,
                "modified": "*" + title,
                "readonly": title + _(" [READONLY]"),
                "loading": _("Loading %s ...") % title,
            }
开发者ID:baverman,项目名称:scribes-goodies,代码行数:12,代码来源:PluginFixedTitleUpdater.py

示例12: find_project_root

def find_project_root(uri):
    f = File(uri)
    special_names = ('.ropeproject', '.git', '.hg', '.bzr', '.scribes_project')
    while True:
        for name in special_names:
            if f.get_child(name).query_exists():
                return f.get_path()

        p = f.get_parent()
        if p:
            f = p
        else:
            return None
开发者ID:baverman,项目名称:scribes-goodies,代码行数:13,代码来源:__init__.py

示例13: __select

	def __select(self):
		try:
			if not self.__editor.uri: raise ValueError
			from gio import File 
			gfile = File(self.__editor.uri)
			folder_uri = gfile.get_parent().get_uri()
			if folder_uri != self.__chooser.get_current_folder_uri():
				self.__chooser.set_current_folder_uri(folder_uri)
			fileinfo = gfile.query_info("standard::display-name")
			self.__chooser.set_current_name(fileinfo.get_display_name())
		except ValueError:
			self.__chooser.set_current_name(_("Unsaved Document"))
			self.__chooser.set_current_folder(self.__editor.desktop_folder)
		return False
开发者ID:mystilleef,项目名称:scribes,代码行数:14,代码来源:URISelector.py

示例14: __get_dictionary

	def __get_dictionary(self, uri):
		from gio import File
		title = File(uri).get_basename() if uri else _("Unnamed Document")
		ellipsize = self.__ellipsize
		if uri: parent_path = File(uri).get_parent().get_parse_name()
		if uri: parent_path = ellipsize(parent_path.replace(self.__editor.home_folder, "~").strip("/\\"))
		fulltitle = "%s - (%s)" % (title, parent_path) if uri else title
		fulltitle = title if len(title) > 30 else fulltitle
		dictionary = {
			"normal": fulltitle,
			"modified": "*" + fulltitle,
			"readonly": fulltitle + _(" [READONLY]"),
			"loading": _("Loading %s ...") % title,
		}
		return dictionary
开发者ID:mystilleef,项目名称:scribes,代码行数:15,代码来源:TitleUpdater.py

示例15: get_gicon_for_file

def get_gicon_for_file(uri):
	"""
	Return a GIcon representing the file at
	the @uri, which can be *either* and uri or a path

	return None if not found
	"""

	gfile = File(uri)
	if not gfile.query_exists():
		return None

	finfo = gfile.query_info(FILE_ATTRIBUTE_STANDARD_ICON)
	gicon = finfo.get_attribute_object(FILE_ATTRIBUTE_STANDARD_ICON)
	return gicon
开发者ID:cjparsons74,项目名称:kupfer,代码行数:15,代码来源:icons.py


注:本文中的gio.File类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。