Skip to content

Commit 09f536e

Browse files
author
David Noble
committed
Ensured that OrderedDict is imported on python 2.6/2.7
The server is OK without this, but we need it for local unit tests
1 parent 80ea477 commit 09f536e

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

splunklib/searchcommands/decorators.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,13 @@
1414

1515
from inspect import getmembers, isclass, isfunction
1616
from types import FunctionType, MethodType
17-
from collections import OrderedDict
1817
from json import JSONEncoder
1918

19+
try:
20+
from collections import OrderedDict # must be python 2.7
21+
except ImportError:
22+
from ordereddict import OrderedDict # must be python 2.6
23+
2024
from .search_command_internals import ConfigurationSettingsType
2125
from .validators import OptionName
2226

splunklib/searchcommands/search_command.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,18 @@
1515
from __future__ import absolute_import
1616

1717
# Absolute imports
18-
from collections import OrderedDict
18+
19+
try:
20+
from collections import OrderedDict # python 2.7
21+
except ImportError:
22+
from ordereddict import OrderedDict # python 2.6
23+
1924
from inspect import getmembers
2025
from os import path
2126
from sys import argv, stdin, stdout
2227

2328
# Relative imports
29+
2430
from . import csv, logging
2531
from . decorators import Option
2632
from . validators import Boolean, Fieldname

0 commit comments

Comments
 (0)