Re: [PATCH 1/2] git-p4.py: support Python 2.5

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



drafnel@xxxxxxxxx wrote on Fri, 25 Jan 2013 12:44 -0800:
> Python 2.5 and older do not accept None as the first argument to
> translate() and complain with:
> 
>    TypeError: expected a character buffer object
> 
> Satisfy this older python by calling maketrans() to generate an empty
> translation table and supplying that to translate().
> 
> This allows git-p4 to be used with Python 2.5.

This was a lot easier than I imagined!

>  def wildcard_present(path):
> -    return path.translate(None, "*#@%") != path
> +    from string import maketrans
> +    return path.translate(maketrans("",""), "*#@%") != path

translate() was a bit too subtle already.  Could you try
something like this instead?

    m = re.search("[*#@%]", path)
    return m is not None

I think that'll work everywhere and not force people to look
up how translate and maketrans work.

		-- Pete
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]