Package wtf :: Module webutil :: Class URL
[hide private]
[frames] | no frames]

Class URL

source code

object --+
         |
        URL

URL abstraction (RFC 1738)
Instance Methods [hide private]
 
__init__(self, url, decode=None)
Initialization
source code
str
__str__(self)
String representation, hostname idna encoded
source code
str
__repr__(self)
Debug representation
source code
unicode
__unicode__(self)
Unicode representation, hostname as unicode (vs.
source code
URL
copy(self)
Copy the URL
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __subclasshook__

Class Methods [hide private]
URL
fromcomponents(cls, path, scheme=None, netloc=None, query=None)
Create URL object from unescaped path
source code
Class Variables [hide private]
tuple _PARTS = ('scheme', 'netloc', 'path', 'params', 'query', 'frag...
ordered list of known URL parts (available via instance attributes)
  _PATH_SAFE = '/()=~'
  _unicode = False
Instance Variables [hide private]
unicode fragment = ''
optional fragment.
unicode netloc = ''
The net location if available (or '')
unicode params = ''
optional unescaped path parameters (or '')
unicode path = ''
The unescaped path if available, for non-path-based schemes this contains the unescaped non-path ;-) (or '')
Query query = ''
query object
str scheme = ''
The URL scheme
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, url, decode=None)
(Constructor)

source code 
Initialization
Parameters:
  • url (basestring or URL) - The url to parse. If it's an instance of this class, the parameters will be copied
  • decode (callable) - Decoder of parsed octet data
Overrides: object.__init__

__str__(self)
(Informal representation operator)

source code 
String representation, hostname idna encoded
Returns: str
The string representation
Overrides: object.__str__

__repr__(self)
(Representation operator)

source code 
Debug representation
Returns: str
The debug representation
Overrides: object.__repr__

__unicode__(self)

source code 
Unicode representation, hostname as unicode (vs. idna)
Returns: unicode
The unicode representation

fromcomponents(cls, path, scheme=None, netloc=None, query=None)
Class Method

source code 

Create URL object from unescaped path

For convenience you can optionally add query, scheme and netloc.

Parameters:
  • path (basestring) - The path to create the URL from
  • scheme (str) - Optional URL scheme (like http)
  • netloc (basestring) - Optional net location (like example.com)
  • query (str) - Optional query string (encoded) or Query object
Returns: URL
New URL object

copy(self)

source code 
Copy the URL
Returns: URL
a new URL instance

Class Variable Details [hide private]

_PARTS

ordered list of known URL parts (available via instance attributes)
Type:
tuple
Value:
('scheme', 'netloc', 'path', 'params', 'query', 'fragment')

Instance Variable Details [hide private]

fragment

optional fragment. Strictly spoken this isn't part of URLs but of URL references. But who cares. (or '')
Type:
unicode
Value:
''