Exemple #1
0
    def __call__(self):
        import textwrap

        from kupfer import uiutils

        environment = make_environment(last_result=DummyResult())
        docstrings = []
        for attr in sorted(environment):
            if attr != "_" and attr.startswith("_"):
                continue
            val = environment[attr]
            if not callable(val):
                docstrings.append(u"%s = %s" % (attr, val))
                continue
            try:
                docstrings.append(val.__doc__)
            except AttributeError:
                pass
        formatted = []
        maxlen = 72
        left_margin = 4
        for docstr in docstrings:
            # Wrap the description and align continued lines
            docsplit = docstr.split("\n", 1)
            if len(docsplit) < 2:
                formatted.append(docstr)
                continue
            wrapped_lines = textwrap.wrap(docsplit[1].strip(),
                                          maxlen - left_margin)
            wrapped = (u"\n" + u" " * left_margin).join(wrapped_lines)
            formatted.append("%s\n    %s" % (docsplit[0], wrapped))
        uiutils.show_text_result("\n\n".join(formatted), _("Calculator"))
        raise IgnoreResultException
Exemple #2
0
	def __call__(self):
		import textwrap

		from kupfer import uiutils

		environment = make_environment(last_result=DummyResult())
		docstrings = []
		for attr in sorted(environment):
			if attr != "_" and attr.startswith("_"):
				continue
			val = environment[attr]
			if not callable(val):
				docstrings.append(u"%s = %s" % (attr, val))
				continue
			try:
				docstrings.append(val.__doc__)
			except AttributeError:
				pass
		formatted = []
		maxlen = 72
		left_margin = 4
		for docstr in docstrings:
			# Wrap the description and align continued lines
			docsplit = docstr.split("\n", 1)
			if len(docsplit) < 2:
				formatted.append(docstr)
				continue
			wrapped_lines = textwrap.wrap(docsplit[1].strip(),
					maxlen - left_margin)
			wrapped = (u"\n" + u" " * left_margin).join(wrapped_lines)
			formatted.append("%s\n    %s" % (docsplit[0], wrapped))
		uiutils.show_text_result("\n\n".join(formatted), _("Calculator"))
		raise IgnoreResultException
 def activate(self, leaf):
     cli = ["gpg", "--verify", "--batch", leaf.object]
     p = subprocess.Popen(cli,
                          stdout=subprocess.PIPE,
                          stderr=subprocess.PIPE)
     stdout, stderr = p.communicate()
     uiutils.show_text_result(stdout or stderr,
                              title=_("Verification Result"))
Exemple #4
0
	def activate(self, leaf):
		import StringIO
		# NOTE: Core imports
		from kupfer.core import qfurl
		from kupfer import uiutils
		from kupfer import puid

		output = StringIO.StringIO()
		def print_func(*args):
			print >>output, " ".join(unicode(a) for a in args)
			pretty.print_debug("debug", *args)

		print_func("Debug info about", leaf)
		print_func(leaf, repr(leaf))
		def get_qfurl(leaf):
			try:
				return qfurl.qfurl(leaf)
			except qfurl.QfurlError:
				pass
		def get_object_fields(leaf):
			return {
				"repr" : leaf,
				"description": leaf.get_description(),
				"thumb" : leaf.get_thumbnail(32, 32),
				"gicon" : leaf.get_gicon(),
				"icon" : leaf.get_icon(),
				"icon-name": leaf.get_icon_name(),
				"type" : type(leaf),
				"module" : leaf.__module__,
				"aliases" : getattr(leaf, "name_aliases", None),
				"qfurl" : get_qfurl(leaf),
				"puid" : puid.get_unique_id(leaf),
				}
		def get_leaf_fields(leaf):
			base = get_object_fields(leaf)
			base.update( {
				"object" : leaf.object,
				"object-type" : type(leaf.object),
				"content" : leaf.content_source(),
				"content-alt" : leaf.content_source(alternate=True),
				"builtin-actions": list(leaf.get_actions()),
				} )
			return base
		def get_source_fields(src):
			base = get_object_fields(src)
			base.update({
				"dynamic" : src.is_dynamic(),
				"sort" : src.should_sort_lexically(),
				"parent" : src.get_parent(),
				"leaf" : src.get_leaf_repr(),
				"provides" : list(src.provides()),
				"cached_items": type(src.cached_items),
				"len": isinstance(src.cached_items, list) and len(src.cached_items),
				} )
			return base

		def print_fields(fields):
			for field in sorted(fields):
				val = fields[field]
				rep = repr(val)
				print_func("%-15s:" % field, rep)
				if str(val) not in rep:
					print_func("%-15s:" % field, val)
		leafinfo = get_leaf_fields(leaf)
		print_fields(leafinfo)
		if leafinfo["content"]:
			print_func("Content ============")
			print_fields(get_source_fields(leafinfo["content"]))
		if leafinfo["content"] != leafinfo["content-alt"]:
			print_func("Content-Alt ========")
			print_fields(get_source_fields(leafinfo["content-alt"]))
		uiutils.show_text_result(output.getvalue())
Exemple #5
0
 def activate(self, leaf, ctx):
     uiutils.show_text_result(leaf.get_text_representation(),
                              title=_("Show Text"),
                              ctx=ctx)
Exemple #6
0
	def activate(self, leaf):
		uiutils.show_text_result(leaf.get_text_representation(), title=_("Show Text"))
Exemple #7
0
	def finish(self, text):
		uiutils.show_text_result(text, title=_("Show Package Information"))
		self._finish_callback(self)
Exemple #8
0
	def activate(self, leaf):
		uiutils.show_text_result(leaf.object, title=_("Show Text"))
Exemple #9
0
 def finish(self, text):
     uiutils.show_text_result(text, title=_("Show Package Information"))
     self._finish_callback(self)
Exemple #10
0
	def thread_finish(self):
		uiutils.show_text_result(self.info, title=_("Show Package Information"))
	def activate(self, leaf):
		cli = ["gpg", "--verify", "--batch", leaf.object]
		p = subprocess.Popen(cli, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
		stdout, stderr = p.communicate()
		uiutils.show_text_result(stdout or stderr, title=_("Verification Result"))