Skip to content

Commit 2f70382

Browse files
committed
flake8 whitespace/formatting changes.
1 parent d8a8810 commit 2f70382

File tree

1 file changed

+36
-31
lines changed

1 file changed

+36
-31
lines changed

roundup/cgi/form_parser.py

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from roundup.cgi import templating
55
from roundup.cgi.exceptions import FormError
66

7+
78
class FormParser:
89
# edit form variable handling (see unit tests)
910
FV_LABELS = r'''
@@ -201,8 +202,8 @@ def parse(self, create=0, num_re=re.compile(r'^\d+$')):
201202
classes = '|'.join(db.classes.keys())
202203
# specials for parsePropsFromForm
203204
# handle the various forms (see unit tests)
204-
self.FV_SPECIAL = re.compile(self.FV_LABELS%classes, re.VERBOSE)
205-
self.FV_DESIGNATOR = re.compile(r'(%s)([-\d]+)'%classes)
205+
self.FV_SPECIAL = re.compile(self.FV_LABELS % classes, re.VERBOSE)
206+
self.FV_DESIGNATOR = re.compile(r'(%s)([-\d]+)' % classes)
206207

207208
# these indicate the default class / item
208209
default_cn = self.classname
@@ -247,7 +248,7 @@ def parse(self, create=0, num_re=re.compile(r'^\d+$')):
247248
nodeid = '-1'
248249
propname = 'content'
249250
all_links.append((default_cn, default_nodeid, 'messages',
250-
[('msg', '-1')]))
251+
[('msg', '-1')]))
251252
have_note = 1
252253
elif d['file']:
253254
# the special file field
@@ -286,7 +287,7 @@ def parse(self, create=0, num_re=re.compile(r'^\d+$')):
286287
for entry in self.extractFormList(form[key]):
287288
m = self.FV_DESIGNATOR.match(entry)
288289
if not m:
289-
raise FormError (self._('link "%(key)s" '
290+
raise FormError(self._('link "%(key)s" '
290291
'value "%(entry)s" not a designator') % locals())
291292
value.append((m.group(1), m.group(2)))
292293

@@ -304,9 +305,9 @@ def parse(self, create=0, num_re=re.compile(r'^\d+$')):
304305
# make sure the link property is valid
305306
if (not isinstance(propdef[propname], hyperdb.Multilink) and
306307
not isinstance(propdef[propname], hyperdb.Link)):
307-
raise FormError (self._('%(class)s %(property)s '
308-
'is not a link or multilink property') % {
309-
'class':cn, 'property':propname})
308+
raise FormError(self._('%(class)s %(property)s '
309+
'is not a link or multilink property') % {
310+
'class':cn, 'property':propname})
310311

311312
all_links.append((cn, nodeid, propname, value))
312313
continue
@@ -316,7 +317,7 @@ def parse(self, create=0, num_re=re.compile(r'^\d+$')):
316317
for entry in self.extractFormList(form[key]):
317318
m = self.FV_SPECIAL.match(entry)
318319
if not m:
319-
raise FormError (self._('The form action claims to '
320+
raise FormError(self._('The form action claims to '
320321
'require property "%(property)s" '
321322
'which doesn\'t exist') % {
322323
'property':propname})
@@ -338,10 +339,10 @@ def parse(self, create=0, num_re=re.compile(r'^\d+$')):
338339
# does the property exist?
339340
if propname not in propdef:
340341
if mlaction != 'set':
341-
raise FormError (self._('You have submitted a %(action)s '
342+
raise FormError(self._('You have submitted a %(action)s '
342343
'action for the property "%(property)s" '
343344
'which doesn\'t exist') % {
344-
'action': mlaction, 'property':propname})
345+
'action': mlaction, 'property': propname})
345346
# the form element is probably just something we don't care
346347
# about - ignore it
347348
continue
@@ -363,7 +364,7 @@ def parse(self, create=0, num_re=re.compile(r'^\d+$')):
363364
else:
364365
# multiple values are not OK
365366
if isinstance(value, type([])):
366-
raise FormError (self._('You have submitted more than one '
367+
raise FormError(self._('You have submitted more than one '
367368
'value for the %s property') % propname)
368369
# value might be a single file upload
369370
if not getattr(value, 'filename', None):
@@ -388,19 +389,19 @@ def parse(self, create=0, num_re=re.compile(r'^\d+$')):
388389
confirm = form[key]
389390
break
390391
else:
391-
raise FormError (self._('Password and confirmation text '
392-
'do not match'))
392+
raise FormError(self._('Password and confirmation text '
393+
'do not match'))
393394
if isinstance(confirm, type([])):
394-
raise FormError (self._('You have submitted more than one '
395+
raise FormError(self._('You have submitted more than one '
395396
'value for the %s property') % propname)
396397
if value != confirm.value:
397-
raise FormError (self._('Password and confirmation text '
398-
'do not match'))
398+
raise FormError(self._('Password and confirmation text '
399+
'do not match'))
399400
try:
400-
value = password.Password(value, scheme = proptype.scheme,
401+
value = password.Password(value, scheme=proptype.scheme,
401402
config=self.db.config)
402403
except hyperdb.HyperdbValueError as msg:
403-
raise FormError (msg)
404+
raise FormError(msg)
404405
elif d['file']:
405406
# This needs to be a Multilink and is checked above
406407
fcn = 'file'
@@ -412,17 +413,18 @@ def parse(self, create=0, num_re=re.compile(r'^\d+$')):
412413
have_file = []
413414
for n, v in enumerate(value):
414415
if not hasattr(v, 'filename'):
415-
raise FormError (self._('Not a file attachment'))
416+
raise FormError(self._('Not a file attachment'))
416417
# skip if the upload is empty
417418
if not v.filename:
418419
continue
419-
fnodeid = str (-(n+1))
420+
fnodeid = str(-(n+1))
420421
have_file.append(fnodeid)
421422
fthis = (fcn, fnodeid)
422423
if fthis not in all_props:
423424
all_props[fthis] = {}
424425
fprops = all_props[fthis]
425-
all_links.append((cn, nodeid, 'files', [('file', fnodeid)]))
426+
all_links.append((cn, nodeid, 'files',
427+
[('file', fnodeid)]))
426428

427429
fprops['content'] = self.parse_file(fpropdef, fprops, v)
428430
value = None
@@ -431,9 +433,9 @@ def parse(self, create=0, num_re=re.compile(r'^\d+$')):
431433
# convert input to list of ids
432434
try:
433435
l = hyperdb.rawToHyperdb(self.db, cl, nodeid,
434-
propname, value)
436+
propname, value)
435437
except hyperdb.HyperdbValueError as msg:
436-
raise FormError (msg)
438+
raise FormError(msg)
437439

438440
# now use that list of ids to modify the multilink
439441
if mlaction == 'set':
@@ -455,7 +457,7 @@ def parse(self, create=0, num_re=re.compile(r'^\d+$')):
455457
try:
456458
existing.remove(entry)
457459
except ValueError:
458-
raise FormError (self._('property '
460+
raise FormError(self._('property '
459461
'"%(propname)s": "%(value)s" '
460462
'not currently in list') % {
461463
'propname': propname, 'value': entry})
@@ -482,9 +484,9 @@ def parse(self, create=0, num_re=re.compile(r'^\d+$')):
482484
value = self.parse_file(propdef, props, value)
483485
else:
484486
value = hyperdb.rawToHyperdb(self.db, cl, nodeid,
485-
propname, value)
487+
propname, value)
486488
except hyperdb.HyperdbValueError as msg:
487-
raise FormError (msg)
489+
raise FormError(msg)
488490

489491
# register that we got this property
490492
if isinstance(proptype, hyperdb.Multilink):
@@ -516,10 +518,12 @@ def parse(self, create=0, num_re=re.compile(r'^\d+$')):
516518
# "missing" existing values may not be None
517519
if not existing:
518520
if isinstance(proptype, hyperdb.String):
519-
# some backends store "missing" Strings as empty strings
521+
# some backends store "missing" Strings as
522+
# empty strings
520523
if existing == self.db.BACKEND_MISSING_STRING:
521524
existing = None
522-
elif isinstance(proptype, hyperdb.Number) or isinstance(proptype, hyperdb.Integer):
525+
elif isinstance(proptype, hyperdb.Number) or \
526+
isinstance(proptype, hyperdb.Integer):
523527
# some backends store "missing" Numbers as 0 :(
524528
if existing == self.db.BACKEND_MISSING_NUMBER:
525529
existing = None
@@ -583,7 +587,7 @@ def parse(self, create=0, num_re=re.compile(r'^\d+$')):
583587
'property': ', '.join(map(self.gettext, required))
584588
})
585589
if s:
586-
raise FormError ('\n'.join(s))
590+
raise FormError('\n'.join(s))
587591

588592
# When creating a FileClass node, it should have a non-empty content
589593
# property to be created. When editing a FileClass node, it should
@@ -610,7 +614,7 @@ def parse(self, create=0, num_re=re.compile(r'^\d+$')):
610614
not props['content']:
611615
# This is an existing file with emtpy content
612616
# value in the form.
613-
del props ['content']
617+
del props['content']
614618
else:
615619
# this is a new file without any content property.
616620
if id is not None and id.startswith('-'):
@@ -639,7 +643,8 @@ def extractFormList(self, value):
639643
''' Extract a list of values from the form value.
640644
641645
It may be one of:
642-
[MiniFieldStorage('value'), MiniFieldStorage('value','value',...), ...]
646+
[MiniFieldStorage('value'),
647+
MiniFieldStorage('value','value',...), ...]
643648
MiniFieldStorage('value,value,...')
644649
MiniFieldStorage('value')
645650
'''

0 commit comments

Comments
 (0)