<commit_before># Persistent toolbars for FreeCAD
# Copyright (C) 2016, 2017  triplus @ FreeCAD
#
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library 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
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA

"""Persistent toolbars for FreeCAD."""

import operator
import FreeCAD as App
import FreeCADGui as Gui
from PySide import QtCore
from PySide import QtGui

conectedToolbars = []
timer = QtCore.QTimer()
mw = Gui.getMainWindow()

def pythonToolbars():
    """Manage Python based toolbars in Arch and Draft workbench."""

    active = Gui.activeWorkbench().__class__.__name__

    if active == "DraftWorkbench" or active == "ArchWorkbench":
        if hasattr(Gui, "draftToolBar"):
            try:
                Gui.draftToolBar.Activated()
            except:
                m = "Persistent toolbars: draftToolBar toolbar not managed.\n"
                App.Console.PrintMessage(m)
        if hasattr(Gui, "Snapper"):
            try:
                Gui.Snapper.show()
            except:
                m = "Persistent toolbars: Snapper toolbar not managed\n."
                App.Console.PrintMessage(m)
    else:
        pass


def isConnected(i):
    """Connect toolbar to onSave function."""

    if i not in conectedToolbars:
        conectedToolbars.append(i)
        i.topLevelChanged.connect(onSave)
    else:
        pass


def onRestore(active):
    """Restore current workbench toolbars position."""

    toolbars = {}
    tb = mw.findChildren(QtGui.QToolBar)
    pUser = App.ParamGet("User parameter:Tux/PersistentToolbars/User")
    pSystem = App.ParamGet("User parameter:Tux/PersistentToolbars/System")

    for i in tb:

        isConnected(i)

        if i.objectName() and not i.isFloating():
            toolbars[i.objectName()] = i<commit_msg>Grammar error<commit_after># Persistent toolbars for FreeCAD
# Copyright (C) 2016, 2017  triplus @ FreeCAD
#
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library 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
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA

"""Persistent toolbars for FreeCAD."""

import operator
import FreeCAD as App
import FreeCADGui as Gui
from PySide import QtCore
from PySide import QtGui

conectedToolbars = []
timer = QtCore.QTimer()
mw = Gui.getMainWindow()

def pythonToolbars():
    """Manage Python based toolbars in Arch and Draft workbench."""

    active = Gui.activeWorkbench().__class__.__name__

    if active == "DraftWorkbench" or active == "ArchWorkbench":
        if hasattr(Gui, "draftToolBar"):
            try:
                Gui.draftToolBar.Activated()
            except:
                m = "Persistent toolbars: draftToolBar toolbar not managed.\n"
                App.Console.PrintMessage(m)
        if hasattr(Gui, "Snapper"):
            try:
                Gui.Snapper.show()
            except:
                m = "Persistent toolbars: Snapper toolbar not managed.\n"
                App.Console.PrintMessage(m)
    else:
        pass


def isConnected(i):
    """Connect toolbar to onSave function."""

    if i not in conectedToolbars:
        conectedToolbars.append(i)
        i.topLevelChanged.connect(onSave)
    else:
        pass


def onRestore(active):
    """Restore current workbench toolbars position."""

    toolbars = {}
    tb = mw.findChildren(QtGui.QToolBar)
    pUser = App.ParamGet("User parameter:Tux/PersistentToolbars/User")
    pSystem = App.ParamGet("User parameter:Tux/PersistentToolbars/System")

    for i in tb:

        isConnected(i)

        if i.objectName() and not i.isFloating():
            toolbars[i.objectName()] = i
{'fraction_non_alphanumeric': 0.08524864187212704, 'fraction_numerical': 0.008775595486836606, 'mean_word_length': 2.9173486088379708, 'pattern_counts': {'":': 2, '<': 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': '5199780', 'n_tokens_mistral': 1412, 'n_tokens_neox': 1319, 'n_words': 494}