# Buggy code
def read_mda(self, attribute):
    lines = attribute.split("\n")
    mda = {}
    current_dict = mda
    path = []
    for line in lines:
        if not line:
            continue
        if line == "END":
            break
        key, val = line.split("=")
        key = key.strip()
        val = val.strip()
        try:
            val = eval(val)
        except NameError:
            pass
        if key in ["GROUP", "OBJECT"]:
            new_dict = {}
            path.append(val)
            current_dict[val] = new_dict
            current_dict = new_dict
        elif key in ["END_GROUP", "END_OBJECT"]:
            if val != path[-1]:
                raise SyntaxError
            path = path[:-1]
            current_dict = mda
            for item in path:
                current_dict = current_dict[item]
        elif key in ["CLASS", "NUM_VAL"]:
            pass
        else:
            current_dict[key] = val
    return mda


# Traceback (SyntaxError)
[DEBUG: 2019-02-20 20:07:05 : satpy.readers] Reading ['/home/aprata/anaconda3/envs/satpy-env/lib/python3.6/site-packages/satpy/etc/readers/modis_l1b.yaml']
[DEBUG: 2019-02-20 20:07:05 : satpy.scene] Setting 'PPP_CONFIG_DIR' to '/home/aprata/anaconda3/envs/satpy-env/lib/python3.6/site-packages/satpy/etc'
[DEBUG: 2019-02-20 20:07:05 : satpy.readers] Reading ['/home/aprata/anaconda3/envs/satpy-env/lib/python3.6/site-packages/satpy/etc/readers/modis_l1b.yaml']
Reading files...
[DEBUG: 2019-02-20 20:07:05 : satpy.readers.yaml_reader] Assigning to modis_l1b: ['/home/aprata/satellite/etna/modis_aqua/data/20190511225/MYD02QKM.A2019051.1225.061.NRT.hdf', '/home/aprata/satellite/etna/modis_aqua/data/20190511225/MYD02HKM.A2019051.1225.061.NRT.hdf', '/home/aprata/satellite/etna/modis_aqua/data/20190511225/MYD021KM.A2019051.1225.061.NRT.hdf', '/home/aprata/satellite/etna/modis_aqua/data/20190511225/MYD03.A2019051.1225.061.NRT.hdf']
Traceback (most recent call last):
File "/home/aprata/anaconda3/envs/satpy-env/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2683, in safe_execfile
self.compile if shell_futures else None)
File "/home/aprata/anaconda3/envs/satpy-env/lib/python3.6/site-packages/IPython/utils/py3compat.py", line 188, in execfile
exec(compiler(f.read(), fname, 'exec'), glob, loc)
File "/home/aprata/PycharmProjects/etna/src/plot_modis_btd.py", line 25, in <module>
scn = Scene(filenames=files)
File "/home/aprata/anaconda3/envs/satpy-env/lib/python3.6/site-packages/satpy/scene.py", line 154, in __init__
reader_kwargs=reader_kwargs)
File "/home/aprata/anaconda3/envs/satpy-env/lib/python3.6/site-packages/satpy/scene.py", line 199, in create_reader_instances
ppp_config_dir=self.ppp_config_dir)
File "/home/aprata/anaconda3/envs/satpy-env/lib/python3.6/site-packages/satpy/readers/__init__.py", line 657, in load_readers
reader_instance.create_filehandlers(loadables)
File "/home/aprata/anaconda3/envs/satpy-env/lib/python3.6/site-packages/satpy/readers/yaml_reader.py", line 500, in create_filehandlers
filename_set)
File "/home/aprata/anaconda3/envs/satpy-env/lib/python3.6/site-packages/satpy/readers/yaml_reader.py", line 487, in new_filehandlers_for_filetype
return list(filtered_iter)
File "/home/aprata/anaconda3/envs/satpy-env/lib/python3.6/site-packages/satpy/readers/yaml_reader.py", line 460, in filter_fh_by_metadata
for filehandler in filehandlers:
File "/home/aprata/anaconda3/envs/satpy-env/lib/python3.6/site-packages/satpy/readers/yaml_reader.py", line 403, in new_filehandler_instances
yield filetype_cls(filename, filename_info, filetype_info, *req_fh)
File "/home/aprata/anaconda3/envs/satpy-env/lib/python3.6/site-packages/satpy/readers/modis_l1b.py", line 122, in __init__
HDFEOSFileReader.__init__(self, filename, filename_info, filetype_info)
File "/home/aprata/anaconda3/envs/satpy-env/lib/python3.6/site-packages/satpy/readers/modis_l1b.py", line 64, in __init__
self.metadata = self.read_mda(self.sd.attributes()['CoreMetadata.0'])
File "/home/aprata/anaconda3/envs/satpy-env/lib/python3.6/site-packages/satpy/readers/modis_l1b.py", line 96, in read_mda
val = eval(val)
File "<string>", line 1
("MYD01.61.2019-051T12:25:00.000000Z.NA.29878844.500100_1.hdf", "MYD03LUT.coeff_V6.1.4", "PM1EPHND_NRT.A2019051.1220.061.2019051125628", "PM1EPHND_NRT.A2019051.1225.061.2019051125628", "PM1EPHND_NRT.A2019051.1230.061.2019051125628", "
^
SyntaxError: EOL while scanning string literal

# Fixed code
def read_mda(attribute):
    """Read HDFEOS metadata and return a dict with all the key/value pairs."""
    lines = attribute.split("\n")
    mda = {}
    current_dict = mda
    path = []
    prev_line = None
    for line in lines:
        if not line:
            continue
        if line == "END":
            break
        if prev_line:
            line = prev_line + line
        key, val = line.split("=")
        key = key.strip()
        val = val.strip()
        try:
            val = eval(val)
        except NameError:
            pass
        except SyntaxError:
            prev_line = line
            continue
        prev_line = None
        if key in ["GROUP", "OBJECT"]:
            new_dict = {}
            path.append(val)
            current_dict[val] = new_dict
            current_dict = new_dict
        elif key in ["END_GROUP", "END_OBJECT"]:
            if val != path[-1]:
                raise SyntaxError
            path = path[:-1]
            current_dict = mda
            for item in path:
                current_dict = current_dict[item]
        elif key in ["CLASS", "NUM_VAL"]:
            pass
        else:
            current_dict[key] = val
    return mda