<commit_before># ***************************************************************************
# *   Copyright (c) 2017 <NAME> <<EMAIL>>                 *
# *   Copyright (c) 2018 <NAME> <<EMAIL>>              *
# *                                                                         *
# *   This file is part of the FreeCAD CAx development system.              *
# *                                                                         *
# *   This program is free software; you can redistribute it and/or modify  *
# *   it under the terms of the GNU Lesser General Public License (LGPL)    *
# *   as published by the Free Software Foundation; either version 2 of     *
# *   the License, or (at your option) any later version.                   *
# *   for detail see the LICENCE text file.                                 *
# *                                                                         *
# *   This program 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 Library General Public License for more details.                  *
# *                                                                         *
# *   You should have received a copy of the GNU Library General Public     *
# *   License along with this program; if not, write to the Free Software   *
# *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  *
# *   USA                                                                   *
# *                                                                         *
# ***************************************************************************

__title__ = "FreeCAD FEM base constraint ViewProvider"
__author__ = "<NAME>, <NAME>"
__url__ = "http://www.freecadweb.org"

## @package _BaseViewProvider
#  \ingroup FEM
#  \brief FreeCAD _Base ViewProvider for FEM workbench

from pivy import coin
from six import string_types

import FreeCAD
import FreeCADGui

import FemGui  # needed to display the icons in TreeView


False if FemGui.__name__ else True  # flake8, dummy FemGui usage


class ViewProxy(object):
    """Proxy View Provider for Pythons base constraint."""

    def __init__(self, vobj):
        vobj.Proxy = self

    # needs to be overwritten, if no standard icon name is used
    # see constraint body heat source as an example
    def getIcon(self):
        # print(self.Object.Name)
        """after load from FCStd file, self.icon does not exist, return constant path instead"""
        # https://forum.freecadweb.org/viewtopic.php?f=18&t=44009
        if (
            hasattr(self.Object.Proxy, "Type")
            and isinstance(self.Object.Proxy.Type, string_types)
            and self.Object.Proxy.Type.startswith("Fem::")
        ):
            return ":/icons/{}.svg".format(self.Object.Proxy.Type.replace("Fem::", "FEM_"))
        else:
            FreeCAD.Console.PrintError("No icon returned for {}\n".format(self.Object.Name))
            FreeCAD.Console.PrintMessage("{}\n".format(self.Object.Proxy.Type))
            return ""

    def attach(self, vobj):
        default = coin.SoGroup()
        vobj.addDisplayMode(default, "Default")
        self.Object = vobj.Object  # used on various places, claim childreens, get icon, etc.
        # self.ViewObject = vobj  # not used ATM

    def getDisplayModes(self, obj):
        "Return a list of display modes."
        modes = ["Default"]
        return modes

    def getDefaultDisplayMode(self):
        return "Default"
<commit_msg>FEM: Python base constraint VP, better log in get icon<commit_after># ***************************************************************************
# *   Copyright (c) 2017 <NAME> <<EMAIL>>                 *
# *   Copyright (c) 2018 <NAME> <<EMAIL>>              *
# *                                                                         *
# *   This file is part of the FreeCAD CAx development system.              *
# *                                                                         *
# *   This program is free software; you can redistribute it and/or modify  *
# *   it under the terms of the GNU Lesser General Public License (LGPL)    *
# *   as published by the Free Software Foundation; either version 2 of     *
# *   the License, or (at your option) any later version.                   *
# *   for detail see the LICENCE text file.                                 *
# *                                                                         *
# *   This program 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 Library General Public License for more details.                  *
# *                                                                         *
# *   You should have received a copy of the GNU Library General Public     *
# *   License along with this program; if not, write to the Free Software   *
# *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  *
# *   USA                                                                   *
# *                                                                         *
# ***************************************************************************

__title__ = "FreeCAD FEM base constraint ViewProvider"
__author__ = "<NAME>, <NAME>"
__url__ = "http://www.freecadweb.org"

## @package _BaseViewProvider
#  \ingroup FEM
#  \brief FreeCAD _Base ViewProvider for FEM workbench

from pivy import coin
from six import string_types

import FreeCAD
import FreeCADGui

import FemGui  # needed to display the icons in TreeView


False if FemGui.__name__ else True  # flake8, dummy FemGui usage


class ViewProxy(object):
    """Proxy View Provider for Pythons base constraint."""

    def __init__(self, vobj):
        vobj.Proxy = self

    # needs to be overwritten, if no standard icon name is used
    # see constraint body heat source as an example
    def getIcon(self):
        """after load from FCStd file, self.icon does not exist, return constant path instead"""
        # https://forum.freecadweb.org/viewtopic.php?f=18&t=44009
        if (
            hasattr(self.Object.Proxy, "Type")
            and isinstance(self.Object.Proxy.Type, string_types)
            and self.Object.Proxy.Type.startswith("Fem::")
        ):
            icon_path = "/icons/{}.svg".format(self.Object.Proxy.Type.replace("Fem::", "FEM_"))
            FreeCAD.Console.PrintLog("{} --> {}\n".format(self.Object.Name, icon_path))
            return ":/{}".format(icon_path)
        else:
            FreeCAD.Console.PrintError("No icon returned for {}\n".format(self.Object.Name))
            FreeCAD.Console.PrintMessage("{}\n".format(self.Object.Proxy.Type))
            return ""

    def attach(self, vobj):
        default = coin.SoGroup()
        vobj.addDisplayMode(default, "Default")
        self.Object = vobj.Object  # used on various places, claim childreens, get icon, etc.
        # self.ViewObject = vobj  # not used ATM

    def getDisplayModes(self, obj):
        "Return a list of display modes."
        modes = ["Default"]
        return modes

    def getDefaultDisplayMode(self):
        return "Default"

{'fraction_non_alphanumeric': 0.12774558684813367, 'fraction_numerical': 0.008354669182050937, 'mean_word_length': 1.772506537168472, 'pattern_counts': {'":': 2, '<': 19, '<?xml version=': 0, '>': 20, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 36, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2491719', 'n_tokens_mistral': 1885, 'n_tokens_neox': 1774, 'n_words': 625}