Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
test.test_nntplib._NNTPServerIO Class Reference
Inheritance diagram for test.test_nntplib._NNTPServerIO:
Inheritance graph
[legend]
Collaboration diagram for test.test_nntplib._NNTPServerIO:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def readable
def writable
def push_data
def write
def readinto
def __new__
def register
def __instancecheck__
def __subclasscheck__

Public Attributes

 c2s
 s2c
 handler

Detailed Description

A raw IO object allowing NNTP commands to be received and processed
by a handler.  The handler can push responses which can then be read
from the IO object.

Definition at line 302 of file test_nntplib.py.


Constructor & Destructor Documentation

def test.test_nntplib._NNTPServerIO.__init__ (   self,
  handler 
)

Definition at line 307 of file test_nntplib.py.

00307 
00308     def __init__(self, handler):
00309         io.RawIOBase.__init__(self)
00310         # The channel from the client
00311         self.c2s = io.BytesIO()
00312         # The channel to the client
00313         self.s2c = io.BytesIO()
00314         self.handler = handler
00315         self.handler.start(self.c2s.readline, self.push_data)

Here is the caller graph for this function:


Member Function Documentation

def abc.ABCMeta.__instancecheck__ (   cls,
  instance 
) [inherited]
Override for isinstance(instance, cls).

Definition at line 158 of file abc.py.

00158 
00159     def __instancecheck__(cls, instance):
00160         """Override for isinstance(instance, cls)."""
00161         # Inline the cache checking
00162         subclass = instance.__class__
00163         if subclass in cls._abc_cache:
00164             return True
00165         subtype = type(instance)
00166         if subtype is subclass:
00167             if (cls._abc_negative_cache_version ==
00168                 ABCMeta._abc_invalidation_counter and
00169                 subclass in cls._abc_negative_cache):
00170                 return False
00171             # Fall back to the subclass check.
00172             return cls.__subclasscheck__(subclass)
00173         return any(cls.__subclasscheck__(c) for c in {subclass, subtype})

Here is the call graph for this function:

def abc.ABCMeta.__new__ (   mcls,
  name,
  bases,
  namespace 
) [inherited]

Definition at line 116 of file abc.py.

00116 
00117     def __new__(mcls, name, bases, namespace):
00118         cls = super().__new__(mcls, name, bases, namespace)
00119         # Compute set of abstract method names
00120         abstracts = {name
00121                      for name, value in namespace.items()
00122                      if getattr(value, "__isabstractmethod__", False)}
00123         for base in bases:
00124             for name in getattr(base, "__abstractmethods__", set()):
00125                 value = getattr(cls, name, None)
00126                 if getattr(value, "__isabstractmethod__", False):
00127                     abstracts.add(name)
00128         cls.__abstractmethods__ = frozenset(abstracts)
00129         # Set up inheritance registry
00130         cls._abc_registry = WeakSet()
00131         cls._abc_cache = WeakSet()
00132         cls._abc_negative_cache = WeakSet()
00133         cls._abc_negative_cache_version = ABCMeta._abc_invalidation_counter
00134         return cls

Here is the call graph for this function:

def abc.ABCMeta.__subclasscheck__ (   cls,
  subclass 
) [inherited]
Override for issubclass(subclass, cls).

Definition at line 174 of file abc.py.

00174 
00175     def __subclasscheck__(cls, subclass):
00176         """Override for issubclass(subclass, cls)."""
00177         # Check cache
00178         if subclass in cls._abc_cache:
00179             return True
00180         # Check negative cache; may have to invalidate
00181         if cls._abc_negative_cache_version < ABCMeta._abc_invalidation_counter:
00182             # Invalidate the negative cache
00183             cls._abc_negative_cache = WeakSet()
00184             cls._abc_negative_cache_version = ABCMeta._abc_invalidation_counter
00185         elif subclass in cls._abc_negative_cache:
00186             return False
00187         # Check the subclass hook
00188         ok = cls.__subclasshook__(subclass)
00189         if ok is not NotImplemented:
00190             assert isinstance(ok, bool)
00191             if ok:
00192                 cls._abc_cache.add(subclass)
00193             else:
00194                 cls._abc_negative_cache.add(subclass)
00195             return ok
00196         # Check if it's a direct subclass
00197         if cls in getattr(subclass, '__mro__', ()):
00198             cls._abc_cache.add(subclass)
00199             return True
00200         # Check if it's a subclass of a registered class (recursive)
00201         for rcls in cls._abc_registry:
00202             if issubclass(subclass, rcls):
00203                 cls._abc_cache.add(subclass)
00204                 return True
00205         # Check if it's a subclass of a subclass (recursive)
00206         for scls in cls.__subclasses__():
00207             if issubclass(subclass, scls):
00208                 cls._abc_cache.add(subclass)
00209                 return True
00210         # No dice; update negative cache
00211         cls._abc_negative_cache.add(subclass)
00212         return False

Here is the call graph for this function:

def test.test_nntplib._NNTPServerIO.push_data (   self,
  data 
)
Push (buffer) some data to send to the client.

Definition at line 322 of file test_nntplib.py.

00322 
00323     def push_data(self, data):
00324         """Push (buffer) some data to send to the client."""
00325         pos = self.s2c.tell()
00326         self.s2c.seek(0, 2)
00327         self.s2c.write(data)
00328         self.s2c.seek(pos)

Here is the caller graph for this function:

Definition at line 316 of file test_nntplib.py.

00316 
00317     def readable(self):
00318         return True

def test.test_nntplib._NNTPServerIO.readinto (   self,
  buf 
)
The client wants to read a response

Definition at line 337 of file test_nntplib.py.

00337 
00338     def readinto(self, buf):
00339         """The client wants to read a response"""
00340         self.handler.process_pending()
00341         b = self.s2c.read(len(buf))
00342         n = len(b)
00343         buf[:n] = b
00344         return n
00345 

def abc.ABCMeta.register (   cls,
  subclass 
) [inherited]
Register a virtual subclass of an ABC.

Definition at line 135 of file abc.py.

00135 
00136     def register(cls, subclass):
00137         """Register a virtual subclass of an ABC."""
00138         if not isinstance(subclass, type):
00139             raise TypeError("Can only register classes")
00140         if issubclass(subclass, cls):
00141             return  # Already a subclass
00142         # Subtle: test for cycles *after* testing for "already a subclass";
00143         # this means we allow X.register(X) and interpret it as a no-op.
00144         if issubclass(cls, subclass):
00145             # This would create a cycle, which is bad for the algorithm below
00146             raise RuntimeError("Refusing to create an inheritance cycle")
00147         cls._abc_registry.add(subclass)
00148         ABCMeta._abc_invalidation_counter += 1  # Invalidate negative cache

Here is the caller graph for this function:

Definition at line 319 of file test_nntplib.py.

00319 
00320     def writable(self):
00321         return True

def test.test_nntplib._NNTPServerIO.write (   self,
  b 
)
The client sends us some data

Definition at line 329 of file test_nntplib.py.

00329 
00330     def write(self, b):
00331         """The client sends us some data"""
00332         pos = self.c2s.tell()
00333         self.c2s.write(b)
00334         self.c2s.seek(pos)
00335         self.handler.process_pending()
00336         return len(b)


Member Data Documentation

Definition at line 310 of file test_nntplib.py.

Definition at line 313 of file test_nntplib.py.

Definition at line 312 of file test_nntplib.py.


The documentation for this class was generated from the following file: