~didrocks/ubuntuone-client/use_result_var

« back to all changes in this revision

Viewing changes to ubuntuone/syncdaemon/config.py

  • Committer: Bazaar Package Importer
  • Author(s): Rodney Dawes
  • Date: 2010-08-12 10:36:50 UTC
  • mto: This revision was merged to the branch mainline in revision 45.
  • Revision ID: james.westby@ubuntu.com-20100812103650-fgrtuxztjdwkt956
Tags: upstream-1.3.8
ImportĀ upstreamĀ versionĀ 1.3.8

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
 
26
26
from ConfigParser import NoOptionError, NoSectionError
27
27
from optparse import OptionParser
28
 
from configglue import TypedConfigParser, glue
29
28
from xdg.BaseDirectory import (
30
29
    load_config_paths,
31
30
    save_config_path,
33
32
    xdg_cache_home,
34
33
)
35
34
 
 
35
# the try/except is to work with older versions of configglue (that
 
36
# had everything that is now configglue.inischema.* as configglue.*).
 
37
# The naming shenanigans are to work around pyflakes being completely
 
38
# stupid WRT people catching ImportErrors
 
39
normoptname = None
 
40
try:
 
41
    from configglue.glue import normoptname as old_normoptname
 
42
    from configglue import TypedConfigParser as old_tcp
 
43
except ImportError:
 
44
    from configglue.inischema import TypedConfigParser as new_tcp
 
45
 
 
46
    def normoptname(_, section, option):
 
47
        if section == "__main__":
 
48
            return option
 
49
        return section + "_" + option
 
50
 
 
51
if normoptname is None:
 
52
    normoptname = old_normoptname
 
53
    TypedConfigParser = old_tcp
 
54
    del old_normoptname, old_tcp
 
55
else:
 
56
    TypedConfigParser = new_tcp
 
57
    del new_tcp
 
58
# end of naming shenanigans
36
59
 
37
60
CONFIG_FILE = 'syncdaemon.conf'
38
61
CONFIG_LOGS = 'logging.conf'
363
386
    overridden = []
364
387
    for section in cp.sections():
365
388
        for optname, optval in cp.items(section):
366
 
            normoptname = glue.normoptname(cp, section, optname)
367
 
            value = getattr(options, normoptname)
 
389
            normopt = normoptname(cp, section, optname)
 
390
            value = getattr(options, normopt)
368
391
            if optval.value != value:
369
392
                # the value has been overridden by an argument;
370
393
                # re-parse it.
371
 
                setattr(options, normoptname, optval.parser(value))
 
394
                setattr(options, normopt, optval.parser(value))
372
395
                overridden.append((section, optname, value))
373
396
 
374
397
    config_files = [fileobj.name] + list(filenames)