Skip to content

Commit b064c3e

Browse files
committed
Update docs
1 parent 44f9a0b commit b064c3e

10 files changed

Lines changed: 1549 additions & 18 deletions

File tree

docs/jsonid/export.html

Lines changed: 144 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ <h2 class="section-title" id="header-functions">Functions</h2>
5555
</summary>
5656
<pre><code class="python">def exportJSON() -&gt; None: # pylint: disable=C0103
5757
&#34;&#34;&#34;Export to JSON.&#34;&#34;&#34;
58-
logger.debug(&#34;exporting registry ad JSON&#34;)
58+
logger.debug(&#34;exporting registry as JSON&#34;)
5959
data = registry_data.registry()
6060
json_obj = []
6161
id_ = {
@@ -74,9 +74,144 @@ <h2 class="section-title" id="header-functions">Functions</h2>
7474
</details>
7575
<div class="desc"><p>Export to JSON.</p></div>
7676
</dd>
77+
<dt id="src.jsonid.export.export_pronom"><code class="name flex">
78+
<span>def <span class="ident">export_pronom</span></span>(<span>) ‑> None</span>
79+
</code></dt>
80+
<dd>
81+
<details class="source">
82+
<summary>
83+
<span>Expand source code</span>
84+
</summary>
85+
<pre><code class="python">def export_pronom() -&gt; None:
86+
&#34;&#34;&#34;Export a PRONOM compatible set of signatures.
87+
88+
Export is done in two phases. A set of proposed &#34;Baseline&#34; JSON
89+
signatures to catch many JSON instances.
90+
91+
Second the JSONID registry is exported.
92+
93+
Every export has a priority over the other so that there should
94+
be no multiple identification results.
95+
&#34;&#34;&#34;
96+
97+
# pylint: disable=R0914; too-many local variables.
98+
99+
logger.debug(&#34;exporting registry as PRONOM&#34;)
100+
101+
reg_data = registry_data.registry()
102+
formats = []
103+
104+
encodings = (&#34;UTF-8&#34;, &#34;UTF-16&#34;, &#34;UTF-16BE&#34;, &#34;UTF-32LE&#34;)
105+
priorities = []
106+
107+
increment_id = 0
108+
109+
for encoding in encodings:
110+
all_baseline = pronom.create_baseline_json_sequences(encoding)
111+
for baseline in all_baseline:
112+
increment_id += 1
113+
fmt = pronom.Format(
114+
id=increment_id,
115+
name=f&#34;JSON (Baseline - fmt/817) ({encoding})&#34;,
116+
version=&#34;&#34;,
117+
puid=&#34;jsonid:0000&#34;,
118+
mime=&#34;application/json&#34;,
119+
classification=&#34;structured text&#34;,
120+
external_signatures=[
121+
pronom.ExternalSignature(
122+
id=increment_id,
123+
signature=&#34;json&#34;,
124+
type=pronom.EXT,
125+
)
126+
],
127+
internal_signatures=[baseline],
128+
priorities=priorities,
129+
)
130+
priorities.append(f&#34;{increment_id}&#34;)
131+
formats.append(fmt)
132+
133+
for encoding in encodings:
134+
for entry in reg_data:
135+
increment_id += 1
136+
json_puid = f&#34;{entry.json()[&#39;identifier&#39;]};{encoding}&#34;
137+
name_ = f&#34;{entry.json()[&#39;name&#39;][0][&#39;@en&#39;]} ({encoding})&#34;
138+
markers = entry.json()[&#34;markers&#34;]
139+
try:
140+
mime = entry.json()[&#34;mime&#34;][0]
141+
except IndexError:
142+
mime = &#34;&#34;
143+
try:
144+
sequences = pronom.process_markers(
145+
copy.deepcopy(markers),
146+
increment_id,
147+
encoding=encoding,
148+
)
149+
except pronom.UnprocessableEntity as err:
150+
logger.error(
151+
&#34;%s %s: cannot handle: %s&#34;,
152+
json_puid,
153+
name_,
154+
err,
155+
)
156+
for marker in markers:
157+
logger.debug(&#34;--- START ---&#34;)
158+
logger.debug(&#34;marker: %s&#34;, marker)
159+
logger.debug(&#34;--- END ---&#34;)
160+
continue
161+
fmt = pronom.Format(
162+
id=increment_id,
163+
name=name_,
164+
version=&#34;&#34;,
165+
puid=json_puid,
166+
mime=mime,
167+
classification=&#34;structured text&#34;,
168+
external_signatures=[
169+
pronom.ExternalSignature(
170+
id=increment_id,
171+
signature=&#34;json&#34;,
172+
type=pronom.EXT,
173+
)
174+
],
175+
internal_signatures=sequences,
176+
priorities=copy.deepcopy(list(set(priorities))),
177+
)
178+
priorities.append(f&#34;{increment_id}&#34;)
179+
formats.append(fmt)
180+
181+
pronom.process_formats_and_save(formats, PRONOM_FILENAME)</code></pre>
182+
</details>
183+
<div class="desc"><p>Export a PRONOM compatible set of signatures.</p>
184+
<p>Export is done in two phases. A set of proposed "Baseline" JSON
185+
signatures to catch many JSON instances.</p>
186+
<p>Second the JSONID registry is exported.</p>
187+
<p>Every export has a priority over the other so that there should
188+
be no multiple identification results.</p></div>
189+
</dd>
77190
</dl>
78191
</section>
79192
<section>
193+
<h2 class="section-title" id="header-classes">Classes</h2>
194+
<dl>
195+
<dt id="src.jsonid.export.PRONOMException"><code class="flex name class">
196+
<span>class <span class="ident">PRONOMException</span></span>
197+
<span>(</span><span>*args, **kwargs)</span>
198+
</code></dt>
199+
<dd>
200+
<details class="source">
201+
<summary>
202+
<span>Expand source code</span>
203+
</summary>
204+
<pre><code class="python">class PRONOMException(Exception):
205+
&#34;&#34;&#34;Exception class if we can&#39;t create a PRONOM signature as expected.&#34;&#34;&#34;</code></pre>
206+
</details>
207+
<div class="desc"><p>Exception class if we can't create a PRONOM signature as expected.</p></div>
208+
<h3>Ancestors</h3>
209+
<ul class="hlist">
210+
<li>builtins.Exception</li>
211+
<li>builtins.BaseException</li>
212+
</ul>
213+
</dd>
214+
</dl>
80215
</section>
81216
</article>
82217
<nav id="sidebar">
@@ -92,6 +227,14 @@ <h2 class="section-title" id="header-functions">Functions</h2>
92227
<li><h3><a href="#header-functions">Functions</a></h3>
93228
<ul class="">
94229
<li><code><a title="src.jsonid.export.exportJSON" href="#src.jsonid.export.exportJSON">exportJSON</a></code></li>
230+
<li><code><a title="src.jsonid.export.export_pronom" href="#src.jsonid.export.export_pronom">export_pronom</a></code></li>
231+
</ul>
232+
</li>
233+
<li><h3><a href="#header-classes">Classes</a></h3>
234+
<ul>
235+
<li>
236+
<h4><code><a title="src.jsonid.export.PRONOMException" href="#src.jsonid.export.PRONOMException">PRONOMException</a></code></h4>
237+
</li>
95238
</ul>
96239
</li>
97240
</ul>

docs/jsonid/export_helpers.html

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
6+
<meta name="generator" content="pdoc3 0.11.6">
7+
<title>src.jsonid.export_helpers API documentation</title>
8+
<meta name="description" content="Helpers for the export functions.">
9+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/13.0.0/sanitize.min.css" integrity="sha512-y1dtMcuvtTMJc1yPgEqF0ZjQbhnc/bFhyvIyVNb9Zk5mIGtqVaAB1Ttl28su8AvFMOY0EwRbAe+HCLqj6W7/KA==" crossorigin>
10+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/13.0.0/typography.min.css" integrity="sha512-Y1DYSb995BAfxobCkKepB1BqJJTPrOp3zPL74AWFugHHmmdcvO+C48WLrUOlhGMc0QG7AE3f7gmvvcrmX2fDoA==" crossorigin>
11+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css" crossorigin>
12+
<style>:root{--highlight-color:#fe9}.flex{display:flex !important}body{line-height:1.5em}#content{padding:20px}#sidebar{padding:1.5em;overflow:hidden}#sidebar > *:last-child{margin-bottom:2cm}.http-server-breadcrumbs{font-size:130%;margin:0 0 15px 0}#footer{font-size:.75em;padding:5px 30px;border-top:1px solid #ddd;text-align:right}#footer p{margin:0 0 0 1em;display:inline-block}#footer p:last-child{margin-right:30px}h1,h2,h3,h4,h5{font-weight:300}h1{font-size:2.5em;line-height:1.1em}h2{font-size:1.75em;margin:2em 0 .50em 0}h3{font-size:1.4em;margin:1.6em 0 .7em 0}h4{margin:0;font-size:105%}h1:target,h2:target,h3:target,h4:target,h5:target,h6:target{background:var(--highlight-color);padding:.2em 0}a{color:#058;text-decoration:none;transition:color .2s ease-in-out}a:visited{color:#503}a:hover{color:#b62}.title code{font-weight:bold}h2[id^="header-"]{margin-top:2em}.ident{color:#900;font-weight:bold}pre code{font-size:.8em;line-height:1.4em;padding:1em;display:block}code{background:#f3f3f3;font-family:"DejaVu Sans Mono",monospace;padding:1px 4px;overflow-wrap:break-word}h1 code{background:transparent}pre{border-top:1px solid #ccc;border-bottom:1px solid #ccc;margin:1em 0}#http-server-module-list{display:flex;flex-flow:column}#http-server-module-list div{display:flex}#http-server-module-list dt{min-width:10%}#http-server-module-list p{margin-top:0}.toc ul,#index{list-style-type:none;margin:0;padding:0}#index code{background:transparent}#index h3{border-bottom:1px solid #ddd}#index ul{padding:0}#index h4{margin-top:.6em;font-weight:bold}@media (min-width:200ex){#index .two-column{column-count:2}}@media (min-width:300ex){#index .two-column{column-count:3}}dl{margin-bottom:2em}dl dl:last-child{margin-bottom:4em}dd{margin:0 0 1em 3em}#header-classes + dl > dd{margin-bottom:3em}dd dd{margin-left:2em}dd p{margin:10px 0}.name{background:#eee;font-size:.85em;padding:5px 10px;display:inline-block;min-width:40%}.name:hover{background:#e0e0e0}dt:target .name{background:var(--highlight-color)}.name > span:first-child{white-space:nowrap}.name.class > span:nth-child(2){margin-left:.4em}.inherited{color:#999;border-left:5px solid #eee;padding-left:1em}.inheritance em{font-style:normal;font-weight:bold}.desc h2{font-weight:400;font-size:1.25em}.desc h3{font-size:1em}.desc dt code{background:inherit}.source > summary,.git-link-div{color:#666;text-align:right;font-weight:400;font-size:.8em;text-transform:uppercase}.source summary > *{white-space:nowrap;cursor:pointer}.git-link{color:inherit;margin-left:1em}.source pre{max-height:500px;overflow:auto;margin:0}.source pre code{font-size:12px;overflow:visible;min-width:max-content}.hlist{list-style:none}.hlist li{display:inline}.hlist li:after{content:',\2002'}.hlist li:last-child:after{content:none}.hlist .hlist{display:inline;padding-left:1em}img{max-width:100%}td{padding:0 .5em}.admonition{padding:.1em 1em;margin:1em 0}.admonition-title{font-weight:bold}.admonition.note,.admonition.info,.admonition.important{background:#aef}.admonition.todo,.admonition.versionadded,.admonition.tip,.admonition.hint{background:#dfd}.admonition.warning,.admonition.versionchanged,.admonition.deprecated{background:#fd4}.admonition.error,.admonition.danger,.admonition.caution{background:lightpink}</style>
13+
<style media="screen and (min-width: 700px)">@media screen and (min-width:700px){#sidebar{width:30%;height:100vh;overflow:auto;position:sticky;top:0}#content{width:70%;max-width:100ch;padding:3em 4em;border-left:1px solid #ddd}pre code{font-size:1em}.name{font-size:1em}main{display:flex;flex-direction:row-reverse;justify-content:flex-end}.toc ul ul,#index ul ul{padding-left:1em}.toc > ul > li{margin-top:.5em}}</style>
14+
<style media="print">@media print{#sidebar h1{page-break-before:always}.source{display:none}}@media print{*{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a[href]:after{content:" (" attr(href) ")";font-size:90%}a[href][title]:after{content:none}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:0.5cm}p,h2,h3{orphans:3;widows:3}h1,h2,h3,h4,h5,h6{page-break-after:avoid}}</style>
15+
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js" integrity="sha512-D9gUyxqja7hBtkWpPWGt9wfbfaMGVt9gnyCvYa+jojwwPHLCzUm5i8rpk7vD7wNee9bA35eYIjobYPaQuKS1MQ==" crossorigin></script>
16+
<script>window.addEventListener('DOMContentLoaded', () => {
17+
hljs.configure({languages: ['bash', 'css', 'diff', 'graphql', 'ini', 'javascript', 'json', 'plaintext', 'python', 'python-repl', 'rust', 'shell', 'sql', 'typescript', 'xml', 'yaml']});
18+
hljs.highlightAll();
19+
/* Collapse source docstrings */
20+
setTimeout(() => {
21+
[...document.querySelectorAll('.hljs.language-python > .hljs-string')]
22+
.filter(el => el.innerHTML.length > 200 && ['"""', "'''"].includes(el.innerHTML.substring(0, 3)))
23+
.forEach(el => {
24+
let d = document.createElement('details');
25+
d.classList.add('hljs-string');
26+
d.innerHTML = '<summary>"""</summary>' + el.innerHTML.substring(3);
27+
el.replaceWith(d);
28+
});
29+
}, 100);
30+
})</script>
31+
</head>
32+
<body>
33+
<main>
34+
<article id="content">
35+
<header>
36+
<h1 class="title">Module <code>src.jsonid.export_helpers</code></h1>
37+
</header>
38+
<section id="section-intro">
39+
<p>Helpers for the export functions.</p>
40+
</section>
41+
<section>
42+
</section>
43+
<section>
44+
</section>
45+
<section>
46+
<h2 class="section-title" id="header-functions">Functions</h2>
47+
<dl>
48+
<dt id="src.jsonid.export_helpers.get_utc_timestamp_now"><code class="name flex">
49+
<span>def <span class="ident">get_utc_timestamp_now</span></span>(<span>)</span>
50+
</code></dt>
51+
<dd>
52+
<details class="source">
53+
<summary>
54+
<span>Expand source code</span>
55+
</summary>
56+
<pre><code class="python">def get_utc_timestamp_now():
57+
&#34;&#34;&#34;Get a formatted UTC timestamp for &#39;now&#39; that can be used when
58+
a timestamp is needed.
59+
&#34;&#34;&#34;
60+
return datetime.datetime.now(timezone.utc).strftime(UTC_TIME_FORMAT)</code></pre>
61+
</details>
62+
<div class="desc"><p>Get a formatted UTC timestamp for 'now' that can be used when
63+
a timestamp is needed.</p></div>
64+
</dd>
65+
<dt id="src.jsonid.export_helpers.new_prettify"><code class="name flex">
66+
<span>def <span class="ident">new_prettify</span></span>(<span>c)</span>
67+
</code></dt>
68+
<dd>
69+
<details class="source">
70+
<summary>
71+
<span>Expand source code</span>
72+
</summary>
73+
<pre><code class="python">def new_prettify(c):
74+
&#34;&#34;&#34;Remove excess newlines from DOM output.
75+
76+
via: https://stackoverflow.com/a/14493981
77+
&#34;&#34;&#34;
78+
reparsed = parseString(c)
79+
return &#34;\n&#34;.join(
80+
[
81+
line
82+
for line in reparsed.toprettyxml(indent=&#34; &#34; * 2).split(&#34;\n&#34;)
83+
if line.strip()
84+
]
85+
)</code></pre>
86+
</details>
87+
<div class="desc"><p>Remove excess newlines from DOM output.</p>
88+
<p>via: <a href="https://stackoverflow.com/a/14493981">https://stackoverflow.com/a/14493981</a></p></div>
89+
</dd>
90+
</dl>
91+
</section>
92+
<section>
93+
</section>
94+
</article>
95+
<nav id="sidebar">
96+
<div class="toc">
97+
<ul></ul>
98+
</div>
99+
<ul id="index">
100+
<li><h3>Super-module</h3>
101+
<ul>
102+
<li><code><a title="src.jsonid" href="index.html">src.jsonid</a></code></li>
103+
</ul>
104+
</li>
105+
<li><h3><a href="#header-functions">Functions</a></h3>
106+
<ul class="">
107+
<li><code><a title="src.jsonid.export_helpers.get_utc_timestamp_now" href="#src.jsonid.export_helpers.get_utc_timestamp_now">get_utc_timestamp_now</a></code></li>
108+
<li><code><a title="src.jsonid.export_helpers.new_prettify" href="#src.jsonid.export_helpers.new_prettify">new_prettify</a></code></li>
109+
</ul>
110+
</li>
111+
</ul>
112+
</nav>
113+
</main>
114+
<footer id="footer">
115+
<p>Generated by <a href="https://pdoc3.github.io/pdoc" title="pdoc: Python API documentation generator"><cite>pdoc</cite> 0.11.6</a>.</p>
116+
</footer>
117+
</body>
118+
</html>

docs/jsonid/helpers.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -273,19 +273,19 @@ <h2 class="section-title" id="header-functions">Functions</h2>
273273
# pylint: disable=R0911
274274

275275
if replace_me.__name__ == &#34;dict&#34;:
276-
return &#34;map&#34;
276+
return TYPE_MAP
277277
if replace_me.__name__ == &#34;int&#34;:
278-
return &#34;integer&#34;
278+
return TYPE_INTEGER
279279
if replace_me.__name__ == &#34;list&#34;:
280-
return &#34;list&#34;
280+
return TYPE_LIST
281281
if replace_me.__name__ == &#34;str&#34;:
282-
return &#34;string&#34;
282+
return TYPE_STRING
283283
if replace_me.__name__ == &#34;float&#34;:
284-
return &#34;float&#34;
284+
return TYPE_FLOAT
285285
if replace_me.__name__ == &#34;bool&#34;:
286-
return &#34;bool&#34;
286+
return TYPE_BOOL
287287
if replace_me.__name__ == &#34;NoneType&#34;:
288-
return &#34;NoneType&#34;
288+
return TYPE_NONE
289289
if not isinstance(replace_me, type):
290290
pass
291291
return replace_me</code></pre>

docs/jsonid/index.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ <h2 class="section-title" id="header-submodules">Sub-modules</h2>
5656
<dd>
5757
<div class="desc"><p>Functions to support export.</p></div>
5858
</dd>
59+
<dt><code class="name"><a title="src.jsonid.export_helpers" href="export_helpers.html">src.jsonid.export_helpers</a></code></dt>
60+
<dd>
61+
<div class="desc"><p>Helpers for the export functions.</p></div>
62+
</dd>
5963
<dt><code class="name"><a title="src.jsonid.file_processing" href="file_processing.html">src.jsonid.file_processing</a></code></dt>
6064
<dd>
6165
<div class="desc"><p>File processing functions.</p></div>
@@ -80,6 +84,10 @@ <h2 class="section-title" id="header-submodules">Sub-modules</h2>
8084
<dd>
8185
<div class="desc"><p>Functions for output of results.</p></div>
8286
</dd>
87+
<dt><code class="name"><a title="src.jsonid.pronom" href="pronom.html">src.jsonid.pronom</a></code></dt>
88+
<dd>
89+
<div class="desc"><p>PRONOM export routines …</p></div>
90+
</dd>
8391
<dt><code class="name"><a title="src.jsonid.registry" href="registry.html">src.jsonid.registry</a></code></dt>
8492
<dd>
8593
<div class="desc"><p>JSON registry processor.</p></div>
@@ -125,12 +133,14 @@ <h2 class="section-title" id="header-submodules">Sub-modules</h2>
125133
<li><code><a title="src.jsonid.base_obj_presets" href="base_obj_presets.html">src.jsonid.base_obj_presets</a></code></li>
126134
<li><code><a title="src.jsonid.compressionlib" href="compressionlib.html">src.jsonid.compressionlib</a></code></li>
127135
<li><code><a title="src.jsonid.export" href="export.html">src.jsonid.export</a></code></li>
136+
<li><code><a title="src.jsonid.export_helpers" href="export_helpers.html">src.jsonid.export_helpers</a></code></li>
128137
<li><code><a title="src.jsonid.file_processing" href="file_processing.html">src.jsonid.file_processing</a></code></li>
129138
<li><code><a title="src.jsonid.helpers" href="helpers.html">src.jsonid.helpers</a></code></li>
130139
<li><code><a title="src.jsonid.htm_template" href="htm_template.html">src.jsonid.htm_template</a></code></li>
131140
<li><code><a title="src.jsonid.jsonid" href="jsonid.html">src.jsonid.jsonid</a></code></li>
132141
<li><code><a title="src.jsonid.lookup" href="lookup.html">src.jsonid.lookup</a></code></li>
133142
<li><code><a title="src.jsonid.output" href="output.html">src.jsonid.output</a></code></li>
143+
<li><code><a title="src.jsonid.pronom" href="pronom.html">src.jsonid.pronom</a></code></li>
134144
<li><code><a title="src.jsonid.registry" href="registry.html">src.jsonid.registry</a></code></li>
135145
<li><code><a title="src.jsonid.registry_class" href="registry_class.html">src.jsonid.registry_class</a></code></li>
136146
<li><code><a title="src.jsonid.registry_data" href="registry_data.html">src.jsonid.registry_data</a></code></li>

0 commit comments

Comments
 (0)