[MERGE] bzrlib.osutils fixes

Robert Collins robertc at robertcollins.net
Sat Mar 10 22:27:27 GMT 2007


On Sat, 2007-03-10 at 16:31 +1100, Andrew Bennetts wrote:
> John Arbash Meinel wrote:
> > Andrew Bennetts wrote:
> [...]
> > > 
> > > I agree we should decide.  Personally, I think the constant would be better.
> > > 
> > > -Andrew.
> > 
> > As far as typos, that is what the test suite is for. :) I do realize
> > that variables are a little more rigorous. You do have to start passing
> > them around everywhere, though.
> 
> Test suites are a great tool for ensuring quality, but given the option I'd
> rather have other tools to help as well :)

Theres another possible with with using named variables; we have a bit
of an ugly smell around file kinds at the moment: they are strings, and
you call functions to get things related to those strings. The actual
strings are rarely printed anywhere though.

Perhaps we could instead have:

class PathKind(object):
    
    def __init__(self, marker, versionable):
        self.marker = marker
        self.versionable = versionable


kind_directory = PathKind('/', True)
kind_file = PathKind('', True)
kind_link = PathKind('@', True)
kind_socket = PathKind('$', False)
...

'foo is kind_directory' will work, as will 'foo is not kind_directory'
and 'foo in (kind_directory, kind_file)' etc.

-Rob


-- 
GPG key available at: <http://www.robertcollins.net/keys.txt>.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20070311/9b5fc271/attachment.pgp 


More information about the bazaar mailing list