Fix flake8 multiple spaces problems
authorKarl O. Pinc <kop@meme.com>
Sun, 21 Oct 2018 22:17:42 +0000 (17:17 -0500)
committerKarl O. Pinc <kop@meme.com>
Sun, 21 Oct 2018 23:58:53 +0000 (18:58 -0500)
src/pgwui_core/pgwui_core.py

index fd131dce0d8d0d3f93d9fef7dbc2423b892b7b82..1ea832a325b817ba9382793d4ec48edad0ec9471 100644 (file)
@@ -65,26 +65,26 @@ from pgwui_core.form_constants import *
 # Setup default values for forms.
 
 class UserInitialPost():
-    db          = LIVE_DB
-    user        = ''
-    password    = ''
+    db = LIVE_DB
+    user = ''
+    password = ''
 
 class AuthInitialPost():
-    db          = ''
-    user        = ''
-    password    = ''
+    db = ''
+    user = ''
+    password = ''
 
 class UploadFileInitialPost(AuthInitialPost):
-    upload_fmt  = CSV
-    datafile    = ''
+    upload_fmt = CSV
+    datafile = ''
     trim_upload = True
 
 class UploadNullFileInitialPost(UploadFileInitialPost):
     upload_null = True
-    null_rep    = ''
+    null_rep = ''
 
 class UploadTableInitialPost(UploadNullFileInitialPost):
-    table       = ''
+    table = ''
 
 # The wtforms that suck data out of the html.
 
@@ -93,10 +93,10 @@ class UserWTForm(Form):
     # We don't actually use the labels, wanting the template to
     # look (and render) like html, but I'll define them anyway
     # just to keep my hand in.
-    user         = StringField('User:')
-    password     = PasswordField('Password:')
+    user = StringField('User:')
+    password = PasswordField('Password:')
 
-    ivals        = UserInitialPost
+    ivals = UserInitialPost
 
 
 class AuthWTForm(UserWTForm):
@@ -104,9 +104,9 @@ class AuthWTForm(UserWTForm):
     # We don't actually use the labels, wanting the template to
     # look (and render) like html, but I'll define them anyway
     # just to keep my hand in.
-    db           = StringField('Database:')
+    db = StringField('Database:')
 
-    ivals        = AuthInitialPost
+    ivals = AuthInitialPost
 
 
 class UploadFileWTForm(AuthWTForm):
@@ -114,13 +114,13 @@ class UploadFileWTForm(AuthWTForm):
     # We don't actually use the labels, wanting the template to
     # look (and render) like html, but I'll define them anyway
     # just to keep my hand in.
-    upload_fmt   = RadioField('Upload Format:',
-                              choices=[('Upload CSV Data:', CSV),
-                                       ('Upload tab delimited Data:', TAB)])
-    datafile     = FileField('File with CSV or Tab delimited Data:')
-    trim_upload  = BooleanField('Trim Leading/Trailing Spaces:')
+    upload_fmt = RadioField('Upload Format:',
+                            choices=[('Upload CSV Data:', CSV),
+                                     ('Upload tab delimited Data:', TAB)])
+    datafile = FileField('File with CSV or Tab delimited Data:')
+    trim_upload = BooleanField('Trim Leading/Trailing Spaces:')
 
-    ivals        = UploadFileInitialPost
+    ivals = UploadFileInitialPost
 
 
 class UploadNullFileWTForm(UploadFileWTForm):
@@ -128,17 +128,17 @@ class UploadNullFileWTForm(UploadFileWTForm):
     # We don't actually use the labels, wanting the template to
     # look (and render) like html, but I'll define them anyway
     # just to keep my hand in.
-    upload_null  = BooleanField('Upload NULL Values:')
-    null_rep     = StringField('NULL Representation:')
+    upload_null = BooleanField('Upload NULL Values:')
+    null_rep = StringField('NULL Representation:')
 
-    ivals        = UploadNullFileInitialPost
+    ivals = UploadNullFileInitialPost
 
 
 class UploadTableWTForm(UploadNullFileWTForm):
     '''The wtform used for uploading arbitrary data into tables.'''
-    table        = StringField('Table or View:')
+    table = StringField('Table or View:')
 
-    ivals        = UploadTableInitialPost
+    ivals = UploadTableInitialPost
 
 
 class LoadedForm(collections.MutableMapping):
@@ -168,11 +168,20 @@ class LoadedForm(collections.MutableMapping):
         self._store = store
         self._fc = fc
 
-    def __iter__(self):                return next(self._store)
-    def __len__(self):                 return len(self._store)
-    def __getitem__(self, key):        return self._store[key]
-    def __setitem__(self, key, value): self._store[key] = value
-    def __delitem__(self, key):        del self._store[key]
+    def __iter__(self):
+        return next(self._store)
+
+    def __len__(self):
+        return len(self._store)
+
+    def __getitem__(self, key):
+        return self._store[key]
+
+    def __setitem__(self, key, value):
+        self._store[key] = value
+
+    def __delitem__(self, key):
+        del self._store[key]
 
     def read(self):
         '''
@@ -314,7 +323,7 @@ class AuthLoadedForm(CredsLoadedForm):
         super(AuthLoadedForm, self).read()
 
         # Keep form variables handy
-        self['db']               = self._form.db.data
+        self['db'] = self._form.db.data
 
 
     def write(self, result, errors):
@@ -322,7 +331,7 @@ class AuthLoadedForm(CredsLoadedForm):
         Produces the dict pyramid will use to render the form.
         '''
         response = super(AuthLoadedForm, self).write(result, errors)
