Skip to content

Commit d60c039

Browse files
committed
json is now guaranteed to be in stdlib, so no need for simplejson
Those were the days…
1 parent 08182e6 commit d60c039

File tree

2 files changed

+9
-28
lines changed

2 files changed

+9
-28
lines changed

sword2/compatible_libs.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,14 @@
55
Provides the module with access to certain libraries that have more than one suitable implementation, in a optimally
66
degredating manner.
77
8-
Provides - `etree` and `json`
8+
Provides - `etree`
99
1010
`etree` can be from any of the following, if found in the local environment:
1111
`lxml`
1212
`xml.etree`
1313
`elementtree`
1414
`cElementTree`
1515
16-
`json` can be from any of the following:
17-
`json` (python >= 2.6)
18-
`simplejson`
19-
2016
If no suitable library is found, then it will pass back `None`
2117
"""
2218

@@ -39,12 +35,3 @@
3935
except ImportError:
4036
cl_l.error("Couldn't find a suitable ElementTree library to use in this environment.")
4137
etree = None
42-
43-
try:
44-
import json
45-
except ImportError:
46-
try:
47-
import simplejson as json
48-
except ImportError:
49-
cl_l.error("Couldn't find a suitable simplejson-like library to use to serialise JSON")
50-
json = None

sword2/transaction_history.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
Provides a class to hold the `sword2.Connection` transaction history and give simple means for export (JSON) and reporting.
66
"""
77

8-
from .sword2_logging import logging
9-
8+
import json
109
from datetime import datetime
1110

11+
from .sword2_logging import logging
12+
1213
th_l = logging.getLogger(__name__)
1314

15+
1416
class Transaction_History(list):
1517
def log(self, event_type, **kw):
1618
self.append({'type':event_type,
@@ -28,18 +30,10 @@ def __str__(self):
2830
return "\n".join(_s)
2931

3032
def to_json(self):
31-
from .compatible_libs import json
32-
if json:
33-
th_l.debug("Attempting to dump %s history items to JSON" % len(self))
34-
return json.dumps(self)
35-
else:
36-
th_l.error("Cannot procede with converting the transaction history to JSON")
33+
th_l.debug("Attempting to dump %s history items to JSON" % len(self))
34+
return json.dumps(self)
3735

3836
def to_pretty_json(self):
39-
from .compatible_libs import json
40-
if json:
41-
th_l.debug("Attempting to dump %s history items to indented, readable JSON" % len(self))
42-
return json.dumps(self, indent=True)
43-
else:
44-
th_l.error("Cannot procede with converting the transaction history to JSON")
37+
th_l.debug("Attempting to dump %s history items to indented, readable JSON" % len(self))
38+
return json.dumps(self, indent=True)
4539

0 commit comments

Comments
 (0)