File: docapps.py

package info (click to toggle)
prody 2.6.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 178,760 kB
  • sloc: xml: 518,270; python: 55,905; ansic: 18,098; fortran: 6,594; cpp: 4,421; javascript: 146; makefile: 73
file content (51 lines) | stat: -rwxr-xr-x 1,407 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
#!/usr/bin/python

import os
import sys
import importlib
from subprocess import Popen, PIPE

from prody.utilities.misctools import impLoadModule

path_apps = importlib.util.find_spec("prody.apps").submodule_search_locations[0]

prody_apps = impLoadModule('prody.apps.prody_apps', path_apps + '/prody_apps/', '__init__')
evol_apps = impLoadModule('prody.apps.evol_apps', path_apps + '/evol_apps/', '__init__')

for cmd, subcmds in [('prody', prody_apps.PRODY_APPS), ('evol', evol_apps.EVOL_APPS)]:

    pipe = Popen([cmd, '-h'], stdout=PIPE, stderr=PIPE)
    with open(os.path.join(cmd, cmd + '.txt'), 'w') as rst:
        rst.write(pipe.stdout.read())

    for sub in subcmds:

        with open(os.path.join(cmd, sub + '.rst'), 'w') as rst:
            rst.write(""".. _{cmd:s}-{sub:s}:

{cmd:s} {sub:s}
====================

Usage
--------------------

Running :command:`{cmd:s} {sub:s} -h` displays::

""".format(cmd=cmd, sub=sub))

            pipe = Popen([cmd , sub, '-h'], stdout=PIPE, stderr=PIPE)
            for line in pipe.stdout.readlines():
                rst.write('  ' + line)

            rst.write("""
Examples
--------------------

Running :command:`{cmd:s} {sub:s} --examples` displays::

""".format(cmd=cmd, sub=sub))


            pipe = Popen([cmd, sub, '--examples'], stdout=PIPE, stderr=PIPE)
            for line in pipe.stdout.readlines():
                rst.write('  ' + line)