Change form_constants.py to constants.py
authorKarl O. Pinc <kop@meme.com>
Sat, 17 Nov 2018 04:43:00 +0000 (22:43 -0600)
committerKarl O. Pinc <kop@meme.com>
Sat, 17 Nov 2018 04:43:00 +0000 (22:43 -0600)
src/pgwui_core/constants.py [new file with mode: 0644]
src/pgwui_core/core.py
src/pgwui_core/form_constants.py [deleted file]

diff --git a/src/pgwui_core/constants.py b/src/pgwui_core/constants.py
new file mode 100644 (file)
index 0000000..69799ad
--- /dev/null
@@ -0,0 +1,36 @@
+# Copyright (C) 2013, 2014, 2018 The Meme Factory, Inc.  http://www.meme.com/
+
+# This file is part of PGWUI_Core.
+#
+# This program is free software: you can redistribute it and/or
+# modify it under the terms of the GNU Affero General Public License
+# as published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with this program.  If not, see
+# <http://www.gnu.org/licenses/>.
+
+# Karl O. Pinc <kop@meme.com>
+#
+
+# Constants used by the GMI pyramid programs.
+
+# The various important containers.
+TEST_DB = 'gombemi_test'
+DEFAULT_SCHEMA = 'gombemi'
+
+CSV = 'csv'
+TAB = 'tab'
+
+# HTML radio button attributes
+# (That these exist is a sign that we're not really utilizing our toolset.)
+CSV_VALUE = CSV
+TAB_VALUE = TAB
+CHECKED = 'checked="checked"'
+UNCHECKED = ''
index 9b5779af81273b708c7a3f86067da56b65e0b687..50e951c6b8b65b55bd992bb7d59fba32b1145f57 100644 (file)
@@ -60,7 +60,7 @@ from wtforms import (
 
 import psycopg2
 
-from pgwui_core import form_constants
+from pgwui_core import constants
 
 
 # Setup default values for forms.
@@ -87,7 +87,7 @@ class UploadFileInitialPost(AuthInitialPost):
     def __init__(self, settings={}):
         super().__init__(settings)
 
-    upload_fmt = form_constants.CSV
+    upload_fmt = constants.CSV
     datafile = ''
     trim_upload = True
 
@@ -136,9 +136,9 @@ class UploadFileWTForm(AuthWTForm):
     # 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:', form_constants.CSV),
+                            choices=[('Upload CSV Data:', constants.CSV),
                                      ('Upload tab delimited Data:',
-                                      form_constants.TAB)])
+                                      constants.TAB)])
     datafile = FileField('File with CSV or Tab delimited Data:')
     trim_upload = BooleanField('Trim Leading/Trailing Spaces:')
 
@@ -396,23 +396,23 @@ class UploadFileForm(AuthLoadedForm):
         '''
         Produces the dict pyramid will use to render the form.
         '''
-        if self['upload_fmt'] == form_constants.CSV:
-            csv_checked = form_constants.CHECKED
-            tab_checked = form_constants.UNCHECKED
+        if self['upload_fmt'] == constants.CSV:
+            csv_checked = constants.CHECKED
+            tab_checked = constants.UNCHECKED
         else:
-            tab_checked = form_constants.CHECKED
-            csv_checked = form_constants.UNCHECKED
+            tab_checked = constants.CHECKED
+            csv_checked = constants.UNCHECKED
 
         if self['trim_upload']:
-            trim_upload_checked = form_constants.CHECKED
+            trim_upload_checked = constants.CHECKED
         else:
-            trim_upload_checked = form_constants.UNCHECKED
+            trim_upload_checked = constants.UNCHECKED
 
         response = super(UploadFileForm, self).write(result, errors)
         response['filename'] = self['filename']
         response['trim_upload'] = trim_upload_checked
-        response['csv_value'] = form_constants.CSV_VALUE
-        response['tab_value'] = form_constants.TAB_VALUE
+        response['csv_value'] = constants.CSV_VALUE
+        response['tab_value'] = constants.TAB_VALUE
         response['csv_checked'] = csv_checked
         response['tab_checked'] = tab_checked
         return response
@@ -486,9 +486,9 @@ class UploadNullFileForm(UploadFileForm):
         Produces the dict pyramid will use to render the form.
         '''
         if self['upload_null']:
-            upload_null_checked = form_constants.CHECKED
+            upload_null_checked = constants.CHECKED
         else:
-            upload_null_checked = form_constants.UNCHECKED
+            upload_null_checked = constants.UNCHECKED
 
         response = super(UploadNullFileForm, self).write(result, errors)
         response['upload_null'] = upload_null_checked
@@ -578,7 +578,7 @@ def textualize(st):
 
 def is_checked(val):
     '''Is the value something a html input entity recognizes as checked?'''
-    return val == form_constants.CHECKED
+    return val == constants.CHECKED
 
 
 # Some functions for logging
@@ -1047,7 +1047,7 @@ class UploadData(DBData):
                     # Give up
                     eol = ''
 
-                if file_fmt == form_constants.CSV:
+                if file_fmt == constants.CSV:
                     def func(st):
                         return next(csv_reader((st,)))
                 else:
@@ -1074,7 +1074,7 @@ class UploadData(DBData):
         self.cols = len(self.headers.tuples)
 
         # Create parser to read raw lines into a list
-        if file_fmt == form_constants.CSV:
+        if file_fmt == constants.CSV:
             self._parser = lambda st: self._extend(st,
                                                    next(csv_reader((st,))))
         else:    # Tab delimited format
diff --git a/src/pgwui_core/form_constants.py b/src/pgwui_core/form_constants.py
deleted file mode 100644 (file)
index 69799ad..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-# Copyright (C) 2013, 2014, 2018 The Meme Factory, Inc.  http://www.meme.com/
-
-# This file is part of PGWUI_Core.
-#
-# This program is free software: you can redistribute it and/or
-# modify it under the terms of the GNU Affero General Public License
-# as published by the Free Software Foundation, either version 3 of
-# the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public
-# License along with this program.  If not, see
-# <http://www.gnu.org/licenses/>.
-
-# Karl O. Pinc <kop@meme.com>
-#
-
-# Constants used by the GMI pyramid programs.
-
-# The various important containers.
-TEST_DB = 'gombemi_test'
-DEFAULT_SCHEMA = 'gombemi'
-
-CSV = 'csv'
-TAB = 'tab'
-
-# HTML radio button attributes
-# (That these exist is a sign that we're not really utilizing our toolset.)
-CSV_VALUE = CSV
-TAB_VALUE = TAB
-CHECKED = 'checked="checked"'
-UNCHECKED = ''