Browse Source

Remove openstack-jsoncheck and openstack-indexpage

These are not used anymore, remove them.

Change-Id: Ib4f8c25bc0bbd8227d21e055f07411926577714b
changes/77/676977/1
Andreas Jaeger 1 month ago
parent
commit
e8fee612e6
3 changed files with 0 additions and 259 deletions
  1. 0
    92
      os_doc_tools/index.py
  2. 0
    162
      os_doc_tools/jsoncheck.py
  3. 0
    5
      setup.cfg

+ 0
- 92
os_doc_tools/index.py View File

@@ -1,92 +0,0 @@
1
-#!/usr/bin/env python
2
-
3
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
4
-# not use this file except in compliance with the License. You may obtain
5
-# a copy of the License at
6
-#
7
-#      http://www.apache.org/licenses/LICENSE-2.0
8
-#
9
-# Unless required by applicable law or agreed to in writing, software
10
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
-# License for the specific language governing permissions and limitations
13
-# under the License.
14
-
15
-import argparse
16
-import glob
17
-import os
18
-import sys
19
-
20
-
21
-def get_pdf_link(root, publish_path):
22
-    p = '%s/*.pdf' % root
23
-    re = glob.glob(p)
24
-    if len(re) == 0:
25
-        return ''
26
-    filename = os.path.basename(re[0])
27
-    path = os.path.relpath(root, publish_path)
28
-    return ' <a href="%s/%s">(pdf)</a>' % (path, filename)
29
-
30
-
31
-def generate_index_file(publish_path):
32
-    """Generate index.html file in publish_path."""
33
-
34
-    if not os.path.isdir(publish_path):
35
-        os.mkdir(publish_path)
36
-
37
-    index_file = open(os.path.join(publish_path, 'index.html'), 'w')
38
-
39
-    index_file.write(
40
-        '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"\n'
41
-        '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n'
42
-        '<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">\n'
43
-        '<body>\n'
44
-        '<h1>Generated documents</h1>\n')
45
-
46
-    links = {}
47
-    for root, dirs, files in os.walk(publish_path):
48
-
49
-        dirs[:] = [d for d in dirs if d not in ['common', 'webapp', 'content',
50
-                                                'www', 'samples']]
51
-
52
-        # Ignore top-level index.html files
53
-        if root == publish_path:
54
-            continue
55
-
56
-        pdf_link = get_pdf_link(root, publish_path)
57
-
58
-        if os.path.isfile(os.path.join(root, 'index.html')):
59
-            path = os.path.relpath(root, publish_path)
60
-            links[path] = ('<a href="%s/index.html">%s</a>%s\n' %
61
-                           (path, path.replace('draft/', ''), pdf_link))
62
-
63
-    for entry in sorted([s for s in links if not s.startswith('draft/')]):
64
-        index_file.write(links[entry])
65
-        index_file.write('<br/>\n')
66
-
67
-    drafts = [s for s in links if s.startswith('draft/')]
68
-    if drafts:
69
-        index_file.write('<h2>Draft guides</h2>\n')
70
-    for entry in sorted(drafts):
71
-        index_file.write(links[entry])
72
-        index_file.write('<br/>\n')
73
-
74
-    if os.path.isfile(os.path.join(publish_path, 'www-index.html')):
75
-        index_file.write('<h2>WWW index pages</h2>\n')
76
-        index_file.write('<a href="www-index.html">List of generated '
77
-                         'WWW pages</a>\n')
78
-    index_file.write('</body>\n'
79
-                     '</html>\n')
80
-    index_file.close()
81
-
82
-
83
-def main():
84
-    parser = argparse.ArgumentParser(description="Generate index file.")
85
-    parser.add_argument('directory', metavar='DIR',
86
-                        help="Directory to search.")
87
-    args = parser.parse_args()
88
-
89
-    generate_index_file(args.directory)
90
-
91
-if __name__ == "__main__":
92
-    sys.exit(main())

+ 0
- 162
os_doc_tools/jsoncheck.py View File

