Skip to content

Commit

Permalink
Continue on python3 compatibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
mraspaud committed Oct 20, 2015
1 parent 542db00 commit 6fdbeb6
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions mpop/readers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@
from collections import namedtuple
import os
from datetime import datetime, timedelta
try:
import configparser
except ImportError:
from six.moves import configparser
import glob

import numpy as np
import six
from trollsift.parser import globify, Parser
Expand All @@ -45,6 +39,12 @@
from mpop.projectable import Projectable
from mpop import runtime_import

try:
import configparser
except ImportError:
from six.moves import configparser
import glob

LOG = logging.getLogger(__name__)

BandID = namedtuple("Band", "name resolution wavelength polarization")
Expand Down Expand Up @@ -269,7 +269,7 @@ def assign_matching_files(reader_info, *files):
for file_pattern in reader_info["file_patterns"]:
pattern = globify(file_pattern)
for filename in list(files):
if fnmatch.fnmatch(os.path.basename(filename), os.path.basename(pattern)):
if fnmatch(os.path.basename(filename), os.path.basename(pattern)):
reader_info["filenames"].append(filename)
files.remove(filename)

Expand Down Expand Up @@ -367,9 +367,7 @@ def get_dataset(self, key, aslist=False):
if ("wavelength_range" in ds and
ds["wavelength_range"][0] <= key <= ds["wavelength_range"][2])]
datasets = sorted(datasets,
lambda ch1, ch2:
cmp(abs(ch1["wavelength_range"][1] - key),
abs(ch2["wavelength_range"][1] - key)))
key=lambda ch: abs(ch["wavelength_range"][1] - key))

if not datasets:
raise KeyError("Can't find any projectable at %gum" % key)
Expand Down

0 comments on commit 6fdbeb6

Please sign in to comment.