<commit_before>import ctypes
import ctypes.wintypes
import os

import win32api

from PyQt4 import QtCore, QtGui

import qmk
import utils

class ScreenshotCommand(qmk.Command):
    '''
    Take a screenshot of the current window.
    '''
    def __init__(self):
        self._name = 'screenshot'
        self._help = self.__doc__

        self._gfw = ctypes.windll.user32.GetForegroundWindow
        self._gwr = ctypes.windll.user32.GetWindowRect
        self._gle = ctypes.windll.kernel32.GetLastError

        op = qmk.CommandOptionParser(name = self._name)
        op.add_option('-b', '--bare', dest = 'bare', default = False,
            action = 'store_true', help = 'grab window with titlebar, etc.')
        op.add_option('--clobber', dest = 'clobber', default = False,
            action = 'store_true', help = 'clobber file if it exists')
        op.add_option('-d', '--desktop', dest = 'desktop', default = False,
            action = 'store_true', help = 'grab entire desktop')
        op.add_option('-f', '--filename', dest = 'filename', default = '',
            help = 'name of file to write snapshot to')
        op.add_option('-w', '--wait', dest = 'wait', default = 1,
            action = 'store', type = 'int',
            help = 'number of seconds to wait before screenshot')
        self._optpar = op

    def _indicateError(self, ecode):
        raise RuntimeError(
            'Error: %s' % (win32api.FormatMessage(ecode).strip()))

    @qmk.capture_and_show_exceptions('screenshot')
    def _take_snapshot(self):
        o = self._opts

        if '' == o.filename:
            fn = 'screenshot-%s.png' % utils.dt_str(sep = '')
        elif not o.filename.endswith(('.PNG', '.png')):
            fn = '%s.png' % o.filename
        else:
            fn = o.filename

        afn = os.path.abspath(fn)

        if os.path.exists(fn):
            if os.path.isfile(fn):<commit_msg>Adjust screenshot command to output to QMK base dir.<commit_after>import ctypes
import ctypes.wintypes
import os

import win32api

from PyQt4 import QtCore, QtGui

import qmk
import utils

class ScreenshotCommand(qmk.Command):
    '''
    Take a screenshot of the current window.
    '''
    def __init__(self):
        self._name = 'screenshot'
        self._help = self.__doc__

        self._gfw = ctypes.windll.user32.GetForegroundWindow
        self._gwr = ctypes.windll.user32.GetWindowRect
        self._gle = ctypes.windll.kernel32.GetLastError

        op = qmk.CommandOptionParser(name = self._name)
        op.add_option('-b', '--bare', dest = 'bare', default = False,
            action = 'store_true', help = 'grab window with titlebar, etc.')
        op.add_option('--clobber', dest = 'clobber', default = False,
            action = 'store_true', help = 'clobber file if it exists')
        op.add_option('-d', '--desktop', dest = 'desktop', default = False,
            action = 'store_true', help = 'grab entire desktop')
        op.add_option('-f', '--filename', dest = 'filename', default = '',
            help = 'name of file to write snapshot to')
        op.add_option('-w', '--wait', dest = 'wait', default = 1,
            action = 'store', type = 'int',
            help = 'number of seconds to wait before screenshot')
        self._optpar = op

        self._base_dir = os.path.join(qmk.base_dir(), 'screenshots')
        if not os.path.exists(self._base_dir):
            os.mkdir(self._base_dir)

    def _indicateError(self, ecode):
        raise RuntimeError(
            'Error: %s' % (win32api.FormatMessage(ecode).strip()))

    @qmk.capture_and_show_exceptions('screenshot')
    def _take_snapshot(self):
        o = self._opts

        if '' == o.filename:
            fn = 'screenshot-%s.png' % utils.dt_str(sep = '')
        elif not o.filename.endswith(('.PNG', '.png')):
            fn = '%s.png' % o.filename
        else:
            fn = o.filename

        if '' == os.path.dirname(fn):
            fn = os.path.join(self._base_dir, fn)

        afn = os.path.abspath(fn)

        if os.path.exists(fn):
            if os.path.isfile(fn):
{'fraction_non_alphanumeric': 0.13785504407443683, 'fraction_numerical': 0.005876591576885406, 'mean_word_length': 2.2996768982229403, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '1432172', 'n_tokens_mistral': 1329, 'n_tokens_neox': 1286, 'n_words': 313}