<commit_before>#!/usr/bin/python2

from __future__ import division

from configobj import ConfigObj
from validate import Validator

from gtk import gdk

# We use PIL for simple tasks and ImageMagick for computationally-heavy tasks
from PIL import Image

import subprocess

import time

import sys

import os

import argparse

# Make sure ImageMagick is installed
subprocess.check_call('which convert > /dev/null', shell = True)

dir = os.path.dirname(os.path.realpath(__file__))
cwd = os.getcwd()

parser = argparse.ArgumentParser(description = 'Take a perdy screenshot.')

parser.add_argument('-f', '--file', help = 'the name of the output file', default = 'screenshot.png')
parser.add_argument('--delay', help = 'the delay in seconds before capturing the active window', default = 1, type = float)

args = vars(parser.parse_args())

config = ConfigObj(dir + '/perdyshot.conf', encoding = 'UTF8', configspec = dir + '/perdyshot.conf.spec')
validator = Validator()
if not config.validate(validator):
    print "Invalid configuration file"
    sys.exit(1)



print "Please select the window to be captured\n"
time.sleep(args['delay'])

startTime = time.time()

# https://gist.github.com/mozbugbox/10cd35b2872628246140
def pixbuf2image(pix):<commit_msg>Added versioning support and improved command-line option help<commit_after>#!/usr/bin/python2

from __future__ import division

from configobj import ConfigObj
from validate import Validator

from gtk import gdk

# We use PIL for simple tasks and ImageMagick for computationally-heavy tasks
from PIL import Image

import subprocess

import time

import sys

import os

import argparse


version = 'Perdyshot v0.5'




# Make sure ImageMagick is installed
subprocess.check_call('which convert > /dev/null', shell = True)

dir = os.path.dirname(os.path.realpath(__file__))
cwd = os.getcwd()

parser = argparse.ArgumentParser(description = 'Take a perdy screenshot.')

parser.add_argument('--delay', help = 'the delay in seconds before capturing the active window (default: 1)', default = 1, type = float)
parser.add_argument('-f', '--file', help = 'the name of the output file (default: screenshot.png)', default = 'screenshot.png')
parser.add_argument('-v', '--version', action = 'version', version = version)

args = vars(parser.parse_args())

config = ConfigObj(dir + '/perdyshot.conf', encoding = 'UTF8', configspec = dir + '/perdyshot.conf.spec')
validator = Validator()
if not config.validate(validator):
    print "Invalid configuration file"
    sys.exit(1)



print "Please select the window to be captured\n"
time.sleep(args['delay'])

startTime = time.time()

# https://gist.github.com/mozbugbox/10cd35b2872628246140
def pixbuf2image(pix):
{'fraction_non_alphanumeric': 0.11444444444444445, 'fraction_numerical': 0.017407407407407406, 'mean_word_length': 4.923245614035087, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5765194', 'n_tokens_mistral': 867, 'n_tokens_neox': 831, 'n_words': 263}