def main(): usage = "Usage: %prog [options] root [features]" parser = OptionParser(usage=usage) parser.add_option('-f', '--file', dest='file', default='pieman.yaml', help='path to a YAML file which describes the target ' 'image') (options, args) = parser.parse_args() if len(args) < 1: fail('{} must take at least one argument'.format(sys.argv[0])) if not os.path.isfile(options.file): fail('{} does not exist'.format(options.file)) attributes_list = attrs.AttributesList(options.file) try: attr = attributes_list.get_attribute(args) except attrs.RootDoesNotExist: fail('There is no root named {}'.format(args[0])) except attrs.AttributeDoesNotExist as e: fail(str(e)) except attrs.UnknownAttribute: fail('{} attribute is unknown'.format(args[-1])) try: attr.echo() except attrs.UnprintableType: fail('{} attribute is not supposed to be printed'.format(args[-1]))
def main(): """The main entry point. """ parser = ArgumentParser() parser.add_argument('-f', '--file', dest='file', default='pieman.yaml', help='path to a YAML file which describes the target ' 'image') parser.add_argument('root', nargs='*') args = parser.parse_args() if not os.path.isfile(args.file): fail('{} does not exist'.format(args.file)) attributes_list = attrs.AttributesList(args.file) try: attr = attributes_list.get_attribute(args.root) except attrs.RootDoesNotExist: fail('There is no root named {}'.format(args.root)) except attrs.AttributeDoesNotExist as exc: fail(str(exc)) except attrs.UnknownAttribute: fail('{} attribute is unknown'.format(args.root[-1])) try: attr.echo() except attrs.UnprintableType: fail('{} attribute is not supposed to be printed'.format( args.root[-1]))
def __init__(self, *args, **kwargs): super(AttrsTestCase, self).__init__(*args, **kwargs) current_mod = sys.modules[__name__] test_path = dirname(abspath(current_mod.__file__)) pieman_yml = '{}/{}'.format(test_path, 'pieman.yml') self._attrs_list = attrs.AttributesList(pieman_yml) self._old_stdout = sys.stdout self._new_stdout = StringIO()
def main(): """The main entry point. """ parser = ArgumentParser() parser.add_argument('root', nargs='*') args = parser.parse_args() attributes_list = attrs.AttributesList(sys.stdin) try: attr = attributes_list.get_attribute(args.root) except attrs.RootDoesNotExist: fail('There is no root named {}'.format(args.root)) except attrs.AttributeDoesNotExist as exc: fail(str(exc)) except attrs.UnknownAttribute: fail('{} attribute is unknown'.format(args.root[-1])) try: attr.echo() except attrs.UnprintableType: fail('{} attribute is not supposed to be printed'.format( args.root[-1]))