]> git.donarmstrong.com Git - neurodebian.git/commitdiff
NF(blends-inject): skip files based on regexp and "emptiness"
authorYaroslav Halchenko <debian@onerussian.com>
Thu, 9 Dec 2010 17:54:28 +0000 (12:54 -0500)
committerYaroslav Halchenko <debian@onerussian.com>
Thu, 9 Dec 2010 17:54:28 +0000 (12:54 -0500)
tools/blends-inject

index ee3d85dab2af44a575b08e0aaaa51aa14fe492dd..71d3fc84ab4d38d47318687478536eeabe09c3f1 100755 (executable)
@@ -47,6 +47,9 @@ files::
  all=~/deb/gits/pkg-exppsy/neurodebian/future/blends/*
      ~/deb/gits/*/debian/blends
      ~/deb/gits/pkg-exppsy/*/debian/blends
+ # Python regular expression on which files to skip
+ # Default is listed below
+ #skip=.*[~#]$
 
 
 Format of debian/blends
@@ -132,7 +135,7 @@ def open(f, *args):
 
 __author__ = 'Yaroslav Halchenko'
 __prog__ = os.path.basename(sys.argv[0])
-__version__ = '0.0.5'
+__version__ = '0.0.6'
 __copyright__ = 'Copyright (c) 2010 Yaroslav Halchenko'
 __license__ = 'GPL'
 
@@ -600,6 +603,20 @@ def print_wnpp(pkgs, config, wnpp_type="ITP"):
         print "Subject: %s\n\n%s" % (subject, body)
 
 
+def is_template(p):
+    """Helper to return true if pkg definition looks like a template
+       and should not be processed
+    """
+    # We might want to skip some which define a skeleton
+    # (no source/homepage/etc although fields are there)
+    for f in ['vcs-browser', 'pkg-url', 'pkg-description',
+              'published-Title', 'pkg-name', 'homepage',
+              'author']:
+        if f in p and p[f] != "":
+            return False
+    return True
+
+
 def main():
 
     p = OptionParser(
@@ -646,7 +663,7 @@ def main():
             options.wnpp_mode = 'ITP'
 
     # Load configuration
-    config = ConfigParser()
+    config = ConfigParser(defaults={'skip': '.*[~#]$'})
     config.read(options.config_file)
 
     if options.all_mode:
@@ -659,12 +676,16 @@ def main():
     if not len(infiles):
         infiles = [join(options.topdir or './', 'debian/blends')]     #  default one
 
+    skip_re = re.compile(config.get('paths', 'skip', None))
+
     for blends_file in infiles:
         verbose(1, "Processing %s" % blends_file)
         if not exists(blends_file):
             error("Cannot find a file %s.  Either provide a file or specify top "
                   "debian directory with -d." % blends_file, 1)
-
+        if skip_re.match(blends_file):
+            verbose(2, "W: Skipped since matches paths.skip regexp")
+            continue
         pkgs = parse_debian_blends(blends_file)
         if options.topdir is None:
             if dirname(blends_file).endswith('/debian'):
@@ -675,6 +696,11 @@ def main():
             topdir = options.topdir
 
                expand_pkgs(pkgs, topdir=topdir)
+
+        pkgs = [p for p in pkgs if not is_template(p)]
+        if not len(pkgs):
+            verbose(2, "W: Skipping since seems to contain templates only")
+            continue
         if options.wnpp_mode is not None:
                    print_wnpp(pkgs, config, options.wnpp_mode)
         else: