#!/usr/bin/python
# -*- coding: UTF-8 -*-
#
# Copyright (c) 2007 Tarek Ziadé
#
# Authors:
#   Tarek Ziadé <tarek@ziade.org>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

def main(options_, arguments, parser):
    if options_.rep is not None:
        chemin = options_.rep
    else:
        if len(arguments) > 0:
            print parser.usage
            sys.exit(2)
        chemin = getcwd()

    chemin = path.normpath(chemin)

    if chemin.endswith(path.sep):
        chemin = chemin[:-1]

    for racine, reps, fichiers in walk(chemin):
        for fichier in fichiers:
            if not fichier.endswith('.py'):
                continue
            nom_complet = path.join(racine, fichier)
            checkFile(nom_complet)

if __name__ == '__main__':
    parser = OptionParser()
    for option in options:
        parser.add_option(*param, **option)

    options, arguments = parser.parse_args()
    sys.argv[:] = arguments
    main(options, arguments, parser)
