[gnome-commander] Doc: Updated Python Plugins section



commit e263d586fab8c5c7c50a3e79f88fbe52d8f280a9
Author: Uwe Scholz <uwescholz src gnome org>
Date:   Mon Feb 3 22:10:06 2014 +0100

    Doc: Updated Python Plugins section

 doc/C/gnome-commander.xml |   34 +++++++++++++++++++++-------------
 1 files changed, 21 insertions(+), 13 deletions(-)
---
diff --git a/doc/C/gnome-commander.xml b/doc/C/gnome-commander.xml
index 3278901..9d56798 100644
--- a/doc/C/gnome-commander.xml
+++ b/doc/C/gnome-commander.xml
@@ -6923,8 +6923,7 @@
 <!-- This section contains info about the python plugins.-->
   <sect1 id="gnome-commander-python-plugins">
     <title>Python Plugins</title>
-        <para>Since version 1.2.4 &app; is capable of executing python plugins.
-        Python plugin is a normal python application containing predefined entry function.</para>
+        <para>&app; is capable of executing python plugins. A Python plugin is a normal python application 
containing a predefined entry function.</para>
     <para>&app; comes with built-in plugins:</para>
     <itemizedlist>
       <listitem>
@@ -6933,6 +6932,9 @@
       <listitem>
         <para><filename>sha1sum</filename> - SHA-1 (160-bit) checksums of the selected files</para>
       </listitem>
+      <listitem>
+        <para><filename>apply_patch</filename> - The plugin applies selected patches to the opposite pane 
using &quot;patch -p1 --directory='%%s' --input='%%s' --quiet&qout;</para>
+      </listitem>
     </itemizedlist>
     <sect2 id="gnome-commander-python-plugins-working-with">
       <title>Working with plugins</title>
@@ -7009,21 +7011,27 @@
     except ImportError:
         import gnome.vfs as gnomevfs
 
-    import md5
-
+    import os
+    import string
+    import hashlib
 
     def main(main_wnd_xid, active_cwd, inactive_cwd, selected_files):
 
+       parent_dir = string.split(active_cwd, os.sep)[-1]
+        if parent_dir=='':
+            parent_dir = 'root'
+        f_md5sum = file(inactive_cwd+os.sep+parent_dir+'.md5sum', 'w')
         for uri in selected_files:
-            fname = gnomevfs.get_file_info(uri).name
-            f = file.open(fname,'rb')
-            file_content = f.read()
-            f.close()
-            md5sum = md5.new(file_content).hexdigest()
-            print md5sum, fname
-
-        return True
-            </programlisting>
+            if gnomevfs.get_file_info(uri).type==gnomevfs.FILE_TYPE_REGULAR:
+                f = file(active_cwd+os.sep+uri.short_name, 'rb')
+                file_content = f.read()
+                f.close()
+                md5sum = hashlib.md5(file_content).hexdigest()
+                f_md5sum.write('%s  %s\n' % (md5sum, uri.short_name))
+        f_md5sum.close()
+ 
+       return True
+             </programlisting>
       </para>
       <note>
         <para>The latest version of md5sum code can be found in


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