[Checkins] SVN: grok/branches/grok-martian/src/grok/ Remove scan tests and scan module as these have moved into martian.

Martijn Faassen faassen at infrae.com
Tue Jun 19 16:17:37 EDT 2007


Log message for revision 76815:
  Remove scan tests and scan module as these have moved into martian.
  

Changed:
  D   grok/branches/grok-martian/src/grok/scan.py
  U   grok/branches/grok-martian/src/grok/tests/directive/multipletimes.py
  D   grok/branches/grok-martian/src/grok/tests/scan/
  U   grok/branches/grok-martian/src/grok/tests/test_grok.py
  U   grok/branches/grok-martian/src/grok/tests/zcml/directivemodule.py
  U   grok/branches/grok-martian/src/grok/tests/zcml/directivepackage.py
  A   grok/branches/grok-martian/src/grok/tests/zcml/stoneage/

-=-
Deleted: grok/branches/grok-martian/src/grok/scan.py
===================================================================
--- grok/branches/grok-martian/src/grok/scan.py	2007-06-19 20:12:41 UTC (rev 76814)
+++ grok/branches/grok-martian/src/grok/scan.py	2007-06-19 20:17:35 UTC (rev 76815)
@@ -1,126 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2006 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Scanning packages and modules
-"""
-
-import os
-
-from zope.dottedname.resolve import resolve
-
-
-def is_package(path):
-    if not os.path.isdir(path):
-        return False
-    init_py = os.path.join(path, '__init__.py')
-    init_pyc = init_py + 'c'
-    # Check whether either __init__.py or __init__.pyc exist
-    return os.path.isfile(init_py) or os.path.isfile(init_pyc)
-
-
-class ModuleInfo(object):
-
-    def __init__(self, path, dotted_name):
-        # Normalize .pyc files to .py
-        if path.endswith('c'):
-            path = path[:-1]
-        self.path = path
-        self.dotted_name = dotted_name
-
-        name_parts = dotted_name.split('.')
-        self.name = name_parts[-1]
-        if self.isPackage():
-            self.package_dotted_name = dotted_name
-        else:
-            self.package_dotted_name = '.'.join(name_parts[:-1])
-
-        self._module = None
-
-    def getResourcePath(self, name):
-        """Get the absolute path of a resource directory 'relative' to this
-        package or module.
-
-        Case one: get the resource directory with name <name> from the same
-        directory as this module
-
-        Case two: get the resource directory with name <name> from the children
-        of this package
-        """
-        return os.path.join(os.path.dirname(self.path), name)
-
-    def getSubModuleInfos(self):
-        if not self.isPackage():
-            return []
-        directory = os.path.dirname(self.path)
-        module_infos = []
-        seen = []
-        for entry in sorted(os.listdir(directory)):
-            entry_path = os.path.join(directory, entry)
-            name, ext = os.path.splitext(entry)
-            dotted_name = self.dotted_name + '.' + name
-
-            # Case one: modules
-            if (os.path.isfile(entry_path) and ext in ['.py', '.pyc']):
-                if name == '__init__':
-                    continue
-                # Avoid duplicates when both .py and .pyc exist
-                if name in seen:
-                    continue
-                seen.append(name)
-                module_infos.append(ModuleInfo(entry_path, dotted_name))
-            # Case two: packages
-            elif is_package(entry_path):
-                # We can blindly use __init__.py even if only
-                # __init__.pyc exists because we never actually use
-                # that filename.
-                module_infos.append(ModuleInfo(
-                    os.path.join(entry_path, '__init__.py'), dotted_name))
-        return module_infos
-
-    def getSubModuleInfo(self, name):
-        path = os.path.join(os.path.dirname(self.path), name)
-        if is_package(path):
-            return ModuleInfo(os.path.join(path, '__init__.py'),
-                              '%s.%s' % (self.package_dotted_name, name))
-        elif os.path.isfile(path + '.py') or os.path.isfile(path + '.pyc'):
-                return ModuleInfo(path + '.py',
-                                  '%s.%s' % (self.package_dotted_name, name))
-        else:
-            return None
-        
-
-    def getAnnotation(self, key, default):
-        key = key.replace('.', '_')
-        key = '__%s__' % key
-        module = self.getModule()
-        return getattr(module, key, default)
-
-    def getModule(self):
-        if self._module is None:
-            self._module = resolve(self.dotted_name)
-        return self._module
-
-    def isPackage(self):
-        return self.path.endswith('__init__.py')
-
-    def __repr__(self):
-        return "<ModuleInfo object for '%s'>" % self.dotted_name
-
-
-def module_info_from_dotted_name(dotted_name):
-    module = resolve(dotted_name)
-    return ModuleInfo(module.__file__, dotted_name)
-
-def module_info_from_module(module):
-    return ModuleInfo(module.__file__, module.__name__)
-

Modified: grok/branches/grok-martian/src/grok/tests/directive/multipletimes.py
===================================================================
--- grok/branches/grok-martian/src/grok/tests/directive/multipletimes.py	2007-06-19 20:12:41 UTC (rev 76814)
+++ grok/branches/grok-martian/src/grok/tests/directive/multipletimes.py	2007-06-19 20:17:35 UTC (rev 76815)
@@ -2,7 +2,7 @@
 Since grok.global_utility is a MultipleTimesDirective, there is a list of
 GlobalUtilityInfo objects annotated on the module.
 
-  >>> from grok import scan
+  >>> from martian import scan
   >>> from grok.tests.directive import multipletimes
   >>> module_info = scan.module_info_from_module(multipletimes)
   >>> guis = module_info.getAnnotation('grok.global_utility', None)

Modified: grok/branches/grok-martian/src/grok/tests/test_grok.py
===================================================================
--- grok/branches/grok-martian/src/grok/tests/test_grok.py	2007-06-19 20:12:41 UTC (rev 76814)
+++ grok/branches/grok-martian/src/grok/tests/test_grok.py	2007-06-19 20:17:35 UTC (rev 76815)
@@ -32,7 +32,7 @@
 
 def test_suite():
     suite = unittest.TestSuite()
-    for name in ['adapter', 'error', 'view', 'scan', 'event', 'security',
+    for name in ['adapter', 'error', 'view', 'event', 'security',
                  'zcml', 'static', 'utility', 'xmlrpc', 'json', 'container',
                  'traversal', 'form', 'site', 'grokker', 'directive', 'util',
                  'baseclass', 'annotation', 'application']:

Modified: grok/branches/grok-martian/src/grok/tests/zcml/directivemodule.py
===================================================================
--- grok/branches/grok-martian/src/grok/tests/zcml/directivemodule.py	2007-06-19 20:12:41 UTC (rev 76814)
+++ grok/branches/grok-martian/src/grok/tests/zcml/directivemodule.py	2007-06-19 20:17:35 UTC (rev 76815)
@@ -8,10 +8,10 @@
   ...     xmlns="http://namespaces.zope.org/zope"
   ...     xmlns:grok="http://namespaces.zope.org/grok"
   ...     >
-  ...     <grok:grok package="grok.tests.scan.stoneage.cave"/>
+  ...     <grok:grok package="grok.tests.zcml.stoneage.cave"/>
   ... </configure>''', context=context)
 
-  >>> from grok.tests.scan.stoneage.cave import Cave
+  >>> from grok.tests.zcml.stoneage.cave import Cave
   >>> cave = Cave()
   
   >>> from zope.publisher.browser import TestRequest

Modified: grok/branches/grok-martian/src/grok/tests/zcml/directivepackage.py
===================================================================
--- grok/branches/grok-martian/src/grok/tests/zcml/directivepackage.py	2007-06-19 20:12:41 UTC (rev 76814)
+++ grok/branches/grok-martian/src/grok/tests/zcml/directivepackage.py	2007-06-19 20:17:35 UTC (rev 76815)
@@ -8,11 +8,11 @@
   ...     xmlns="http://namespaces.zope.org/zope"
   ...     xmlns:grok="http://namespaces.zope.org/grok"
   ...     >
-  ...     <grok:grok package="grok.tests.scan.stoneage"/>
+  ...     <grok:grok package="grok.tests.zcml.stoneage"/>
   ... </configure>''', context=context)
 
-  >>> from grok.tests.scan.stoneage.cave import Cave
-  >>> from grok.tests.scan.stoneage.hunt.mammoth import Mammoth
+  >>> from grok.tests.zcml.stoneage.cave import Cave
+  >>> from grok.tests.zcml.stoneage.hunt.mammoth import Mammoth
   >>> manfred = Mammoth()
   >>> cave = Cave()
   
@@ -35,4 +35,4 @@
   <h1>ME GROK HUNT MAMMOTH!</h1>
   </body>
   </html>
-"""
\ No newline at end of file
+"""

Copied: grok/branches/grok-martian/src/grok/tests/zcml/stoneage (from rev 76792, grok/branches/grok-martian/src/grok/tests/scan/stoneage)



More information about the Checkins mailing list