예제 #1
0
def register(parser):
    parser.add_argument('--cfg-path',
                        default='datasette_metadata.json',
                        type=PathType(type='file', must_exist=False))
    parser.add_argument('--db-path',
                        default=None,
                        type=PathType(type='file', must_exist=False))
    parser.add_argument(
        'dataset',
        help='specify dataset(s) by metadata file, Zenodo DOI or python module'
    )
    parser.add_argument('--entry-point', help=argparse.SUPPRESS, default=None)
예제 #2
0
def register(parser):
    parser.add_argument(
        '--mimetype',
        choices=['wav', 'ogg', 'mp3'],
        default=None,
    )
    parser.add_argument(
        '-l',
        '--list',
        help="List available mimetypes and file number and size",
        action='store_true',
        default=False,
    )
    parser.add_argument('--out',
                        help="Directory to which to download the audio files.",
                        type=PathType(type='dir'),
                        default=pathlib.Path('.'))
    parser.add_argument(
        '--create-release',
        help=
        "Switch to create {id}_audio directory containing audio.zip, README.md and .zenodo.json for releasing on zenodo.",
        action='store_true',
        default=False,
    )
    parser.add_argument(
        '--update-zenodo',
        help="Deposit ID to update metadata by using {id}_audio/zendo.json.",
        required=False,
        default=None,
    )
예제 #3
0
def register(parser):
    """
    Register command options and arguments.

    :param parser: and `argparse.ArgumentParser`instance.
    """
    # Standard catalogs can be "requested" as follows:
    add_catalog_spec(parser, 'clts')

    # Require a dataset as argument for the command:
    add_dataset_spec(parser)

    # Add a flag (i.e. a boolean option):
    parser.add_argument(
        '--strict',
        action='store_true',
        default=False,
        help='do stuff in a strict way',
    )

    # Add another argument:
    parser.add_argument(
        'input_file',
        type=PathType(type='file'),
        help='some input from a file',
    )
예제 #4
0
def register(parser):
    parser.add_argument('path', nargs='+', type=PathType(type='file'))
    parser.add_argument(
        '--encoding',
        default='cp1252',
        choices=['cp1252', 'macroman', 'mixed'],
    )
예제 #5
0
def register(parser):
    parser.add_argument(
        'outdir',
        type=PathType(must_exist=False, type='dir'),
        help=
        "Output directory. The last path segment will be used as default value for the"
        "'directory_name' variable.")
    parser.add_argument(
        'variables',
        nargs='*',
        type=kv,
        help=
        "If run non-interactively, defaults for the template variables can be passed in"
        "as 'key=value'-formatted arguments",
    )
    parser.add_argument(
        '-f',
        '--force',
        default=False,
        help="Overwrite an existing project directory",
        action='store_true',
    )
    parser.add_argument(
        '--quiet',
        default=False,
        help=
        "Run non-interactively, i.e. do not prompt for template variable input.",
        action='store_true',
    )
예제 #6
0
def main(args=None, catch_all=False, parsed_args=None, log=None):
    parser, subparsers = get_parser_and_subparsers('acc')
    parser.add_argument('--repos',
                        default='.',
                        type=PathType(type='dir'),
                        help='acc-data')
    register_subcommands(subparsers, pyacc.commands)

    args = parsed_args or parser.parse_args(args=args)

    if not hasattr(args, "main"):
        parser.print_help()
        return 1

    with contextlib.ExitStack() as stack:
        args.api = ACC(args.repos)
        if not log:  # pragma: no cover
            stack.enter_context(Logging(args.log, level=args.log_level))
        else:
            args.log = log
        try:
            return args.main(args) or 0
        except KeyboardInterrupt:  # pragma: no cover
            return 0
        except ParserError as e:
            print(e)
            return main([args._command, '-h'])
        except Exception as e:  # pragma: no cover
            if catch_all:
                print(e)
                return 1
            raise
예제 #7
0
def main(args=None, catch_all=False, parsed_args=None, log=None):
    parser, subparsers = get_parser_and_subparsers('georoc')
    parser.add_argument('--repos',
                        type=PathType(type='dir'),
                        default=pathlib.Path('.'),
                        help='Location of the data repository')
    register_subcommands(subparsers, pygeoroc.commands)

    args = parsed_args or parser.parse_args(args=args)

    if not hasattr(args, "main"):  # pragma: no cover
        parser.print_help()
        return 1

    with contextlib.ExitStack() as stack:
        if not log:  # pragma: no cover
            stack.enter_context(Logging(args.log, level=args.log_level))
        else:
            args.log = log
        args.repos = GEOROC(args.repos)
        try:
            return args.main(args) or 0
        except KeyboardInterrupt:  # pragma: no cover
            return 0
        except Exception as e:  # pragma: no cover
            if catch_all:
                print(e)
                return 1
            raise
예제 #8
0
파일: initdb.py 프로젝트: marctang/clld
def register(parser):
    parser.add_argument(
        "config-uri",
        action=BootstrappedAppConfig,
        help="ini file providing app config",
    )
    parser.add_argument(
        '--prime-cache-only',
        action='store_true',
        default=False,
    )
    parser.add_argument(
        '--cldf',
        type=PathType(type='file'),
        default=None,
    )
    for name in ['concepticon', 'glottolog']:
        parser.add_argument(
            '--' + name,
            metavar=name.upper(),
            help='Path to repository clone of {0} data'.format(name.capitalize()),
            default=None)
        parser.add_argument(
            '--{0}-version'.format(name),
            help='Version of {0} data to checkout'.format(name.capitalize()),
            default=None)
예제 #9
0
def add_corpus(parser):
    parser.add_argument(
        'dataset',
        type=PathType(type='file', must_exist=False),
        help=
        "Either a CLDF dataset specified by its metadata file or a CLDF ExampleTable"
        "as CSV file or '-' to read from <stdin>.")
예제 #10
0
def register(parser):
    parser.add_argument('doi')
    parser.add_argument(
        '--directory',
        type=PathType(type='dir', must_exist=False),
        default=pathlib.Path('.'),
    )
예제 #11
0
def register(parser):
    parser.add_argument('bib',
                        type=PathType(type='file'),
                        help='path to updated benjamins.bib')
    parser.add_argument('--bibkey',
                        default='benjamins.bib',
                        help=argparse.SUPPRESS)
예제 #12
0
def add_output_dir(parser):
    parser.add_argument(
        '--output',
        help='An existing directory for the output',
        type=PathType(type='dir'),
        default=pathlib.Path('.'),
    )
예제 #13
0
def main(args=None, catch_all=False, parsed_args=None):
    try:  # pragma: no cover
        repos = Config.from_file().get_clone('concepticon')
    except KeyError:  # pragma: no cover
        repos = pathlib.Path('.')

    parser, subparsers = get_parser_and_subparsers('norare')
    parser.add_argument('--repos',
                        help="clone of concepticon/concepticon-data",
                        default=repos,
                        type=PathType(type='dir'))
    parser.add_argument(
        '--repos-version',
        help="version of repository data. Requires a git clone!",
        default=None)
    parser.add_argument('--norarepo',
                        default=pathlib.Path('.'),
                        type=PathType(type='dir'))

    register_subcommands(subparsers, pynorare.commands)

    args = parsed_args or parser.parse_args(args=args)
    if not hasattr(args, "main"):  # pragma: no cover
        parser.print_help()
        return 1

    with contextlib.ExitStack() as stack:
        stack.enter_context(Logging(args.log, level=args.log_level))
        if args.repos_version:  # pragma: no cover
            # If a specific version of the data is to be used, we make
            # use of a Catalog as context manager:
            stack.enter_context(Catalog(args.repos, tag=args.repos_version))
        args.repos = Concepticon(args.repos)
        args.api = NoRaRe(args.norarepo, concepticon=args.repos)
        args.log.info('norare at {0}'.format(args.repos.repos))
        try:
            return args.main(args) or 0
        except KeyboardInterrupt:  # pragma: no cover
            return 0
        except ParserError as e:  # pragma: no cover
            print(e)
            return main([args._command, '-h'])
        except Exception as e:  # pragma: no cover
            if catch_all:  # pragma: no cover
                print(e)
                return 1
            raise
예제 #14
0
def add_dataset(parser):
    parser.add_argument(
        'dataset',
        metavar='DATASET',
        help=
        "Dataset specification (i.e. path to a CLDF metadata file or to the data file)",
        type=PathType(type='file'),
    )
