def activate(self, leaf, iobj): archive_type = __kupfer_settings__["archive_type"] dirpath = iobj.object basename = os_path.basename(leaf.object) archive_path = \ utils.get_destpath_in_directory(dirpath, basename, archive_type) utils.launch_commandline("file-roller --add-to='%s' '%s'" % (archive_path, leaf.object))
def _make_archive(cls, ctx, basename, dirpath, filepaths): archive_type = __kupfer_settings__["archive_type"] archive_path = \ utils.get_destpath_in_directory(dirpath, basename, archive_type) cmd = ["file-roller", "--add-to=%s" % (archive_path, )] cmd.extend(filepaths) runtimehelper.register_async_file_result(ctx, archive_path) utils.spawn_async_notify_as("file-roller.desktop", cmd) return archive_path
def activate(self, leaf, iobj): if iobj.object is not None: # Copy the template to destination directory basename = os.path.basename(iobj.object) tmpl_gfile = gio.File(iobj.object) destpath = utils.get_destpath_in_directory(leaf.object, basename) destfile = gio.File(destpath) tmpl_gfile.copy(destfile, flags=gio.FILE_COPY_ALL_METADATA) elif isinstance(iobj, NewFolder): filename = unicode(iobj) destpath = utils.get_destpath_in_directory(leaf.object, filename) os.makedirs(destpath) else: # create new empty file filename = unicode(iobj) f, destpath = utils.get_destfile_in_directory(leaf.object, filename) f.close() return FileLeaf(destpath)
def activate(self, leaf, iobj): if iobj.object is not None: # Copy the template to destination directory basename = os.path.basename(iobj.object) tmpl_gfile = Gio.File.new_for_path(iobj.object) destpath = utils.get_destpath_in_directory(leaf.object, basename) destfile = Gio.File.new_for_path(destpath) tmpl_gfile.copy(destfile, Gio.FileCopyFlags.ALL_METADATA, None, None, None) elif isinstance(iobj, NewFolder): filename = str(iobj) destpath = utils.get_destpath_in_directory(leaf.object, filename) os.makedirs(destpath) else: # create new empty file filename = str(iobj) f, destpath = utils.get_destfile_in_directory(leaf.object, filename) f.close() return FileLeaf(destpath)
def activate(self, leaf, obj=None): fpath = leaf.object dirname = os_path.dirname(fpath) head, ext = os_path.splitext(os_path.basename(fpath)) filename = "%s_%s%s" % (head, self.rotation, ext) dpath = utils.get_destpath_in_directory(dirname, filename) cmdline = ("jpegtran -copy all -rotate '%s' -outfile '%s' '%s'" % (self.rotation, dpath, fpath)) utils.launch_commandline(cmdline) return FileLeaf(dpath)
def activate(self, leaf, obj): size = self._make_size(obj.object) fpath = leaf.object dirname = os_path.dirname(fpath) head, ext = os_path.splitext(os_path.basename(fpath)) filename = "%s_%s%s" % (head, size, ext) dpath = utils.get_destpath_in_directory(dirname, filename) cmdline = "convert -scale '%s' '%s' '%s'" % (size, fpath, dpath) utils.launch_commandline(cmdline) return FileLeaf(dpath)
def activate(self, leaf, obj=None): fpath = leaf.object dirname = os_path.dirname(fpath) head, ext = os_path.splitext(os_path.basename(fpath)) filename = "%s_%s%s" % (head, self.rotation, ext) dpath = utils.get_destpath_in_directory(dirname, filename) argv = ["jpegtran", "-copy", "all", "-rotate", self.rotation, "-outfile", dpath, fpath] runtimehelper.register_async_file_result(dpath) utils.spawn_async(argv) return FileLeaf(dpath)
def activate(self, leaf, obj): size = self._make_size(obj.object) fpath = leaf.object dirname = os_path.dirname(fpath) head, ext = os_path.splitext(os_path.basename(fpath)) filename = "%s_%s%s" % (head, size, ext) dpath = utils.get_destpath_in_directory(dirname, filename) argv = ["convert", "-scale", ('%s' % size), fpath, dpath] runtimehelper.register_async_file_result(dpath) utils.spawn_async(argv) return FileLeaf(dpath)
def activate(self, leaf, obj, ctx): size = self._make_size(obj.object) fpath = leaf.object dirname = os_path.dirname(fpath) head, ext = os_path.splitext(os_path.basename(fpath)) filename = "%s_%s%s" % (head, size, ext) dpath = utils.get_destpath_in_directory(dirname, filename) argv = ["convert", "-scale", ('%s' % size), fpath, dpath] runtimehelper.register_async_file_result(ctx, dpath) spawn_operation_err(argv) return FileLeaf(dpath)
def activate(self, leaf, ctx): fpath = leaf.object dirname = os_path.dirname(fpath) head, ext = os_path.splitext(os_path.basename(fpath)) filename = "%s_%s%s" % (head, self.rotation, ext) dpath = utils.get_destpath_in_directory(dirname, filename) argv = [ "jpegtran", "-copy", "all", "-rotate", self.rotation, "-outfile", dpath, fpath ] runtimehelper.register_async_file_result(ctx, dpath) spawn_operation_err(argv) return FileLeaf(dpath)