Example #1
0
class DefaultArgsParser:
    def __init__(self, description):
        self.parser = ArgumentParser(description=description)

        self.parser.add_argument('-u', '--url', dest='fc_url', action='store', required=False,
                            help='If set, this will override which api is used (default is https://api.firecloud.org/api)')

    def __getattr__(self, attr):
        return self.parser.__getattribute__(attr)

    def parse_args(self):
        args = self.parser.parse_args()

        if args.fc_url:
            set_fc_url(args.fc_url)
        return args
Example #2
0
def parse_args():
    r""" Parse the command line arguments """
    args = ArgumentParser()
    args.add_argument("train",
                      help="Path from where to read the training file")
    args.add_argument("test", help="Path from where to read the test file")
    args.add_argument("out", help="Path write the generated labels")
    args.add_argument("--smooth",
                      help="Perform add-1 smoothing",
                      action="store_true")
    args = args.parse_args()

    for fld in ["train", "test"]:
        path = Path(args.__getattribute__(fld))
        if not path.is_file(): raise ValueError(f"Unknown {fld} file {path}")
        args.__setattr__(fld, path)
    args.out = Path(args.out)
    if args.out.exists() and not args.out.is_file():
        raise ValueError(
            f"Out file \"{args.out}\" appears not to be a file.  Cannot overwrite"
        )
    return args