[MERGE] Rule-based preferences (EOL part 1 of 3)

Ian Clatworthy ian.clatworthy at internode.on.net
Wed Jun 25 13:14:34 BST 2008


John Arbash Meinel wrote:
> John Arbash Meinel has voted tweak.

> +    def get_items(self, path, names=None):
> +        """Return the preferences for a path as a sequence of
> name,value tuples.
> +
> +        :param path: tree relative path
> +        :param names: the list of preferences to lookup - None for all
> +        :return: None if no rule matched, otherwise a sequence of
> name,value
> +          tuples. If names is not None, the sequence is the same length as
> +          names, tuple order matches the order in names, and undefined
> +          preferences are given the value None.
> +        """
> +        raise NotImplementedError(self.get_items)
> 
> ^- The api here seems heavily dependent on whether names is supplied or
> not. (If you supply it, you always get return values, if you don't you
> sometimes get a sequence, sometimes get None.)

Hmm, not really. As the text says "None if no rule matched".
I think the API design is OK - it's exactly what *I* want/need. :-)
I'm happy to improve the docstring if you can suggest some better text.

> +    def test_get_items_from_extension_match(self):
> +        rs = self.make_searcher(["[*.txt]", "foo=bar", "a=True"])
> 
> ^- Shouldn't these lines have '\n' at the end of them?
> Even better, have it take "text" and then do the splitting yourself
> before handing it to _IniBasedRulesSearcher. I think it would be a lot
> easier for humans to understand than trying to follow the nested [] and
> quote characters.

I'm yet to do this but I'm happy to once the namespace keyword is agreed
(and hence the text is stable).

Ian C.




More information about the bazaar mailing list