import zipfile


def read_kmz(infile):
    """read raw kml/kmz file"""
    if infile.upper().endswith('.KML'):
        with open(infile, "r") as f:
            return f.read()

    if infile.upper().endswith('.KMZ'):
        with zipfile.ZipFile(infile, "r") as f:
            return f.read(f.namelist()[0])