Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

docbook-manual.py: follow PEP8 coding guidelines

  • Loading branch information...
commit 45ae8b3605793b1d0f824af1228b60d4e2ee0bf5 1 parent 1f42fb4
@dregad dregad authored
Showing with 39 additions and 24 deletions.
  1. +39 −24 docbook-manual.py
View
63 docbook-manual.py
@@ -1,13 +1,14 @@
#!/usr/bin/env python
-import os, sys
import errno
+import getopt
import glob
+import os
+from os import path
import shutil
import subprocess
-from os import path
+import sys
-import getopt
# Constants
MAKE = 'make'
@@ -15,18 +16,22 @@
# Script options
options = "hda"
-long_options = [ "help", "delete", "all", "pdf", "html", "release" ]
+long_options = ["help", "delete", "all", "pdf", "html", "release"]
+
def usage():
- print '''Usage: docbook-manual /path/to/mantisbt/docbook /path/to/install [<lang> ...]
+ print '''Usage: docbook-manual /path/to/mantisbt/docbook /path/to/install \
+[<lang> ...]
Options: -h | --help Print this usage message
-d | --delete Delete install directory before building
--html Build HTML manual
--pdf Build PDF manual
- --release Build single file types used for release tarballs
+ --release Build single file types used for
+ release tarballs
-a | --all Build all manual types'''
#end usage()
+
def main():
try:
opts, args = getopt.gnu_getopt(sys.argv[1:], options, long_options)
@@ -73,15 +78,15 @@ def main():
if len(sys.argv) > 2:
languages = args[2:]
- os.chdir( docroot )
+ os.chdir(docroot)
- if delete and installroot != "/" and path.isdir( installroot ):
+ if delete and installroot != "/" and path.isdir(installroot):
print "Deleting install directory " + installroot
- for root, dirs, files in os.walk( installroot, topdown=False ):
+ for root, dirs, files in os.walk(installroot, topdown=False):
for name in files:
- os.remove( path.join( root, name ) )
+ os.remove(path.join(root, name))
for name in dirs:
- os.rmdir( path.join( root, name ) )
+ os.rmdir(path.join(root, name))
buildcount = 0
@@ -90,8 +95,8 @@ def main():
if dir == '.svn' or dir == 'template':
continue
- builddir = path.join( docroot, dir )
- os.chdir( builddir )
+ builddir = path.join(docroot, dir)
+ os.chdir(builddir)
# Languages to process
if len(languages) > 0:
@@ -108,7 +113,9 @@ def main():
print "Building manual in '%s'\n" % builddir
os.system('publican clean')
- os.system('publican build --formats=%s --langs=%s' % (types[PUBLICAN], ','.join(langs)))
+ os.system('publican build --formats=%s --langs=%s' % (
+ types[PUBLICAN], ','.join(langs))
+ )
print "\nCopying generated manuals to '%s'" % installroot
for lang in langs:
@@ -124,11 +131,13 @@ def main():
raise
# Copy HTML manuals with rsync
- rsync = "rsync -a --delete %s %s" % (path.join(builddir, 'html*'), installdir)
+ rsync = "rsync -a --delete %s %s" % (
+ path.join(builddir, 'html*'), installdir
+ )
print rsync
- retCode = subprocess.call(rsync, shell=True)
- if retCode != 0:
- log('ERROR: rsync call failed with exit code %i' % retCode)
+ ret = subprocess.call(rsync, shell=True)
+ if ret != 0:
+ print 'ERROR: rsync call failed with exit code %i' % ret
# Copy PDF and TXT files (if built)
for filetype in ['pdf', 'txt']:
@@ -143,19 +152,25 @@ def main():
for lang in langs:
if not path.isdir(path.join(builddir, lang)):
- print "WARNING: Unknown language '%s' in '%s'" % (lang, builddir)
+ print "WARNING: Unknown language '%s' in '%s'" % (
+ lang, builddir
+ )
continue
- builddir = path.join( builddir, lang )
- installdir = path.join( installroot, lang )
- os.chdir( builddir )
+ builddir = path.join(builddir, lang)
+ installdir = path.join(installroot, lang)
+ os.chdir(builddir)
if not path.exists('Makefile'):
continue
print "Building manual in '%s'\n" % builddir
- os.system( 'make clean %s 2>&1 && make INSTALL_DIR=%s install 2>&1'%(types[MAKE], installdir) )
- os.system( 'make clean 2>&1' )
+ os.system(
+ 'make clean %s 2>&1 && '
+ 'make INSTALL_DIR=%s install 2>&1' %
+ (types[MAKE], installdir)
+ )
+ os.system('make clean 2>&1')
print "\nBuild complete\n"
buildcount += 1
Please sign in to comment.
Something went wrong with that request. Please try again.