예제 #15
0
def register(parser):
    parser.add_argument(
        'glottolog',
        metavar='GLOTTOLOG',
        help="clone of glottolog/glottolog",
        type=PathType(type='dir'),
    )
    parser.add_argument(
        'glottolog_version',
        help="tag to checkout glottolog/glottolog to",
    )
    parser.add_argument('--cldf-repos',
                        help="clone of d-place/dplace-cldf",
                        default='../dplace-cldf',
                        type=PathType(type='dir'))
    parser.add_argument('--dev', action='store_true', default=False)
    parser.add_argument('--fix-code-id', action='store_true', default=False)
예제 #16
0
def register(parser):
    parser.add_argument(
        'path',
        type=PathType(),
        help=
        "Path to file or directory to create CDSTAR object(s) for. When PATH is a file, "
        "a single object (possibly with multiple bitstreams) is created; when PATH is a "
        "directory, an object will be created for each file in the directory "
        "(recursing into subdirectories).",
        metavar='PATH')
예제 #17
0
def register(parser):
    parser.add_argument(
        'filename',
        metavar='SHEET',
        help=
        "Path of a specific TSV file to check or substring of a filename (e.g. a glottocode)",
        default=None,
        type=PathType(type='file', must_exist=False),
    )
    add_wiki_repos(parser)
예제 #18
0
def add_database(parser, must_exist=True):
    add_dataset(parser)
    parser.add_argument(
        'db',
        metavar='SQLITE_DB_PATH',
        help='Path to the SQLite db file',
        type=PathType(type='file', must_exist=must_exist),
    )
    parser.add_argument('--infer-primary-keys',
                        action='store_true',
                        default=False)
예제 #19
0
def register(parser):
    add_testable(parser)
    parser.add_argument(
        'datasets',
        type=lambda s:
        (get_dataset(PathType(must_exist=True, type='file')
                     (s.split('#')[0])), s.partition('#')[2] or None),
        nargs='+',
    )
    parser.add_argument('-l',
                        '--list',
                        help='list templates',
                        default=False,
                        action='store_true')
    parser.add_argument('--text-string', default=None)
    parser.add_argument('--text-file',
                        type=PathType(type='file', must_exist=True),
                        default=None)
    parser.add_argument('--templates', type=PathType(type='dir'), default=None)
    parser.add_argument('--output',
                        type=PathType(type='file', must_exist=False),
                        default=None)
예제 #20
0
def register(parser):
    add_output_dir(parser)
    parser.add_argument(
        '--glottocodes',
        help='File listing Glottocodes the map should be restricted to',
        type=PathType(type='file'),
        default=None,
    )
    parser.add_argument(
        '--min-langs-for-legend',
        help='minimum number of languages in a family for a map legend entry',
        type=int,
        default=10,
    )
예제 #21
0
def register(parser):
    parser.add_argument(
        '--filename',
        help="Path of a specific TSV file to check",
        default=None,
        type=PathType(type='file'),
    )
    parser.add_argument(
        '--report',
        help="Path of TSV file, to which results will be written.",
        default=None,
    )
    parser.add_argument(
        '--verbose',
        default=False,
        action='store_true',
    )
예제 #22
0
def register(parser):
    add_output_dir(parser)
    parser.add_argument(
        '--glottocodes',
        help='File listing Glottocodes the map should be restricted to',
        type=PathType(type='file'),
        default=None,
    )
    parser.add_argument(
        '--min-langs-for-legend',
        help='minimum number of languages in a family for a map legend entry',
        type=int,
        default=10,
    )
    parser.add_argument(
        '--open',
        action='store_true',
        default=False,
        help='open the map in a web browser after',
    )
예제 #23
0
def register(parser):
    parser.add_argument('--html',
                        type=PathType(type='file'),
                        default=pathlib.Path('.') / '..' / '..' / '..' /
                        'glottobank.github.io' / 'people.html')
예제 #24
0
def register(parser):
    parser.add_argument('-f', '--force', default=False, action='store_true')
    parser.add_argument('--dump-schema', default=False, action='store_true')
    parser.add_argument('--archive', type=PathType(type='dir'))
예제 #25
0
def register(parser):
    parser.add_argument('path', nargs='+', type=PathType(type='file'))
예제 #26
0
def register(parser):
    parser.add_argument('bib',
                        type=PathType(type='file'),
                        help='path to downloaded evobib-converted.bib')
