9 SINGLE, INTERVAL, UNIVERSAL = range(3)
86 return self.
type == INTERVAL
88 return self.
type == SINGLE
89 def isUniversal(self):
90 return self.
type == UNIVERSAL
95 if(self.
type == SINGLE):
96 return i == self.singleton
97 elif(self.
type == INTERVAL):
100 elif(self.
type == UNIVERSAL):
108 if(self.
type == SINGLE):
109 if(lower <= self.
single <= upper):
111 elif(self.
type == INTERVAL):
113 for i
in range(max(a,lower),min(upper,b)+1):
116 for i
in range(lower,upper+1):
122 if(self.
type == SINGLE):
124 elif(self.
type == INTERVAL):
126 for i
in range(a,b+1):
134 if(self.
type == SINGLE):
135 return self.singleton
136 elif(self.
type == INTERVAL):
144 if(self.
type == SINGLE):
145 return self.singleton
146 elif(self.
type == INTERVAL):
154 if(self.
type == SINGLE):
155 return (self.singleton,self.singleton)
156 elif(self.
type == INTERVAL):
162 if(self.
type == SINGLE):
163 return "[ " + repr(self.singleton) +
"]"
164 elif(self.
type == INTERVAL):
166 return "[ " + repr(a) +
".." + repr(b) +
"]"
167 elif(self.
type == UNIVERSAL):
170 class RangeType(object):
171 def __init__(self,type=int):
173 def __call__(self, string):
174 x = string.split(
"..")
176 return Range.interval((self.
type(x[0]),self.
type(x[1])))
178 return Range.single(self.
type(x[0]))
180 raise argparse.ArgumentTypeError(
"Invalid range '%s' valid range should be like '1..2'" % string)