Added support for private GitHub repos

Implements: blueprint support-private-github-repos
Closes-Bug: 1319604
Change-Id: I6f0181a59165e5ab7e0b2d38aab07c8b06ec7462
This commit is contained in:
Ravi Sankar Penta
2014-06-09 16:05:59 -07:00
parent 3c3a51ede6
commit e640ec3943
32 changed files with 637 additions and 140 deletions

View File

@@ -80,3 +80,29 @@ class Base(wtypes.Base):
for k in keys
if hasattr(self, k) and
getattr(self, k) != wsme.Unset)
class MultiType(wtypes.UserType):
"""A complex type that represents one or more types.
Used for validating that a value is an instance of one of the types.
:param *types: Variable-length list of types.
"""
def __init__(self, *types):
self.types = types
def __str__(self):
return ' | '.join(map(str, self.types))
def validate(self, value):
for t in self.types:
if t is wsme.types.text and isinstance(value, wsme.types.bytes):
value = value.decode()
if isinstance(value, t):
return value
else:
raise ValueError(
_("Wrong type. Expected '%(type)s', got '%(value)s'")
% {'type': self.types, 'value': type(value)})