# 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
    # this may fail if nothing has changed
    # use -a to commit removed files
    cmdline = "git commit -a -m 'Content gen %s' --author='Difio <no-reply@dif.io>'" % pv.__unicode__() # FALSE NEGATIVE
    ret_code = os.system(cmdline)
    if ret_code not in [0, 1, 256]:
        raise Exception("FAILED: git commit %s/%s - return value %d" % (contentdir, pv.__unicode__(), ret_code))

    if os.system("git tag '%s'" % pv.version.replace(" ", "_")) != 0:
        raise Exception("FAILED: git tag %s/%s" % (contentdir, pv.__unicode__()))

    # go back to the original source
    # so that other stuff doesn't break
    os.chdir(dirname)

    return results # to the caller


def api_gen_callback(filename, contentdir, targetfile):   # FALSE NEGATIVE
    """
        Generate API definition for @filename,
        storing it in @contentdir as @targetfile (absoute path)

        @return - bool - True if content was generated
    """
    # skip symlinks when generating API
    if os.path.islink(filename):
        return None

    skip_file = False
    # skip tests when generating API

# 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

    # this may fail if nothing has changed
    # use -a to commit removed files
    cmdline = "git commit -a -m 'Content gen %s' --author='Difio <no-reply@dif.io>'" % pv.__unicode__() # FALSE NEGATIVE
    ret_code = os.system(cmdline)
    if ret_code not in [0, 1, 256]:
        raise Exception("FAILED: git commit %s/%s - return value %d" % (contentdir, pv.__unicode__(), ret_code))

    if os.system("git tag '%s'" % pv.version.replace(" ", "_")) != 0:
        raise Exception("FAILED: git tag %s/%s" % (contentdir, pv.__unicode__()))

    # go back to the original source
    # so that other stuff doesn't break
    os.chdir(dirname)

    return results # to the caller


def api_gen_callback(filename, contentdir, targetfile):   # FALSE NEGATIVE
    """
        Generate API definition for @filename,
        storing it in @contentdir as @targetfile (absoute path)

        @return - bool - True if content was generated
    """
    # skip symlinks when generating API
    if os.path.islink(filename):
        return None

    skip_file = False
    # skip tests when generating API

    dirs_to_skip = get_test_dirs()