PEP8 improvements white space here and there

I search with regexp ",[^\s-]" to spot missing space after comma. I also, add double break line in front of function or class. I change a couple of comparator in order to add space in front and after " == " for instance.
This commit is contained in:
BuhtigithuB
2014-04-24 12:25:34 -04:00
parent accc7bdf38
commit bc1e9b5c98
+14 -1
View File
@@ -45,9 +45,11 @@ except ImportError:
widget_class = re.compile('^\w*') widget_class = re.compile('^\w*')
def add_class(a, b): def add_class(a, b):
return a+' '+b if a else b return a+' '+b if a else b
def represent(field, value, record): def represent(field, value, record):
f = field.represent f = field.represent
if not callable(f): if not callable(f):
@@ -191,9 +193,11 @@ class TimeWidget(StringWidget):
class DateWidget(StringWidget): class DateWidget(StringWidget):
_class = 'date' _class = 'date'
class DatetimeWidget(StringWidget): class DatetimeWidget(StringWidget):
_class = 'datetime' _class = 'datetime'
class TextWidget(FormWidget): class TextWidget(FormWidget):
_class = 'text' _class = 'text'
@@ -209,6 +213,7 @@ class TextWidget(FormWidget):
attr = cls._attributes(field, default, **attributes) attr = cls._attributes(field, default, **attributes)
return TEXTAREA(**attr) return TEXTAREA(**attr)
class JSONWidget(FormWidget): class JSONWidget(FormWidget):
_class = 'json' _class = 'json'
@@ -226,6 +231,7 @@ class JSONWidget(FormWidget):
attr = cls._attributes(field, default, **attributes) attr = cls._attributes(field, default, **attributes)
return TEXTAREA(**attr) return TEXTAREA(**attr)
class BooleanWidget(FormWidget): class BooleanWidget(FormWidget):
_class = 'boolean' _class = 'boolean'
@@ -814,6 +820,7 @@ def formstyle_bootstrap(form, fields):
parent.append(DIV(label, _controls, _class='control-group', _id=id)) parent.append(DIV(label, _controls, _class='control-group', _id=id))
return parent return parent
def formstyle_bootstrap3(form, fields): def formstyle_bootstrap3(form, fields):
""" bootstrap 3 format form layout """ bootstrap 3 format form layout
@@ -1812,7 +1819,6 @@ class SQLFORM(FORM):
return CAT( return CAT(
DIV(_id=panel_id, _style="display:none;", *criteria), fadd) DIV(_id=panel_id, _style="display:none;", *criteria), fadd)
@staticmethod @staticmethod
def grid(query, def grid(query,
fields=None, fields=None,
@@ -2708,6 +2714,7 @@ class SQLFORM(FORM):
constraints = {} constraints = {}
field = None field = None
name = None name = None
def format(table, row): def format(table, row):
if not row: if not row:
return T('Unknown') return T('Unknown')
@@ -3167,6 +3174,7 @@ class ExportClass(object):
def export(self): def export(self):
raise NotImplementedError raise NotImplementedError
class ExporterTSV(ExportClass): class ExporterTSV(ExportClass):
label = 'TSV' label = 'TSV'
file_ext = "csv" file_ext = "csv"
@@ -3203,6 +3211,7 @@ class ExporterTSV(ExportClass):
out.truncate(0) out.truncate(0)
return str(final.getvalue()) return str(final.getvalue())
class ExporterCSV(ExportClass): class ExporterCSV(ExportClass):
#CSV, represent == True #CSV, represent == True
label = 'CSV' label = 'CSV'
@@ -3220,6 +3229,7 @@ class ExporterCSV(ExportClass):
else: else:
return None return None
class ExporterCSV_hidden(ExportClass): class ExporterCSV_hidden(ExportClass):
#pure csv, no represent. #pure csv, no represent.
label = 'CSV' label = 'CSV'
@@ -3235,6 +3245,7 @@ class ExporterCSV_hidden(ExportClass):
else: else:
return '' return ''
class ExporterHTML(ExportClass): class ExporterHTML(ExportClass):
label = 'HTML' label = 'HTML'
file_ext = "html" file_ext = "html"
@@ -3247,6 +3258,7 @@ class ExporterHTML(ExportClass):
xml = self.rows.xml() if self.rows else '' xml = self.rows.xml() if self.rows else ''
return '<html>\n<head>\n<meta http-equiv="content-type" content="text/html; charset=UTF-8" />\n</head>\n<body>\n%s\n</body>\n</html>' % (xml or '') return '<html>\n<head>\n<meta http-equiv="content-type" content="text/html; charset=UTF-8" />\n</head>\n<body>\n%s\n</body>\n</html>' % (xml or '')
class ExporterXML(ExportClass): class ExporterXML(ExportClass):
label = 'XML' label = 'XML'
file_ext = "xml" file_ext = "xml"
@@ -3261,6 +3273,7 @@ class ExporterXML(ExportClass):
else: else:
return '<rows></rows>' return '<rows></rows>'
class ExporterJSON(ExportClass): class ExporterJSON(ExportClass):
label = 'JSON' label = 'JSON'
file_ext = "json" file_ext = "json"