comparison roundup/cgi/templating.py @ 7022:f4bfc1af5d95

flake8 inline comment spacing; too many leading # E261 at least two spaces before inline comment E266 too many leading '#' for block comment
author John Rouillard <rouilj@ieee.org>
date Sun, 09 Oct 2022 17:34:42 -0400
parents 4e25815961a7
children ae6fa7b32e2d
comparison
equal deleted inserted replaced
7021:4e25815961a7 7022:f4bfc1af5d95
46 except ImportError: 46 except ImportError:
47 import pickle 47 import pickle
48 try: 48 try:
49 from StructuredText.StructuredText import HTML as StructuredText 49 from StructuredText.StructuredText import HTML as StructuredText
50 except ImportError: 50 except ImportError:
51 try: # older version 51 try: # older version
52 import StructuredText 52 import StructuredText
53 except ImportError: 53 except ImportError:
54 StructuredText = None 54 StructuredText = None
55 try: 55 try:
56 from docutils.core import publish_parts as ReStructuredText 56 from docutils.core import publish_parts as ReStructuredText
226 sid=client.session_api._sid, 226 sid=client.session_api._sid,
227 __timestamp=ts) 227 __timestamp=ts)
228 otks.commit() 228 otks.commit()
229 return key 229 return key
230 230
231 ### templating 231 # templating
232 232
233 233
234 class NoTemplate(RoundupException): 234 class NoTemplate(RoundupException):
235 pass 235 pass
236 236
293 for extension in ['', '.html', '.xml']: 293 for extension in ['', '.html', '.xml']:
294 f = name + extension 294 f = name + extension
295 src = os.path.join(realsrc, f) 295 src = os.path.join(realsrc, f)
296 realpath = os.path.realpath(src) 296 realpath = os.path.realpath(src)
297 if not realpath.startswith(realsrc): 297 if not realpath.startswith(realsrc):
298 return # will raise invalid template 298 return # will raise invalid template
299 if os.path.exists(src): 299 if os.path.exists(src):
300 return (src, f) 300 return (src, f)
301 301
302 def check(self, name): 302 def check(self, name):
303 return bool(self._find(name)) 303 return bool(self._find(name))
1741 if start >= 0: 1741 if start >= 0:
1742 prefix = match.string[start] 1742 prefix = match.string[start]
1743 if end < len(match.string): 1743 if end < len(match.string):
1744 suffix = match.string[end] 1744 suffix = match.string[end]
1745 if (prefix, suffix) in {('[', ']')}: 1745 if (prefix, suffix) in {('[', ']')}:
1746 if match.string[end+1] == '(': # find following ( 1746 if match.string[end+1] == '(': # find following (
1747 return match.group(0) 1747 return match.group(0)
1748 if (prefix, suffix) in {('(',')')}: 1748 if (prefix, suffix) in {('(',')')}:
1749 if match.string[start-1] == ']': 1749 if match.string[start-1] == ']':
1750 return match.group(0) 1750 return match.group(0)
1751 return self._hyper_repl_item(match,'[%(item)s](%(cls)s%(id)s)') 1751 return self._hyper_repl_item(match,'[%(item)s](%(cls)s%(id)s)')
2128 2128
2129 n_rb = self.input(type="radio", name=self._formname, value="no", 2129 n_rb = self.input(type="radio", name=self._formname, value="no",
2130 checked="checked", id="%s_%s"%(self._formname, 'no'), **kwargs) 2130 checked="checked", id="%s_%s"%(self._formname, 'no'), **kwargs)
2131 2131
2132 if (u_label): 2132 if (u_label):
2133 if (u_label is True): # it was set via u_label=True 2133 if (u_label is True): # it was set via u_label=True
2134 u_label = '' # make it empty but a string not boolean 2134 u_label = '' # make it empty but a string not boolean
2135 u_rb = self.input(type="radio", name=self._formname, value="", 2135 u_rb = self.input(type="radio", name=self._formname, value="",
2136 id="%s_%s"%(self._formname, 'unk'), **kwargs) 2136 id="%s_%s"%(self._formname, 'unk'), **kwargs)
2137 else: 2137 else:
2138 # don't generate a trivalue radiobutton. 2138 # don't generate a trivalue radiobutton.
2139 u_label = '' 2139 u_label = ''
2709 if sort_by_link: 2709 if sort_by_link:
2710 val = prop[orderprop]._value 2710 val = prop[orderprop]._value
2711 else: 2711 else:
2712 val = prop._value 2712 val = prop._value
2713 2713
2714 if val is None: # verify orderprop is set to a value 2714 if val is None: # verify orderprop is set to a value
2715 return (NoneCode, None) 2715 return (NoneCode, None)
2716 return (1, val) # val should be base python type 2716 return (1, val) # val should be base python type
2717 2717
2718 value.sort(key=keyfunc, reverse=reverse) 2718 value.sort(key=keyfunc, reverse=reverse)
2719 return value 2719 return value
3033 dirkey = key + 'dir' 3033 dirkey = key + 'dir'
3034 if self._form_has_key(key) and not fields: 3034 if self._form_has_key(key) and not fields:
3035 fields = handleListCGIValue(self.form[key]) 3035 fields = handleListCGIValue(self.form[key])
3036 if dirkey in self.form: 3036 if dirkey in self.form:
3037 dirs.append(self.form.getfirst(dirkey)) 3037 dirs.append(self.form.getfirst(dirkey))
3038 if fields: # only try other special char if nothing found 3038 if fields: # only try other special char if nothing found
3039 break 3039 break
3040 3040
3041 # sometimes requests come in without a class 3041 # sometimes requests come in without a class
3042 # chances are they won't have any filter params, 3042 # chances are they won't have any filter params,
3043 # in that case anyway but... 3043 # in that case anyway but...
3553 try: 3553 try:
3554 # date_str and display can be set to an invalid value 3554 # date_str and display can be set to an invalid value
3555 # if user submits a value like "d4" and gets an edit error. 3555 # if user submits a value like "d4" and gets an edit error.
3556 # If either or both invalid just ignore that we can't parse it 3556 # If either or both invalid just ignore that we can't parse it
3557 # and assign them to today. 3557 # and assign them to today.
3558 curr_date = date.Date(date_str) # to highlight 3558 curr_date = date.Date(date_str) # to highlight
3559 display = date.Date(display) # to show 3559 display = date.Date(display) # to show
3560 except ValueError: 3560 except ValueError:
3561 # we couldn't parse the date 3561 # we couldn't parse the date
3562 # just let the calendar display 3562 # just let the calendar display
3563 curr_date = current_date 3563 curr_date = current_date
3564 display = current_date 3564 display = current_date

Roundup Issue Tracker: http://roundup-tracker.org/