From 7ee95f7f1e056dd42c2668b30fc1cd869ebd86f8 Mon Sep 17 00:00:00 2001 From: Ralic Lo Date: Thu, 18 May 2017 18:40:43 -0700 Subject: [PATCH] Convert to Python3 (#160) * Convert to python3 * Remove .bak * Remove (( and )) in print --- api/server.py | 8 ++++---- tests/test_buku.py | 2 +- tests/test_bukuDb.py | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/api/server.py b/api/server.py index a8a578f..0946162 100644 --- a/api/server.py +++ b/api/server.py @@ -41,7 +41,7 @@ def bookmarks(): result_bookmark = { 'url': bookmark[1], 'title': bookmark[2], - 'tags': list(filter(None, bookmark[3].split(','))), + 'tags': list([_f for _f in bookmark[3].split(',') if _f]), 'description': bookmark[4] } result['bookmarks'].append(result_bookmark) @@ -92,7 +92,7 @@ def bookmark_api(id): result = { 'url': bookmark[1], 'title': bookmark[2], - 'tags': list(filter(None, bookmark[3].split(','))), + 'tags': list([_f for _f in bookmark[3].split(',') if _f]), 'description': bookmark[4] } return jsonify(result) @@ -199,7 +199,7 @@ def bookmark_range_operations(starting_id, ending_id): bookmarks[i] = { 'url': bookmark[1], 'title': bookmark[2], - 'tags': list(filter(None, bookmark[3].split(','))), + 'tags': list([_f for _f in bookmark[3].split(',') if _f]), 'description': bookmark[4] } return jsonify(result) @@ -247,7 +247,7 @@ def search_bookmarks(): 'id': bookmark[0], 'url': bookmark[1], 'title': bookmark[2], - 'tags': list(filter(None, bookmark[3].split(','))), + 'tags': list([_f for _f in bookmark[3].split(',') if _f]), 'description': bookmark[4] } results['bookmarks'].append(result_bookmark) diff --git a/tests/test_buku.py b/tests/test_buku.py index 594c8fa..001d021 100644 --- a/tests/test_buku.py +++ b/tests/test_buku.py @@ -140,7 +140,7 @@ def test_edit_at_prompt(nav, is_editor_valid_retval, edit_rec_retval): @pytest.mark.parametrize( 'field_filter, single_record', - product(range(4), [True, False]) + product(list(range(4)), [True, False]) ) def test_format_json(field_filter, single_record): """test func.""" diff --git a/tests/test_bukuDb.py b/tests/test_bukuDb.py index d8b07b8..9f84fc7 100644 --- a/tests/test_bukuDb.py +++ b/tests/test_bukuDb.py @@ -92,7 +92,7 @@ class TestBukuDb(unittest.TestCase): except KeyError: pass self.assertEqual(dbdir_relative_expected, BukuDb.get_default_dbdir()) - for key, value in originals.items(): + for key, value in list(originals.items()): os.environ[key] = value # # not sure how to test this in nondestructive manner @@ -929,7 +929,7 @@ def split_and_test_membership(a, b): def inclusive_range(start, end): - return range(start, end + 1) + return list(range(start, end + 1)) def normalize_range(db_len, low, high):