[Zope-Checkins] SVN: Zope/branches/tseaver-no_globals_imports/lib/python/TreeDisplay/TreeTag.py Import / PEP8 cleanup.

Tres Seaver tseaver at palladion.com
Sat Dec 27 00:28:15 EST 2008


Log message for revision 94374:
  Import / PEP8 cleanup.

Changed:
  U   Zope/branches/tseaver-no_globals_imports/lib/python/TreeDisplay/TreeTag.py

-=-
Modified: Zope/branches/tseaver-no_globals_imports/lib/python/TreeDisplay/TreeTag.py
===================================================================
--- Zope/branches/tseaver-no_globals_imports/lib/python/TreeDisplay/TreeTag.py	2008-12-27 05:05:03 UTC (rev 94373)
+++ Zope/branches/tseaver-no_globals_imports/lib/python/TreeDisplay/TreeTag.py	2008-12-27 05:28:15 UTC (rev 94374)
@@ -15,20 +15,31 @@
 __rcs_id__='$Id$'
 __version__='$Revision: 1.58 $'[11:-2]
 
-from DocumentTemplate.DT_Util import *
-from DocumentTemplate.DT_String import String
-
+from binascii import a2b_base64
+from binascii import b2a_base64
 from cPickle import dumps
+import re
 from string import translate
-from urllib import quote, unquote
-from zlib import compress, decompressobj
-from binascii import b2a_base64, a2b_base64
-import re
+from urllib import quote
+from urllib import unquote
+from zlib import compress
+from zlib import decompressobj
 
-tbl=''.join(map(chr, range(256)))
-tplus=tbl[:ord('+')]+'-'+tbl[ord('+')+1:]
-tminus=tbl[:ord('-')]+'+'+tbl[ord('-')+1:]
+#from DocumentTemplate.DT_Util import *
+from DocumentTemplate.DT_Util import add_with_prefix
+from DocumentTemplate.DT_Util import Eval
+from DocumentTemplate.DT_Util import InstanceDict
+from DocumentTemplate.DT_Util import name_param
+from DocumentTemplate.DT_Util import parse_params
+from DocumentTemplate.DT_Util import ParseError
+from DocumentTemplate.DT_Util import render_blocks
+from DocumentTemplate.DT_Util import simple_name
+from DocumentTemplate.DT_String import String
 
+tbl = ''.join(map(chr, range(256)))
+tplus = tbl[:ord('+')]+'-'+tbl[ord('+')+1:]
+tminus = tbl[:ord('-')]+'+'+tbl[ord('-')+1:]
+
 class Tree:
     name='tree'
     blockContinuations=()
@@ -36,35 +47,51 @@
 
     def __init__(self, blocks):
         tname, args, section = blocks[0]
-        args=parse_params(args, name=None, expr=None, nowrap=1,
-                          expand=None, leaves=None,
-                          header=None, footer=None,
-                          branches=None, branches_expr=None,
-                          sort=None, reverse=1, skip_unauthorized=1,
-                          id=None, single=1, url=None,
+        args = parse_params(args,
+                            name=None,
+                            expr=None,
+                            nowrap=1,
+                            expand=None,
+                            leaves=None,
+                            header=None,
+                            footer=None,
+                            branches=None,
+                            branches_expr=None,
+                            sort=None,
+                            reverse=1,
+                            skip_unauthorized=1,
+                            id=None,
+                            single=1,
+                            url=None,
                           # opened_decoration=None,
                           # closed_decoration=None,
                           # childless_decoration=None,
-                          assume_children=1,
-                          urlparam=None, prefix=None)
-        has_key=args.has_key
+                            assume_children=1,
+                            urlparam=None, prefix=None)
+        has_key = args.has_key
 
         if has_key('') or has_key('name') or has_key('expr'):
-            name,expr=name_param(args,'tree',1)
+            name, expr = name_param(args,'tree',1)
 
-            if expr is not None: args['expr']=expr
-            elif has_key(''): args['name']=name
-        else: name='a tree tag'
+            if expr is not None:
+                args['expr'] = expr
+            elif has_key(''):
+                args['name'] = name
+        else:
+            name='a tree tag'
 
         if has_key('branches_expr'):
             if has_key('branches'):
                 raise ParseError, _tm(
                     'branches and  and branches_expr given', 'tree')
-            args['branches_expr']=Eval(args['branches_expr']).eval
-        elif not has_key('branches'): args['branches']='tpValues'
+            args['branches_expr'] = Eval(args['branches_expr']).eval
+        elif not has_key('branches'):
+            args['branches']='tpValues'
 
-        if not has_key('id'): args['id']='tpId'
-        if not has_key('url'): args['url']='tpURL'
+        if not has_key('id'):
+            args['id'] = 'tpId'
+        if not has_key('url'):
+            args['url'] = 'tpURL'
         if not has_key('childless_decoration'):
             args['childless_decoration']=''
 
@@ -74,20 +101,23 @@
                 'prefix is not a simple name', 'tree')
 
         self.__name__ = name
-        self.section=section.blocks
-        self.args=args
+        self.section = section.blocks
+        self.args = args
 
 
-    def render(self,md):
-        args=self.args
-        have=args.has_key
+    def render(self, md):
+        args = self.args
+        have = args.has_key
 
-        if have('name'): v=md[args['name']]
-        elif have('expr'): v=args['expr'].eval(md)
-        else: v=md.this
-        return tpRender(v,md,self.section, self.args)
+        if have('name'):
+            v = md[args['name']]
+        elif have('expr'):
+            v = args['expr'].eval(md)
+        else:
+            v = md.this
+        return tpRender(v, md, self.section, self.args)
 
-    __call__=render
+    __call__ = render
 
 String.commands['tree']=Tree
 
@@ -374,7 +404,8 @@
         dataspan=colspan-level
         output('<td%s%s valign="top" align="left">' %
                ((dataspan > 1 and (' colspan="%s"' % dataspan) or ''),
-               (have_arg('nowrap') and args['nowrap'] and ' style="white-space: nowrap"' or ''))
+               (have_arg('nowrap') and
+                args['nowrap'] and ' style="white-space: nowrap"' or ''))
                )
         output(render_blocks(section, md))
         output('</td>\n</tr>\n')
@@ -396,7 +427,8 @@
                 output(doc(
                     None, md,
                     standard_html_header=(
-                        '<tr>%s<td width="16" style="white-space: nowrap"></td>'
+                        '<tr>%s'
+                        '<td width="16" style="white-space: nowrap"></td>'
                         '<td%s valign="top">'
                         % (h,
                            (dataspan > 1 and (' colspan="%s"' % dataspan)
@@ -417,7 +449,8 @@
                     try: output(doc(
                         None,md,
                         standard_html_header=(
-                            '<tr>%s<td width="16" style="white-space: nowrap"></td>'
+                            '<tr>%s'
+                            '<td width="16" style="white-space: nowrap"></td>'
                             '<td%s valign="top">'
                             % (h,
                                (dataspan > 1 and
@@ -697,7 +730,8 @@
     except pickle.UnpicklingError, e:
         if e[0]!='Refused': raise ValueError(x)
 
-class _junk_class: pass
+class _junk_class:
+    pass
 
 def _test():
     _should_succeed('hello')



More information about the Zope-Checkins mailing list