Changeset 143

Show
Ignore:
Timestamp:
Wed Nov 23 15:55:02 2005
Author:
drew
Message:

bump

Files:

Legend:

Unmodified
Added
Removed
Modified
  • trunk/tests/doctests/utils/config.py

    r120 r143  
    1   '''  
      1 """  
    1 1 doctests for xix.utils.config  
    2   '''  
      2 """  
    2 2  
    3 3 __author__ = 'Drew Smathers'  
     
    19 19 class ConfigLoaderTest:  
    20 20     def example_noDuplicateEntries(self):  
    21           '''  
      21         """  
    21 21         Duplicate entries are strictly not allowed:  
    22 22  
    23           >>> fd = File("""  
      23         >>> fd = File('''  
    23 23         ... foo.bar=123  
    24 24         ... foo.bar="foobar"  
    25           ... """)  
    26           >>> ConfigLoader.load(fd)  
      25         ... ''')  
      26         >>> loader = ConfigLoader()  
      27         >>> loader.load(fd)  
    27 28         Traceback (most recent call last):  
    28 29         ...  
    29 30         ConfigLoaderException: Duplicate entry foo.bar  
    30           '''  
      31         """  
    30 31     def example_cannotOverrideTerminalNodes(self):  
    31           '''  
      32         """  
    31 32         Cannot override terminal nodes:  
    32 33  
    33           >>> fd = File("""  
      34         >>> fd = File('''  
    33 34         ... foo=123  
    34 35         ... foo.bar="foobar"  
    35           ... """)  
    36           >>> ConfigLoader.load(fd)  
      36         ... ''')  
      37         >>> loader = ConfigLoader()  
      38         >>> loader.load(fd)  
    37 39         Traceback (most recent call last):  
    38 40         ...  
    39 41         ConfigLoaderException: Duplicate entry foo.bar  
    40           '''  
      42         """  
    40 42     def example_wellFormedFiles():  
    41           '''  
      43         """  
    41 43         Configuration files must be well formed:  
    42 44  
    43 45         >>> fd = File("crap here")  
    44           >>> ConfigLoader.load(fd)  
      46         >>> loader = ConfigLoader()  
      47         >>> loader.load(fd)  
    45 48         Traceback (most recent call last):  
    46 49         ...  
    47 50         ConfigLoaderException: Malformed line found in configuration: crap here  
    48           '''  
      51         """  
    48 51     def example_validNodeName(self):  
    49           '''  
      52         """  
    49 52         Configuration nodes must be valid python names:  
    50 53  
    51 54         >>> fd = File("this.123='hello'")  
    52           >>> ConfigLoader.load(fd)  
      55         >>> loader = ConfigLoader()  
      56         >>> loader.load(fd)  
    53 57         Traceback (most recent call last):  
    54 58         ...  
    55 59         ConfigLoaderException: Config node 123 does not map to valid Python name  
    56           '''  
      60         """  
    56 60     def example_valueImplicitPythonSyntax(self):  
    57           '''  
      61         """  
    57 61         Type values are implicit by given python syntax:  
    58 62  
    59 63         >>> fd = File("foo.bar=[1,2,3]")  
    60           >>> cfg = ConfigLoader.load(fd)  
      64         >>> loader = ConfigLoader()  
      65         >>> cfg = loader.load(fd)  
    61 66         >>> type(cfg.foo.bar)  
    62 67         <type 'list'>  
    63           '''  
      68         """  
      69     def example_builtinPlugins_path(self):  
      70         """Using the builtin path plugin  
      71  
      72         >>> fd = File("foo.bar=path('/this/is/a/path')")  
      73         >>> loader = ConfigLoader()  
      74         >>> cfg = loader.load(fd)  
      75         >>> import os.path  
      76         >>> int(os.path.sep in cfg.foo.bar)  
      77         1  
      78         >>> print cfg.foo.bar.replace(os.path.sep, '/')  
      79         /this/is/a/path  
      80         """  
    64 81     def example_mustIndicateStringsWithQuotes(self):  
    65           '''  
      82         """  
    65 82         Strings MUST be indicated with quotes (single or double):  
    66 83          
    67 84         >>> fd = File("foo.bar=not good dude")  
    68           >>> ConfigLoader.load(fd)  
      85         >>> loader = ConfigLoader()  
      86         >>> loader.load(fd)  
    69 87         Traceback (most recent call last):  
    70 88         ...  
    71           ConfigLoaderException: Cannot resolve type : not good dude.  
    72           '''  
      89         ConfigLoaderException: Internal exception while trying to convert not good dude -- Cannot resolve type : not good dude.  
      90         """  
    73 91     def example_someTypesNotSupported(self):  
    74           '''  
      92         """  
    74 92         Not all types are supported:  
    75 93          
    76 94         >>> fd = File("foo.bar=type")  
    77           >>> ConfigLoader.load(fd)  
      95         >>> loader = ConfigLoader()  
      96         >>> loader.load(fd)  
    78 97         Traceback (most recent call last):  
    79 98         ...  
    80 99         ConfigLoaderException: Unsupported type: <type 'type'>.  
    81           '''  
      100         """  
    81 100     def example_moduleWrapper(self):  
    82           '''  
      101         """  
    82 101         We can also get a module wrapper ...  
    83 102  
    84 103         >>> fd = File("foo.bar=xix.utils.string")  
    85           >>> cfg = ConfigLoader.load(fd)  
      104         >>> loader = ConfigLoader()  
      105         >>> cfg = loader.load(fd)  
    86 106         >>> from xix.utils.interfaces import IModuleWrapper  
    87 107         >>> IModuleWrapper.providedBy(cfg.foo.bar)  
    88 108         True  
    89           '''  
      109         """  
    89 109  
    90 110  
     
    110 130  
    111 131 class ConfigFactoryTest:  
    112       '''ConfigFactory unit tests  
    113       '''  
      132     """ConfigFactory unit tests  
      133     """  
    114 134  
    115 135     def verifySingletonInstance(self):  
    116           '''Let's make sure these tests are valid - i.e. configFactory  
      136         """Let's make sure these tests are valid - i.e. configFactory  
    116 136         is an instance of ConfigFactory:  
    117 137  
    118 138         >>> configFactory.__class__ == ConfigFactory  
    119 139         True  
    120           '''  
      140         """  
    120 140  
    121 141     def getConfig(self):  
    122           '''Example usage of config API.  You should make a __appcfg__.py  
      142         """Example usage of config API.  You should make a __appcfg__.py  
    122 142         module for you package which does all the addResource shit ...  
    123 143  
     
    131 151         >>> cfg.my.little.test  
    132 152         'Hello World'  
    133           '''  
      153         """  
      154  
      155     def callAlias(self):  
      156         """Using call instead of getConfig  
      157  
      158         >>> _resetConfigFactory()  
      159         >>> from xix.utils.python import fileHere  
      160         >>> configFactory.addResource("test.cfg", fileHere("__testcfg__.cfg"))  
      161         >>> cfg = configFactory("test.cfg")  
      162         >>> cfg.my.little.test  
      163         'Hello World'  
      164         """  
    134 165  
    135 166     def reloadConfig(self):  
    136           '''Reloading a config forces the config to be loaded again into memory.  
      167         """Reloading a config forces the config to be loaded again into memory.  
    136 167         This will reload from file of course, which means any references to config  
    137 168         object you have elsewhere may be out of sync with what's freshly loaded.  
     
    151 182         >>> cfg.my.little.test  
    152 183         'Hello World'  
    153           '''  
      184         """  
    153 184  
    154 185     def addResource_url(self):  
    155           '''Adding a reource ... This is demonstrated well in other tests, but here  
      186         """Adding a reource ... This is demonstrated well in other tests, but here  
    155 186         goes.  
    156 187  
     
    164 195         >>> IConfig.providedBy(cfg)  
    165 196         True  
    166           '''  
      197         """  
    166 197      
    167 198     def addResource_config(self):  
    168           '''Using config keyword argument:  
      199         """Using config keyword argument:  
    168 199  
    169 200         >>> _resetConfigFactory()  
     
    179 210         >>> IConfig.providedBy(cfg)  
    180 211         True  
    181           '''  
      212         """  
    181 212  
    182 213     def addResource_urlAndConfig(self):  
    183           '''Using url and config keyword arguments together:  
      214         """Using url and config keyword arguments together:  
    183 214  
    184 215         >>> _resetConfigFactory()  
     
    201 232         >>> cfg.my.little.test  
    202 233         'Hello World'  
    203           '''  
      234         """  
    203 234  
  • trunk/setup.py

    r138 r143  
    24 24     description='Web Application Prototyping Kit',  
    25 25     url='http://www.cc.gatech.edu/ugrads/d/dpaces/',  
    26       packages=['xix', 'xix.rend', 'xix.services', 'xix.tests','xix.utils', 'xix.taps'],  
      26     packages=['xix', 'xix.rend', 'xix.services', 'xix.tests','xix.utils', 'xix.taps', 'xix.utils.comp'],  
    26 26     package_data = {'xix' : ['plugins.tml', 'utils/README']},  
    27 27     scripts=['xix/scripts/xxrclient', 'xix/scripts/runxix']  
  • trunk/xix/utils/string.py

    r112 r143  
    7 7 # $Id$  
    8 8  
    9   from xix.utils.aspout import getlogger  
    10   write = getlogger()  
      9 #from xix.utils.aspout import getlogger  
      10 #write = getlogger()  
    11 11  
    12 12  
     
    77 77 iprint = IndentPrint()  
    78 78  
      79 def underline(msg, chr='-'):  
      80     """Underline string msg with stream of characters to same length.  
      81  
      82     Examplae usage:  
      83  
      84     >>> print underline('This is a message')  
      85     This is a message  
      86     -----------------  
      87     >>> print underline('This is another message', chr='*')  
      88     This is another message  
      89     ***********************  
      90     """  
      91     return msg + '\n' + chr * len(msg)  
      92  
    79 93 def trim( string, maxlen=100, ellipsis='...' ):  
    80 94     ellipsis = ellipsis or ''  
     
    83 97  
    84 98 # DO NOT USE THIS METHOD ... USE YOUR MODULE'S WRITER AND TRIM INSTEAD  
    85   def prim(string, maxlen=75, ellipsis='...'):  
    86       write( trim( string, maxlen, ellipsis=ellipsis ))  
      99 #def prim(string, maxlen=75, ellipsis='...'):  
      100 #    write( trim( string, maxlen, ellipsis=ellipsis ))  
    87 101  
    88 102 def indent( level, marker=' ' ):  
  • trunk/xix/__xixcfg__.py

    r121 r143  
    1 1 # Internal configuration setup  
    2 2 from xix.utils.config import configFactory  
    3   from xix.utils.python import fileHere  
      3 import os  
    3 3  
    4   configFactory.addResource('app.cfg', fileHere('__app__.cfg'))  
      4 pj = os.path.join  
      5 dir = os.path.dirname  
      6  
      7 configFactory.addResource('app.cfg', pj(dir(__file__), '__app__.cfg'))  
    5 8  
    6 9 _cfg = configFactory.getConfig('app.cfg')  
  • trunk/runtests.py

    r134 r143  
    10 10 import doctest  
    11 11 import os, inspect  
      12 from glob import glob  
    12 13 # setup path for for tests  
    13 14 os.environ['XIXSITEPATH'] = os.path.abspath('xix/tests/data/xixpage'.replace('/',os.sep))  
     
    20 21 import xix.utils.string  
    21 22 import xix.utils.rules  
      23 import xix.utils.python  
    22 24 import xix.xixxml.xmlbuilder  
    23 25 from tests import doctests  
      26 from xix.utils.config import configFactory  
    24 27  
    25 28 __author__ = 'Drew Smathers'  
     
    27 30 __license__ = 'MIT'  
    28 31 __version__ = '$Revision$'[11:-2]  
      32  
      33 configFactory.addResource('xix-unittests.cfg', 'unittests.cfg')  
      34  
      35 docfiles = glob('tests/doctests/txt/*.txt')  
    29 36          
    30 37 def main():  
     
    39 46     suite.addTest(doctest.DocTestSuite(xix.utils.rules))  
    40 47     suite.addTest(doctest.DocTestSuite(xix.xixxml.xmlbuilder))  
      48     suite.addTest(doctest.DocTestSuite(xix.utils.python))  
    41 49     suite.addTest(doctest.DocTestSuite(doctests.utils.config))  
    42 50     suite.addTest(doctest.DocTestSuite(doctests.utils.python))  
      51     for docfile in docfiles:  
      52         suite.addTest(doctest.DocFileSuite(docfile))  
    43 53     runner = unittest.TextTestRunner(verbosity=2)  
    44 54     runner.run(suite)