rda-python-miscs 2.0.5__tar.gz → 2.0.6__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 (54) hide show
  1. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/PKG-INFO +1 -1
  2. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/pyproject.toml +1 -1
  3. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/src/rda_python_miscs/pg_rst.py +47 -50
  4. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/src/rda_python_miscs/rst_templates/index.rst.temp +2 -9
  5. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/src/rda_python_miscs/rst_templates/section.rst.temp +2 -3
  6. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/src/rda_python_miscs.egg-info/PKG-INFO +1 -1
  7. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/LICENSE +0 -0
  8. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/MANIFEST.in +0 -0
  9. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/README.md +0 -0
  10. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/setup.cfg +0 -0
  11. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/src/rda_python_miscs/__init__.py +0 -0
  12. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/src/rda_python_miscs/bash_qsub.py +0 -0
  13. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/src/rda_python_miscs/bashqsub.py +0 -0
  14. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/src/rda_python_miscs/bashqsub.usg +0 -0
  15. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/src/rda_python_miscs/gdex_ls.py +0 -0
  16. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/src/rda_python_miscs/gdexls.py +0 -0
  17. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/src/rda_python_miscs/gdexls.usg +0 -0
  18. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/src/rda_python_miscs/gdexls_standalone.py +0 -0
  19. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/src/rda_python_miscs/pg_docs.py +0 -0
  20. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/src/rda_python_miscs/pg_wget.py +0 -0
  21. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/src/rda_python_miscs/pgwget.py +0 -0
  22. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/src/rda_python_miscs/rda_cp.py +0 -0
  23. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/src/rda_python_miscs/rda_kill.py +0 -0
  24. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/src/rda_python_miscs/rda_mod.py +0 -0
  25. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/src/rda_python_miscs/rda_own.py +0 -0
  26. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/src/rda_python_miscs/rda_ps.py +0 -0
  27. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/src/rda_python_miscs/rda_sub.py +0 -0
  28. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/src/rda_python_miscs/rda_zip.py +0 -0
  29. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/src/rda_python_miscs/rdacp.py +0 -0
  30. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/src/rda_python_miscs/rdacp.usg +0 -0
  31. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/src/rda_python_miscs/rdakill.py +0 -0
  32. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/src/rda_python_miscs/rdakill.usg +0 -0
  33. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/src/rda_python_miscs/rdals.py +0 -0
  34. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/src/rda_python_miscs/rdals.usg +0 -0
  35. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/src/rda_python_miscs/rdamod.py +0 -0
  36. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/src/rda_python_miscs/rdamod.usg +0 -0
  37. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/src/rda_python_miscs/rdaown.py +0 -0
  38. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/src/rda_python_miscs/rdaown.usg +0 -0
  39. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/src/rda_python_miscs/rdaps.py +0 -0
  40. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/src/rda_python_miscs/rdaps.usg +0 -0
  41. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/src/rda_python_miscs/rdasub.py +0 -0
  42. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/src/rda_python_miscs/rdasub.usg +0 -0
  43. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/src/rda_python_miscs/rdazip.py +0 -0
  44. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/src/rda_python_miscs/rdazip.usg +0 -0
  45. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/src/rda_python_miscs/rst_templates/toc.rst.temp +0 -0
  46. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/src/rda_python_miscs/tcsh_qsub.py +0 -0
  47. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/src/rda_python_miscs/tcshqsub.py +0 -0
  48. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/src/rda_python_miscs/tcshqsub.usg +0 -0
  49. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/src/rda_python_miscs.egg-info/SOURCES.txt +0 -0
  50. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/src/rda_python_miscs.egg-info/dependency_links.txt +0 -0
  51. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/src/rda_python_miscs.egg-info/entry_points.txt +0 -0
  52. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/src/rda_python_miscs.egg-info/requires.txt +0 -0
  53. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/src/rda_python_miscs.egg-info/top_level.txt +0 -0
  54. {rda_python_miscs-2.0.5 → rda_python_miscs-2.0.6}/tests/test_miscs.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rda_python_miscs
3
- Version: 2.0.5
3
+ Version: 2.0.6
4
4
  Summary: RDA Python package to hold RDA miscellaneous utility programs
5
5
  Author-email: Zaihua Ji <zji@ucar.edu>
6
6
  Project-URL: Homepage, https://github.com/NCAR/rda-python-miscs
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
6
6
 
7
7
  [project]
8
8
  name = "rda_python_miscs"
9
- version = "2.0.5"
9
+ version = "2.0.6"
10
10
  authors = [
11
11
  { name="Zaihua Ji", email="zji@ucar.edu" },
12
12
  ]
@@ -22,7 +22,6 @@ from os import path as op
22
22
  from rda_python_common.pg_file import PgFile
23
23
  from rda_python_common.pg_util import PgUtil
24
24
 
25
-
26
25
  class PgRST(PgFile, PgUtil):
27
26
  """Convert text-based program usage documents (.usg files) into
28
27
  reStructuredText (.rst) files using RST template files.
@@ -48,7 +47,7 @@ class PgRST(PgFile, PgUtil):
48
47
  Q0 = "'"
49
48
  Q1 = "**" # RST bold open (was "<i><b>")
50
49
  Q2 = "**" # RST bold close (was "</i></b>")
51
-
50
+ TLEVEL = 3 # max section level to be rendered (1, 2, or 3)
52
51
  EMLIST = {
53
52
  'dsarch' : 1,
54
53
  'msarch' : 1,
@@ -60,7 +59,6 @@ class PgRST(PgFile, PgUtil):
60
59
  'rcm' : 1,
61
60
  'dcm' : 1,
62
61
  }
63
-
64
62
  SEARCH = "(Action|Info|Mode|Multi-Value|Single-Value)"
65
63
 
66
64
  def __init__(self):
@@ -116,7 +114,6 @@ class PgRST(PgFile, PgUtil):
116
114
  'DOCTIT' : "", # document name in upper case letters
117
115
  'DOCLNK' : None,
118
116
  }
119
-
120
117
  self.LINKS = ['dsarch', 'dsupdt', 'dsrqst', 'dscheck']
121
118
 
122
119
  #
@@ -150,7 +147,7 @@ class PgRST(PgFile, PgUtil):
150
147
  self.change_local_directory(self.DOCS['DOCDIR'], self.LGWNEX)
151
148
  self.pglog("Write rst document '{}' under {}".format(docname, self.DOCS['DOCDIR']), self.LOGWRN)
152
149
 
153
- if op.exists("index.rst"): # write index file once
150
+ if op.exists(op.join(self.DOCS['DOCDIR'], "index.rst")): # write index file once
154
151
  self.pglog("index.rst exists already, delete first if needs to be regenerated", self.LOGWRN)
155
152
  else:
156
153
  self.write_index(self.sections[0])
@@ -164,12 +161,8 @@ class PgRST(PgFile, PgUtil):
164
161
  def parse_docs(self, docname):
165
162
  """Read *docname*.usg and populate ``sections``, ``options``, and ``examples``.
166
163
 
167
- Lines beginning with ``#`` are treated as comments and skipped. Inline
168
- trailing comments are also stripped. Angle-bracketed uppercase tokens
169
- (e.g. ``<FILENAME>``) are temporarily escaped to ``&ltFILENAME&gt``
170
- so they are not misidentified as option markers (``<:>``, ``<=>``,
171
- ``<!>``) later in processing. They are unescaped back to ``<FILENAME>``
172
- in :meth:`replace_option_link` before appearing in RST output.
164
+ Lines beginning with ``#`` are treated as comments and skipped. In-line
165
+ trailing comments are also stripped.
173
166
 
174
167
  Args:
175
168
  docname (str): Short document name used to locate ``<ORIGIN>/<docname>.usg``.
@@ -190,14 +183,6 @@ class PgRST(PgFile, PgUtil):
190
183
  else:
191
184
  line = line.rstrip() # remove trailing white spaces
192
185
 
193
- # Temporarily escape <UPPERCASE> tokens so they are not confused
194
- # with special markers like <:>, <=>, <!> used in option parsing.
195
- while True:
196
- ms = re.search(r'(<([A-Z/\-\.]+)>)', line)
197
- if ms:
198
- line = line.replace(ms.group(1), "&lt{}&gt".format(ms.group(2)))
199
- else:
200
- break
201
186
  ms = re.match(r'^([\d\.]+)\s+(.+)$', line)
202
187
  if ms: # start new section
203
188
  section = self.record_section(section, option, example, ms.group(1), ms.group(2))
@@ -298,10 +283,16 @@ class PgRST(PgFile, PgUtil):
298
283
  dict | None: A new example dict when *ndesc* is given, else ``None``.
299
284
  """
300
285
  if example:
301
- ms = re.match(r'^(.*)\.\s*(.*)$', example['desc'])
286
+ lines = example['desc'].split('\n')
287
+ first_line = lines[0]
288
+ rest = '\n'.join(lines[1:]) if len(lines) > 1 else ''
289
+ ms = re.match(r'^(.*)\.\s*(.*)$', first_line)
302
290
  if ms:
303
291
  example['title'] = ms.group(1)
304
- example['desc'] = ms.group(2)
292
+ example['desc'] = (ms.group(2) + '\n' + rest) if rest else ms.group(2)
293
+ else:
294
+ example['title'] = first_line
295
+ example['desc'] = rest
305
296
  option['exmidxs'].append(len(self.examples)) # record example index in option
306
297
  self.examples.append(example) # record example globally
307
298
 
@@ -394,7 +385,8 @@ class PgRST(PgFile, PgUtil):
394
385
  Returns:
395
386
  dict: New example dict with keys ``opt``, ``title``, and ``desc``.
396
387
  """
