diff --git a/desktop/mypaint-ora-thumbnailer.py b/desktop/mypaint-ora-thumbnailer.py index 2cb3c6834..3632a667b 100644 --- a/desktop/mypaint-ora-thumbnailer.py +++ b/desktop/mypaint-ora-thumbnailer.py @@ -29,6 +29,7 @@ import gi + gi.require_version("GdkPixbuf", "2.0") try: from lib.gibindings import GdkPixbuf diff --git a/doc/spectral/rgb_to_spectral.py b/doc/spectral/rgb_to_spectral.py index 9fba214bb..415550474 100644 --- a/doc/spectral/rgb_to_spectral.py +++ b/doc/spectral/rgb_to_spectral.py @@ -9,19 +9,21 @@ # !pip install git+git://github.com/colour-science/colour - import colour import numpy as np +from scipy.optimize import minimize + + from colour.colorimetry import ( STANDARD_OBSERVERS_CMFS, SpectralDistribution, SpectralShape, sd_ones, - sd_zeros, spectral_to_XYZ_integration, + sd_zeros, ) -from colour.utilities import from_range_100, to_domain_1 -from scipy.optimize import minimize +from colour.utilities import to_domain_1, from_range_100 + # could use straight Meng but we can do Chromatic Adaptation via the illuminant_SPD instead # this is Meng modified to be more similar to Scott Allen Burns least log slope squared method diff --git a/gui/accelmap.py b/gui/accelmap.py index 48349fb2a..4457bc877 100644 --- a/gui/accelmap.py +++ b/gui/accelmap.py @@ -14,10 +14,13 @@ import logging import re -import lib.xml -from lib.gettext import C_ +from lib.gibindings import Gtk +from lib.gibindings import Gdk +from lib.gibindings import Pango from lib.gettext import gettext as _ -from lib.gibindings import Gdk, Gtk, Pango +from lib.gettext import C_ + +import lib.xml from lib.pycompat import unicode logger = logging.getLogger(__name__) diff --git a/gui/application.py b/gui/application.py index 09231c0c4..06c3bd035 100644 --- a/gui/application.py +++ b/gui/application.py @@ -28,68 +28,74 @@ # guess GTK is caching something internally, like GLib's g_get_*_dir() # stuff, but wtf is libmypaint doing to break those? -import json -import logging import os import sys +from os.path import join from collections import namedtuple +import logging +import json + +from lib.gibindings import GObject +from lib.gibindings import Gtk +from lib.gibindings import Gdk +from lib.gibindings import GdkPixbuf +from lib.gibindings import GLib from gettext import gettext as _ -from os.path import join -import gui.autorecover -import gui.compatibility as compat -import gui.cursor -import gui.device -import gui.factoryaction # registration only -import gui.picker -import gui.profiling -import gui.userconfig +import lib.observable import lib.cache -import lib.config import lib.document -import lib.fileutils -import lib.glib -import lib.observable import lib.strokemap -import lib.xml -from lib import brush, brushsettings, helpers, mypaintlib, validation -from lib.gibindings import Gdk, GdkPixbuf, GLib, GObject, Gtk -from lib.pycompat import unicode - -from . import accelmap # noqa: F401 -from . import colorpreview # noqa: F401 -from . import colors # noqa: F401 -from . import colortools # noqa: F401 +from lib import brush +from lib import helpers +from lib import mypaintlib +from lib import brushsettings +from lib import validation +import gui.compatibility as compat +import gui.device +from . import filehandling +from . import keyboard +from . import brushmanager +from . import document +from . import tileddrawwidget +from . import workspace # noqa: F401 +from . import topbar # noqa: F401 from . import drawwindow # noqa: F401 -from . import fill # noqa: F401 -from . import framewindow # noqa: F401 -from . import history # noqa: F401 +from . import backgroundwindow +from . import preferenceswindow +from . import brusheditor from . import layerswindow # noqa: F401 -from . import optionspanel # noqa: F401 from . import previewwindow # noqa: F401 +from . import optionspanel # noqa: F401 +from . import framewindow # noqa: F401 from . import scratchwindow # noqa: F401 +from . import inputtestwindow +from . import brushiconeditor +from . import history # noqa: F401 +from . import colortools # noqa: F401 +from . import brushmodifier +from . import blendmodehandler from . import toolbar # noqa: F401 -from . import topbar # noqa: F401 -from . import workspace # noqa: F401 -from . import ( - backgroundwindow, - blendmodehandler, - brusheditor, - brushiconeditor, - brushmanager, - brushmodifier, - document, - filehandling, - inputtestwindow, - keyboard, - linemode, - preferenceswindow, - tileddrawwidget, -) +from . import linemode +from . import colors # noqa: F401 +from . import colorpreview # noqa: F401 +from . import fill # noqa: F401 +from . import accelmap # noqa: F401 from .brushcolor import BrushColorManager -from .buttonmap import ButtonMapping from .overlays import LastPaintPosOverlay # noqa: F401 from .overlays import ScaleOverlay # noqa: F401 +from .buttonmap import ButtonMapping +import lib.config +import lib.glib +import gui.cursor +import lib.fileutils +import gui.picker +import gui.userconfig +import gui.factoryaction # registration only +import gui.autorecover +import lib.xml +import gui.profiling +from lib.pycompat import unicode logger = logging.getLogger(__name__) diff --git a/gui/autorecover.py b/gui/autorecover.py index 2ce01fae0..740496908 100644 --- a/gui/autorecover.py +++ b/gui/autorecover.py @@ -9,16 +9,17 @@ """Autorecovery UI""" -import logging -import os.path -import shutil import weakref +import os.path from gettext import gettext as _ +import shutil +import logging + +from lib.gibindings import Gtk import lib.document -import lib.errors import lib.helpers -from lib.gibindings import Gtk +import lib.errors from lib.pycompat import unicode logger = logging.getLogger(__name__) diff --git a/gui/backgroundwindow.py b/gui/backgroundwindow.py index fab93c746..1c07d6ef2 100644 --- a/gui/backgroundwindow.py +++ b/gui/backgroundwindow.py @@ -11,17 +11,21 @@ ## Imports -import logging import os import sys +import logging + from gettext import gettext as _ +from lib.gibindings import Gtk +from lib.gibindings import GdkPixbuf +from . import pixbuflist +from . import windowing +from lib import tiledsurface +from lib import helpers import lib.pixbuf -from lib import helpers, tiledsurface -from lib.gibindings import GdkPixbuf, Gtk -from lib.pycompat import unicode, xrange - -from . import pixbuflist, windowing +from lib.pycompat import unicode +from lib.pycompat import xrange logger = logging.getLogger(__name__) diff --git a/gui/brushcolor.py b/gui/brushcolor.py index 8a685b2cc..90216dc4f 100644 --- a/gui/brushcolor.py +++ b/gui/brushcolor.py @@ -9,9 +9,8 @@ """Brush color changer.""" -import lib.color - from . import colors +import lib.color class BrushColorManager(colors.ColorManager): diff --git a/gui/brusheditor.py b/gui/brusheditor.py index 9206f8346..90d6dd0b0 100644 --- a/gui/brusheditor.py +++ b/gui/brusheditor.py @@ -13,24 +13,28 @@ # Imports: -import logging import os +import logging + +from lib.gibindings import Gtk +from lib.gibindings import Pango +from lib.gibindings import GLib +from lib.gibindings import GdkPixbuf -import lib.brush -from lib import brushsettings from lib.gettext import C_ -from lib.gibindings import GdkPixbuf, GLib, Gtk, Pango +from lib import brushsettings from lib.pycompat import iteritems, itervalues -from . import brushmanager -from . import curve as notuseddirectly # noqa - needed for interactive testing +import lib.brush from . import dialogs +from . import brushmanager from .builderhacks import add_objects_from_template_string +from .windowing import SubWindow +from . import curve as notuseddirectly # noqa - needed for interactive testing # The widget class needs to be in scope before it is # instantiated via the loading of the glade file. from .sliderwidget import InputSlider # noqa -from .windowing import SubWindow logger = logging.getLogger(__name__) diff --git a/gui/brushiconeditor.py b/gui/brushiconeditor.py index 15c98ec05..5456bd3e2 100644 --- a/gui/brushiconeditor.py +++ b/gui/brushiconeditor.py @@ -11,13 +11,17 @@ import logging from gettext import gettext as _ +from lib.gibindings import Gtk +from lib.gibindings import GLib + +from . import tileddrawwidget +from . import windowing import lib.document from gui.document import CanvasController -from lib.gibindings import GLib, Gtk -from lib.observable import event - -from . import brushmanager, drawutils, tileddrawwidget, windowing from .freehand import FreehandMode +from . import brushmanager +from lib.observable import event +from . import drawutils logger = logging.getLogger(__name__) diff --git a/gui/brushmanager.py b/gui/brushmanager.py index 9466dd2c6..e7ab54f19 100644 --- a/gui/brushmanager.py +++ b/gui/brushmanager.py @@ -12,28 +12,33 @@ ## Imports -import contextlib -import logging +from itertools import chain import os -import shutil -import uuid import zipfile -from itertools import chain from os.path import basename from warnings import warn +import logging +import shutil +import uuid +import contextlib -import gui.mode -import lib.config -import lib.pixbuf -from lib.brush import BrushInfo -from lib.gettext import C_ from lib.gettext import gettext as _ -from lib.gibindings import GdkPixbuf, Gtk +from lib.gettext import C_ from lib.helpers import utf8 -from lib.observable import event -from lib.pycompat import PY3, unicode, xrange -from . import dialogs, drawutils +from lib.gibindings import Gtk +from lib.gibindings import GdkPixbuf + +from . import dialogs +from lib.brush import BrushInfo +from lib.observable import event +import lib.pixbuf +from . import drawutils +import gui.mode +import lib.config +from lib.pycompat import unicode +from lib.pycompat import xrange +from lib.pycompat import PY3 if PY3: import urllib.parse @@ -263,8 +268,8 @@ def _mock(cls): any zipfile.Zipfile()s you open, even for read. """ - from shutil import rmtree from tempfile import mkdtemp + from shutil import rmtree dist_brushes = lib.config.mypaint_brushdir tmp_user_brushes = mkdtemp(suffix="_brushes") diff --git a/gui/brushmanip.py b/gui/brushmanip.py index 899862ed7..81dfc6ab4 100644 --- a/gui/brushmanip.py +++ b/gui/brushmanip.py @@ -11,11 +11,12 @@ from math import ceil, hypot, log, pi -import gui.mode import gui.overlays +import gui.mode + from lib.brush import brush_visual_radius -from lib.gettext import C_ from lib.gibindings import Gdk +from lib.gettext import C_ class BrushSizeOverlay(gui.overlays.Overlay): diff --git a/gui/brushmodifier.py b/gui/brushmodifier.py index aefc56ba5..252552033 100644 --- a/gui/brushmodifier.py +++ b/gui/brushmodifier.py @@ -7,9 +7,9 @@ # (at your option) any later version. from gettext import gettext as _ +from lib.helpers import rgb_to_hsv, hsv_to_rgb import gui.blendmodehandler -from lib.helpers import hsv_to_rgb, rgb_to_hsv class BrushModifier(object): diff --git a/gui/brushselectionwindow.py b/gui/brushselectionwindow.py index 4ce50ac65..10c2d02ea 100644 --- a/gui/brushselectionwindow.py +++ b/gui/brushselectionwindow.py @@ -19,11 +19,18 @@ import logging -from lib.gettext import C_, ngettext -from lib.gibindings import GdkPixbuf, GLib, Gtk +from lib.gibindings import Gtk +from lib.gibindings import GdkPixbuf +from lib.gibindings import GLib -from . import brushmanager, dialogs, pixbuflist, widgets +from lib.gettext import C_ +from lib.gettext import ngettext + +from . import pixbuflist +from . import dialogs +from . import brushmanager from .toolstack import SizedVBoxToolWidget +from . import widgets logger = logging.getLogger(__name__) diff --git a/gui/builderhacks.py b/gui/builderhacks.py index 627a341e6..f60b47cc4 100755 --- a/gui/builderhacks.py +++ b/gui/builderhacks.py @@ -10,11 +10,12 @@ """Hacks for loading stuff from GtkBuilder files.""" -import lib.xml - ## Imports from lib.gibindings import Gtk +import lib.xml + + ## Public functions diff --git a/gui/buttonmap.py b/gui/buttonmap.py index 407479fd9..ce23f0c06 100644 --- a/gui/buttonmap.py +++ b/gui/buttonmap.py @@ -8,14 +8,17 @@ """Button press mapping.""" -import logging from gettext import gettext as _ +import logging -import lib.xml -from lib.gibindings import Gdk, GObject, Gtk, Pango -from lib.pycompat import unicode +from lib.gibindings import Gtk +from lib.gibindings import Gdk +from lib.gibindings import GObject +from lib.gibindings import Pango +import lib.xml from . import widgets +from lib.pycompat import unicode logger = logging.getLogger(__name__) @@ -105,7 +108,7 @@ def get_handler_object(app, action_name): value None). """ - from gui.mode import InteractionMode, ModeRegistry + from gui.mode import ModeRegistry, InteractionMode mode_class = ModeRegistry.get_mode_class(action_name) if mode_class is not None: diff --git a/gui/colorpicker.py b/gui/colorpicker.py index 947a23247..b9b40a57f 100644 --- a/gui/colorpicker.py +++ b/gui/colorpicker.py @@ -12,10 +12,12 @@ from gettext import gettext as _ import gui.mode +from .overlays import Overlay +from .overlays import rounded_box from lib.color import HCYColor, HSVColor + from lib.gibindings import GLib -from .overlays import Overlay, rounded_box ## Color picking mode, with a preview rectangle overlay diff --git a/gui/colors/__init__.py b/gui/colors/__init__.py index 507ac49ac..3b66f2635 100644 --- a/gui/colors/__init__.py +++ b/gui/colors/__init__.py @@ -9,7 +9,9 @@ """Color manipulation submodule.""" -from .adjbases import ColorAdjuster, ColorManager, PreviousCurrentColorAdjuster +from .adjbases import ColorManager +from .adjbases import ColorAdjuster +from .adjbases import PreviousCurrentColorAdjuster from .hsvsquare import HSVSquare __all__ = [ diff --git a/gui/colors/adjbases.py b/gui/colors/adjbases.py index dc5ba0b53..7f4cd2471 100644 --- a/gui/colors/adjbases.py +++ b/gui/colors/adjbases.py @@ -10,28 +10,33 @@ """Manager+adjuster bases for tweaking a single color via many widgets. """ -import logging import math -import os +from copy import deepcopy, copy +from warnings import warn import weakref -from copy import copy, deepcopy +import os +import logging from gettext import gettext as _ -from warnings import warn +from lib.gibindings import GObject +from lib.gibindings import Gdk +from lib.gibindings import Gtk +from lib.gibindings import GdkPixbuf import cairo +from .util import clamp +from .util import add_distance_fade_stops +from .util import draw_marker_circle +from lib.color import RGBColor, HCYColor +from .bases import CachedBgDrawingArea +from .bases import IconRenderable +from . import uimisc +from lib.palette import Palette +from lib.observable import event import gui.dialogs import gui.uicolor -from lib.color import HCYColor, RGBColor -from lib.gibindings import Gdk, GdkPixbuf, GObject, Gtk -from lib.observable import event -from lib.palette import Palette from lib.pycompat import xrange -from . import uimisc -from .bases import CachedBgDrawingArea, IconRenderable -from .util import add_distance_fade_stops, clamp, draw_marker_circle - logger = logging.getLogger(__name__) diff --git a/gui/colors/bases.py b/gui/colors/bases.py index 7f6b72d07..9187e101a 100644 --- a/gui/colors/bases.py +++ b/gui/colors/bases.py @@ -11,9 +11,9 @@ import logging +from lib.gibindings import Gtk import cairo -from lib.gibindings import Gtk logger = logging.getLogger(__name__) diff --git a/gui/colors/changers.py b/gui/colors/changers.py index ce0861056..f76fcf339 100644 --- a/gui/colors/changers.py +++ b/gui/colors/changers.py @@ -9,15 +9,18 @@ """The old popup color changers wrapped as new-style Adjusters""" + +## Imports +from lib.gibindings import GdkPixbuf +from lib.gibindings import Gdk + +import lib.color import gui.colors import gui.colors.adjbases -import lib.color from lib import mypaintlib - -## Imports -from lib.gibindings import Gdk, GdkPixbuf from lib.helpers import gdkpixbuf2numpy + ## Class definitions @@ -123,11 +126,10 @@ class Rings(_CColorChanger): if __name__ == "__main__": + from lib.gibindings import Gtk import os import sys - from lib.gibindings import Gtk - mgr = gui.colors.ColorManager(prefs={}, datapath=".") widget_classes = [CrossedBowl, Wash, Rings] widgets = [] diff --git a/gui/colors/hcywheel.py b/gui/colors/hcywheel.py index 6de3d09a2..99a5dbc8a 100644 --- a/gui/colors/hcywheel.py +++ b/gui/colors/hcywheel.py @@ -12,30 +12,33 @@ """ import math -import os.path -import re from copy import deepcopy +import re +import os.path +from lib.gibindings import Gtk +from lib.gibindings import Gdk import cairo +from .adjbases import ColorManager +from .adjbases import ColorAdjuster +from .adjbases import HueSaturationWheelMixin +from .adjbases import HueSaturationWheelAdjuster +from .sliders import HCYLumaSlider +from .combined import CombinedAdjusterPage +from lib.color import RGBColor +from lib.color import HCYColor +from lib.color import HSVColor import gui.uicolor +from .util import clamp +from lib.palette import Palette import lib.alg as geom -from lib.color import HCYColor, HSVColor, RGBColor +from .paletteview import palette_load_via_dialog +from .paletteview import palette_save_via_dialog from lib.gettext import C_ -from lib.gibindings import Gdk, Gtk -from lib.palette import Palette + from lib.pycompat import xrange -from .adjbases import ( - ColorAdjuster, - ColorManager, - HueSaturationWheelAdjuster, - HueSaturationWheelMixin, -) -from .combined import CombinedAdjusterPage -from .paletteview import palette_load_via_dialog, palette_save_via_dialog -from .sliders import HCYLumaSlider -from .util import clamp PREFS_MASK_KEY = "colors.hcywheel.mask.gamuts" PREFS_ACTIVE_KEY = "colors.hcywheel.mask.active" diff --git a/gui/colors/hsvcube.py b/gui/colors/hsvcube.py index 451ccd060..83f0d72c9 100644 --- a/gui/colors/hsvcube.py +++ b/gui/colors/hsvcube.py @@ -14,24 +14,22 @@ from gettext import gettext as _ import cairo - -from lib.color import HSVColor, RGBColor from lib.gibindings import Gtk -from lib.pycompat import xrange -from .adjbases import ( - ColorAdjuster, - ColorAdjusterWidget, - IconRenderableColorAdjusterWidget, - SliderColorAdjuster, -) +from .util import clamp +from .util import draw_marker_circle +from lib.color import HSVColor +from lib.color import RGBColor +from .adjbases import ColorAdjusterWidget +from .adjbases import ColorAdjuster +from .adjbases import SliderColorAdjuster +from .adjbases import IconRenderableColorAdjusterWidget from .combined import CombinedAdjusterPage -from .uimisc import ( - PRIMARY_ADJUSTERS_MIN_HEIGHT, - PRIMARY_ADJUSTERS_MIN_WIDTH, - borderless_button, -) -from .util import clamp, draw_marker_circle +from .uimisc import borderless_button +from .uimisc import PRIMARY_ADJUSTERS_MIN_WIDTH +from .uimisc import PRIMARY_ADJUSTERS_MIN_HEIGHT + +from lib.pycompat import xrange class HSVCubePage(CombinedAdjusterPage): @@ -252,7 +250,6 @@ def paint_foreground_cb(self, cr, wd, ht): if __name__ == "__main__": import os import sys - from adjbases import ColorManager mgr = ColorManager(prefs={}, datapath=".") diff --git a/gui/colors/hsvsquare.py b/gui/colors/hsvsquare.py index 20187e336..dd37f3492 100644 --- a/gui/colors/hsvsquare.py +++ b/gui/colors/hsvsquare.py @@ -14,21 +14,20 @@ import math from gettext import gettext as _ -import cairo - -from lib.color import HSVColor, RGBColor from lib.gibindings import Gtk -from lib.pycompat import xrange +import cairo -from .adjbases import ( - ColorAdjuster, - ColorAdjusterWidget, - HueSaturationWheelAdjuster, - IconRenderableColorAdjusterWidget, -) +from .util import clamp +from .util import draw_marker_circle +from lib.color import RGBColor, HSVColor from .bases import IconRenderable +from .adjbases import ColorAdjusterWidget +from .adjbases import ColorAdjuster +from .adjbases import IconRenderableColorAdjusterWidget +from .adjbases import HueSaturationWheelAdjuster from .combined import CombinedAdjusterPage -from .util import clamp, draw_marker_circle + +from lib.pycompat import xrange class HSVSquarePage(CombinedAdjusterPage, IconRenderable): @@ -420,7 +419,6 @@ def paint_foreground_cb(self, cr, wd, ht): if __name__ == "__main__": import os import sys - from adjbases import ColorManager mgr = ColorManager(prefs={}, datapath=".") diff --git a/gui/colors/hsvwheel.py b/gui/colors/hsvwheel.py index e34422013..818cc360e 100644 --- a/gui/colors/hsvwheel.py +++ b/gui/colors/hsvwheel.py @@ -12,13 +12,14 @@ from gettext import gettext as _ -from lib.color import HSVColor -from lib.gibindings import Gdk, Gtk +from lib.gibindings import Gtk +from lib.gibindings import Gdk from .adjbases import HueSaturationWheelAdjuster -from .combined import CombinedAdjusterPage from .sliders import HSVValueSlider +from lib.color import HSVColor from .util import clamp +from .combined import CombinedAdjusterPage class HSVHueSaturationWheel(HueSaturationWheelAdjuster): @@ -104,7 +105,6 @@ def set_color_manager(self, manager): if __name__ == "__main__": import os import sys - from adjbases import ColorManager mgr = ColorManager(prefs={}, datapath=".") diff --git a/gui/colors/paletteview.py b/gui/colors/paletteview.py index 48ef79671..c9ce8018d 100644 --- a/gui/colors/paletteview.py +++ b/gui/colors/paletteview.py @@ -15,31 +15,33 @@ # - sort palette by approx. hue+chroma binning, then luma variations -import logging - ## Imports import math import os import re +import logging from io import open +from lib.gibindings import Gdk +from lib.gibindings import Gtk +from lib.gibindings import GLib import cairo - -import gui.uicolor -from lib.color import HCYColor, HSVColor, RGBColor from lib.gettext import C_ -from lib.gibindings import Gdk, GLib, Gtk + +from .util import clamp from lib.palette import Palette +from lib.color import RGBColor +from lib.color import HCYColor +from lib.color import HSVColor +import gui.uicolor +from .adjbases import ColorAdjuster +from .adjbases import ColorAdjusterWidget +from .adjbases import ColorManager +from .adjbases import DATAPATH_PALETTES_SUBDIR +from .combined import CombinedAdjusterPage + from lib.pycompat import unicode -from .adjbases import ( - DATAPATH_PALETTES_SUBDIR, - ColorAdjuster, - ColorAdjusterWidget, - ColorManager, -) -from .combined import CombinedAdjusterPage -from .util import clamp logger = logging.getLogger(__name__) diff --git a/gui/colors/sliders.py b/gui/colors/sliders.py index cdbd432a6..ec6304f3e 100644 --- a/gui/colors/sliders.py +++ b/gui/colors/sliders.py @@ -10,13 +10,16 @@ """Component sliders for power users. """ -from lib.color import HCYColor, HSVColor, RGBColor -from lib.gettext import C_ from lib.gibindings import Gtk -from .adjbases import ColorAdjuster, SliderColorAdjuster +from lib.color import RGBColor +from lib.color import HSVColor +from lib.color import HCYColor from .bases import IconRenderable +from .adjbases import ColorAdjuster +from .adjbases import SliderColorAdjuster from .combined import CombinedAdjusterPage +from lib.gettext import C_ class ComponentSlidersAdjusterPage(CombinedAdjusterPage, IconRenderable): @@ -305,7 +308,6 @@ def get_background_validity(self): if __name__ == "__main__": import os import sys - from adjbases import ColorManager mgr = ColorManager(prefs={}, datapath=".") diff --git a/gui/colors/uimisc.py b/gui/colors/uimisc.py index f055ac9c6..466bbc098 100644 --- a/gui/colors/uimisc.py +++ b/gui/colors/uimisc.py @@ -12,6 +12,7 @@ from lib.gibindings import Gtk + ## Layout constants ## # Most pages in the old combined adjuster widget were split into a primary area diff --git a/gui/colortools.py b/gui/colortools.py index 25a1640e9..84d4efe6c 100644 --- a/gui/colortools.py +++ b/gui/colortools.py @@ -9,19 +9,21 @@ """Dockable Workspace tools for color adjusters.""" -import gui.colors.changers -from gui.colors import ColorAdjuster +from lib.gibindings import Gtk + +from lib.gettext import C_ + +from . import widgets +from .toolstack import TOOL_WIDGET_MIN_WIDTH from gui.colors.hcywheel import HCYAdjusterPage -from gui.colors.hsvcube import HSVCubePage -from gui.colors.hsvsquare import HSVSquarePage from gui.colors.hsvwheel import HSVAdjusterPage from gui.colors.paletteview import PalettePage +from gui.colors.hsvcube import HSVCubePage +from gui.colors.hsvsquare import HSVSquarePage from gui.colors.sliders import ComponentSlidersAdjusterPage -from lib.gettext import C_ -from lib.gibindings import Gtk +import gui.colors.changers +from gui.colors import ColorAdjuster -from . import widgets -from .toolstack import TOOL_WIDGET_MIN_WIDTH ## Adapter classes for old-style "Page" ColorAdjuster classes diff --git a/gui/compatibility.py b/gui/compatibility.py index 5a1a960f7..b1b923028 100644 --- a/gui/compatibility.py +++ b/gui/compatibility.py @@ -9,17 +9,20 @@ from logging import getLogger -import lib.eotf -from lib.gettext import C_ from lib.gibindings import Gtk -from lib.layer.data import BackgroundLayer -from lib.meta import MYPAINT_VERSION, PREREL, Compatibility -from lib.modes import MODE_STRINGS, set_default_mode -from lib.mypaintlib import CombineNormal, CombineSpectralWGM, combine_mode_get_info from . import compatconfig as config + from .compatconfig import C1X, C2X, COMPAT_SETTINGS, DEFAULT_COMPAT +import lib.eotf +from lib.layer.data import BackgroundLayer +from lib.meta import Compatibility, PREREL, MYPAINT_VERSION +from lib.modes import MODE_STRINGS, set_default_mode +from lib.mypaintlib import CombineNormal, CombineSpectralWGM +from lib.mypaintlib import combine_mode_get_info +from lib.gettext import C_ + logger = getLogger(__name__) FILE_WARNINGS = { diff --git a/gui/cursor.py b/gui/cursor.py index 4798a6645..bc4044020 100644 --- a/gui/cursor.py +++ b/gui/cursor.py @@ -7,15 +7,17 @@ # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. -import logging -import math - import cairo +import math +import logging import gui.drawutils -from lib.gibindings import Gdk, GdkPixbuf, Gtk from lib.pycompat import xrange +from lib.gibindings import Gtk +from lib.gibindings import Gdk +from lib.gibindings import GdkPixbuf + logger = logging.getLogger(__name__) # Absolute minimum size diff --git a/gui/curve.py b/gui/curve.py index 193075e7e..bcda025be 100644 --- a/gui/curve.py +++ b/gui/curve.py @@ -11,7 +11,8 @@ import logging from math import pi -from lib.gibindings import Gdk, Gtk +from lib.gibindings import Gtk, Gdk + from lib.helpers import clamp logger = logging.getLogger(__name__) diff --git a/gui/device.py b/gui/device.py index cef165af4..ed43ab5eb 100644 --- a/gui/device.py +++ b/gui/device.py @@ -12,15 +12,18 @@ ## Imports -import collections import logging +import collections import re -import gui.application -import gui.mode from lib.gettext import C_ -from lib.gibindings import Gdk, Gtk, Pango +from lib.gibindings import Gtk +from lib.gibindings import Gdk +from lib.gibindings import Pango + from lib.observable import event +import gui.application +import gui.mode logger = logging.getLogger(__name__) diff --git a/gui/dialogs.py b/gui/dialogs.py index 74601985a..eeba8a963 100644 --- a/gui/dialogs.py +++ b/gui/dialogs.py @@ -10,15 +10,18 @@ """Common dialog functions""" -from fnmatch import fnmatch +## Imports +from lib.gibindings import Gtk +from lib.gibindings import Gdk +from lib.gibindings import GdkPixbuf + from gettext import gettext as _ +from fnmatch import fnmatch +from . import widgets from lib.color import RGBColor +from . import uicolor -## Imports -from lib.gibindings import Gdk, GdkPixbuf, Gtk - -from . import uicolor, widgets ## Module constants diff --git a/gui/displayfilter.py b/gui/displayfilter.py index 1214c37bc..c6eb8781d 100644 --- a/gui/displayfilter.py +++ b/gui/displayfilter.py @@ -13,6 +13,7 @@ ## Imports import numpy as np + ## Constants # sRGB coefficients: the usual sRGB / Rec. 709 ones diff --git a/gui/document.py b/gui/document.py index de7bab1c5..58b94defe 100644 --- a/gui/document.py +++ b/gui/document.py @@ -16,38 +16,40 @@ ## Imports -import logging -import math import os import os.path -import weakref +import math from warnings import warn +import weakref +import logging + +from lib.gibindings import Gtk +from lib.gibindings import Gdk +from lib.gibindings import GLib +import lib.document +import lib.layer +import lib.helpers +from lib.helpers import clamp +import lib.observable +from . import stategroup import gui.application -import gui.backgroundwindow -import gui.buttonmap +import gui.mode import gui.colorpicker # purely for registration -import gui.device -import gui.externalapp +import gui.symmetry # registration only import gui.freehand import gui.inktool # registration only import gui.layerprops -import gui.mode -import gui.symmetry # registration only +import gui.buttonmap +import gui.externalapp +import gui.device +import gui.backgroundwindow import gui.tileddrawwidget -import lib.document -import lib.helpers -import lib.layer -import lib.observable from gui.widgets import with_wait_cursor -from lib.gettext import C_ from lib.gettext import gettext as _ -from lib.gibindings import Gdk, GLib, Gtk -from lib.helpers import clamp +from lib.gettext import C_ from lib.modes import PASS_THROUGH_MODE -from . import stategroup - logger = logging.getLogger(__name__) diff --git a/gui/drawutils.py b/gui/drawutils.py index 6b2f32fc8..4379c0fc2 100644 --- a/gui/drawutils.py +++ b/gui/drawutils.py @@ -17,18 +17,20 @@ import logging import math -import cairo -import numpy - -import gui.style -import lib.color -import lib.tiledsurface from lib.brush import Brush, BrushInfo -from lib.gibindings import Gdk, GdkPixbuf, Gtk -from lib.helpers import clamp +import lib.tiledsurface from lib.pixbufsurface import render_as_pixbuf +from lib.helpers import clamp +import gui.style +import lib.color from lib.pycompat import xrange +import numpy +import cairo +from lib.gibindings import GdkPixbuf +from lib.gibindings import Gdk +from lib.gibindings import Gtk + logger = logging.getLogger(__name__) ## Module constants @@ -563,7 +565,6 @@ def get_drop_shadow_offsets(line_width, z=2): if __name__ == "__main__": logging.basicConfig(level=logging.DEBUG) import sys - import lib.pixbuf for myb_file in sys.argv[1:]: diff --git a/gui/drawwindow.py b/gui/drawwindow.py index 26f3e0273..2b370a899 100644 --- a/gui/drawwindow.py +++ b/gui/drawwindow.py @@ -16,45 +16,45 @@ ## Imports -import logging -import math import os import os.path import webbrowser -import xml.etree.ElementTree as ET from warnings import warn +import logging +import math +import xml.etree.ElementTree as ET -import gui.brushmanip # noqa: F401 -import gui.displayfilter -import gui.footer -import gui.layermanip # noqa: F401 (registration of GObject classes) -import gui.meta -import gui.picker -import gui.tileddrawwidget -import gui.viewmanip # noqa: F401 (registration of GObject classes) -import lib.glib -import lib.xml -from lib.color import HSVColor -from lib.gettext import C_ -from lib.gettext import gettext as _ -from lib.gibindings import Gdk, Gtk +from lib.gibindings import Gtk +from lib.gibindings import Gdk -from . import brushselectionwindow # noqa: F401 (registration) +from . import compatibility +from . import historypopup +from . import stategroup from . import colorpicker # noqa: F401 (registration of GObject classes) -from . import layermodes # noqa: F401 (registration of GObject classes) from . import windowing # noqa: F401 (registration of GObject classes) -from . import ( - compatibility, - dialogs, - historypopup, - quickchoice, - stategroup, - toolbar, - uicolor, -) +from . import toolbar +from . import dialogs +from . import layermodes # noqa: F401 (registration of GObject classes) +from . import quickchoice +import gui.viewmanip # noqa: F401 (registration of GObject classes) +import gui.layermanip # noqa: F401 (registration of GObject classes) +import gui.brushmanip # noqa: F401 +from lib.color import HSVColor +from . import uicolor +import gui.picker +import gui.footer +from . import brushselectionwindow # noqa: F401 (registration) +from .overlays import LastPaintPosOverlay +from .overlays import ScaleOverlay from .framewindow import FrameOverlay -from .overlays import LastPaintPosOverlay, ScaleOverlay from .symmetry import SymmetryOverlay +import gui.tileddrawwidget +import gui.displayfilter +import gui.meta +import lib.xml +import lib.glib +from lib.gettext import gettext as _ +from lib.gettext import C_ logger = logging.getLogger(__name__) diff --git a/gui/externalapp.py b/gui/externalapp.py index d254a3b39..55a75e043 100644 --- a/gui/externalapp.py +++ b/gui/externalapp.py @@ -12,19 +12,25 @@ ## Imports -import logging -import os +import weakref import os.path +import os import subprocess -import weakref import gui.document # noqa -import lib.xml -from lib.gettext import C_ + from lib.gettext import gettext as _ -from lib.gibindings import Gio, Gtk, Pango +from lib.gettext import C_ from lib.layer.core import LayerBase # noqa +from lib.gibindings import Gio +from lib.gibindings import Pango +from lib.gibindings import Gtk + +import lib.xml + +import logging + logger = logging.getLogger(__name__) ## UI string consts diff --git a/gui/factoryaction.py b/gui/factoryaction.py index c3a657e44..ac2a34720 100644 --- a/gui/factoryaction.py +++ b/gui/factoryaction.py @@ -12,8 +12,8 @@ from warnings import warn import gi - -from lib.gibindings import GObject, Gtk +from lib.gibindings import Gtk +from lib.gibindings import GObject class FactoryAction(Gtk.Action): diff --git a/gui/filehandling.py b/gui/filehandling.py index 0b081df5b..1e6f70e08 100644 --- a/gui/filehandling.py +++ b/gui/filehandling.py @@ -13,25 +13,31 @@ ## Imports -import logging import os import re +from glob import glob import sys -import time +import logging from collections import OrderedDict -from glob import glob +import time + +from lib.gibindings import Gtk +from lib.gibindings import Pango +from lib import helpers +from lib import fileutils +from lib.errors import FileHandlingError +from lib.errors import AllocationError import gui.compatibility as compat -import lib.feedback -import lib.glib -import lib.xml from gui.widgets import with_wait_cursor -from lib import fileutils, helpers, mypaintlib -from lib.errors import AllocationError, FileHandlingError -from lib.gettext import C_, ngettext -from lib.gibindings import Gtk, Pango +from lib import mypaintlib +from lib.gettext import ngettext +from lib.gettext import C_ +import lib.glib from lib.glib import filename_to_unicode -from lib.pycompat import PY3, unicode +import lib.xml +import lib.feedback +from lib.pycompat import unicode, PY3 logger = logging.getLogger(__name__) diff --git a/gui/fill.py b/gui/fill.py index 4931780b2..961d329ff 100644 --- a/gui/fill.py +++ b/gui/fill.py @@ -11,24 +11,28 @@ # Imports import weakref +from lib.gibindings import Gtk +from lib.gibindings import Pango +from lib.gibindings import GLib from gettext import gettext as _ +from lib.gettext import C_ import cairo +import gui.mode import gui.cursor +from gui.blendmodehandler import BlendModes import gui.layers -import gui.mode import gui.overlays +from gui.sliderwidget import InputSlider + import lib.eotf import lib.floodfill import lib.helpers +import lib.mypaintlib import lib.layer import lib.modes -import lib.mypaintlib -from gui.blendmodehandler import BlendModes -from gui.sliderwidget import InputSlider -from lib.gettext import C_ -from lib.gibindings import GLib, Gtk, Pango + # Class defs diff --git a/gui/footer.py b/gui/footer.py index 1f922936f..a0904318b 100644 --- a/gui/footer.py +++ b/gui/footer.py @@ -9,19 +9,21 @@ """Footer widget behaviour.""" -import logging - ## Imports import math -from gettext import gettext as _ +import logging import cairo +from lib.gibindings import Gdk +from lib.gibindings import GdkPixbuf + import gui.brushmanager -import lib.xml from gui.quickchoice import BrushChooserPopup # noqa + +import lib.xml from lib.gettext import C_ -from lib.gibindings import Gdk, GdkPixbuf +from gettext import gettext as _ logger = logging.getLogger(__name__) diff --git a/gui/framewindow.py b/gui/framewindow.py index 034524f29..de5fc5dfb 100644 --- a/gui/framewindow.py +++ b/gui/framewindow.py @@ -10,25 +10,26 @@ ## Imports -import functools import math -from gettext import gettext as _ +import functools +from lib.gibindings import Gtk +from lib.gibindings import Gdk +from lib.gibindings import GLib +from gettext import gettext as _ import cairo -import gui.cursor -import gui.mode -import gui.style -import lib.helpers from gui.tileddrawwidget import TiledDrawWidget # noqa -from lib.alg import LineType, intersection_of_vector_and_poly, pairwise +import gui.mode from lib.color import RGBColor -from lib.document import DEFAULT_RESOLUTION -from lib.gibindings import Gdk, GLib, Gtk -from lib.helpers import Rect - +from lib.alg import pairwise, intersection_of_vector_and_poly, LineType from . import uicolor from .overlays import Overlay +import lib.helpers +from lib.helpers import Rect +from lib.document import DEFAULT_RESOLUTION +import gui.cursor +import gui.style class _EditZone: diff --git a/gui/freehand.py b/gui/freehand.py index 96b000f44..2f5edb50e 100644 --- a/gui/freehand.py +++ b/gui/freehand.py @@ -10,18 +10,20 @@ ## Imports -import logging import math +import logging from collections import deque from gettext import gettext as _ +from lib.gibindings import Gtk +from lib.gibindings import Gdk +from lib.gibindings import GLib import numpy as np -import gui.mode from gui.tileddrawwidget import TiledDrawWidget -from lib.gibindings import Gdk, GLib, Gtk -from lib.helpers import clamp +from lib.helpers import clamp +import gui.mode from .drawutils import spline_4p from .sliderwidget import InputSlider diff --git a/gui/gtkexcepthook.py b/gui/gtkexcepthook.py index ed8f749f6..b7d16de89 100644 --- a/gui/gtkexcepthook.py +++ b/gui/gtkexcepthook.py @@ -17,25 +17,28 @@ # - fix lockup with dialog.run(), return to mainloop instead # see also http://faq.pygtk.org/index.py?req=show&file=faq20.010.htp # (The license is still whatever you want.) +from lib.pycompat import PY3 + import inspect import linecache import pydoc import sys -import textwrap import traceback from gettext import gettext as _ +import textwrap + +from lib.gibindings import Gtk +from lib.gibindings import Gdk +from lib.gibindings import Pango import lib.meta -from lib.gibindings import Gdk, Gtk, Pango -from lib.pycompat import PY3 if PY3: from io import StringIO from urllib.parse import quote_plus else: - from urllib import quote_plus - from cStringIO import StringIO + from urllib import quote_plus # Function that will be called when the user presses "Quit" @@ -71,10 +74,9 @@ def lookup(name, frame, lcls): def analyse(exctyp, value, tb): + import tokenize import keyword import platform - import tokenize - from gui import application from gui.meta import get_libs_version_string @@ -326,8 +328,8 @@ def _dialog_response_cb(dialog, resp, trace, exctyp, value): if __name__ == "__main__": - import os import sys + import os def _test_button_clicked_cb(*a): class _TestException(Exception): diff --git a/gui/history.py b/gui/history.py index 18dadd27c..fe4a129a5 100644 --- a/gui/history.py +++ b/gui/history.py @@ -12,12 +12,15 @@ ## Imports +from lib.gibindings import Gtk +from lib.gibindings import GLib +from lib.gibindings import GdkPixbuf + from lib.color import RGBColor -from lib.gibindings import GdkPixbuf, GLib, Gtk +from .colors import ColorAdjuster from lib.observable import event - from . import widgets -from .colors import ColorAdjuster + ## Module constants diff --git a/gui/historypopup.py b/gui/historypopup.py index 9f4da6f01..6c071ff76 100644 --- a/gui/historypopup.py +++ b/gui/historypopup.py @@ -7,12 +7,13 @@ # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. +from lib.gibindings import Gtk +from lib.gibindings import Gdk import cairo -from lib.gibindings import Gdk, Gtk - from . import windowing + """Color history popup.""" diff --git a/gui/inktool.py b/gui/inktool.py index aaf5b5c43..145495c88 100644 --- a/gui/inktool.py +++ b/gui/inktool.py @@ -9,25 +9,27 @@ ## Imports -import collections import math +import collections import weakref -from gettext import gettext as _ from logging import getLogger +from gettext import gettext as _ +from lib.gibindings import Gdk +from lib.gibindings import GLib import numpy as np -import gui.cursor -import gui.drawutils import gui.mode -import gui.mvp import gui.overlays import gui.style +import gui.drawutils import lib.helpers +import gui.cursor import lib.observable -from lib.gibindings import Gdk, GLib +import gui.mvp from lib.pycompat import xrange + ## Module constants logger = getLogger(__name__) diff --git a/gui/inputtestwindow.py b/gui/inputtestwindow.py index 866dfb63a..06ca739f1 100644 --- a/gui/inputtestwindow.py +++ b/gui/inputtestwindow.py @@ -10,7 +10,10 @@ import logging from gettext import gettext as _ -from lib.gibindings import Gdk, GLib, Gtk, Pango +from lib.gibindings import Gtk +from lib.gibindings import Gdk +from lib.gibindings import GLib +from lib.gibindings import Pango from . import windowing diff --git a/gui/keyboard.py b/gui/keyboard.py index dfb4a91b6..2974966dd 100644 --- a/gui/keyboard.py +++ b/gui/keyboard.py @@ -17,9 +17,11 @@ import logging +from lib.gibindings import Gtk +from lib.gibindings import Gdk + import gui.document import gui.tileddrawwidget -from lib.gibindings import Gdk, Gtk logger = logging.getLogger(__name__) diff --git a/gui/layermanip.py b/gui/layermanip.py index 3ee72a2bf..24a905322 100644 --- a/gui/layermanip.py +++ b/gui/layermanip.py @@ -11,10 +11,13 @@ ## Imports from gettext import gettext as _ -import gui.cursor +from lib.gibindings import Gdk +from lib.gibindings import GLib + import gui.mode import lib.command -from lib.gibindings import Gdk, GLib +import gui.cursor + ## Class defs diff --git a/gui/layermodes.py b/gui/layermodes.py index a47a30c3c..05ab0aedd 100644 --- a/gui/layermodes.py +++ b/gui/layermodes.py @@ -12,7 +12,11 @@ ## Imports from lib.gibindings import Gtk -from lib.modes import MODE_STRINGS, STACK_MODES, STANDARD_MODES + +from lib.modes import STACK_MODES +from lib.modes import STANDARD_MODES +from lib.modes import MODE_STRINGS + ## Class definitions diff --git a/gui/layerprops.py b/gui/layerprops.py index f2f646e48..6fb50490b 100644 --- a/gui/layerprops.py +++ b/gui/layerprops.py @@ -15,13 +15,19 @@ import logging from collections import namedtuple -import cairo - -import gui.mvp +from lib.modes import STACK_MODES +from lib.modes import STANDARD_MODES +from lib.modes import PASS_THROUGH_MODE +from lib.modes import MODE_STRINGS import lib.xml from lib.gettext import C_ -from lib.gibindings import Gdk, GdkPixbuf, Gtk -from lib.modes import MODE_STRINGS, PASS_THROUGH_MODE, STACK_MODES, STANDARD_MODES +import gui.mvp + +import cairo +from lib.gibindings import Gtk +from lib.gibindings import Gdk +from lib.gibindings import GdkPixbuf + # Module constants: diff --git a/gui/layers.py b/gui/layers.py index a88735c52..e3828c5bc 100644 --- a/gui/layers.py +++ b/gui/layers.py @@ -11,20 +11,28 @@ ## Imports -import logging -import sys - -import gui.drawutils import lib.layer -from gui.layerprops import make_preview +from lib.xml import escape +from lib.observable import event from lib import helpers + from lib.document import Document -from lib.gettext import C_ from lib.gettext import gettext as _ -from lib.gibindings import Gdk, GdkPixbuf, GLib, GObject, Gtk, Pango -from lib.observable import event +from lib.gettext import C_ +from gui.layerprops import make_preview +import gui.drawutils from lib.pycompat import unicode -from lib.xml import escape + +from lib.gibindings import Gtk +from lib.gibindings import Gdk +from lib.gibindings import GObject +from lib.gibindings import GLib +from lib.gibindings import Pango +from lib.gibindings import GdkPixbuf + +import sys +import logging + ## Module vars @@ -1127,7 +1135,7 @@ def new_blend_mode_combo(modes, mode_strings): def _test(): """Test the custom model in an ad-hoc GUI window""" - from lib.layer import LayerStack, PaintingLayer + from lib.layer import PaintingLayer, LayerStack doc_model = Document() root = doc_model.layer_stack diff --git a/gui/layerswindow.py b/gui/layerswindow.py index 225f4876b..647756a5f 100644 --- a/gui/layerswindow.py +++ b/gui/layerswindow.py @@ -13,20 +13,25 @@ ## Imports -import os.path from gettext import gettext as _ +import os.path from logging import getLogger -import gui.layervis +from lib.gibindings import Gtk +from lib.gibindings import GObject + import lib.layer -import lib.modes import lib.xml -from lib.gibindings import GObject, Gtk -from lib.modes import MODE_STRINGS, PASS_THROUGH_MODE, STACK_MODES, STANDARD_MODES - -from . import layers, widgets -from .toolstack import SizedVBoxToolWidget +from . import widgets from .widgets import inline_toolbar +from .toolstack import SizedVBoxToolWidget +from . import layers +from lib.modes import STACK_MODES +from lib.modes import STANDARD_MODES +from lib.modes import MODE_STRINGS +from lib.modes import PASS_THROUGH_MODE +import lib.modes +import gui.layervis logger = getLogger(__name__) diff --git a/gui/layervis.py b/gui/layervis.py index 83a3fefa4..8771ffff8 100644 --- a/gui/layervis.py +++ b/gui/layervis.py @@ -11,16 +11,17 @@ # Imports: +import gui.mvp import logging - -import gui.application import gui.dialogs -import gui.mvp +import gui.application import lib.layervis from lib.gettext import C_ -from lib.gibindings import Gtk from lib.xml import escape +from lib.gibindings import Gtk + + # Module vars: logger = logging.getLogger(__name__) diff --git a/gui/linemode.py b/gui/linemode.py index ed9d69375..6a9f55fb7 100644 --- a/gui/linemode.py +++ b/gui/linemode.py @@ -17,16 +17,19 @@ ## Imports -import logging import math +import logging from gettext import gettext as _ -import gui.cursor +from lib.gibindings import Gtk +from lib.gibindings import Gdk +from lib.gibindings import GLib + +from .curve import CurveWidget import gui.mode -from lib.gibindings import Gdk, GLib, Gtk +import gui.cursor from lib.pycompat import xrange -from .curve import CurveWidget logger = logging.getLogger(__name__) diff --git a/gui/main.py b/gui/main.py index 40b2bcaee..c46a92c24 100644 --- a/gui/main.py +++ b/gui/main.py @@ -11,18 +11,19 @@ ## Imports *nothing involving mypaintlib at this point* -import logging import os import sys +import logging import warnings + +from lib.gibindings import GdkPixbuf from optparse import OptionParser -import gui.userconfig import lib.config import lib.glib -from lib.gibindings import GdkPixbuf from lib.i18n import USER_LOCALE_PREF from lib.meta import MYPAINT_VERSION +import gui.userconfig logger = logging.getLogger(__name__) diff --git a/gui/meta.py b/gui/meta.py index 469d738f5..f1de8340b 100644 --- a/gui/meta.py +++ b/gui/meta.py @@ -15,19 +15,21 @@ """ -import os -import platform - ## Imports import sys +import os +import platform +from lib.gibindings import Gtk +from lib.gibindings import GdkPixbuf +from lib.gibindings import GLib import cairo -import lib.meta from lib.gettext import C_ -from lib.gibindings import GdkPixbuf, GLib, Gtk +import lib.meta from lib.xml import escape + ## Program-related string constants COPYRIGHT_STRING = C_( diff --git a/gui/mode.py b/gui/mode.py index 3e89b12e4..4cbd257b3 100644 --- a/gui/mode.py +++ b/gui/mode.py @@ -14,15 +14,21 @@ import math from gettext import gettext as _ -import gui.cursor -import lib.command from gui.sliderwidget import InputSlider + +from lib.gibindings import Gtk +from lib.gibindings import Gdk +from lib.gibindings import GLib + +import lib.command from lib.brushsettings import settings_dict from lib.document import Document -from lib.gibindings import Gdk, GLib, Gtk from lib.layer.data import SimplePaintingLayer from lib.observable import event -from lib.pycompat import add_metaclass, unicode +from lib.pycompat import add_metaclass +from lib.pycompat import unicode + +import gui.cursor logger = logging.getLogger(__name__) diff --git a/gui/mvp.py b/gui/mvp.py index 1ad694d01..157374766 100644 --- a/gui/mvp.py +++ b/gui/mvp.py @@ -11,14 +11,15 @@ # Imports: +import os +import inspect import abc import functools -import inspect import logging -import os from lib.gibindings import Gtk + logger = logging.getLogger(__name__) diff --git a/gui/objfactory.py b/gui/objfactory.py index 66f4d70e9..400efa698 100644 --- a/gui/objfactory.py +++ b/gui/objfactory.py @@ -14,6 +14,7 @@ from warnings import warn from lib.gibindings import GObject + from lib.observable import event logger = logging.getLogger(__name__) diff --git a/gui/optionspanel.py b/gui/optionspanel.py index ed0defd3c..53537a914 100644 --- a/gui/optionspanel.py +++ b/gui/optionspanel.py @@ -12,11 +12,11 @@ import logging +from .toolstack import SizedVBoxToolWidget, TOOL_WIDGET_NATURAL_HEIGHT_SHORT import lib.xml from lib.gettext import C_ -from lib.gibindings import Gtk -from .toolstack import TOOL_WIDGET_NATURAL_HEIGHT_SHORT, SizedVBoxToolWidget +from lib.gibindings import Gtk logger = logging.getLogger(__name__) diff --git a/gui/overlays.py b/gui/overlays.py index 1d844c413..bcc1c20df 100644 --- a/gui/overlays.py +++ b/gui/overlays.py @@ -11,14 +11,17 @@ ## Imports -from gettext import gettext as _ from math import pi +from gettext import gettext as _ +from lib.gibindings import Pango +from lib.gibindings import PangoCairo +from lib.gibindings import GLib import cairo -import gui.style -from lib.gibindings import GLib, Pango, PangoCairo from lib.helpers import clamp +import gui.style + ## Base classes and utils diff --git a/gui/picker.py b/gui/picker.py index 36017b530..8642acee2 100644 --- a/gui/picker.py +++ b/gui/picker.py @@ -15,16 +15,18 @@ """ -import abc -import logging - -import gui.cursor -from gui.document import Document - ## Imports from gui.tileddrawwidget import TiledDrawWidget +from gui.document import Document from lib.gettext import C_ -from lib.gibindings import Gdk, GLib, Gtk +import gui.cursor + +from lib.gibindings import Gtk +from lib.gibindings import Gdk +from lib.gibindings import GLib + +import abc +import logging logger = logging.getLogger(__name__) diff --git a/gui/pixbuflist.py b/gui/pixbuflist.py index 0f0b3c381..047f93e46 100644 --- a/gui/pixbuflist.py +++ b/gui/pixbuflist.py @@ -7,15 +7,18 @@ # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. -import logging from math import ceil +import logging + +from lib.gibindings import Gtk +from lib.gibindings import Gdk +from lib.gibindings import GdkPixbuf +from lib.gibindings import GLib from lib import helpers -from lib.gibindings import Gdk, GdkPixbuf, GLib, Gtk from lib.observable import event -from lib.pycompat import xrange - from . import uicolor +from lib.pycompat import xrange logger = logging.getLogger(__name__) diff --git a/gui/preferenceswindow.py b/gui/preferenceswindow.py index 4a95f7110..b368ef2c5 100644 --- a/gui/preferenceswindow.py +++ b/gui/preferenceswindow.py @@ -10,18 +10,20 @@ """Preferences dialog.""" import os.path -from gettext import gettext as _ from logging import getLogger +from gettext import gettext as _ + +from lib.gibindings import Gtk +from lib.gibindings import Gdk +from gui.compatibility import CompatibilityPreferences import lib.config import lib.localecodes -from gui.compatibility import CompatibilityPreferences -from lib.gettext import C_ -from lib.gibindings import Gdk, Gtk from lib.i18n import USER_LOCALE_PREF - +from lib.gettext import C_ from . import windowing + logger = getLogger(__name__) RESPONSE_REVERT = 1 diff --git a/gui/previewwindow.py b/gui/previewwindow.py index 6cc9c3492..bdbc0ee5f 100644 --- a/gui/previewwindow.py +++ b/gui/previewwindow.py @@ -9,21 +9,25 @@ ## Imports -import bisect import math +import bisect + from gettext import gettext as _ +from lib.gibindings import Gtk +from lib.gibindings import Gdk +from lib.gibindings import GLib import cairo +import gui.mode +from . import overlays +from . import tileddrawwidget +from .toolstack import SizedVBoxToolWidget, TOOL_WIDGET_NATURAL_HEIGHT_SHORT +import lib.alg as geom import gui.cursor import gui.drawutils -import gui.mode import gui.style -import lib.alg as geom -from lib.gibindings import Gdk, GLib, Gtk -from . import overlays, tileddrawwidget -from .toolstack import TOOL_WIDGET_NATURAL_HEIGHT_SHORT, SizedVBoxToolWidget ## Module consts diff --git a/gui/profiling.py b/gui/profiling.py index f23a2d4bd..fe89094d9 100644 --- a/gui/profiling.py +++ b/gui/profiling.py @@ -8,16 +8,19 @@ # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. -import logging import os -import shutil -import subprocess import sys -import tempfile import time +import tempfile +import subprocess +import shutil +import logging + +from lib.gibindings import GLib +from lib.gibindings import Gtk import lib.fileutils -from lib.gibindings import GLib, Gtk + logger = logging.getLogger(__name__) diff --git a/gui/quickchoice.py b/gui/quickchoice.py index b8b264518..1566e960a 100644 --- a/gui/quickchoice.py +++ b/gui/quickchoice.py @@ -12,13 +12,18 @@ import abc -import gui.colortools from lib.gibindings import Gtk + +from .pixbuflist import PixbufList +from . import brushmanager +from . import brushselectionwindow +from . import widgets +from . import spinbox +from . import windowing from lib.observable import event +import gui.colortools from lib.pycompat import add_metaclass -from . import brushmanager, brushselectionwindow, spinbox, widgets, windowing -from .pixbuflist import PixbufList ## Module consts diff --git a/gui/scratchwindow.py b/gui/scratchwindow.py index dd8ca9c06..02a246285 100644 --- a/gui/scratchwindow.py +++ b/gui/scratchwindow.py @@ -14,11 +14,11 @@ import logging from lib.gettext import gettext as _ -from lib.gibindings import Gtk - -from .toolstack import TOOL_WIDGET_NATURAL_HEIGHT_SHORT, SizedVBoxToolWidget +from .toolstack import SizedVBoxToolWidget, TOOL_WIDGET_NATURAL_HEIGHT_SHORT from .widgets import inline_toolbar +from lib.gibindings import Gtk + logger = logging.getLogger(__name__) diff --git a/gui/sliderwidget.py b/gui/sliderwidget.py index d1ef810d0..8d6bc7598 100644 --- a/gui/sliderwidget.py +++ b/gui/sliderwidget.py @@ -10,10 +10,15 @@ import weakref -from lib.gibindings import Gdk, GObject, Gtk -from lib.observable import event +from lib.gibindings import Gtk +from lib.gibindings import Gdk +from lib.gibindings import GObject + from lib.pycompat import with_metaclass +from lib.observable import event + + # Can't access the constant as a normal attribute - it starts with a digit. _DOUBLE_CLICK = getattr(Gdk.EventType, "2BUTTON_PRESS") diff --git a/gui/stategroup.py b/gui/stategroup.py index 6a68c04ac..7ad827aad 100644 --- a/gui/stategroup.py +++ b/gui/stategroup.py @@ -9,7 +9,10 @@ import logging -from lib.gibindings import Gdk, GLib, Gtk +from lib.gibindings import Gtk +from lib.gibindings import Gdk +from lib.gibindings import GLib + logger = logging.getLogger(__name__) diff --git a/gui/style.py b/gui/style.py index 70b0e88e6..afc655fc2 100644 --- a/gui/style.py +++ b/gui/style.py @@ -18,6 +18,7 @@ from lib.color import HCYColor, RGBColor + ## Alpha checks (chequerboard pattern) ALPHA_CHECK_SIZE = 16 diff --git a/gui/symmetry.py b/gui/symmetry.py index 0fd8af32d..453b07b23 100644 --- a/gui/symmetry.py +++ b/gui/symmetry.py @@ -9,33 +9,37 @@ # (at your option) any later version. -import math - # Imports import cairo +import math +import gui.overlays +import gui.mode import gui.cursor import gui.drawutils -import gui.mode -import gui.overlays import gui.style -import gui.tileddrawwidget import gui.widgets import gui.windowing +import gui.tileddrawwidget +from gui.sliderwidget import InputSlider + import lib.alg import lib.mypaintlib import lib.tiledsurface -from gui.sliderwidget import InputSlider -from lib.gettext import C_ -from lib.gibindings import Gdk, GLib, Gtk -from lib.helpers import Rect from lib.mypaintlib import ( SymmetryHorizontal, + SymmetryVertical, + SymmetryVertHorz, SymmetryRotational, SymmetrySnowflake, - SymmetryVertHorz, - SymmetryVertical, ) +from lib.helpers import Rect +from lib.gettext import C_ + +from lib.gibindings import Gdk +from lib.gibindings import GLib +from lib.gibindings import Gtk + # Module settings diff --git a/gui/tileddrawwidget.py b/gui/tileddrawwidget.py index 75f00ecb7..9f8565cd7 100644 --- a/gui/tileddrawwidget.py +++ b/gui/tileddrawwidget.py @@ -10,28 +10,29 @@ ## Imports -import contextlib -import logging -import math import random +from math import floor, ceil, log, exp +import math import weakref -from math import ceil, exp, floor, log +import contextlib +import logging +from lib.gibindings import Gtk +from lib.gibindings import Gdk +from lib.gibindings import GLib import cairo import numpy as np -import gui.style -import lib.alg -import lib.color -import lib.layer -from lib import helpers, pixbufsurface, tiledsurface -from lib.gibindings import Gdk, GLib, Gtk +from lib import helpers, tiledsurface, pixbufsurface from lib.observable import event -from lib.pycompat import xrange - +import lib.layer from . import cursor from .drawutils import render_checks from .windowing import clear_focus +import gui.style +import lib.color +import lib.alg +from lib.pycompat import xrange logger = logging.getLogger(__name__) diff --git a/gui/toolbar.py b/gui/toolbar.py index 21bf79f88..07ec6dc95 100644 --- a/gui/toolbar.py +++ b/gui/toolbar.py @@ -18,6 +18,7 @@ from . import widgets + ## Module constants diff --git a/gui/toolstack.py b/gui/toolstack.py index 8c25e630b..4077a5d22 100644 --- a/gui/toolstack.py +++ b/gui/toolstack.py @@ -8,20 +8,25 @@ """Toolstacks with panels that can be closed/detached/reordered""" +from warnings import warn import logging import weakref -from warnings import warn -import lib.helpers -import lib.xml +from lib.gibindings import GObject +from lib.gibindings import Gtk +from lib.gibindings import Gdk +from lib.gibindings import GLib + from gui.windowing import set_initial_window_position -from lib.gettext import C_ -from lib.gibindings import Gdk, GLib, GObject, Gtk -from lib.pycompat import unicode, xrange +import lib.xml +import lib.helpers from . import objfactory from .widgets import borderless_button from .windowing import clear_focus +from lib.gettext import C_ +from lib.pycompat import xrange +from lib.pycompat import unicode logger = logging.getLogger(__name__) diff --git a/gui/topbar.py b/gui/topbar.py index e429f9d3b..c2da1569c 100644 --- a/gui/topbar.py +++ b/gui/topbar.py @@ -11,9 +11,11 @@ ## Imports import logging -from gettext import gettext as _ -from lib.gibindings import Gdk, GObject, Gtk +from lib.gibindings import GObject +from lib.gibindings import Gtk +from lib.gibindings import Gdk +from gettext import gettext as _ logger = logging.getLogger(__name__) diff --git a/gui/uicolor.py b/gui/uicolor.py index 0f4620a2a..4ed4a46f2 100644 --- a/gui/uicolor.py +++ b/gui/uicolor.py @@ -18,8 +18,9 @@ import struct -from lib.color import RGBColor from lib.gibindings import Gdk + +from lib.color import RGBColor from lib.helpers import clamp diff --git a/gui/userconfig.py b/gui/userconfig.py index 5482877aa..ad39d44f3 100644 --- a/gui/userconfig.py +++ b/gui/userconfig.py @@ -8,15 +8,16 @@ # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. -import json -import logging import os import sys +import json +import logging + +from lib.gibindings import GLib import lib.glib -from gui.compatconfig import DEFAULT_CONFIG as COMPAT_CONFIG from lib.eotf import DEFAULT_EOTF -from lib.gibindings import GLib +from gui.compatconfig import DEFAULT_CONFIG as COMPAT_CONFIG logger = logging.getLogger(__name__) diff --git a/gui/viewmanip.py b/gui/viewmanip.py index 0e8a09f3e..62c0e320e 100644 --- a/gui/viewmanip.py +++ b/gui/viewmanip.py @@ -9,11 +9,13 @@ """Modes for manipulating the view""" +## Imports +import gui.mode + import math + from gettext import gettext as _ -## Imports -import gui.mode ## Class defs diff --git a/gui/widgets.py b/gui/widgets.py index 6a2651201..47be6692f 100644 --- a/gui/widgets.py +++ b/gui/widgets.py @@ -10,7 +10,9 @@ import functools -from lib.gibindings import Gdk, Gtk +from lib.gibindings import Gtk +from lib.gibindings import Gdk + # Exact icon sizes diff --git a/gui/windowing.py b/gui/windowing.py index 4e1b30288..7fe851372 100644 --- a/gui/windowing.py +++ b/gui/windowing.py @@ -13,8 +13,11 @@ import logging -from lib.gibindings import Gdk, GLib, Gtk -from lib.helpers import Rect, clamp +from lib.gibindings import Gtk +from lib.gibindings import Gdk +from lib.gibindings import GLib + +from lib.helpers import clamp, Rect from lib.pycompat import xrange logger = logging.getLogger(__name__) diff --git a/gui/workspace.py b/gui/workspace.py index a4bb0c453..9c318f2bb 100644 --- a/gui/workspace.py +++ b/gui/workspace.py @@ -10,14 +10,17 @@ ## Imports -import logging from warnings import warn +import logging + +from lib.gibindings import GObject +from lib.gibindings import Gtk +from lib.gibindings import Gdk +from lib.gibindings import GLib from gui.toolstack import ToolStack, ToolStackWindow from gui.windowing import set_initial_window_position -from lib.gibindings import Gdk, GLib, GObject, Gtk from lib.observable import event - from . import objfactory logger = logging.getLogger(__name__) diff --git a/lib/brush.py b/lib/brush.py index ac4c0890c..7e93977db 100644 --- a/lib/brush.py +++ b/lib/brush.py @@ -7,14 +7,17 @@ # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. -import copy -import json import logging +import copy import math +import json -from lib import brushsettings, helpers, mypaintlib +from lib import mypaintlib +from lib import helpers +from lib import brushsettings from lib.eotf import eotf -from lib.pycompat import PY3, unicode +from lib.pycompat import unicode +from lib.pycompat import PY3 if PY3: from urllib.parse import unquote diff --git a/lib/brushes_migrate_json.py b/lib/brushes_migrate_json.py index e76502341..dd9592334 100644 --- a/lib/brushes_migrate_json.py +++ b/lib/brushes_migrate_json.py @@ -13,8 +13,8 @@ """ -import os import sys +import os from lib import brush diff --git a/lib/brushsettings.py b/lib/brushsettings.py index 8a40aa9cd..4975ee8dc 100644 --- a/lib/brushsettings.py +++ b/lib/brushsettings.py @@ -14,6 +14,7 @@ import lib.mypaintlib as _mypaintlib + # Public variables: #: List of info about all brush engine inputs known to libmypaint. diff --git a/lib/color.py b/lib/color.py index c7cfd0622..450d7b407 100644 --- a/lib/color.py +++ b/lib/color.py @@ -21,11 +21,14 @@ ## Imports -import colorsys import re +import colorsys from lib.gibindings import GdkPixbuf -from lib.pycompat import PY3, xrange + +from lib.pycompat import xrange +from lib.pycompat import PY3 + ## Lightweight color objects diff --git a/lib/command.py b/lib/command.py index 5dc377e71..235ccdbb8 100644 --- a/lib/command.py +++ b/lib/command.py @@ -10,21 +10,20 @@ ## Imports -import weakref from collections import deque +from warnings import warn from copy import deepcopy +import weakref from gettext import gettext as _ from logging import getLogger -from warnings import warn import lib.layer import lib.layer.data -import lib.stroke +from . import helpers from lib.observable import event +import lib.stroke from lib.pycompat import unicode -from . import helpers - logger = getLogger(__name__) diff --git a/lib/document.py b/lib/document.py index 29676f611..5511c709d 100644 --- a/lib/document.py +++ b/lib/document.py @@ -10,40 +10,44 @@ ## Imports -import json -import logging import os -import shutil import sys +import zipfile import tempfile import time -import xml.etree.ElementTree as ET -import zipfile -from collections import namedtuple -from datetime import datetime from os.path import join +import xml.etree.ElementTree as ET from warnings import warn +import shutil +from datetime import datetime +from collections import namedtuple +import json +import logging +from lib.fileutils import safename +from lib.naming import make_unique_name -import lib.brush as brush -import lib.command as command -import lib.feedback -import lib.fileutils as fileutils -import lib.glib +from lib.gibindings import GObject +from lib.gibindings import GLib + +import lib.meta import lib.helpers as helpers -import lib.idletask +import lib.fileutils as fileutils +import lib.tiledsurface as tiledsurface +import lib.command as command import lib.layer as layer -import lib.layervis -import lib.meta +import lib.brush as brush +from lib.observable import event +from lib.observable import ObservableDict import lib.pixbuf -import lib.tiledsurface as tiledsurface -import lib.xml from lib.cache import DEFAULT_CACHE_SIZE -from lib.errors import AllocationError, FileHandlingError -from lib.fileutils import safename +from lib.errors import FileHandlingError +from lib.errors import AllocationError +import lib.idletask from lib.gettext import C_ -from lib.gibindings import GLib, GObject -from lib.naming import make_unique_name -from lib.observable import ObservableDict, event +import lib.xml +import lib.glib +import lib.feedback +import lib.layervis from lib.pycompat import unicode logger = logging.getLogger(__name__) diff --git a/lib/feedback.py b/lib/feedback.py index 641438348..4b9cae04f 100644 --- a/lib/feedback.py +++ b/lib/feedback.py @@ -11,8 +11,9 @@ # Imports: -import lib.helpers from lib.observable import event +import lib.helpers + # Class defs: diff --git a/lib/fileutils.py b/lib/fileutils.py index 22e6bcab4..f094b3d81 100644 --- a/lib/fileutils.py +++ b/lib/fileutils.py @@ -12,18 +12,20 @@ ## Imports -import functools -import logging import os import os.path -import shutil import sys +import functools +import logging +import shutil import unicodedata import lib.helpers -from lib.gibindings import Gio, GLib from lib.pycompat import unicode +from lib.gibindings import GLib +from lib.gibindings import Gio + logger = logging.getLogger(__name__) diff --git a/lib/fill_common.py b/lib/fill_common.py index 4d97ca322..014db78ff 100644 --- a/lib/fill_common.py +++ b/lib/fill_common.py @@ -8,10 +8,10 @@ """Functions and constants common to fill and morphological operations""" -import numpy - import lib.helpers import lib.mypaintlib +import numpy + N = lib.mypaintlib.TILE_SIZE diff --git a/lib/floodfill.py b/lib/floodfill.py index 6a2823fa5..9bafb0a16 100644 --- a/lib/floodfill.py +++ b/lib/floodfill.py @@ -9,20 +9,22 @@ """This module implements tile-based floodfill and related operations.""" import logging -import threading import numpy as np +import threading + +from lib.gibindings import GLib -import lib.fill_common as fc import lib.helpers -import lib.modes -import lib.morphology import lib.mypaintlib as myplib import lib.surface import lib.tiledsurface -from lib.fill_common import _EMPTY_TILE, _FULL_TILE, _OPAQUE from lib.gettext import C_ -from lib.gibindings import GLib +import lib.fill_common as fc +from lib.fill_common import _OPAQUE, _FULL_TILE, _EMPTY_TILE +import lib.modes +import lib.morphology + from lib.pycompat import iteritems logger = logging.getLogger(__name__) diff --git a/lib/gettext.py b/lib/gettext.py index a44e2dbe8..c78ece8b2 100644 --- a/lib/gettext.py +++ b/lib/gettext.py @@ -24,13 +24,12 @@ """ -import sys from warnings import warn - from lib.gibindings import GLib # Set the default encoding like PyGTK from lib.pycompat import PY3 +import sys if not PY3: reload(sys) # noqa: F821 @@ -43,6 +42,7 @@ from gettext import gettext # noqa: F401 E402 from gettext import ngettext # noqa: F401 E402 + # Newer code should use C_() even for simple cases, and provide contexts # for translators. diff --git a/lib/gettext_setup.py b/lib/gettext_setup.py index 3a9ab1a7b..74283b9b8 100644 --- a/lib/gettext_setup.py +++ b/lib/gettext_setup.py @@ -6,12 +6,12 @@ # 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. -# This imports the global gettext package, not lib/gettext -import gettext -import logging import os import sys +import logging +# This imports the global gettext package, not lib/gettext +import gettext import lib.config as config logger = logging.getLogger(__file__) @@ -39,7 +39,6 @@ def init_gettext(localepath): """ import locale - import lib.i18n # Required in Windows for the "Region and Language" settings diff --git a/lib/glib.py b/lib/glib.py index ec63e44cc..5d4eef16c 100644 --- a/lib/glib.py +++ b/lib/glib.py @@ -22,8 +22,10 @@ import logging import sys +from lib.pycompat import PY3 +from lib.pycompat import unicode + from lib.gibindings import GLib -from lib.pycompat import PY3, unicode logger = logging.getLogger(__name__) diff --git a/lib/helpers.py b/lib/helpers.py index 3879e0e4f..9cfbda301 100644 --- a/lib/helpers.py +++ b/lib/helpers.py @@ -7,23 +7,24 @@ # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. +import itertools +from math import floor, isnan +import os +import hashlib +import zipfile import colorsys import gc -import hashlib -import itertools import logging -import os import sys -import zipfile -from math import floor, isnan -import lib.glib -import lib.pixbuf -from lib.gettext import C_ from lib.gibindings import GdkPixbuf -from lib.pycompat import PY2, unicode +from lib.gettext import C_ from . import mypaintlib +import lib.pixbuf +import lib.glib +from lib.pycompat import PY2 +from lib.pycompat import unicode logger = logging.getLogger(__name__) diff --git a/lib/i18n.py b/lib/i18n.py index 213b8c221..df2295540 100644 --- a/lib/i18n.py +++ b/lib/i18n.py @@ -14,10 +14,10 @@ """ -import locale -import logging import os import sys +import locale +import logging logger = logging.getLogger(__name__) diff --git a/lib/layer/__init__.py b/lib/layer/__init__.py index e71fab374..14c6700b8 100644 --- a/lib/layer/__init__.py +++ b/lib/layer/__init__.py @@ -28,7 +28,7 @@ """ -from .core import * # noqa: F401, F403 -from .data import * # noqa: F401, F403 from .group import * # noqa: F401, F403 +from .data import * # noqa: F401, F403 +from .core import * # noqa: F401, F403 from .tree import * # noqa: F401, F403 diff --git a/lib/layer/core.py b/lib/layer/core.py index de8e0bc41..c6d51473c 100644 --- a/lib/layer/core.py +++ b/lib/layer/core.py @@ -12,32 +12,29 @@ ## Imports -import abc import logging import os -import weakref import xml.etree.ElementTree as ET +import weakref from warnings import warn +import abc -import lib.fileutils -import lib.helpers as helpers -import lib.modes +from lib.gettext import C_ import lib.mypaintlib -import lib.pixbuf import lib.strokemap -import lib.tiledsurface +import lib.helpers as helpers +import lib.fileutils +import lib.pixbuf +from lib.modes import PASS_THROUGH_MODE +from lib.modes import STANDARD_MODES +from lib.modes import ORA_MODES_BY_OPNAME +from lib.modes import MODES_EFFECTIVE_AT_ZERO_ALPHA +from lib.modes import MODES_DECREASING_BACKDROP_ALPHA +import lib.modes import lib.xml -from lib.gettext import C_ -from lib.modes import ( - MODES_DECREASING_BACKDROP_ALPHA, - MODES_EFFECTIVE_AT_ZERO_ALPHA, - ORA_MODES_BY_OPNAME, - PASS_THROUGH_MODE, - STANDARD_MODES, -) -from lib.pycompat import unicode - +import lib.tiledsurface from .rendering import Renderable +from lib.pycompat import unicode logger = logging.getLogger(__name__) diff --git a/lib/layer/data.py b/lib/layer/data.py index f87b6f99c..0d9b685e0 100644 --- a/lib/layer/data.py +++ b/lib/layer/data.py @@ -12,40 +12,41 @@ """Data layer classes""" -import contextlib +## Imports +import zlib import logging import os -import shutil -import struct -import tempfile import time -import uuid - -## Imports -import zlib +import tempfile +import shutil from copy import deepcopy from random import randint +import uuid +import struct +import contextlib -import lib.autosave -import lib.feedback -import lib.fileutils +from lib.brush import BrushInfo +from lib.gettext import C_ +from lib.tiledsurface import N +import lib.tiledsurface as tiledsurface +import lib.strokemap import lib.helpers as helpers -import lib.layer.error +import lib.fileutils +import lib.pixbuf import lib.modes import lib.mypaintlib -import lib.pixbuf -import lib.strokemap -import lib.tiledsurface as tiledsurface +from . import core +import lib.layer.error +import lib.autosave import lib.xml -from lib.brush import BrushInfo -from lib.gettext import C_ -from lib.pycompat import PY3, unicode -from lib.tiledsurface import N - -from . import core, rendering +import lib.feedback +from . import rendering +from lib.pycompat import PY3 +from lib.pycompat import unicode if PY3: - from io import BytesIO, StringIO + from io import StringIO + from io import BytesIO else: from cStringIO import StringIO diff --git a/lib/layer/group.py b/lib/layer/group.py index 3035e8378..ec637e5e3 100644 --- a/lib/layer/group.py +++ b/lib/layer/group.py @@ -15,21 +15,23 @@ import logging from copy import copy -import lib.autosave -import lib.feedback -import lib.fileutils -import lib.helpers as helpers -import lib.layer.core -import lib.layer.error +from lib.gettext import C_ import lib.mypaintlib import lib.pixbufsurface +import lib.helpers as helpers +import lib.fileutils +from lib.modes import STANDARD_MODES +from lib.modes import STACK_MODES +from lib.modes import PASS_THROUGH_MODE +from . import core +from . import data +import lib.layer.error import lib.surface -from lib.gettext import C_ -from lib.modes import PASS_THROUGH_MODE, STACK_MODES, STANDARD_MODES -from lib.pycompat import unicode - -from . import core, data +import lib.autosave +import lib.feedback +import lib.layer.core from .rendering import Opcode +from lib.pycompat import unicode logger = logging.getLogger(__name__) diff --git a/lib/layer/rendering.py b/lib/layer/rendering.py index 39ea2fbd6..4a6ba17d6 100644 --- a/lib/layer/rendering.py +++ b/lib/layer/rendering.py @@ -17,6 +17,7 @@ import abc + # Public constants: diff --git a/lib/layer/test.py b/lib/layer/test.py index 8ebdfff46..9d11d493b 100644 --- a/lib/layer/test.py +++ b/lib/layer/test.py @@ -15,8 +15,8 @@ def make_test_stack(): :rtype: tuple """ - import lib.layer.data import lib.layer.group + import lib.layer.data import lib.layer.tree root = lib.layer.tree.RootLayerStack(doc=None) diff --git a/lib/layer/tree.py b/lib/layer/tree.py index 895ceb376..f2b961731 100644 --- a/lib/layer/tree.py +++ b/lib/layer/tree.py @@ -13,31 +13,38 @@ ## Imports -import contextlib +import re import logging +from copy import copy +from copy import deepcopy import os.path -import re -from copy import copy, deepcopy from warnings import warn +import contextlib +from lib.gibindings import GdkPixbuf +from lib.gibindings import GLib import numpy as np -import lib.cache -import lib.feedback -import lib.helpers as helpers -import lib.mypaintlib -import lib.naming -import lib.pixbuf -import lib.tiledsurface as tiledsurface from lib.eotf import eotf from lib.gettext import C_ -from lib.gibindings import GdkPixbuf, GLib -from lib.modes import MODES_DECREASING_BACKDROP_ALPHA, PASS_THROUGH_MODE +import lib.mypaintlib +import lib.tiledsurface as tiledsurface +from lib.tiledsurface import TileAccessible +from lib.tiledsurface import TileBlittable +import lib.helpers as helpers from lib.observable import event +import lib.pixbuf +import lib.cache +from lib.modes import PASS_THROUGH_MODE +from lib.modes import MODES_DECREASING_BACKDROP_ALPHA +from . import data +from . import group +from . import core +from . import rendering +import lib.feedback +import lib.naming from lib.pycompat import xrange -from lib.tiledsurface import TileAccessible, TileBlittable -from . import core, data, group, rendering logger = logging.getLogger(__name__) diff --git a/lib/layervis.py b/lib/layervis.py index 0b59732bd..c08645a30 100644 --- a/lib/layervis.py +++ b/lib/layervis.py @@ -26,12 +26,13 @@ import logging -import lib.naming -from lib.command import Command from lib.gettext import C_ +import lib.naming from lib.observable import event +from lib.command import Command from lib.pycompat import unicode + # Module vars: logger = logging.getLogger(__name__) diff --git a/lib/meta.py b/lib/meta.py index be06f92df..ae8992206 100644 --- a/lib/meta.py +++ b/lib/meta.py @@ -261,10 +261,10 @@ def _get_versions(gitprefix="gitexport"): to derive the additional information. """ - import os import re - import subprocess + import os import sys + import subprocess # Establish some fallbacks for use when there's no .git present, # or no release_info. diff --git a/lib/modes.py b/lib/modes.py index 864bcc5c6..f5de8b5f4 100644 --- a/lib/modes.py +++ b/lib/modes.py @@ -9,7 +9,6 @@ """Layer mode constants""" from gettext import gettext as _ - import lib.mypaintlib #: Additional pass-through mode for layer groups (not saved, but reflected diff --git a/lib/morphology.py b/lib/morphology.py index eca55c31f..d8cd2d3be 100644 --- a/lib/morphology.py +++ b/lib/morphology.py @@ -11,9 +11,10 @@ """ import logging -import lib.fill_common as fc import lib.mypaintlib as myplib -from lib.fill_common import _EMPTY_TILE, _FULL_TILE + +import lib.fill_common as fc +from lib.fill_common import _FULL_TILE, _EMPTY_TILE N = myplib.TILE_SIZE diff --git a/lib/observable.py b/lib/observable.py index a25a26fe0..332900900 100644 --- a/lib/observable.py +++ b/lib/observable.py @@ -9,8 +9,8 @@ """Observable method calls and C#-like syntactic sugar for events.""" -import logging import weakref +import logging logger = logging.getLogger(__name__) diff --git a/lib/palette.py b/lib/palette.py index debbe6237..69eea095f 100644 --- a/lib/palette.py +++ b/lib/palette.py @@ -14,16 +14,19 @@ ## Imports -import logging import re from copy import copy -from io import open +import logging -from lib.color import UIColor # noqa -from lib.color import RGBColor, YCbCrColor from lib.helpers import clamp from lib.observable import event -from lib.pycompat import PY3, unicode, xrange +from lib.color import RGBColor +from lib.color import YCbCrColor +from lib.color import UIColor # noqa +from lib.pycompat import unicode +from lib.pycompat import xrange +from lib.pycompat import PY3 +from io import open logger = logging.getLogger(__name__) diff --git a/lib/pixbuf.py b/lib/pixbuf.py index 2efac77e4..6c6384481 100644 --- a/lib/pixbuf.py +++ b/lib/pixbuf.py @@ -20,14 +20,15 @@ ## Imports +from lib.gibindings import GdkPixbuf + +import lib.fileutils +import lib.feedback + import logging import os import zipfile # noqa -import lib.feedback -import lib.fileutils -from lib.gibindings import GdkPixbuf - logger = logging.getLogger(__name__) diff --git a/lib/pixbufsurface.py b/lib/pixbufsurface.py index e5c6b8ece..32d3686be 100644 --- a/lib/pixbufsurface.py +++ b/lib/pixbufsurface.py @@ -13,17 +13,18 @@ import contextlib from logging import getLogger +from lib.gibindings import GdkPixbuf +from lib.gibindings import Gdk import cairo -import lib.feedback -import lib.surface +from . import mypaintlib +from . import helpers from lib.eotf import eotf +import lib.surface +from lib.surface import TileAccessible, TileBlittable from lib.errors import AllocationError from lib.gettext import C_ -from lib.gibindings import Gdk, GdkPixbuf -from lib.surface import TileAccessible, TileBlittable - -from . import helpers, mypaintlib +import lib.feedback logger = getLogger(__name__) diff --git a/lib/strokemap.py b/lib/strokemap.py index e427c43b5..32c2b0570 100644 --- a/lib/strokemap.py +++ b/lib/strokemap.py @@ -9,19 +9,19 @@ ## Imports -import math import struct import zlib +import math from logging import getLogger from warnings import warn import numpy as np +from . import mypaintlib +from . import idletask import lib.tiledsurface as tiledsurface -from lib.pycompat import PY3, iteritems from lib.surface import TileAccessible # noqa - -from . import idletask, mypaintlib +from lib.pycompat import PY3, iteritems logger = getLogger(__name__) TILE_SIZE = N = mypaintlib.TILE_SIZE diff --git a/lib/surface.py b/lib/surface.py index f22f15f24..169011af6 100644 --- a/lib/surface.py +++ b/lib/surface.py @@ -11,18 +11,18 @@ """Common interfaces & routines for surface and surface-like objects""" import abc -import logging import os +import logging import numpy as np -import lib.feedback +from . import mypaintlib import lib.helpers from lib.errors import FileHandlingError from lib.gettext import C_ +import lib.feedback from lib.pycompat import xrange -from . import mypaintlib logger = logging.getLogger(__name__) diff --git a/lib/tiledsurface.py b/lib/tiledsurface.py index a4db41d49..f0e5af525 100644 --- a/lib/tiledsurface.py +++ b/lib/tiledsurface.py @@ -11,26 +11,29 @@ ## Imports +import time +import sys +import os import contextlib import logging -import os -import sys -import time -from gettext import gettext as _ +from gettext import gettext as _ import numpy as np -import lib.feedback -import lib.fileutils -import lib.floodfill -import lib.modes -import lib.surface +from . import mypaintlib +from . import pixbufsurface from lib.eotf import eotf -from lib.pycompat import PY3, itervalues, xrange -from lib.surface import TileAccessible, TileBlittable, TileCompositable - -from . import mypaintlib, pixbufsurface +import lib.surface +from lib.surface import TileAccessible +from lib.surface import TileBlittable +from lib.surface import TileCompositable from .errors import FileHandlingError +import lib.fileutils +import lib.modes +import lib.feedback +import lib.floodfill +from lib.pycompat import xrange +from lib.pycompat import PY3, itervalues logger = logging.getLogger(__name__) diff --git a/lib/xml.py b/lib/xml.py index fb6f75096..9f7bb5344 100644 --- a/lib/xml.py +++ b/lib/xml.py @@ -12,10 +12,10 @@ ## Imports -import xml.etree.ElementTree as _ET - from lib.pycompat import PY3 +import xml.etree.ElementTree as _ET + ## Consts for XML dialects # Namespaces are registered by importing this module. diff --git a/mypaint.py b/mypaint.py index 5d45dd3a8..d173c44b0 100644 --- a/mypaint.py +++ b/mypaint.py @@ -20,12 +20,12 @@ ## Imports (standard Python only at this point) -import logging +import sys import os import os.path +from os.path import join, isdir, dirname, abspath import re -import sys -from os.path import abspath, dirname, isdir, join +import logging logger = logging.getLogger("mypaint") if sys.version_info >= (3,): @@ -103,7 +103,7 @@ def win32_unicode_argv(): characters with '?'. """ try: - from ctypes import POINTER, byref, c_int, cdll, windll + from ctypes import POINTER, byref, cdll, c_int, windll from ctypes.wintypes import LPCWSTR, LPWSTR get_cmd = cdll.kernel32.GetCommandLineW diff --git a/pyproject.toml b/pyproject.toml deleted file mode 100644 index 5d7bf33d9..000000000 --- a/pyproject.toml +++ /dev/null @@ -1,2 +0,0 @@ -[tool.isort] -profile = "black" diff --git a/setup.cfg b/setup.cfg index bb8a40e69..2314af15b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -21,7 +21,7 @@ verbosity=2 [flake8] max-line-length = 120 -extend-select = B950,I001 +extend-select = B950 ignore = E203,E266,E501,E701,W503,E251,E226,BLK100 exclude = .git, diff --git a/setup.py b/setup.py index f35ecff56..3e4d159e8 100644 --- a/setup.py +++ b/setup.py @@ -2,28 +2,30 @@ # Imports: -import functools +from contextlib import contextmanager +import subprocess import glob import os import os.path +from os.path import join, abspath, normpath import pprint -import shutil -import subprocess import sys -import tempfile import textwrap -from contextlib import contextmanager +import tempfile +import shutil +import functools + +from setuptools import setup +from setuptools import Extension +from setuptools import Command +from setuptools.command.build_ext import build_ext +from setuptools.command.install import install +from setuptools.command.install_scripts import install_scripts # setuptools must be imported first since they ensure # their distutils implementation will be used. from distutils.command.build import build from distutils.command.clean import clean -from os.path import abspath, join, normpath - -from setuptools import Command, Extension, setup -from setuptools.command.build_ext import build_ext -from setuptools.command.install import install -from setuptools.command.install_scripts import install_scripts # Constants diff --git a/svg/symbolic-icons-extract.py b/svg/symbolic-icons-extract.py index be4e7ff38..2b72ab872 100755 --- a/svg/symbolic-icons-extract.py +++ b/svg/symbolic-icons-extract.py @@ -11,12 +11,12 @@ ## Imports import argparse +from copy import deepcopy import gzip import logging import os import sys import xml.etree.ElementTree as ET -from copy import deepcopy from scour.scour import start as scour_optimize diff --git a/tests/compositeops.py b/tests/compositeops.py index f985d6763..b3e2f53df 100644 --- a/tests/compositeops.py +++ b/tests/compositeops.py @@ -2,17 +2,17 @@ # Tests the layer compositing/blending code for correctness of its # advertized optimization flags. -import unittest from random import random +import unittest import numpy as np +from . import paths from lib import mypaintlib +from lib.tiledsurface import N from lib.modes import MODE_STRINGS from lib.pycompat import xrange -from lib.tiledsurface import N -from . import paths ALPHA_VALUES = (0.0, 0.5, 1.0) GREY_VALUES = (0.0, 0.25, 0.5, 0.75, 1.0) diff --git a/tests/fill.py b/tests/fill.py index e231075a4..f7bb3985f 100644 --- a/tests/fill.py +++ b/tests/fill.py @@ -2,18 +2,21 @@ # Imports: -import contextlib -import copy +from time import time import os import sys -import unittest -from itertools import chain, product, repeat from os.path import join -from time import time - -from lib import document, fill_common, floodfill, morphology, mypaintlib +import unittest +import contextlib +import copy +from itertools import repeat, chain, product from . import paths +from lib import mypaintlib +from lib import document +from lib import floodfill +from lib import fill_common +from lib import morphology N = mypaintlib.TILE_SIZE diff --git a/tests/localedata.py b/tests/localedata.py index 53fe0e466..31a32ff7f 100644 --- a/tests/localedata.py +++ b/tests/localedata.py @@ -1,6 +1,5 @@ import unittest from glob import glob - from lib import localecodes as lc diff --git a/tests/mypaintlib.py b/tests/mypaintlib.py index 24a999de1..5c8998fdf 100755 --- a/tests/mypaintlib.py +++ b/tests/mypaintlib.py @@ -2,20 +2,23 @@ # Imports: -import os -import shutil +from time import time +from os.path import join +from itertools import product +import unittest import sys +import os import tempfile -import unittest -from itertools import product -from os.path import join -from time import time +import shutil import numpy as np -from lib import brush, document, mypaintlib, tiledsurface - from . import paths +from lib import mypaintlib +from lib import tiledsurface +from lib import brush +from lib import document + N = mypaintlib.TILE_SIZE diff --git a/tests/rendering.py b/tests/rendering.py index b56025925..d53ea731f 100755 --- a/tests/rendering.py +++ b/tests/rendering.py @@ -2,20 +2,19 @@ # Imports: -import math +from os.path import join import sys import time -import unittest -from collections import namedtuple -from os.path import join - +import math import cairo +from collections import namedtuple +import unittest +from . import paths from lib import mypaintlib from lib.document import Document -from lib.pycompat import PY3, xrange +from lib.pycompat import xrange, PY3 -from . import paths TEST_BIGIMAGE = "bigimage.ora" diff --git a/tests/unported/guicontrol.py b/tests/unported/guicontrol.py index e5430f674..ed1be3db2 100644 --- a/tests/unported/guicontrol.py +++ b/tests/unported/guicontrol.py @@ -1,14 +1,16 @@ +import traceback +import tempfile import os import sys -import tempfile -import traceback -import gi import numpy as np +import gi + try: gi.require_version("Gtk", "3.0") - from lib.gibindings import GObject, Gtk + from lib.gibindings import Gtk + from lib.gibindings import GObject except: raise diff --git a/tests/unported/memory_leak.py b/tests/unported/memory_leak.py index c481a79f8..a912d0873 100755 --- a/tests/unported/memory_leak.py +++ b/tests/unported/memory_leak.py @@ -1,19 +1,18 @@ #!/usr/bin/env python -import gc -import os -import sys from time import time +import sys +import os +import gc import numpy as np os.chdir(os.path.dirname(__file__)) sys.path.insert(0, "..") +from lib import mypaintlib, tiledsurface, brush, document, command, helpers import guicontrol -from lib import brush, command, document, helpers, mypaintlib, tiledsurface - # loadtxt is known to leak memory, thus we run it only once # http://projects.scipy.org/numpy/ticket/1356 painting30sec_events = np.loadtxt("painting30sec.dat") diff --git a/tests/unported/performance.py b/tests/unported/performance.py index 48997a683..63b96ca7a 100755 --- a/tests/unported/performance.py +++ b/tests/unported/performance.py @@ -1,14 +1,14 @@ #!/usr/bin/env python -import cProfile +import sys import os import subprocess -import sys -from time import sleep, time +import cProfile +from time import time, sleep import shutil +import numpy as np import guicontrol -import numpy as np start_measurement = -1 stop_measurement = -2 @@ -207,7 +207,7 @@ def save_png_layer(): @nogui_test def brushengine_paint_hires(): - from lib import brush, tiledsurface + from lib import tiledsurface, brush s = tiledsurface.Surface() with open("brushes/v2/watercolor.myb") as fp: