# HG changeset patch # User Sylvain Thénault # Date 1269545938 -3600 # Node ID 2826f5406201942ab9760b55901aa84900747475 # Parent 9e718abe3fdeca13e7621f5597668018bebfb2f6 deprecate __use__ and __recommend__ diff -r 9e718abe3fde -r 2826f5406201 cwconfig.py --- a/cwconfig.py Thu Mar 25 20:33:03 2010 +0100 +++ b/cwconfig.py Thu Mar 25 20:38:58 2010 +0100 @@ -404,14 +404,33 @@ return Version(version) @classmethod + def _cube_deps(cls, cube, key, oldkey): + """return cubicweb cubes used by the given cube""" + pkginfo = cls.cube_pkginfo(cube) + try: + deps = getattr(pkginfo, key) + except AttributeError: + if hasattr(pkginfo, oldkey): + warn('[3.6] %s is deprecated, use %s dict' % (oldkey, key), + DeprecationWarning) + deps = getattr(pkginfo, oldkey) + else: + deps = {} + if not isinstance(deps, dict): + deps = dict((key, None) for key in deps) + warn('[3.6] cube %s should define %s as a dict' % (cube, key), + DeprecationWarning) + return deps + + @classmethod def cube_dependencies(cls, cube): """return cubicweb cubes used by the given cube""" - return getattr(cls.cube_pkginfo(cube), '__use__', ()) + return cls._cube_deps(cube, '__depends_cubes__', '__use__') @classmethod def cube_recommends(cls, cube): """return cubicweb cubes recommended by the given cube""" - return getattr(cls.cube_pkginfo(cube), '__recommend__', ()) + return cls._cube_deps(cube, '__recommends_cubes__', '__recommend__') @classmethod def expand_cubes(cls, cubes, with_recommends=False): @@ -444,9 +463,10 @@ graph = {} for cube in cubes: cube = CW_MIGRATION_MAP.get(cube, cube) - deps = cls.cube_dependencies(cube) + \ - cls.cube_recommends(cube) - graph[cube] = set(dep for dep in deps if dep in cubes) + graph[cube] = set(dep for dep in cls.cube_dependencies(cube) + if dep in cubes) + graph[cube] |= set(dep for dep in cls.cube_recommends(cube) + if dep in cubes) cycles = get_cycles(graph) if cycles: cycles = '\n'.join(' -> '.join(cycle) for cycle in cycles) diff -r 9e718abe3fde -r 2826f5406201 cwctl.py --- a/cwctl.py Thu Mar 25 20:33:03 2010 +0100 +++ b/cwctl.py Thu Mar 25 20:38:58 2010 +0100 @@ -13,6 +13,7 @@ # possible (for cubicweb-ctl reactivity, necessary for instance for usable bash # completion). So import locally in command helpers. import sys +from warnings import warn from os import remove, listdir, system, pathsep try: from os import kill, getpgid @@ -295,10 +296,17 @@ tversion = '[missing cube information]' print '* %s %s' % (cube.ljust(namesize), tversion) if self.config.verbose: - shortdesc = tinfo and (getattr(tinfo, 'short_desc', '') - or tinfo.__doc__) - if shortdesc: - print ' '+ ' \n'.join(shortdesc.splitlines()) + if tinfo: + descr = getattr(tinfo, 'description', '') + if not descr: + descr = getattr(tinfo, 'short_desc', '') + if descr: + warn('[3.8] short_desc is deprecated, update %s' + ' pkginfo' % cube, DeprecationWarning) + else: + descr = tinfo.__doc__ + if descr: + print ' '+ ' \n'.join(descr.splitlines()) modes = detect_available_modes(cwcfg.cube_dir(cube)) print ' available modes: %s' % ', '.join(modes) print diff -r 9e718abe3fde -r 2826f5406201 skeleton/__pkginfo__.py.tmpl --- a/skeleton/__pkginfo__.py.tmpl Thu Mar 25 20:33:03 2010 +0100 +++ b/skeleton/__pkginfo__.py.tmpl Thu Mar 25 20:38:58 2010 +0100 @@ -41,7 +41,9 @@ # them to be included in the debian package __depends__ = {'cubicweb': '>= 3.6.0'} -__depends_cubes__ = {} +__depends_cubes__ = dict( (x[len('cubicweb-):], v) for x, v in __depends__ + if x.startswith('cubicweb-')) __recommends__ = {} -__recommends_cubes__ = {} +__recommends_cubes__ = dict( (x[len('cubicweb-):], v) for x, v in __recommends__ + if x.startswith('cubicweb-')) diff -r 9e718abe3fde -r 2826f5406201 test/unittest_cwconfig.py --- a/test/unittest_cwconfig.py Thu Mar 25 20:33:03 2010 +0100 +++ b/test/unittest_cwconfig.py Thu Mar 25 20:38:58 2010 +0100 @@ -55,7 +55,7 @@ def test_reorder_cubes_recommends(self): from cubes.comment import __pkginfo__ as comment_pkginfo - comment_pkginfo.__recommend__ = ('file',) + comment_pkginfo.__recommends_cubes__ = {'file': None} try: # email recommends comment # comment recommends file @@ -68,7 +68,7 @@ self.assertEquals(self.config.reorder_cubes(('comment', 'forge', 'email', 'file')), ('forge', 'email', 'comment', 'file')) finally: - comment_pkginfo.__use__ = () + comment_pkginfo.__recommends_cubes__ = {} # def test_vc_config(self):