397
- return {'opt' : opt, 'title' : "", 'desc' : desc.title() + "\n"}
388
+ desc = (desc[0].upper() + desc[1:]) if desc else desc
389
+ return {'opt' : opt, 'title' : "", 'desc' : desc + "\n"}
398
390
 
399
391
  #
400
392
  # write the entry file: index.rst
@@ -481,8 +473,8 @@ class PgRST(PgFile, PgUtil):
481
473
  #
482
474
  # create rst content for table of contents
483
475
  #
484
- def create_toc(self):
485
- """Build and return the RST table-of-contents string.
476
+ def create_toc(self, csection=None):
477
+ """Build and return the RST table-of-contents string of a given section.
486
478
 
487
479
  Produces a nested bullet list of section links (indented by section
488
480
  level) followed by a flat Appendix A list of all example links.
@@ -490,29 +482,38 @@ class PgRST(PgFile, PgUtil):
490
482
  Returns:
491
483
  str: RST-formatted TOC content ready for ``__TOC__`` substitution.
492
484
  """
485
+
493
486
  content = ""
487
+ clevel = csection['level'] if csection else 0
488
+ csecid = csection['secid'] if csection else ""
489
+ depth = self.TLEVEL - clevel
494
490
 
495
491
  # nested bullet list for all sections
496
492
  for section in self.sections:
497
493
  secid = section['secid']
498
- indent = " " * (section['level'] - 1)
499
- content += "{}- `{}. {} <section{}.rst>`_\n".format(
500
- indent, secid, section['title'], secid)
501
-
502
- content += "\n"
503
-
504
- # appendix A: list of examples
505
- content += "**Appendix A: List of Examples**\n\n"
506
-
494
+ level = section['level']
495
+ if csecid:
496
+ if not secid.startswith(csecid + "."): continue
497
+ elif level > (clevel+1):
498
+ continue
499
+ content += " section{}\n".format(secid)
500
+
501
+ if not content: return ""
502
+
503
+ content = f".. toctree::\n :maxdepth: {depth}\n :caption: Table of Contents\n{content}\n"
504
+ # appendix A: list of examples for the parent section and its subsections
505
+ appendix = ""
507
506
  idx = 1 # used as example index
508
- for example in self.examples:
509
- opt = example['opt']
507
+ for exm in self.examples:
508
+ opt = exm['opt']
510
509
  option = self.options[opt]
511
510
  secid = option['secid']
512
- content += "- `A.{}. {} Option -{} (-{}) <section{}.rst#e{}>`_\n".format(
513
- idx, option['type'], opt, option['name'], secid, idx)
511
+ if not csecid or secid == csecid or secid.startswith(csecid + "."):
512
+ appendix += "- `A.{}. {} Option -{} (-{}) <{}_e{}>`_\n".format(
513
+ idx, option['type'], opt, option['name'], secid, idx)
514
514
  idx += 1
515
- content += "\n"
515
+ if appendix:
516
+ content += "**Appendix A: List of Examples**\n\n" + appendix + "\n"
516
517
 
517
518
  return content
518
519
 
@@ -537,6 +538,7 @@ class PgRST(PgFile, PgUtil):
537
538
  for opt in section['opts']:
538
539
  content += self.create_option(opt, secid)
539
540
 
541
+ content += self.create_toc(section) # add a local TOC for the section and its subsections
540
542
  return content
541
543
 
542
544
  #
@@ -612,7 +614,7 @@ class PgRST(PgFile, PgUtil):
612
614
  def create_example(self, exmidx, secid):
613
615
  """Build the RST content for a single example.
614
616
 
615
- Emits a ``.. _e<N>:`` anchor, a bold ``EXAMPLE N. <title>`` heading,
617
+ Emits a ``.. _secid_e<N>:`` anchor, a bold ``EXAMPLE N. <title>`` heading,
616
618
  and the example's body description.
617
619
 
618
620
  Args:
