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

Public Member Functions

def __init__
 
def add_password
 
def find_user_password
 
def reduce_uri
 
def is_suburi
 

Data Fields

 passwd
 

Detailed Description

Definition at line 514 of file urllib2.py.

Constructor & Destructor Documentation

def __init__ (   self)

Definition at line 515 of file urllib2.py.

516  def __init__(self):
517  self.passwd = {}

Member Function Documentation

def add_password (   self,
  realm,
  uri,
  user,
  passwd 
)

Definition at line 518 of file urllib2.py.

References HTTPPasswordMgr.passwd, ftpwrapper.passwd, HTTPPasswordMgr.reduce_uri(), and log_faction_ships.tuple.

519  def add_password(self, realm, uri, user, passwd):
520  # uri could be a single URI or a sequence
521  if isinstance(uri, (types.StringType, types.UnicodeType)):
522  uri = [uri]
523  uri = tuple(map(self.reduce_uri, uri))
524  if not self.passwd.has_key(realm):
525  self.passwd[realm] = {}
526  self.passwd[realm][uri] = (user, passwd)
def find_user_password (   self,
  realm,
  authuri 
)

Definition at line 527 of file urllib2.py.

References HTTPPasswordMgr.is_suburi(), and HTTPPasswordMgr.reduce_uri().

528  def find_user_password(self, realm, authuri):
529  domains = self.passwd.get(realm, {})
530  authuri = self.reduce_uri(authuri)
531  for uris, authinfo in domains.items():
532  for uri in uris:
533  if self.is_suburi(uri, authuri):
534  return authinfo
535  return None, None
def is_suburi (   self,
  base,
  test 
)
Check if test is below base in a URI tree

Both args must be URIs in reduced form.

Definition at line 544 of file urllib2.py.

References posixpath.commonprefix().

545  def is_suburi(self, base, test):
546  """Check if test is below base in a URI tree
547 
548  Both args must be URIs in reduced form.
549  """
550  if base == test:
551  return 1
552  if base[0] != test[0]:
553  return 0
554  common = posixpath.commonprefix((base[1], test[1]))
555  if len(common) == len(base[1]):
556  return 1
557  return 0
558 
def reduce_uri (   self,
  uri 
)
Accept netloc or URI and extract only the netloc and path

Definition at line 536 of file urllib2.py.

References urlparse.urlparse().

537  def reduce_uri(self, uri):
538  """Accept netloc or URI and extract only the netloc and path"""
539  parts = urlparse.urlparse(uri)
540  if parts[1]:
541  return parts[1], parts[2] or '/'
542  else:
543  return parts[2], '/'

Field Documentation

passwd

Definition at line 516 of file urllib2.py.


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