bundle_docs.py :  » Game-2D-3D » Pygame » pygame-1.9.1release » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Game 2D 3D » Pygame 
Pygame » pygame 1.9.1release » bundle_docs.py
#! /usr/bin/env python

"""Tar-zip the Pygame documents and examples

Run this script from the Pygame source root directory.
"""

import os
import tarfile
import re

def add_files(bundle, root, alias, file_names):
    for file_name in file_names:
        file_alias = os.path.join(alias, file_name)
        print " ", file_name, "-->", file_alias
        bundle.add(os.path.join(root, file_name), file_alias)

def add_directory(bundle, root, alias):
    reject_dirs = re.compile(r'(.svn)$')
    # Since it is the file extension that is of interest the reversed
    # file name is checked.
    reject_files_reversed = re.compile(r'((~.*)|(cyp\..*))')
    for sub_root, directories, files in os.walk(root):
        directories[:] = [d for d in directories if reject_dirs.match(d) is None]
        files[:] = [f for f in files if reject_files_reversed.match(f[-1::-1]) is None]
        sub_alias = os.path.join(alias, sub_root[len(root)+1:])
        add_files(bundle, sub_root, sub_alias, files)
        
def main():
    bundle_name_elements = ['pygame', 'docs']
    setup = open('setup.py', 'r')
    try:
        match = re.search(r'"version":[ \t]+"([0-9]+\.[0-9]+)\.[^"]+"', setup.read())
    finally:
        setup.close()
    if match is None:
        print "*** Unable to find Pygame version in setup.py"
        version = ''
    else:
        version = '-%s' % match.group(1)
    bundle_name = 'pygame%s-docs-and-examples.tar.gz' % version
    print "Creating bundle", bundle_name
    bundle = tarfile.open(bundle_name, 'w:gz')
    try:
        root = os.path.abspath('.')
        alias = 'pygame'
        add_files(bundle, root, alias, ['LGPL', 'readme.html', 'install.html'])
        add_directory(bundle, os.path.join(root, 'docs'), os.path.join(alias, 'docs'))
        add_directory(bundle, os.path.join(root, 'examples'), os.path.join(alias, 'examples'))
        print "\nFinished", bundle_name
    finally:
        bundle.close()

if __name__ == '__main__':
    main()
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.