예제 #1
0
def download(bibfile, log):  # pragma: no cover
    with NamedTemporaryFile(delete=False) as fp:
        log.info('download bib from {0}'.format(URL))
        fp.write(urlopen(URL).read())

    bibtool(fp.name)
    stats = Counter()

    def fix_entry_type(entry):
        type_ = entry.type.lower()
        type_map = {
            'thesis': 'phdthesis',
            'mvreference': 'misc',
            'report': 'techreport'
        }
        entry.type = type_map.get(type_, type_)
        stats.update([entry.type])

    bibfile.update(fp.name, log=log)
    bibfile.visit(fix_entry_type)
    bibfile.check(log)
    res = Table('entry type', '#')
    res.extend(list(stats.most_common()))
    res.append(['TOTAL', sum(stats.values())])
    print('\n' + res.render(tablefmt='simple'))
예제 #2
0
def features(args):
    bipa = TranscriptionSystem(args.system)
    features = set()
    for sound in bipa.sounds.values():
        if sound.type not in ['marker', 'unknownsound']:
            for k, v in sound.featuredict.items():
                features.add((sound.type, k, v or ''))
    table = Table('TYPE', 'FEATURE', 'VALUE')
    table.extend(sorted(features))
    print(table.render(tablefmt='simple'))
예제 #3
0
파일: __main__.py 프로젝트: Anaphory/pycldf
def stats(args):
    """
    cldf stats <DATASET>

    Print basic stats for CLDF dataset <DATASET>, where <DATASET> may be the path to
    - a CLDF metadata file
    - a CLDF core data file
    """
    ds = _get_dataset(args)
    print(ds)
    md = Table('key', 'value')
    md.extend(ds.properties.items())
    print(md.render(condensed=False, tablefmt=None))
    print()
    t = Table('Path', 'Type', 'Rows')
    for p, type_, r in ds.stats():
        t.append([p, type_, r])
    print(t.render(condensed=False, tablefmt=None))
예제 #4
0
def stats(args):
    """
    cldf stats <DATASET>

    Print basic stats for CLDF dataset <DATASET>, where <DATASET> may be the path to
    - a CLDF metadata file
    - a CLDF core data file
    """
    ds = _get_dataset(args)
    print(ds)
    md = Table('key', 'value')
    md.extend(ds.properties.items())
    print(md.render(condensed=False, tablefmt=None))
    print()
    t = Table('Path', 'Type', 'Rows')
    for p, type_, r in ds.stats():
        t.append([p, type_, r])
    print(t.render(condensed=False, tablefmt=None))
예제 #5
0
def update(newbib, bibfile, log):  # pragma: no cover
    bibtool(newbib)
    stats = Counter()

    def fix_entry_type(entry):
        type_ = entry.type.lower()
        type_map = {
            'thesis': 'phdthesis',
            'mvreference': 'misc',
            'mvbook': 'book',
            'bookinbook': 'book',
            'report': 'techreport',
        }
        entry.type = type_map.get(type_, type_)
        stats.update([entry.type])

    bibfile.update(newbib, log=log)
    bibfile.visit(fix_entry_type)
    bibfile.check(log)
    res = Table('entry type', '#')
    res.extend(list(stats.most_common()))
    res.append(['TOTAL', sum(stats.values())])
    print('\n' + res.render(tablefmt='simple'))