Exemple #1
0
def get_package_metadata(database, name):
    """Extract infos (description, url) from the local database"""
    # Note: we could use the PyPI database but this has been written on
    # machine which is not connected to the internet
    db = cp.ConfigParser()
    db.readfp(open(osp.join(DATA_PATH, database)))
    metadata = dict(
        description='',
        url='https://pypi.org/project/' + name,
    )
    for key in metadata:
        name1 = name.lower()
        # wheel replace '-' per '_' in key
        for name2 in (
                name1,
                name1.split('-')[0],
                name1.replace('-', '_'),
                '-'.join(name1.split('_')),
                normalize(name),
        ):
            try:
                metadata[key] = db.get(name2, key)
                break
            except (cp.NoSectionError, cp.NoOptionError):
                pass
    return metadata
Exemple #2
0
def get_hg_user_password():
    """Get Hg user and password infos from configuration file (hgrc)"""
    fname = osp.join(osp.dirname(__name__), ".hg", "hgrc")
    hgrc = cp.ConfigParser()
    hgrc.read(fname)
    defpath = hgrc.get("paths", "default")
    match = re.match(r'https://([a-zA-Z0-9\.\_\%]*):([\S]*)'\
                     r'@winpython.googlecode.com/hg/', defpath)
    user = match.group(1).replace('%40', '@')
    password = match.group(2)
    return user, password
Exemple #3
0
def get_package_metadata(database, name, gotoWWW=False, update=False):
    """Extract infos (description, url) from the local database"""
    # Note: we could use the PyPI database but this has been written on
    # machine which is not connected to the internet
    # we store only  normalized names now (PEP 503)
    db = cp.ConfigParser()
    db.readfp(open(osp.join(DATA_PATH, database)))
    my_metadata = dict(
        description='',
        url='https://pypi.org/project/' + name,
    )
    for key in my_metadata:
        name1 = name.lower()
        # wheel replace '-' per '_' in key
        for name2 in (
            name1,
            name1.split('-')[0],
            name1.replace('-', '_'),
            '-'.join(name1.split('_')),
            normalize(name),
        ):
            try:
                my_metadata[key] = db.get(name2, key)
                break
            except (cp.NoSectionError, cp.NoOptionError):
                pass
    database_desc = my_metadata.get('description')
    if my_metadata.get('description') == '' and metadata:  # nothing in package.ini
        try:
            my_metadata['description']=(
                    metadata(name)['Summary']+'\n').splitlines()[0]
        except:
            pass
    if  my_metadata['description'] == '' and gotoWWW:
        the_official = get_official_description(name)
        if the_official != '':
            my_metadata['description'] = the_official
    if update == True and database_desc == '' and my_metadata['description'] !='':
        try:
            db[normalize(name)]={}
            db[normalize(name)]['description'] = my_metadata['description']
            with open(osp.join(DATA_PATH, database), 'w') as configfile:
                db.write(configfile)
        except:
            pass
    return my_metadata