Initial checkin of new API implementation
[plcapi.git] / PLC / Parameter.py
1 #
2 # Shared type definitions
3 #
4 # Mark Huang <mlhuang@cs.princeton.edu>
5 # Copyright (C) 2006 The Trustees of Princeton University
6 #
7 # $Id$
8 #
9
10 class Parameter:
11     """
12     Typed value wrapper. Use in accepts and returns to document method
13     parameters. Set the optional and default attributes for
14     sub-parameters (i.e., dict fields).
15     """
16
17     def __init__(self, type, doc = "", optional = True, default = None):
18         (self.type, self.doc, self.optional, self.default) = \
19                     (type, doc, optional, default)
20
21     def __repr__(self):
22         return repr(self.type)
23
24 class Mixed(tuple):
25     """
26     A list (technically, a tuple) of types. Use in accepts and returns
27     to document method parameters that may return mixed types.
28     """
29
30     def __new__(cls, *types):
31         return tuple.__new__(cls, types)