git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Brandon Casey <drafnel@gmail.com>
Date
Jan 26, 2013, 18:19 UTC
Message-ID
<CA+sFfMfxQUqe-Nqp-2CjZ0ShLuwOYqPUCOQMrGASUmhEhxNMNg@mail.gmail.com>
In-Reply-To
<20130126124510.GA31052@padd.com>
On Sat, Jan 26, 2013 at 4:45 AM, Pete Wyckoff <pw@padd.com> wrote:
Show 26 quoted lines
> drafnel@gmail.com 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.
Yes that's simpler and works fine.
-Brandon
Previous: Pete WyckoffNext: Brandon Casey
Message 4 of 8 in “git-p4 support for older python”
  1. 0/2 git-p4 support for older pythonBrandon Casey, Jan 25, 2013
  2. 1/2 git-p4.py: support Python 2.5Brandon Casey, Jan 25, 2013
  3. Pete WyckoffJan 26, 2013
  4. Brandon CaseyJan 26, 2013
  5. 2/2 git-p4.py: support Python 2.4Brandon Casey, Jan 25, 2013
  6. Pete WyckoffJan 26, 2013
  7. Brandon CaseyJan 26, 2013
  8. Junio C HamanoJan 25, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.