[gnome-commander] python plugins: new plugin 'apply_patch'



commit 479e2fba2330d562c91bf569f6b43b594ef49032
Author: Piotr Eljasiak <epiotr src gnome org>
Date:   Sat Jan 7 13:29:56 2012 +0100

    python plugins: new plugin 'apply_patch'

 plugins/python/apply-patch/Makefile.am    |    7 +++++
 plugins/python/apply-patch/apply_patch.py |   41 +++++++++++++++++++++++++++++
 2 files changed, 48 insertions(+), 0 deletions(-)
---
diff --git a/plugins/python/apply-patch/Makefile.am b/plugins/python/apply-patch/Makefile.am
new file mode 100644
index 0000000..d5c27a1
--- /dev/null
+++ b/plugins/python/apply-patch/Makefile.am
@@ -0,0 +1,7 @@
+## Process this file with automake to produce Makefile.in
+
+plugindir = $(pkglibdir)/plugins
+
+plugin_PYTHON = apply_patch.py
+
+-include $(top_srcdir)/git.mk
diff --git a/plugins/python/apply-patch/apply_patch.py b/plugins/python/apply-patch/apply_patch.py
new file mode 100644
index 0000000..81548b1
--- /dev/null
+++ b/plugins/python/apply-patch/apply_patch.py
@@ -0,0 +1,41 @@
+#       apply_patch python plugin
+#       Copyright (C) 2012 Piotr Eljasiak
+#
+#    Part of
+#       GNOME Commander - A GNOME based file manager
+#       Copyright (C) 2001-2006 Marcus Bjurman
+#       Copyright (C) 2007-2012 Piotr Eljasiak
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+
+# Description:
+#   the plugin applies selected patches to the opposite pane using -p1 param
+
+try:
+    import gnomevfs
+except ImportError:
+    import gnome.vfs as gnomevfs
+
+import os
+import urllib
+
+
+def main(main_wnd_xid, active_cwd, inactive_cwd, selected_files):
+    for uri in selected_files:
+        if gnomevfs.get_file_info(uri,gnomevfs.FILE_INFO_GET_MIME_TYPE|gnomevfs.FILE_INFO_FORCE_FAST_MIME_TYPE).mime_type=='text/x-patch':
+            cmd = "patch -p1 --directory='%s' --input='%s' --quiet" % (inactive_cwd, urllib.unquote(uri.path))
+            os.system(cmd)
+
+    return True



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]