File: genmods.py

package info (click to toggle)
python-periodictable 2.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,068 kB
  • sloc: python: 13,338; makefile: 103; sh: 92; javascript: 7
file content (75 lines) | stat: -rw-r--r-- 2,118 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
from __future__ import with_statement
import os.path

MODULE_TEMPLATE=""".. Autogenerated by genmods.py

******************************************************************************
%(name)s
******************************************************************************

:mod:`%(package)s.%(module)s`
==============================================================================

.. automodule:: %(package)s.%(module)s
   :members:
   :undoc-members:
   :inherited-members:
   :show-inheritance:

"""

INDEX_TEMPLATE=""".. Autogenerated by genmods.py

.. _api-index:

##############################################################################
   %(package_name)s
##############################################################################

.. only:: html

   :Release: |version|
   :Date: |today|

.. toctree::

   %(rsts)s
"""


def genfiles(package, package_name, modules, dir='api'):

    if not os.path.exists(dir):
        os.makedirs(dir)

    for module,name in modules:
        with open(os.path.join(dir,module+'.rst'), 'w') as f:
            f.write(MODULE_TEMPLATE%locals())

    rsts = "\n   ".join(module+'.rst' for module,name in modules)
    with open(os.path.join(dir,'index.rst'),'w') as f:
        f.write(INDEX_TEMPLATE%locals())


modules=[
    #('__init__', 'Top level namespace'),
    ('core', 'Core table'),
    ('formulas', 'Chemical formula operations'),
    ('covalent_radius', 'Covalent radius'),
    ('constants', 'Fundamental constants'),
    ('crystal_structure', 'Crystal structure'),
    ('density', 'Density'),
    ('fasta', 'FASTA format for DNA/RNA and amino acid sequences'),
    ('magnetic_ff', 'Magnetic Form Factor'),
    ('mass', 'Mass'),
    ('activation', 'Neutron activation'),
    ('nsf', 'Neutron scattering potentials'),
    ('xsf', 'X-ray scattering potentials and spectral lines'),
    ('cromermann', 'X-ray scattering factor f0 calculations'),
    ('plot', 'Element plotter'),
    ('util', 'Utility functions'),
    ('mass_2001', 'Deprecated mass/abundance values'),
]
package='periodictable'
package_name='Reference'
genfiles(package, package_name, modules)