예제 #27
0
def register(parser):
    add_testable(parser)
    add_dataset(parser)
    add_catalog_spec(parser, 'glottolog')
    add_listvalued(
        parser,
        '--parameters',
        help=
        "Comma-separated Parameter IDs, specifying the values to plot on the map. If not "
        "specified, all languages in the dataset will be plotted.",
    )
    add_listvalued(
        parser,
        '--colormaps',
        help=
        "Comma-separated names of colormaps to use for the respective parameter. Choose from "
        "{} for categorical and from {} for continuous parameters."
        "".format(join_quoted(COLORMAPS[CATEGORICAL]),
                  join_quoted(COLORMAPS[CONTINUOUS])),
    )
    add_listvalued(
        parser,
        '--language-properties',
        help=
        "Comma-separated language properties, i.e. columns in the dataset's LanguageTable "
        "to plot on the map.",
    )
    add_listvalued(
        parser,
        '--language-properties-colormaps',
        help=
        "Comma-separated names of colormap to use for the respective language properties. "
        "See help for --colormaps for choices",
    )
    parser.add_argument(
        '--output',
        type=PathType(type='file', must_exist=False),
        help=
        "Filesystem path to write the resulting map to. If no suffix is specified, it will "
        "be appended according to FORMAT; if given, suffix must match FORMAT.",
        default=pathlib.Path('map'))
    parser.add_argument(
        '--format',
        default='html',
        metavar='FORMAT',
        choices=list(FORMATS),
    )
    parser.add_argument(
        '--markersize',
        help="Size of map markers in pixels",
        type=int,
        default=10,
    )
    parser.add_argument(
        '--marker-factory',
        help=
        "A python module providing a subclass of `cldfviz.map.MarkerFactory`.",
        default=None,
    )
    parser.add_argument(
        '--title',
        default=None,
        help="Title for the map plot",
    )
    parser.add_argument(
        '--pacific-centered',
        action='store_true',
        default=False,
        help=
        "Center maps of the whole world at the pacific, thus not cutting large language "
        "families in half.")
    parser.add_argument(
        '--language-labels',
        action='store_true',
        default=False,
        help="Display language names on the map",
    )
    parser.add_argument(
        '--missing-value',
        default=None,
        help=
        "A color used to indicate missing values. If not specified missing values will be "
        "omitted.",
    )
    parser.add_argument(
        '--no-legend',
        action='store_true',
        default=False,
        help=
        "Don't add a legend to the map (e.g. because it would be too big).",
    )

    for cls in Map.__subclasses__():
        cls.add_options(parser,
                        help_suffix='(Only for FORMATs {})'.format(
                            join_quoted(cls.__formats__)))
예제 #28
0
def register(parser):
    add_dataset_spec(parser, multiple=True)
    parser.add_argument(
        '-m',
        '--mimetype',
        help=
        'Comma-separated list of desired mimetypes/extensions/classes; default {all}',
        default=None,
    )
    parser.add_argument(
        '-l',
        '--list',
        help='List available mimetypes and file number and size',
        action='store_true',
        default=False,
    )
    parser.add_argument(
        '-o',
        '--out',
        help=
        'Directory to which to download the media files and to create the to be released '
        'data.',
        type=PathType(type='dir'),
        default=pathlib.Path('.'))
    parser.add_argument(
        '-c',
        '--communities',
        default='',
        help=
        'Comma-separated list of communities to which the dataset should be submitted',
    )
    parser.add_argument(
        '-p',
        '--parent-doi',
        default='',
        help=
        'DOI to which this release refers (format 10.5281/zenodo.1234567). It is required '
        'for --create-release.',
    )
    parser.add_argument(
        '--create-release',
        help=
        'Switch to create ID_{0} directory containing {0}.zip, README.md and {1} for '
        'releasing on zenodo. Cannot be used with --update-zenodo.'.format(
            MEDIA, ZENODO_FILE_NAME),  # noqa: E122
        action='store_true',
        default=False,
    )
    parser.add_argument(
        '--update-zenodo',
        help=
        "Deposit ID (number after DOI's last slash) to update metadata by using ID_{0}/{1}. "
        "Cannot be used with --create-release.".format(
            MEDIA, ZENODO_FILE_NAME),  # noqa: E122
        default=None,
    )
    parser.add_argument(
        '--debug',
        help=
        'Switch to work with max. 500 media files and with sandbox.zenodo for testing ONLY',
        action='store_true',
        default=False,
    )
예제 #29
0
def register(parser):
    parser.add_argument(
        '--output',
        help=argparse.SUPPRESS,
        type=PathType(type='file', must_exist=False),
        default=None)
예제 #30
0
def register(parser):
    parser.add_argument('sheet', type=PathType(type='file'))