5
for dirpath, dirnames, filenames in os.walk(path):
8
if dirpath.startswith("."):
11
for filename in filenames:
12
if filename.lower().endswith(".blend"):
13
filepath = os.path.join(dirpath, filename)
17
def generate(dirpath, random_order, **kwargs):
19
# in case file is selected!
20
if not os.path.exists(dirpath) or not os.path.isdir(dirpath):
21
dirpath = os.path.dirname(dirpath)
23
files = list(blend_list(dirpath))
32
defaults = kwargs.copy()
34
config.append(defaults)
36
return config, dirpath
39
def as_string(dirpath, random_order, **kwargs):
40
""" Config loader is in demo_mode.py
42
cfg, dirpath = generate(dirpath, random_order, **kwargs)
44
# hint for reader, can be used if files are not found.
46
cfg_str += ["# generated file\n"]
48
cfg_str += ["# edit the search path so other systems may find the files below\n"]
49
cfg_str += ["# based on name only if the absolute paths cant be found\n"]
50
cfg_str += ["# Use '//' for current blend file path.\n"]
52
cfg_str += ["search_path = %r\n" % dirpath]
55
# All these work but use nicest formatting!
56
if 0: # works but not nice to edit.
57
cfg_str += ["config = %r" % cfg]
60
cfg_str += ["config = %s" % pprint.pformat(cfg, indent=0, width=120)]
62
cfg_str += [("config = %r" % cfg).replace("{", "\n {")]
67
return "dict(%s)" % ", ".join(("%s=%s" % (k, pprint.pformat(v))) for k, v in sorted(d.items()))
69
cfg_str += ["config = [\n"]
71
cfg_str += ["%s%s,\n" % (ident, dict_as_kw(cfg_item))]
72
cfg_str += ["%s]\n\n" % ident]
74
return "".join(cfg_str), dirpath