[CMF-checkins] SVN: CMF/trunk/CMFSetup/ removed some utils that are
now in GenericSetup/utils.py
Yvo Schubbe
y.2005- at wcm-solutions.de
Thu Sep 29 02:58:00 EDT 2005
Log message for revision 38679:
removed some utils that are now in GenericSetup/utils.py
Changed:
U CMF/trunk/CMFSetup/tests/test_utils.py
U CMF/trunk/CMFSetup/utils.py
-=-
Modified: CMF/trunk/CMFSetup/tests/test_utils.py
===================================================================
--- CMF/trunk/CMFSetup/tests/test_utils.py 2005-09-29 06:47:47 UTC (rev 38678)
+++ CMF/trunk/CMFSetup/tests/test_utils.py 2005-09-29 06:57:59 UTC (rev 38679)
@@ -166,71 +166,7 @@
</dummy>
"""
-def _testFunc( *args, **kw ):
- """ This is a test.
-
- This is only a test.
- """
-
-_TEST_FUNC_NAME = 'Products.CMFSetup.tests.test_utils._testFunc'
-
-class Whatever:
- pass
-
-_WHATEVER_NAME = 'Products.CMFSetup.tests.test_utils.Whatever'
-
-whatever_inst = Whatever()
-whatever_inst.__name__ = 'whatever_inst'
-
-_WHATEVER_INST_NAME = 'Products.CMFSetup.tests.test_utils.whatever_inst'
-
-class UtilsTests( unittest.TestCase ):
-
- def test__getDottedName_simple( self ):
-
- from Products.CMFSetup.utils import _getDottedName
-
- self.assertEqual( _getDottedName( _testFunc ), _TEST_FUNC_NAME )
-
- def test__getDottedName_string( self ):
-
- from Products.CMFSetup.utils import _getDottedName
-
- self.assertEqual( _getDottedName( _TEST_FUNC_NAME ), _TEST_FUNC_NAME )
-
- def test__getDottedName_unicode( self ):
-
- from Products.CMFSetup.utils import _getDottedName
-
- dotted = u'%s' % _TEST_FUNC_NAME
- self.assertEqual( _getDottedName( dotted ), _TEST_FUNC_NAME )
- self.assertEqual( type( _getDottedName( dotted ) ), str )
-
- def test__getDottedName_class( self ):
-
- from Products.CMFSetup.utils import _getDottedName
-
- self.assertEqual( _getDottedName( Whatever ), _WHATEVER_NAME )
-
- def test__getDottedName_inst( self ):
-
- from Products.CMFSetup.utils import _getDottedName
-
- self.assertEqual( _getDottedName( whatever_inst )
- , _WHATEVER_INST_NAME )
-
- def test__getDottedName_noname( self ):
-
- from Products.CMFSetup.utils import _getDottedName
-
- class Doh:
- pass
-
- doh = Doh()
- self.assertRaises( ValueError, _getDottedName, doh )
-
-
class DummyObject(Folder):
meta_type = 'Dummy Type'
@@ -509,11 +445,7 @@
def test_suite():
- # reimport to make sure tests are run from Products
- from Products.CMFSetup.tests.test_utils import UtilsTests
-
return unittest.TestSuite((
- unittest.makeSuite( UtilsTests ),
unittest.makeSuite( ImportConfiguratorBaseTests ),
unittest.makeSuite( ExportConfiguratorBaseTests ),
))
Modified: CMF/trunk/CMFSetup/utils.py
===================================================================
--- CMF/trunk/CMFSetup/utils.py 2005-09-29 06:47:47 UTC (rev 38678)
+++ CMF/trunk/CMFSetup/utils.py 2005-09-29 06:57:59 UTC (rev 38679)
@@ -16,9 +16,7 @@
"""
import os
-from inspect import getdoc
from xml.dom.minidom import parseString as domParseString
-from xml.sax.handler import ContentHandler
import Products
from AccessControl import ClassSecurityInfo
@@ -33,107 +31,11 @@
_pkgdir = package_home( globals() )
-_wwwdir = os.path.join( _pkgdir, 'www' )
-_datadir = os.path.join( _pkgdir, 'data' )
_xmldir = os.path.join( _pkgdir, 'xml' )
CONVERTER, DEFAULT, KEY = range(3)
-def _getDottedName( named ):
-
- if isinstance( named, basestring ):
- return str( named )
-
- try:
- return '%s.%s' % ( named.__module__, named.__name__ )
- except AttributeError:
- raise ValueError, 'Cannot compute dotted name: %s' % named
-
-def _resolveDottedName( dotted ):
-
- parts = dotted.split( '.' )
-
- if not parts:
- raise ValueError, "incomplete dotted name: %s" % dotted
-
- parts_copy = parts[:]
-
- while parts_copy:
- try:
- module = __import__( '.'.join( parts_copy ) )
- break
-
- except ImportError:
-
- del parts_copy[ -1 ]
-
- if not parts_copy:
- raise
-
- parts = parts[ 1: ] # Funky semantics of __import__'s return value
-
- obj = module
-
- for part in parts:
- obj = getattr( obj, part )
-
- return obj
-
-def _extractDocstring( func, default_title, default_description ):
-
- try:
- doc = getdoc( func )
- lines = doc.split( '\n' )
-
- except AttributeError:
-
- title = default_title
- description = default_description
-
- else:
- title = lines[ 0 ]
-
- if len( lines ) > 1 and lines[ 1 ].strip() == '':
- del lines[ 1 ]
-
- description = '\n'.join( lines[ 1: ] )
-
- return title, description
-
-
-class HandlerBase( ContentHandler ):
-
- _encoding = None
- _MARKER = object()
-
- def _extract( self, attrs, key, default=None ):
-
- result = attrs.get( key, self._MARKER )
-
- if result is self._MARKER:
- return default
-
- return self._encode( result )
-
- def _extractBoolean( self, attrs, key, default ):
-
- result = attrs.get( key, self._MARKER )
-
- if result is self._MARKER:
- return default
-
- result = result.lower()
- return result in ( '1', 'yes', 'true' )
-
- def _encode( self, content ):
-
- if self._encoding is None:
- return content
-
- return content.encode( self._encoding )
-
-
class ImportConfiguratorBase(Implicit):
""" Synthesize data from XML description.
"""
More information about the CMF-checkins
mailing list