rivtlib 1.0.0a1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. rivtlib-1.0.0a1/PKG-INFO +38 -0
  2. rivtlib-1.0.0a1/pyproject.toml +47 -0
  3. rivtlib-1.0.0a1/src/rivtlib/__init__.py +37 -0
  4. rivtlib-1.0.0a1/src/rivtlib/__main__.py +4 -0
  5. rivtlib-1.0.0a1/src/rivtlib/rvapi.py +446 -0
  6. rivtlib-1.0.0a1/src/rivtlib/rvcmd.py +956 -0
  7. rivtlib-1.0.0a1/src/rivtlib/rvdoc.py +687 -0
  8. rivtlib-1.0.0a1/src/rivtlib/rvparse.py +321 -0
  9. rivtlib-1.0.0a1/src/rivtlib/rvreport.py +35 -0
  10. rivtlib-1.0.0a1/src/rivtlib/rvtag.py +303 -0
  11. rivtlib-1.0.0a1/src/rivtlib/rvunits.py +134 -0
  12. rivtlib-1.0.0a1/src/rivtlib/scripts/genpdocs.cmd +1 -0
  13. rivtlib-1.0.0a1/src/rivtlib/scripts/pdfdoc.sty +61 -0
  14. rivtlib-1.0.0a1/src/rivtlib/scripts/reportmerge.py +206 -0
  15. rivtlib-1.0.0a1/src/rivtlib/scripts/rivet_labels.txt +994 -0
  16. rivtlib-1.0.0a1/src/rivtlib/scripts/rst2html.py +23 -0
  17. rivtlib-1.0.0a1/src/rivtlib/scripts/rst2html4.py +26 -0
  18. rivtlib-1.0.0a1/src/rivtlib/scripts/rst2html5.py +35 -0
  19. rivtlib-1.0.0a1/src/rivtlib/scripts/rst2latex.py +26 -0
  20. rivtlib-1.0.0a1/src/rivtlib/scripts/rst2man.py +26 -0
  21. rivtlib-1.0.0a1/src/rivtlib/scripts/rst2odt.py +30 -0
  22. rivtlib-1.0.0a1/src/rivtlib/scripts/rst2odt_prepstyles.py +67 -0
  23. rivtlib-1.0.0a1/src/rivtlib/scripts/rst2pseudoxml.py +23 -0
  24. rivtlib-1.0.0a1/src/rivtlib/scripts/rst2s5.py +24 -0
  25. rivtlib-1.0.0a1/src/rivtlib/scripts/rst2xetex.py +27 -0
  26. rivtlib-1.0.0a1/src/rivtlib/scripts/rst2xml.py +23 -0
  27. rivtlib-1.0.0a1/src/rivtlib/scripts/rv0000-simple-doc/beam.png +0 -0
  28. rivtlib-1.0.0a1/src/rivtlib/scripts/rv0000-simple-doc/rv0000-simple-doc.py +66 -0
  29. rivtlib-1.0.0a1/src/rivtlib/scripts/tex2text.py +145 -0
  30. rivtlib-1.0.0a1/src/rivtlib/styles/fonts/Arial.ttf +0 -0
  31. rivtlib-1.0.0a1/src/rivtlib/styles/fonts/ArialBold.ttf +0 -0
  32. rivtlib-1.0.0a1/src/rivtlib/styles/fonts/ArialBoldOblique.ttf +0 -0
  33. rivtlib-1.0.0a1/src/rivtlib/styles/fonts/ArialCeb.ttf +0 -0
  34. rivtlib-1.0.0a1/src/rivtlib/styles/fonts/ArialOblique.ttf +0 -0
  35. rivtlib-1.0.0a1/src/rivtlib/styles/fonts/DejaVu Fonts License.txt +97 -0
  36. rivtlib-1.0.0a1/src/rivtlib/styles/fonts/DejaVuMathTeXGyre.ttf +0 -0
  37. rivtlib-1.0.0a1/src/rivtlib/styles/fonts/DejaVuSans-Bold.ttf +0 -0
  38. rivtlib-1.0.0a1/src/rivtlib/styles/fonts/DejaVuSans-BoldOblique.ttf +0 -0
  39. rivtlib-1.0.0a1/src/rivtlib/styles/fonts/DejaVuSans-ExtraLight.ttf +0 -0
  40. rivtlib-1.0.0a1/src/rivtlib/styles/fonts/DejaVuSans-Oblique.ttf +0 -0
  41. rivtlib-1.0.0a1/src/rivtlib/styles/fonts/DejaVuSans.ttf +0 -0
  42. rivtlib-1.0.0a1/src/rivtlib/styles/fonts/DejaVuSansCondensed-Bold.ttf +0 -0
  43. rivtlib-1.0.0a1/src/rivtlib/styles/fonts/DejaVuSansCondensed-BoldOblique.ttf +0 -0
  44. rivtlib-1.0.0a1/src/rivtlib/styles/fonts/DejaVuSansCondensed-Oblique.ttf +0 -0
  45. rivtlib-1.0.0a1/src/rivtlib/styles/fonts/DejaVuSansCondensed.ttf +0 -0
  46. rivtlib-1.0.0a1/src/rivtlib/styles/fonts/DejaVuSansMono-Bold.ttf +0 -0
  47. rivtlib-1.0.0a1/src/rivtlib/styles/fonts/DejaVuSansMono-BoldOblique.ttf +0 -0
  48. rivtlib-1.0.0a1/src/rivtlib/styles/fonts/DejaVuSansMono-Oblique.ttf +0 -0
  49. rivtlib-1.0.0a1/src/rivtlib/styles/fonts/DejaVuSansMono.ttf +0 -0
  50. rivtlib-1.0.0a1/src/rivtlib/styles/fonts/DejaVuSerif-Bold.ttf +0 -0
  51. rivtlib-1.0.0a1/src/rivtlib/styles/fonts/DejaVuSerif-BoldItalic.ttf +0 -0
  52. rivtlib-1.0.0a1/src/rivtlib/styles/fonts/DejaVuSerif-Italic.ttf +0 -0
  53. rivtlib-1.0.0a1/src/rivtlib/styles/fonts/DejaVuSerif.ttf +0 -0
  54. rivtlib-1.0.0a1/src/rivtlib/styles/fonts/DejaVuSerifCondensed-Bold.ttf +0 -0
  55. rivtlib-1.0.0a1/src/rivtlib/styles/fonts/DejaVuSerifCondensed-BoldItalic.ttf +0 -0
  56. rivtlib-1.0.0a1/src/rivtlib/styles/fonts/DejaVuSerifCondensed-Italic.ttf +0 -0
  57. rivtlib-1.0.0a1/src/rivtlib/styles/fonts/DejaVuSerifCondensed.ttf +0 -0
  58. rivtlib-1.0.0a1/src/rivtlib/styles/fonts/Inconsolata-Bold.ttf +0 -0
  59. rivtlib-1.0.0a1/src/rivtlib/styles/fonts/Inconsolata-Regular.ttf +0 -0
  60. rivtlib-1.0.0a1/src/rivtlib/styles/fonts/OpenSans-Bold.ttf +0 -0
  61. rivtlib-1.0.0a1/src/rivtlib/styles/fonts/OpenSans-BoldItalic.ttf +0 -0
  62. rivtlib-1.0.0a1/src/rivtlib/styles/fonts/OpenSans-Italic.ttf +0 -0
  63. rivtlib-1.0.0a1/src/rivtlib/styles/fonts/OpenSans-Regular.ttf +0 -0
  64. rivtlib-1.0.0a1/src/rivtlib/styles/htmlsite.css +441 -0
  65. rivtlib-1.0.0a1/src/rivtlib/styles/layout.ini +37 -0
  66. rivtlib-1.0.0a1/src/rivtlib/styles/line.png +0 -0
  67. rivtlib-1.0.0a1/src/rivtlib/styles/rlabpdf.yaml +385 -0
  68. rivtlib-1.0.0a1/src/rivtlib/styles/rstcover.rst +54 -0
  69. rivtlib-1.0.0a1/src/rivtlib/styles/texpdf.sty +0 -0
  70. rivtlib-1.0.0a1/src/rivtlib/unum/core.py +612 -0
  71. rivtlib-1.0.0a1/src/rivtlib/unum/exceptions.py +53 -0
  72. rivtlib-1.0.0a1/src/rivtlib/unum/utils.py +95 -0
