import gi gi.require_version('Gtk', '3.0') # noqa: E402 gi.require_version('PangoCairo', '1.0') # noqa: E402 # for some reason performance is improved by importing Gtk early from gi.repository import Gtk as gtk from hamster.lib import default_logger logger = default_logger(__name__) try: # defs.py is created by waf from defs.py.in from hamster import defs __version__ = defs.VERSION installed = True except ImportError: # if defs is not there, we are running from sources from subprocess import getstatusoutput rc, output = getstatusoutput("git describe --tags --always --dirty=+") __version__ = "2.2.2" if rc else "{} (uninstalled)".format(output) installed = False del getstatusoutput, rc, output # cleanup namespace del default_logger del gtk # performance is retained
from gi.repository import Gio as gio from gi.repository import GLib as glib import hamster from hamster import client, reports from hamster import logger as hamster_logger from hamster.about import About from hamster.edit_activity import CustomFactController from hamster.overview import Overview from hamster.preferences import PreferencesEditor from hamster.lib import default_logger, stuff from hamster.lib import datetime as dt from hamster.lib.fact import Fact logger = default_logger(__file__) def word_wrap(line, max_len): """primitive word wrapper""" lines = [] cur_line, cur_len = "", 0 for word in line.split(): if len("%s %s" % (cur_line, word)) < max_len: cur_line = ("%s %s" % (cur_line, word)).strip() else: if cur_line: lines.append(cur_line) cur_line = word if cur_line: lines.append(cur_line)