def get_metadata(main_file):
    """Get metadata about the package/module.

    Positional arguments:
    main_file -- python file path within `HERE` which has __author__ and the others defined as global variables.

    Returns:
    Dictionary to be passed into setuptools.setup().
    """
    with open(os.path.join(HERE, 'README.md'), encoding='utf-8') as f:
        long_description = f.read()

    with open(os.path.join(HERE, main_file), encoding='utf-8') as f:
        lines = [l.strip() for l in f if l.startswith('__')]
    metadata = ast.literal_eval("{'" + ", '".join([l.replace(' = ', "': ") for l in lines]) + '}')
    __author__, __license__, __version__ = [metadata[k] for k in ('__author__', '__license__', '__version__')]

    everything = dict(version=__version__, long_description=long_description, author=__author__, license=__license__)
    if not all(everything.values()):
        raise ValueError('Failed to obtain metadata from package/module.')

    return everything
def get_metadata ( main_file ) : with open ( os . path . join ( HERE , 'README.md' ) , encoding = 'utf-8' ) as f : long_description = f . read ( ) with open ( os . path . join ( HERE , main_file ) , encoding = 'utf-8' ) as f : lines = [ l . strip ( ) for l in f if l . startswith ( '__' ) ] metadata = ast . literal_eval ( "{'" + ", '" . join ( [ l . replace ( ' = ' , "': " ) for l in lines ] ) + '}' ) __author__ , __license__ , __version__ = [ metadata [ k ] for k in ( '__author__' , '__license__' , '__version__' ) ] everything = dict ( version = __version__ , long_description = long_description , author = __author__ , license = __license__ ) if not all ( everything . values ( ) ) : raise ValueError ( 'Failed to obtain metadata from package/module.' ) return everything
Get metadata about the package/module.

    Positional arguments:
    main_file -- python file path within `HERE` which has __author__ and the others defined as global variables.

    Returns:
    Dictionary to be passed into setuptools.setup().