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

@ -854,6 +854,14 @@ class ReplApplication(Cmd, ConsoleApplication):
for obj in self.objects:
if isinstance(obj, CapBaseObject):
self.format(obj)
elif isinstance(obj, Collection):
if obj.id and obj.title:
print u'Collection: %s%s%s (%s)' % \
(self.BOLD, obj.id, self.NC, obj.title)
elif obj.id:
print u'Collection: %s%s%s' % (self.BOLD, obj.id, self.NC)
else:
print obj
else:
print obj.title
@ -861,13 +869,15 @@ class ReplApplication(Cmd, ConsoleApplication):
def do_cd(self, line):
"""
cd PATH
cd [PATH]
Follow a path.
If empty, return home.
"""
line = line.encode('utf-8')
self.working_path.extend(line)
if not len(line.strip()):
self.working_path.home()
else:
self.working_path.extend(line)
objects = self._fetch_objects()
if len(objects) == 0: