Skip to content

Commit

Permalink
remove some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
hydrargyrum committed Dec 12, 2024
1 parent 328a0c1 commit 08f70d0
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 24 deletions.
1 change: 1 addition & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
PYTHONDEVMODE: "1"
PIP_ROOT_USER_ACTION: "ignore"

cache:
paths:
Expand Down
6 changes: 3 additions & 3 deletions csv2table/csv2table.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import csv
import sys

from prettytable import PrettyTable, SINGLE_BORDER, MARKDOWN
from prettytable import PrettyTable, TableStyle


def sniff(fn):
Expand Down Expand Up @@ -57,9 +57,9 @@ def main():

table = PrettyTable()
if args.box:
table.set_style(SINGLE_BORDER)
table.set_style(TableStyle.SINGLE_BORDER)
elif args.markdown:
table.set_style(MARKDOWN)
table.set_style(TableStyle.MARKDOWN)
table.field_names = data[0].keys()
table.header = args.header
table.align = "l"
Expand Down
36 changes: 19 additions & 17 deletions json2sqlite/json2sqlite
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ class Inserter(object):

self.cursor.execute('UPDATE %s SET %s WHERE %s' % (self.table, req_set, req_match), ordered_values)

def commit(self):
self.db.commit()
def close(self):
self.db.close()

def _create_table(self, d):
columns = ','.join('%s %s' % (k, self._column_type(d[k])) for k in d)
Expand Down Expand Up @@ -151,21 +151,23 @@ def main():

inserter = Inserter(args.database, args.table, create=args.create, alter=args.alter)

if args.json and args.file:
parser.error('-f and -j are mutually exclusive')
elif args.json:
js = json.loads(args.json)
elif args.file == '-':
js = json.load(sys.stdin)
else:
js = json.load(open(args.file, 'rb'))

if args.update_ids:
inserter.update_data(args.update_ids, js)
else:
inserter.insert_data(js)

inserter.commit()
try:
if args.json and args.file:
parser.error('-f and -j are mutually exclusive')
elif args.json:
js = json.loads(args.json)
elif args.file == '-':
js = json.load(sys.stdin)
else:
js = json.load(open(args.file, 'rb'))

with inserter.db:
if args.update_ids:
inserter.update_data(args.update_ids, js)
else:
inserter.insert_data(js)
finally:
inserter.close()


if __name__ == '__main__':
Expand Down
4 changes: 2 additions & 2 deletions json2table/json2table
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ keys = list(keys)

table = prettytable.PrettyTable(field_names=keys)
if args.box:
table.set_style(prettytable.SINGLE_BORDER)
table.set_style(prettytable.TableStyle.SINGLE_BORDER)
elif args.markdown:
table.set_style(prettytable.MARKDOWN)
table.set_style(prettytable.TableStyle.MARKDOWN)

for d in data:
table.add_row([d.get(k) for k in keys])
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions table-add-border/table-add-border.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import re
import sys

from prettytable import PrettyTable, SINGLE_BORDER
from prettytable import PrettyTable, TableStyle


# TODO: accept ANSI-colored entries, where width != number of codepoints
Expand Down Expand Up @@ -33,7 +33,7 @@ def split_at(line, points):

table = PrettyTable([cell.strip() for cell in split_at(lines[0], intersect)])
table.align = "l"
table.set_style(SINGLE_BORDER)
table.set_style(TableStyle.SINGLE_BORDER)
for line in lines[1:]:
table.add_row([cell.strip() for cell in split_at(line, intersect)])
print(table)

0 comments on commit 08f70d0

Please sign in to comment.