Commit 7e9000ba authored by Greg Stein's avatar Greg Stein

no changes other than indentation level (now 4) and comment reflow.

use "cvs diff -b" to verify.
parent 4666c99a
...@@ -90,7 +90,7 @@ def _fs_import(dir, modname, fqname): ...@@ -90,7 +90,7 @@ def _fs_import(dir, modname, fqname):
# Simple function-based importer # Simple function-based importer
# #
class FuncImporter(imputil.Importer): class FuncImporter(imputil.Importer):
"Importer subclass to use a supplied function rather than method overrides." "Importer subclass to delegate to a function rather than method overrides."
def __init__(self, func): def __init__(self, func):
self.func = func self.func = func
def get_code(self, parent, modname, fqname): def get_code(self, parent, modname, fqname):
...@@ -122,8 +122,8 @@ class PackageArchiveImporter(imputil.Importer): ...@@ -122,8 +122,8 @@ class PackageArchiveImporter(imputil.Importer):
# under the top level module (package / archive). # under the top level module (package / archive).
assert parent.__importer__ == self assert parent.__importer__ == self
# if a parent "package" is provided, then we are importing a sub-file # if a parent "package" is provided, then we are importing a
# from the archive. # sub-file from the archive.
result = self.get_subfile(parent.__archive__, modname) result = self.get_subfile(parent.__archive__, modname)
if result is None: if result is None:
return None return None
......
...@@ -106,7 +106,7 @@ class HTTPResponse: ...@@ -106,7 +106,7 @@ class HTTPResponse:
self.chunked = _UNKNOWN # is "chunked" being used? self.chunked = _UNKNOWN # is "chunked" being used?
self.chunk_left = _UNKNOWN # bytes left to read in current chunk self.chunk_left = _UNKNOWN # bytes left to read in current chunk
self.length = _UNKNOWN # number of bytes left in response self.length = _UNKNOWN # number of bytes left in response
self.will_close = _UNKNOWN # connection will close at end of response self.will_close = _UNKNOWN # conn will close at end of response
def begin(self): def begin(self):
if self.msg is not None: if self.msg is not None:
...@@ -291,7 +291,8 @@ class HTTPResponse: ...@@ -291,7 +291,8 @@ class HTTPResponse:
by a signal (resulting in a partial read). by a signal (resulting in a partial read).
Note that we cannot distinguish between EOF and an interrupt when zero Note that we cannot distinguish between EOF and an interrupt when zero
bytes have been read. IncompleteRead() will be raised in this situation. bytes have been read. IncompleteRead() will be raised in this
situation.
This function should be used when <amt> bytes "should" be present for This function should be used when <amt> bytes "should" be present for
reading. If the bytes are truly not available (due to EOF), then the reading. If the bytes are truly not available (due to EOF), then the
...@@ -397,8 +398,8 @@ class HTTPConnection: ...@@ -397,8 +398,8 @@ class HTTPConnection:
# if there is no prior response, then we can request at will. # if there is no prior response, then we can request at will.
# #
# if point (2) is true, then we will have passed the socket to the # if point (2) is true, then we will have passed the socket to the
# response (effectively meaning, "there is no prior response"), and will # response (effectively meaning, "there is no prior response"), and
# open a new one when a new request is made. # will open a new one when a new request is made.
# #
# Note: if a prior response exists, then we *can* start a new request. # Note: if a prior response exists, then we *can* start a new request.
# We are not allowed to begin fetching the response to this new # We are not allowed to begin fetching the response to this new
...@@ -434,10 +435,10 @@ class HTTPConnection: ...@@ -434,10 +435,10 @@ class HTTPConnection:
self.putheader('Host', self.host) self.putheader('Host', self.host)
# note: we are assuming that clients will not attempt to set these # note: we are assuming that clients will not attempt to set these
# headers since *this* library must deal with the consequences. # headers since *this* library must deal with the
# this also means that when the supporting libraries are # consequences. this also means that when the supporting
# updated to recognize other forms, then this code should be # libraries are updated to recognize other forms, then this
# changed (removed or updated). # code should be changed (removed or updated).
# we only want a Content-Encoding of "identity" since we don't # we only want a Content-Encoding of "identity" since we don't
# support encodings such as x-gzip or x-deflate. # support encodings such as x-gzip or x-deflate.
...@@ -513,14 +514,15 @@ class HTTPConnection: ...@@ -513,14 +514,15 @@ class HTTPConnection:
# behavior) # behavior)
# #
# note: if a prior response existed, but was connection-close, then the # note: if a prior response existed, but was connection-close, then the
# socket and response were made independent of this HTTPConnection object # socket and response were made independent of this HTTPConnection
# since a new request requires that we open a whole new connection # object since a new request requires that we open a whole new
# connection
# #
# this means the prior response had one of two states: # this means the prior response had one of two states:
# 1) will_close: this connection was reset and the prior socket and # 1) will_close: this connection was reset and the prior socket and
# response operate independently # response operate independently
# 2) persistent: the response was retained and we await its isclosed() # 2) persistent: the response was retained and we await its
# status to become true. # isclosed() status to become true.
# #
if self.__state != _CS_REQ_SENT or self.__response: if self.__state != _CS_REQ_SENT or self.__response:
raise ResponseNotReady() raise ResponseNotReady()
...@@ -641,7 +643,8 @@ class HTTP(HTTPConnection): ...@@ -641,7 +643,8 @@ class HTTP(HTTPConnection):
def putheader(self, header, *values): def putheader(self, header, *values):
"The superclass allows only one value argument." "The superclass allows only one value argument."
HTTPConnection.putheader(self, header, string.joinfields(values, '\r\n\t')) HTTPConnection.putheader(self, header,
string.joinfields(values, '\r\n\t'))
def getreply(self): def getreply(self):
"""Compat definition since superclass does not define it. """Compat definition since superclass does not define it.
...@@ -677,7 +680,8 @@ class HTTP(HTTPConnection): ...@@ -677,7 +680,8 @@ class HTTP(HTTPConnection):
# note that self.file == response.fp, which gets closed by the # note that self.file == response.fp, which gets closed by the
# superclass. just clear the object ref here. # superclass. just clear the object ref here.
### hmm. messy. if status==-1, then self.file is owned by us. ### hmm. messy. if status==-1, then self.file is owned by us.
### well... we aren't explicitly closing, but losing this ref will do it ### well... we aren't explicitly closing, but losing this ref will
### do it
self.file = None self.file = None
......
...@@ -61,7 +61,8 @@ class ImportManager: ...@@ -61,7 +61,8 @@ class ImportManager:
# .py files (or a .py file's cached bytecode) # .py files (or a .py file's cached bytecode)
for desc in imp.get_suffixes(): for desc in imp.get_suffixes():
if desc[2] == imp.C_EXTENSION: if desc[2] == imp.C_EXTENSION:
self.add_suffix(desc[0], DynLoadSuffixImporter(desc).import_file) self.add_suffix(desc[0],
DynLoadSuffixImporter(desc).import_file)
self.add_suffix('.py', py_suffix_importer) self.add_suffix('.py', py_suffix_importer)
def _import_hook(self, fqname, globals=None, locals=None, fromlist=None): def _import_hook(self, fqname, globals=None, locals=None, fromlist=None):
...@@ -95,8 +96,8 @@ class ImportManager: ...@@ -95,8 +96,8 @@ class ImportManager:
return top_module return top_module
if not top_module.__dict__.get('__ispkg__'): if not top_module.__dict__.get('__ispkg__'):
# __ispkg__ isn't defined (the module was not imported by us), or # __ispkg__ isn't defined (the module was not imported by us),
# it is zero. # or it is zero.
# #
# In the former case, there is no way that we could import # In the former case, there is no way that we could import
# sub-modules that occur in the fromlist (but we can't raise an # sub-modules that occur in the fromlist (but we can't raise an
...@@ -107,16 +108,17 @@ class ImportManager: ...@@ -107,16 +108,17 @@ class ImportManager:
# modules present, so we can just return. # modules present, so we can just return.
# #
# In both cases, since len(parts) == 1, the top_module is also # In both cases, since len(parts) == 1, the top_module is also
# the "bottom" which is the defined return when a fromlist exists. # the "bottom" which is the defined return when a fromlist
# exists.
return top_module return top_module
importer = top_module.__dict__.get('__importer__') importer = top_module.__dict__.get('__importer__')
if importer: if importer:
return importer._finish_import(top_module, parts[1:], fromlist) return importer._finish_import(top_module, parts[1:], fromlist)
# If the importer does not exist, then we have to bail. A missing importer # If the importer does not exist, then we have to bail. A missing
# means that something else imported the module, and we have no knowledge # importer means that something else imported the module, and we have
# of how to get sub-modules out of the thing. # no knowledge of how to get sub-modules out of the thing.
raise ImportError, 'No module named ' + fqname raise ImportError, 'No module named ' + fqname
def _determine_import_context(self, globals): def _determine_import_context(self, globals):
...@@ -216,7 +218,8 @@ class Importer: ...@@ -216,7 +218,8 @@ class Importer:
# since we imported/handled the bottom module, this means that we can # since we imported/handled the bottom module, this means that we can
# also handle its fromlist (and reliably use __ispkg__). # also handle its fromlist (and reliably use __ispkg__).
# if the bottom node is a package, then (potentially) import some modules. # if the bottom node is a package, then (potentially) import some
# modules.
# #
# note: if it is not a package, then "fromlist" refers to names in # note: if it is not a package, then "fromlist" refers to names in
# the bottom module rather than modules. # the bottom module rather than modules.
...@@ -294,10 +297,11 @@ class Importer: ...@@ -294,10 +297,11 @@ class Importer:
def _import_fromlist(self, package, fromlist): def _import_fromlist(self, package, fromlist):
'Import any sub-modules in the "from" list.' 'Import any sub-modules in the "from" list.'
# if '*' is present in the fromlist, then look for the '__all__' variable # if '*' is present in the fromlist, then look for the '__all__'
# to find additional items (modules) to import. # variable to find additional items (modules) to import.
if '*' in fromlist: if '*' in fromlist:
fromlist = list(fromlist) + list(package.__dict__.get('__all__', [])) fromlist = list(fromlist) + \
list(package.__dict__.get('__all__', []))
for sub in fromlist: for sub in fromlist:
# if the name is already present, then don't try to import it (it # if the name is already present, then don't try to import it (it
...@@ -335,8 +339,9 @@ class Importer: ...@@ -335,8 +339,9 @@ class Importer:
modname specifies a single module (not dotted) within the parent. modname specifies a single module (not dotted) within the parent.
fqname specifies the fully-qualified module name. This is a (potentially) fqname specifies the fully-qualified module name. This is a
dotted name from the "root" of the module namespace down to the modname. (potentially) dotted name from the "root" of the module namespace
down to the modname.
If there is no parent, then modname==fqname. If there is no parent, then modname==fqname.
This method should return None, or a 3-tuple. This method should return None, or a 3-tuple.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment