Merge genscripts revision 481
authorfuzzyray <fuzzyray@gentoo.org>
Mon, 15 Nov 2010 19:07:39 +0000 (19:07 -0000)
committerfuzzyray <fuzzyray@gentoo.org>
Mon, 15 Nov 2010 19:07:39 +0000 (19:07 -0000)
svn path=/trunk/gentoolkit/; revision=847

pym/gentoolkit/equery/depends.py
pym/gentoolkit/equery/has.py
pym/gentoolkit/package.py
pym/gentoolkit/test/eclean/distsupport.py
pym/gentoolkit/test/eclean/test_search.py
pym/gentoolkit/test/equery/test_init.py
setup.py

index cab23d1c4499a29f3d6608f88b98005475ee16f3..9e5d8de8e7a2bed3601a890d5632edbe3dd73242 100644 (file)
@@ -40,6 +40,8 @@ QUERY_OPTS = {
 class DependPrinter(object):
        """Output L{gentoolkit.dependencies.Dependencies} objects."""
        def __init__(self, verbose=True):
+               self.verbose = verbose
+
                if verbose:
                        self.print_fn = self.print_verbose
                else:
@@ -62,7 +64,7 @@ class DependPrinter(object):
        def print_quiet(indent, cpv, use_conditional, depatom):
                """Quietly prints a subset set of dep strings."""
 
-               pp.uprint(indent + pp.cpv(cpv))
+               pp.uprint(indent + cpv)
 
        def format_depend(self, dep, dep_is_displayed):
                """Format a dependency for printing.
@@ -71,6 +73,10 @@ class DependPrinter(object):
                @param dep: the dependency to display
                """
 
+               # Don't print blank lines
+               if dep_is_displayed and not self.verbose:
+                       return
+
                depth = getattr(dep, 'depth', 0)
                indent = " " * depth
                mdep = dep.matching_dep
index e40a766786fc5c2e307f97485baaea44e65126f1..9ea5f77c2135369df844598d99360510f81d473b 100644 (file)
@@ -40,9 +40,6 @@ QUERY_OPTS = {
        "env_var": None
 }
 
-AUXDBKEYS = set(auxdbkeys)
-AUXDBKEYS.difference_update(['UNUSED_0{0}'.format(x) for x in range(6)])
-
 # =========
 # Functions
 # =========
@@ -70,11 +67,7 @@ def print_help(with_description=True):
                ("              TMPL",
                        "a format template using (see man page):")
        )))
-       print(" " * 24, ', '.join(pp.emph(x) for x in FORMAT_TMPL_VARS))                        
-       print()
-       print(pp.command("env_var"))
-       print("", ', '.join(pp.emph(x) for x in AUXDBKEYS))                     
-       print(" other env_vars provided by eclasses may be available")
+#      print(" " * 24, ', '.join(pp.emph(x) for x in FORMAT_TMPL_VARS))                        
 
 
 def query_in_env(query, env_var, pkg):
index 70f05d69d97f5aa8057a20351b7b1422a9c6a670..a4031a3a8ad93551d4731ebf2d8ae12cdf7e195e 100644 (file)
@@ -143,7 +143,7 @@ class Package(CPV):
        def environment(self, envvars, prefer_vdb=True, fallback=True):
                """Returns one or more of the predefined environment variables.
 
-               Available envvars are:
+               Some available envvars are:
                ----------------------
                        BINPKGMD5  COUNTER         FEATURES   LICENSE  SRC_URI
                        CATEGORY   CXXFLAGS        HOMEPAGE   PDEPEND  USE
@@ -319,7 +319,7 @@ class Package(CPV):
        def use_status(self):
                """Returns the USE flags active for installation."""
 
-               iuse, final_flags = get_flags(slef.cpv, final_setting=True)
+               iuse, final_flags = get_flags(self.cpv, final_setting=True)
                return final_flags
 
        def parsed_contents(self):
index ab81f7f7ef02baf2ca101bbb410befaf07aa131e..3a4b0114df3bc24aac98073594c6f801874a746a 100644 (file)
@@ -343,7 +343,7 @@ Exclude= {'packages': {
 def get_props(cpvs):
        props = {}
        for cpv in cpvs:
-               props[cpv] = PROPS[cpv]
+               props[cpv] = PROPS[cpv].copy()
        return props
 
 class Dbapi(object):
index 28bd7c6628481a4f81b6871a36a150a22e0ef72e..328c543daa8911bbfd263cb3d539ecd46a3b6391 100644 (file)
@@ -267,7 +267,7 @@ class TestFetchRestricted(unittest.TestCase):
                cpvs.append('app-portage/deprecated-pkg-1.0.0')
                pkgs, deprecated = self.target_class._fetch_restricted(None, cpvs)
                self.record_results('fetch_restricted2', pkgs, deprecated)
-               self.test_results("test_fetch_restricted")
+               self.check_results("test_fetch_restricted")
 
 
        def test_unrestricted(self):
@@ -279,16 +279,20 @@ class TestFetchRestricted(unittest.TestCase):
                cpvs.append('app-portage/deprecated-pkg-1.0.0')
                pkgs, deprecated = self.target_class._unrestricted(None, cpvs)
                self.record_results('unrestricted2', pkgs, deprecated)
-               self.test_results("test_unrestricted")
+               self.check_results("test_unrestricted")
 
 
-       def test_results(self, test_name):
+       def check_results(self, test_name):
                print("\nChecking results for %s,............" %test_name)
                for key in sorted(self.results):
                        testdata = self.testdata[key]
                        results = self.results[key]
                        for item in sorted(testdata):
-                               #print("comparing %s, %s" %(key, item))
+                               if sorted(results[item]) == sorted(testdata[item]):
+                                       test = "OK"
+                               else:
+                                       test = "FAILED"
+                               print("comparing %s, %s" %(key, item), test)
                                self.failUnlessEqual(sorted(testdata[item]), sorted(results[item]),
                                        "\n%s: %s %s data does not match\nresult=" %(test_name, key, item) +\
                                        str(results[item]) + "\ntestdata=" + str(testdata[item]))
@@ -301,6 +305,10 @@ class TestFetchRestricted(unittest.TestCase):
                                }
 
 
+       def tearDown(self):
+               del self.portdb, self.vardb
+
+
 class TestNonDestructive(unittest.TestCase):
        """Tests eclean.search.DistfilesSearch._non_destructive and _destructive
        functions, with addition useage tests of fetch_restricted() and _unrestricted()