@@ -624,7 +626,7 @@ class PgRST(PgFile, PgUtil):
624
626
  """
625
627
  example = self.examples[exmidx]
626
628
  exm = exmidx + 1
627
- content = "\n.. _e{}:\n\n".format(exm)
629
+ content = "\n.. _{}_e{}:\n\n".format(secid, exm)
628
630
  content += "**EXAMPLE {}. {}**\n\n".format(exm, example['title'])
629
631
  content += self.create_description(example['desc'], secid, 2)
630
632
 
@@ -713,7 +715,7 @@ class PgRST(PgFile, PgUtil):
713
715
  if ptype == 2 and re.search(r'Mode Options*', opt) and dtype == 3:
714
716
  link = "{}`{} <mode_>`_{}".format(pre, opt, after)
715
717
  else:
716
- link = "{}`{} <section{}_>`_{}".format(pre, opt, secid, after)
718
+ link = "{}`{} <section{}>`_{}".format(pre, opt, secid, after)
717
719
  line = line.replace(replace, link)
718
720
 
719
721
  ms = re.search(r'(https*://\S+)(\.|\,)', line)
@@ -734,10 +736,6 @@ class PgRST(PgFile, PgUtil):
734
736
  link = self.Q1 + opt + self.Q2
735
737
  line = line.replace(replace, link)
736
738
 
737
- # Unescape <UPPERCASE> tokens that were temporarily escaped during
738
- # parsing to avoid confusion with option markers (<:>, <=>, <!>).
739
- line = line.replace('&lt', '<').replace('&gt', '>')
740
-
741
739
  return line
742
740
 
743
741
  #
@@ -879,7 +877,6 @@ class PgRST(PgFile, PgUtil):
879
877
 
880
878
  Detects three sub-formats:
881
879
 
882
- * Lines starting with ``- `` → RST numbered list (``#.``).
883
880
  * Lines ending with ``=>`` → RST line block (``|``).
884
881
  * Lines split on `` - `` (key-value pairs) → ``.. list-table::`` directive.
885
882
  * All other lines split on 2+ spaces → RST simple table.
@@ -900,7 +897,7 @@ class PgRST(PgFile, PgUtil):
900
897
  line = lines[i]
901
898
  ms = re.match(r'^\s+-\s+(.*)', line)
902
899
  if ms:
903
- content += "#. " + self.replace_option_link(ms.group(1), secid, 1) + "\n"
900
+ content += "* " + self.replace_option_link(ms.group(1), secid, 1) + "\n"
904
901
  else:
905
902
  content += " " + self.replace_option_link(line, secid, 1) + "\n"
906
903
  content += "\n"
@@ -1031,7 +1028,7 @@ class PgRST(PgFile, PgUtil):
1031
1028
  if ms:
1032
1029
  content += "| {}{}{} {}\n".format(self.Q1, self.DOCS['DOCNAM'], self.Q2, ms.group(1))
1033
1030
  else:
1034
- content += "| {}\n".format(line.strip())
1031
+ content += "|{}\n".format(line)
1035
1032
  content += "\n"
1036
1033
 
1037
1034
  return content
@@ -1077,11 +1074,11 @@ class PgRST(PgFile, PgUtil):
1077
1074
  title (str): Section title text to look up.
1078
1075
 
1079
1076
  Returns:
1080
- str: RST `` `title <sectionN.rst>`_ `` link, or *title* if not found.
1077
+ str: RST `` `title <sectionN>`_ `` link, or *title* if not found.
1081
1078
  """
1082
1079
  for section in self.sections:
1083
1080
  if title == section['title']:
1084
- return "`{} <section{}.rst>`_".format(title, section['secid'])
1081
+ return "`{} <section{}>`_".format(title, section['secid'])
1085
1082
 
1086
1083
  return title
1087
1084
 
@@ -1,11 +1,10 @@
1
1
  ################################################################################
2
2
  #
3
- # Title : index.temp
3
+ # Title : index_rst.temp
4
4
  # Author : Zaihua Ji, zji@ucar.edu
5
5
  # Date : 03/17/2026
6
6
  # Purpose : template file for help document index.rst (reStructuredText)
7
- #
8
- # Work File : $DSSHOME/lib/templates/index.temp
7
+ # Github : https://github.com/NCAR/rda-python-mics.git
9
8
  #
10
9
  ################################################################################
11
10
 
@@ -15,10 +14,4 @@
15
14
  A GUIDE TO __TITLE__
16
15
  ============================
17
16
 
18
- .. toctree::
19
- :maxdepth: 2
20
- :caption: Contents
21
-
22
- section__SECID__
23
-
24
17
  __TOC__
@@ -1,11 +1,10 @@
1
1
  ################################################################################
2
2
  #
3
- # Title : section.temp
3
+ # Title : section_rst.temp
4
4
  # Author : Zaihua Ji, zji@ucar.edu
5
5
  # Date : 03/17/2026
6
6
  # Purpose : template file for help document section.rst (reStructuredText)
7
- #
8
- # Work File : $DSSHOME/lib/templates/section.temp
7
+ # Github : https://github.com/NCAR/rda-python-mics.git
9
8
  #
10
9
  ################################################################################
11
10
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rda_python_miscs
3
- Version: 2.0.5
3
+ Version: 2.0.6
4
4
  Summary: RDA Python package to hold RDA miscellaneous utility programs
5
5
  Author-email: Zaihua Ji <zji@ucar.edu>
6
6
  Project-URL: Homepage, https://github.com/NCAR/rda-python-miscs