File: _common.py

package info (click to toggle)
epoptes 23.01-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,704 kB
  • sloc: python: 2,461; sh: 477; makefile: 11
file content (33 lines) | stat: -rw-r--r-- 1,001 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# This file is part of Epoptes, https://epoptes.org
# Copyright 2018 the Epoptes team, see AUTHORS.
# SPDX-License-Identifier: GPL-3.0-or-later
"""
Define required gi package versions in a common place, and install gettext.

Rationale:
gi requires something like:
    import gi
    gi.require_version('Gtk', '3.0')
    from gi.repository import Gtk
This conflicts with https://www.python.org/dev/peps/pep-0008/#imports
and triggers pycodestyle's "E402 module level import not at top of file".
The following is a bit better:
    import sys  # Import standard library modules

    import twisted  # Import third party modules

    from _common import gettext as _  # Import local modules
    from gi.repository import Gtk, Gdk
That last line "only" triggers pylint's "wrong-import-position" once.
"""
import gettext
import locale
import os

import gi

gi.require_version('Gtk', '3.0')
gi.require_version('Gdk', '3.0')
gettext.textdomain('epoptes')
locale.textdomain('epoptes')
gettext = gettext.gettext