+ def get_description(self, pkg_name):
+ """Some logic to extract description.
+
+ If binary package matching pkg_name is found -- gets it description.
+ If no binary package with such name, and name matches source name,
+ obtain description of the first binary package.
+ """
+ if pkg_name in self.binaries:
+ pass
+ elif pkg_name.lower() == self.source['Source'].lower():
+ pkg_name = self.binaries.keys()[0]
+ else:
+ error("Name %s does not match any binary, nor source package in %s"
+ % (pkg_name, self))
+ return self.binaries[pkg_name]['Description']
+
+def print_wnpp(pkgs, config, wnpp_type="ITP"):
+ """Little helper to spit out formatted entry for WNPP bugreport
+
+ TODO: It would puke atm if any field is missing
+ """
+
+ pkg = pkgs[0] # everything is based on the 1st one
+ opts = dict(pkg.items())
+ opts['WNPP-Type'] = wnpp_type.upper()
+ opts['Pkg-Description-Short'] = re.sub('\n.*', '', pkg['Pkg-Description'])
+
+ subject = "%(WNPP-Type)s: %(Pkg-Name)s -- %(Pkg-Description-Short)s" % opts
+ body = """*** Please type your report below this line ***
+
+* Package name : %(Pkg-Name)s
+ Version : %(Version)s
+ Upstream Author : %(Author)s
+* URL : %(Homepage)s
+* License : %(License)s
+ Programming Lang: %(Language)s
+ Description : %(Pkg-Description)s
+
+""" % opts
+
+ # Unfortunately could not figure out how to set the owner, so I will just print it out
+ if False:
+ tmpfile = tempfile.NamedTemporaryFile()
+ tmpfile.write(body)
+ tmpfile.flush()
+ cmd = "reportbug -b --paranoid --subject='%s' --severity=wishlist --body-file='%s' -o /tmp/o.txt wnpp" \
+ % (subject, tmpfile.name)
+ verbose(2, "Running %s" %cmd)
+ os.system(cmd)
+ else:
+ 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
+