When you are writing a paper or some other text, which uses data that is produced by a experiment, it is very useful to have direct access from your TeX sources to your experiment results. This is especially useful if you want to reproduce your paper with a different version of your programs.
Can be used as: input parameter and output parameter
DatarefDict is like PgfKeyDict, but generates keys for dataref.
Can be used as: input parameter and output parameter
A Macros file is a normal File with the extension, that you can define TeX macros easily. This is especially useful for writing texts. You may have a experiment, which may be an analysis to an experiment that produces raw data. The produced numbers should appear in your LaTeX document. So instead of copying the numbers you can define TeX macros and use them in the text. This is especially useful if you work on the experiment and the text in parallel and the numbers change often.
>>> from versuchung.tex import Macros
>>> macro = Macros("/tmp/test.tex")
>>> macro.macro("MyNewTexMacro", 23)
>>> print macro.value
\newcommand{\MyNewTexMacro} {23}
Can be used as: input parameter and output parameter
PgfKeyDict is very similar to Macros, but instead of \newcommand directives it uses pgfkeys, can be used as a dict and it is possible to read it in again to produce the (almost) same dict again.
>>> from versuchung.tex import PgfKeyDict
>>> pgf = PgfKeyDict("/tmp/test.tex")
>>> pgf["abcd"] = 23
>>> pgf.flush() # flush method of File
>>> print open("/tmp/test.tex").read()
\pgfkeyssetvalue{/versuchung/abcd}{23}
In the TeX source you can do something like:
\usepackage{tikz}
\pgfkeys{/pgf/number format/.cd,fixed,precision=1}
[...]
\newcommand{\versuchung}[1]{\pgfkeysvalueof{/versuchung/#1}}
\versuchung{abcd}
Note
It is better to use PgfKeyDict instead of Macros, because you can also use spaces and other weird characters in pgfkeys, which cannot be used in TeX macro names.