Make CapCollection understandable and useable by humans

* Make the declaration of fct and it in the constructor Collection,
 instead of adding them from the outside
* Add a function to flatten a list containing collection (solves the
 radioob search crash)
* Better display of collections in the "ls" command (and display both id
 and title)
* The "cd" command goes to the root of the path (like the UNIX cd)
* Move the Video object of canalplus in a correct path
* Make Collection iterable
* Add comments to CapCollection
* Cache the result of fct in a Collection; it is only called once
* CollectionNotFound errors can be more explicit by providing a path
* Require utf-8 in collection paths
* Code cleanups
This commit is contained in:
Laurent Bachelier 2012-02-02 19:16:31 +01:00
commit 682e14c86a
14 changed files with 125 additions and 63 deletions

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright(C) 2010-2011 Nicolas Duhamel
# Copyright(C) 2010-2012 Nicolas Duhamel, Laurent Bachelier
#
# This file is part of weboob.
#
@ -27,6 +27,9 @@ class Path(object):
def extend(self, user_input):
"""
Add a new part to the current path
"""
user_input = urllib.quote_plus(user_input)
user_input = posixpath.normpath(user_input)
@ -49,8 +52,17 @@ class Path(object):
self._working_path = final_parse
def restore(self):
"""
Go to the previous path
"""
self._working_path = self._previous
def home(self):
"""
Go to the root
"""
self._previous = self._working_path
self._working_path = []
def get(self):
return copy.copy(self._working_path)