<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def import_locations(self, data):
 """Parse `GNU miscfiles`_ cities data files. ``import_locations()`` returns a list containing :class:`City` objects. It expects data files in the same format that `GNU miscfiles`_ provides, that is:: ID : 1 Type : City Population : 210700 Size : Name : Aberdeen Country : UK Region : Scotland Location : Earth Longitude : -2.083 Latitude : 57.150 Elevation : Date : 19961206 Entered-By : Rob.Hooft@EMBL-Heidelberg.DE // ID : 2 Type : City Population : 1950000 Size : Name : Abidjan Country : Ivory Coast Region : Location : Earth Longitude : -3.867 Latitude : 5.333 Elevation : Date : 19961206 Entered-By : Rob.Hooft@EMBL-Heidelberg.DE When processed by ``import_locations()`` will return ``list`` object in the following style:: [City(1, "City", 210700, None, "Aberdeen", "UK", "Scotland", "Earth", -2.083, 57.15, None, (1996, 12, 6, 0, 0, 0, 4, 341, -1), "Rob.Hooft@EMBL-Heidelberg.DE"), City(2, "City", 1950000, None, "Abidjan", "Ivory Coast", "", "Earth", -3.867, 5.333, None, (1996, 12, 6, 0, 0, 0, 4, 341, -1), "Rob.Hooft@EMBL-Heidelberg.DE")]) Args: data (iter):
 :abbr:`NOAA (National Oceanographic and Atmospheric Administration)` station data to read Returns: list: Places as ``City`` objects Raises: TypeError: Invalid value for data .. _GNU miscfiles: http://directory.fsf.org/project/miscfiles/ """

        self._data = data
        if hasattr(data, 'read'):
            data = data.read().split('//\n')
        elif isinstance(data, list):
            pass
        elif isinstance(data, basestring):
            data = open(data).read().split('//\n')
        else:
            raise TypeError('Unable to handle data of type %r' % type(data))

        keys = ('identifier', 'ptype', 'population', 'size', 'name', 'country',
                'region', 'location', 'longitude', 'latitude', 'altitude',
                'date', 'entered')

        for record in data:
            # We truncate after splitting because the v1.4.2 datafile contains
            # a broken separator between 229 and 230 that would otherwise break
            # the import
            data = [i.split(':')[1].strip() for i in record.splitlines()[:13]]
            entries = dict(zip(keys, data))

            # Entry for Utrecht has the incorrect value of 0.000 for elevation.
            if entries['altitude'] == '0.000':
                logging.debug("Ignoring `0.000' value for elevation in %r "
                              'entry' % record)
                entries['altitude'] = ''
            for i in ('identifier', 'population', 'size', 'altitude'):
                entries[i] = int(entries[i]) if entries[i] else None
            for i in ('longitude', 'latitude'):
                entries[i] = float(entries[i]) if entries[i] else None
            entries['date'] = time.strptime(entries['date'], '%Y%m%d')
            self.append(City(**entries))