[csw-devel] SF.net SVN: gar:[8369] csw/mgar/gar/v2
wahwah at users.sourceforge.net
wahwah at users.sourceforge.net
Sun Feb 7 12:06:43 CET 2010
Revision: 8369
http://gar.svn.sourceforge.net/gar/?rev=8369&view=rev
Author: wahwah
Date: 2010-02-07 11:06:43 +0000 (Sun, 07 Feb 2010)
Log Message:
-----------
mGAR v2: checkpkg, refactored CheckpkgTag to include pkgname for better screen output
Modified Paths:
--------------
csw/mgar/gar/v2/bin/analyze_module_results.py
csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-actionclasses.py
csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-archall.py
csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-libs.py
csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-license.py
csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-missing-symbols.py
csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-obsolete-deps.py
csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-you-can-write-your-own.py
csw/mgar/gar/v2/lib/python/checkpkg.py
csw/mgar/gar/v2/lib/python/checkpkg_test.py
Modified: csw/mgar/gar/v2/bin/analyze_module_results.py
===================================================================
--- csw/mgar/gar/v2/bin/analyze_module_results.py 2010-02-07 04:10:38 UTC (rev 8368)
+++ csw/mgar/gar/v2/bin/analyze_module_results.py 2010-02-07 11:06:43 UTC (rev 8369)
@@ -32,7 +32,7 @@
if line.startswith("#"):
continue
pkgname, tag_name, tag_info = checkpkg.ParseTagLine(line)
- error_tags.append((pkgname, checkpkg.CheckpkgTag(tag_name, tag_info)))
+ error_tags.append(checkpkg.CheckpkgTag(pkgname, tag_name, tag_info))
overrides = reduce(lambda x, y: x + y, overrides_list)
tags_after_overrides = checkpkg.ApplyOverrides(error_tags, overrides)
exit_code = bool(tags_after_overrides)
Modified: csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-actionclasses.py
===================================================================
--- csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-actionclasses.py 2010-02-07 04:10:38 UTC (rev 8368)
+++ csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-actionclasses.py 2010-02-07 11:06:43 UTC (rev 8369)
@@ -33,13 +33,14 @@
only_in_pkgmap = pkgmap_classes.difference(pkginfo_classes)
for action_class in only_in_pkginfo:
error = checkpkg.CheckpkgTag(
+ pkg.pkgname,
"action-class-only-in-pkginfo",
action_class,
msg="This shouldn't cause any problems, but it might be not necessary.")
errors.append(error)
for action_class in only_in_pkgmap:
errors.append(
- checkpkg.CheckpkgTag("action-class-only-in-pkgmap", action_class))
+ checkpkg.CheckpkgTag(pkg.pkgname, "action-class-only-in-pkgmap", action_class))
return errors
Modified: csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-archall.py
===================================================================
--- csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-archall.py 2010-02-07 04:10:38 UTC (rev 8368)
+++ csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-archall.py 2010-02-07 11:06:43 UTC (rev 8369)
@@ -24,7 +24,7 @@
arch = pkginfo["ARCH"]
if binaries and arch == "all":
for binary in binaries:
- errors.append(checkpkg.CheckpkgTag("archall-with-binaries"), binary)
+ errors.append(checkpkg.CheckpkgTag(pkg.pkgname, "archall-with-binaries"), binary)
elif not binaries and arch != "all":
# This is not a clean way of handling messages for the user, but there's
# not better way at the moment.
Modified: csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-libs.py
===================================================================
--- csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-libs.py 2010-02-07 04:10:38 UTC (rev 8368)
+++ csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-libs.py 2010-02-07 11:06:43 UTC (rev 8369)
@@ -202,11 +202,13 @@
for soname in orphan_sonames:
errors.append(
checkpkg.CheckpkgTag(
+ pkgname,
"orphan-soname",
soname))
for missing_dep in missing_deps:
errors.append(
checkpkg.CheckpkgTag(
+ pkgname,
"missing-dependency",
missing_dep))
return errors
Modified: csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-license.py
===================================================================
--- csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-license.py 2010-02-07 04:10:38 UTC (rev 8368)
+++ csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-license.py 2010-02-07 11:06:43 UTC (rev 8369)
@@ -28,6 +28,7 @@
if license_path not in pkgmap.entries_by_path:
errors.append(
checkpkg.CheckpkgTag(
+ pkg.pkgname,
"license-missing",
msg="See http://sourceforge.net/apps/trac/gar/wiki/CopyRight"))
return errors
Modified: csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-missing-symbols.py
===================================================================
--- csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-missing-symbols.py 2010-02-07 04:10:38 UTC (rev 8368)
+++ csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-missing-symbols.py 2010-02-07 11:06:43 UTC (rev 8369)
@@ -43,7 +43,7 @@
missing_symbols = True
binary_base = os.path.basename(binary)
if missing_symbols:
- errors.append(checkpkg.CheckpkgTag("symbol-not-found", binary_base))
+ errors.append(checkpkg.CheckpkgTag(pkg.pkgname, "symbol-not-found", binary_base))
return errors
Modified: csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-obsolete-deps.py
===================================================================
--- csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-obsolete-deps.py 2010-02-07 04:10:38 UTC (rev 8368)
+++ csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-obsolete-deps.py 2010-02-07 11:06:43 UTC (rev 8369)
@@ -43,7 +43,8 @@
if not msg:
msg = None
errors.append(
- checkpkg.CheckpkgTag("obsolete-dependency", obsolete_pkg, msg=msg))
+ checkpkg.CheckpkgTag(pkg.pkgname, "obsolete-dependency",
+ obsolete_pkg, msg=msg))
return errors
Modified: csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-you-can-write-your-own.py
===================================================================
--- csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-you-can-write-your-own.py 2010-02-07 04:10:38 UTC (rev 8368)
+++ csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-you-can-write-your-own.py 2010-02-07 11:06:43 UTC (rev 8369)
@@ -27,10 +27,10 @@
Gets a DirctoryFormatPackage as an argument, and returns a list of errors.
Errors should be a list of checkpkg.CheckpkgTag objects:
- errors.append(checkpkg.CheckpkgTag("tag-name"))
+ errors.append(checkpkg.CheckpkgTag(pkg.pkgname, "tag-name"))
You can also add a parameter:
- errors.append(checkpkg.CheckpkgTag("tag-name", "/opt/csw/bin/problem"))
+ errors.append(checkpkg.CheckpkgTag(pkg.pkgname, "tag-name", "/opt/csw/bin/problem"))
"""
errors = []
# Checking code for an individual package goes here. See the
@@ -40,7 +40,7 @@
# Here's how to report an error:
something_is_wrong = False
if something_is_wrong:
- errors.append(checkpkg.CheckpkgTag("example-problem", "thing"))
+ errors.append(checkpkg.CheckpkgTag(pkg.pkgname, "example-problem", "thing"))
return errors
Modified: csw/mgar/gar/v2/lib/python/checkpkg.py
===================================================================
--- csw/mgar/gar/v2/lib/python/checkpkg.py 2010-02-07 04:10:38 UTC (rev 8368)
+++ csw/mgar/gar/v2/lib/python/checkpkg.py 2010-02-07 11:06:43 UTC (rev 8369)
@@ -540,15 +540,16 @@
class CheckpkgTag(object):
"""Represents a tag to be written to the checkpkg tag file."""
- def __init__(self, tag_name, tag_info=None, severity=None, msg=None):
+ def __init__(self, pkgname, tag_name, tag_info=None, severity=None, msg=None):
+ self.pkgname = pkgname
self.tag_name = tag_name
self.tag_info = tag_info
self.severity = severity
self.msg = msg
def __repr__(self):
- return (u"CheckpkgTag(%s, %s, ...)"
- % (repr(self.tag_name), repr(self.tag_info)))
+ return (u"CheckpkgTag(%s, %s, %s, ...)"
+ % (repr(self.pkgname), repr(self.tag_name), repr(self.tag_info)))
class CheckpkgManager(object):
@@ -588,7 +589,17 @@
for function in self.set_checks:
set_errors = function(packages, debug=self.debug)
if set_errors:
- errors["package-set"] = set_errors
+ # These were generated by a set, but are likely to be bound to specific
+ # packages. We'll try to preserve the package assignments.
+ for tag in set_errors:
+ if tag.pkgname:
+ if not tag.pkgname in errors:
+ errors[tag.pkgname] = []
+ errors[tag.pkgname].append(tag)
+ else:
+ if "package-set" not in errors:
+ errors["package-set"] = []
+ errors["package-set"].append(error)
return errors
def FormatReports(self, errors):
@@ -651,13 +662,13 @@
return (u"Override(%s, %s, %s)"
% (self.pkgname, self.tag_name, self.tag_info))
- def DoesApply(self, pkgname, tag):
+ def DoesApply(self, tag):
"""Figures out if this override applies to the given tag."""
basket_a = {}
basket_b = {}
if self.pkgname:
basket_a["pkgname"] = self.pkgname
- basket_b["pkgname"] = pkgname
+ basket_b["pkgname"] = tag.pkgname
if self.tag_info:
basket_a["tag_info"] = self.tag_info
basket_b["tag_info"] = tag.tag_info
@@ -685,15 +696,16 @@
def ApplyOverrides(error_tags, overrides):
- """Filters out all the error tags that overrides apply to."""
+ """Filters out all the error tags that overrides apply to.
+
+ O(N * M), but N and M are always small.
+ """
tags_after_overrides = []
- # This can be done more efficiently after creating indexes, but I'm going to
- # do an O(N*M) as if I didn't know anything about programming. :-P
- for pkgname, tag in error_tags:
+ for tag in error_tags:
override_applies = False
for override in overrides:
- if override.DoesApply(pkgname, tag):
+ if override.DoesApply(tag):
override_applies = True
if not override_applies:
- tags_after_overrides.append((pkgname, tag))
+ tags_after_overrides.append(tag)
return tags_after_overrides
Modified: csw/mgar/gar/v2/lib/python/checkpkg_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/checkpkg_test.py 2010-02-07 04:10:38 UTC (rev 8368)
+++ csw/mgar/gar/v2/lib/python/checkpkg_test.py 2010-02-07 11:06:43 UTC (rev 8369)
@@ -590,7 +590,7 @@
m = checkpkg.CheckpkgManager("testname", "/tmp", ["CSWfoo"])
tags = {
"CSWfoo": [
- checkpkg.CheckpkgTag("foo-tag", "foo-info"),
+ checkpkg.CheckpkgTag("CSWfoo", "foo-tag", "foo-info"),
],
}
screen_report, tags_report = m.FormatReports(tags)
@@ -601,9 +601,9 @@
m = checkpkg.CheckpkgManager("testname", "/tmp", ["CSWfoo"])
tags = {
"CSWfoo": [
- checkpkg.CheckpkgTag("foo-tag", "foo-info"),
- checkpkg.CheckpkgTag("bar-tag", "bar-info"),
- checkpkg.CheckpkgTag("baz-tag"),
+ checkpkg.CheckpkgTag("CSWfoo", "foo-tag", "foo-info"),
+ checkpkg.CheckpkgTag("CSWfoo", "bar-tag", "bar-info"),
+ checkpkg.CheckpkgTag("CSWfoo", "baz-tag"),
],
}
screen_report, tags_report = m.FormatReports(tags)
@@ -671,47 +671,47 @@
def test_1a(self):
"""One tag, no overrides."""
- tags = [(None, checkpkg.CheckpkgTag("foo-tag"))]
+ tags = [checkpkg.CheckpkgTag("CSWfoo", "foo-tag")]
overrides = []
self.assertEqual(tags, checkpkg.ApplyOverrides(tags, overrides))
def test_1b(self):
"""One override, matching by tag name only."""
- tags = [(None, checkpkg.CheckpkgTag("foo-tag"))]
+ tags = [checkpkg.CheckpkgTag("CSWfoo", "foo-tag")]
overrides = [checkpkg.Override(None, "foo-tag", None)]
self.assertEqual([], checkpkg.ApplyOverrides(tags, overrides))
def test_1c(self):
"""One override, matching by tag name only, no pkgname."""
- tags = [(None, checkpkg.CheckpkgTag("foo-tag"))]
+ tags = [checkpkg.CheckpkgTag("CSWfoo", "foo-tag")]
overrides = [checkpkg.Override(None, "foo-tag", None)]
self.assertEqual([], checkpkg.ApplyOverrides(tags, overrides))
def test_2(self):
"""One override, matching by tag name and tag info, no pkgname."""
- tags = [(None, checkpkg.CheckpkgTag("foo-tag", "tag-info-1"))]
+ tags = [checkpkg.CheckpkgTag("CSWfoo", "foo-tag")]
overrides = [checkpkg.Override(None, "foo-tag", None)]
self.assertEqual([], checkpkg.ApplyOverrides(tags, overrides))
def test_3(self):
"""One override, matching by tag name, mismatching tag info, no pkgname."""
- tags = [(None, checkpkg.CheckpkgTag("foo-tag", "tag-info-1"))]
+ tags = [checkpkg.CheckpkgTag("CSWfoo", "foo-tag", "tag-info-1")]
overrides = [checkpkg.Override(None, "foo-tag", "tag-info-2")]
self.assertEqual(tags, checkpkg.ApplyOverrides(tags, overrides))
def test_4(self):
- tags = [("CSWfoo", checkpkg.CheckpkgTag("foo-tag", "tag-info-1"))]
+ tags = [checkpkg.CheckpkgTag("CSWfoo", "foo-tag", "tag-info-1")]
overrides = [checkpkg.Override(None, "foo-tag", "tag-info-1")]
self.assertEqual([], checkpkg.ApplyOverrides(tags, overrides))
def test_5(self):
- tags = [("CSWfoo", checkpkg.CheckpkgTag("foo-tag", "tag-info-1"))]
+ tags = [checkpkg.CheckpkgTag("CSWfoo", "foo-tag", "tag-info-1")]
overrides = [checkpkg.Override("CSWfoo", "foo-tag", "tag-info-1")]
self.assertEqual([], checkpkg.ApplyOverrides(tags, overrides))
def test_5(self):
"""Pkgname mismatch."""
- tags = [("CSWfoo", checkpkg.CheckpkgTag("foo-tag", "tag-info-1"))]
+ tags = [checkpkg.CheckpkgTag("CSWfoo", "foo-tag", "tag-info-1")]
overrides = [checkpkg.Override("CSWbar", "foo-tag", "tag-info-1")]
self.assertEqual(tags, checkpkg.ApplyOverrides(tags, overrides))
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the devel
mailing list