<commit_before>/*
 * Copyright (C) 2003-2004 <NAME> <<EMAIL>>
 * Copyright (C) 2003 <NAME> <<EMAIL>>
 * Copyright (c) 2005 <NAME> <<EMAIL>>
 *
 * This file is part of Superkaramba.
 *
 *  Superkaramba is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  Superkaramba 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 General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with Superkaramba; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 ****************************************************************************/

#include "karamba_python.h"
#include "dcopinterface_stub.h"
#include "richtextlabel.h"
#include "karamba.h"
#include "karambaapp.h"
#include "themesdlg.h"
#include "lineparser.h"

#include <kdebug.h>
#include <kmessagebox.h>
#include <krun.h>
#include <klocale.h>
#include <kwin.h>
#include <kdeversion.h>

#include <kparts/componentfactory.h>
#include <kparts/part.h>

#include <qdir.h>
#include <qwidgetlist.h>

#include <X11/xpm.h>

// Menu IDs
#define EDITSCRIPT 1
#define THEMECONF  2

karamba::karamba(QString fn, bool reloading) :
    QWidget(0,"karamba", Qt::WGroupLeader | WStyle_Customize |
            WRepaintNoErase| WStyle_NoBorder | WDestructiveClose  ),
    meterList(0), imageList(0), clickList(0), kpop(0), widgetMask(0),
    config(0), kWinModule(0), tempUnit('C'), sensorList(0), timeList(0),
    themeConfMenu(0), clickPos(0, 0), accColl(0), menuAccColl(0),
    toggleLocked(0), pythonIface(0), defaultTextField(0)
{
  //qDebug("karamba::karamba");
  if(!m_theme.set(fn))
  {
    setFixedSize(0, 0);
    QTimer::singleShot(100, this, SLOT(killWidget()));
    return;
  }
  setName("karamba - " + m_theme.name());

  widgetUpdate = true;

  // Creates KConfig Object
  QString cfg = QDir::home().absPath() + "/.superkaramba/"
      + m_theme.name() + ".rc";
  QFile themeConfigFile(cfg);
  // Tests if config file Exists
  if (!QFileInfo(themeConfigFile).exists())
  {
    // Create config file
    themeConfigFile.open(IO_ReadWrite);
    themeConfigFile.close();
  }

  config = new KConfig(cfg, false, false);
  config -> sync();
  config -> setGroup("internal");

  m_reloading = reloading;
  QTimer::singleShot(0, this, SLOT(initPythonInterface()));

  // <NAME>: set window type to "dock" (plays better with taskbar themes
  // this way)
  KWin::setType(winId(), NET::Dock);

#if defined(KDE_MAKE_VERSION)
# if KDE_VERSION >= KDE_MAKE_VERSION(3,1,9)
  //KDE 3.2 addition for the always on top issues
  KWin::setState(winId(), NET::KeepBelow);
# endif
#endif
<commit_msg>Don't import python module unless it exists.<commit_after>/*
 * Copyright (C) 2003-2004 <NAME> <<EMAIL>>
 * Copyright (C) 2003 <NAME> <<EMAIL>>
 * Copyright (c) 2005 <NAME> <<EMAIL>>
 *
 * This file is part of Superkaramba.
 *
 *  Superkaramba is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  Superkaramba 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 General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with Superkaramba; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 ****************************************************************************/

#include "karamba_python.h"
#include "dcopinterface_stub.h"
#include "richtextlabel.h"
#include "karamba.h"
#include "karambaapp.h"
#include "themesdlg.h"
#include "lineparser.h"

#include <kdebug.h>
#include <kmessagebox.h>
#include <krun.h>
#include <klocale.h>
#include <kwin.h>
#include <kdeversion.h>

#include <kparts/componentfactory.h>
#include <kparts/part.h>

#include <qdir.h>
#include <qwidgetlist.h>

#include <X11/xpm.h>

// Menu IDs
#define EDITSCRIPT 1
#define THEMECONF  2

karamba::karamba(QString fn, bool reloading) :
    QWidget(0,"karamba", Qt::WGroupLeader | WStyle_Customize |
            WRepaintNoErase| WStyle_NoBorder | WDestructiveClose  ),
    meterList(0), imageList(0), clickList(0), kpop(0), widgetMask(0),
    config(0), kWinModule(0), tempUnit('C'), sensorList(0), timeList(0),
    themeConfMenu(0), clickPos(0, 0), accColl(0), menuAccColl(0),
    toggleLocked(0), pythonIface(0), defaultTextField(0)
{
  if(!m_theme.set(fn))
  {
    setFixedSize(0, 0);
    QTimer::singleShot(100, this, SLOT(killWidget()));
    return;
  }
  kdDebug() << "Starting theme: " << m_theme.name() << endl;
  setName("karamba - " + m_theme.name());

  widgetUpdate = true;

  // Creates KConfig Object
  QString cfg = QDir::home().absPath() + "/.superkaramba/"
      + m_theme.name() + ".rc";
  QFile themeConfigFile(cfg);
  // Tests if config file Exists
  if (!QFileInfo(themeConfigFile).exists())
  {
    // Create config file
    themeConfigFile.open(IO_ReadWrite);
    themeConfigFile.close();
  }

  config = new KConfig(cfg, false, false);
  config -> sync();
  config -> setGroup("internal");

  m_reloading = reloading;
  if(!m_theme.pythonModule().isEmpty() &&
     m_theme.fileExists(m_theme.pythonModule() + ".py"))
  {
    kdDebug() << "Loading python module: " << m_theme.pythonModule() << endl;
    QTimer::singleShot(0, this, SLOT(initPythonInterface()));
  }
  // <NAME>: set window type to "dock" (plays better with taskbar themes
  // this way)
  KWin::setType(winId(), NET::Dock);

#if defined(KDE_MAKE_VERSION)
# if KDE_VERSION >= KDE_MAKE_VERSION(3,1,9)
  //KDE 3.2 addition for the always on top issues
  KWin::setState(winId(), NET::KeepBelow);
# endif
#endif

{'fraction_non_alphanumeric': 0.15904700579523504, 'fraction_numerical': 0.0206052801030264, 'mean_word_length': 4.328473413379074, 'pattern_counts': {'":': 0, '<': 57, '<?xml version=': 0, '>': 51, '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': '457129', 'n_tokens_mistral': 2179, 'n_tokens_neox': 2057, 'n_words': 591}