@@ -0,0 +1,38 @@
1
+ Metadata-Version: 2.3
2
+ Name: rivtlib
3
+ Version: 1.0.0a1
4
+ Summary: install rivtlib project
5
+ Author: rod holland
6
+ Author-email: rod holland <rholland@structurelabs.com>
7
+ Requires-Dist: tabulate>=0.9.0
8
+ Requires-Dist: fastcore>=1.8.16
9
+ Requires-Dist: pillow>=11.2.1
10
+ Requires-Dist: matplotlib>=3.10.1
11
+ Requires-Dist: sympy>=1.13.3
12
+ Requires-Dist: scipy>=1.16.3
13
+ Requires-Dist: numpy>=2.2.5
14
+ Requires-Dist: pandas>=2.2.3
15
+ Requires-Dist: docutils>=0.21.2
16
+ Requires-Dist: ipython>=8.16.2
17
+ Requires-Dist: ipykernel>=6.28.1
18
+ Requires-Dist: reportlab>=4.4.0
19
+ Requires-Dist: rst2pdf>=0.103.1
20
+ Requires-Dist: pypdf>=1.0.3
21
+ Requires-Dist: sphinx>=8.2.3
22
+ Requires-Dist: pydata-sphinx-theme>=0.16.1
23
+ Requires-Dist: sphinx-copybutton>=0.5.2
24
+ Requires-Dist: sphinx-design>=0.6.1
25
+ Requires-Dist: sphinx-favicon>=1.0.1
26
+ Requires-Dist: sphinx-togglebutton>=0.3.2
27
+ Requires-Dist: sphinxcontrib-applehelp>=2.0.0
28
+ Requires-Dist: sphinxcontrib-devhelp>=2.0.0
29
+ Requires-Dist: sphinxcontrib-email>=0.3.6
30
+ Requires-Dist: sphinxcontrib-htmlhelp>=2.1.0
31
+ Requires-Dist: sphinxcontrib-jquery>=4.1
32
+ Requires-Dist: sphinxcontrib-jsmath>=1.0.1
33
+ Requires-Dist: sphinxcontrib-qthelp>=2.0.0
34
+ Requires-Dist: sphinxcontrib-serializinghtml>=2.0.0
35
+ Requires-Dist: pyside6>=6.10.1
36
+ Requires-Dist: pyzo>=4.20.0
37
+ Requires-Dist: github-clone>=1.2.0
38
+ Requires-Python: >=3.13
@@ -0,0 +1,47 @@
1
+ [project]
2
+ name = "rivtlib"
3
+ version = "1.0.0a1"
4
+ description = "install rivtlib project"
5
+ authors = [{ name = "rod holland", email = "rholland@structurelabs.com" }]
6
+ requires-python = ">=3.13"
7
+
8
+ dependencies = [
9
+ "tabulate>=0.9.0",
10
+ "fastcore>=1.8.16",
11
+ "pillow>=11.2.1",
12
+ "matplotlib>=3.10.1",
13
+ "sympy>=1.13.3",
14
+ "scipy>=1.16.3",
15
+ "numpy>=2.2.5",
16
+ "pandas>=2.2.3",
17
+ "docutils>=0.21.2",
18
+ "ipython>=8.16.2",
19
+ "ipykernel>=6.28.1",
20
+ "reportlab>=4.4.0",
21
+ "rst2pdf>=0.103.1",
22
+ "pypdf>=1.0.3",
23
+ "Sphinx>=8.2.3",
24
+ "pydata-sphinx-theme>=0.16.1",
25
+ "sphinx-copybutton>=0.5.2",
26
+ "sphinx_design>=0.6.1",
27
+ "sphinx-favicon>=1.0.1",
28
+ "sphinx-togglebutton>=0.3.2",
29
+ "sphinxcontrib-applehelp>=2.0.0",
30
+ "sphinxcontrib-devhelp>=2.0.0",
31
+ "sphinxcontrib-email>=0.3.6",
32
+ "sphinxcontrib-htmlhelp>=2.1.0",
33
+ "sphinxcontrib-jquery>=4.1",
34
+ "sphinxcontrib-jsmath>=1.0.1",
35
+ "sphinxcontrib-qthelp>=2.0.0",
36
+ "sphinxcontrib-serializinghtml>=2.0.0",
37
+ "pyside6>=6.10.1",
38
+ "pyzo>=4.20.0",
39
+ "github-clone>=1.2.0",
40
+ ]
41
+
42
+ [build-system]
43
+ requires = ["uv_build"]
44
+ build-backend = "uv_build"
45
+
46
+ [tool.ruff]
47
+ line-length = 80
@@ -0,0 +1,37 @@
1
+ """
2
+ rivtlib
3
+ =======
4
+
5
+ *rivtlib* is a Python library for writing and sharing engineering documents. It
6
+ outputs *rivt docs* and *reports* from a *rivt file*. A rivt file is a Python
7
+ file (*.py) that imports *rivtlib*::
8
+
9
+ rivt API
10
+
11
+ usage:
12
+ import rivtlib.rvapi as rv
13
+
14
+ API functions:
15
+ rv.R(rS) - (Run) Execute shell scripts
16
+ rv.I(rS) - (Insert) Insert static text, math, images and tables
17
+ rv.V(rS) - (Values) Evaluate values and equations
18
+ rv.T(rS) - (Tools) Execute Python scripts
19
+ rv.D(rS) - (Docs) Publish formatted doc file
20
+ rv.S(rS) - (Skip) Skip processing of section
21
+ rv.X(rS) - (Exit) Exit processing of rivt file
22
+
23
+ where the argument rS is a triple quoted utf-8 string (rivt string)
24
+
25
+ where **rS** is a triple quoted rivt string that uses *rivt markup* - a
26
+ lightweight markup language that wraps *restructuredtext*. *rivt docs* and
27
+ *reports* may be output as text, PDF or HTML files from the same *rivt file*.
28
+
29
+ A *rivt file* may be run from the command line as::
30
+
31
+ python rvddss-filename.py
32
+
33
+ where *rvddss-* is the doc number and *dd* and *ss* are integers identifying the
34
+ report division and subdivision respectively.
35
+ See the `rivt User Manual <https://rivt.info>`_ for details.
36
+
37
+ """
@@ -0,0 +1,4 @@
1
+ """rivtlib
2
+
3
+ library for processing *rivt files*
4
+ """
@@ -0,0 +1,446 @@
1
+ #! python
2
+ """
3
+ rivt API
4
+
5
+ usage:
6
+ import rivtlib.rvapi as rv
7
+
8
+ API functions:
9
+ rv.R(rS) - (Run) Execute shell scripts
10
+ rv.I(rS) - (Insert) Insert static text, math, images and tables
11
+ rv.V(rS) - (Values) Evaluate values and equations
12
+ rv.T(rS) - (Tools) Execute Python scripts
13
+ rv.D(rS) - (Docs) Publish formatted doc file
14
+ rv.S(rS) - (Skip) Skip processing of section
15
+ rv.X(rS) - (Exit) Exit processing of rivt file
16
+
17
+ where the argument rS is a triple quoted rivt string (utf-8)
18
+
19
+ Doc comment settings:
20
+ # rc singledoc: True; False (default is False)
21
+
22
+
23
+ Globals:
24
+ utfS (str): utf doc string
25
+ rs2S (str): rstpdf doc string
26
+ rstS (str): texpdf doc string
27
+ lablD (dict): formatting parameters
28
+ foldD (dict): folder and file paths
29
+ rivtD (dict): calculated values
30
+
31
+ Last letter of var name indicates type:
32
+ A => array
33
+ B => boolean
34
+ C => class instance
35
+ D => dictionary
36
+ F => float
37
+ I => integer
38
+ L => list
39
+ N => file name (string)
40
+ O => object
41
+ P => path
42
+ S => string
43
+ T => path + file name (path)
44
+ """
45
+
46
+ import fnmatch
47
+ import logging
48
+ import os
49
+ import sys
50
+ import warnings
51
+ from importlib.metadata import version
52
+ from pathlib import Path
53
+
54
+ import __main__
55
+ from rivtlib import rvdoc, rvparse
56
+
57
+ # region - rivt file name and paths
58
+ rivtP = Path(os.getcwd())
59
+ reptP = Path(os.path.dirname(rivtP))
60
+ rivtN = os.path.basename(__main__.__file__)
61
+ rivtT = Path(rivtP, rivtN)
62
+ print(rivtN, rivtT)
63
+ pypathS = os.path.dirname(sys.executable)
64
+ rivtpkgP = os.path.join(pypathS, "Lib", "site-packages", "rivt")
65
+
66
+ if fnmatch.fnmatch(rivtN, "rv[A-Z0-9][0-9][0-9]-*.py"):
67
+ pass
68
+ else:
69
+ print(f"""The rivt file name provided was {rivtN}""")
70
+ print("""The file name must match rvDss-filename.py""")
71
+ print("""where D is an alpha-numeric division label""")
72
+ print("""and ss is a two-digit subdivision integer""")
73
+ sys.exit()
74
+
75
+ rbaseS = rivtN.split(".")[0]
76
+ rivtpN = rivtN.replace("rv", "rv-")
77
+ docnumS = rbaseS[0:6]
78
+ bakN = rbaseS + ".bak"
79
+ apilogN = docnumS + "api.txt"
80
+ errlogN = docnumS + "log.txt"
81
+ publicP = Path(rivtP, "public")
82
+ srcP = Path(rivtP, "src")
83
+ storeP = Path(rivtP, "store")
84
+ pubP = Path(rivtP, "publish")
85
+ logsP = Path(storeP, "logs")
86
+ # endregion
87
+
88
+ # region - rivt file flags
89
+ prflagB = False
90
+ rvsingleB = False
91
+ with open(rivtT, "r") as f1: # noqa: F405
92
+ rivtL = f1.readlines()
93
+ for lnS in rivtL:
94
+ if lnS[0:4] == "# rv":
95
+ if "singledoc" and "True" in lnS:
96
+ rvsingleB = True
97
+
98
+ # print(f"={rvsingleB}")
99
+
100
+ if rvsingleB:
101
+ errlogT = Path(rivtP, errlogN)
102
+ apilogT = Path(rivtP, apilogN)
103
+ bakT = Path(rivtP, bakN)
104
+ rivtT = Path(rivtP, rivtN)
105
+ else:
106
+ errlogT = Path(logsP, errlogN)
107
+ apilogT = Path(logsP, apilogN)
108
+ bakT = Path(logsP, bakN)
109
+ rivtT = Path(rivtP, rivtN)
110
+ try:
111
+ package_version = version("rivtlib")
112
+ verS = f"rivtlib version: {package_version}"
113
+ except Exception as e:
114
+ verS = f"rivtlib version not available: {e}"
115
+ # endregion
116
+
117
+ # region - logs
118
+ warnings.filterwarnings("ignore")
119
+ try:
120
+ logging.basicConfig(
121
+ level=logging.DEBUG,
122
+ format="%(asctime)-8s " + rbaseS + " %(levelname)-8s %(message)s",
123
+ datefmt="%m-%d %H:%M",
124
+ filename=errlogT,
125
+ filemode="w",
126
+ )
127
+ except Exception:
128
+ pass
129
+ logging.info("Doc start")
130
+ logging.info(verS)
131
+ # write backup file
132
+ with open(rivtT, "r") as f2: # noqa: F405
133
+ rivtS = f2.read()
134
+ try:
135
+ with open(bakT, "w") as f3: # noqa: F405
136
+ f3.write(rivtS)
137
+ logging.info(f"""rivt backup : {bakT}""") # noqa: F405
138
+ except Exception:
139
+ pass
140
+ # api log
141
+ with open(apilogT, "w") as f4:
142
+ f4.write("API log: " + rivtN + "\n")
143
+ f4.write("---------------------------------------\n")
144
+ # end region
145
+
146
+ # region - dictionaries
147
+ rivtD = {
148
+ "metaD": {
149
+ "authors": " - ",
150
+ "version": " - ",
151
+ "email": " - ",
152
+ "repo": " - ",
153
+ "license": " - ",
154
+ "fork1": [" - "],
155
+ "fork2": [" - "],
156
+ },
157
+ }
158
+ metaD = {} # metadata
159
+ foldD = { # folders
160
+ "errlogT": errlogT,
161
+ "apilogT": apilogT,
162
+ "bakT": bakT,
163
+ "rvsingleB": rvsingleB,
164
+ "pthS": " ",
165
+ "srcnS": " ",
166
+ "rivtN": rivtN, # file name
167
+ "rivtT": rivtT, # full path name
168
+ "rivtP": Path(os.getcwd()),
169
+ "rbaseS": rbaseS, # file base name
170
+ "reptfoldN": os.path.dirname(rivtP),
171
+ "docP": Path(rivtP, "rivDocs"),
172
+ "pdfN": rbaseS + ".pdf",
173
+ "readmeT": Path(rivtP, "README.txt"),
174
+ "rivtpubP": Path(rivtP, "publish"),
175
+ "rivtpub_P": Path(rivtP),
176
+ "publicT": Path(rivtP, "public", rivtpN),
177
+ "public_T": Path(rivtP, rivtpN),
178
+ "srcP": srcP,
179
+ "src_P": Path(rivtP),
180
+ "storeP": storeP,
181
+ "valP": Path(srcP, "values"),
182
+ "toolP": Path(srcP, "tools"),
183
+ "styleP": Path(srcP, "styles"),
184
+ "tempP": Path(srcP, "temp"),
185
+ "val_P": rivtP,
186
+ "style_P": rivtP,
187
+ "tool_P": rivtP,
188
+ "temp_P": rivtP,
189
+ }
190
+ lablD = { # dictionary of labels
191
+ "rvtypeS": "", # section type r,i,v,t,d
192
+ "docnumS": rbaseS[0:6], # doc number
193
+ "divS": rbaseS[2:3], # div number
194
+ "sdivS": rbaseS[3:5], # subdiv
195
+ "docnameS": rbaseS[6:].replace("-", " "), # document name
196
+ "replablS": reptP.name[5:],
197
+ "valprfx": rbaseS[0:6].replace("rv", "v"),
198
+ "sectS": "", # section title
199
+ "secnumI": 0, # section number
200
+ "equI": 1, # equation number
201
+ "tableI": 1, # table number
202
+ "figI": 1, # figure number
203
+ "pageI": 1, # starting page number
204
+ "noteL": [0], # endnote counter
205
+ "descS": "ref", # value description
206
+ "deciI": 2, # decimals
207
+ "headrS": "", # header string
208
+ "footrS": "", # footer string
209
+ "aliaS": "rvsource", # folder alias
210
+ "unitS": "M,M", # units
211
+ "valexpS": "", # list of values for export
212
+ "publicB": False, # public section
213
+ "showB": True, # print section to doc
214
+ "mergeB": False,
215
+ "apiB": True,
216
+ "tocB": False, # table of contents
217
+ "subB": False, # sub values in equations
218
+ "colorL": ["red", "blue", "yellow", "green", "gray"], # pallete
219
+ "colorS": "none", # topic background color
220
+ "widthI": 80, # print width
221
+ }
222
+ # endregion
223
+
224
+ # initialize doc strings
225
+ dutfS = ""
226
+ drs2S = ""
227
+ drstS = ""
228
+ dhtmS = ""
229
+ dcmdS = ""
230
+
231
+
232
+ def cmdhelp():
233
+ """command line help"""
234
+
235
+ print()
236
+ print("Run rivt file on command line with: ")
237
+ print()
238
+ print(" python rvDss-filename.py ")
239
+ print()
240
+ print("Where D is a capital alpha-numeric division label ")
241
+ print("and ss is a two digit subdivision integer. ")
242
+ print("See User Manual at https://rivt.info for details ")
243
+ sys.exit()
244
+
245
+
246
+ def doc_parse(rS, tS, tagL, cmdL):
247
+ """section string to doc string
248
+ Args:
249
+ sS (str): rivt section
250
+ tS (str): section type (R,I,V,T,W,S)
251
+ Calls:
252
+ Section (class), section (method)
253
+ Returns:
254
+ sutfS (str): utf output
255
+ srsrS (str): rst2pdf output
256
+ srstS (str): reSt output
257
+ """
258
+ global dutfS, drs2S, drstS, dhtmS, foldD, lablD, rivtD
259
+ rsL = rS.split("\n")
260
+ conC = rvparse.Rs(tS, rsL, foldD, lablD, rivtD, prflagB, rivtL)
261
+ sutfS, srs2S, srstS, foldD, lablD, rivtD = conC.content(tS, tagL, cmdL)
262
+ dutfS += sutfS
263
+ drs2S += srs2S
264
+ drstS += srstS
265
+ return dutfS, drs2S, drstS
266
+
267
+
268
+ def R(rS):
269
+ """Run shell command
270
+ Args:
271
+ rS (str): rivt string
272
+ """
273
+ global dutfS, drs2S, drstS, dhtmS, foldD, lablD, rivtD
274
+ cmdL = ["SHELL"] # commands from file
275
+ tagL = []
276
+ tagbL = [
277
+ "[SHELL]]", # run commands
278
+ "[END]]", # end
279
+ "[NEWPAGE]]", # new page
280
+ ]
281
+ tagL = tagbL + tagL
282
+ dutfS, drs2S, drstS = doc_parse(rS, "R", tagL, cmdL)
283
+
284
+
285
+ def I(rS): # noqa: E743
286
+ """Insert static source
287
+ Args:
288
+ rS (str): rivt string
289
+ """
290
+ global dutfS, drs2S, drstS, dhtmS, foldD, lablD, rivtD
291
+ cmdL = [
292
+ "IMAGE", # insert image from file
293
+ "IMAGE2", # insert adjacent images from file
294
+ "TABLE", # insert table from file
295
+ "TEXT", # insert text from filoe
296
+ ]
297
+ tagL = [
298
+ "C]", # center text
299
+ "R]", # right justify text
300
+ "M]", # math
301
+ "L]", # LaTeX math
302
+ "#]", # footnote
303
+ "G]", # glossary
304
+ "S]", # section link
305
+ "D]", # doc link
306
+ "U]", # url link
307
+ "V]", # var value
308
+ "E]", # equation label
309
+ "T]", # table label
310
+ "F]", # figure label
311
+ ]
312
+ tagbL = [
313
+ "[INDENT]]", # indent
314
+ "[ITALIC]]", # indent and italicize
315
+ "[ENDNOTES]]", # note description
316
+ "[TEXT]]", # format text
317
+ "[TOPIC]]", # topic
318
+ "[END]]", # end
319
+ "[NEWPAGE]]", # new page
320
+ ]
321
+ tagL = tagL + tagbL
322
+ dutfS, drs2S, drstS = doc_parse(rS, "I", tagL, cmdL)
323
+
324
+
325
+ def V(rS):
326
+ """Values calculate
327
+ Args:
328
+ rS (str): rivt string
329
+ """
330
+ global dutfS, drs2S, drstS, dhtmS, foldD, lablD, rivtD
331
+ compL = [" < ", " > ", " != ", " == ", " <= ", " >= "]
332
+ cmdL = [
333
+ "IMAGE", # image from file
334
+ "IMAGE2", # adjacent image files
335
+ "TABLE", # table from file
336
+ "VALTABLE", # value table from file
337
+ "PYTHON", # execute Python file
338
+ " ==: ", # define value
339
+ " <=: ", # assign value
340
+ " :=: ", # assign value
341
+ compL, # comparisons
342
+ ]
343
+ tagL = [
344
+ "V]", # var value
345
+ "E]", # equation label
346
+ "T]", # table label
347
+ "F]", # figure label
348
+ ]
349
+ tagbL = [
350
+ "[PYTHON]]", # execute Python script
351
+ "[END]]", # end
352
+ "[NEWPAGE]]", # new page
353
+ ]
354
+ tagL = tagL + tagbL
355
+ dutfS, drs2S, drstS = doc_parse(rS, "V", tagL, cmdL)
356
+
357
+
358
+ def T(rS):
359
+ """Python and Markup Tools
360
+ Args:
361
+ rS (str): rivt string
362
+ """
363
+ global dutfS, drs2S, drstS, dhtmS, foldD, lablD, rivtD
364
+ cmdL = [
365
+ "PYTHON", # execute Python file
366
+ "MARKUP", # execute script file
367
+ ]
368
+ tagL = []
369
+ tagbL = [
370
+ "[PYTHON]]", # execute Python script
371
+ "[MARKUP]]", # execute script
372
+ "[END]]", # end
373
+ "[NEWPAGE]]", # new page
374
+ ]
375
+ tagL = tagL + tagbL
376
+
377
+ blkB = False
378
+ blkS = ""
379
+ lL = rS.split("\n")
380
+ for lS in lL:
381
+ if blkB: # tag flag
382
+ if "[[END]]" in lS:
383
+ blkB = False
384
+ exec(blkS, globals(), rivtD)
385
+ blkS = ""
386
+ continue
387
+ blkS += lS.strip()
388
+ continue
389
+ for subS in tagL: # tags
390
+ if subS in lS:
391
+ blkB = True
392
+ continue
393
+ for subS in cmdL:
394
+ pass
395
+
396
+
397
+ def D(rS):
398
+ """Publish Doc files
399
+
400
+ Writes docs as .txt, .pdf (reportLab or tex) and .html
401
+
402
+ Args:
403
+ rS (str): rivt string
404
+ """
405
+ global dutfS, drs2S, drstS, dhtmS, foldD, lablD, rivtD
406
+ cmdL = ["PUBLISH", "ATTACHPDF"]
407
+ tagbL = ["_[[LAYOUT", "_[[METADATA", "_[[END"]
408
+ tagL = []
409
+ tagL = tagL + tagbL
410
+ dutfS += "\nend of doc\n"
411
+ drs2S += "\nend of doc\n"
412
+ drstS += "\nend of doc\n"
413
+ wrtdoc = rvdoc.Cmdp(
414
+ rS, foldD, lablD, cmdL, tagL, dutfS, drs2S, drstS, rivtD
415
+ )
416
+ mssgS = wrtdoc.cmdx()
417
+ print(f"{mssgS}")
418
+ sys.exit()
419
+
420
+
421
+ def S(rS):
422
+ """skip rivt string processing
423
+ Args:
424
+ rS (str): rivt string
425
+ """
426
+ global dutfS, drs2S, drstS, dhtmS
427
+
428
+ shL = rS.split("\n")
429
+ sutfS = srsrS = srstS = (
430
+ "\n[" + shL[0].strip() + "] : section skipped " + "\n"
431
+ )
432
+ print(sutfS)
433
+ dutfS += sutfS
434
+ drs2S += srsrS
435
+ drstS += srstS
436
+
437
+
438
+ def X(rS):
439
+ """exit rivt file processing
440
+ Args:
441
+ rS (str): rivt string
442
+ """
443
+ shL = rS.split("\n")
444
+ logging.info("exit rivt file at: " + shL[0])
445
+ print("\n[" + shL[0].strip() + "] : rivtlib exit " + "\n")
446
+ sys.exit()