Anonymous avatar Anonymous committed 735f874

add file chooser, enumerate procedure database, write to directory

Comments (0)

Files changed (1)

 import os
 import collections
 import ctypes
+import unicodedata
+import re
+
+def slugify(value):
+    """
+    Normalizes string, converts to lowercase, removes non-alpha characters,
+    and converts spaces to hyphens.
+
+    Based on code in: Django
+    """
+    value = unicodedata.normalize('NFKD', unicode(value))
+    value = value.encode('ascii', 'ignore')
+    value = re.sub('[^\w\s-]', '', value).strip().lower()
+    value = re.sub('[-\s]+', '-', value)
+    return value
 
 def get_dir() :
         MessageBox = ctypes.windll.user32.MessageBoxA
 def dump_pdb() :
         MessageBox = ctypes.windll.user32.MessageBoxA
 
-        ofstr = get_dir()
-        if("" == ofstr) :
+        outDirectory = get_dir()
+        if("" == outDirectory) :
                 return None
 
-        plugins = gimp.pdb.query()
-        i = (int) (len(plugins) * random())
+        for name in gimp.pdb.query() :
+                plugin = pdb[name]
+                outFile = os.path.join(
+                        outDirectory,
+                        "%s%s"%(slugify(name), ".txt")
+                )
 
-        MessageBox(None, "directory:%s\nplug-ins:%d\nrandom:%d"%(ofstr, len(plugins), i), "Your moms a rabbit", 0)
-
+                with open(outFile, 'w') as f :
+                        f.write("author:\n%s\n"%plugin.proc_author)
+                        f.write("date:\n%s\n"%plugin.proc_date)
+                        f.write("cpy:\n%s\n"%plugin.proc_copyright)
+                        f.write("blurb:\n%s\n"%plugin.proc_blurb)
+                        f.write("help:\n%s\n"%plugin.proc_help)
 
         return None
 
         #image types
         None,
         #params
-        [
-        ],
+        [],
         #results
         [],
         #function
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.