-        response['db']   = self['db']
+        response['db'] = self['db']
         return response
 
 
@@ -349,8 +358,8 @@ class UploadFileForm(AuthLoadedForm):
         super(UploadFileForm, self).read()
 
         # Read our own data
-        self['upload_fmt']       = self._form.upload_fmt.data
-        self['trim_upload']      = self._form.trim_upload.data
+        self['upload_fmt'] = self._form.upload_fmt.data
+        self['trim_upload'] = self._form.trim_upload.data
 
         # Other POST variables involving a file
         self['filename'] = ''
@@ -359,9 +368,9 @@ class UploadFileForm(AuthLoadedForm):
             if self._form.datafile.data != '':
                 post = self.uh.request.POST
                 if hasattr(post['datafile'], 'filename'):
-                    self['filename']  = post['datafile'].filename
+                    self['filename'] = post['datafile'].filename
                 if hasattr(post['datafile'], 'file'):
-                    self['localfh']   = post['datafile'].file
+                    self['localfh'] = post['datafile'].file
 
 
     def write(self, result, errors):
@@ -381,10 +390,10 @@ class UploadFileForm(AuthLoadedForm):
             trim_upload_checked = UNCHECKED
 
         response = super(UploadFileForm, self).write(result, errors)
-        response['filename']    = self['filename']
+        response['filename'] = self['filename']
         response['trim_upload'] = trim_upload_checked
-        response['csv_value']   = CSV_VALUE
-        response['tab_value']   = TAB_VALUE
+        response['csv_value'] = CSV_VALUE
+        response['tab_value'] = TAB_VALUE
         response['csv_checked'] = csv_checked
         response['tab_checked'] = tab_checked
         return response
@@ -414,16 +423,16 @@ class UploadDoubleFileForm(UploadFileForm):
         # Read our own data
         post = self.uh.request.POST
         if 'last_key' in post:
-            self['last_key']      = post['last_key']
+            self['last_key'] = post['last_key']
         else:
-            self['last_key']      = ''
+            self['last_key'] = ''
 
     def write(self, result, errors):
         '''
         Produces the dict pyramid will use to render the form.
         '''
         response = super(UploadDoubleFileForm, self).write(result, errors)
-        response['last_key']   = self['last_key']
+        response['last_key'] = self['last_key']
         return response
 
 
@@ -450,8 +459,8 @@ class UploadNullFileForm(UploadFileForm):
         super(UploadNullFileForm, self).read()
 
         # Read our own data
-        self['upload_null']      = self._form.upload_null.data
-        self['null_rep']         = self._form.null_rep.data
+        self['upload_null'] = self._form.upload_null.data
+        self['null_rep'] = self._form.null_rep.data
 
 
     def write(self, result, errors):
@@ -464,8 +473,8 @@ class UploadNullFileForm(UploadFileForm):
             upload_null_checked = UNCHECKED
 
         response = super(UploadNullFileForm, self).write(result, errors)
-        response['upload_null']   = upload_null_checked
-        response['null_rep']      = self['null_rep']
+        response['upload_null'] = upload_null_checked
+        response['null_rep'] = self['null_rep']
         return response
 
 
@@ -492,7 +501,7 @@ class UploadTableForm(UploadNullFileForm):
         super(UploadTableForm, self).read()
 
         # Read our own data
-        self['table']      = self._form.table.data
+        self['table'] = self._form.table.data
 
 
     def write(self, result, errors):
@@ -500,7 +509,7 @@ class UploadTableForm(UploadNullFileForm):
         Produces the dict pyramid will use to render the form.
         '''
         response = super(UploadTableForm, self).write(result, errors)
-        response['table']   = self['table']
+        response['table'] = self['table']
         return response
 
 
@@ -528,16 +537,16 @@ class UploadDoubleTableForm(UploadTableForm):
         # Read our own data
         post = self.uh.request.POST
         if 'last_key' in post:
-            self['last_key']      = post['last_key']
+            self['last_key'] = post['last_key']
         else:
-            self['last_key']      = ''
+            self['last_key'] = ''
 
     def write(self, result, errors):
         '''
         Produces the dict pyramid will use to render the form.
         '''
         response = super(UploadDoubleTableForm, self).write(result, errors)
-        response['last_key']   = self['last_key']
+        response['last_key'] = self['last_key']
         return response
 
 
@@ -1179,8 +1188,8 @@ class DBHandler(object):
         request A pyramid request instance
         '''
         super(DBHandler, self).__init__()
-        self.request      = request
-        self.uf  = self.make_form()
+        self.request = request
+        self.uf = self.make_form()
 
     def make_form(self):
         '''
@@ -1589,10 +1598,10 @@ class DBConnector(object):
             try:
                 conn = psycopg2.connect(
                     database = self.db,
-                    user     = self.user,
+                    user = self.user,
                     password = self.password,
-                    host     = registry.settings['pg_host'],
-                    port     = registry.settings['pg_port'])
+                    host = registry.settings['pg_host'],
+                    port = registry.settings['pg_port'])
             except psycopg2.OperationalError:
                 errors = [self.authfailerror_factory()]
                 havecreds = False