1 # ##### BEGIN GPL LICENSE BLOCK #####
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 # ##### END GPL LICENSE BLOCK #####
25 for dirpath
, dirnames
, filenames
in os
.walk(path
):
27 dirnames
[:] = [d
for d
in dirnames
if not d
.startswith(".")]
28 for filename
in filenames
:
29 if filename
.lower().endswith(".blend"):
30 filepath
= os
.path
.join(dirpath
, filename
)
34 def generate(dirpath
, random_order
, **kwargs
):
35 files
= list(blend_list(dirpath
))
44 defaults
= kwargs
.copy()
46 config
.append(defaults
)
48 return config
, dirpath
51 def as_string(dirpath
, random_order
, exit
, **kwargs
):
52 """ Config loader is in demo_mode.py
54 cfg
, dirpath
= generate(dirpath
, random_order
, **kwargs
)
56 # hint for reader, can be used if files are not found.
60 "# edit the search path so other systems may find the files below\n",
61 "# based on name only if the absolute paths cant be found\n",
62 "# Use '//' for current blend file path.\n",
64 "search_path = %r\n" % dirpath
,
70 # All these work but use nicest formatting!
71 if 0: # works but not nice to edit.
72 cfg_str
+= ["config = %r" % cfg
]
75 cfg_str
+= ["config = %s" % pprint
.pformat(cfg
, indent
=0, width
=120)]
77 cfg_str
+= [("config = %r" % cfg
).replace("{", "\n {")]
82 return "dict(%s)" % ", ".join(("%s=%s" % (k
, pprint
.pformat(v
))) for k
, v
in sorted(d
.items()))
84 cfg_str
+= ["config = [\n"]
86 cfg_str
+= ["%s%s,\n" % (ident
, dict_as_kw(cfg_item
))]
87 cfg_str
+= ["%s]\n\n" % ident
]
89 return "".join(cfg_str
), dirpath