/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to tools/package_docs.py

  • Committer: Ian Clatworthy
  • Date: 2009-09-09 00:31:53 UTC
  • mto: (4634.37.2 prepare-2.0)
  • mto: This revision was merged to the branch mainline in revision 4689.
  • Revision ID: ian.clatworthy@canonical.com-20090909003153-xjuneaqavuqqpuvi
package html into bundles

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
import os
20
20
import sys
 
21
import tarfile
21
22
from optparse import OptionParser
22
23
from shutil import copy2, copytree, rmtree
23
24
 
39
40
        rmtree(dest_html)
40
41
    copytree(src_html, dest_html)
41
42
 
42
 
    # TODO: package the html as a downloadable archive
 
43
    # Package the html as a downloadable archive
 
44
    archive_root = "bzr-%s-html" % (section,)
 
45
    archive_basename = "%s.tar.bz2" % (archive_root,)
 
46
    archive_name = os.path.join(dest_downloads, archive_basename)
 
47
    build_archive(src_html, archive_name, archive_root, 'bz2')
43
48
 
44
 
    # TODO: copy across the PDF docs, if any, including the quick ref card
 
49
    # Copy across the PDF docs, if any, including the quick ref card
45
50
    pdf_files = []
46
51
    quick_ref = os.path.join(src_html,
47
52
        '_static/%s/bzr-quick-reference.pdf' % (section,))
62
67
    # TODO: copy across the CHM files, if any
63
68
 
64
69
 
 
70
def build_archive(src_dir, archive_name, archive_root, format):
 
71
    print "creating %s ..." % (archive_name,)
 
72
    tar = tarfile.open(archive_name, "w:%s" % (format,))
 
73
    for relpath in os.listdir(src_dir):
 
74
        src_path = os.path.join(src_dir, relpath)
 
75
        archive_path = os.path.join(archive_root, relpath)
 
76
        tar.add(src_path, arcname=archive_path)
 
77
    tar.close()
 
78
 
 
79
 
65
80
def main(argv):
66
81
    # Check usage. The first argument is the parent directory of
67
82
    # the Sphinx _build directory. It will typically be 'doc/xx'.