@@ -311,13 +319,12 @@ class TestNonDestructive(unittest.TestCase):
                        props=PROPS, cp_list=[], name="FAKE VARDB")
                self.portdb = Dbapi(cp_all=[], cpv_all=CPVS[:4],
                        props=get_props(CPVS[:4]), cp_list=[], name="FAKE PORTDB")
+               print(self.portdb)
                # set a fetch restricted pkg
                self.portdb._props[CPVS[0]]["RESTRICT"] = 'fetch'
                self.callback_data = []
-               self.output = self.output = OutputSimulator(self.callback)
+               self.output = OutputSimulator(self.callback)
                self.target_class = DistfilesSearch(self.output.einfo, self.portdb, self.vardb)
-               self.target_class.portdb = self.portdb
-               self.target_class.portdb = self.portdb
                search.exclDictExpand = self.exclDictExpand
                self.exclude = parseExcludeFile(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'distfiles.exclude'), self.output.einfo)
                #print(self.callback_data)
@@ -346,8 +353,8 @@ class TestNonDestructive(unittest.TestCase):
                                        'deprecated': {
                                                },
                                        'pkgs': {
-                                               'sys-auth/consolekit-0.4.1': 'http://www.freedesktop.org/software/ConsoleKit/dist/ConsoleKit-0.4.1.tar.bz2',
                                                'sys-apps/devicekit-power-014': 'http://hal.freedesktop.org/releases/DeviceKit-power-014.tar.gz',
+                                               'sys-auth/consolekit-0.4.1': 'http://www.freedesktop.org/software/ConsoleKit/dist/ConsoleKit-0.4.1.tar.bz2',
                                                'media-libs/sdl-pango-0.1.2': 'mirror://sourceforge/sdlpango/SDL_Pango-0.1.2.tar.gz http://zarb.org/~gc/t/SDL_Pango-0.1.2-API-adds.patch'
                                                },
                                        'output': [
@@ -485,15 +492,20 @@ class TestNonDestructive(unittest.TestCase):
                        fetch_restricted=False, pkgs_=None)
                self.record_results('non_destructive1', pkgs, deprecated)
 
+               pkgs = None
+               deprecated = None
                self.callback_data = []
                self.vardb._cpv_all=CPVS[:3]
                self.vardb._props=get_props(CPVS[:3])
                self.portdb._cpv_all=CPVS[:]
                self.portdb._props=get_props(CPVS)
+               self.target_class.installed_cpvs = None
                pkgs, deprecated = self.target_class._non_destructive(destructive=True,
                        fetch_restricted=True, pkgs_=None)
                self.record_results('non_destructive2', pkgs, deprecated)
 
+               pkgs = None
+               deprecated = None
                self.callback_data = []
                self.vardb._cpv_all=CPVS[:2]
                self.vardb._props=get_props(CPVS[:2])
@@ -505,19 +517,27 @@ class TestNonDestructive(unittest.TestCase):
                pkgs, deprecated = self.target_class._non_destructive(destructive=True,
                        fetch_restricted=True, pkgs_=pkgs)
                self.record_results('non_destructive3', pkgs, deprecated)
