From 2d971a29501d256256d349055b6fd97d108d0e59 Mon Sep 17 00:00:00 2001 From: Cort Buffington Date: Mon, 16 Apr 2018 08:36:59 -0500 Subject: [PATCH] Revert "Added json and dictionary checking to eliminate terminations when the DMR-MARC database can't download." This reverts commit 192d36a94c7f5c6648a8a9ecc56fe5fba7e0905c. --- dmr_utils/utils.py | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/dmr_utils/utils.py b/dmr_utils/utils.py index 8197f3d..a6f63d2 100755 --- a/dmr_utils/utils.py +++ b/dmr_utils/utils.py @@ -22,7 +22,6 @@ from __future__ import print_function import json from os.path import isfile, getmtime -from os import remove from time import time from urllib import URLopener from csv import reader as csv_reader @@ -115,13 +114,7 @@ def mk_id_dict(_path, _file): if _file.endswith(('.json','.JSON')): try: with open(_path+_file, 'rU') as _handle: - - try: - ids = json.loads(_handle.read().decode('utf-8', 'ignore')) - except (ValueError): - remove(_path+_file) - return dict - + ids = json.loads(_handle.read().decode('utf-8', 'ignore')) if 'repeaters' in ids: ids = ids['repeaters'] id_type = 'locator' @@ -137,13 +130,9 @@ def mk_id_dict(_path, _file): else: return dict - try: - for row in range(len(ids)): - dict[int(ids[row][id_type])] = ids[row][id_value].encode('ascii','ignore') - except (ValueError, KeyError): - remove(_path+_file) - return dict; - + for row in range(len(ids)): + dict[int(ids[row][id_type])] = ids[row][id_value].encode('ascii','ignore') + _handle.close return dict except IOError: @@ -206,4 +195,4 @@ def get_alias(_id, _dict, *args): return _id # FOR LEGACY PURPOSES -get_info = get_alias +get_info = get_alias \ No newline at end of file