changeset 31:084ee90bd176

chartypes_create: do not execute the main code if the module is just imported
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 28 Feb 2011 01:38:45 +0100
parents 32b471240a8a
children 15f746a76acd
files MoinMoin/util/chartypes_create.py
diffstat 1 files changed, 25 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/util/chartypes_create.py	Mon Feb 28 01:32:51 2011 +0100
+++ b/MoinMoin/util/chartypes_create.py	Mon Feb 28 01:38:45 2011 +0100
@@ -7,28 +7,29 @@
 """
 
 
-uppercase = []
-lowercase = []
-digits = []
-space = []
-for code in range(1, 65535):
-    c = unichr(code)
-    str = "\\u%04x" % code
-    if c.isupper():
-        uppercase.append(str)
-    elif c.islower():
-        lowercase.append(str)
-    elif c.isdigit():
-        digits.append(str)
-    elif c.isspace():
-        space.append(str)
+def main():
+    uppercase = []
+    lowercase = []
+    digits = []
+    space = []
+    for code in range(1, 65535):
+        c = unichr(code)
+        str = "\\u%04x" % code
+        if c.isupper():
+            uppercase.append(str)
+        elif c.islower():
+            lowercase.append(str)
+        elif c.isdigit():
+            digits.append(str)
+        elif c.isspace():
+            space.append(str)
 
-chars_upper = u''.join(uppercase)
-chars_lower = u''.join(lowercase+digits)
-chars_digits = u''.join(digits)
-chars_spaces = u''.join(space)
+    chars_upper = u''.join(uppercase)
+    chars_lower = u''.join(lowercase+digits)
+    chars_digits = u''.join(digits)
+    chars_spaces = u''.join(space)
 
-print """
+    print """
 chars_upper = u"%(chars_upper)s"
 
 chars_lower = u"%(chars_lower)s"
@@ -38,5 +39,8 @@
 chars_spaces = u"%(chars_spaces)s"
 
 
-""" % globals()
+""" % locals()
 
+if __name__ == '__main__':
+    main()
+