-               self.test_results("test_non_destructive")
+               self.check_results("test_non_destructive")
 
 
-       def test_results(self, test_name):
+       def check_results(self, test_name):
                print("\nChecking results for %s,............" %test_name)
                for key in sorted(self.results):
                        testdata = self.testdata[key]
                        results = self.results[key]
                        for item in sorted(testdata):
-                               #print("comparing %s, %s" %(key, item))
+                               if sorted(results[item]) == sorted(testdata[item]):
+                                       test = "OK"
+                               else:
+                                       test = "FAILED"
+                               print("comparing %s, %s..." %(key, item), test)
+                               if test == "FAILED":
+                                       print("", sorted(results[item]), "\n",  sorted(testdata[item]))
                                self.failUnlessEqual(sorted(testdata[item]), sorted(results[item]),
-                                       "\n%s: %s %s data does not match\nresult=" %(test_name, key, item) +\
-                                       str(results[item]) + "\ntestdata=" + str(testdata[item]))
+                                       "\n%s: %s, %s data does not match\n"
+                                       %(test_name, key, item) + \
+                                       "result=" + str(results[item]) + "\ntestdata=" + str(testdata[item])
+                               )
 
 
        def record_results(self, test, pkgs, deprecated):
@@ -563,7 +583,7 @@ class TestNonDestructive(unittest.TestCase):
                pkgs, deprecated = self.target_class._destructive(package_names=False,
                        exclude=self.exclude, pkgs_=None, installed_included=False )
                self.record_results('destructive4', pkgs, deprecated)
-               self.test_results("test_destructive")
+               self.check_results("test_destructive")
 
                self.callback_data = []
                self.vardb._cpv_all=CPVS[:3]
@@ -575,7 +595,11 @@ class TestNonDestructive(unittest.TestCase):
                pkgs, deprecated = self.target_class._destructive(package_names=False,
                        exclude=self.exclude, pkgs_=None, installed_included=False )
                self.record_results('destructive5', pkgs, deprecated)
-               self.test_results("test_destructive")
+               self.check_results("test_destructive")
+
+
+       def tearDown(self):
+               del self.portdb, self.vardb
 
 
 class TestRemoveProtected(unittest.TestCase):
index 31da63508ce5bc11b4cb012267c35e0426f573d5..996cade8e0e82bb23bad8a6baf20958cb9986529 100644 (file)
@@ -17,7 +17,7 @@ class TestEqueryInit(unittest.TestCase):
        def test_expand_module_name(self):
                # Test that module names are properly expanded
                name_map = {
-                       'a': 'has',
+                       #'a': 'has',
                        'b': 'belongs',
                        'c': 'changes',
                        'k': 'check',
index b643914390fd87b6e8c70ff082fb6c0931c5a59a..55cb3bd4df93c432096212a731e2ed0e2bd6927c 100755 (executable)
--- a/setup.py
+++ b/setup.py
@@ -21,7 +21,7 @@ cwd = os.getcwd()
 try: 
        from portage.const import EPREFIX 
 except ImportError: 
-       EPREFIX='' 
+       EPREFIX='/
 
 
 # Bash files that need `VERSION=""` subbed, relative to this dir:
@@ -95,13 +95,20 @@ def load_test():
 
        return test
 
-
 packages = [
        str('.'.join(root.split(os.sep)[1:]))
        for root, dirs, files in os.walk('pym/gentoolkit')
        if '__init__.py' in files
 ]
 
+test_data = {
+       'gentoolkit': [
+               'test/eclean/Packages',
+               'test/eclean/testdistfiles.tar.gz',
+               'test/eclean/distfiles.exclude'
+       ]
+}
+
 core.setup(
        name='gentoolkit',
        version=__version__,
@@ -115,12 +122,13 @@ core.setup(
                % __version__,
        package_dir={'': 'pym'},
        packages=packages,
+       package_data = test_data,
        scripts=(glob('bin/*')),
        data_files=(
-               (EPREFIX + '/etc/env.d', ['data/99gentoolkit-env']),
-               (EPREFIX + '/etc/revdep-rebuild', ['data/revdep-rebuild/99revdep-rebuild']),
-               (EPREFIX + '/etc/eclean', glob('data/eclean/*')),
-               (EPREFIX + '/usr/share/man/man1', glob('man/*'))
+               (os.path.join(EPREFIX, 'etc/env.d'), ['data/99gentoolkit-env']),
+               (os.path.join(EPREFIX, 'etc/revdep-rebuild'), ['data/revdep-rebuild/99revdep-rebuild']),
+               (os.path.join(EPREFIX, 'etc/eclean'), glob('data/eclean/*')),
+               (os.path.join(EPREFIX, 'usr/share/man/man1'), glob('man/*')),
        ),
        cmdclass={
                'test': load_test(),