<commit_before>import sys, operator, copy
import Xlib
import Xlib.display
import Xlib.ext.xinerama as xinerama
from Xlib import X, XK, Xatom
import Xlib.protocol.event as event
import command, utils

class QTileError(Exception): pass


class Key:
    def __init__(self, modifiers, key, action, *args, **kwargs):
        self.modifiers, self.key = modifiers, key
        self.action, self.args, self.kwargs = action, args, kwargs
        self.keysym = XK.string_to_keysym(key)
        if self.keysym == 0:
            raise QTileError("Unknown key: %s"%key)
        self.modmask = utils.translateMasks(self.modifiers)
    
    def __repr__(self):
        return "Key(%s, %s)"%(self.modifiers, self.key)


class _Layout:
    def clone(self, group):
        c = copy.copy(self)
        c.group = group
        return c


class Max(_Layout):
    name = "max"
    def configure(self, c):
        if c == self.group.focusClient:
            c.place(
                self.group.screen.x,
                self.group.screen.y,
                self.group.screen.width,
                self.group.screen.height,
            )
        else:
            c.hide()


class Screen:
    group = None
    def __init__(self, index, x, y, width, height, group):
        self.index, self.x, self.y = index, x, y
        self.width, self.height = width, height
        self.setGroup(group)

    def setGroup(self, g):
        if self.group and self.group != g:
            self.group.hide()
        self.group = g
        self.group.toScreen(self)


class Group:
    def __init__(self, name, layouts):
        self.name = name
        self.screen = None
        self.clients = []
        self.layouts = [i.clone(self) for i in layouts]
        self.currentLayout = 0
        self.focusClient = None

    @property
    def layout(self):
        return self.layouts[self.currentLayout]

    def layoutAll(self):
        if self.screen and self.clients:
            for i in self.clients:
                self.layout.configure(i)
            self.focusClient.focus()

    def toScreen(self, screen):
        if self.screen:
            self.screen.group = None
        self.screen = screen
        self.layoutAll()

    def hide(self):
        self.screen = None
        for i in self.clients:
            i.hide()

    def add(self, client):
        self.clients.insert(0, client)
        client.group = self
        self.focus(client)

    def delete(self, client):
        if self.focusClient is client:
            if len(self.clients) > 1:
                self.focusNext()
            else:
                self.focus(None)
        self.clients.remove(client)
        client.group = None
        self.layoutAll()

    def focusNext(self):
        idx = (self.clients.index(self.focusClient) + 1) % len(self.clients)
        self.focus(self.clients[idx])

    def focusPrevious(self):
        idx = (self.clients.index(self.focusClient) - 1) % len(self.clients)
        self.focus(self.clients[idx])

    def disableMask(self, mask):
        for i in self.clients:
            i.disableMask(mask)

    def resetMask(self):
        for i in self.clients:
            i.resetMask()

    def focus(self, client):
        if not client:
            self.focusClient = None
        elif self.focusClient != client:
            self.disableMask(X.EnterWindowMask)
            self.focusClient = client
            if self.screen:
                self.layout.configure(client)
                self.layoutAll()
            self.resetMask()

    def info(self):
        return dict(
            name = self.name,<commit_msg>Remove extraneous layout call.<commit_after>import sys, operator, copy
import Xlib
import Xlib.display
import Xlib.ext.xinerama as xinerama
from Xlib import X, XK, Xatom
import Xlib.protocol.event as event
import command, utils

class QTileError(Exception): pass


class Key:
    def __init__(self, modifiers, key, action, *args, **kwargs):
        self.modifiers, self.key = modifiers, key
        self.action, self.args, self.kwargs = action, args, kwargs
        self.keysym = XK.string_to_keysym(key)
        if self.keysym == 0:
            raise QTileError("Unknown key: %s"%key)
        self.modmask = utils.translateMasks(self.modifiers)
    
    def __repr__(self):
        return "Key(%s, %s)"%(self.modifiers, self.key)


class _Layout:
    def clone(self, group):
        c = copy.copy(self)
        c.group = group
        return c


class Max(_Layout):
    name = "max"
    def configure(self, c):
        if c == self.group.focusClient:
            c.place(
                self.group.screen.x,
                self.group.screen.y,
                self.group.screen.width,
                self.group.screen.height,
            )
        else:
            c.hide()


class Screen:
    group = None
    def __init__(self, index, x, y, width, height, group):
        self.index, self.x, self.y = index, x, y
        self.width, self.height = width, height
        self.setGroup(group)

    def setGroup(self, g):
        if self.group and self.group != g:
            self.group.hide()
        self.group = g
        self.group.toScreen(self)


class Group:
    def __init__(self, name, layouts):
        self.name = name
        self.screen = None
        self.clients = []
        self.layouts = [i.clone(self) for i in layouts]
        self.currentLayout = 0
        self.focusClient = None

    @property
    def layout(self):
        return self.layouts[self.currentLayout]

    def layoutAll(self):
        if self.screen and self.clients:
            for i in self.clients:
                self.layout.configure(i)
            self.focusClient.focus()

    def toScreen(self, screen):
        if self.screen:
            self.screen.group = None
        self.screen = screen
        self.layoutAll()

    def hide(self):
        self.screen = None
        for i in self.clients:
            i.hide()

    def add(self, client):
        self.clients.insert(0, client)
        client.group = self
        self.focus(client)

    def delete(self, client):
        if self.focusClient is client:
            if len(self.clients) > 1:
                self.focusNext()
            else:
                self.focus(None)
        self.clients.remove(client)
        client.group = None
        self.layoutAll()

    def focusNext(self):
        idx = (self.clients.index(self.focusClient) + 1) % len(self.clients)
        self.focus(self.clients[idx])

    def focusPrevious(self):
        idx = (self.clients.index(self.focusClient) - 1) % len(self.clients)
        self.focus(self.clients[idx])

    def disableMask(self, mask):
        for i in self.clients:
            i.disableMask(mask)

    def resetMask(self):
        for i in self.clients:
            i.resetMask()

    def focus(self, client):
        if not client:
            self.focusClient = None
        elif self.focusClient != client:
            self.disableMask(X.EnterWindowMask)
            self.focusClient = client
            if self.screen:
                self.layoutAll()
            self.resetMask()

    def info(self):
        return dict(
            name = self.name,
{'fraction_non_alphanumeric': 0.10713786841737673, 'fraction_numerical': 0.0016762117614191926, 'mean_word_length': 1.8345209817893904, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1734393', 'n_tokens_mistral': 2196, 'n_tokens_neox': 2134, 'n_words': 527}