#!/usr/bin/python2

##
# autosign
# https://github.com/leosartaj/autosign.git
# 
# copyright (c) 2014 sartaj singh
# licensed under the mit license.
##

"""
script for running remsign utility of autosign
"""

import os
from autosign import main
from autosign.parse import remsign_options

def format(filename):
    """
    Formats for verbose output
    """
    msg = filename + ' has been un-signed.'
    return msg

def gen_summary(count):
    """
    Generates the stats
    """
    stats = ''
    stats += '\nTotal un-signed Files: ' + str(count)
    return stats

if __name__ == '__main__':
    args = remsign_options.parse_args()

    target= args.target
    if not os.path.exists(target):
        raise IOError('file/dir \'%s\' does not exist.' %(target))

    count = 0
    for filename in main.removeSignFiles(target, args.recursive):
        count += 1
        if args.verbose:
            print format(filename)

    if args.verbose:
        print gen_summary(count)
