diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-03-29 12:16:09 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-03-29 12:16:09 +0400 |
commit | ad974de4793a7714e9e77f50dd216eab9bb9ebeb (patch) | |
tree | 6590af170a389b3cf98ea7994971a85b4dca41d3 /system_demo_mode/config.py | |
parent | 58c2bec4eb2d8c4f2a29a37179fbd3d050814f79 (diff) |
Many small improvements, its generally usable now.
Diffstat (limited to 'system_demo_mode/config.py')
-rw-r--r-- | system_demo_mode/config.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/system_demo_mode/config.py b/system_demo_mode/config.py index 6ef731fc..6dcc4d9c 100644 --- a/system_demo_mode/config.py +++ b/system_demo_mode/config.py @@ -1,5 +1,6 @@ import os + def blend_list(path): for dirpath, dirnames, filenames in os.walk(path): @@ -36,8 +37,10 @@ def generate(dirpath, random_order, **kwargs): def as_string(dirpath, random_order, **kwargs): + """ Config loader is in demo_mode.py + """ cfg, dirpath = generate(dirpath, random_order, **kwargs) - + # hint for reader, can be used if files are not found. cfg_str = [] cfg_str += ["# generated file\n"] @@ -48,9 +51,8 @@ def as_string(dirpath, random_order, **kwargs): cfg_str += ["search_path = %r\n" % dirpath] cfg_str += ["\n"] - # All these work but use nicest formatting! - if 0: # works but not nice to edit. + if 0: # works but not nice to edit. cfg_str += ["config = %r" % cfg] elif 0: import pprint @@ -59,6 +61,7 @@ def as_string(dirpath, random_order, **kwargs): cfg_str += [("config = %r" % cfg).replace("{", "\n {")] else: import pprint + def dict_as_kw(d): return "dict(%s)" % ", ".join(("%s=%s" % (k, pprint.pformat(v))) for k, v in sorted(d.items())) ident = " " @@ -66,6 +69,5 @@ def as_string(dirpath, random_order, **kwargs): for cfg_item in cfg: cfg_str += ["%s%s,\n" % (ident, dict_as_kw(cfg_item))] cfg_str += ["%s]\n\n" % ident] - - + return "".join(cfg_str), dirpath |