2020__docformat__ = 'restructuredtext'
2121
2222# List of schemes that are not rendered as links in rst and markdown.
23- _disable_url_schemes = [ 'javascript' , 'data' ]
23+ _disable_url_schemes = ['javascript' , 'data' ]
2424
2525import base64 , cgi , re , os .path , mimetypes , csv , string
2626import calendar
@@ -71,7 +71,7 @@ class Markdown(markdown2.Markdown):
7171 _safe_protocols = re .compile ('(?!' + ':|' .join ([re .escape (s ) for s in _disable_url_schemes ]) + ':)' , re .IGNORECASE )
7272
7373 def _extras (config ):
74- extras = { 'fenced-code-blocks' : {}, 'nofollow' : None }
74+ extras = {'fenced-code-blocks' : {}, 'nofollow' : None }
7575 if config ['MARKDOWN_BREAK_ON_NEWLINE' ]:
7676 extras ['break-on-newline' ] = True
7777 return extras
@@ -149,7 +149,7 @@ def _import_mistune():
149149 import mistune
150150 from mistune import Renderer , escape_link , escape
151151
152- mistune ._scheme_blacklist = [ s + ':' for s in _disable_url_schemes ]
152+ mistune ._scheme_blacklist = [s + ':' for s in _disable_url_schemes ]
153153
154154 class LinkRendererWithRel (Renderer ):
155155 ''' Rendering class that sets the rel="nofollow noreferer"
@@ -162,7 +162,8 @@ def autolink(self, link, is_email=False):
162162 text = link = escape_link (link )
163163 if is_email :
164164 link = 'mailto:%s' % link
165- return '<a href="%(href)s">%(text)s</a>' % { 'href' : link , 'text' : text }
165+ return '<a href="%(href)s">%(text)s</a>' % {
166+ 'href' : link , 'text' : text }
166167 return '<a href="%(href)s" rel="%(rel)s">%(href)s</a>' % {
167168 'rel' : self .rel_value , 'href' : escape_link (link )}
168169
@@ -217,7 +218,7 @@ def anti_csrf_nonce(client, lifetime=None):
217218 ts = otks .lifetime (lifetime * 60 )
218219 otks .set (key , uid = client .db .getuid (),
219220 sid = client .session_api ._sid ,
220- __timestamp = ts )
221+ __timestamp = ts )
221222 otks .commit ()
222223 return key
223224
@@ -886,7 +887,7 @@ def classhelp(self, properties=None, label=''"(list)", width='500',
886887 properties = sorted (self ._klass .getprops (protected = 0 ).keys ())
887888 properties = ',' .join (properties )
888889 if sort is None :
889- if 'username' in properties .split ( ',' ):
890+ if 'username' in properties .split (',' ):
890891 sort = 'username'
891892 else :
892893 sort = self ._klass .orderprop ()
@@ -1106,7 +1107,7 @@ def journal(self, direction='descending'):
11061107 return []
11071108
11081109 def history (self , direction = 'descending' , dre = re .compile (r'^\d+$' ),
1109- limit = None , showall = False ):
1110+ limit = None , showall = False ):
11101111 """Create an html view of the journal for the item.
11111112
11121113 Display property changes for all properties that does not have quiet set.
@@ -1331,7 +1332,7 @@ def history(self, direction='descending', dre=re.compile(r'^\d+$'),
13311332
13321333 arg_s = '<br />' .join (cell )
13331334 else :
1334- if action in ( 'retired' , 'restored' ):
1335+ if action in ('retired' , 'restored' ):
13351336 # args = None for these actions
13361337 pass
13371338 else :
@@ -1607,7 +1608,7 @@ class StringHTMLProperty(HTMLProperty):
16071608 'raw_enabled' : 0 ,
16081609 '_disable_config' : 1 }
16091610
1610- valid_schemes = { }
1611+ valid_schemes = {}
16111612
16121613 def _hyper_repl (self , match ):
16131614 if match .group ('url' ):
@@ -2066,12 +2067,12 @@ def field(self, labelfirst=False, y_label=None, n_label=None,
20662067 value = value .strip ().lower () in ('checked' , 'yes' , 'true' ,
20672068 'on' , '1' )
20682069
2069- if ( not y_label ):
2070+ if (not y_label ):
20702071 y_label = '<label class="rblabel" for="%s_%s">' % (self ._formname , 'yes' )
20712072 y_label += self ._ ('Yes' )
20722073 y_label += '</label>'
20732074
2074- if ( not n_label ):
2075+ if (not n_label ):
20752076 n_label = '<label class="rblabel" for="%s_%s">' % (self ._formname , 'no' )
20762077 n_label += self ._ ('No' )
20772078 n_label += '</label>'
@@ -2090,7 +2091,7 @@ def field(self, labelfirst=False, y_label=None, n_label=None,
20902091 n_rb = self .input (type = "radio" , name = self ._formname , value = "no" ,
20912092 checked = "checked" , id = "%s_%s" % (self ._formname , 'no' ), ** kwargs )
20922093
2093- if ( u_label ):
2094+ if (u_label ):
20942095 if (u_label is True ): # it was set via u_label=True
20952096 u_label = '' # make it empty but a string not boolean
20962097 u_rb = self .input (type = "radio" , name = self ._formname , value = "" ,
@@ -2100,7 +2101,7 @@ def field(self, labelfirst=False, y_label=None, n_label=None,
21002101 u_label = ''
21012102 u_rb = ''
21022103
2103- if ( labelfirst ):
2104+ if (labelfirst ):
21042105 s = u_label + u_rb + y_label + y_rb + n_label + n_rb
21052106 else :
21062107 s = u_label + u_rb + y_rb + y_label + n_rb + n_label
@@ -2540,7 +2541,7 @@ def menu(self, size=None, height=None, showid=0, additional=[], value=None,
25402541
25412542 if value in [optionid , option ]:
25422543 s = 'selected="selected" '
2543- if ( showdef ):
2544+ if (showdef ):
25442545 selected_mark = showdef
25452546
25462547 # figure the label
@@ -3237,7 +3238,7 @@ def indexargs_url(self, url, args):
32373238 q = urllib_ .quote
32383239 sc = self .special_char
32393240 l = ['%s=%s' % (k ,is_us (v ) and q (v ) or v )
3240- for k ,v in args .items () if v != None ]
3241+ for k ,v in args .items () if v != None ]
32413242 # pull out the special values (prefixed by @ or :)
32423243 specials = {}
32433244 for key in args .keys ():
0 commit comments