Permalink
Browse files

Convert to four-space tabs

  • Loading branch information...
1 parent 265548d commit d1c7e54722249be49a722d9a92652a87d72a842e @jreese jreese committed Oct 13, 2011
Showing with 171 additions and 171 deletions.
  1. +97 −97 docbook-manual-repo.py
  2. +74 −74 docbook-manual.py
View
@@ -14,17 +14,17 @@
# Regular expressions of refs to ignore
ignorelist = map(re.compile, [
- 'HEAD',
- '-1\.0\.[\w\d]+',
- '-1\.1\.[\w\d]+'
- ])
+ 'HEAD',
+ '-1\.0\.[\w\d]+',
+ '-1\.1\.[\w\d]+'
+ ])
# Script options
options = "hfda"
long_options = [ "help", "force", "delete", "all", "pdf", "html", "release" ]
def usage():
- print '''Usage: docbook-manual-repo /path/to/mantisbt/repo /path/to/install [<lang> ...]
+ print '''Usage: docbook-manual-repo /path/to/mantisbt/repo /path/to/install [<lang> ...]
Options: -h | --help Print this usage message
-f | --force Ignore timestamps and force building
-d | --delete Delete install directories before building
@@ -35,101 +35,101 @@ def usage():
#end usage()
def ignore( ref ):
- '''Decide which refs to ignore based on regexen listed in 'ignorelist'.
- '''
-
- ignore = False
- for regex in ignorelist:
- if len(regex.findall(ref)) > 0:
- ignore = True
- return ignore
+ '''Decide which refs to ignore based on regexen listed in 'ignorelist'.
+ '''
+
+ ignore = False
+ for regex in ignorelist:
+ if len(regex.findall(ref)) > 0:
+ ignore = True
+ return ignore
#end ignore()
def main():
- try:
- opts, args = getopt.gnu_getopt(sys.argv[1:], options, long_options)
- except getopt.GetoptError, err:
- print str(err)
- usage()
- sys.exit(2)
-
- force = False
- pass_opts = ""
-
- for opt, val in opts:
- if opt in ("-h", "--help"):
- usage()
- sys.exit(0)
-
- elif opt in ("-f", "--force"):
- force = True
-
- elif opt in ("-d", "--delete"):
- pass_opts += " -d"
-
- elif opt in ("-a", "--all"):
- pass_opts += " -a"
-
- elif opt == "--html":
- pass_opts += " --html"
-
- elif opt == "--pdf":
- pass_opts += " --pdf"
-
- elif opt == "--release":
- pass_opst += " --release"
-
- if len(args) < 2:
- usage()
- sys.exit(1)
-
- repo = args[0]
- installroot = args[1]
- languages = []
-
- if len(sys.argv) > 2:
- languages = args[2:]
-
- # Update repo from default remote
- os.chdir(repo)
- os.system('git fetch')
- os.system('git remote prune origin')
-
- # List refs from remote branches and tags
- branches = os.popen('git branch -r').read().split()
- tags = os.popen('git tag -l').read().split()
-
- # Filter refs using ignore()
- refs = [ref for ref in branches + tags if not ignore(ref)]
-
- # Regex to strip 'origin/' from ref names
- refnameregex = re.compile('(?:[a-zA-Z0-9-.]+/)?(.*)')
-
- # For each ref, checkout and call docbook-manual.py, tracking last build timestamp
- # to prevent building a manual if there have been no commits since last build
- for ref in refs:
- manualpath = installroot.rstrip('/') + '/' + refnameregex.search( ref ).group(1)
-
- os.system('git checkout -f %s'%(ref))
- lastchange = os.popen('git log --pretty="format:%ct" -n1').read()
-
- buildfile = path.join(manualpath, '.build')
- lastbuild = 0
- if path.exists(buildfile):
- f = open(buildfile, 'r')
- lastbuild = f.read()
- f.close()
-
- if lastchange > lastbuild or force:
- buildcommand = '%s %s %s %s %s'%(manualscript, pass_opts, path.abspath('docbook'), manualpath, ' '.join(languages))
- print "Calling: " + buildcommand
- if(os.system(buildcommand)):
- print 'here'
-
- f = open(buildfile, 'w')
- f.write(lastchange)
- f.close()
+ try:
+ opts, args = getopt.gnu_getopt(sys.argv[1:], options, long_options)
+ except getopt.GetoptError, err:
+ print str(err)
+ usage()
+ sys.exit(2)
+
+ force = False
+ pass_opts = ""
+
+ for opt, val in opts:
+ if opt in ("-h", "--help"):
+ usage()
+ sys.exit(0)
+
+ elif opt in ("-f", "--force"):
+ force = True
+
+ elif opt in ("-d", "--delete"):
+ pass_opts += " -d"
+
+ elif opt in ("-a", "--all"):
+ pass_opts += " -a"
+
+ elif opt == "--html":
+ pass_opts += " --html"
+
+ elif opt == "--pdf":
+ pass_opts += " --pdf"
+
+ elif opt == "--release":
+ pass_opst += " --release"
+
+ if len(args) < 2:
+ usage()
+ sys.exit(1)
+
+ repo = args[0]
+ installroot = args[1]
+ languages = []
+
+ if len(sys.argv) > 2:
+ languages = args[2:]
+
+ # Update repo from default remote
+ os.chdir(repo)
+ os.system('git fetch')
+ os.system('git remote prune origin')
+
+ # List refs from remote branches and tags
+ branches = os.popen('git branch -r').read().split()
+ tags = os.popen('git tag -l').read().split()
+
+ # Filter refs using ignore()
+ refs = [ref for ref in branches + tags if not ignore(ref)]
+
+ # Regex to strip 'origin/' from ref names
+ refnameregex = re.compile('(?:[a-zA-Z0-9-.]+/)?(.*)')
+
+ # For each ref, checkout and call docbook-manual.py, tracking last build timestamp
+ # to prevent building a manual if there have been no commits since last build
+ for ref in refs:
+ manualpath = installroot.rstrip('/') + '/' + refnameregex.search( ref ).group(1)
+
+ os.system('git checkout -f %s'%(ref))
+ lastchange = os.popen('git log --pretty="format:%ct" -n1').read()
+
+ buildfile = path.join(manualpath, '.build')
+ lastbuild = 0
+ if path.exists(buildfile):
+ f = open(buildfile, 'r')
+ lastbuild = f.read()
+ f.close()
+
+ if lastchange > lastbuild or force:
+ buildcommand = '%s %s %s %s %s'%(manualscript, pass_opts, path.abspath('docbook'), manualpath, ' '.join(languages))
+ print "Calling: " + buildcommand
+ if(os.system(buildcommand)):
+ print 'here'
+
+ f = open(buildfile, 'w')
+ f.write(lastchange)
+ f.close()
#end main
if __name__ == '__main__':
- main()
+ main()
View
@@ -10,88 +10,88 @@
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
+ -d | --delete Delete install directory before building
--html Build HTML manual
--pdf Build PDF manual
--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)
- except getopt.GetoptError, err:
- print str(err)
- usage()
- sys.exit(2)
-
- delete = False
- types = "html pdf"
-
- for opt, val in opts:
- if opt in ("-h", "--help"):
- usage()
- sys.exit(0)
-
- elif opt in ("-d", "--delete"):
- delete = True
-
- elif opt in ("-a", "--all"):
- types = "html html_onefile html.tar.gz text pdf ps"
-
- elif opt == "--html":
- types = "html html_onefile html.tar.gz"
-
- elif opt == "--pdf":
- types = "pdf"
-
- elif opt == "--release":
- types = "html_onefile pdf text"
-
- if len(args) < 2:
- usage()
- sys.exit(1)
-
- docroot = args[0]
- installroot = args[1]
- languages = []
-
- if len(sys.argv) > 2:
- languages = args[2:]
-
- os.chdir( docroot )
-
- if delete and installroot != "/" and path.isdir( installroot ):
- print "Deleting install directory " + installroot
- for root, dirs, files in os.walk( installroot, topdown=False ):
- for name in files:
- os.remove( path.join( root, name ) )
- for name in dirs:
- os.rmdir( path.join( root, name ) )
-
- for dir in os.listdir( docroot ):
- if dir == '.svn' or dir == 'template':
- continue
-
- if len(languages) > 0:
- langs = languages
- else:
- langs = os.listdir( path.join( docroot, dir ) )
- if langs.count('.svn'):
- langs.remove('.svn')
-
- for lang in langs:
- builddir = path.join( docroot, dir, lang )
- installdir = path.join( installroot, lang )
-
- if path.isdir( builddir ):
- print "Building manual in " + builddir
- os.chdir( builddir )
- os.system( 'make clean %s 2>&1 && make INSTALL_DIR=%s install 2>&1'%(types, installdir) )
- os.system( 'make clean 2>&1' )
+ try:
+ opts, args = getopt.gnu_getopt(sys.argv[1:], options, long_options)
+ except getopt.GetoptError, err:
+ print str(err)
+ usage()
+ sys.exit(2)
+
+ delete = False
+ types = "html pdf"
+
+ for opt, val in opts:
+ if opt in ("-h", "--help"):
+ usage()
+ sys.exit(0)
+
+ elif opt in ("-d", "--delete"):
+ delete = True
+
+ elif opt in ("-a", "--all"):
+ types = "html html_onefile html.tar.gz text pdf ps"
+
+ elif opt == "--html":
+ types = "html html_onefile html.tar.gz"
+
+ elif opt == "--pdf":
+ types = "pdf"
+
+ elif opt == "--release":
+ types = "html_onefile pdf text"
+
+ if len(args) < 2:
+ usage()
+ sys.exit(1)
+
+ docroot = args[0]
+ installroot = args[1]
+ languages = []
+
+ if len(sys.argv) > 2:
+ languages = args[2:]
+
+ os.chdir( docroot )
+
+ if delete and installroot != "/" and path.isdir( installroot ):
+ print "Deleting install directory " + installroot
+ for root, dirs, files in os.walk( installroot, topdown=False ):
+ for name in files:
+ os.remove( path.join( root, name ) )
+ for name in dirs:
+ os.rmdir( path.join( root, name ) )
+
+ for dir in os.listdir( docroot ):
+ if dir == '.svn' or dir == 'template':
+ continue
+
+ if len(languages) > 0:
+ langs = languages
+ else:
+ langs = os.listdir( path.join( docroot, dir ) )
+ if langs.count('.svn'):
+ langs.remove('.svn')
+
+ for lang in langs:
+ builddir = path.join( docroot, dir, lang )
+ installdir = path.join( installroot, lang )
+
+ if path.isdir( builddir ):
+ print "Building manual in " + builddir
+ os.chdir( builddir )
+ os.system( 'make clean %s 2>&1 && make INSTALL_DIR=%s install 2>&1'%(types, installdir) )
+ os.system( 'make clean 2>&1' )
#end main
if __name__ == '__main__':
- main()
+ main()

0 comments on commit d1c7e54

Please sign in to comment.