Revision 2c9fa1ff lib/ht.py
b/lib/ht.py | ||
---|---|---|
1 | 1 |
# |
2 | 2 |
# |
3 | 3 |
|
4 |
# Copyright (C) 2010, 2011 Google Inc. |
|
4 |
# Copyright (C) 2010, 2011, 2012 Google Inc.
|
|
5 | 5 |
# |
6 | 6 |
# This program is free software; you can redistribute it and/or modify |
7 | 7 |
# it under the terms of the GNU General Public License as published by |
... | ... | |
318 | 318 |
#: Maybe a dictionary (dict or None) |
319 | 319 |
TMaybeDict = TOr(TDict, TNone) |
320 | 320 |
|
321 |
#: a positive integer |
|
321 |
#: a non-negative integer (value >= 0) |
|
322 |
TNonNegativeInt = \ |
|
323 |
TAnd(TInt, WithDesc("EqualOrGreaterThanZero")(lambda v: v >= 0)) |
|
324 |
|
|
325 |
#: a positive integer (value > 0) |
|
322 | 326 |
TPositiveInt = \ |
323 |
TAnd(TInt, WithDesc("EqualGreaterZero")(lambda v: v >= 0))
|
|
327 |
TAnd(TInt, WithDesc("GreaterThanZero")(lambda v: v > 0))
|
|
324 | 328 |
|
325 | 329 |
#: a maybe positive integer (positive integer or None) |
326 | 330 |
TMaybePositiveInt = TOr(TPositiveInt, TNone) |
327 | 331 |
|
328 |
#: a strictly positive integer |
|
329 |
TStrictPositiveInt = \ |
|
330 |
TAnd(TInt, WithDesc("GreaterThanZero")(lambda v: v > 0)) |
|
331 |
|
|
332 |
#: a maybe strictly positive integer (strictly positive integer or None) |
|
333 |
TMaybeStrictPositiveInt = TOr(TStrictPositiveInt, TNone) |
|
334 |
|
|
335 |
#: a strictly negative integer (0 > value) |
|
336 |
TStrictNegativeInt = \ |
|
332 |
#: a negative integer (value < 0) |
|
333 |
TNegativeInt = \ |
|
337 | 334 |
TAnd(TInt, WithDesc("LessThanZero")(compat.partial(operator.gt, 0))) |
338 | 335 |
|
339 | 336 |
#: a positive float |
340 |
TPositiveFloat = \
|
|
341 |
TAnd(TFloat, WithDesc("EqualGreaterZero")(lambda v: v >= 0.0))
|
|
337 |
TNonNegativeFloat = \
|
|
338 |
TAnd(TFloat, WithDesc("EqualOrGreaterThanZero")(lambda v: v >= 0.0))
|
|
342 | 339 |
|
343 | 340 |
#: Job ID |
344 |
TJobId = WithDesc("JobId")(TOr(TPositiveInt,
|
|
341 |
TJobId = WithDesc("JobId")(TOr(TNonNegativeInt,
|
|
345 | 342 |
TRegex(re.compile("^%s$" % |
346 | 343 |
constants.JOB_ID_TEMPLATE)))) |
347 | 344 |
|
... | ... | |
349 | 346 |
TNumber = TOr(TInt, TFloat) |
350 | 347 |
|
351 | 348 |
#: Relative job ID |
352 |
TRelativeJobId = WithDesc("RelativeJobId")(TStrictNegativeInt)
|
|
349 |
TRelativeJobId = WithDesc("RelativeJobId")(TNegativeInt) |
|
353 | 350 |
|
354 | 351 |
|
355 | 352 |
def TInstanceOf(my_inst): |
Also available in: Unified diff