Plug in the abc module so we can have run-time validation of type
conformance.
Details
Details
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
Plug in the abc module so we can have run-time validation of type
conformance.
| Lint Skipped |
| Unit Tests Skipped |
| # Copyright 21 May 2005 - (c) 2005 Jake Edge <jake@edge2.net> | # Copyright 21 May 2005 - (c) 2005 Jake Edge <jake@edge2.net> | ||||
| # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> | # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> | ||||
| # | # | ||||
| # This software may be used and distributed according to the terms of the | # This software may be used and distributed according to the terms of the | ||||
| # GNU General Public License version 2 or any later version. | # GNU General Public License version 2 or any later version. | ||||
| from __future__ import absolute_import | from __future__ import absolute_import | ||||
| import abc | |||||
| import cgi | import cgi | ||||
| import struct | import struct | ||||
| import sys | import sys | ||||
| from .i18n import _ | from .i18n import _ | ||||
| from . import ( | from . import ( | ||||
| encoding, | encoding, | ||||
| error, | error, | ||||
| HGERRTYPE = 'application/hg-error' | HGERRTYPE = 'application/hg-error' | ||||
| class abstractserverproto(object): | class abstractserverproto(object): | ||||
| """abstract class that summarizes the protocol API | """abstract class that summarizes the protocol API | ||||
| Used as reference and documentation. | Used as reference and documentation. | ||||
| """ | """ | ||||
| __metaclass__ = abc.ABCMeta | |||||
| @abc.abstractmethod | |||||
| def getargs(self, args): | def getargs(self, args): | ||||
| """return the value for arguments in <args> | """return the value for arguments in <args> | ||||
| returns a list of values (same order as <args>)""" | returns a list of values (same order as <args>)""" | ||||
| raise NotImplementedError() | |||||
| @abc.abstractmethod | |||||
| def getfile(self, fp): | def getfile(self, fp): | ||||
| """write the whole content of a file into a file like object | """write the whole content of a file into a file like object | ||||
| The file is in the form:: | The file is in the form:: | ||||
| (<chunk-size>\n<chunk>)+0\n | (<chunk-size>\n<chunk>)+0\n | ||||
| chunk size is the ascii version of the int. | chunk size is the ascii version of the int. | ||||
| """ | """ | ||||
| raise NotImplementedError() | |||||
| @abc.abstractmethod | |||||
| def redirect(self): | def redirect(self): | ||||
| """may setup interception for stdout and stderr | """may setup interception for stdout and stderr | ||||
| See also the `restore` method.""" | See also the `restore` method.""" | ||||
| raise NotImplementedError() | |||||
| # If the `redirect` function does install interception, the `restore` | # If the `redirect` function does install interception, the `restore` | ||||
| # function MUST be defined. If interception is not used, this function | # function MUST be defined. If interception is not used, this function | ||||
| # MUST NOT be defined. | # MUST NOT be defined. | ||||
| # | # | ||||
| # left commented here on purpose | # left commented here on purpose | ||||
| # | # | ||||
| #def restore(self): | #def restore(self): | ||||