Skip to content

Commit a71759a

Browse files
author
James William Pye
committed
Variety: add documentation, fix bit/varbit, add Row.transform, and change xact.
* Add Row interface documentation. This is remarkably useful for informing the user about transform and some of the distinctions from mappings and sequences. * Change Transaction.__exit__ to indirectly require prepare() by only calling commit(). The prior double with-statement allowed for potential misuse of a prepared transaction block. Generally, it is somewhat desirable to make using the prepared transaction interface directly; rather a manager *should* be constructed for dealing with global transaction records and dealing with the prepare sequence on exit. * Add documentation for ps.load() against COPY FROM STDIN statements. * bit/varbit had yet to be fixed for Python 3. * Indent CODE, SEVERITY, CONTEXT, LOCATION, etc in exception printout.
1 parent 441ea9d commit a71759a

6 files changed

Lines changed: 491 additions & 121 deletions

File tree

postgresql/api.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -351,12 +351,12 @@ def __str__(self):
351351
detailstr = os.linesep + detailstr
352352
locstr = self.location_string
353353
if locstr:
354-
locstr = os.linesep + locstr
354+
locstr = os.linesep + ' LOCATION: ' + locstr
355355

356356
code = "" if not self.code or self.code == "00000" else '(' + self.code + ')'
357357
return sev + code + ': ' + self.message + locstr + detailstr + \
358-
os.linesep + \
359-
os.linesep.join([': '.join(x[1:]) for x in ss]) + \
358+
os.linesep + ' ' + \
359+
(os.linesep + ' ').join([': '.join(x[1:]) for x in ss]) + \
360360
os.linesep
361361

362362
@property
@@ -367,31 +367,31 @@ def location_string(self):
367367
]
368368
return (
369369
"" if loc == ['?', '?', '?']
370-
else "LOCATION: File {0!r}, "\
370+
else "File {0!r}, "\
371371
"line {1!s}, in {2!s}".format(*loc)
372372
)
373373

374374
@property
375375
def details_string(self):
376376
return os.linesep.join((
377-
': '.join((k.upper(), str(v)))
377+
': '.join((' ' + k.upper(), str(v)))
378378
for k, v in sorted(self.details.items(), key = itemgetter(0))
379379
if k not in ('message', 'severity', 'file', 'function', 'line')
380380
))
381381

382382
def ife_snapshot_text(self):
383383
details = self.details
384-
code = (os.linesep + "CODE: " + self.code) if self.code else ""
384+
code = (os.linesep + " CODE: " + self.code) if self.code else ""
385385
sev = details.get('severity')
386386
sevmsg = ""
387387
if sev:
388-
sevmsg = os.linesep + "SEVERITY: " + sev.upper()
388+
sevmsg = os.linesep + " SEVERITY: " + sev.upper()
389389
detailstr = self.details_string
390390
if detailstr:
391391
detailstr = os.linesep + detailstr
392392
locstr = self.location_string
393393
if locstr:
394-
locstr = os.linesep + locstr
394+
locstr = os.linesep + " LOCATION: " + locstr
395395
return self.message + code + sevmsg + detailstr + locstr
396396

397397
def emit(self):

0 commit comments

Comments
 (0)