mapper(st) Maps st onto desired python representation
(Used for trimming whitespace)
'''
- super(UploadLine, self).__init__()
+ super().__init__()
self.raw = line
self.tuples = [mapper(st) for st in stol(line)]
'No column headings found on first line',
'The first line is ({0})'.format(line))
- super(UploadHeaders, self).__init__(line, stol, mapper)
+ super().__init__(line, stol, mapper)
self.sql = ', '.join(['"' + doublequote(st) + '"'
for st in self.tuples])
lineno The line number
'''
def __init__(self, line, lineno, stol, mapper):
- super(UploadDataLine, self).__init__(line, stol, mapper)
+ super().__init__(line, stol, mapper)
self.lineno = lineno
'''
stmts List of SQLCommand instances
'''
- super(SQLData, self).__init__()
+ super().__init__()
self.stmts = stmts
def _thunk(self):
return st.split('\t')
return (eol, UploadHeaders(line, func, do_trim))
- super(UploadData, self).__init__()
+ super().__init__()
if trim:
def do_trim(st):
ue UploadEngine instance
uh UploadHandler instance
'''
- super(DataLineProcessor, self).__init__()
+ super().__init__()
self.ue = ue
self.uh = uh
self.cur = ue.cur
uh UploadHandler instance
cur psycopg3 cursor
'''
- super(NoOpProcessor, self).__init__(ue, uh)
+ super().__init__(ue, uh)
def eat(self, udl):
'''
uh UploadHandler instance
cur psycopg3 cursor
'''
- super(ExecuteSQL, self).__init__(ue, uh)
+ super().__init__(ue, uh)
def eat(self, sqlc):
'''
errors A list of core_ex.UploadError exceptions.
csrf_token Token for detecting CSRF.
'''
- response = super(SessionDBHandler, self).write(result, errors)
+ response = super().write(result, errors)
response['csrf_token'] = self.session.new_csrf_token()
return response
A list of Error instances
'''
uf = self.uf
- errors = super(UploadHandler, self).val_input()
+ errors = super().val_input()
if uf['filename'] == '':
errors.append(core_ex.NoFileError('No file supplied'))
'''
uh An UploadHandler instance
'''
- super(DBConnector, self).__init__()
+ super().__init__()
# Configuration and response management.
self.uh = uh
'''
uh An UploadHandler instance
'''
- super(NoTransactionEngine, self).__init__(uh)
+ super().__init__(uh)
def _call_alter_db(self, func, conn):
'''
'''
uh An UploadHandler instance
'''
- super(UnsafeUploadEngine, self).__init__(uh)
+ super().__init__(uh)
def _call_alter_db(self, func, conn):
'''
'''
uh An UploadHandler instance
'''
- super(UploadEngine, self).__init__(uh)
+ super().__init__(uh)
def csrferror_factory(self):
return core_ex.CSRFError(
def read(self):
'''Add a csrf_token.'''
- super(UploadEngine, self).read()
+ super().read()
self.read_csrf_token()
def call_with_connection(self, func):
return ([self.csrferror_factory()],
response)
else:
- (errors, response) = (super(UploadEngine, self)
- .call_with_connection(func))
+ (errors, response) = super().call_with_connection(func)
response['session_expired'] = False
return (errors, response)
* TooManyColsError
'''
def __init__(self, e, lineno='', descr='', detail='', data=''):
- super(UploadError, self).__init__()
+ super().__init__()
self.lineno = lineno
self.e = e
self.descr = descr
detail Extra HTML describing the error
'''
def __init__(self, e, descr='', detail=''):
- super(SetupError, self).__init__(e=e, descr=descr, detail=detail)
+ super().__init__(e=e, descr=descr, detail=detail)
class NoFileError(SetupError):
'''No file uploaded'''
def __init__(self, e, descr='', detail=''):
- super(NoFileError, self).__init__(e, descr, detail)
+ super().__init__(e, descr, detail)
class NoDBError(SetupError):
'''No database name given'''
def __init__(self, e, descr='', detail=''):
- super(NoDBError, self).__init__(e, descr, detail)
+ super().__init__(e, descr, detail)
class NoUserError(SetupError):
'''No user name supplied'''
def __init__(self, e, descr='', detail=''):
- super(NoUserError, self).__init__(e, descr, detail)
+ super().__init__(e, descr, detail)
class AuthFailError(SetupError):
'''Unable to connect to the db'''
def __init__(self, e, descr='', detail=''):
- super(AuthFailError, self).__init__(e, descr, detail)
+ super().__init__(e, descr, detail)
class DryRunError(SetupError):
'''Rollback due to dry_run config option'''
def __init__(self, e, descr='', detail=''):
- super(DryRunError, self).__init__(e, descr, detail)
+ super().__init__(e, descr, detail)
class CSRFError(SetupError):
'''Invalid CSRF token'''
def __init__(self, e, descr='', detail=''):
- super(CSRFError, self).__init__(e, descr, detail)
+ super().__init__(e, descr, detail)
class NoHeadersError(SetupError):
'''No column headings found'''
def __init__(self, e, descr='', detail=''):
- super(NoHeadersError, self).__init__(e, descr, detail)
+ super().__init__(e, descr, detail)
class NoDataError(SetupError):
'''No data uploaded'''
def __init__(self, e, descr='', detail=''):
- super(NoDataError, self).__init__(e, descr, detail)
+ super().__init__(e, descr, detail)
class CantDecodeError(SetupError):
class DuplicateUploadError(SetupError):
'''The same filename updated twice into the same db'''
def __init__(self, e, descr='', detail=''):
- super(DuplicateUploadError, self).__init__(e, descr, detail)
+ super().__init__(e, descr, detail)
class DataInconsistencyError(SetupError):
def __init__(self, e, descr='', detail=''):
- super(DataInconsistencyError, self).__init__(e, descr, detail)
+ super().__init__(e, descr, detail)
class SQLEncodingError(SetupError):
pgexc The psycopg3 exception object
e Description of what PG was doing
'''
- super(DBError, self).__init__(
+ super().__init__(
'PostgreSQL is unable to ' + e + ':',
'It reports:',
self.html_blockquote(pgexc))
class DBCommitError(DBError):
def __init__(self, pgexc):
- super(DBCommitError, self).__init__(pgexc)
+ super().__init__(pgexc)
class DBDataLineError(DBError):
udl An UploadDataLine instance
pgexc The psycopg3 exception object
'''
- super(DBDataLineError, self).__init__(pgexc)
+ super().__init__(pgexc)
self.lineno = udl.lineno
self.data = udl.raw
data The uploaded data
'''
def __init__(self, lineno, e, descr='', detail='', data=''):
- super(DataLineError, self).__init__(e, lineno, descr, detail, data)
+ super().__init__(e, lineno, descr, detail, data)
class TooManyColsError(DataLineError):
def __init__(self, lineno, e, descr='', detail='', data=''):
- super(TooManyColsError, self).__init__(lineno, e, descr, detail, data)
+ super().__init__(lineno, e, descr, detail, data)
class TooFewColsError(DataLineError):