Skip to content

Commit

Permalink
remove dependency of OrderedDict due to absence in py2.6
Browse files Browse the repository at this point in the history
  • Loading branch information
wjo1212 committed Nov 20, 2018
1 parent d47d360 commit eb32f51
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
5 changes: 2 additions & 3 deletions aliyun/log/etl_core/trans_comp/trans_regex.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
import logging
import re
import six
from collections import OrderedDict

from .trans_base import trans_comp_base
from ..exceptions import SettingError
Expand Down Expand Up @@ -111,7 +110,7 @@ def __init__(self, pattern, fields_info=None):
raise SettingError(ex, pattern)

self.fields_info = None
if isinstance(fields_info, (six.text_type, six.binary_type, list, dict, OrderedDict)):
if isinstance(fields_info, (six.text_type, six.binary_type, list, dict)):
self.fields_info = fields_info
elif fields_info is not None:
logger.warning('transform_regex: unknown fields info type: "{0}"'.format(fields_info))
Expand Down Expand Up @@ -147,7 +146,7 @@ def __call__(self, event, inpt):
if isinstance(self.fields_info, (six.binary_type, six.text_type)):
# only find first one
event[self.fields_info] = m.group()
elif isinstance(self.fields_info, (dict, OrderedDict)):
elif isinstance(self.fields_info, (dict, )):
ms = [m] + list(find_iter)

for i, m in enumerate(ms):
Expand Down
6 changes: 3 additions & 3 deletions aliyun/log/etl_core/transform/condition_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import logging
import re
import six
from collections import OrderedDict, Callable
from collections import Callable
from ..exceptions import SettingError

logger = logging.getLogger(__name__)
Expand All @@ -30,7 +30,7 @@ def get_check(c):
return lambda e: c
elif isinstance(c, Callable):
return c
elif isinstance(c, (dict, OrderedDict)):
elif isinstance(c, (dict, )):
def check(event):
for k, v in six.iteritems(c):
if k in event:
Expand Down Expand Up @@ -103,7 +103,7 @@ def call_processor(self, fn, evt, *args, **kwargs):
return ret

def __call__(self, entity):
if isinstance(entity, (dict, OrderedDict)):
if isinstance(entity, (dict, )):
return any(c(entity) for c in self.check_list)
elif isinstance(entity, Callable):
fn = entity
Expand Down
4 changes: 2 additions & 2 deletions aliyun/log/etl_core/transform/transform_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"""

import logging
from collections import OrderedDict, Callable
from collections import Callable

import six
from ..trans_comp import REGEX
Expand All @@ -106,7 +106,7 @@ def __init__(self, trans):
for tr in self.trans:
if isinstance(tr, Callable):
self.transform_list.append(tr)
elif isinstance(tr, (dict, OrderedDict)):
elif isinstance(tr, (dict, )):
def real_transform(event):
result = {}
for k, v in six.iteritems(tr):
Expand Down
3 changes: 1 addition & 2 deletions aliyun/log/etl_core/transform/transform_meta.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import re
import six
from collections import OrderedDict

from .transform_base import transform_base
from ..exceptions import SettingError
Expand Down Expand Up @@ -49,7 +48,7 @@ def __call__(self, event):

class rename_fields(transform_base):
def __init__(self, config):
if isinstance(config, (dict, OrderedDict)):
if isinstance(config, (dict, )):
self.new_name = lambda k: k if k not in config else config[k]
elif config is None or config == "":
self.new_name = lambda k: k
Expand Down

0 comments on commit eb32f51

Please sign in to comment.