[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn commit: r33539 - trunk/build/generator

From: Greg Stein <gstein_at_gmail.com>
Date: Wed, 8 Oct 2008 02:19:54 -0700

On Wed, Oct 8, 2008 at 1:12 AM, <rhuijben_at_tigris.org> wrote:
>...
> +++ trunk/build/generator/gen_win.py Wed Oct 8 01:12:06 2008 (r33539)
>...
> + def _find_sqlite(self):
>...
> + fp = open(header_file)
> + txt = fp.read()
> + fp.close()

Can simplify to:

  txt = open(header_file).read()

> + vermatch = re.compile(r'^\s*#define\s+SQLITE_VERSION\s+"(\d+)\.(\d+)\.(\d+)"', re.M) \
> + .search(txt)

You only need to use re.compile() if you plan to save the compiled
regex. In this case... no. So:

  vermatch = re.search(r'^\s...)"', txt, re.M)

> + version = (int(vermatch.group(1)),
> + int(vermatch.group(2)),
> + int(vermatch.group(3)))

Simpler:
  version = map(int, vermatch.groups())

or:
  version = [int(v) for v in vermatch.groups()]

> + self.sqlite_version = '%d.%d.%d' % version

With the above simplification for version=, you get a list. So the
statement above needs tuple(version). Or:
  self.sqlite_version = '%s.%s.%s' % vermatch.groups()

> + msg = 'Found SQLite version %s\n'
> +
> + if version[0] < 3 or (version[0] == 3 and version[1] < 4):
> + msg = "WARNING: SQLite 3.4.0 or higher is required (%s found)\n"

Rather than version=, you could do:

  major, minor, patch = map(int, vermatch.groups())

WIth appropriate followthru tweaks...

Cheers,
-g

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: dev-help_at_subversion.tigris.org
Received on 2008-10-08 11:20:15 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.