def __init__(self, jsons, paths):
     len_jsons = len(jsons) if isinstance(jsons, list) else None
     len_paths = len(paths) if isinstance(paths, list) else None
     msg = fmt(
         'len(jsons) -> {len_jsons} != len(paths) -> {len_paths}; jsons={jsons}, paths={paths}'
     )
     super(JsonsDontMatchPathsError, self).__init__(msg)
Пример #2
0
def add_cr():
    parser = ArgumentParser(add_help=False)

    parser.add_argument(
        '--version',
        action='version',
        version='change-request ' + version)
    parser.add_argument(
        '--debug',
        action='store_true',
        help='default="%(default)s"; toggle debug mode on')
    parser.add_argument(
        '--verbose',
        action='store_true',
        help='default="%(default)s"; toggle verbose mode on')
    parser.add_argument(
        '--config',
        metavar='FILEPATH',
        default=[
            fmt('~/.config/{PROJ}/{PROJ}.yml'),
            fmt('{CWD}/{PROJ}.yml'),
        ],
        help='default="%(default)s"; config filepath')
    parser.add_argument(
        '-O', '--output',
        metavar='OUPUT',
        default=default_output(),
        choices=OUTPUT,
        help='default="%(default)s"; set the output type; choices=[%(choices)s]')
    parser.add_argument(
        '--api-url',
        metavar='URL',
        help='default="%(default)s"; the REST api endpoint url')

    template_group = parser\
        .add_argument_group(title='template options')\
        .add_mutually_exclusive_group(required=False)
    template_group.add_argument(
        '-F', '--template-file',
        metavar='FILE',
        help='path to template file')
    template_group.add_argument(
        '-N', '--template-name',
        metavar='NAME',
        help='name of template stored on server')

    return parser
Пример #3
0
 def __init__(self, stop, start):
     msg = fmt('error: planned-stop {stop} is before planned-start {start}')
     super(PlannedStopBeforeStartError, self).__init__(msg)
Пример #4
0
 def __init__(self, start):
     msg = fmt('error: planned-start {start} is in the past')
     super(PlannedStartInPastError, self).__init__(msg)
Пример #5
0
 def __init__(self, string, utcnow):
     msg = fmt('future peer_review_date={string} before utcnow={utcnow} not allowed')
     super(FuturePeerReviewError, self).__init__(msg)
Пример #6
0
 def __init__(self, string):
     msg = fmt('the string={string} could not be converted to ISO_8601')
     super(DateParseError, self).__init__(msg)
Пример #7
0
def add_create(subparsers, *defaults):
    parser = subparsers.add_parser(
        'create',
        description=FRIENDLY_TIMEDELTA)
    parser.add_argument(
        'planned_start_date',
        metavar='planned-start',
        nargs='?',
        default='utcnow',
        action=PlannedStart,
        help='default="%(default)s"; ' + fmt(DATETIME_OR_TIMEDELTA, anchor='utcnow', example='+4h15m OR 2020-1-16T12:30:00Z'))
    parser.add_argument(
        'planned_stop_date',
        metavar='planned-stop',
        action=PlannedStop,
        help=fmt(DATETIME_OR_TIMEDELTA, anchor='planned-start', example='+2w3d8h OR 2056-10-30T7:58:13Z'))

    required_group = parser.add_argument_group(title='questionnaire required')
    required_group.add_argument(
        '-C', '--change-plan',
        metavar='PLAN',
        default=required,
        help='enter in text regarding the change plan if it is applicable')
    required_group.add_argument(
        '-D', '--short-description',
        metavar='DESC',
        default=required,
        help='enter in text regarding the short description if it is applicable')
    required_group.add_argument(
        '-B', '--business-impact',
        metavar='IMPACT',
        default=required,
        choices=BUSINESS_IMPACT,
        help='choose the business impact from [%(choices)s]')
    required_group.add_argument(
        '-I', '--change-impact',
        metavar='IMPACT',
        default=required,
        choices=CHANGE_IMPACT,
        help='choose the impact from [%(choices)s]')
    required_group.add_argument(
        '-u', '--user-impact',
        metavar='IMPACT',
        default=required,
        choices=USER_IMPACT,
        help='choose the user-impact from [%(choices)s]')
    required_group.add_argument(
        '-s', '--security-risk',
        metavar='LEVEL',
        default=required,
        choices=SECURITY_RISK,
        help='choose the security risk level from [%(choices)s]')
    required_group.add_argument(
        '-f', '--change-frequency',
        metavar='FREQ',
        default=required,
        choices=CHANGE_FREQUENCY,
        help='choose the change frequency from [%(choices)s]')

    optional_group = parser.add_argument_group(title='questionnaire optional')
    optional_group.add_argument(
        '-t', '--test-plan',
        metavar='PLAN',
        help='enter in text regarding the test plan if it is applicable')
    optional_group.add_argument(
        '-p', '--post-implementation-plan',
        metavar='PLAN',
        help='enter in text regarding the post implementation plan, if applicable')
    optional_group.add_argument(
        '-e', '--customer-end-user-plan',
        metavar='PLAN',
        help='enter in text regarding the customer / end-user plan, if applicable')
    optional_group.add_argument(
        '-r', '--rollback-procedure',
        metavar='PROC',
        help='enter in text regarding the rollback procedure')
    optional_group.add_argument(
        '-R', '--peer-review-date',
        metavar='DATE',
        action=PeerReviewDate,
        help='enter peer-review date (ISO_8601), if applicable')
    optional_group.add_argument(
        '-v', '--vendor-name',
        metavar='NAME',
        help='enter the vendor name, if applicable')
    optional_group.add_argument(
        '-d', '--planned-downtime',
        action='store_true',
        help='default="%(default)s"; toggle if previous change was successfully performed in downtime window')

    for d in defaults:
        parser.set_defaults(**d)
    return parser
 def __init__(self, path_or_paths):
     msg = fmt('error with ChangeRequest param path(s) = {path_or_paths}')
     super(ChangeRequestPathError, self).__init__(msg)