All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joshua Lock <joshua.g.lock@linux.intel.com>
To: Stephano Cetola <stephano.cetola@linux.intel.com>,
	yocto@yoctoproject.org
Subject: Re: [yocto-autobuilder][PATCH] ScrapeTargets: use translate instead of regex
Date: Mon, 17 Jul 2017 15:03:15 +0100	[thread overview]
Message-ID: <1500300195.3198.8.camel@linux.intel.com> (raw)
In-Reply-To: <20170715193359.63097-1-stephano.cetola@linux.intel.com>

On Sat, 2017-07-15 at 12:33 -0700, Stephano Cetola wrote:
> From some quick tests the string translate function is comparable in
> efficiency and certainly more legible than regex. We should note that
> if we ever move this functionality to an environment running python3,
> the translate function takes one dictionary argument, but functions
> in much the same way.

Oh, I didn't know about translate. Neat, thanks! Merged.

Joshua

> 
> Signed-off-by: Stephano Cetola <stephano.cetola@linux.intel.com>
> ---
>  .../site-packages/autobuilder/buildsteps/ScrapeTargets.py          | 
> 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/python2.7/site-
> packages/autobuilder/buildsteps/ScrapeTargets.py
> b/lib/python2.7/site-packages/autobuilder/buildsteps/ScrapeTargets.py
> index ceed0c709..0480f3de3 100644
> --- a/lib/python2.7/site-
> packages/autobuilder/buildsteps/ScrapeTargets.py
> +++ b/lib/python2.7/site-
> packages/autobuilder/buildsteps/ScrapeTargets.py
> @@ -57,9 +57,10 @@ class ScrapeTargets(ShellCommand):
>              targets = res.group()
>              # Try and ensure we scrape the target regardless of
> which
>              # assignment operator is used and surrounding whitespace
> -            targets = re.sub('%s *\??\??:?.?\+?=\+?\.? *\"' %
> self.targetsvar, '', targets, 1)
> -            targets = targets.replace('\\', '')
> -            targets = targets.replace('\n', '')
> +            targets = targets.replace(self.targetsvar, '')
> +            targets = targets.translate(None, ':+?="')
> +            targets = targets.replace("\\", "")
> +            targets = targets.replace ("\n", "")
>          self.setProperty("scraped_targets",
>                           targets,
>                           'Targets "%s" scraped from %s' % (targets,
> -- 
> 2.13.2
> 


      reply	other threads:[~2017-07-17 14:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-15 19:33 [yocto-autobuilder][PATCH] ScrapeTargets: use translate instead of regex Stephano Cetola
2017-07-17 14:03 ` Joshua Lock [this message]

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=1500300195.3198.8.camel@linux.intel.com \
    --to=joshua.g.lock@linux.intel.com \
    --cc=stephano.cetola@linux.intel.com \
    --cc=yocto@yoctoproject.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.