Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
FileHandler Class Reference
Inheritance diagram for FileHandler:
BaseHandler

Public Member Functions

def file_open
 
def get_names
 
def open_local_file
 
- Public Member Functions inherited from BaseHandler
def add_parent
 
def close
 

Static Public Attributes

 names = None
 

Additional Inherited Members

- Data Fields inherited from BaseHandler
 parent
 

Detailed Description

Definition at line 856 of file urllib2.py.

Member Function Documentation

def file_open (   self,
  req 
)

Definition at line 858 of file urllib2.py.

References URLopener.open_local_file(), and FileHandler.open_local_file().

859  def file_open(self, req):
860  url = req.get_selector()
861  if url[:2] == '//' and url[2:3] != '/':
862  req.type = 'ftp'
863  return self.parent.open(req)
864  else:
865  return self.open_local_file(req)
def get_names (   self)

Definition at line 868 of file urllib2.py.

869  def get_names(self):
870  if FileHandler.names is None:
871  FileHandler.names = (socket.gethostbyname('localhost'),
872  socket.gethostbyname(socket.gethostname()))
873  return FileHandler.names
def open_local_file (   self,
  req 
)

Definition at line 875 of file urllib2.py.

References rfc822.formatdate(), Cmd.get_names(), FileHandler.get_names(), mimetypes.guess_type(), aifc.open(), urllib.splitport(), and macurl2path.url2pathname().

876  def open_local_file(self, req):
877  host = req.get_host()
878  file = req.get_selector()
879  localfile = url2pathname(file)
880  stats = os.stat(localfile)
881  size = stats[stat.ST_SIZE]
882  modified = rfc822.formatdate(stats[stat.ST_MTIME])
883  mtype = mimetypes.guess_type(file)[0]
884  stats = os.stat(localfile)
885  headers = mimetools.Message(StringIO(
886  'Content-Type: %s\nContent-Length: %d\nLast-modified: %s\n' %
887  (mtype or 'text/plain', size, modified)))
888  if host:
889  host, port = splitport(host)
890  if not host or \
891  (not port and socket.gethostbyname(host) in self.get_names()):
892  return addinfourl(open(localfile, 'rb'),
893  headers, 'file:'+file)
894  raise URLError('file not on local host')

Field Documentation

names = None
static

Definition at line 867 of file urllib2.py.


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