Skip to content

Commit

Permalink
Fix #786: Remove usage of "six" library
Browse files Browse the repository at this point in the history
  • Loading branch information
stennie committed Oct 12, 2020
1 parent fc144f0 commit bbf5faf
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 23 deletions.
6 changes: 3 additions & 3 deletions mtools/mplotqueries/mplotqueries.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env python3

from six.moves import cPickle
import glob
import inspect
import os
import pickle
import sys
import uuid
from datetime import timedelta
Expand Down Expand Up @@ -317,7 +317,7 @@ def save_overlay(self):

# dump plots and handle exceptions
try:
cPickle.dump(self.plot_instances, open(target_file, 'wb'), -1)
pickle.dump(self.plot_instances, open(target_file, 'wb'), -1)
print("Created overlay: %s" % uid)
except Exception as e:
print("Error: %s" % e)
Expand All @@ -335,7 +335,7 @@ def load_overlays(self):
target_files = glob.glob(os.path.join(target_path, '*'))
for f in target_files:
try:
overlay = cPickle.load(open(f, 'rb'))
overlay = pickle.load(open(f, 'rb'))
except Exception:
print("Couldn't read overlay %s, skipping." % f)
continue
Expand Down
4 changes: 1 addition & 3 deletions mtools/test/test_mloginfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
from datetime import timedelta, date
from random import randrange

import six

import mtools
from mtools.mloginfo.mloginfo import MLogInfoTool
from mtools.util.logfile import LogFile
Expand Down Expand Up @@ -396,7 +394,7 @@ def _test_rsinfo(self, logfile_path, **expected):
self.tool.run('--rsinfo %s' % logfile_path)
output = sys.stdout.getvalue()
results = self._parse_output(output)
for key, value in six.iteritems(expected):
for key, value in expected.items():
print("results[%s] == %s" % (key, value))
assert results.get(key) == value

Expand Down
4 changes: 1 addition & 3 deletions mtools/util/grouping.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

import re

import six

from mtools.util import OrderedDict


Expand Down Expand Up @@ -111,7 +109,7 @@ def sort_by_size(self, group_limit=None, discard_others=False,
group is removed instead.
"""
# sort groups by number of elements
self.groups = OrderedDict(sorted(six.iteritems(self.groups),
self.groups = OrderedDict(sorted(self.groups.items(),
key=lambda x: len(x[1]),
reverse=True))

Expand Down
12 changes: 5 additions & 7 deletions mtools/util/log2code.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
#!/usr/bin/env python3

from __future__ import print_function

import os
import re
# import sys
# import argparse
from six.moves import zip_longest as izip_longest
from six.moves import cPickle
from itertools import zip_longest
import pickle

import mtools

Expand All @@ -20,7 +18,7 @@ def import_l2c_db():
"""
data_path = os.path.join(os.path.dirname(mtools.__file__), 'data')
if os.path.exists(os.path.join(data_path, 'log2code.pickle')):
av, lv, lbw, lcl = cPickle.load(open(os.path.join(data_path,
av, lv, lbw, lcl = pickle.load(open(os.path.join(data_path,
'log2code.pickle'),
'rb'))
return av, lv, lbw, lcl
Expand Down Expand Up @@ -153,7 +151,7 @@ def __call__(self, line, variable=False):

def combine(self, pattern, variable):
"""Combine a pattern and variable parts to be a line string again."""
inter_zip = izip_longest(variable, pattern, fillvalue='')
inter_zip = zip_longest(variable, pattern, fillvalue='')
interleaved = [elt for pair in inter_zip for elt in pair]
return ''.join(interleaved)

Expand Down Expand Up @@ -265,4 +263,4 @@ def combine(self, pattern, variable):
# possible_versions.values(), align='center')
# plt.xticks(range(len(possible_versions.keys())),
# possible_versions.keys(), size='small', rotation=90)
# plt.show()
# plt.show()
2 changes: 0 additions & 2 deletions mtools/util/logevent.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import dateutil.parser
from dateutil.tz import tzutc

from six.moves import range

from mtools.util.pattern import json2pattern


Expand Down
4 changes: 2 additions & 2 deletions mtools/util/parse_sourcecode.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3

from six.moves import cPickle
import pickle
import os
import re
import subprocess
Expand Down Expand Up @@ -307,7 +307,7 @@ def extract_logs(log_code_lines, current_version):
.update({'pattern': instance['pattern']}, instance,
upsert=True)())

cPickle.dump((versions, logs_versions, logs_by_word, log_code_lines),
pickle.dump((versions, logs_versions, logs_by_word, log_code_lines),
open('log2code.pickle', 'wb'), -1)

print("%i unique log messages imported and written to log2code.pickle"
Expand Down
3 changes: 0 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
try:
from setuptools import setup, find_packages

# test for 2.7-included packages, add to requirements if not available
install_requires = ['six', 'python-dateutil>=2.7']

python_requires='>=3.6'

# Additional dependencies from requirements.txt that should be installed
Expand Down

0 comments on commit bbf5faf

Please sign in to comment.