optional external files, optional clone masters

I like to keep things in separate files when appropriate (scripts, data tables, tox files). But I’ve found that it makes projects/components more difficult to reuse in other projects since you need to remember which files need to go along with the tox.
So I’ve developed a technique to optionally use external files if they exist, but use embedded data if they don’t. For tox files you don’t really need to do anything special since they have a built-in backup capability, but it’s still annoying to see warnings about missing files that aren’t important.
In the file parameter I use an expression like this:

file: 'components/whatever_shader.frag' if mod.os.path.exists('components/whatever_shader.frag') else ''

That way it will only even attempt to use the file if it actually exists.

For components that you intend to clone, I use these expressions:

clone: op('/_/modules/voronoi_module') or ""
tox: ('modules/voronoi_module.tox' if (mod.os.path.exists('modules/voronoi_module.tox') and me.par.clone.eval() in (None, me)) else None) or ""

You can then just drop that file into a project in some standard location (I use /_/components), and then copy and paste it elsewhere in the project. The pasted ones will be clones of the master if it exists but will still work if it doesn’t, and they’ll load from an external file if it exists and they are the master copy. That way loading the tox file for an instance of a master component won’t reset its parameters since the only one that loads from a file will be the master one.