Better path changing support
* Create a get_collection method similar to get_* methods for objects. * Fix title initialization of a collection * Remove the hack were both id and title were allowed when CDing. That hack only worked with the canalplus module, and failed with others like redmine (but they still showed in suggestions). Moreover, the canalplus module now has friendlier IDs so this is not really needed anymore. * Allow backends to tell if a path is valid or not. For instance, it now allows to cd in a Redmine project with no issues in it. It also won't display "404" for invalid project IDs. By default, we still use the unreliable method of checking there is at least one result in iter_resources(). * Fix cd completion to work with unicode strings (all strings after an unicode string were ignored!) * Do not suggest '..' when completing cd in the root refs #774
This commit is contained in:
parent
1a5ece25df
commit
b6021d4732
5 changed files with 57 additions and 24 deletions
|
|
@ -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.
|
||||
#
|
||||
|
|
@ -90,18 +90,14 @@ class CanalplusBrowser(BaseBrowser):
|
|||
yield channel
|
||||
elif len(split_path) == 2:
|
||||
subchannels = self.iter_resources(split_path[0:1])
|
||||
channel = None
|
||||
for subchannel in subchannels:
|
||||
# allow matching by title for backward compatibility (for now)
|
||||
if split_path[0] == subchannel.split_path[0] and \
|
||||
split_path[1] in (subchannel.split_path[1], subchannel.title):
|
||||
channel = subchannel
|
||||
if channel:
|
||||
self.location("http://service.canal-plus.com/video/rest/getMEAs/cplus/%s" % channel.id)
|
||||
try:
|
||||
channel = [subchannel for subchannel in subchannels
|
||||
if split_path == subchannel.split_path][0]
|
||||
self.location("http://service.canal-plus.com/video/rest/getMEAs/cplus/%s" % channel._link_id)
|
||||
assert self.is_on_page(VideoPage)
|
||||
for video in self.page.iter_channel():
|
||||
yield video
|
||||
else:
|
||||
except IndexError:
|
||||
raise CollectionNotFound(split_path)
|
||||
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -34,11 +34,12 @@ class InitPage(BasePage):
|
|||
for elem in self.document[2].getchildren():
|
||||
for e in elem.getchildren():
|
||||
if e.tag == "NOM":
|
||||
name = e.text.strip()
|
||||
name = unicode(e.text.strip())
|
||||
channels.append(Collection([name]))
|
||||
elif e.tag == "SELECTIONS":
|
||||
for select in e:
|
||||
sub = Collection([name, select[0].text],
|
||||
title=select[1].text.strip())
|
||||
subname = unicode(select[1].text.strip())
|
||||
sub = Collection([name, subname])
|
||||
sub._link_id = select[0].text
|
||||
channels.append(sub)
|
||||
return channels
|
||||
|
|
|
|||
|
|
@ -107,6 +107,15 @@ class RedmineBackend(BaseBackend, ICapContent, ICapBugTracker, ICapCollection):
|
|||
|
||||
raise CollectionNotFound(split_path)
|
||||
|
||||
def _is_collection_valid(self, objs, split_path):
|
||||
if len(split_path) == 0:
|
||||
return True
|
||||
if Issue in objs and len(split_path) == 1:
|
||||
for project in self.browser.iter_projects():
|
||||
if split_path[0] in (project['id'], project['name']):
|
||||
return True
|
||||
return self.get_project(split_path[0]) is not None
|
||||
return False
|
||||
|
||||
############# CapBugTracker ###################################################
|
||||
def _build_project(self, project_dict):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue