lkml.org 
[lkml]   [2014]   [Oct]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [RFC v2 3/4] backports: use BACKPORT_DIR prefix on kconfig sources
From
Date
On Wed, 2014-10-29 at 01:21 -0700, Luis R. Rodriguez wrote:

> src_line = re.compile(r'^\s*source\s+"?(?P<src>[^\s"]*)"?\s*$')
> +bk_src_line = re.compile(r'^\s*source\s+"?\$BACKPORT_DIR/(?P<src>[^\s"]*)"?\s*$')
> tri_line = re.compile(r'^(?P<spc>\s+)tristate')
> bool_line = re.compile(r'^(?P<spc>\s+)bool')
> cfg_line = re.compile(r'^(?P<opt>config|menuconfig)\s+(?P<sym>[^\s]*)')
> @@ -21,23 +22,47 @@ class ConfigTree(object):
> yield f
> for l in open(os.path.join(self.basedir, f), 'r'):
> m = src_line.match(l)
> - if m and os.path.exists(os.path.join(self.basedir, m.group('src'))):
> - for i in self._walk(m.group('src')):
> - yield i
> + if m:
> + bm = bk_src_line.match(l)
> + if bm:
> + if os.path.exists(os.path.join(self.basedir, bm.group('src'))):
> + for i in self._walk(os.path.join(self.basedir, bm.group('src'))):
> + yield i
> + elif os.path.exists(os.path.join(self.basedir, 'backports/' + bm.group('src'))):
> + for i in self._walk(os.path.join(self.basedir, 'backports/' + bm.group('src'))):
> + yield i
> + else:
> + if os.path.exists(os.path.join(self.basedir, m.group('src'))):
> + for i in self._walk(m.group('src')):
> + yield i

Are you even using the src_line regular expression any more? Seems like
you could just modify it though to make the (\$BACKPORT_DIR/) part
optional.

> def _prune_sources(self, f, ignore):
> for nf in self._walk(f):
> out = ''
> for l in open(os.path.join(self.basedir, nf), 'r'):
> - m = src_line.match(l)
> - if not m:
> - out += l
> - continue
> - src = m.group('src')
> - if src in ignore or os.path.exists(os.path.join(self.basedir, src)):
> - out += l
> + bm = bk_src_line.match(l)
> + if bm:
> + bp_src = bm.group('src')
> + if bp_src in ignore or \
> + os.path.exists(os.path.join(self.basedir, bp_src)) or \
> + os.path.exists(os.path.join(self.basedir, 'backports/' + bp_src)):

I'd prefer parentheses instead of \ line continuations :)

the backports/ part seems to be for integration only?

> + m = src_line.match(l)
> + # we should consider disallowing these as it could mean
> + # someone forgot to add the BACKPORT_DIR prefix to
> + # the kconfig source entries which we will need to
> + # support built-in integration.

If you put it in the same RE then you can just print a warning on this
if detected but skip it otherwise.

johannes



\
 
 \ /
  Last update: 2014-10-31 09:21    [W:0.091 / U:0.440 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site