def get_metadata(source):
    """
    Extract the metadata from the module or dict argument.

    It returns a `metadata` dictionary that provides keywords arguments
    for the setuptools `setup` function.
    """
    if isinstance(source, types.ModuleType):
        metadata = source.__dict__
    else:
        metadata = source

    setuptools_kwargs = {}

    for key in "name version url license".split():
        val = metadata.get("__" + key + "__")
        if val is not None:
            setuptools_kwargs[key] = val

    version = metadata.get("__version__")
    if version is not None:
        setuptools_kwargs["version"] = version

    # Search for author email with a <...@...> syntax in the author field.
    author = metadata.get("__author__")
    if author is not None:
        email_pattern = u"<([^>]+@[^>]+)>"
        match = re.search(email_pattern, author)
        if match is not None:
            setuptools_kwargs["author_email"] = email = match.groups()[0]
            setuptools_kwargs["author"] = author.replace(u"<" + email + u">", u"").strip()
        else:
            setuptools_kwargs["author"] = author

    # Get the module summary.
    summary = metadata.get("__summary__")
    if summary is not None:
        setuptools_kwargs["description"] = summary

    # Get and process the module README.
    README_filenames = ["README.md", "README.txt", "README"]
    for filename in README_filenames:
        if os.path.isfile(filename):
            README = open(filename).read()
            if hasattr(README, "decode"):
                README = README.decode("utf-8")
            README_rst = to_rst(README)
            setuptools_kwargs["long_description"] = README_rst or README
            break

    # Process keywords that match trove classifiers.
    keywords = metadata.get("__keywords__")
    if keywords is not None:
        classifiers = []
        keywords = [k.strip() for k in keywords.split(",")]
        for keyword in keywords:
            trove_id = trove_search(keyword)
            if trove_id is not None:
                classifiers.append(trove_id)
        classifiers = sorted(list(set(classifiers)))
        setuptools_kwargs["classifiers"] = classifiers

    return setuptools_kwargs
def get_metadata ( source ) : if isinstance ( source , types . ModuleType ) : metadata = source . __dict__ else : metadata = source setuptools_kwargs = { } for key in "name version url license" . split ( ) : val = metadata . get ( "__" + key + "__" ) if val is not None : setuptools_kwargs [ key ] = val version = metadata . get ( "__version__" ) if version is not None : setuptools_kwargs [ "version" ] = version author = metadata . get ( "__author__" ) if author is not None : email_pattern = u"<([^>]+@[^>]+)>" match = re . search ( email_pattern , author ) if match is not None : setuptools_kwargs [ "author_email" ] = email = match . groups ( ) [ 0 ] setuptools_kwargs [ "author" ] = author . replace ( u"<" + email + u">" , u"" ) . strip ( ) else : setuptools_kwargs [ "author" ] = author summary = metadata . get ( "__summary__" ) if summary is not None : setuptools_kwargs [ "description" ] = summary README_filenames = [ "README.md" , "README.txt" , "README" ] for filename in README_filenames : if os . path . isfile ( filename ) : README = open ( filename ) . read ( ) if hasattr ( README , "decode" ) : README = README . decode ( "utf-8" ) README_rst = to_rst ( README ) setuptools_kwargs [ "long_description" ] = README_rst or README break keywords = metadata . get ( "__keywords__" ) if keywords is not None : classifiers = [ ] keywords = [ k . strip ( ) for k in keywords . split ( "," ) ] for keyword in keywords : trove_id = trove_search ( keyword ) if trove_id is not None : classifiers . append ( trove_id ) classifiers = sorted ( list ( set ( classifiers ) ) ) setuptools_kwargs [ "classifiers" ] = classifiers return setuptools_kwargs
Extract the metadata from the module or dict argument.

    It returns a `metadata` dictionary that provides keywords arguments
    for the setuptools `setup` function.