# Class e.c.m.MediaUri:

Part of elisa.core.media_uri View In Hierarchy

Media URI management

An URI is structured like this:

      scheme://[user:password@]host[:port]/path[/][?params][#fragment]

This class is able to parse that and wrap access to all found attributes. When I'm parsing file:// URIs I'm allowed to replace paths like:

      ./path/to/foo

With the following:

      "%s/path/to/foo" % os.curdir

Instance Variables | scheme | the URI scheme (type: string )
| user | the optional username (type: string )
| password | the optional password (type: string )
| host | the URI hostname (type: string )
| port | URI optional port. Set to 0 if not found (type: int )
| path | the URI path, delimitted by slashes (/) (type: string )
| fragment | optional URI fragment (type: string )
| extension | the extension of the uri or empty (type: unicode )
| filename | the filename of the uri, means the part behind the last slash. Could be empty! (type: unicode )
| label | the label for this uri (per default the same as the filename) (type: unicode or `elisa.extern.translator.Translateable` )
| parent | the parent uri (means the last part of the path is removed) (type: `MediaUri` )

Line # | Kind | Name | Docs
--- | --- | --- | ---
188 | Method | __init__ | Create an Uri from various representations.
276 | Method | path__get | Undocumented
283 | Method | path__set | Undocumented
376 | Method | set_params | Set a lot of parameters at one time. Attention: it simply
387 | Method | set_param | Set the parameter 'name' to 'value'. If this parameter is already
401 | Method | get_param | Get the value for the parameter 'name'. If there is none found, return
419 | Method | get_params | Get all params as a dict.
427 | Method | get_params_string | Get the params as a one-line string (excluding a leading '?').
435 | Method | del_param | Delete the paramter with the name 'name' (and it's value), if it is
446 | Method | extension__get | Undocumented
454 | Method | filename__get | Return the filename of the Uri.
473 | Method | label__set | Undocumented
481 | Method | label__get | Return a displayable string designing the Uri. Return last path
504 | Method | parent__get | Return the parent URI.
525 | Method | join | Append the given path to my path attribute
578 | Method | __str__ | Byte string representation of the URI
590 | Method | __cmp__ | Compare myself with another uri.
603 | Method | __eq__ |
614 | Method | __ne__ |
623 | Method | __nonzero__ | Undocumented
626 | Method | __contains__ | Undocumented
629 | Method | __add__ | Undocumented
632 | Method | endswith | Undocumented
635 | Method | __getslice__ | Undocumented

def __init__(self, data):

Create an Uri from various representations.

Representation can be either a string containing the uri or the components of the uri stored in a dictionary.

Parameters | data | An uri stored in a unicode string or described by its components (scheme, user, password, host, port, path, params, fragment), each of them being a string (type: string or dict )
Raises | TypeError | If none of location or parts has been provided
| ParseException | If the location wasn't correctly parsed

def path__get(self):
Undocumented
def path__set(self, value):
Undocumented
def set_params(self, values):
Set a lot of parameters at one time. Attention: it simply overrides already existing values!

Parameters | values | a dictionary, where the parameter names are pointing to the unquoted values. (type: dict )

def set_param(self, name, value):
Set the parameter 'name' to 'value'. If this parameter is already existing it is overritten. The value shouldn't be quoted yet, because it is quoted here. That might lead to very bad parameter values!

Parameters | name | the name of the paramter (type: Unicode )
| value | unquoted value for the parameter (type: Unicode )

def get_param(self, name, default=u''):
Get the value for the parameter 'name'. If there is none found, return the value of 'default'. If 'default' is not set it is an empty unicode.

Parameters | name | the name of the parameter (type: Unicode )
| default | value that should be returned, if the parameter is not found (per default that is an empty Unicode) (type: Unicode )
Returns | paramter or the value of default, if the paramter was not found (type: unquoted Unicode )

def get_params(self):
Get all params as a dict.

Returns | of quoted key value pairs (type: dict )

def get_params_string(self):
Get the params as a one-line string (excluding a leading '?').

Returns | key1=value1&key2=value2 (type: unicode )

def del_param(self, name):
Delete the paramter with the name 'name' (and it's value), if it is found in the list of parameters.

Parameters | name | the name of the paramter to delete (type: Unicode )

def extension__get(self):
Undocumented
def filename__get(self):

Return the filename of the Uri.

Returns last path component label parameter like uri://path/to/foo then 'foo' is returned.

If there is no path, like in uri://host:port/ or in uri:// an empty unicode is returned

def label__set(self, value):
Undocumented
def label__get(self):
Return a displayable string designing the Uri. Return last path component if the URI has no predetermined label instance attribute set.

def parent__get(self):

Return the parent URI.

If the URI is like uri://path/to/foo return uri://path/to/

def join(self, path):
Append the given path to my path attribute

Parameters | path | the path to append at the end of my path (type: string )
Returns | (type: `MediaUri` )

def __str__(self):
Byte string representation of the URI

Returns | (type: string )

def __cmp__(self, other_uri):

    Compare myself with another uri.

    @see help of builtin cmp()
    @param other_uri: The URI I'm comparing myself with
    @type other_uri:  L{MediaUri}
    @rtype:           int
    @raise TypeError: When trying to compare with non-MediaUri object

def __eq__(self, other_uri):

Raises | TypeError | When trying to compare with non-MediaUri object

def __ne__(self, other_uri):

Raises | TypeError | When trying to compare with non-MediaUri object

def __nonzero__(self):
Undocumented
def __contains__(self, component):
Undocumented
def __add__(self, path):
Undocumented
def endswith(self, character):
Undocumented
def __getslice__(self, i, j):
Undocumented