def get_package_info_from_line(tpip_pkg, line):
    """Given a line of text from metadata, extract semantic info"""
    lower_line = line.lower()

    try:
        metadata_key, metadata_value = lower_line.split(':', 1)
    except ValueError:
        return

    metadata_key = metadata_key.strip()
    metadata_value = metadata_value.strip()

    if metadata_value == 'unknown':
        return

    # extract exact matches
    if metadata_key in TPIP_FIELD_MAPPINGS:
        tpip_pkg[TPIP_FIELD_MAPPINGS[metadata_key]] = metadata_value
        return

    if metadata_key.startswith('version') and not tpip_pkg.get('PkgVersion'):
        # ... but if not, we'll use whatever we find
        tpip_pkg['PkgVersion'] = metadata_value
        return

    # Handle british and american spelling of licence/license
    if 'licen' in lower_line:
        if metadata_key.startswith('classifier') or '::' in metadata_value:
            license = lower_line.rsplit(':')[-1].strip().lower()
            license = license_cleanup(license)
            if license:
                tpip_pkg.setdefault('PkgLicenses', []).append(license)
Given a line of text from metadata, extract semantic info