src/ztfy/utils/interfaces.py
branchZTK-1.1
changeset 173 7164eb24f949
parent 171 0e8925323082
child 174 380f23a1587e
equal deleted inserted replaced
171:0e8925323082 173:7164eb24f949
    40 #
    40 #
    41 
    41 
    42 class IListInfo(Interface):
    42 class IListInfo(Interface):
    43     """Custom interface used to handle list-like components"""
    43     """Custom interface used to handle list-like components"""
    44 
    44 
    45     def count():
    45     def count(self):
    46         """Get list items count"""
    46         """Get list items count"""
    47 
    47 
    48     def index():
    48     def index(self):
    49         """Get position of the given item"""
    49         """Get position of the given item"""
    50 
    50 
    51     def __contains__():
    51     def __contains__(self, value):
    52         """Check if given value is int list"""
    52         """Check if given value is in list"""
    53 
    53 
    54     def __getitem__():
    54     def __getitem__(self, index):
    55         """Return item at given position"""
    55         """Return item at given position"""
    56 
    56 
    57     def __iter__():
    57     def __iter__(self):
    58         """Iterator over list items"""
    58         """Iterator over list items"""
    59 
    59 
    60 
    60 
    61 class IListWriter(Interface):
    61 class IListWriter(Interface):
    62     """Writer interface for list-like components"""
    62     """Writer interface for list-like components"""
    63 
    63 
    64     def append():
    64     def append(self, value):
    65         """Append value to list"""
    65         """Append value to list"""
    66 
    66 
    67     def extend():
    67     def extend(self, values):
    68         """Extend list with given items"""
    68         """Extend list with given items"""
    69 
    69 
    70     def insert():
    70     def insert(self, index, value):
    71         """Insert item to given index"""
    71         """Insert item to given index"""
    72 
    72 
    73     def pop():
    73     def pop(self):
    74         """Pop item from list and returns it"""
    74         """Pop item from list and returns it"""
    75 
    75 
    76     def remove():
    76     def remove(self, value):
    77         """Remove given item from list"""
    77         """Remove given item from list"""
    78 
    78 
    79     def reverse():
    79     def reverse(self):
    80         """Sort list in reverse order"""
    80         """Sort list in reverse order"""
    81 
    81 
    82     def sort():
    82     def sort(self):
    83         """Sort list"""
    83         """Sort list"""
    84 
    84 
    85 
    85 
    86 class IList(IListInfo, IListWriter):
    86 class IList(IListInfo, IListWriter):
    87     """Marker interface for list-like components"""
    87     """Marker interface for list-like components"""
    92 #
    92 #
    93 
    93 
    94 class IDictInfo(Interface):
    94 class IDictInfo(Interface):
    95     """Custom interface used to handle dict-like components"""
    95     """Custom interface used to handle dict-like components"""
    96 
    96 
    97     def keys():
    97     def keys(self):
    98         """Get list of keys for the dict"""
    98         """Get list of keys for the dict"""
    99 
    99 
   100     def has_key(key):
   100     def has_key(self, key):
   101         """Check to know if dict includes the given key"""
   101         """Check to know if dict includes the given key"""
   102 
   102 
   103     def get(key, default=None):
   103     def get(self, key, default=None):
   104         """Get given key or default from dict"""
   104         """Get given key or default from dict"""
   105 
   105 
   106     def copy():
   106     def copy(self,):
   107         """Duplicate content of dict"""
   107         """Duplicate content of dict"""
   108 
   108 
   109     def __contains__(key):
   109     def __contains__(self, key):
   110         """Check if given key is in dict"""
   110         """Check if given key is in dict"""
   111 
   111 
   112     def __getitem__(key):
   112     def __getitem__(self, key):
   113         """Get given key value from dict"""
   113         """Get given key value from dict"""
   114 
   114 
   115     def __iter__():
   115     def __iter__(self):
   116         """Iterator over dictionnary keys"""
   116         """Iterator over dictionnary keys"""
   117 
   117 
   118 
   118 
   119 class IDictWriter(Interface):
   119 class IDictWriter(Interface):
   120     """Writer interface for dict-like components"""
   120     """Writer interface for dict-like components"""
   121 
   121 
   122     def clear():
   122     def clear(self):
   123         """Clear dict"""
   123         """Clear dict"""
   124 
   124 
   125     def update(b):
   125     def update(self, b):
   126         """Update dict with given values"""
   126         """Update dict with given values"""
   127 
   127 
   128     def setdefault(key, failobj=None):
   128     def setdefault(self, key, failobj=None):
   129         """Create value for given key if missing"""
   129         """Create value for given key if missing"""
   130 
   130 
   131     def pop(key, *args):
   131     def pop(self, key, *args):
   132         """Remove and return given key from dict"""
   132         """Remove and return given key from dict"""
   133 
   133 
   134     def popitem():
   134     def popitem(self, item):
   135         """Pop item from dict"""
   135         """Pop item from dict"""
   136 
   136 
   137     def __setitem__(key, value):
   137     def __setitem__(self, key, value):
   138         """Update given key with given value"""
   138         """Update given key with given value"""
   139 
   139 
   140     def __delitem__(key):
   140     def __delitem__(self, key):
   141         """Remove selected key from dict"""
   141         """Remove selected key from dict"""
   142 
   142 
   143 
   143 
   144 class IDict(IDictInfo, IDictWriter):
   144 class IDict(IDictInfo, IDictWriter):
   145     """Marker interface for dict-like components"""
   145     """Marker interface for dict-like components"""
   180                             required=False)
   180                             required=False)
   181 
   181 
   182     def getJSONSettings(self):
   182     def getJSONSettings(self):
   183         """Get ZEO connection setting as a JSON dict"""
   183         """Get ZEO connection setting as a JSON dict"""
   184 
   184 
       
   185     def update(self, values):
       
   186         """Update connection properties from given dict values"""
       
   187 
   185     def getConnection(self, wait=False):
   188     def getConnection(self, wait=False):
   186         """Open ZEO connection with given settings"""
   189         """Open ZEO connection with given settings"""