Commits

Gordon Hemsley committed d7dcfb0

Add --dump-refs flag, which outputs a JSON file listing the references used in the spec.

Comments (0)

Files changed (2)

     parser.add_argument("--output-encoding", action="store", type=str,
                         dest="output_encoding", help="Output encoding")
 
+    parser.add_argument("--dump-refs", action="store", type=str,
+                        dest="dump_refs", help=SUPPRESS)
+
     parser.add_argument("--dump-xrefs", action="store", type=str,
                         dest="dump_xrefs", help=SUPPRESS)
 
         escape_lt_in_attrs=False,
         escape_rcdata=False,
         output_encoding="utf-8",
+        dump_refs='',
         dump_xrefs='',
         use_strict=False,
         publication_date='',

anolislib/processes/refs.py

 class refs(object):
   """Add references section."""
 
-  def __init__(self, ElementTree, split_references_section=False, **kwargs):
+  def __init__(self, ElementTree, split_references_section=False, dump_refs='', **kwargs):
     self.refs = {}
     self.usedrefs = []
     self.foundrefs = {}
       self.addReferencesList(ElementTree, **kwargs)
     else:
       self.addTwoReferencesLists(ElementTree, **kwargs)
+    if dump_refs:
+      self.dump(self.getTwoReferencesLists(), dump_refs, **kwargs)
 
   def addDD(self, dl, ref, informative):
     if isinstance(self.refs[ref], list):
     self.refs = json.load(list)
     list.close()
 
-  def addTwoReferencesLists(self, ElementTree, **kwargs):
+  def getTwoReferencesLists(self):
     informative = []
     normative = []
     for ref in self.usedrefs:
         normative.append(ref)
       else:
         informative.append(ref)
-    self.addPartialReferencesList(ElementTree, normative, "normative", **kwargs)
-    self.addPartialReferencesList(ElementTree, informative, "informative", **kwargs)
+    return { "normative": normative, "informative": informative }
+
+  def dump(self, obj, f, **kwargs):
+    d = json.dumps(obj, sort_keys=True, allow_nan=False, indent=2, separators=(',', ': '))
+    fp = open(f, "w")
+    fp.write(d + "\n")
+    fp.close()
+
+  def addTwoReferencesLists(self, ElementTree, **kwargs):
+    refs = self.getTwoReferencesLists()
+    self.addPartialReferencesList(ElementTree, refs["normative"], "normative", **kwargs)
+    self.addPartialReferencesList(ElementTree, refs["informative"], "informative", **kwargs)
 
   def addPartialReferencesList(self, ElementTree, l, id, **kwargs):
     if not len(l):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.