Tools used by OpenStack Documentation
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
2.1 KiB

## copyright: B1 Systems GmbH <>, 2013.
## author: Christian Berendt <>, 2013.
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# Call ./tools/cleanup/ in the
# root of openstack-manuals.
import os
import re
import shutil
import tempfile
# should be the same like in tools/
FILE_EXCEPTIONS = ['ha-guide-docinfo.xml',
elements = [
checks = []
for element in elements:
% element)),
% element))
for root, dirs, files in os.walk('doc/'):
for f in files:
if (not (f.endswith('.xml') and
f != 'pom.xml' and
docfile = os.path.abspath(os.path.join(root, f))
tmpfile = tempfile.mkstemp()
tmpfd = os.fdopen(tmpfile[0], "w")
match = False
for line in open(docfile, 'r'):
for check in checks:
if check.match(line):
line = check.sub(r"\1\2", line)
match = True
if match:
shutil.copyfile(tmpfile[1], docfile)