[Hejes-devel] [857] updated dbekwiki tool

hejes-devel at nytud.hu hejes-devel at nytud.hu
Fri Jul 19 15:35:23 CEST 2013


Revision: 857
Author:   mihaltz
Date:     2013-07-19 15:35:23 +0200 (Fri, 19 Jul 2013)
Log Message:
-----------
updated dbekwiki tool

Modified Paths:
--------------
    trunk/misc/dbekwiki/create_grmrule_pages.py

Added Paths:
-----------
    trunk/misc/dbekwiki/databases

Modified: trunk/misc/dbekwiki/create_grmrule_pages.py
===================================================================
--- trunk/misc/dbekwiki/create_grmrule_pages.py	2013-07-19 11:53:44 UTC (rev 856)
+++ trunk/misc/dbekwiki/create_grmrule_pages.py	2013-07-19 13:35:23 UTC (rev 857)
@@ -6,6 +6,7 @@
 """
 
 import sys
+import datetime
 
 sys.path.append('/opt/web2py')
 from gluon import *
@@ -39,20 +40,27 @@
 
 # Generate pages
 #TODO: add rulestr
+tstamp = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
+cnt = 0
 for rule in rules:
-  print(rule.id)
+  #print(rule.id)
+  slug = rule.id.replace(':','-')
   rkey = ' + '.join([x[0] for x in rule.lhs])
   rstr = str(rule).replace("'", "''")
+  rcomm = rule.comment.replace("'", "''")
   # all columns: (id, rulestr, rulekey, slug, title, body, tags, can_read, can_edit, changelog, html, is_active, created_on, created_by, modified_on, modified_by)
   sql = '''INSERT OR IGNORE INTO wiki_page 
-    (slug, title, body, tags, can_read, can_edit, html, is_active, created_on, created_by, rulekey, rulestr)
-    VALUES ('{0}', '#Rule# {1}', '#Rule {1}\n\nTODO', '||', '|everybody|', '|everybody|', '<h1>Rule {1}</h1><p>TODO</p>', 'T', '{2}', 1, '{3}', '{4}');
-    '''.format(rule.id.replace(':','-'), rule.id, '2013-07-18 16:46:00', rkey, rstr)
+    (slug, title, body, tags, can_read, can_edit, html, is_active, created_on, created_by, modified_on, rulekey, rulestr)
+    VALUES ('{0}', '#Rule# {1}', '{5}\n\nTODO', '||', '|everybody|', '|everybody|', '<p>{5}</p>\n<p>TODO</p>', 'T', '{2}', 1, '{2}', '{3}', '{4}');
+    '''.format(slug, rule.id, tstamp, rkey, rstr, rcomm)
     #escape_string(rstr).replace('{', '\\{').replace('}', '\\}'))
   #print(sql)
   r = db.executesql(sql)
   if r != []:
     print(r)
+  else:
+    cnt += 1
 
 # commit
 db.commit()
+sys.stderr.write('{0} record(s) inserted\n'.format(cnt))

Added: trunk/misc/dbekwiki/databases
===================================================================
--- trunk/misc/dbekwiki/databases	                        (rev 0)
+++ trunk/misc/dbekwiki/databases	2013-07-19 13:35:23 UTC (rev 857)
@@ -0,0 +1 @@
+link ../../web2py/applications/ekwiki/databases/
\ No newline at end of file


Property changes on: trunk/misc/dbekwiki/databases
___________________________________________________________________
Added: svn:special
   + *




More information about the Hejes-devel mailing list