From: Pete Wyckoff <pw@padd.com>
To: Brandon Casey <drafnel@gmail.com>
Cc: git@vger.kernel.org, esr@thyrsus.com, john@keeping.me.uk,
Brandon Casey <bcasey@nvidia.com>
Subject: Re: [PATCH 1/2] git-p4.py: support Python 2.5
Date: Sat, 26 Jan 2013 07:45:10 -0500 [thread overview]
Message-ID: <20130126124510.GA31052@padd.com> (raw)
In-Reply-To: <1359146641-27810-2-git-send-email-drafnel@gmail.com>
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.
-- Pete
next prev parent reply other threads:[~2013-01-26 12:45 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-25 20:43 [PATCH 0/2] git-p4 support for older python Brandon Casey
2013-01-25 20:44 ` [PATCH 1/2] git-p4.py: support Python 2.5 Brandon Casey
2013-01-26 12:45 ` Pete Wyckoff [this message]
2013-01-26 18:19 ` Brandon Casey
2013-01-25 20:44 ` [PATCH 2/2] git-p4.py: support Python 2.4 Brandon Casey
2013-01-26 12:48 ` Pete Wyckoff
2013-01-26 19:02 ` Brandon Casey
2013-01-25 21:10 ` [PATCH 0/2] git-p4 support for older python Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130126124510.GA31052@padd.com \
--to=pw@padd.com \
--cc=bcasey@nvidia.com \
--cc=drafnel@gmail.com \
--cc=esr@thyrsus.com \
--cc=git@vger.kernel.org \
--cc=john@keeping.me.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).