Esempio n. 1
0
	def write_items(self, items):
		our_ext = ".kfcom"

		def make_obj_filename(lname, id_):
			id_ = id_.replace("/", "_")
			return "%s (%s)%s" % (lname, id_, our_ext)

		written_now = set()
		for obj in items:
			obj = AppLeaf(obj)
			action = objects.Launch()
			composed = compose.ComposedLeaf(obj, action)
			lname = kupferstring.tolocale(unicode(obj))
			basename = make_obj_filename(lname, obj.get_id())
			filename = os.path.join(DOCKDIR, basename)
			written_now.add(basename)
			if os.path.exists(filename):
				#debug_log("exists:", filename)
				continue
			debug_log("creating:", filename)
			tmpname = "%s.%d" % (basename, os.getpid())
			execfile.save_to_file(composed, tmpname)
			execfile.update_icon(obj, tmpname)
			gio.File(tmpname).move(gio.File(filename),
			                       flags=gio.FILE_COPY_OVERWRITE)

		for fname in os.listdir(DOCKDIR):
			if fname.endswith(our_ext) and fname not in written_now:
				filepath = os.path.join(DOCKDIR, fname)
				if os.access(filepath, os.W_OK):
					debug_log("remove:", fname)
					gio.File(os.path.join(DOCKDIR, fname)).delete(None)
Esempio n. 2
0
 def activate(self, obj, iobj):
     filepath = iobj.object
     execfile.save_to_file(obj, filepath)
     execfile.update_icon(obj, iobj.object)
     return FileLeaf(os.path.abspath(filepath))
Esempio n. 3
0
 def activate(self, obj, iobj):
     filepath = kupferstring.tolocale(iobj.object)
     execfile.save_to_file(obj, filepath)
     execfile.update_icon(obj, iobj.object)
     return FileLeaf(os.path.abspath(filepath))
Esempio n. 4
0
 def activate(self, obj, iobj):
     filepath = kupferstring.tolocale(iobj.object)
     execfile.save_to_file(obj, filepath)
     execfile.update_icon(obj, iobj.object)
     return FileLeaf(os.path.abspath(filepath))