예제 #1
0
def add_classifier(st, classifier):
    ''' Add a classifier to the trove_classifiers list
    '''
    cursor = st.get_cursor()
    cursor.execute("select max(id) from trove_classifiers")
    id = cursor.fetchone()[0]
    if id:
        id = int(id) + 1
    else:
        id = 1
    fields = [f.strip() for f in classifier.split('::')]
    for f in fields:
        assert ':' not in f
    levels = []
    for l in range(2, len(fields)):
        c2 = ' :: '.join(fields[:l])
        store.safe_execute(
            cursor, 'select id from trove_classifiers where classifier=%s',
            (c2, ))
        l = cursor.fetchone()
        if not l:
            raise ValueError, c2 + " is not a known classifier"
        levels.append(l[0])
    levels += [id] + [0] * (3 - len(levels))
    store.safe_execute(
        cursor,
        'insert into trove_classifiers (id, classifier, l2, l3, l4, l5) '
        'values (%s,%s,%s,%s,%s,%s)', [id, classifier] + levels)
예제 #2
0
파일: admin.py 프로젝트: ericholscher/pypi
def add_classifier(st, classifier):
    ''' Add a classifier to the trove_classifiers list
    '''
    cursor = st.get_cursor()
    cursor.execute("select max(id) from trove_classifiers")
    id = cursor.fetchone()[0]
    if id:
        id = int(id) + 1
    else:
        id = 1
    fields = [f.strip() for f in classifier.split('::')]
    for f in fields:
        assert ':' not in f
    levels = []
    for l in range(2, len(fields)):
        c2 = ' :: '.join(fields[:l])
        store.safe_execute(cursor, 'select id from trove_classifiers where classifier=%s', (c2,))
        l = cursor.fetchone()
        if not l:
            raise ValueError, c2 + " is not a known classifier"
        levels.append(l[0])
    levels += [id] + [0]*(3-len(levels))
    store.safe_execute(cursor, 'insert into trove_classifiers (id, classifier, l2, l3, l4, l5) '
        'values (%s,%s,%s,%s,%s,%s)', [id, classifier]+levels)
예제 #3
0
def get_paths(cursor, prefix=None):
    store.safe_execute(cursor, "SELECT python_version, name, filename FROM release_files")

    for type, name, filename in cursor.fetchall():
        yield os.path.join(prefix, type, name[0], name, filename)
예제 #4
0
def get_paths(cursor, prefix=None):
    store.safe_execute(
        cursor, "SELECT python_version, name, filename FROM release_files")

    for type, name, filename in cursor.fetchall():
        yield os.path.join(prefix, type, name[0], name, filename)