Example #1
0
    def test_constructors(self):
        '''Constructors'''
        eq=self.assertEqual

        eq( ini().keys(), [] )

        i=ini( answer='42', witch='guilty' )
        i["foo"]=properties(answer='43')
        i["bar"]=properties(witch='innocent')
        eq( i['foo']['answer'], '43' )
        eq( i['bar']['witch'], 'innocent' )
        eq( i.get('foo', 'answer'), '43' )
        eq( i.get('bar', 'witch'),  'innocent')

        eq( i.get('foo', 'witch'), 'guilty' )
        eq( i.get('bar', 'answer'), '42' )
        
        i=ini( self.inifile, answer=43, witch='alwaysguilty' )
        eq( i['Foo Bar']['foo'], 'bar' )
        eq( i.get('Foo Bar','answer'), 43 )
        eq( i.get('Internationalized Stuff','witch'), 'alwaysguilty' )
        eq( i.get('Internationalized Stuff','foo'), 'Default' )

        i=ini( {'toto':'tata', 'titi':'toutou' }, answer=43, witch='alwaysguilty' )
        i['tata']=properties()
        eq( i.get('tata','toto'), 'tata' )
        eq( i.get('tata','titi'), 'toutou' )
        eq( i.get('tata','answer'), 43 )
    def test_constructors(self):
        '''Constructors'''
        eq = self.assertEqual

        eq(ini().keys(), [])

        i = ini(answer='42', witch='guilty')
        i["foo"] = properties(answer='43')
        i["bar"] = properties(witch='innocent')
        eq(i['foo']['answer'], '43')
        eq(i['bar']['witch'], 'innocent')
        eq(i.get('foo', 'answer'), '43')
        eq(i.get('bar', 'witch'), 'innocent')

        eq(i.get('foo', 'witch'), 'guilty')
        eq(i.get('bar', 'answer'), '42')

        i = ini(self.inifile, answer=43, witch='alwaysguilty')
        eq(i['Foo Bar']['foo'], 'bar')
        eq(i.get('Foo Bar', 'answer'), 43)
        eq(i.get('Internationalized Stuff', 'witch'), 'alwaysguilty')
        eq(i.get('Internationalized Stuff', 'foo'), 'Default')

        i = ini({
            'toto': 'tata',
            'titi': 'toutou'
        },
                answer=43,
                witch='alwaysguilty')
        i['tata'] = properties()
        eq(i.get('tata', 'toto'), 'tata')
        eq(i.get('tata', 'titi'), 'toutou')
        eq(i.get('tata', 'answer'), 43)
Example #3
0
 def test_scenario1(self):
     '''Scenario 1.'''
     eq=self.assertEqual
     i=ini(self.inifile)
     i['Foo Bar']['foo'] = 'bloublou'
     i['Internationalized Stuff']['witch'] = 'Burn burn !'
     i.write(self.inifile)
     i=ini(self.inifile)
     
     eq( i['Foo Bar']['foo'], 'bloublou')
     eq( i['Internationalized Stuff']['witch'], 'Burn burn !')
    def test_scenario1(self):
        '''Scenario 1.'''
        eq = self.assertEqual
        i = ini(self.inifile)
        i['Foo Bar']['foo'] = 'bloublou'
        i['Internationalized Stuff']['witch'] = 'Burn burn !'
        i.write(self.inifile)
        i = ini(self.inifile)

        eq(i['Foo Bar']['foo'], 'bloublou')
        eq(i['Internationalized Stuff']['witch'], 'Burn burn !')
Example #5
0
 def test_read(self):
     '''Read'''
     eq=self.assertEqual
     i=ini()
     i.read(self.inifile)
     eq( i.get('Internationalized Stuff','foo'), 'Default' )
     eq( i['Foo Bar']['foo'], 'bar' )
 def test_read(self):
     '''Read'''
     eq = self.assertEqual
     i = ini()
     i.read(self.inifile)
     eq(i.get('Internationalized Stuff', 'foo'), 'Default')
     eq(i['Foo Bar']['foo'], 'bar')
Example #7
0
    def test_dustbin(self):
        '''Dustbin'''
        i=ini()
        del i['tata']
        del i['toto']
        i['toto'] = '45'

        self.assertEqual( i['toto'], '45' )
        self.assertEqual( 'tata' in i.dustbin, True)
        self.assertEqual( 'toto' not in i.dustbin, True)
    def test_dustbin(self):
        '''Dustbin'''
        i = ini()
        del i['tata']
        del i['toto']
        i['toto'] = '45'

        self.assertEqual(i['toto'], '45')
        self.assertEqual('tata' in i.dustbin, True)
        self.assertEqual('toto' not in i.dustbin, True)
Example #9
0
    def test_variables(self):
        '''Variables'''
        i=ini()
        i['section']=properties()
        i['section']['tata']= 1
        i['section']['toto']= "$tata"
        i['section']['titi'] ="123$toto" 

        self.assertEqual( i['section']['tata'], '1' )
        self.assertEqual( i['section'].get('toto'), '1')
        self.assertEqual( i['section'].get('titi'), '1231')
    def test_variables(self):
        '''Variables'''
        i = ini()
        i['section'] = properties()
        i['section']['tata'] = 1
        i['section']['toto'] = "$tata"
        i['section']['titi'] = "123$toto"

        self.assertEqual(i['section']['tata'], '1')
        self.assertEqual(i['section'].get('toto'), '1')
        self.assertEqual(i['section'].get('titi'), '1231')
Example #11
0
    def test_write(self):
        '''Write'''
        i=ini()
        i['section']=properties()
        i['section']['answer'], i['section']['witch'] = 43, 'alwaysguilty'
        i['section']['tata']=3
        del i['section']['tata']
        del i['section']['witch']
        i.write(self.emptyfile)
        correct='''[section]\nanswer=43\n
'''
        self.assertEqual(file(self.emptyfile).read(),correct)
    def test_write(self):
        '''Write'''
        i = ini()
        i['section'] = properties()
        i['section']['answer'], i['section']['witch'] = 43, 'alwaysguilty'
        i['section']['tata'] = 3
        del i['section']['tata']
        del i['section']['witch']
        i.write(self.emptyfile)
        correct = '''[section]\nanswer=43\n
'''
        self.assertEqual(file(self.emptyfile).read(), correct)
Example #13
0
#!/usr/bin/env python
"""
Report updated and modified files in monitored trees.

XXX: integrate with cllct
"""
import os, re, optparse, confparse, itertools


config = confparse.get_config('monitor')
settings = confparse.ini(config)

# Predefined values, override in config file
monitors = settings.monitors.getlist([ '~/htdocs/' ])

# Hard coded
usage_descr = """%monitor [options] paths"""

options_spec = (
    ('--add-monitor', {'default': None, 'help': "." }),
)


def getpath(name, *dirs):
    paths = []
    j = os.path.join
    [ paths.extend([ j(d, name), j(d, '.' + name) ]) for d in dirs ]
    for p in paths:
        yield p

def getconfig(name, all=False, force=False):