Back to index

system-config-printer  1.3.9+20120706
Public Member Functions | Public Attributes | Private Member Functions
smburi.SMBURI Class Reference

List of all members.

Public Member Functions

def __init__
def get_uri
def sanitize_uri
def separate

Public Attributes

 uri

Private Member Functions

def _construct

Detailed Description

Definition at line 32 of file smburi.py.


Constructor & Destructor Documentation

def smburi.SMBURI.__init__ (   self,
  uri = None,
  group = '',
  host = '',
  share = '',
  user = '',
  password = '' 
)

Definition at line 35 of file smburi.py.

00035 
00036                   group='', host='', share='', user='', password=''):
00037         if uri:
00038             if group or host or share or user or password:
00039                 raise RuntimeError
00040 
00041             uri = uri.encode ('utf-8')
00042             if uri.startswith ("smb://"):
00043                 uri = uri[6:]
00044 
00045             self.uri = uri
00046         else:
00047             self.uri = self._construct (group, host, share,
00048                                         user=user, password=password)


Member Function Documentation

def smburi.SMBURI._construct (   self,
  group,
  host,
  share,
  user = '',
  password = '' 
) [private]

Definition at line 49 of file smburi.py.

00049 
00050     def _construct (self, group, host, share, user='', password=''):
00051         uri_password = ''
00052         if password:
00053             uri_password = ':' + urlquote (password)
00054         if user:
00055             uri_password += '@'
00056         uri = "%s%s%s" % (urlquote (user),
00057                           uri_password,
00058                           urlquote (group))
00059         if len (group) > 0:
00060             uri += '/'
00061         uri += urlquote (host)
00062         if len (share) > 0:
00063             uri += "/" + urlquote (share)
00064         return uri

Here is the caller graph for this function:

def smburi.SMBURI.get_uri (   self)

Definition at line 65 of file smburi.py.

00065 
00066     def get_uri (self):
00067         return self.uri

Here is the caller graph for this function:

Definition at line 68 of file smburi.py.

00068 
00069     def sanitize_uri (self):
00070         group, host, share, user, password = self.separate ()
00071         return self._construct (group, host, share)

Here is the call graph for this function:

def smburi.SMBURI.separate (   self)

Definition at line 72 of file smburi.py.

00072 
00073     def separate (self):
00074         uri = self.get_uri ()
00075         user = ''
00076         password = ''
00077         auth = uri.find ('@')
00078         if auth != -1:
00079             u = uri[:auth].find(':')
00080             if u != -1:
00081                 user = uri[:u]
00082                 password = uri[u + 1:auth]
00083             else:
00084                 user = uri[:auth]
00085             uri = uri[auth + 1:]
00086         sep = uri.count ('/')
00087         group = ''
00088         if sep == 2:
00089             g = uri.find('/')
00090             group = uri[:g]
00091             uri = uri[g + 1:]
00092         if sep < 1:
00093             host = ''
00094         else:
00095             h = uri.find('/')
00096             host = uri[:h]
00097             uri = uri[h + 1:]
00098             p = host.find(':')
00099             if p != -1:
00100                 host = host[:p]
00101         share = uri
00102         return (urllib.unquote (group), urllib.unquote (host),
00103                 urllib.unquote (share),
00104                 urllib.unquote (user), urllib.unquote (password))

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 44 of file smburi.py.


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