-
Notifications
You must be signed in to change notification settings - Fork 571
/
CommaSeparatedParameter.py
159 lines (129 loc) · 5.54 KB
/
CommaSeparatedParameter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
from typing import Union, List
from cruisecontrolclient.client.CCParameter.Parameter import AbstractParameter
class AbstractCommaSeparatedParameter(AbstractParameter):
def __init__(self, value: Union[str, List[str]]):
# Transform the list into a comma-separated string to store self.value
# in the format that is closest to what cruise-control expects
if type(value) == list:
value = ','.join(value)
AbstractParameter.__init__(self, value)
def validate_value(self):
if type(self.value) != str:
raise ValueError(f"{self.value} is not a string value")
class ApproveParameter(AbstractCommaSeparatedParameter):
"""approve=[id1,id2,...]"""
name = 'approve'
description = "The review IDs to approve"
argparse_properties = {
'args': ('--approve',),
'kwargs': dict(help=description, nargs='+')
}
class BrokerIdParameter(AbstractCommaSeparatedParameter):
"""brokerid=[id1,id2...]"""
name = 'brokerid'
description = 'Comma-separated and/or space-separated list of broker IDs'
argparse_properties = {
'args': ('brokers',),
'kwargs': dict(help=description,
nargs='+')
}
class ClientIdsParameter(AbstractCommaSeparatedParameter):
"""client_ids=[Set-of-ClientIdentity]"""
name = 'client_ids'
description = "The set of Client IDs by which to filter the user_tasks response"
argparse_properties = {
'args': ('--client-id', '--client-ids'),
'kwargs': dict(help=description, nargs='+')
}
class DestinationBrokerIdsParameter(AbstractCommaSeparatedParameter):
"""destination_broker_ids=[id1,id2...]"""
name = 'destination_broker_ids'
description = 'Comma-separated and/or space-separated list of broker IDs'
argparse_properties = {
'args': ('--destination-broker',
'--destination-brokers',
'--destination-broker-id',
'--destination-broker-ids'),
'kwargs': dict(help=description,
nargs='+')
}
class DiscardParameter(AbstractCommaSeparatedParameter):
"""discard=[id1,id2,...]"""
name = 'discard'
description = "The review IDs to discard"
argparse_properties = {
'args': ('--discard',),
'kwargs': dict(help=description, nargs='+')
}
class DropRecentlyDemotedBrokersParameter(AbstractCommaSeparatedParameter):
"""drop_recently_demoted_brokers=[id1,id2...]"""
name = 'drop_recently_demoted_brokers'
description = 'Comma-separated and/or space-separated list of broker IDs'
argparse_properties = {
'args': ('--drop-recently-demoted-broker',
'--drop-recently-demoted-brokers',
'--drop-recently-demoted-broker-id',
'--drop-recently-demoted-brokers-ids'),
'kwargs': dict(help=description,
nargs='+')
}
class DropRecentlyRemovedBrokersParameter(AbstractCommaSeparatedParameter):
"""drop_recently_removed_brokers=[id1,id2...]"""
name = 'drop_recently_removed_brokers'
description = 'Comma-separated and/or space-separated list of broker IDs'
argparse_properties = {
'args': ('--drop-recently-removed-broker',
'--drop-recently-removed-brokers',
'--drop-recently-removed-broker-id',
'--drop-recently-removed-brokers-ids'),
'kwargs': dict(help=description,
nargs='+')
}
class EndpointsParameter(AbstractCommaSeparatedParameter):
"""endpoints=[Set-of-{@link EndPoint}]"""
name = 'endpoints'
description = "The set of Endpoint by which to filter the user_tasks response"
argparse_properties = {
'args': ('--endpoint', '--endpoints'),
'kwargs': dict(help=description, nargs='+')
}
class GoalsParameter(AbstractCommaSeparatedParameter):
"""goals=[goal1,goal2...]"""
name = 'goals'
description = 'Comma-separated and/or space-separated ordered list of goals'
argparse_properties = {
'args': ('--goals',),
'kwargs': dict(help=description, nargs='+')
}
class ReplicaMovementStrategiesParameter(AbstractCommaSeparatedParameter):
"""replica_movement_strategies=[strategy1,strategy2...]"""
name = 'replica_movement_strategies'
description = 'Comma-separated and/or space-separated list of replica movement strategies'
argparse_properties = {
'args': ('--strategies',),
'kwargs': dict(help=description, nargs='+')
}
class ReviewIDsParameter(AbstractCommaSeparatedParameter):
"""review_ids=[id1,id2,...]"""
name = 'review_ids'
description = "The review IDs by which to filter the review_board response"
argparse_properties = {
'args': ('--review-ids', '--review-id', '--reviews', '--review'),
'kwargs': dict(help=description, nargs='+')
}
class TypesParameter(AbstractCommaSeparatedParameter):
"""types=[Set-of-{@link UserTaskManager.TaskState}]"""
name = 'types'
description = "The set of TaskStates by which to filter the user_tasks response"
argparse_properties = {
'args': ('--types', '--type', '--task-states', '--task-state'),
'kwargs': dict(help=description, nargs='+')
}
class UserTaskIdsParameter(AbstractCommaSeparatedParameter):
"""user_task_ids=[Set-of-USER-TASK-IDS]"""
name = 'user_task_ids'
description = "The set of UserTaskIDs by which to filter the user_tasks response"
argparse_properties = {
'args': ('--user-task-ids', '--user-task-id'),
'kwargs': dict(help=description, nargs='+')
}