@@ -1,162 +0,0 @@
1
-#!/usr/bin/env python
2
-
3
-#    Licensed under the Apache License, Version 2.0 (the "License"); you may
4
-#    not use this file except in compliance with the License. You may obtain
5
-#    a copy of the License at
6
-#
7
-#         http://www.apache.org/licenses/LICENSE-2.0
8
-#
9
-#    Unless required by applicable law or agreed to in writing, software
10
-#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
-#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
-#    License for the specific language governing permissions and limitations
13
-#    under the License.
14
-
15
-"""
16
-
17
-Usage:
18
-    jsoncheck.py [-f] FILES
19
-
20
-Checks JSON syntax and optionally reformats (pretty-prints) the valid files.
21
-
22
-Optional:
23
-    - demjson Python library (better diagnostics for invalid JSON synax)
24
-
25
-"""
26
-
27
-from __future__ import print_function
28
-
29
-import argparse
30
-import collections
31
-import json
32
-import sys
33
-import textwrap
34
-
35
-try:
36
-    import demjson
37
-except ImportError:
38
-    demjson = None
39
-    sys.stderr.write("Cannot import the demjson Python module. Diagnostics "
40
-                     "for invalid JSON files\nwill be limited.\n")
41
-
42
-# -----------------------------------------------------------------------------
43
-# Public interface
44
-# -----------------------------------------------------------------------------
45
-
46
-
47
-def check_syntax(path):
48
-    """Check syntax of one JSON file."""
49
-    _process_file(path)
50
-
51
-
52
-def check_formatting(path):
53
-    """Check formatting of one JSON file."""
54
-    _process_file(path, formatting='check')
55
-
56
-
57
-def fix_formatting(path, verbose=False):
58
-    """Fix formatting of one JSON file."""
59
-    _process_file(path, formatting='fix', verbose=verbose)
60
-
61
-# -----------------------------------------------------------------------------
62
-# Implementation details
63
-# -----------------------------------------------------------------------------
64
-
65
-
66
-def _indent_note(note):
67
-    """Indents and wraps a string."""
68
-    indented_note = []
69
-    # Split into single lines in case the argument is pre-formatted.
70
-    for line in note.splitlines():
71
-        indented_note.append(textwrap.fill(line, initial_indent=4 * ' ',
72
-                             subsequent_indent=12 * ' ',
73
-                             width=80))
74
-    return "\n".join(indented_note)
75
-
76
-
77
-def _get_demjson_diagnostics(raw):
78
-    """Get diagnostics string for invalid JSON files from demjson."""
79
-    errstr = None
80
-    try:
81
-        demjson.decode(raw, strict=True)
82
-    except demjson.JSONError as err:
83
-        errstr = err.pretty_description()
84
-    return errstr
85
-
86
-
87
-class ParserException(Exception):
88
-    pass
89
-
90
-
91
-def _parse_json(raw):
92
-    """Parse raw JSON file."""
93
-    try:
94
-        parsed = json.loads(raw, object_pairs_hook=collections.OrderedDict)
95
-    except ValueError as err:
96
-        note = str(err)
97
-        # if demjson is available, print its diagnostic string as well
98
-        if demjson:
99
-            demerr = _get_demjson_diagnostics(raw)
100
-            if demerr:
101
-                note += "\n" + demerr
102
-        raise ParserException(note)
103
-    else:
104
-        return parsed
105
-
106
-
107
-def _format_parsed_json(parsed):
108
-    """Pretty-print JSON file content while retaining key order."""
109
-    return json.dumps(parsed, sort_keys=False, separators=(',', ': '),
110
-                      indent=4) + "\n"
111
-
112
-
113
-def _process_file(path, formatting=None, verbose=False):
114
-    """Check syntax/formatting and fix formatting of a JSON file.
115
-
116
-    :param formatting: one of 'check' or 'fix' (default: None)
117
-
118
-    Raises ValueError if JSON syntax is invalid or reformatting needed.
119
-    """
120
-    with open(path, 'r') as infile:
121
-        raw = infile.read()
122
-        try:
123
-            parsed = _parse_json(raw)
124
-        except ParserException as err:
125
-            raise ValueError(err)
126
-        else:
127
-            if formatting in ('check', 'fix'):
128
-                formatted = _format_parsed_json(parsed)
129
-                if formatted != raw:
130
-                    if formatting == "fix":
131
-                        with open(path, 'w') as outfile:
132
-                            outfile.write(formatted)
133
-                        if verbose:
134
-                            print("%s\n%s" % (path,
135
-                                              _indent_note("Reformatted")))
136
-                    else:
137
-                        raise ValueError("Reformatting needed")
138
-            elif formatting is not None:
139
-                # for the benefit of external callers
140
-                raise ValueError("Called with invalid formatting value.")
141
-
142
-
143
-def main():
144
-    parser = argparse.ArgumentParser(description="Validate and reformat JSON"
145
-                                     "files.")
146
-    parser.add_argument('files', metavar='FILES', nargs='+')
147
-    parser.add_argument('-f', '--formatting', choices=['check', 'fix'],
148
-                        help='check or fix formatting of JSON files')
149
-    args = parser.parse_args()
150
-
151
-    exit_status = 0
152
-    for path in args.files:
153
-        try:
154
-            _process_file(path, args.formatting, verbose=True)
155
-        except ValueError as err:
156
-            print("%s\n%s" % (path, _indent_note(str(err))))
157
-            exit_status = 1
158
-
159
-    return exit_status
160
-
161
-if __name__ == "__main__":
162
-    sys.exit(main())

+ 0
- 5
setup.cfg View File

@@ -32,10 +32,5 @@ scripts =
32 32
 setup-hooks =
33 33
     pbr.hooks.setup_hook
34 34
 
35
-[entry_points]
36
-console_scripts =
37
-     openstack-jsoncheck = os_doc_tools.jsoncheck:main
38
-     openstack-indexpage = os_doc_tools.index:main
39
-
40 35
 [wheel]
41 36
 universal = 1

Loading…
Cancel
Save