Example #1
0
def test_cmd_error():
    from clldutils.clilib import ArgumentParser

    def cmd(args):
        raise ValueError

    parser = ArgumentParser('pkg', cmd)
    with pytest.raises(ValueError):
        parser.main(args=['cmd'])

    assert parser.main(args=['cmd'], catch_all=True) == 1
Example #2
0
    def test_cmd_error(self):
        from clldutils.clilib import ArgumentParser

        def cmd(args):
            raise ValueError

        parser = ArgumentParser('pkg', cmd)
        with self.assertRaises(ValueError):
            parser.main(args=['cmd'])

        self.assertEqual(parser.main(args=['cmd'], catch_all=True), 1)
Example #3
0
    def test_ArgumentParser(self):
        from clldutils.clilib import ArgumentParser, ParserError

        def cmd(args):
            """
            docstring
            """
            if len(args.args) < 1:
                raise ParserError('not enough arguments')
            print(args.args[0])

        parser = ArgumentParser('pkg', cmd)

        with capture(parser.main, args=['help', 'cmd']) as out:
            self.assertIn('docstring', out)

        with capture(parser.main, args=['cmd', 'arg']) as out:
            self.assertIn('arg', out)

        self.assertEqual(parser.main(args=['cmd', 'arg']), 0)

        with capture(parser.main, args=['cmd']) as out:
            self.assertIn('not enough arguments', out)

        with capture_all(parser.main, args=['x']) as res:
            self.assertNotEqual(res[0], 0)
            self.assertTrue(res[1].startswith('invalid'))
Example #4
0
def main():
    parser = ArgumentParser('pytsammalex', update_taxa, upload_images,
                            update_distribution)
    parser.add_argument('--tsammalex-data',
                        help="path to tsammalex-data repository",
                        default=Path(pytsammalex.__file__).parent.parent)
    sys.exit(parser.main())
Example #5
0
def main():  # pragma: no cover
    parser = ArgumentParser(
        __name__,
        link,
        stats,
        attributes,
        intersection,
        union,
        upload_sources,
        map_concepts,
        lookup)
    parser.add_argument(
        '--data',
        help="path to concepticon-data",
        default=Path(pyconcepticon.__file__).parent.parent)
    parser.add_argument(
        '--full_search',
        help="select between approximate search (default) and full search",
        default=False,
        action='store_true')
    parser.add_argument(
        '--output',
        help="specify output file",
        default=None)
    parser.add_argument(
        '--similarity',
        help="specify level of similarity for concept mapping",
        default=5,
        type=int)
    parser.add_argument(
        '--language',
        help="specify your desired language for mapping",
        default='en',
        type=text_type)
    sys.exit(parser.main())
Example #6
0
def main():
    parser = ArgumentParser('pygelato', download, ls)
    parser.add_argument('--gelato-repos',
                        help="path to gelato data repository",
                        default=Path(pygelato.__file__).parent.parent)
    parser.add_argument('--glottolog-repos',
                        help="path to glottolog data repository",
                        default=None)
    sys.exit(parser.main())
Example #7
0
def main():  # pragma: no cover
    parser = ArgumentParser('segments')
    parser.add_argument("--encoding", help='input encoding', default="utf8")
    parser.add_argument("--profile",
                        help='path to an orthography profile',
                        default=None)
    parser.add_argument("--mapping",
                        help='column name in ortho profile to map graphemes',
                        default=None)
    sys.exit(parser.main())
Example #8
0
def main():
    parser = ArgumentParser('pylexibank', readme, download, cldf, ls, report,
                            word_length, coverage)
    parser.add_argument('--lexibank-repos',
                        help="path to lexibank data repository",
                        default=Path(pylexibank.__file__).parent.parent)
    parser.add_argument('--glottolog-repos',
                        help="path to glottolog data repository",
                        default=None)
    parser.add_argument('--concepticon-repos',
                        help="path to concepticon data repository",
                        default=None)
    sys.exit(parser.main())
Example #9
0
def main():  # pragma: no cover
    parser = ArgumentParser(
        'pyglottolog',
        monster,
        index,
        tree2lff,
        lff2tree,
        new_languoid,
        recode,
        tree,
        missing_iso,
        check_tree)
    parser.add_argument(
        '--repos', help="path to glottolog data repository", type=Path, default=DATA_DIR)
    sys.exit(parser.main())
Example #10
0
def main():  # pragma: no cover
    parser = ArgumentParser('pyclpa', report, check)
    sys.exit(parser.main())
Example #11
0
    ----------
    args : Namespace
        A Namespace object with an 'args' property, which is a tuple of strings.
        The strings should be valid paths corresponding to resp. the metadata file of
        the Lingpy data set and the CLDF word list.

    Notes
    -----
        When this function is called, a new CLDF wordlist file is generated at
        the output path that is passed, based on the input Lingpy dataset.
    """
    # TODO: Finish this docstring.
    input_file, output_file = args.args
    reader = csv.DictReader(input_file, delimiter="\t")
    for i, row in enumerate(reader):
        if i == 0:
            # FIXME: Refactor 'writer' variable so it cannot be called if it is not defined yet.
            writer = csv.DictWriter(
                output_file,
                delimiter=",",
                fieldnames=[lingpy_to_cldf(c) for c in reader.fieldnames])
            writer.writeheader()
        writer.writerow(
            {lingpy_to_cldf(key): value
             for key, value in row.items()})


if __name__ == "__main__":
    parser = ArgumentParser('lingpycldf', cldf, lingpy)
    sys.exit(parser.main())
Example #12
0
def main():  # pragma: no cover
    parser = ArgumentParser(__name__, link, stats, attributes)
    sys.exit(parser.main())
Example #13
0
def main():  # pragma: no cover
    parser = ArgumentParser('pyclpa', report, check)
    sys.exit(parser.main())
Example #14
0
def main():  # pragma: no cover
    parser = ArgumentParser('multicode')
    sys.exit(parser.main())
Example #15
0
def main():  # pragma: no cover
    parser = ArgumentParser('pycldf', datasets, stats)
    sys.exit(parser.main())