# Path: utils.py
# def files_in_dir(dirname):
#     """
#         Walk all files in @dirname and return the filenames.
# 
#         todo: optimize walking all files
#     """
#     dirfiles = []
# 
#     for (path, dirs, files) in os.walk(dirname):
#         for f in files:
#             fname = os.path.join(path, f)
#             dirfiles.append(fname)
# 
#     return dirfiles
# 
# Path: utils.py
# def get_test_dirs():
#     """
#         Return a list of directories commonly used for tests.
# 
#         Some operations, like API diff will skip such directories.
#     """
#     return [
#             'SelfTest/', # pycrypto
#             'test/',
#             'tests/',
#             't/',
#             'testing/',
#             'test_utils/',
#             'tests_utils/',
#             'testsuite/',
#             'tests.py',
#             'test.py',
#             'test_regex.py' # Pythoin regex module
#             ]


import os
import shutil
import filters
from utils import files_in_dir
from utils import get_test_dirs
from pygments import highlight
from pygments import lexers
from pygments.formatters import NullFormatter
    if os.system('git tag | grep "^%s$"' % version) == 0: # tag already exists
        return [] # we have no idea if content was generated in the previous run
                    # so return []

    # remove all content files from previous tag.
    # we're doing this because tags are not imported in sequence.
    for p in os.listdir(contentdir):
        if p == ".git": # skip git directory
            continue

        if os.path.isfile(p):
            os.remove(p)

        if os.path.isdir(p):
            shutil.rmtree(p, True) # ignore errors


    os.chdir(dirname)
    # MAKE SURE we're working on the tag for this version
    if os.system('git checkout "%s"' % pv.version.replace(" ", "_")) != 0:
        raise Exception("FAILED: git checkout - tag doesn't exist")


    # walk all files and generate the content
    l = len(dirname)+1

    # create empty .gitignore so we can commit
    f = open(os.path.join(contentdir, ".gitignore"), 'w')
    f.close()


# Path: utils.py
# def files_in_dir(dirname):
#     """
#         Walk all files in @dirname and return the filenames.
# 
#         todo: optimize walking all files
#     """
#     dirfiles = []
# 
#     for (path, dirs, files) in os.walk(dirname):
#         for f in files:
#             fname = os.path.join(path, f)
#             dirfiles.append(fname)
# 
#     return dirfiles
# 
# Path: utils.py
# def get_test_dirs():
#     """
#         Return a list of directories commonly used for tests.
# 
#         Some operations, like API diff will skip such directories.
#     """
#     return [
#             'SelfTest/', # pycrypto
#             'test/',
#             'tests/',
#             't/',
#             'testing/',
#             'test_utils/',
#             'tests_utils/',
#             'testsuite/',
#             'tests.py',
#             'test.py',
#             'test_regex.py' # Pythoin regex module
#             ]


# Path: api.py
import os
import shutil
import filters
from utils import files_in_dir
from utils import get_test_dirs
from pygments import highlight
from pygments import lexers
from pygments.formatters import NullFormatter

    if os.system('git tag | grep "^%s$"' % version) == 0: # tag already exists
        return [] # we have no idea if content was generated in the previous run
                    # so return []

    # remove all content files from previous tag.
    # we're doing this because tags are not imported in sequence.
    for p in os.listdir(contentdir):
        if p == ".git": # skip git directory
            continue

        if os.path.isfile(p):
            os.remove(p)

        if os.path.isdir(p):
            shutil.rmtree(p, True) # ignore errors


    os.chdir(dirname)
    # MAKE SURE we're working on the tag for this version
    if os.system('git checkout "%s"' % pv.version.replace(" ", "_")) != 0:
        raise Exception("FAILED: git checkout - tag doesn't exist")


    # walk all files and generate the content
    l = len(dirname)+1

    # create empty .gitignore so we can commit
    f = open(os.path.join(contentdir, ".gitignore"), 'w')
    f.close()


    for filename in files_in_dir(dirname):