From edd62b1852b4d62ffbe693ef61cb429005aaa299 Mon Sep 17 00:00:00 2001 From: pmp-p Date: Tue, 12 Jul 2022 23:42:54 +0200 Subject: [PATCH 1/8] wip --- .gitignore | 1 + main.py | 44 ++++++++++++++++++++++++++++++++++ nodezator/alphamask/basicop.py | 31 +++++++++++++++--------- nodezator/alphamask/utils.py | 13 +++++++--- nodezator/ourstdlibs/pyl.py | 2 +- 5 files changed, 76 insertions(+), 15 deletions(-) create mode 100644 .gitignore create mode 100644 main.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..cd0e1567 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/nodezator/logs diff --git a/main.py b/main.py new file mode 100644 index 00000000..6ca9a1c8 --- /dev/null +++ b/main.py @@ -0,0 +1,44 @@ +import sys +from nodezator import __main__ + +NATIVE_FILE_EXTENSION = '.ndz' + +print( __main__.main ) + +if __name__ == "__main__": + + ### parse arguments received, looking for a filepath + ### (or using None instead, a filepath wasn't provided) + + ## import argument parser + from argparse import ArgumentParser + + ## instantiate and configure it + + parser = ArgumentParser( + description = " - Python Node Editor" + ) + + parser.add_argument( + + 'filepath', + + type = str, + nargs = '?', + default = None, + + help = ( + "path of " + + NATIVE_FILE_EXTENSION + + " file to be loaded." + ) + ) + + ## parse arguments + args = parser.parse_args() + + + ### finally call the main function, passing along + ### the filepath argument received (which might be the + ### default, None) + __main__.main(args.filepath) diff --git a/nodezator/alphamask/basicop.py b/nodezator/alphamask/basicop.py index 60f0f65c..9b6255d5 100644 --- a/nodezator/alphamask/basicop.py +++ b/nodezator/alphamask/basicop.py @@ -30,10 +30,10 @@ class used as an extension for the AlphaMask class; stored anywhere, since we are only interested in its alpha values and size. -The masking operations carried out in this module are -different from the ones carried out by pygame.mask module -because pygame.mask only deals with bitmasks (a pixel is -either fully opaque or fully transparent), while the mask +The masking operations carried out in this module are +different from the ones carried out by pygame.mask module +because pygame.mask only deals with bitmasks (a pixel is +either fully opaque or fully transparent), while the mask operations here doesn't rely on bitmasks and work with pixels in all ranges of transparency, (fully opaque, fully transparent and partially transparent pixels). @@ -59,13 +59,13 @@ class used as an extension for the AlphaMask class; Technique 1 is best suited for usage in target surfaces which only have solid colors, that is, surfaces whose all alpha values equal 255. - + This is usually so because source surfaces usually have their visible area (or at least most of it) rendered with solid colors (alpha is 255) and when such values are applied in target surfaces with semitransparent areas such areas would then be rendered solid. - + In other words, if the target surface had alpha values different than 255, they would be reverted back to the full 255 alpha value, that is, the alpha of the source @@ -96,8 +96,8 @@ class used as an extension for the AlphaMask class; that the resulting alpha value is assigned to the target surface. - When such multiplications are carried out, the pixels of - the target surface whose alpha are multiplied by 0 + When such multiplications are carried out, the pixels of + the target surface whose alpha are multiplied by 0 become completely transparent. Naturally, the pixels whose alpha is multiplied by a number between 0 and 1 retain only a percentage of its original alpha value. @@ -124,7 +124,7 @@ class used as an extension for the AlphaMask class; In other words, this technique takes into account the original alpha values of the target surface. - + However, when dealing with target surfaces that only have solid colors, the first technique is preferable, since it achieves the same effect with less steps. @@ -137,8 +137,11 @@ class used as an extension for the AlphaMask class; from pygame import Rect, Surface -from pygame.surfarray import pixels_alpha - +try: + import numpy + from pygame.surfarray import pixels_alpha +except: + numpy = None ### class definition @@ -197,6 +200,9 @@ def mask_by_replacing(self, surf): ### the surface remains locked for the lifetime of ### this array (which is why we'll soon delete it ### once we don't need it anymore) + if numpy is None: + print(__file__,"204: pixels_alpha need numpy") + return surf_alpha_values = pixels_alpha(surf) ### iterate over the columns of full alpha values @@ -246,6 +252,9 @@ def mask_by_multiplying(self, surf): ### the surface remains locked for the lifetime of ### this array (which is why we'll soon delete it ### once we don't need it anymore) + if numpy is None: + print(__file__,"254: pixels_alpha need numpy") + return surf_alpha_values = pixels_alpha(surf) ### multiply the alpha of each pixel in the surface diff --git a/nodezator/alphamask/utils.py b/nodezator/alphamask/utils.py index c44c0aa9..c89450d2 100644 --- a/nodezator/alphamask/utils.py +++ b/nodezator/alphamask/utils.py @@ -24,7 +24,11 @@ from pygame import Rect -from pygame.surfarray import pixels_alpha +try: + import numpy + from pygame.surfarray import pixels_alpha +except: + numpy = None def size_from_alpha_values(alpha_values): @@ -124,7 +128,7 @@ def full_alpha_values_from_surface(surf): ========== surf (pygame.Surface instance) surface used as source of alpha values. - + How it works ============ @@ -133,7 +137,7 @@ def full_alpha_values_from_surface(surf): which represent columns of the source surface and hold the alpha value of each pixel in that column. - + To be more specific, the columns are listed from the leftmost to the rightmost pixel column of the source surface and the values within each column @@ -182,6 +186,9 @@ def full_alpha_values_from_surface(surf): ### method), but even when they would not (as with the ### mask_by_replacing() method), the differences ### observed in practice cannot be perceived by a human; + if numpy is None: + print(__file__,"190: pixels_alpha requires numpy") + return [[0]] return [ diff --git a/nodezator/ourstdlibs/pyl.py b/nodezator/ourstdlibs/pyl.py index 3f4629db..00daf359 100644 --- a/nodezator/ourstdlibs/pyl.py +++ b/nodezator/ourstdlibs/pyl.py @@ -14,7 +14,7 @@ def load_pyl(filepath): with open( str(filepath), mode='r', encoding='utf-8' ) as f: - + print(filepath) return literal_eval(f.read()) def save_pyl( From c1f524deaf31bf1ef19d20450fdd416eadff9db9 Mon Sep 17 00:00:00 2001 From: pmp-p Date: Wed, 13 Jul 2022 19:14:13 +0200 Subject: [PATCH 2/8] rel import 1/x --- main.py | 8 +-- nodezator/__main__.py | 8 ++- nodezator/alphamask/main.py | 18 +++--- nodezator/alphamask/masksop.py | 2 +- nodezator/classes2d/collections.py | 10 +-- nodezator/classes2d/single.py | 2 +- nodezator/colorsman/color2d.py | 14 ++--- nodezator/colorsman/colors.py | 8 +-- nodezator/colorsman/editor/loopop.py | 18 +++--- nodezator/colorsman/editor/main.py | 24 +++---- nodezator/colorsman/viewer/main.py | 36 +++++------ nodezator/colorsman/viewer/modes/colorlist.py | 38 ++++++------ .../colorsman/viewer/modes/patterns/main.py | 36 +++++------ .../viewer/modes/patterns/particles.py | 14 ++--- .../colorsman/viewer/modes/patterns/waves.py | 6 +- nodezator/dialog.py | 38 ++++++------ nodezator/editing/gridlogic.py | 18 +++--- nodezator/editing/main.py | 18 +++--- nodezator/editing/objinsert.py | 46 +++++++------- nodezator/fileman/bookmarkpanel/main.py | 38 ++++++------ nodezator/fileman/bookmarkpanel/surfs.py | 6 +- nodezator/fileman/constants.py | 2 +- nodezator/fileman/dirpanel/extraop.py | 6 +- nodezator/fileman/dirpanel/main.py | 62 +++++++++---------- nodezator/fileman/dirpanel/mouseop.py | 4 +- nodezator/fileman/dirpanel/newpathform.py | 34 +++++----- nodezator/fileman/dirpanel/surfs.py | 6 +- nodezator/fileman/main.py | 38 ++++++------ nodezator/fileman/op.py | 20 +++--- nodezator/fileman/pathobj.py | 24 +++---- nodezator/fileman/surfs.py | 6 +- nodezator/fontsman/cache.py | 10 +-- nodezator/fontsman/constants.py | 2 +- nodezator/graphman/callablenode/main.py | 18 +++--- nodezator/graphman/callablenode/preproc.py | 10 +-- nodezator/graphman/presets.py | 4 +- nodezator/graphman/widget/utils.py | 44 ++++++------- nodezator/htsl/codeblock.py | 14 ++--- nodezator/htsl/constants.py | 6 +- nodezator/htsl/creation.py | 50 +++++++-------- nodezator/htsl/image.py | 10 +-- nodezator/htsl/main.py | 54 ++++++++-------- nodezator/htsl/prep.py | 21 ++++--- nodezator/imagesman/cache.py | 14 ++--- nodezator/imagesman/render.py | 16 ++--- nodezator/logman/main.py | 10 +-- nodezator/loopman/exception.py | 2 +- nodezator/loopman/main.py | 10 +-- nodezator/mainloop.py | 18 +++--- nodezator/memoryman.py | 16 ++--- nodezator/our3rdlibs/behaviour.py | 8 +-- nodezator/our3rdlibs/button.py | 14 ++--- nodezator/our3rdlibs/grid/main.py | 10 +-- nodezator/our3rdlibs/grid/oop.py | 6 +- nodezator/our3rdlibs/userlogger.py | 2 +- nodezator/ourstdlibs/color/conversion.py | 6 +- nodezator/ourstdlibs/color/creation.py | 7 ++- nodezator/ourstdlibs/color/custom.py | 20 +++--- nodezator/ourstdlibs/color/property.py | 2 +- nodezator/ourstdlibs/color/utils.py | 12 ++-- nodezator/ourstdlibs/exceptionutils.py | 12 ++-- nodezator/ourstdlibs/stringutils.py | 2 +- nodezator/pygameconstants.py | 2 +- nodezator/recentfile.py | 4 +- nodezator/rectsman/main.py | 24 +++---- nodezator/surfdef.py | 18 +++--- nodezator/surfsman/cache.py | 12 ++-- nodezator/surfsman/draw.py | 22 +++---- nodezator/surfsman/icon.py | 11 ++-- nodezator/surfsman/render.py | 12 ++-- nodezator/syntaxman/syntaxes/comment.py | 12 ++-- nodezator/syntaxman/syntaxes/python/main.py | 26 ++++---- nodezator/syntaxman/syntaxes/python/utils.py | 10 +-- nodezator/syntaxman/utils.py | 24 +++---- nodezator/textman/cache.py | 18 +++--- nodezator/textman/editor/constants.py | 6 +- nodezator/textman/editor/cursor/main.py | 27 ++++---- .../textman/editor/cursor/modes/insert.py | 10 +-- .../textman/editor/cursor/modes/normal.py | 8 +-- nodezator/textman/editor/cursor/navigation.py | 12 ++-- nodezator/textman/editor/cursor/op.py | 12 ++-- nodezator/textman/editor/cursor/syntaxhigh.py | 26 ++++---- nodezator/textman/editor/line.py | 14 ++--- nodezator/textman/editor/main.py | 36 +++++------ nodezator/textman/entryedition/cursor.py | 10 +-- nodezator/textman/entryedition/line.py | 6 +- nodezator/textman/label/main.py | 14 ++--- nodezator/textman/render.py | 20 +++--- nodezator/textman/text.py | 11 ++-- nodezator/textman/viewer/constants.py | 6 +- nodezator/textman/viewer/main.py | 28 ++++----- nodezator/textman/viewer/op.py | 16 ++--- nodezator/textman/viewer/prep.py | 36 +++++------ nodezator/translation.py | 10 +-- nodezator/userprefsman/main.py | 16 ++--- nodezator/widget/checkbutton.py | 16 ++--- nodezator/widget/colorbutton.py | 36 +++++------ nodezator/widget/intfloatentry/main.py | 22 +++---- nodezator/widget/intfloatentry/modes.py | 24 +++---- nodezator/widget/intfloatentry/op.py | 12 ++-- nodezator/widget/literaldisplay.py | 46 +++++++------- nodezator/widget/literalentry.py | 24 +++---- nodezator/widget/optionmenu/creation.py | 8 +-- nodezator/widget/optionmenu/main.py | 22 +++---- nodezator/widget/optionmenu/op.py | 16 ++--- nodezator/widget/optiontray/creation.py | 16 ++--- nodezator/widget/optiontray/main.py | 18 +++--- nodezator/widget/optiontray/op.py | 6 +- nodezator/widget/stringentry.py | 34 +++++----- nodezator/widget/textdisplay.py | 60 +++++++++--------- nodezator/winman/main.py | 52 ++++++++-------- 111 files changed, 990 insertions(+), 979 deletions(-) diff --git a/main.py b/main.py index 6ca9a1c8..58ee053a 100644 --- a/main.py +++ b/main.py @@ -1,9 +1,8 @@ import sys -from nodezator import __main__ +import asyncio -NATIVE_FILE_EXTENSION = '.ndz' -print( __main__.main ) +NATIVE_FILE_EXTENSION = '.ndz' if __name__ == "__main__": @@ -41,4 +40,5 @@ ### finally call the main function, passing along ### the filepath argument received (which might be the ### default, None) - __main__.main(args.filepath) + from nodezator.mainloop import run_app + asyncio.run(run_app(args.filepath)) diff --git a/nodezator/__main__.py b/nodezator/__main__.py index 86d421bc..92e1ae57 100644 --- a/nodezator/__main__.py +++ b/nodezator/__main__.py @@ -10,6 +10,8 @@ """ ### standard library imports +import asyncio + from pathlib import Path from sys import path @@ -37,7 +39,7 @@ logger = get_new_logger(__name__) -def main(filepath=None): +async def main(filepath=None): """Launch application. Parameters @@ -69,7 +71,7 @@ def main(filepath=None): logger.info("Starting application session.") - run_app(filepath) + await run_app(filepath) logger.info("Finished application session.") @@ -110,4 +112,4 @@ def main(filepath=None): ### finally call the main function, passing along ### the filepath argument received (which might be the ### default, None) - main(args.filepath) + asyncio.run( main(args.filepath) ) diff --git a/nodezator/alphamask/main.py b/nodezator/alphamask/main.py index e0e7f924..43cd2204 100644 --- a/nodezator/alphamask/main.py +++ b/nodezator/alphamask/main.py @@ -15,7 +15,7 @@ described earlier. -Alpha Masking +Alpha Masking ============= Alpha masking here refers to the operation of using the @@ -55,10 +55,10 @@ pygame.Surface.convert_alpha(), but blitting has nothing to do with alpha masking. -Additionally, even if images without alpha channels were -loaded faster, which we haven't tested, such advantage -wouldn't be relevant to the masking out operations, which -are carried out several times during the lifetime of the +Additionally, even if images without alpha channels were +loaded faster, which we haven't tested, such advantage +wouldn't be relevant to the masking out operations, which +are carried out several times during the lifetime of the mask, whereas loading is only performed once. Furthermore, even if loading speed became an issue, @@ -71,9 +71,9 @@ ### local import -from imagesman.cache import IMAGE_SURFS_DB +from ..imagesman.cache import IMAGE_SURFS_DB -from alphamask.utils import ( +from .utils import ( size_from_alpha_values, unit_from_full_alpha_values, full_from_unit_alpha_values, @@ -82,8 +82,8 @@ ## class extensions -from alphamask.basicop import AlphaMaskBasicOperations -from alphamask.masksop import ( +from .basicop import AlphaMaskBasicOperations +from .masksop import ( AlphaMaskOperationsBetweenMasks ) diff --git a/nodezator/alphamask/masksop.py b/nodezator/alphamask/masksop.py index fc894e9c..f2d7d22b 100644 --- a/nodezator/alphamask/masksop.py +++ b/nodezator/alphamask/masksop.py @@ -41,7 +41,7 @@ class used as an extension for the AlphaMask class; ### local imports -from alphamask.utils import ( +from .utils import ( size_from_alpha_values, unit_from_full_alpha_values, full_from_unit_alpha_values, diff --git a/nodezator/classes2d/collections.py b/nodezator/classes2d/collections.py index 43c32f9f..97e731b5 100644 --- a/nodezator/classes2d/collections.py +++ b/nodezator/classes2d/collections.py @@ -10,12 +10,12 @@ ### local imports -from pygameconstants import ( +from ..pygameconstants import ( blit_on_screen, SCREEN_RECT, ) -from rectsman.main import ( +from ..rectsman.main import ( rect_property, RectsManager, ) @@ -52,7 +52,7 @@ def get_on_screen(self): def get_colliding(self, rect): """Return iterator of objects colliding w/ rect. - + rect (instance of pygame.Rect) """ return ( @@ -98,7 +98,7 @@ def get_clusters(self, *inflation): ### the rects in the cluster for cluster in self.rect.get_clusters(*inflation): - + yield [ rect_id_to_obj[id(rect)] for rect in cluster @@ -132,7 +132,7 @@ def mouse_method_on_collision(self, method_name, event): mouse interaction protocol used; here we use it to retrieve the position of the mouse when the first button was released. - + Check pygame.event module documentation on pygame website for more info about this event object. diff --git a/nodezator/classes2d/single.py b/nodezator/classes2d/single.py index 67a38e8b..5919e115 100644 --- a/nodezator/classes2d/single.py +++ b/nodezator/classes2d/single.py @@ -9,7 +9,7 @@ ### local imports -from pygameconstants import ( +from ..pygameconstants import ( SCREEN_RECT, blit_on_screen, ) diff --git a/nodezator/colorsman/color2d.py b/nodezator/colorsman/color2d.py index 0c6bfd84..20fa5985 100644 --- a/nodezator/colorsman/color2d.py +++ b/nodezator/colorsman/color2d.py @@ -6,19 +6,19 @@ ### local imports -from ourstdlibs.collections.general import FactoryDict +from ..ourstdlibs.collections.general import FactoryDict -from ourstdlibs.color.creation import get_contrasting_bw +from ..ourstdlibs.color.creation import get_contrasting_bw -from classes2d.single import Object2D +from ..classes2d.single import Object2D -from surfsman.draw import draw_checker_pattern -from surfsman.render import render_rect +from ..surfsman.draw import draw_checker_pattern +from ..surfsman.render import render_rect # TODO render_rect usage throughout the module should # probably be replaced by usage of the RECT_SURF_MAP # from surfsman/cache.py, which caches the surface; -from colorsman.colors import TRANSP_COLOR_A, TRANSP_COLOR_B +from .colors import TRANSP_COLOR_A, TRANSP_COLOR_B ### constant: contrasting color map @@ -69,7 +69,7 @@ class Color2D(Object2D): checkered pattern visible through the color's transparency to make the transparency apparent. """ - + ### class attribute containing a dictionary used to ### map a given size to a surface of that size with a ### checkered pattern diff --git a/nodezator/colorsman/colors.py b/nodezator/colorsman/colors.py index 1f482b28..86566cf6 100644 --- a/nodezator/colorsman/colors.py +++ b/nodezator/colorsman/colors.py @@ -2,17 +2,17 @@ ### local imports -from config import APP_COLORS_FILE +from ..config import APP_COLORS_FILE -from ourstdlibs.pyl import load_pyl +from ..ourstdlibs.pyl import load_pyl ### utility function def populate_locals_dict(locals_dict, obj): - + for key, value in obj.items(): - + locals_dict[key] = value if isinstance(value, dict): diff --git a/nodezator/colorsman/editor/loopop.py b/nodezator/colorsman/editor/loopop.py index e4697331..75108c84 100644 --- a/nodezator/colorsman/editor/loopop.py +++ b/nodezator/colorsman/editor/loopop.py @@ -20,15 +20,15 @@ ### local imports -from pygameconstants import SCREEN_RECT, blit_on_screen +from ...pygameconstants import SCREEN_RECT, blit_on_screen -from classes2d.single import Object2D +from ...classes2d.single import Object2D -from loopman.main import LoopHolder +from ...loopman.main import LoopHolder -from surfsman.cache import UNHIGHLIGHT_SURF_MAP +from ...surfsman.cache import UNHIGHLIGHT_SURF_MAP -from ourstdlibs.color.custom import custom_format_color +from ...ourstdlibs.color.custom import custom_format_color class LoopOperations(Object2D, LoopHolder): @@ -52,7 +52,7 @@ def edit_colors( provided by the user. The values provided by the user for those parameters - are relevant, though. Such actual values received + are relevant, though. Such actual values received are used when returning the value back at the end of the editing session, if the user doesn't cancel the editing session. @@ -232,7 +232,7 @@ def handle_input(self): ### pressed elif event.type == KEYDOWN: - + if event.key in (K_LEFT, K_a): self.colors_panel.go_left() @@ -269,7 +269,7 @@ def on_mouse_action(self, method_name, event): required in order to comply with mouse action protocol; - + Check pygame.event module documentation on pygame website for more info about this event object; @@ -302,7 +302,7 @@ def on_mouse_action(self, method_name, event): else: method(event) ## regardless of whether or not the object - ## had an operation retrieved and executed + ## had an operation retrieved and executed ## in the last clauses, break out of the ## "for loop" break diff --git a/nodezator/colorsman/editor/main.py b/nodezator/colorsman/editor/main.py index e3481b4c..fb07de23 100644 --- a/nodezator/colorsman/editor/main.py +++ b/nodezator/colorsman/editor/main.py @@ -2,27 +2,27 @@ ### local imports -from pygameconstants import SCREEN_RECT +from ...pygameconstants import SCREEN_RECT -from classes2d.single import Object2D +from ...classes2d.single import Object2D -from surfsman.draw import draw_border, draw_depth_finish -from surfsman.render import render_rect +from ...surfsman.draw import draw_border, draw_depth_finish +from ...surfsman.render import render_rect -from colorsman.colors import WINDOW_BG +from ...colorsman.colors import WINDOW_BG ## class extensions -from colorsman.editor.loopop import LoopOperations -from colorsman.editor.widgetop import WidgetOperations +from .loopop import LoopOperations +from .widgetop import WidgetOperations ## functions for injection -from colorsman.editor.widgetsetup.scale import setup_scales -from colorsman.editor.widgetsetup.button import setup_buttons -from colorsman.editor.widgetsetup.entry import setup_entries -from colorsman.editor.widgetsetup.label import setup_labels +from .widgetsetup.scale import setup_scales +from .widgetsetup.button import setup_buttons +from .widgetsetup.entry import setup_entries +from .widgetsetup.label import setup_labels ## class for composition @@ -34,7 +34,7 @@ class ColorsEditor( WidgetOperations, ): """loop holder to pick/edit color(s). - + This class is instantiated only once and its edit_colors() method is aliased to be used wherever needed in the entire package (look at the last lines diff --git a/nodezator/colorsman/viewer/main.py b/nodezator/colorsman/viewer/main.py index 1c5b8f64..d538d683 100644 --- a/nodezator/colorsman/viewer/main.py +++ b/nodezator/colorsman/viewer/main.py @@ -11,35 +11,35 @@ ### local imports -from pygameconstants import SCREEN_RECT +from ...pygameconstants import SCREEN_RECT -from ourstdlibs.meta import initialize_bases +from ...ourstdlibs.meta import initialize_bases -from ourstdlibs.collections.general import CallList +from ...ourstdlibs.collections.general import CallList -from ourstdlibs.behaviour import ( +from ...ourstdlibs.behaviour import ( empty_function, get_oblivious_callable, ) -from ourstdlibs.color.custom import custom_format_color +from ...ourstdlibs.color.custom import custom_format_color -from classes2d.single import Object2D -from classes2d.collections import List2D +from ...classes2d.single import Object2D +from ...classes2d.collections import List2D -from loopman.main import LoopHolder +from ...loopman.main import LoopHolder -from surfsman.draw import draw_border -from surfsman.render import render_rect +from ...surfsman.draw import draw_border +from ...surfsman.render import render_rect -from textman.render import render_text -from fontsman.constants import ENC_SANS_BOLD_FONT_HEIGHT +from ...textman.render import render_text +from ...fontsman.constants import ENC_SANS_BOLD_FONT_HEIGHT -from surfsman.icon import render_layered_icon +from ...surfsman.icon import render_layered_icon -from widget.optionmenu.main import OptionMenu +from ...widget.optionmenu.main import OptionMenu -from colorsman.colors import ( +from ...colorsman.colors import ( BLACK, WHITE, BUTTON_FG, BUTTON_BG, WINDOW_FG, WINDOW_BG, @@ -47,8 +47,8 @@ ## class extensions -from colorsman.viewer.modes.colorlist import ColorListMode -from colorsman.viewer.modes.patterns.main import PatternsMode +from .modes.colorlist import ColorListMode +from .modes.patterns.main import PatternsMode ### constants @@ -226,7 +226,7 @@ def change_mode(): self.buttons = List2D() self.buttons.extend((mode_options, go_back_button)) - + ### create a label for the colors viewer ## create and store a collection to store labels diff --git a/nodezator/colorsman/viewer/modes/colorlist.py b/nodezator/colorsman/viewer/modes/colorlist.py index 6b92641b..de44a4ee 100644 --- a/nodezator/colorsman/viewer/modes/colorlist.py +++ b/nodezator/colorsman/viewer/modes/colorlist.py @@ -18,31 +18,31 @@ ### local imports -from pygameconstants import blit_on_screen +from ....pygameconstants import blit_on_screen -from ourstdlibs.color.conversion import ( +from ....ourstdlibs.color.conversion import ( full_rgb_to_html_name, full_rgb_to_hex_string, ) -from classes2d.single import Object2D -from classes2d.collections import List2D +from ....classes2d.single import Object2D +from ....classes2d.collections import List2D -from loopman.exception import QuitAppException +from ....loopman.exception import QuitAppException -from surfsman.draw import draw_border -from surfsman.render import render_rect +from ....surfsman.draw import draw_border +from ....surfsman.render import render_rect -from textman.render import render_text +from ....textman.render import render_text -from fontsman.constants import ENC_SANS_BOLD_FONT_HEIGHT +from ....fontsman.constants import ENC_SANS_BOLD_FONT_HEIGHT -from colorsman.colors import ( +from ....colorsman.colors import ( COLOR_VIEWER_COLOR_LIST_FG, COLOR_VIEWER_COLOR_LIST_BG, ) -from colorsman.color2d import Color2D +from ....colorsman.color2d import Color2D ### size in pixels of the surfaces representing each color @@ -139,7 +139,7 @@ def create_color_list(self): full_rgb_to_html_name(color) ): - + # create and append the text object text_obj = \ @@ -224,14 +224,14 @@ def create_color_list(self): coordinates_name='topleft', coordinates_value=display_area.topleft ) - + self.color_list_clean = \ self.color_list_bg.image.copy() def color_list_event_handling(self): """Event handling for the color list mode.""" for event in get_events(): - + ### raise specific exception if user tries to ### quit the application @@ -243,21 +243,21 @@ def color_list_event_handling(self): ### key is released elif event.type == KEYUP: - + if event.key == K_ESCAPE: self.running = False ### if a mouse button is released... elif event.type == MOUSEBUTTONUP: - + ## if it is the left button, execute ## specific mouse action method if event.button == 1: self.color_list_on_mouse_release(event) - + ## if it is the mouse wheel being ## scrolled, scroll the list up or down @@ -370,13 +370,13 @@ def color_list_on_mouse_release(self, event): ### the mouse for button in self.buttons: - + ## if a button collides, execute its mouse ## release action if it has one, then break out ## of the "for loop" if button.rect.collidepoint(mouse_pos): - + try: method = getattr( button, 'on_mouse_release') diff --git a/nodezator/colorsman/viewer/modes/patterns/main.py b/nodezator/colorsman/viewer/modes/patterns/main.py index b7bbdb2f..27c53c0c 100644 --- a/nodezator/colorsman/viewer/modes/patterns/main.py +++ b/nodezator/colorsman/viewer/modes/patterns/main.py @@ -15,30 +15,30 @@ ### local imports -from pygameconstants import blit_on_screen +from .....pygameconstants import blit_on_screen -from ourstdlibs.behaviour import ( +from .....ourstdlibs.behaviour import ( empty_function, get_oblivious_callable) -from loopman.exception import QuitAppException +from .....loopman.exception import QuitAppException -from widget.optionmenu.main import OptionMenu +from .....widget.optionmenu.main import OptionMenu -from classes2d.single import Object2D +from .....classes2d.single import Object2D -from textman.render import render_text -from fontsman.constants import ENC_SANS_BOLD_FONT_HEIGHT +from .....textman.render import render_text +from .....fontsman.constants import ENC_SANS_BOLD_FONT_HEIGHT -from colorsman.colors import ( +from .....colorsman.colors import ( BUTTON_FG, BUTTON_BG, WINDOW_FG, WINDOW_BG) ## pattern drawing functions -from colorsman.viewer.modes.patterns.waves import draw_waves -from colorsman.viewer.modes.patterns.particles import( +from .waves import draw_waves +from .particles import( draw_circles) @@ -55,7 +55,7 @@ class PatternsMode: """Has operations to draw patterns from given colors.""" - + def __init__(self): """Create support objects for the patterns mode.""" ### create a "Pattern:" label to indicate the @@ -195,7 +195,7 @@ def redraw_pattern(self): ## and 'close' methods, respectively if isinstance(result, GeneratorType): - + self.update = result.__next__ self.close_generator = result.close @@ -249,7 +249,7 @@ def patterns_event_handling(self): Grab and process events from pygame.event.get. """ for event in get_events(): - + ### raise a specific exception if the user ### tries to quit the app if event.type == QUIT: raise QuitAppException @@ -259,7 +259,7 @@ def patterns_event_handling(self): ### setting the 'running' flag to False elif event.type == KEYUP: - + if event.key == K_ESCAPE: self.running = False @@ -268,10 +268,10 @@ def patterns_event_handling(self): ### method elif event.type == MOUSEBUTTONUP: - + if event.button == 1: self.color_list_on_mouse_release(event) - + def patterns_on_mouse_release(self, event): """Trigger exiting colors viewer or invoke button. @@ -306,9 +306,9 @@ def patterns_on_mouse_release(self, event): ## if a button collides, execute its mouse ## release action if it has one, then break out ## of the "for loop" - + if button.rect.collidepoint(mouse_pos): - + try: method = getattr( button, 'on_mouse_release') diff --git a/nodezator/colorsman/viewer/modes/patterns/particles.py b/nodezator/colorsman/viewer/modes/patterns/particles.py index 8ba3de12..67ae309a 100644 --- a/nodezator/colorsman/viewer/modes/patterns/particles.py +++ b/nodezator/colorsman/viewer/modes/patterns/particles.py @@ -16,9 +16,9 @@ ### local imports -from surfsman.draw import draw_linear_gradient +from .....surfsman.draw import draw_linear_gradient -from surfsman.icon import render_layered_icon +from .....surfsman.icon import render_layered_icon ### constant: standard distance between two points in @@ -190,7 +190,7 @@ def draw_particles(icon_ordinal, heights, canvas_surf, colors): for height in heights } - + ### calculate all spots (points) in a rect larger than ### the canvas which are distant from each other by the ### POINT_DISTANCE and offset by a random distance @@ -328,7 +328,7 @@ def draw_particles(icon_ordinal, heights, canvas_surf, colors): ## the last ones if other_colors: - + ## obtain a list representing a population of ## colors with colors repeating themselves in ## different proportions; @@ -367,7 +367,7 @@ def draw_particles(icon_ordinal, heights, canvas_surf, colors): heights, (all_spots, less_spots, even_less_spots) ): - + ## reference the dict with particle surfaces for ## each color locally, all surfaces being of the ## specified height @@ -383,9 +383,9 @@ def draw_particles(icon_ordinal, heights, canvas_surf, colors): ## canvas for spot in spot_samples: - + particle_surf = color_to_surfs[next_color()] - + canvas_surf.blit(particle_surf, spot) diff --git a/nodezator/colorsman/viewer/modes/patterns/waves.py b/nodezator/colorsman/viewer/modes/patterns/waves.py index cb92dfe8..b8de2c1b 100644 --- a/nodezator/colorsman/viewer/modes/patterns/waves.py +++ b/nodezator/colorsman/viewer/modes/patterns/waves.py @@ -9,9 +9,9 @@ ### local imports -from alphamask.main import AlphaMask +from .....alphamask.main import AlphaMask -from surfsman.draw import draw_linear_gradient +from .....surfsman.draw import draw_linear_gradient ### mask obtained from an image representing a wave @@ -78,7 +78,7 @@ def draw_waves(canvas_surf, colors): ## instance of the first color if other_colors: - + color_population = [] for color in other_colors: diff --git a/nodezator/dialog.py b/nodezator/dialog.py index 8c2976c6..8f73eedd 100644 --- a/nodezator/dialog.py +++ b/nodezator/dialog.py @@ -20,27 +20,27 @@ ### local imports -from translation import DIALOGS_MAP +from .translation import DIALOGS_MAP -from pygameconstants import SCREEN_RECT, blit_on_screen +from .pygameconstants import SCREEN_RECT, blit_on_screen -from classes2d.single import Object2D -from classes2d.collections import List2D +from .classes2d.single import Object2D +from .classes2d.collections import List2D -from loopman.main import LoopHolder +from .loopman.main import LoopHolder -from surfsman.draw import blit_aligned, draw_border -from surfsman.render import render_rect -from surfsman.icon import render_layered_icon +from .surfsman.draw import blit_aligned, draw_border +from .surfsman.render import render_rect +from .surfsman.icon import render_layered_icon -from textman.cache import CachedTextObject -from textman.render import render_text +from .textman.cache import CachedTextObject +from .textman.render import render_text -from fontsman.constants import ENC_SANS_BOLD_FONT_HEIGHT +from .fontsman.constants import ENC_SANS_BOLD_FONT_HEIGHT -from surfsman.cache import UNHIGHLIGHT_SURF_MAP +from .surfsman.cache import UNHIGHLIGHT_SURF_MAP -from colorsman.colors import ( +from .colorsman.colors import ( CONTRAST_LAYER_COLOR, @@ -110,7 +110,7 @@ ICON_MAP = { - level_name : + level_name : render_layered_icon( @@ -193,7 +193,7 @@ class DialogManager(Object2D, LoopHolder): """Prints a message box like in tkinter. - + This class is instantiated only once in the end of the module and its main method is aliased to be used wherever needed in the entire package. @@ -340,7 +340,7 @@ def create_and_show_dialog( ### to increase constrast between the dialog ### and whatever is behind it (making what's behind ### appear unhighlighted) - + ## if an object was received, draw it if unhighlighter_obj is not None: unhighlighter_obj.draw() @@ -425,7 +425,7 @@ def create_buttons( button_offset_by, ): """Create buttons for the dialog. - + Parameters ========== @@ -581,7 +581,7 @@ def handle_input(self): self.dismissable and event.type == KEYUP ): - + if event.key == K_ESCAPE: self.exit_dialog() @@ -668,7 +668,7 @@ def on_mouse_release(self, event): break else: - + if ( self.dismissable diff --git a/nodezator/editing/gridlogic.py b/nodezator/editing/gridlogic.py index 12127ea8..8034bd55 100644 --- a/nodezator/editing/gridlogic.py +++ b/nodezator/editing/gridlogic.py @@ -14,24 +14,24 @@ ### local imports -from config import APP_REFS +from ..config import APP_REFS -from pygameconstants import SCREEN, SCREEN_RECT +from ..pygameconstants import SCREEN, SCREEN_RECT -from dialog import create_and_show_dialog +from ..dialog import create_and_show_dialog -from ourstdlibs.collections.general import CallList +from ..ourstdlibs.collections.general import CallList -from ourstdlibs.behaviour import ( +from ..ourstdlibs.behaviour import ( empty_function, get_attribute_rotator, ) -from our3rdlibs.grid.oop import ScrollableGrid +from ..our3rdlibs.grid.oop import ScrollableGrid -from rectsman.main import RectsManager +from ..rectsman.main import RectsManager -from colorsman.colors import ( +from ..colorsman.colors import ( SMALL_GRID_COLOR, LARGE_GRID_COLOR, ) @@ -100,7 +100,7 @@ def scroll_grids(self, dx, dy): Integers representing amount of pixels to scroll in the x and y axes, respectively. """ - ### increment scrolling amount by the deltas + ### increment scrolling amount by the deltas self.scrolling_amount += (dx, dy) ### scroll each grid diff --git a/nodezator/editing/main.py b/nodezator/editing/main.py index b1eeaeb3..86109730 100644 --- a/nodezator/editing/main.py +++ b/nodezator/editing/main.py @@ -2,22 +2,22 @@ ### local imports -from config import APP_REFS +from ..config import APP_REFS -from ourstdlibs.meta import initialize_bases +from ..ourstdlibs.meta import initialize_bases ## class extensions -from editing.gridlogic import GridHandling -from editing.objinsert import ObjectInsertionRemoval -from editing.selection import SelectionHandling -from editing.reposition import Repositioning -from editing.export.main import Exporting -from editing.data import DataHandling +from .gridlogic import GridHandling +from .objinsert import ObjectInsertionRemoval +from .selection import SelectionHandling +from .reposition import Repositioning +from .export.main import Exporting +from .data import DataHandling ## more operations -from editing.categorycolors import ( +from .categorycolors import ( rebuild_category_color_form, change_category_colors, ) diff --git a/nodezator/editing/objinsert.py b/nodezator/editing/objinsert.py index 5d704a69..cf54ede7 100644 --- a/nodezator/editing/objinsert.py +++ b/nodezator/editing/objinsert.py @@ -9,29 +9,29 @@ ### local imports -from config import APP_REFS +from ..config import APP_REFS -from dialog import create_and_show_dialog +from ..dialog import create_and_show_dialog -from appinfo import NODES_KEY +from ..appinfo import NODES_KEY -from translation import TRANSLATION_HOLDER as t +from ..translation import TRANSLATION_HOLDER as t -from logman.main import get_new_logger +from ..logman.main import get_new_logger -from our3rdlibs.userlogger import USER_LOGGER +from ..our3rdlibs.userlogger import USER_LOGGER -from our3rdlibs.behaviour import indicate_unsaved +from ..our3rdlibs.behaviour import indicate_unsaved -from graphman.callablenode.main import CallableNode -from graphman.operatornode.main import OperatorNode -from graphman.builtinnode.main import BuiltinNode -from graphman.stlibnode.main import StandardLibNode -from graphman.capsulenode.main import CapsuleNode -from graphman.proxynode.main import ProxyNode -from graphman.textblock.main import TextBlock +from ..graphman.callablenode.main import CallableNode +from ..graphman.operatornode.main import OperatorNode +from ..graphman.builtinnode.main import BuiltinNode +from ..graphman.stlibnode.main import StandardLibNode +from ..graphman.capsulenode.main import CapsuleNode +from ..graphman.proxynode.main import ProxyNode +from ..graphman.textblock.main import TextBlock -from graphman.widget.picker.main import pick_widget +from ..graphman.widget.picker.main import pick_widget ### create logger for module @@ -122,7 +122,7 @@ def insert_node( """ ### assess which kind of argument was received in ### the node_hint parameter - + ## if we have a node instance, we just insert it if isinstance( @@ -187,7 +187,7 @@ def insert_node( (CapsuleNode, 'capsule_id'), ): - + if node_hint in cls.available_ids: node_data[key] = node_hint @@ -204,7 +204,7 @@ def insert_node( ## if we have a dict... elif isinstance(node_hint, dict): - + if 'signature_callable' in node_hint: ## gather data in a dict which will be @@ -268,7 +268,7 @@ def insert_node( return else: - + widget_data = deepcopy(node_hint) ## gather data in a dict which will be @@ -382,7 +382,7 @@ def insert_text_block( text_block_data=text_block_data, text_block_absolute_midtop=absolute_midtop ) - + ### otherwise, we know it is a text block instance, ### so we instead just insert it else: APP_REFS.gm.insert_text_block( @@ -417,7 +417,7 @@ def duplicate_selected(self): ## there's a new object on top of the original one for obj in self.selected_objs: - + if type(obj) is CallableNode: self.insert_node( @@ -469,7 +469,7 @@ def duplicate_selected(self): (CapsuleNode, 'capsule_id'), ): - + if type(obj) is cls: self.insert_node( @@ -538,7 +538,7 @@ def remove_selected(self): ### to its class for obj in self.selected_objs: - + if isinstance(obj, TextBlock): self.remove_text_block(obj) diff --git a/nodezator/fileman/bookmarkpanel/main.py b/nodezator/fileman/bookmarkpanel/main.py index f15ca309..5762a69f 100644 --- a/nodezator/fileman/bookmarkpanel/main.py +++ b/nodezator/fileman/bookmarkpanel/main.py @@ -17,30 +17,30 @@ ### local imports -from userprefsman.main import BOOKMARKS_FILE +from ...userprefsman.main import BOOKMARKS_FILE -from dialog import create_and_show_dialog +from ...dialog import create_and_show_dialog -from ourstdlibs.pyl import load_pyl, save_pyl +from ...ourstdlibs.pyl import load_pyl, save_pyl -from ourstdlibs.behaviour import get_oblivious_callable +from ...ourstdlibs.behaviour import get_oblivious_callable -from surfsman.draw import ( +from ...surfsman.draw import ( blit_aligned, draw_border, draw_depth_finish, ) -from surfsman.render import render_rect +from ...surfsman.render import render_rect -from classes2d.single import Object2D -from classes2d.collections import List2D +from ...classes2d.single import Object2D +from ...classes2d.collections import List2D -from colorsman.colors import BUTTON_BG +from ...colorsman.colors import BUTTON_BG -from fileman.pathobj import PathObject +from ..pathobj import PathObject -from fileman.constants import ( +from ..constants import ( PATH_OBJ_QUANTITY, PATH_OBJ_PADDING, BKM_PANEL_WIDTH, @@ -48,7 +48,7 @@ MAX_MSECS_TO_2ND_MOUSE_EVENT, ) -from fileman.bookmarkpanel.surfs import ( +from .surfs import ( BOOKMARK_BUTTON_SURF, UNBOOKMARK_BUTTON_SURF, ) @@ -58,7 +58,7 @@ class BookmarkPanel: def __init__(self, directory_panel, semitransp_obj): """Store argument and perform setups. - + Parameters ========== directory_panel (fileman.dirpanel.DirectoryPanel @@ -83,7 +83,7 @@ def __init__(self, directory_panel, semitransp_obj): ### create a rect attribute self.rect = Rect( - + ## position BKM_PANEL_TOPLEFT, @@ -170,7 +170,7 @@ def create_bookmark_objects(self): ### below the other for _ in range(PATH_OBJ_QUANTITY): - + ## instantiate (position is also set) path_obj = PathObject( @@ -267,7 +267,7 @@ def update_bookmark_objs_paths(self): ### a bookmark for index, path_obj in enumerate(self.bookmark_objs): - + try: path = self.bookmark_paths_deque[index] except IndexError: @@ -315,7 +315,7 @@ def check_live_bookmarks(self): ## but also has the side-effect of updating the ## json file too self.update_bookmarks() - + def draw(self): """Draw widgets.""" ### draw bookmark objects @@ -402,7 +402,7 @@ def scroll(self, up): ### pre-condition if up: - + ## if the first bookmark path is present in the ## first bookmark object, there's no point in ## scrolling up, so we just return @@ -418,7 +418,7 @@ def scroll(self, up): rotation_amount = 1 else: - + ## if the path in the last bookmark object is ## also the last bookmark path or None, there's ## no point in scrolling down, so we just return diff --git a/nodezator/fileman/bookmarkpanel/surfs.py b/nodezator/fileman/bookmarkpanel/surfs.py index 01ab8557..1e507096 100644 --- a/nodezator/fileman/bookmarkpanel/surfs.py +++ b/nodezator/fileman/bookmarkpanel/surfs.py @@ -5,12 +5,12 @@ ### local imports -from surfsman.icon import render_layered_icon +from ...surfsman.icon import render_layered_icon -from colorsman.colors import BLACK +from ...colorsman.colors import BLACK -BOOKMARK_BUTTON_SURF = render_layered_icon( +BOOKMARK_BUTTON_SURF = render_layered_icon( chars = [ chr(ordinal) for ordinal in (54, 55) ], diff --git a/nodezator/fileman/constants.py b/nodezator/fileman/constants.py index 8c92bb85..adf12ecf 100644 --- a/nodezator/fileman/constants.py +++ b/nodezator/fileman/constants.py @@ -1,6 +1,6 @@ """Constants for the file manager subpackage.""" -from fontsman.constants import ENC_SANS_BOLD_FONT_HEIGHT +from ..fontsman.constants import ENC_SANS_BOLD_FONT_HEIGHT FONT_HEIGHT = ENC_SANS_BOLD_FONT_HEIGHT # height of font in pixels diff --git a/nodezator/fileman/dirpanel/extraop.py b/nodezator/fileman/dirpanel/extraop.py index aead5b92..294c5af0 100644 --- a/nodezator/fileman/dirpanel/extraop.py +++ b/nodezator/fileman/dirpanel/extraop.py @@ -15,7 +15,7 @@ ### local import -from fileman.constants import PATH_OBJ_QUANTITY +from ..constants import PATH_OBJ_QUANTITY class ExtraOperations: @@ -63,7 +63,7 @@ def scroll(self, up): ## scroll up if up: - + ## if the first path is on the first path obj, ## then there's no further item above, so we ## return earlier to avoid scrolling @@ -77,7 +77,7 @@ def scroll(self, up): ## scroll down else: - + ## reference the path in the last path obj last_path = self.path_objs[-1].path diff --git a/nodezator/fileman/dirpanel/main.py b/nodezator/fileman/dirpanel/main.py index 2071f582..82084437 100644 --- a/nodezator/fileman/dirpanel/main.py +++ b/nodezator/fileman/dirpanel/main.py @@ -17,45 +17,35 @@ ### local imports -from pygameconstants import SCREEN +from ...pygameconstants import SCREEN -from dialog import create_and_show_dialog +from ...dialog import create_and_show_dialog -from ourstdlibs.behaviour import get_oblivious_callable +from ...ourstdlibs.behaviour import get_oblivious_callable -from surfsman.draw import ( +from ...surfsman.draw import ( blit_aligned, draw_border, draw_depth_finish, ) -from surfsman.render import render_rect +from ...surfsman.render import render_rect -from classes2d.single import Object2D -from classes2d.collections import List2D +from ...classes2d.single import Object2D +from ...classes2d.collections import List2D -from textman.label.main import Label +from ...textman.label.main import Label -from colorsman.colors import ( +from ...colorsman.colors import ( BUTTON_BG, NORMAL_PATH_FG, NORMAL_PATH_BG, ACTIVE_SELECTION_OUTLINE, ) -from fileman.pathobj import PathObject +from ..pathobj import PathObject -from fileman.dirpanel.newpathform import get_path - -from fileman.dirpanel.surfs import ( - HOME_BUTTON_SURF, - RELOAD_DIR_BUTTON_SURF, - PARENT_BUTTON_SURF, - NEW_FILE_BUTTON_SURF, - NEW_FOLDER_BUTTON_SURF, - ) - -from fileman.constants import ( +from ..constants import ( FONT_HEIGHT, PATH_OBJ_QUANTITY, PATH_OBJ_PADDING, @@ -64,11 +54,21 @@ DIR_PANEL_TOPLEFT, ) +from .newpathform import get_path + +from .surfs import ( + HOME_BUTTON_SURF, + RELOAD_DIR_BUTTON_SURF, + PARENT_BUTTON_SURF, + NEW_FILE_BUTTON_SURF, + NEW_FOLDER_BUTTON_SURF, + ) + ## class extensions -from fileman.dirpanel.loadop import LoadingOperations -from fileman.dirpanel.mouseop import MouseOperations -from fileman.dirpanel.extraop import ExtraOperations +from .loadop import LoadingOperations +from .mouseop import MouseOperations +from .extraop import ExtraOperations class DirectoryPanel( @@ -80,7 +80,7 @@ class DirectoryPanel( def __init__(self, file_manager): """Assign variables, perform setups. - + Parameters ========== file_manager (fileman.main.FileManager instance) @@ -302,7 +302,7 @@ def update_outline_rect(self): ### if a TypeError is raised, then it is None, ### in which case we set the outline rect to None except TypeError: self.outline_rect = None - + ### otherwise we check whether any of the path ### object holds that path @@ -337,7 +337,7 @@ def update_path_objects_paths(self): ### the paths deque (or None, if not available) for index, path_obj in enumerate(self.path_objs): - + try: path = self.paths_deque[index] except IndexError: path = None @@ -347,7 +347,7 @@ def update_path_objects_paths(self): def update_path_objs_appearance(self): """Update path objects to reflect selection state.""" for path_obj in self.path_objs: - + ### try retrieving the index of the path try: index = self.selectable_paths.index( path_obj.path) @@ -461,7 +461,7 @@ def get_selection(self): self.selection_states ) - ## if said selection state is True + ## if said selection state is True if selection_state ] @@ -508,7 +508,7 @@ def present_new_path_form(self, is_file): ### otherwise we proceed according to the requested ### action - + ## reference the action name and the new path action_name = form_data['action_name'] @@ -525,7 +525,7 @@ def present_new_path_form(self, is_file): self.fm.submit_selected() elif action_name == 'create_path': - + ## pick path creation operation according to ## kind of path chosen diff --git a/nodezator/fileman/dirpanel/mouseop.py b/nodezator/fileman/dirpanel/mouseop.py index 01f1cc40..c534d85e 100644 --- a/nodezator/fileman/dirpanel/mouseop.py +++ b/nodezator/fileman/dirpanel/mouseop.py @@ -9,7 +9,7 @@ ### local import -from fileman.constants import MAX_MSECS_TO_2ND_MOUSE_EVENT +from ..constants import MAX_MSECS_TO_2ND_MOUSE_EVENT class MouseOperations: @@ -205,7 +205,7 @@ def extend_selection(self, path_obj): ### selection among all the selected paths else: - + ## make it so the path of the given path obj ## is marked as selected diff --git a/nodezator/fileman/dirpanel/newpathform.py b/nodezator/fileman/dirpanel/newpathform.py index 037d217c..3e76755a 100644 --- a/nodezator/fileman/dirpanel/newpathform.py +++ b/nodezator/fileman/dirpanel/newpathform.py @@ -17,43 +17,43 @@ ### local imports -from translation import TRANSLATION_HOLDER as t +from ...translation import TRANSLATION_HOLDER as t -from pygameconstants import ( +from ...pygameconstants import ( SCREEN_RECT, FPS, maintain_fps, ) -from dialog import create_and_show_dialog +from ...dialog import create_and_show_dialog -from ourstdlibs.behaviour import empty_function +from ...ourstdlibs.behaviour import empty_function -from our3rdlibs.button import Button +from ...our3rdlibs.button import Button -from classes2d.single import Object2D -from classes2d.collections import List2D +from ...classes2d.single import Object2D +from ...classes2d.collections import List2D -from fontsman.constants import ENC_SANS_BOLD_FONT_HEIGHT -from textman.label.main import Label +from ...fontsman.constants import ENC_SANS_BOLD_FONT_HEIGHT +from ...textman.label.main import Label -from surfsman.draw import draw_border, draw_depth_finish -from surfsman.render import render_rect +from ...surfsman.draw import draw_border, draw_depth_finish +from ...surfsman.render import render_rect -from loopman.exception import ( +from ...loopman.exception import ( QuitAppException, SwitchLoopException, ) -from colorsman.colors import ( +from ...colorsman.colors import ( BUTTON_FG, BUTTON_BG, WINDOW_FG, WINDOW_BG) -from fileman.surfs import FILE_ICON, FOLDER_ICON +from .surfs import FILE_ICON, FOLDER_ICON ## widget -from widget.stringentry import StringEntry +from ...widget.stringentry import StringEntry ### XXX @@ -212,7 +212,7 @@ def build_form_widgets(self): ## improve surface style by giving a finish ## to convey depth draw_depth_finish(button.image) - + ## store in dedicated attribute setattr(self, attr_name, button) @@ -387,7 +387,7 @@ def mouse_method_on_collision(self, method_name, event): mouse interaction protocol used; here we use it to retrieve the position of the mouse when the first button was released. - + Check pygame.event module documentation on pygame website for more info about this event object. diff --git a/nodezator/fileman/dirpanel/surfs.py b/nodezator/fileman/dirpanel/surfs.py index 8a5abcea..9e6968e7 100644 --- a/nodezator/fileman/dirpanel/surfs.py +++ b/nodezator/fileman/dirpanel/surfs.py @@ -6,11 +6,11 @@ ### local imports -from surfsman.icon import render_layered_icon +from ...surfsman.icon import render_layered_icon -from surfsman.render import combine_surfaces +from ...surfsman.render import combine_surfaces -from colorsman.colors import BLACK +from ...colorsman.colors import BLACK diff --git a/nodezator/fileman/main.py b/nodezator/fileman/main.py index 8359ad04..b76ea3c1 100644 --- a/nodezator/fileman/main.py +++ b/nodezator/fileman/main.py @@ -12,30 +12,30 @@ ### local imports -from translation import TRANSLATION_HOLDER as t +from ..translation import TRANSLATION_HOLDER as t -from pygameconstants import SCREEN_RECT +from ..pygameconstants import SCREEN_RECT -from ourstdlibs.behaviour import ( +from ..ourstdlibs.behaviour import ( empty_function, get_oblivious_callable, ) -from surfsman.draw import draw_border -from surfsman.render import render_rect +from ..surfsman.draw import draw_border +from ..surfsman.render import render_rect -from surfsman.icon import render_layered_icon +from ..surfsman.icon import render_layered_icon -from widget.stringentry import StringEntry +from ..widget.stringentry import StringEntry -from classes2d.single import Object2D -from classes2d.collections import Set2D +from ..classes2d.single import Object2D +from ..classes2d.collections import Set2D -from textman.render import render_text +from ..textman.render import render_text -from textman.label.main import Label +from ..textman.label.main import Label -from colorsman.colors import ( +from ..colorsman.colors import ( BLACK, CONTRAST_LAYER_COLOR, NORMAL_PATH_FG, @@ -44,15 +44,15 @@ WINDOW_BG, WINDOW_FG, ) -from fileman.constants import FILEMAN_SIZE, FONT_HEIGHT +from .constants import FILEMAN_SIZE, FONT_HEIGHT ## class extension -from fileman.op import FileManagerOperations +from .op import FileManagerOperations ## classes for composition -from fileman.dirpanel.main import DirectoryPanel -from fileman.bookmarkpanel.main import BookmarkPanel +from .dirpanel.main import DirectoryPanel +from .bookmarkpanel.main import BookmarkPanel ### XXX for extra flexibility, the order in which some @@ -93,7 +93,7 @@ def __init__(self): ## control for storing current mode self.current_mode = None - + ## control for storing the path selection self.path_selection = [] @@ -176,7 +176,7 @@ def blit_static_surfs_on_image(self): ### also store the midright coordinates of the ### whole area occupied by the app objects ### defined above; - ### + ### ### it will be used as the midleft position of ### a label for custom captions which we'll create ### further ahead @@ -300,7 +300,7 @@ def build_labels(self): ) self.labels.add(self.widget_label) - + def instantiate_and_store_widgets(self): """Instantiate and store panels and other objects.""" ### instantiate directory panel diff --git a/nodezator/fileman/op.py b/nodezator/fileman/op.py index 8df04f54..07619a24 100644 --- a/nodezator/fileman/op.py +++ b/nodezator/fileman/op.py @@ -21,29 +21,29 @@ ### local imports -from translation import TRANSLATION_HOLDER as t +from ..translation import TRANSLATION_HOLDER as t -from pygameconstants import ( +from ..pygameconstants import ( SCREEN_RECT, FPS, maintain_fps, blit_on_screen, ) -from dialog import create_and_show_dialog +from ..dialog import create_and_show_dialog -from ourstdlibs.behaviour import ( +from ..ourstdlibs.behaviour import ( empty_function, get_oblivious_callable, ) -from loopman.exception import ( +from ..loopman.exception import ( SwitchLoopException, QuitAppException) -from surfsman.cache import UNHIGHLIGHT_SURF_MAP +from ..surfsman.cache import UNHIGHLIGHT_SURF_MAP -from classes2d.single import Object2D +from ..classes2d.single import Object2D class FileManagerOperations(Object2D): @@ -61,7 +61,7 @@ def browse_paths( This method shows the user the file manager interface, allowing the user to browse the filesystem visually while either: - + 1) in the 'select' mode: selecting paths to be returned; @@ -180,7 +180,7 @@ def set_mode(self, mode, path_name): else t.file_manager.new_path ) + ":" - + self.widget_label.set(widget_label_text) ### perform setups to guarantee the appropriate @@ -188,7 +188,7 @@ def set_mode(self, mode, path_name): ### to the choosen mode if mode == 'select': - + chosen_widget = self.selection_label self.labels.add(self.selection_label) diff --git a/nodezator/fileman/pathobj.py b/nodezator/fileman/pathobj.py index 9ce6876f..e177fe37 100644 --- a/nodezator/fileman/pathobj.py +++ b/nodezator/fileman/pathobj.py @@ -6,31 +6,31 @@ ### local imports -from translation import TRANSLATION_HOLDER as t +from ..translation import TRANSLATION_HOLDER as t -from pygameconstants import blit_on_screen +from ..pygameconstants import blit_on_screen -from appinfo import NATIVE_FILE_EXTENSION +from ..appinfo import NATIVE_FILE_EXTENSION -from ourstdlibs.behaviour import empty_function +from ..ourstdlibs.behaviour import empty_function -from surfsman.render import render_rect +from ..surfsman.render import render_rect -from textman.label.main import Label +from ..textman.label.main import Label -from colorsman.colors import ( +from ..colorsman.colors import ( NORMAL_PATH_FG, SELECTED_PATH_FG, NORMAL_PATH_BG, SELECTED_PATH_BG, ) -from fileman.surfs import ( +from .surfs import ( FILE_ICON, FOLDER_ICON, TEXT_ICON, PYTHON_ICON, IMAGE_ICON, FONT_ICON, AUDIO_ICON, VIDEO_ICON, PDF_ICON, NATIVE_FILE_ICON, ) -from fileman.constants import ( +from .constants import ( FONT_HEIGHT, PATH_OBJ_PARENT_TEXT, ) @@ -243,7 +243,7 @@ def create_visuals(self): max_width = label_max_width, **NORMAL_KWARGS ) - + self.selected_label = Label( text = self.text, max_width = label_max_width, @@ -299,11 +299,11 @@ def update_path(self, path, grandparent_path=None): ### if path is None, set the drawing behaviour to ### an empty function if path is None: drawing_behaviour = empty_function - + ### otherwise, if path isn't None... else: - + ## update text attribute and text in labels if ( diff --git a/nodezator/fileman/surfs.py b/nodezator/fileman/surfs.py index cb8824a7..7ea453f7 100644 --- a/nodezator/fileman/surfs.py +++ b/nodezator/fileman/surfs.py @@ -2,11 +2,11 @@ ### local imports -from surfsman.icon import render_layered_icon +from ..surfsman.icon import render_layered_icon -from imagesman.cache import IMAGE_SURFS_DB +from ..imagesman.cache import IMAGE_SURFS_DB -from colorsman.colors import BLACK, WHITE +from ..colorsman.colors import BLACK, WHITE FOLDER_ICON = render_layered_icon( diff --git a/nodezator/fontsman/cache.py b/nodezator/fontsman/cache.py index d35b65a9..d1354eac 100644 --- a/nodezator/fontsman/cache.py +++ b/nodezator/fontsman/cache.py @@ -23,7 +23,7 @@ ### local import -from fontsman.exception import UnattainableFontHeight +from .exception import UnattainableFontHeight @@ -32,7 +32,7 @@ class FontsDatabase(dict): Extends the built-in dict. """ - + def __missing__(self, key): """Create, store and return dict for given key. @@ -97,7 +97,7 @@ def get_font(font_path, desired_height): Since instantiating pygame.font.Font and using its 'size' method is very quick, this is fast enough as to not be noticeable. - + Furthermore, this is done only once per font and desired height, since the resulting font object is stored for future reference (as can be seen in @@ -114,7 +114,7 @@ def get_font(font_path, desired_height): instantiated with size 31 renders surfaces of height 35 and when instantiated with size 32 renders surfaces with height 37. - + In such case, we'll use the closest one which doesn't surpass the desired height, that is, the font with surfaces of height 35. @@ -157,7 +157,7 @@ def get_font(font_path, desired_height): ### "break" statement) while size not in attempted_sizes: - + ### create font and calculate the height of the ### surface of an arbitrary character (space) when ### rendered diff --git a/nodezator/fontsman/constants.py b/nodezator/fontsman/constants.py index 973eb0bb..62fb75cd 100644 --- a/nodezator/fontsman/constants.py +++ b/nodezator/fontsman/constants.py @@ -1,7 +1,7 @@ """Constants for fonts in the app.""" ### local import -from config import FONTS_DIR +from ..config import FONTS_DIR ### enc sans bold text diff --git a/nodezator/graphman/callablenode/main.py b/nodezator/graphman/callablenode/main.py index 0376f078..56382d17 100644 --- a/nodezator/graphman/callablenode/main.py +++ b/nodezator/graphman/callablenode/main.py @@ -2,27 +2,27 @@ ### local imports -from config import APP_REFS +from ...config import APP_REFS ## class extensions -from graphman.callablenode.preproc import Preprocessing +from .preproc import Preprocessing -from graphman.callablenode.vizprep.main import ( +from .vizprep.main import ( VisualRelatedPreparations ) -from graphman.callablenode.vizop.main import ( +from .vizop.main import ( VisualRelatedOperations ) -from graphman.callablenode.subparam.main import ( +from .subparam.main import ( SubparameterHandling ) -from graphman.callablenode.execution import Execution +from .execution import Execution -from graphman.callablenode.export import Exporting +from .export import Exporting class CallableNode( @@ -147,7 +147,7 @@ def __init__( ## the inspection is performed only once for each ## different signature callable. Thus, if another - ## node instance is created with the same + ## node instance is created with the same ## signature callable, it will use the already ## created data, shared through class attributes @@ -181,7 +181,7 @@ def __init__( self.midtop = ( midtop - if midtop is not None + if midtop is not None else self.data['midtop'] diff --git a/nodezator/graphman/callablenode/preproc.py b/nodezator/graphman/callablenode/preproc.py index fa7f72c6..ef44baa4 100644 --- a/nodezator/graphman/callablenode/preproc.py +++ b/nodezator/graphman/callablenode/preproc.py @@ -11,16 +11,16 @@ ### local imports -from config import APP_REFS +from ...config import APP_REFS -from graphman.presets import ( +from ...graphman.presets import ( PARAM_ANNOTATION_PRESET_MAP, OUTPUT_ANNOTATION_PRESET_MAP, ) -from graphman.widget.utils import get_widget_metadata +from ...graphman.widget.utils import get_widget_metadata -from graphman.validation.main import ( +from ...graphman.validation.main import ( check_return_annotation_mini_lang, ) @@ -266,7 +266,7 @@ def inspect_callable_object(self, signature_callable): ### list's items is a dictionary with ### metadata for an output; outputs_metadata = return_annotation - + ### populate the ordered output with the ### names (as keys) and types (as values) ### in the provided order diff --git a/nodezator/graphman/presets.py b/nodezator/graphman/presets.py index 16c536e2..54252338 100644 --- a/nodezator/graphman/presets.py +++ b/nodezator/graphman/presets.py @@ -4,7 +4,7 @@ from collections.abc import Iterator ### local import -from ourstdlibs.dictutils import flatten_keys +from ..ourstdlibs.dictutils import flatten_keys ## parameter annotation preset map @@ -76,7 +76,7 @@ }, ( - 'positive_int', + 'positive_int', 'positive_integer', ) : { diff --git a/nodezator/graphman/widget/utils.py b/nodezator/graphman/widget/utils.py index 861834a7..4416bff3 100644 --- a/nodezator/graphman/widget/utils.py +++ b/nodezator/graphman/widget/utils.py @@ -11,39 +11,39 @@ ## widgets -from widget.stringentry import StringEntry +from ...widget.stringentry import StringEntry -from widget.literalentry import LiteralEntry +from ...widget.literalentry import LiteralEntry -from widget.intfloatentry.main import ( +from ...widget.intfloatentry.main import ( ALLOWED_NUM_CLASSES, IntFloatEntry, ) -from widget.textdisplay import TextDisplay -from widget.literaldisplay import LiteralDisplay +from ...widget.textdisplay import TextDisplay +from ...widget.literaldisplay import LiteralDisplay -from widget.checkbutton import CheckButton -from widget.colorbutton import ColorButton -from widget.sortingbutton import SortingButton -from widget.defaultholder import DefaultHolder +from ...widget.checkbutton import CheckButton +from ...widget.colorbutton import ColorButton +from ...widget.sortingbutton import SortingButton +from ...widget.defaultholder import DefaultHolder -from widget.optionmenu.main import OptionMenu -from widget.optiontray.main import OptionTray +from ...widget.optionmenu.main import OptionMenu +from ...widget.optiontray.main import OptionTray -from widget.pathpreview.path import PathPreview -from widget.pathpreview.text import TextPreview -from widget.pathpreview.image import ImagePreview -from widget.pathpreview.audio import AudioPreview -from widget.pathpreview.video import VideoPreview -from widget.pathpreview.font import FontPreview +from ...widget.pathpreview.path import PathPreview +from ...widget.pathpreview.text import TextPreview +from ...widget.pathpreview.image import ImagePreview +from ...widget.pathpreview.audio import AudioPreview +from ...widget.pathpreview.video import VideoPreview +from ...widget.pathpreview.font import FontPreview ### XXX implement remaining widgets -### +### ### from our3rdlibs.range import Range -### +### ### from our3rdlibs.calenderclock import CalendarClock ### (CalendarClock has the functionality of all the ### date/time related widgets listed below (which weren't @@ -51,7 +51,7 @@ ### CalendarClock should be used isntead, once created) in ### this comment, including deltas; there is a design sketch ### on paper on 2020-02-14) -### +### ### from our3rdlibs.date import IsoDate ### from our3rdlibs.time import IsoTime ### from our3rdlibs.datetime import IsoDateTime @@ -137,7 +137,7 @@ def get_widget_metadata(annotation, default): if isinstance(annotation, dict) \ and annotation.get('widget_name'): - + ## alias the annotation as metadata metadata = annotation @@ -181,7 +181,7 @@ def get_widget_metadata(annotation, default): ### doing so if widget_name: - + ## handle int float entry specific requirements ## if widget name matches; ## diff --git a/nodezator/htsl/codeblock.py b/nodezator/htsl/codeblock.py index 68a1c5d1..782f5344 100644 --- a/nodezator/htsl/codeblock.py +++ b/nodezator/htsl/codeblock.py @@ -9,22 +9,22 @@ ### local imports -from classes2d.single import Object2D +from ..classes2d.single import Object2D -from surfsman.render import render_rect +from ..surfsman.render import render_rect -from textman.render import render_text, get_text_size +from ..textman.render import render_text, get_text_size -from textman.text import ( +from ..textman.text import ( get_normal_lines, get_highlighted_lines, ) -from syntaxman.exception import SyntaxMappingError +from ..syntaxman.exception import SyntaxMappingError -from syntaxman.utils import get_ready_theme +from ..syntaxman.utils import get_ready_theme -from htsl.constants import GENERAL_CODE_TEXT_SETTINGS +from .constants import GENERAL_CODE_TEXT_SETTINGS ### diff --git a/nodezator/htsl/constants.py b/nodezator/htsl/constants.py index 3d0e70b7..cac3f0e5 100644 --- a/nodezator/htsl/constants.py +++ b/nodezator/htsl/constants.py @@ -1,7 +1,7 @@ ### local imports -from fontsman.constants import ( +from ..fontsman.constants import ( NOTO_SANS_REGULAR_FONT_PATH, NOTO_SANS_BOLD_FONT_PATH, @@ -13,7 +13,7 @@ ) -from colorsman.colors import ( +from ..colorsman.colors import ( HTSL_GENERAL_TEXT_FG, HTSL_HEADING_TEXT_FG, @@ -103,7 +103,7 @@ HEADING_TO_FONT_HEIGHT = {} for i in range(1, 7): - + exec( f"""H{i}_FONT_HEIGHT = ( diff --git a/nodezator/htsl/creation.py b/nodezator/htsl/creation.py index 9850e1cf..ce9e720d 100644 --- a/nodezator/htsl/creation.py +++ b/nodezator/htsl/creation.py @@ -17,19 +17,19 @@ ### local imports -from classes2d.single import Object2D +from ..classes2d.single import Object2D -from classes2d.collections import List2D +from ..classes2d.collections import List2D -from textman.render import render_text +from ..textman.render import render_text -from textman.cache import CachedTextObject +from ..textman.cache import CachedTextObject -from rectsman.main import RectsManager +from ..rectsman.main import RectsManager -from surfsman.render import render_rect, unite_surfaces +from ..surfsman.render import render_rect, unite_surfaces -from colorsman.colors import ( +from ..colorsman.colors import ( HTSL_CANVAS_BG, HTSL_MARKED_TEXT_BG, @@ -39,7 +39,7 @@ ) -from htsl.constants import ( +from .constants import ( ANCHOR_TEXT_SETTINGS_MINUS_FG, @@ -56,7 +56,7 @@ ### class definitions class Anchor(Object2D): - + def __init__(self, surface, href): self.image = surface @@ -66,7 +66,7 @@ def __init__(self, surface, href): @classmethod def from_text(cls, text, href): - + return cls( render_text( @@ -149,7 +149,7 @@ def get_heading(heading, max_width): if heading.getAttribute('id'): heading_obj.id = heading.getAttribute('id') - + ### return heading_obj @@ -161,14 +161,14 @@ class TextBlock(List2D): def __init__(self, text_block, max_width): super().__init__() - + ELEMENT_NODE = text_block.ELEMENT_NODE TEXT_NODE = text_block.TEXT_NODE substrings_data = [] for child in text_block.childNodes: - + node_type = child.nodeType if node_type == TEXT_NODE: @@ -206,7 +206,7 @@ def __init__(self, text_block, max_width): tag_name = data.get('tag_name') if href: - + anchor_group = [] append_to_anchor_group = ( @@ -341,9 +341,9 @@ def __init__(self, text_block, max_width): else HTSL_ANCHOR_TEXT_FG ) - + for anchor in group: - + left = anchor.rect.left if left > last_left: @@ -391,9 +391,9 @@ def __init__(self, text_block, max_width): last_left = -1 same_line_marked.clear() - + for marked in group: - + left = marked.rect.left if left > last_left: @@ -424,9 +424,9 @@ def __init__(self, text_block, max_width): last_left = -1 same_line_linecut.clear() - + for linecut in group: - + left = linecut.rect.left if left > last_left: @@ -862,7 +862,7 @@ def strikethrough(surface): ) -class BlockQuote(List2D): +class BlockQuote(List2D): def __init__(self, blockquote, max_width): @@ -982,7 +982,7 @@ class Table(List2D): """ def __init__(self, table, max_width): - + unit_width = (max_width // 12) super().__init__() @@ -1033,7 +1033,7 @@ def __init__(self, table, max_width): text_blocks = [] for row in rows: - + cells = row.getElementsByTagName('th') if cells: @@ -1045,7 +1045,7 @@ def __init__(self, table, max_width): cells = row.getElementsByTagName('td') row_is_heading = False - + for column_rect, cell in ( zip(column_rects, cells) @@ -1083,7 +1083,7 @@ def __init__(self, table, max_width): zip(column_rects, text_blocks) ): - + text_block.rect.midleft = ( column_rect.x, row_rect.centery, diff --git a/nodezator/htsl/image.py b/nodezator/htsl/image.py index f4580611..590753d3 100644 --- a/nodezator/htsl/image.py +++ b/nodezator/htsl/image.py @@ -5,15 +5,15 @@ ### local imports -from classes2d.single import Object2D +from ..classes2d.single import Object2D -from classes2d.collections import List2D +from ..classes2d.collections import List2D -from surfdef import surfdef_obj_from_element +from ..surfdef import surfdef_obj_from_element -from surfsman.render import render_rect +from ..surfsman.render import render_rect -from colorsman.colors import HTSL_CANVAS_BG +from ..colorsman.colors import HTSL_CANVAS_BG HTSL_CACHE = {} diff --git a/nodezator/htsl/main.py b/nodezator/htsl/main.py index 047a4355..d9f414c8 100644 --- a/nodezator/htsl/main.py +++ b/nodezator/htsl/main.py @@ -43,27 +43,27 @@ ### local imports -from pygameconstants import SCREEN_RECT, blit_on_screen +from ..pygameconstants import SCREEN_RECT, blit_on_screen -from translation import APP_WIDE_WEB_DIR +from ..translation import APP_WIDE_WEB_DIR -from ourstdlibs.meta import initialize_bases +from ..ourstdlibs.meta import initialize_bases -from classes2d.single import Object2D +from ..classes2d.single import Object2D -from fontsman.constants import ENC_SANS_BOLD_FONT_PATH +from ..fontsman.constants import ENC_SANS_BOLD_FONT_PATH -from textman.label.main import Label +from ..textman.label.main import Label -from surfsman.icon import render_layered_icon +from ..surfsman.icon import render_layered_icon -from loopman.main import LoopHolder +from ..loopman.main import LoopHolder -from surfsman.render import render_rect +from ..surfsman.render import render_rect -from surfsman.cache import UNHIGHLIGHT_SURF_MAP +from ..surfsman.cache import UNHIGHLIGHT_SURF_MAP -from colorsman.colors import ( +from ..colorsman.colors import ( HTSL_BROWSER_BG, HTSL_CANVAS_BG, HTSL_DOCUMENT_TITLE_TEXT_FG, @@ -71,7 +71,7 @@ ) ## extension class -from htsl.prep import Preparation +from .prep import Preparation ### constants @@ -101,7 +101,7 @@ class HTSLBrowser(Object2D, Preparation, LoopHolder): HTSL means "HyperText as Surfaces" markup Language, which is just a xml file used to describe web-like pages to be rendered as pygame surfaces. - + This class is instantiated only once in the end of the module and its main method is aliased to be used wherever needed in the entire package. @@ -226,7 +226,7 @@ def create_and_show_htsl_page(self, htsl_element): self.show_htsl_page() def show_htsl_page(self, optional_id=''): - + ### define whether horizontal and vertical ### scrolling are enabled @@ -259,7 +259,7 @@ def show_htsl_page(self, optional_id=''): if optional_id: for obj in self.objs: - + obj_id = getattr(obj, 'id', '') if optional_id == obj_id: @@ -299,7 +299,7 @@ def resolve_htsl_path(self, path_string): start = path_string.find('.pysite') if start != -1: - + pysite = self.pysite = path_string[:start+7] path_string = path_string[start+8:] or 'index.htsl' @@ -337,7 +337,7 @@ def handle_events(self): if event.type == QUIT: self.quit() elif event.type == KEYUP: - + if event.key == K_ESCAPE: self.exit_loop() @@ -397,9 +397,9 @@ def on_mouse_release(self, event): ### iterate over objects for obj in self.objs: - + if obj.rect.collidepoint(mouse_pos): - + try: href = self.href except AttributeError: pass @@ -408,15 +408,15 @@ def on_mouse_release(self, event): self.open_link(href) break - + try: anchors = obj.anchor_list except AttributeError: pass else: - + for anchor in anchors: - + if anchor.rect.collidepoint(mouse_pos): self.open_link(anchor.href) @@ -454,14 +454,14 @@ def handle_keyboard_input(self): self.draw_once() def move_objs(self, x, y): - + objs_rect = self.objs.rect.copy() content_area = self.content_area_obj.rect if x and self.horizontal_scrolling_enabled: - + if x > 0: - + max_left = content_area.left resulting_left = objs_rect.move(x, 0).left @@ -482,7 +482,7 @@ def move_objs(self, x, y): if y and self.vertical_scrolling_enabled: if y > 0: - + max_top = content_area.top resulting_top = objs_rect.move(0, y).top @@ -530,7 +530,7 @@ def draw_once(self): for obj in self.objs: if obj.rect.colliderect(content_area): - + obj.draw_relative(content_area_obj) ### diff --git a/nodezator/htsl/prep.py b/nodezator/htsl/prep.py index 5a231442..81c3f4ed 100644 --- a/nodezator/htsl/prep.py +++ b/nodezator/htsl/prep.py @@ -6,13 +6,16 @@ ### local imports -from classes2d.collections import List2D +from ..classes2d.collections import List2D -from surfdef import surfdef_obj_from_element +from ..surfdef import surfdef_obj_from_element -from htsl.constants import KNOWN_TAGS +from ..colorsman.colors import HTSL_CANVAS_BG -from htsl.creation import ( + +from .constants import KNOWN_TAGS + +from .creation import ( TextBlock, BlockQuote, @@ -25,11 +28,11 @@ ) -from htsl.image import get_image_obj +from .image import get_image_obj + +from .codeblock import get_python_codeblock -from htsl.codeblock import get_python_codeblock -from colorsman.colors import HTSL_CANVAS_BG class Preparation: @@ -75,7 +78,7 @@ def handle_body(self, body): ELEMENT_NODE = body.ELEMENT_NODE for child in body.childNodes: - + if child.nodeType != ELEMENT_NODE: continue tag_name = child.tagName.lower() @@ -125,7 +128,7 @@ def handle_body(self, body): ) elif tag_name == 'img': - + resource_path = ( self.resolve_htsl_path( child.getAttribute('src') diff --git a/nodezator/imagesman/cache.py b/nodezator/imagesman/cache.py index 7b7c4d07..dc7880b6 100644 --- a/nodezator/imagesman/cache.py +++ b/nodezator/imagesman/cache.py @@ -40,16 +40,16 @@ ### local imports -from config import IMAGES_DIR +from ..config import IMAGES_DIR -from classes2d.single import Object2D +from ..classes2d.single import Object2D -from ourstdlibs.dictutils import ( +from ..ourstdlibs.dictutils import ( settings_to_hashable_repr, hashable_repr_to_settings, ) -from imagesman.render import render_image_from_original +from .render import render_image_from_original ORIGINAL_IMAGE_SURFS_MAP = {} @@ -60,7 +60,7 @@ class ImageSurfacesDatabase(dict): Extends the built-in dict. """ - + def __missing__(self, key): """Create, store and return dict for given key. @@ -176,7 +176,7 @@ def __init__( ### XXX what to do about resizing and ### repositioning after using methods below? - + def change_image_settings(self, image_settings): """Change image settings and replace surface. @@ -206,7 +206,7 @@ def change_image_path(self, image_path): self.image_path = image_path -### +### def update_cache_for_image(image_path): diff --git a/nodezator/imagesman/render.py b/nodezator/imagesman/render.py index 8a4cd835..1fd8e2b5 100644 --- a/nodezator/imagesman/render.py +++ b/nodezator/imagesman/render.py @@ -18,17 +18,17 @@ ### local imports -from surfsman.draw import ( +from ..surfsman.draw import ( blit_aligned, draw_checker_pattern, draw_not_found_icon, ) -from surfsman.render import render_rect +from ..surfsman.render import render_rect -from our3rdlibs.userlogger import USER_LOGGER +from ..our3rdlibs.userlogger import USER_LOGGER -from colorsman.colors import ( +from ..colorsman.colors import ( IMAGE_NOT_FOUND_FG, IMAGE_NOT_FOUND_BG, TRANSP_IMAGE_A, @@ -98,7 +98,7 @@ def render_image_from_original( ## image has alpha or not try: - + surf = original_image_surfs_map[image_path] = ( load_image(image_path).convert_alpha() @@ -209,7 +209,7 @@ def render_image_from_original( ### must be kept or not) if background_width and background_height: - + bg_surf = render_rect( background_width, background_height, @@ -251,7 +251,7 @@ def get_final_size( height = max(min_height, min(max_height, height)) if (width, height) != (actual_width, actual_height): - + ## adjust width and height if the size ratio must ## be kept @@ -265,5 +265,5 @@ def get_final_size( ).fit( 0, 0, width, height ).size - + return (width, height) diff --git a/nodezator/logman/main.py b/nodezator/logman/main.py index 7f7d9752..83aafd38 100644 --- a/nodezator/logman/main.py +++ b/nodezator/logman/main.py @@ -28,7 +28,7 @@ ### local imports -from appinfo import TITLE, APP_VERSION +from ..appinfo import TITLE, APP_VERSION ### constants @@ -52,25 +52,25 @@ BACKUP_COUNT = 30 ## maximum size in bytes of the log files; -## +## ## whenever a log file gets close to this size, a new log ## file replaces it and it becomes a rotated file (called ## a backup log) and its contents are rotated (transfered) ## through a log file backup hierarchy; -## +## ## bear in mind, however, that we mean to keep each log ## file containing only records for a single run of the ## software whenever possible and this size limit was ## provided just for safety, to prevent the log to grow ## indefinitely large in case something goes wrong; -## +## ## that's why we use a value purposefully higher than what ## we expect a common session to produce in size, though we ## don't have data enough to determine such number ## accurately; thus, this value will be adjusted in the ## future when we have enough data to decide on a value ## closer to reality; -## +## ## however, even if a log file reaches its limit and ## rotates, thereby no longer representing a full session ## (since new records for the current session will still diff --git a/nodezator/loopman/exception.py b/nodezator/loopman/exception.py index 17e15867..f981cd6e 100644 --- a/nodezator/loopman/exception.py +++ b/nodezator/loopman/exception.py @@ -1,7 +1,7 @@ """Loop management exceptions.""" ### local import -from config import APP_REFS +from ..config import APP_REFS class SwitchLoopException(Exception): diff --git a/nodezator/loopman/main.py b/nodezator/loopman/main.py index 6920e2d8..b25e2edb 100644 --- a/nodezator/loopman/main.py +++ b/nodezator/loopman/main.py @@ -11,9 +11,9 @@ ### local imports -from pygameconstants import FPS, maintain_fps +from ..pygameconstants import FPS, maintain_fps -from loopman.exception import ( +from .exception import ( ContinueLoopException, SwitchLoopException, QuitAppException, @@ -23,7 +23,7 @@ class LoopHolder: def loop(self): - + ### if loop hold doesn't have a 'draw' method, ### assign pygame.display.update to the ### attribute @@ -40,11 +40,11 @@ def loop(self): self.running = True while self.running: - + maintain_fps(FPS) try: - + loop_holder.handle_input() loop_holder.update() loop_holder.draw() diff --git a/nodezator/mainloop.py b/nodezator/mainloop.py index 25e544c2..c2a0c409 100644 --- a/nodezator/mainloop.py +++ b/nodezator/mainloop.py @@ -11,15 +11,15 @@ ### local imports and provisional screen filling -from config import APP_REFS +from .config import APP_REFS -from pygameconstants import ( +from .pygameconstants import ( SCREEN, FPS, maintain_fps, ) -from colorsman.colors import WINDOW_BG +from .colorsman.colors import WINDOW_BG ## before going on, fill the screen with the window @@ -34,22 +34,22 @@ update() -from logman.main import get_new_logger +from .logman.main import get_new_logger -from our3rdlibs.behaviour import ( +from .our3rdlibs.behaviour import ( are_changes_saved, remove_buffer, ) -from loopman.exception import ( +from .loopman.exception import ( ContinueLoopException, SwitchLoopException, QuitAppException, ) -from dialog import show_dialog_from_key +from .dialog import show_dialog_from_key -from winman.main import perform_startup_preparations +from .winman.main import perform_startup_preparations ### create logger for module @@ -128,7 +128,7 @@ def run_app(filepath=None): logger.info("User tried closing the app.") - ## if changes are not saved, ask user what to do + ## if changes are not saved, ask user what to do if not are_changes_saved(): diff --git a/nodezator/memoryman.py b/nodezator/memoryman.py index d60e226a..642ea450 100644 --- a/nodezator/memoryman.py +++ b/nodezator/memoryman.py @@ -6,17 +6,17 @@ ### local imports -from config import APP_REFS +from .config import APP_REFS -from ourstdlibs.treeutils import yield_tree_attrs +from .ourstdlibs.treeutils import yield_tree_attrs -from our3rdlibs.userlogger import USER_LOGGER +from .our3rdlibs.userlogger import USER_LOGGER -from widget.optionmenu.main import OptionMenu +from .widget.optionmenu.main import OptionMenu -from widget.optiontray.main import OptionTray +from .widget.optiontray.main import OptionTray -from textman.cache import TEXT_SURFS_DB +from .textman.cache import TEXT_SURFS_DB def free_up_memory(): @@ -63,7 +63,7 @@ def free_up_memory(): ### the lists holding them) for menu in menus: - + ## obtain an iterator which yields lists of children ## held by the menu @@ -103,7 +103,7 @@ def free_up_memory(): 'category_index_map', 'custom_stdout_lines', ): - + obj = getattr(APP_REFS, attr_name) obj.clear() diff --git a/nodezator/our3rdlibs/behaviour.py b/nodezator/our3rdlibs/behaviour.py index fe4ea89d..e70d8ef2 100644 --- a/nodezator/our3rdlibs/behaviour.py +++ b/nodezator/our3rdlibs/behaviour.py @@ -10,13 +10,13 @@ ### local imports -from config import APP_REFS +from ..config import APP_REFS -from pygameconstants import _CLOCK +from ..pygameconstants import _CLOCK -from loopman.exception import QuitAppException +from ..loopman.exception import QuitAppException -from translation import STATUS_MESSAGES_MAP +from ..translation import STATUS_MESSAGES_MAP ### utility functions diff --git a/nodezator/our3rdlibs/button.py b/nodezator/our3rdlibs/button.py index ee0c2325..ff46bf90 100644 --- a/nodezator/our3rdlibs/button.py +++ b/nodezator/our3rdlibs/button.py @@ -2,19 +2,19 @@ ### local imports -from ourstdlibs.behaviour import empty_function +from ..ourstdlibs.behaviour import empty_function -from classes2d.single import Object2D +from ..classes2d.single import Object2D -from imagesman.cache import IMAGE_SURFS_DB +from ..imagesman.cache import IMAGE_SURFS_DB -from textman.render import render_text +from ..textman.render import render_text -from fontsman.constants import ( +from ..fontsman.constants import ( ENC_SANS_BOLD_FONT_HEIGHT, ENC_SANS_BOLD_FONT_PATH) -from colorsman.colors import BUTTON_FG, BUTTON_BG +from ..colorsman.colors import BUTTON_FG, BUTTON_BG ### XXX needs lots of refactoring and implementing @@ -88,7 +88,7 @@ def on_mouse_release(self, event): used; can be used to retrieve the mouse position when release, for instance, if the information is needed. - + Check pygame.event module documentation on pygame website for more info about this event object. diff --git a/nodezator/our3rdlibs/grid/main.py b/nodezator/our3rdlibs/grid/main.py index fd058ede..55359ab4 100644 --- a/nodezator/our3rdlibs/grid/main.py +++ b/nodezator/our3rdlibs/grid/main.py @@ -8,8 +8,8 @@ ### local imports -from pygameconstants import SCREEN_RECT -from ourstdlibs.mathutils import get_reaching_multiple +from ...pygameconstants import SCREEN_RECT +from ...ourstdlibs.mathutils import get_reaching_multiple def enforce_multiple(unit_rect, area_rect): @@ -137,7 +137,7 @@ def generate_grid_lines( if separate_orientation: return horiz_lines, vert_lines ### otherwise, return a concatenated single list - else: return horiz_lines + vert_lines + else: return horiz_lines + vert_lines def move_grid_lines_along_axis( lines, axis_name, delta, unit_rect, area_rect): @@ -163,7 +163,7 @@ def move_grid_lines_along_axis( moved by the exact amount, but rather by the remainder of such amount in relation to the respective unit rect dimension (width for x axis and height for y axis). - + This is because lines which go out of the grid area are 'warped' to the opposite side of the grid area as to appear that the grid is moving indefinitely, thus @@ -183,7 +183,7 @@ def move_grid_lines_along_axis( 5, 50 or 500 units (try using the rotate method of the deque), the integer 1 always end up in the same position. - + Also try rotating it by 1 unit and then by 6 units. It always end up only "walking" one position, right? Thus, in the end, if you use the remainder of the diff --git a/nodezator/our3rdlibs/grid/oop.py b/nodezator/our3rdlibs/grid/oop.py index 6204a3f1..5a9529a3 100644 --- a/nodezator/our3rdlibs/grid/oop.py +++ b/nodezator/our3rdlibs/grid/oop.py @@ -8,12 +8,12 @@ ### local imports -from pygameconstants import ( +from ...pygameconstants import ( SCREEN, SCREEN_RECT, ) -from our3rdlibs.grid.main import ( +from ...our3rdlibs.grid.main import ( enforce_multiple, generate_grid_lines, move_grid_lines_along_axis, @@ -53,7 +53,7 @@ def __init__( Width of grid lines in pixels. color 3-tuple of integers representing red, green and - blue values respectively, from 0 to 255. List or + blue values respectively, from 0 to 255. List or pygame.Color instance are also allowed. unit_rect pygame.Rect instance representing an unit in the diff --git a/nodezator/our3rdlibs/userlogger.py b/nodezator/our3rdlibs/userlogger.py index a4630b9a..e8318080 100644 --- a/nodezator/our3rdlibs/userlogger.py +++ b/nodezator/our3rdlibs/userlogger.py @@ -10,7 +10,7 @@ ### local import -from ourstdlibs.timeutils import get_friendly_time +from ..ourstdlibs.timeutils import get_friendly_time ### constants diff --git a/nodezator/ourstdlibs/color/conversion.py b/nodezator/ourstdlibs/color/conversion.py index 9993bfa5..e8dbe344 100644 --- a/nodezator/ourstdlibs/color/conversion.py +++ b/nodezator/ourstdlibs/color/conversion.py @@ -15,12 +15,12 @@ ### local imports -from ourstdlibs.color.largemaps import ( +from ...ourstdlibs.color.largemaps import ( HTML_COLOR_MAP, PYGAME_COLOR_MAP, ) -from ourstdlibs.color.constants import ( +from ...ourstdlibs.color.constants import ( RGBA_FACTOR, HLS_FACTORS, HSV_FACTORS, @@ -290,7 +290,7 @@ def full_rgb_to_color_name(color_map, full_rgba): ### color, returning the corresponding name in such case for name, value in color_map.items(): - + if color == value: return name ### if no name is found instead, we return the 'unamed' diff --git a/nodezator/ourstdlibs/color/creation.py b/nodezator/ourstdlibs/color/creation.py index 7ab62b3b..3f6cd23d 100644 --- a/nodezator/ourstdlibs/color/creation.py +++ b/nodezator/ourstdlibs/color/creation.py @@ -3,6 +3,8 @@ from random import choice + + from colorsys import ( rgb_to_hls, hls_to_rgb, @@ -12,8 +14,9 @@ yiq_to_rgb, ) +### local -from ourstdlibs.color.constants import ( +from ..color.constants import ( HLS_FACTORS, HSV_FACTORS, HLS_NAMES, @@ -166,7 +169,7 @@ def random_color_from_existing(color, property_to_randomize): ### randomize is 'luma' (the 'Y' of the YIQ model) elif property_to_randomize == 'luma': - + ## convert from unit rgb to yiq values y, i, q = rgb_to_yiq(*unit_rgb) diff --git a/nodezator/ourstdlibs/color/custom.py b/nodezator/ourstdlibs/color/custom.py index 28e9217f..08b369eb 100644 --- a/nodezator/ourstdlibs/color/custom.py +++ b/nodezator/ourstdlibs/color/custom.py @@ -6,20 +6,20 @@ ### local imports -from ourstdlibs.color.property import get_saturation +from ...ourstdlibs.color.property import get_saturation -from ourstdlibs.color.utils import ( +from ...ourstdlibs.color.utils import ( map_colors_by_hue, sort_colors_by_luma, validate_hex_color_string, ) -from ourstdlibs.color.conversion import ( +from ...ourstdlibs.color.conversion import ( hex_string_to_full_rgb, full_rgb_to_hex_string, ) -from ourstdlibs.iterutils import separate_by_condition +from ...ourstdlibs.iterutils import separate_by_condition ### formatting related functions @@ -79,7 +79,7 @@ def get_custom_color_format_info(color_value): ### a tuple if isinstance(color_value, tuple): - + ## if all items are integers within a valid range ## and the length is either 3 or 4, we have a valid ## color representation, so we return its info @@ -186,7 +186,7 @@ def custom_format_color( ### to rgb(a) colors if color_format == 'rgb_tuple' and 'hex' in format_name: - + color_value = tuple( hex_string_to_full_rgb(item) for item in color_value @@ -240,7 +240,7 @@ def validate_custom_color_format( if color_format == 'rgb_tuple' \ and 'rgb' not in format_name: - + raise TypeError( "since the 'color_format' argument" " was set to 'rgb_tuple', individual" @@ -348,7 +348,7 @@ def get_custom_sorted_colors(colors): function to use as the key of list.sort or the "sorted" built-in function, instead of returning a new list as we in this function. - + However I think presenting the steps as done in this function makes it easier to understand and maintain this function. @@ -490,7 +490,7 @@ def get_custom_sorted_colors(colors): # ### which is the lightness # # else: -# +# # ### create an enumeration which we'll use as # ### provide of pairs comprised by an arbitrary # ### hue index greater than 1 and the range of @@ -498,7 +498,7 @@ def get_custom_sorted_colors(colors): # enumeration = enumerate( # HUE_SETS_MAP.values(), start=1 # ) -# +# # ### if the color's hue is within the given range, # ### break out of the "for loop" so that the # ### hue_index variable keep representing the diff --git a/nodezator/ourstdlibs/color/property.py b/nodezator/ourstdlibs/color/property.py index e3c0329f..ede3a8fa 100644 --- a/nodezator/ourstdlibs/color/property.py +++ b/nodezator/ourstdlibs/color/property.py @@ -2,7 +2,7 @@ ### local imports -from ourstdlibs.color.conversion import ( +from ...ourstdlibs.color.conversion import ( full_rgb_to_hls, full_rgb_to_hsv, full_to_unit_rgba, diff --git a/nodezator/ourstdlibs/color/utils.py b/nodezator/ourstdlibs/color/utils.py index e0a284dd..d7f2ab8f 100644 --- a/nodezator/ourstdlibs/color/utils.py +++ b/nodezator/ourstdlibs/color/utils.py @@ -11,16 +11,16 @@ ### local imports -from ourstdlibs.iterutils import get_type_yielder +from ...ourstdlibs.iterutils import get_type_yielder -from ourstdlibs.color.largemaps import ( +from ...ourstdlibs.color.largemaps import ( HTML_COLOR_MAP, PYGAME_COLOR_MAP, ) -from ourstdlibs.color.constants import HUE_SETS_MAP +from ...ourstdlibs.color.constants import HUE_SETS_MAP -from ourstdlibs.color.property import ( +from ...ourstdlibs.color.property import ( PROPERTY_GETTER_MAP, get_hue, ) @@ -54,7 +54,7 @@ def validate_hex_color_string(hex_string): ### before continuing, make string all lowercase hex_string = hex_string.lower() - + ### characters must all be characters used in ### hexadecimal representations @@ -132,7 +132,7 @@ def get_int_sequence_repr(values): + ', '.join( str(value).rjust(3, ' ') for value in values - ) + ) ### closing square bracket + ']' diff --git a/nodezator/ourstdlibs/exceptionutils.py b/nodezator/ourstdlibs/exceptionutils.py index e5ac6519..4957fc51 100644 --- a/nodezator/ourstdlibs/exceptionutils.py +++ b/nodezator/ourstdlibs/exceptionutils.py @@ -1,7 +1,7 @@ """Facility for exception related utilities.""" ### local imports -from ourstdlibs.behaviour import ( +from ..ourstdlibs.behaviour import ( return_untouched, get_decorator_from_wrapper) @@ -24,7 +24,7 @@ def bool_func_from_raiser( Used when you have a function which raises exceptions under certain conditions and want to replace it with a boolean function. - + The replacement function works in such manner that if an expected exception is thrown, it is caught and the execution proceeds normally until None is returned and, @@ -126,7 +126,7 @@ def didnt_raise_expected(*args, **kwargs): ## preformated or not else: - + ## grab exception message raw_msg = ( @@ -155,7 +155,7 @@ def didnt_raise_expected(*args, **kwargs): ### if no exception is raised, though, we just ### return True else: return True - + ### return defined function return didnt_raise_expected @@ -292,7 +292,7 @@ def raise_another_exception(*args, **kwargs): ## preformated or not else: - + ## grab exception message raw_msg = ( @@ -336,7 +336,7 @@ def raise_another_exception(*args, **kwargs): ### otherwise we just return the output else: return output - + ### return defined function return raise_another_exception diff --git a/nodezator/ourstdlibs/stringutils.py b/nodezator/ourstdlibs/stringutils.py index 01c67226..868e885e 100644 --- a/nodezator/ourstdlibs/stringutils.py +++ b/nodezator/ourstdlibs/stringutils.py @@ -9,7 +9,7 @@ ### local import -from ourstdlibs.exceptionutils import bool_func_from_raiser +from ..ourstdlibs.exceptionutils import bool_func_from_raiser ### validation command map diff --git a/nodezator/pygameconstants.py b/nodezator/pygameconstants.py index 0049c47b..6bb63176 100644 --- a/nodezator/pygameconstants.py +++ b/nodezator/pygameconstants.py @@ -16,7 +16,7 @@ ### local imports -from appinfo import FULL_TITLE, ABBREVIATED_TITLE +from .appinfo import FULL_TITLE, ABBREVIATED_TITLE ### pygame mixer pre-initialization diff --git a/nodezator/recentfile.py b/nodezator/recentfile.py index 4642f774..33057fe2 100644 --- a/nodezator/recentfile.py +++ b/nodezator/recentfile.py @@ -6,9 +6,9 @@ ### local imports -from userprefsman.main import RECENT_FILES +from .userprefsman.main import RECENT_FILES -from ourstdlibs.pyl import load_pyl, save_pyl +from .ourstdlibs.pyl import load_pyl, save_pyl def get_recent_files(): diff --git a/nodezator/rectsman/main.py b/nodezator/rectsman/main.py index fdcd382d..32fa6d8d 100644 --- a/nodezator/rectsman/main.py +++ b/nodezator/rectsman/main.py @@ -24,12 +24,12 @@ ### local imports (class extensions) -from rectsman.special import SpecialMethods -from rectsman.spatial import SpatialProperties -from rectsman.sizepos import SizePositionMethods -from rectsman.singlepos import PositionSingleRectsMethods +from .special import SpecialMethods +from .spatial import SpatialProperties +from .sizepos import SizePositionMethods +from .singlepos import PositionSingleRectsMethods -from rectsman.cluster import get_clusters +from .cluster import get_clusters ### "rect" property definition (getter and setter) @@ -85,12 +85,12 @@ class RectsManager( Check the "doctests" directory to find extensive documentation and doctests regarding the usage of this class. - + Such documentation also has a discussion regarding a future/possible redesign, which keeps the pygame.Rect API compatibility but has even more flexible behaviour and also new ones beyond the pygame.Rect API. - + For now, there is only two methods provided which are beyond the pygame.Rect API, which is the '__iter__' method from the 'special.py' module (even though the @@ -181,7 +181,7 @@ def keep_rects_attrs(self, *attr_names): } ### suspend execution by yielding; - ### + ### ### exceptions occurring in this step are ### purposefully not caught; yield @@ -317,14 +317,14 @@ def collidedict(self, *args): the elements to be tested for collision. The second argument is optional and must be a boolean or integer indicating True or False. - + Passing False or omitting the argument altogether, makes it so the keys in the dict are used for collision testing (they'll probably be tuples, since keys in dictionaries must be hashable, which lists and pygame.Rect instances are not, they can only be used as values). - + If you pass True instead, the opposite happens, that is, the values of the dict are used for collision testing. @@ -344,14 +344,14 @@ def collidedictall(self, *args): the elements to be tested for collision. The second argument is optional and must be a boolean or integer indicating True or False. - + Passing False or omitting the argument altogether, makes it so the keys in the dict are used for collision testing (they'll probably be tuples, since keys in dictionaries must be hashable, which lists and pygame.Rect instances are not, they can only be used as values). - + If you pass True instead, the opposite happens, that is, the values of the dict are used for collision testing. diff --git a/nodezator/surfdef.py b/nodezator/surfdef.py index b29d2c8c..de995174 100644 --- a/nodezator/surfdef.py +++ b/nodezator/surfdef.py @@ -30,15 +30,15 @@ ### local imports -from classes2d.single import Object2D +from .classes2d.single import Object2D -from classes2d.collections import List2D +from .classes2d.collections import List2D -from surfsman.draw import draw_border +from .surfsman.draw import draw_border -from surfsman.render import render_rect +from .surfsman.render import render_rect -from htsl.creation import TextBlock +from .htsl.creation import TextBlock def surfdef_obj_from_element( @@ -60,9 +60,9 @@ def surfdef_obj_from_element( ELEMENT_NODE = surfdef_element.ELEMENT_NODE for child in surfdef_element.childNodes: - + if child.nodeType != ELEMENT_NODE: continue - + child_name = child.tagName.lower() if child_name in ('rect', 'ellipse'): @@ -246,7 +246,7 @@ def surfdef_obj_from_element( stroke_width, ) - elif child_name == 'polyline': + elif child_name == 'polyline': if child.getAttribute('points'): @@ -392,7 +392,7 @@ def points_from_directives(directives_text): temp_points = [] while chars: - + point_text = '' while True: diff --git a/nodezator/surfsman/cache.py b/nodezator/surfsman/cache.py index 129c774d..087ebf7b 100644 --- a/nodezator/surfsman/cache.py +++ b/nodezator/surfsman/cache.py @@ -10,24 +10,24 @@ ### local imports -from pygameconstants import ( +from ..pygameconstants import ( SCREEN, SCREEN_RECT, blit_on_screen, ) -from ourstdlibs.collections.general import FactoryDict +from ..ourstdlibs.collections.general import FactoryDict -from surfsman.render import render_rect -from surfsman.draw import draw_not_found_icon - -from colorsman.colors import ( +from ..colorsman.colors import ( CONTRAST_LAYER_COLOR, IMAGE_NOT_FOUND_FG, IMAGE_NOT_FOUND_BG, ) +from .render import render_rect + +from .draw import draw_not_found_icon ### empty surface EMPTY_SURF = Surface((0, 0)).convert() diff --git a/nodezator/surfsman/draw.py b/nodezator/surfsman/draw.py index fcd5f3b0..cc0edab0 100644 --- a/nodezator/surfsman/draw.py +++ b/nodezator/surfsman/draw.py @@ -25,7 +25,7 @@ ### local imports -from colorsman.colors import ( +from ..colorsman.colors import ( BLACK, WHITE, SHADOW_COLOR, HIGHLIGHT_COLOR) @@ -50,10 +50,10 @@ def draw_depth_finish( Such finish application consists of drawing polygons which work as borders of the surface to simulate highlights and shadows, giving depth to the surface. - + Parameters ========== - + surf (pygame.Surface instance) surface wherein to draw the lines. thickness (integer >= 1) @@ -116,7 +116,7 @@ def draw_border(surf, color=BLACK, thickness=1): It works by drawing a sequence of rects with thickness 1, one inside the other. - + Parameters ========== surf (pygame.Surface instance) @@ -184,7 +184,7 @@ def draw_border_on_area(surf, color, area_rect, thickness=1): It works by drawing a sequence of rects with thickness 1, one inside the other. - + Parameters ========== surf (pygame.Surface instance) @@ -260,7 +260,7 @@ def draw_checker_pattern( ### the surface is covered by the checker pattern while True: - + ## if the unit rect isn't touching the ## surface area, invert the x_offset, ## move it back using such new x_offset and @@ -349,12 +349,12 @@ def draw_linear_gradient( rgb_to_hls(*[v/255 for v in color[:3]]) - ### iterate over all vertical sections of the + ### iterate over all vertical sections of the ### surface represented by all possible values of ### x within the width of the surface for x in range(width): - + ## if x is before or at the start, the max ## lightness percentage is used as the percentage if x <= start : percent = max_lightness_percentage @@ -391,7 +391,7 @@ def draw_linear_gradient( hls_to_rgb(hue, current_lightness, saturation) ] - + ## and use it to draw a line on the vertical section draw_line(surf, color, (x, 0), (x, height), 1) @@ -413,7 +413,7 @@ def draw_linear_gradient( ## needed elif direction in ('bottom_to_top', 'top_to_bottom'): - + # define the amount of rotation needed according # to the specific vertical direction rotation_amount = \ @@ -484,7 +484,7 @@ def draw_not_found_icon(surf, color): ## draw diagonal based on ellipse thickness if ellipse_thickness >= 3: - + dimension_size = round(ellipse_thickness / sqrt(2)) small_rect = Rect( diff --git a/nodezator/surfsman/icon.py b/nodezator/surfsman/icon.py index 838e61c7..9286b854 100644 --- a/nodezator/surfsman/icon.py +++ b/nodezator/surfsman/icon.py @@ -42,16 +42,15 @@ ### local imports -from fontsman.constants import ICON_FONT_PATH +from ..fontsman.constants import ICON_FONT_PATH -from surfsman.draw import ( +from ..colorsman.colors import BLACK + +from .draw import ( draw_border, draw_depth_finish, ) -from colorsman.colors import BLACK - - def render_layered_icon( @@ -268,7 +267,7 @@ def get_objs_for_icon_rendering( ### utility function def get_size_results(font_size): - + ### create font and produce a surface with the ### given char, using its "render" method; the ### render method must not receive a background diff --git a/nodezator/surfsman/render.py b/nodezator/surfsman/render.py index 12dd0799..52f18fa9 100644 --- a/nodezator/surfsman/render.py +++ b/nodezator/surfsman/render.py @@ -11,20 +11,22 @@ ### local imports -from colorsman.colors import ( + +from ..colorsman.colors import ( BLACK, WINDOW_BG, SHADOW_COLOR, HIGHLIGHT_COLOR, ) -from surfsman.draw import ( +from ..rectsman.main import RectsManager + + +from .draw import ( draw_border, draw_depth_finish, ) -from rectsman.main import RectsManager - def render_rect(width, height, color=BLACK): """Return surface representing rect with a single color. @@ -136,7 +138,7 @@ def unite_surfaces( rects = [] for surf, rect in surface_rect_pairs: - + surfaces.append(surf) rects.append(rect) diff --git a/nodezator/syntaxman/syntaxes/comment.py b/nodezator/syntaxman/syntaxes/comment.py index 023742af..62e98d9e 100644 --- a/nodezator/syntaxman/syntaxes/comment.py +++ b/nodezator/syntaxman/syntaxes/comment.py @@ -5,7 +5,7 @@ ### local import -from ourstdlibs.mathutils import get_remaining_intervals +from ...ourstdlibs.mathutils import get_remaining_intervals ### constants @@ -145,7 +145,7 @@ def get_line_syntax_intervals(comment_text): ### (if there are such words) for word in TODO_WORDS: - + ## store the length of the word length = len(word) @@ -155,10 +155,10 @@ def get_line_syntax_intervals(comment_text): ## now we repeat the block below as many times as ## there are substrings of the todo word in the - ## comment_text string + ## comment_text string for _ in range(comment_text.count(word)): - + ## define the boundaries of the interval ## containing the todo word in the string @@ -269,7 +269,7 @@ def is_char_allowed(line_string, index): Used to check whether a "todo" substring (a string from the TODO_WORDS constant) from line_string is a proper todo word. - + Such check is made indirectly, by checking the characters which reside in the adjacent indices of the substring. The following rules apply: @@ -291,7 +291,7 @@ def is_char_allowed(line_string, index): ### it doesn't exist, which is a valid condition, so ### we return True if index < 0: return True - + ### check whether the index points to a character in ### the line string try: char = line_string[index] diff --git a/nodezator/syntaxman/syntaxes/python/main.py b/nodezator/syntaxman/syntaxes/python/main.py index 4dad82f0..5b474e4c 100644 --- a/nodezator/syntaxman/syntaxes/python/main.py +++ b/nodezator/syntaxman/syntaxes/python/main.py @@ -21,17 +21,17 @@ ### local imports -from ourstdlibs.mathutils import get_remaining_intervals +from ....ourstdlibs.mathutils import get_remaining_intervals -from ourstdlibs.exceptionutils import \ +from ....ourstdlibs.exceptionutils import \ new_raiser_from_existing_deco -from syntaxman.exception import SyntaxMappingError +from ...exception import SyntaxMappingError -from syntaxman.syntaxes.python.namemap import \ +from ..python.namemap import \ HIGHLIGHT_NAME_MAP -from syntaxman.syntaxes.python.utils import ( +from ..python.utils import ( is_triple_quotes_string, has_def_or_class_statement, interval_of_next_def_word, @@ -93,7 +93,7 @@ def get_python_syntax_map(source_text): >>> # "python -m doctest" can't find this function >>> # anymore, so this test isn't performed; think >>> # about solutions for this - + >>> text = "condition = True" >>> expected_output = { ... 0: { @@ -130,7 +130,7 @@ def get_python_syntax_map(source_text): source_text.encode('utf-8') ).readline ) - + ### also list all lines in the source source_lines = source_text.splitlines() @@ -216,7 +216,7 @@ def get_python_syntax_map(source_text): interval_category_pairs = \ get_comment_offset_intervals( token_line, interval[0]) - + ## map the intervals to their respective ## category names @@ -232,7 +232,7 @@ def get_python_syntax_map(source_text): ## according to several rules... elif token_type == NAME: - + ## if the name is present in a special map, ## grab the respective value as the ## category of that name and map the interval @@ -282,7 +282,7 @@ def get_python_syntax_map(source_text): ## "for loop" we ignored all other operators) elif token_type == OP: - + ## if the '@' represents the usage of ## a decorator over a class, method or ## function definition (regardless of @@ -310,7 +310,7 @@ def get_python_syntax_map(source_text): # category names if decorator_name_interval: - + ( line_index_to_data [line_index][interval] @@ -361,7 +361,7 @@ def get_python_syntax_map(source_text): for line_index in range( first_line_index, last_line_index + 1 ): - + ## grab the line text line_text = source_lines[line_index] @@ -410,7 +410,7 @@ def get_python_syntax_map(source_text): ### of text contain normal text for line_index, line_text in enumerate(source_lines): - + ## ignore line if it is empty if not line_text: continue diff --git a/nodezator/syntaxman/syntaxes/python/utils.py b/nodezator/syntaxman/syntaxes/python/utils.py index b79bb9c7..de4b46af 100644 --- a/nodezator/syntaxman/syntaxes/python/utils.py +++ b/nodezator/syntaxman/syntaxes/python/utils.py @@ -5,7 +5,7 @@ ### local import -from syntaxman.syntaxes.comment import get_comment_syntax_map +from ..comment import get_comment_syntax_map MULTI_LINE_STR_QUOTES = '"""', "'''" @@ -142,14 +142,14 @@ def represents_applied_decorator(line_index, source_lines): ### isn't 1, we assume it isn't a decorator being ### applied, so we return an empty tuple if line_text.count('@') != 1: return () - + ### XXX note that, in the 'if block' above, even though ### we assume that a line which doesn't have only one ### '@' character is't a decorator, there is still a ### possibility, however rare, in which we could still ### have a decorator being applied with more than one ### '@' character in the same line: - ### + ### ### the other(s) character(s) could be inside strings ### in arguments of a call, in case the decorator is ### returned by a callable; @@ -229,7 +229,7 @@ def represents_applied_decorator(line_index, source_lines): ## iterate over each subsequent line for index in count(start=next_line_index): - + ## grab the text of the line line_text = source_lines[index] @@ -303,7 +303,7 @@ def represents_applied_decorator(line_index, source_lines): def get_comment_offset_intervals(line_text, comment_start): """Return intervals for comment syntax with offset. - + Such syntax separates normal comment text from special "todo" words (TODO, XXX and FIXME). The offset is need because the comment doesn't always start from diff --git a/nodezator/syntaxman/utils.py b/nodezator/syntaxman/utils.py index cea2826b..e50bf788 100644 --- a/nodezator/syntaxman/utils.py +++ b/nodezator/syntaxman/utils.py @@ -2,25 +2,25 @@ ### local imports -from config import SYNTAX_THEMES_DIR +from ..config import SYNTAX_THEMES_DIR -from ourstdlibs.pyl import load_pyl +from ..ourstdlibs.pyl import load_pyl -from ourstdlibs.dictutils import settings_to_hashable_repr +from ..ourstdlibs.dictutils import settings_to_hashable_repr ## syntax mapping functions -from syntaxman.syntaxes.python.main import ( +from .syntaxes.python.main import ( get_python_syntax_map ) -from syntaxman.syntaxes.comment import ( +from .syntaxes.comment import ( get_comment_syntax_map ) -from syntaxman.syntaxes.userlog import ( - get_user_log_syntax_map +from .syntaxes.userlog import ( + get_user_log_syntax_map ) @@ -35,7 +35,7 @@ RAW_THEMES_MAP = { # key is the syntax name - syntax_name : + syntax_name : # value is the json contents (a dict) loaded from the # path resulting of joining the themes dir with the @@ -144,7 +144,7 @@ def create_ready_theme(syntax_name, default_text_settings): settings for the syntax to be used (such highlight settings are several text settings for different kinds of words/text in a specific syntax). - + For instance, in the Python syntax, the highlight settings include settings for several kinds of text like keywords, built-in functions, etc. Each of these @@ -158,13 +158,13 @@ def create_ready_theme(syntax_name, default_text_settings): Before using the specific settings, we also assign the background color from the theme to the general settings. - + Why not just use the specific settings, then? Because the general settings as well as the background color represent default values for specific settings that may not be present in the specific settings, thus serving as a base. - + This is specially important for settings not defined on the theme, like font height, which is something that usually depends on where the text will be used @@ -195,7 +195,7 @@ def create_ready_theme(syntax_name, default_text_settings): ### them as they are merged into the dict merged_settings_map = { - + ## this new dict map each kind of highlighted ## text to a dict kind_of_text : dict( diff --git a/nodezator/textman/cache.py b/nodezator/textman/cache.py index d5945f95..41fc64a4 100644 --- a/nodezator/textman/cache.py +++ b/nodezator/textman/cache.py @@ -15,7 +15,7 @@ converted to a hashable representation), automatically creates another dict containing a surface map and a width map. - + Both the surface map and width map are dicts which associate text to surfaces and the width of such surfaces, respectively. They are stored in the @@ -68,11 +68,11 @@ ### local imports -from ourstdlibs.dictutils import settings_to_hashable_repr +from ..ourstdlibs.dictutils import settings_to_hashable_repr -from classes2d.single import Object2D +from ..classes2d.single import Object2D -from textman.render import render_text +from .render import render_text ### constant: pairs containing special characters and @@ -148,7 +148,7 @@ def free_up_memory(self): class TextSurfaceMap(dict): """Map to store text surfaces; has extra behaviour.""" - + def __init__(self, text_settings): """Store given text settings, perform extra setups.""" ### store text settings @@ -225,7 +225,7 @@ def free_up_memory(self): class TextWidthMap(dict): """Map to store text surfs width; has extra behaviour.""" - + def __init__(self, surf_map): """Store the given surface map.""" self.surf_map = surf_map @@ -294,19 +294,19 @@ def change_text_settings(self, text_settings): settings. We did so by decorating this method with appcommon.debug.measure_average_speed function. We used 4, 100, 1000, and 10000 repetitions. - + It turned out, unexpectedly so, that the solution with the "if block" made the method quicker when the number of repetitions where 4, 100, 1000. The speed was about 10% faster. - + We expected all experiments to yield results favorable to the solution without the "if block", since we know every time the "if check" was performed, it came out negative and ended up executing the rest of the method anyway, so it was just an unnecessary step. - + Only when the repetitions were 10000 the solution without the "if block" performed better, but it isn't that relevant, cause this method is intended diff --git a/nodezator/textman/editor/constants.py b/nodezator/textman/editor/constants.py index 6c487e4a..fee47555 100644 --- a/nodezator/textman/editor/constants.py +++ b/nodezator/textman/editor/constants.py @@ -6,13 +6,13 @@ ### local imports -from pygameconstants import SCREEN_RECT +from ...pygameconstants import SCREEN_RECT -from fontsman.constants import ( +from ...fontsman.constants import ( ENC_SANS_BOLD_FONT_PATH, FIRA_MONO_BOLD_FONT_PATH) -from colorsman.colors import ( +from ...colorsman.colors import ( TEXT_EDITING_AREA_FG, TEXT_EDITING_AREA_BG) diff --git a/nodezator/textman/editor/cursor/main.py b/nodezator/textman/editor/cursor/main.py index 47b4deb0..ca964cae 100644 --- a/nodezator/textman/editor/cursor/main.py +++ b/nodezator/textman/editor/cursor/main.py @@ -10,28 +10,29 @@ ### local imports -from surfsman.cache import EMPTY_SURF +from ....surfsman.cache import EMPTY_SURF -from classes2d.collections import List2D +from ....classes2d.collections import List2D -from fontsman.constants import FIRA_MONO_BOLD_FONT_PATH +from ....fontsman.constants import FIRA_MONO_BOLD_FONT_PATH -from textman.render import render_text +from ...render import render_text -from textman.editor.constants import NUMBER_OF_VISIBLE_LINES +from ..constants import NUMBER_OF_VISIBLE_LINES -from textman.editor.line import Line +from ..line import Line -from textman.editor.cursor.op import GeneralOperations - -from textman.editor.cursor.navigation import Navigation -from textman.editor.cursor.syntaxhigh import \ +from .navigation import Navigation +from .syntaxhigh import \ SyntaxHighlighting -from textman.editor.cursor.modes.normal import NormalMode -from textman.editor.cursor.modes.insert import InsertMode +from .modes.normal import NormalMode +from .modes.insert import InsertMode + +from ..constants import EDITING_AREA_RECT + -from textman.editor.constants import EDITING_AREA_RECT +from .op import GeneralOperations ### XXX the next time you make a general refactoring of diff --git a/nodezator/textman/editor/cursor/modes/insert.py b/nodezator/textman/editor/cursor/modes/insert.py index be1b9d3b..b325a9cd 100644 --- a/nodezator/textman/editor/cursor/modes/insert.py +++ b/nodezator/textman/editor/cursor/modes/insert.py @@ -17,13 +17,13 @@ ### local imports -from loopman.exception import QuitAppException +from .....loopman.exception import QuitAppException -from htsl.main import open_htsl_link +from .....htsl.main import open_htsl_link -from textman.editor.constants import NUMBER_OF_VISIBLE_LINES +from ...constants import NUMBER_OF_VISIBLE_LINES -from textman.editor.line import Line +from ...line import Line class InsertMode: @@ -81,7 +81,7 @@ def insert_mode_handling(self): ### TAB key adds 4 spaces elif event.key == K_TAB: - + ### XXX as of now, we do have a tab ### representation which is the tab ### character itself ('\t'), but which diff --git a/nodezator/textman/editor/cursor/modes/normal.py b/nodezator/textman/editor/cursor/modes/normal.py index 14e108eb..d755c2c2 100644 --- a/nodezator/textman/editor/cursor/modes/normal.py +++ b/nodezator/textman/editor/cursor/modes/normal.py @@ -21,13 +21,13 @@ ### local imports -from loopman.exception import QuitAppException +from .....loopman.exception import QuitAppException -from htsl.main import open_htsl_link +from .....htsl.main import open_htsl_link -from textman.editor.constants import NUMBER_OF_VISIBLE_LINES +from ...constants import NUMBER_OF_VISIBLE_LINES -from textman.editor.line import Line +from ...line import Line class NormalMode: diff --git a/nodezator/textman/editor/cursor/navigation.py b/nodezator/textman/editor/cursor/navigation.py index 83e2c82a..04466830 100644 --- a/nodezator/textman/editor/cursor/navigation.py +++ b/nodezator/textman/editor/cursor/navigation.py @@ -8,7 +8,7 @@ ### local import -from textman.editor.constants import NUMBER_OF_VISIBLE_LINES +from ..constants import NUMBER_OF_VISIBLE_LINES ### XXX @@ -23,7 +23,7 @@ ### injecting in the cursor class, but without losing ### the benefit of setting extra partial methods with ### functools.partialmethod? -### +### ### I mean, this must be done in a way that isn't ### cumbersome and everything could be set up here ### and just be injected once, in a single line in the @@ -61,7 +61,7 @@ def navigate(self, rows, cols): """Jump number of rows and columns provided. Use in normal mode. - + Parameters ========== rows, cols (integers) @@ -180,7 +180,7 @@ def navigate(self, rows, cols): ## if we otherwise succeed in retrieving the char ## in the current column, we move the cursor to the ## position of that character object; - ## + ## ## we also update the cursor size to that of the ## character obj @@ -215,7 +215,7 @@ def navigate_ins(self, rows, cols): """Jump number of rows and columns provided. Use in insert mode. - + Parameters ========== rows, cols (integers) @@ -367,7 +367,7 @@ def navigate_ins(self, rows, cols): ## if we otherwise succeed in retrieving the char ## in the current column, we move the cursor to the ## position of that character object; - ## + ## ## we also update the cursor size to that of the ## character obj diff --git a/nodezator/textman/editor/cursor/op.py b/nodezator/textman/editor/cursor/op.py index 4e946771..b02f07f7 100644 --- a/nodezator/textman/editor/cursor/op.py +++ b/nodezator/textman/editor/cursor/op.py @@ -10,11 +10,11 @@ ### local imports -from pygameconstants import SCREEN, blit_on_screen +from ....pygameconstants import SCREEN, blit_on_screen -from ourstdlibs.behaviour import had_to_set_new_value +from ....ourstdlibs.behaviour import had_to_set_new_value -from textman.editor.constants import ( +from ..constants import ( TEXT_EDITOR_RECT, EDITING_AREA_RECT) @@ -83,7 +83,7 @@ def adjust_editing_area_left_and_width(self): new_left = ( # start from the x coordinate from where we - # blit line numbers + # blit line numbers LINE_NUMBER_X # add the width which will be occupied by the @@ -174,12 +174,12 @@ def clamp_cursor_horizontally(self): There might be, though, rare cases where a character has a height different than that of the vast majority of other character. - + We didn't address this possibility yet, because on top of being rare, the slight difference in height might not be enough to justify adjusting the position of objects vertically. - + That is, the character might still be visible enough to be comfortably identified by the user editing the text. diff --git a/nodezator/textman/editor/cursor/syntaxhigh.py b/nodezator/textman/editor/cursor/syntaxhigh.py index 94cb0f74..05e325ff 100644 --- a/nodezator/textman/editor/cursor/syntaxhigh.py +++ b/nodezator/textman/editor/cursor/syntaxhigh.py @@ -6,21 +6,21 @@ ### local imports -from ourstdlibs.behaviour import empty_function +from ....ourstdlibs.behaviour import empty_function -from ourstdlibs.color.creation import get_contrasting_bw +from ....ourstdlibs.color.creation import get_contrasting_bw -from syntaxman.exception import SyntaxMappingError +from ....syntaxman.exception import SyntaxMappingError -from syntaxman.utils import ( +from ....syntaxman.utils import ( AVAILABLE_SYNTAXES, SYNTAX_TO_MAPPING_FUNCTION, get_ready_theme, ) -from fontsman.constants import FIRA_MONO_BOLD_FONT_PATH +from ....fontsman.constants import FIRA_MONO_BOLD_FONT_PATH -from textman.editor.constants import ( +from ..constants import ( SANS_FONT_SETTINGS, MONO_FONT_SETTINGS, ) @@ -36,7 +36,7 @@ class SyntaxHighlighting: """Operations/setups for syntax highlighting support.""" - + def set_syntax_highlighting( self, font_path, syntax_highlighting ): @@ -88,7 +88,7 @@ def set_syntax_highlighting( ### if a valid syntax is requested... if syntax_highlighting in AVAILABLE_SYNTAXES: - + ## define the default settings depending on the ## font style @@ -208,7 +208,7 @@ def set_syntax_highlighting( ### with the current background color used self.cursor_color = \ get_contrasting_bw(self.background_color) - + def check_syntax_highlighting(self): """Trigger syntax highlighting update, if suitable.""" ### if the last time when an edition was performed @@ -217,7 +217,7 @@ def check_syntax_highlighting(self): ### point in updating the syntax highlighting data; ### therefore, we cancel the operation by returning if not self.last_edition_msecs: return - + ### otherwise, there were changes, so we check ### wether the pre-defined delay between the last ### change and the present time has elapsed; @@ -264,7 +264,7 @@ def update_syntax_highlight_data(self): except SyntaxMappingError: self.highlight_data = { - + ## store a dict item where the line index is ## the key and another dict is the value @@ -279,7 +279,7 @@ def update_syntax_highlight_data(self): (0, len(line)): 'normal' } - + ## for each line_index and respective line for line_index, line in enumerate(self.lines) @@ -341,7 +341,7 @@ def syntax_highlight_visible_lines(self): (including_start, excluding_end), category_name ) in interval_data.items(): - + # retrieve the text settings for the # category category_text_settings = \ diff --git a/nodezator/textman/editor/line.py b/nodezator/textman/editor/line.py index 5940e98c..39c3b75c 100644 --- a/nodezator/textman/editor/line.py +++ b/nodezator/textman/editor/line.py @@ -6,18 +6,18 @@ ### local imports -from classes2d.collections import List2D +from ...classes2d.collections import List2D -from syntaxman.utils import ( +from ...syntaxman.utils import ( AVAILABLE_SYNTAXES, get_ready_theme, ) -from fontsman.constants import FIRA_MONO_BOLD_FONT_PATH +from ...fontsman.constants import FIRA_MONO_BOLD_FONT_PATH -from textman.cache import CachedTextObject +from ..cache import CachedTextObject -from textman.editor.constants import ( +from ..editor.constants import ( SANS_FONT_SETTINGS, MONO_FONT_SETTINGS, ) @@ -63,7 +63,7 @@ def __init__(self, contents): def get_all_rects(self): """Return rects from this line. - + This includes the line rect plus the rects of each item of this list. @@ -181,7 +181,7 @@ def insert_text(self, index, text): the instantiated objects. text (string) characters to be inserted in the line. - + Rearrange positions at the end. """ for next_index, char in enumerate(text, start=index): diff --git a/nodezator/textman/editor/main.py b/nodezator/textman/editor/main.py index 4199cc3b..3d38bafe 100644 --- a/nodezator/textman/editor/main.py +++ b/nodezator/textman/editor/main.py @@ -15,28 +15,28 @@ ### local imports -from pygameconstants import ( +from ...pygameconstants import ( SCREEN_RECT, maintain_fps, FPS, blit_on_screen, ) -from dialog import create_and_show_dialog +from ...dialog import create_and_show_dialog -from ourstdlibs.collections.general import CallList +from ...ourstdlibs.collections.general import CallList -from surfsman.cache import UNHIGHLIGHT_SURF_MAP +from ...surfsman.cache import UNHIGHLIGHT_SURF_MAP -from classes2d.single import Object2D -from classes2d.collections import List2D +from ...classes2d.single import Object2D +from ...classes2d.collections import List2D -from surfsman.draw import draw_border -from surfsman.render import render_rect +from ...surfsman.draw import draw_border +from ...surfsman.render import render_rect -from surfsman.icon import render_layered_icon +from ...surfsman.icon import render_layered_icon -from colorsman.colors import ( +from ...colorsman.colors import ( BLACK, WHITE, WINDOW_FG, WINDOW_BG, @@ -44,20 +44,20 @@ CONTRAST_LAYER_COLOR, ) -from textman.render import render_text +from ...textman.render import render_text -from fontsman.constants import ( +from ...fontsman.constants import ( ENC_SANS_BOLD_FONT_HEIGHT, ENC_SANS_BOLD_FONT_PATH, FIRA_MONO_BOLD_FONT_HEIGHT, FIRA_MONO_BOLD_FONT_PATH, ) -from textman.label.main import Label +from ...textman.label.main import Label -from textman.editor.cursor.main import Cursor +from ...textman.editor.cursor.main import Cursor -from textman.editor.constants import ( +from ...textman.editor.constants import ( TEXT_EDITOR_RECT, EDITING_AREA_RECT) @@ -387,7 +387,7 @@ def edit_text( validation_command (None or callable) if it is None, the instance is set up so that no validation is done; - + if it is a callable, it must accept a single argument and its return value is used to determined whether validation passed (when the @@ -396,7 +396,7 @@ def edit_text( syntax_highlighting (string) represents the name of a syntax used to highlight the text (for instance, 'python'); - if an empty string, which is the default value, + if an empty string, which is the default value, or the name of an unsupported syntax is given, syntax highlighting is disabled; if, otherwise, the argument indicates a @@ -574,7 +574,7 @@ def draw(self): ### update screen (pygame.display.update) update() - + def mouse_release_action(self, mouse_pos): """Invoke colliding button, if any. diff --git a/nodezator/textman/entryedition/cursor.py b/nodezator/textman/entryedition/cursor.py index 98b32131..a78430fa 100644 --- a/nodezator/textman/entryedition/cursor.py +++ b/nodezator/textman/entryedition/cursor.py @@ -17,9 +17,11 @@ ### local imports -from textman.entryedition.line import EntryLine +from ...colorsman.colors import BLACK + +from .line import EntryLine + -from colorsman.colors import BLACK class EntryCursor: @@ -179,7 +181,7 @@ def draw(self): def navigate(self, cols): """Jump number of columns provided. - + Parameters ========== cols (integer) @@ -247,7 +249,7 @@ def navigate(self, cols): ## if we otherwise succeed in retrieving the char ## in the current column, we move the cursor to the ## position of that character object; - ## + ## ## we also update the cursor size to that of the ## character obj diff --git a/nodezator/textman/entryedition/line.py b/nodezator/textman/entryedition/line.py index 230f366a..a7f3a6fa 100644 --- a/nodezator/textman/entryedition/line.py +++ b/nodezator/textman/entryedition/line.py @@ -6,9 +6,9 @@ ### local imports -from classes2d.collections import List2D +from ...classes2d.collections import List2D -from textman.cache import CachedTextObject +from ..cache import CachedTextObject class EntryLine(List2D): @@ -48,7 +48,7 @@ def __init__(self, text, topleft, font_settings): def get_all_rects(self): """Return rects composing this line. - + This includes the line rect plus the rects of each text object in this list. diff --git a/nodezator/textman/label/main.py b/nodezator/textman/label/main.py index 9f289549..72495778 100644 --- a/nodezator/textman/label/main.py +++ b/nodezator/textman/label/main.py @@ -6,15 +6,15 @@ ### local imports -from classes2d.single import Object2D +from ...classes2d.single import Object2D -from surfsman.render import render_rect +from ...surfsman.render import render_rect -from fontsman.constants import ENC_SANS_BOLD_FONT_PATH +from ...fontsman.constants import ENC_SANS_BOLD_FONT_PATH -from textman.cache import TEXT_SURFS_DB +from ...textman.cache import TEXT_SURFS_DB -from colorsman.colors import BLACK +from ...colorsman.colors import BLACK # XXX it's not clear why the Label constructor parameters @@ -229,7 +229,7 @@ def add_text(self, text): else: setattr( self.rect, coordinates_name, coordinates_value) - + def update_image(self): """Update image surface attribute.""" ### reference the width map locally @@ -360,7 +360,7 @@ def get_chars_within_width(self): chars = chars + ellipsis else: - + for char in self.contents[::-1]: # calculate the resulting width from diff --git a/nodezator/textman/render.py b/nodezator/textman/render.py index f2f18847..eda01107 100644 --- a/nodezator/textman/render.py +++ b/nodezator/textman/render.py @@ -12,18 +12,18 @@ ### local imports -from fontsman.cache import FONTS_DB +from ..fontsman.cache import FONTS_DB -from fontsman.constants import ( +from ..fontsman.constants import ( ENC_SANS_BOLD_FONT_PATH, ENC_SANS_BOLD_FONT_HEIGHT, ) -from surfsman.draw import draw_border, draw_depth_finish +from ..surfsman.draw import draw_border, draw_depth_finish -from rectsman.main import RectsManager +from ..rectsman.main import RectsManager -from colorsman.colors import BLACK +from ..colorsman.colors import BLACK def get_text_size( @@ -33,7 +33,7 @@ def get_text_size( padding=0, ): """Return surf size of text as if it were rendered. - + text Any string. font_height @@ -159,7 +159,7 @@ def render_text( ): """Return surface or object representing rendered text. - + Parameters ========== @@ -409,7 +409,7 @@ def render_multiline_text( ### if padding was requested if padding: - + ### pick surface converting method according to ### presence of transparence @@ -447,7 +447,7 @@ def render_multiline_text( surf.fill(background_color) - ## blit text surf on new surf taking the + ## blit text surf on new surf taking the ## text padding into account surf.blit(text_surface, (padding, padding)) @@ -522,7 +522,7 @@ def render_multiline_text( surf.fill(background_color) for text_surf, rect in zip(text_surfaces, rects): - + surf.blit(text_surf, rect) ### add other effects as requested diff --git a/nodezator/textman/text.py b/nodezator/textman/text.py index 5b51ef57..2f88adb3 100644 --- a/nodezator/textman/text.py +++ b/nodezator/textman/text.py @@ -8,15 +8,14 @@ ### local imports -from classes2d.single import Object2D -from classes2d.collections import List2D +from ..classes2d.single import Object2D +from ..classes2d.collections import List2D -from surfsman.cache import EMPTY_SURF +from ..surfsman.cache import EMPTY_SURF -from textman.render import render_text - -from syntaxman.utils import SYNTAX_TO_MAPPING_FUNCTION +from ..syntaxman.utils import SYNTAX_TO_MAPPING_FUNCTION +from .render import render_text ### functions diff --git a/nodezator/textman/viewer/constants.py b/nodezator/textman/viewer/constants.py index 8fa87f66..aa398365 100644 --- a/nodezator/textman/viewer/constants.py +++ b/nodezator/textman/viewer/constants.py @@ -5,14 +5,14 @@ ### local imports -from pygameconstants import SCREEN_RECT +from ...pygameconstants import SCREEN_RECT -from fontsman.constants import ( +from ...fontsman.constants import ( FIRA_MONO_BOLD_FONT_HEIGHT, FIRA_MONO_BOLD_FONT_PATH, ) -from colorsman.colors import ( +from ...colorsman.colors import ( TEXT_VIEWER_FG, TEXT_VIEWER_BG, CUSTOM_STDOUT_FG, diff --git a/nodezator/textman/viewer/main.py b/nodezator/textman/viewer/main.py index eab571b2..ed513f0f 100644 --- a/nodezator/textman/viewer/main.py +++ b/nodezator/textman/viewer/main.py @@ -3,32 +3,32 @@ ### local imports -from ourstdlibs.collections.general import CallList +from ...ourstdlibs.collections.general import CallList -from ourstdlibs.behaviour import empty_function +from ...ourstdlibs.behaviour import empty_function -from surfsman.draw import draw_border +from ...surfsman.draw import draw_border -from surfsman.render import combine_surfaces +from ...surfsman.render import combine_surfaces -from classes2d.single import Object2D +from ...classes2d.single import Object2D -from fontsman.constants import ( +from ...fontsman.constants import ( ENC_SANS_BOLD_FONT_HEIGHT, ENC_SANS_BOLD_FONT_PATH, ) -from textman.label.main import Label +from ...textman.label.main import Label -from textman.render import ( +from ...textman.render import ( render_text, render_multiline_text, ) -from surfsman.icon import render_layered_icon -from surfsman.cache import RECT_SURF_MAP +from ...surfsman.icon import render_layered_icon +from ...surfsman.cache import RECT_SURF_MAP -from colorsman.colors import ( +from ...colorsman.colors import ( BLACK, WHITE, TEXT_VIEWER_HELP_FG, TEXT_VIEWER_HELP_BG, @@ -40,11 +40,11 @@ ## class extensions -from textman.viewer.op import Operations -from textman.viewer.prep import TextPreparation +from .op import Operations +from .prep import TextPreparation ## common constants -from textman.viewer.constants import TEXT_VIEWER_RECT +from .constants import TEXT_VIEWER_RECT ### XXX could the design of the removed module diff --git a/nodezator/textman/viewer/op.py b/nodezator/textman/viewer/op.py index 4f173cd9..1acc0aa8 100644 --- a/nodezator/textman/viewer/op.py +++ b/nodezator/textman/viewer/op.py @@ -28,19 +28,19 @@ ### local imports -from pygameconstants import ( +from ...pygameconstants import ( SCREEN_RECT, FPS, blit_on_screen, maintain_fps, ) -from surfsman.draw import draw_border -from surfsman.cache import UNHIGHLIGHT_SURF_MAP +from ...surfsman.draw import draw_border +from ...surfsman.cache import UNHIGHLIGHT_SURF_MAP -from classes2d.single import Object2D +from ...classes2d.single import Object2D -from loopman.exception import QuitAppException +from ...loopman.exception import QuitAppException ### constants @@ -107,7 +107,7 @@ def run(self): ## over lineno panel if line numbers were shown if self.draw_lines == self.draw_lines_and_lineno: - + panel_rect = self.lineno_panel.rect blit_on_screen( @@ -397,7 +397,7 @@ def scroll(self, dx, dy): First, we must check whether there is more text beyond the scrolling area in the direction we want to peek (the opposite we want to scroll). - + This is important because if there isn't, we shouldn't scroll at all, so we set the delta to 0. @@ -458,7 +458,7 @@ def scroll(self, dx, dy): dy = 0 elif ( - text_rect.bottom + dy + text_rect.bottom + dy < self.scroll_area.bottom ): diff --git a/nodezator/textman/viewer/prep.py b/nodezator/textman/viewer/prep.py index 4fa03e27..bd095679 100644 --- a/nodezator/textman/viewer/prep.py +++ b/nodezator/textman/viewer/prep.py @@ -10,38 +10,38 @@ ### local imports -from config import APP_REFS +from ...config import APP_REFS -from dialog import create_and_show_dialog +from ...dialog import create_and_show_dialog -from syntaxman.exception import SyntaxMappingError +from ...syntaxman.exception import SyntaxMappingError -from syntaxman.utils import get_ready_theme +from ...syntaxman.utils import get_ready_theme -from fontsman.constants import FIRA_MONO_BOLD_FONT_PATH +from ...fontsman.constants import FIRA_MONO_BOLD_FONT_PATH -from ourstdlibs.timeutils import get_friendly_time -from ourstdlibs.behaviour import empty_function +from ...ourstdlibs.timeutils import get_friendly_time +from ...ourstdlibs.behaviour import empty_function -from classes2d.single import Object2D +from ...classes2d.single import Object2D -from surfsman.draw import draw_border -from surfsman.render import render_rect +from ...surfsman.draw import draw_border +from ...surfsman.render import render_rect -from surfsman.cache import RECT_SURF_MAP +from ...surfsman.cache import RECT_SURF_MAP -from textman.render import ( +from ...textman.render import ( get_text_size, render_text, ) -from textman.text import ( +from ...textman.text import ( get_normal_lines, get_highlighted_lines, ) ## common constants -from textman.viewer.constants import ( +from ...textman.viewer.constants import ( DEFAULT_TEXT_SETTINGS, TEXT_SETTINGS_PRESETS_MAP, TEXT_VIEWER_RECT, @@ -91,7 +91,7 @@ def view_text( syntax_highlighting (string) represents the name of a syntax used to highlight the text (for instance 'python'); - if an empty string, which is the default value, + if an empty string, which is the default value, or the name of an unsupported syntax is given, syntax highlighting isn't applied; if, otherwise, it indicates an available syntax, @@ -300,7 +300,7 @@ def view_text( ### the line numbers was required or not if show_line_number: - + ## set line drawing behaviour to draw both ## lines and their respective line numbers self.draw_lines = self.draw_lines_and_lineno @@ -311,7 +311,7 @@ def view_text( if syntax_highlighting: - + text_settings = theme_map['text_settings'] try: lineno_settings = ( @@ -437,7 +437,7 @@ def view_text( self.header_label.set(f":: {header_text} ::") if show_caption: - + self.header_label.rect.midleft = ( self.caption.rect.move(5, 0).midright ) diff --git a/nodezator/translation.py b/nodezator/translation.py index 35f98421..9f95d32e 100644 --- a/nodezator/translation.py +++ b/nodezator/translation.py @@ -5,15 +5,15 @@ ### local imports -from config import DATA_DIR +from .config import DATA_DIR -from userprefsman.main import USER_PREFS +from .userprefsman.main import USER_PREFS -from ourstdlibs.pyl import load_pyl +from .ourstdlibs.pyl import load_pyl -from ourstdlibs.treeutils import merge_nested_dicts +from .ourstdlibs.treeutils import merge_nested_dicts -from ourstdlibs.collections.nestedfromdict import ( +from .ourstdlibs.collections.nestedfromdict import ( NestedObjectFromDict diff --git a/nodezator/userprefsman/main.py b/nodezator/userprefsman/main.py index 1a176959..9251c478 100644 --- a/nodezator/userprefsman/main.py +++ b/nodezator/userprefsman/main.py @@ -9,15 +9,15 @@ ### local imports -from appinfo import APP_CONFIG_DIR_NAME +from ..appinfo import APP_CONFIG_DIR_NAME -from our3rdlibs.userlogger import USER_LOGGER +from ..our3rdlibs.userlogger import USER_LOGGER -from ourstdlibs.pyl import load_pyl +from ..ourstdlibs.pyl import load_pyl -from userprefsman.validation import validate_prefs_dict +from .validation import validate_prefs_dict -from logman.main import get_new_logger +from ..logman.main import get_new_logger ### module level logger @@ -85,11 +85,11 @@ ## if file exists, try loading it if CONFIG_FILEPATH.exists(): - + try: user_config_data = load_pyl(CONFIG_FILEPATH) except Exception: - + USER_LOGGER.exception( ERROR_LOADING_USER_PREFS_MESSAGE ) @@ -111,7 +111,7 @@ USER_LOGGER.info(UNEXISTENT_USER_PREFS_MESSAGE) if not APP_CONFIG_DIR.exists(): - + try: APP_CONFIG_DIR.mkdir(parents=True) except Exception: diff --git a/nodezator/widget/checkbutton.py b/nodezator/widget/checkbutton.py index ed71c169..83b1dff8 100644 --- a/nodezator/widget/checkbutton.py +++ b/nodezator/widget/checkbutton.py @@ -6,15 +6,15 @@ ### local imports -from ourstdlibs.behaviour import empty_function +from ..ourstdlibs.behaviour import empty_function -from classes2d.single import Object2D +from ..classes2d.single import Object2D -from surfsman.icon import render_layered_icon +from ..surfsman.icon import render_layered_icon -from surfsman.draw import draw_border +from ..surfsman.draw import draw_border -from colorsman.colors import ( +from ..colorsman.colors import ( CHECKBUTTON_FG, CHECKBUTTON_BG, CHECKBUTTON_OUTLINE, @@ -159,7 +159,7 @@ def get_surface_map( ### checkbutton is set to True; we do so by ### rendering a surface which represents the heavy ### check mark icon, with padding and a border; - + true_surf = render_layered_icon( chars=[chr(124)], @@ -256,7 +256,7 @@ def toggle_value(self, event): although we don't use it here, it is required in order to comply with the mouse action protocol; - + check pygame.event module documentation on pygame website for more info about this event object. @@ -294,7 +294,7 @@ def svg_repr(self): ) if self.value: - + r = self.rect.inflate(-12, -12) points = ( diff --git a/nodezator/widget/colorbutton.py b/nodezator/widget/colorbutton.py index 348499cc..d7cc64a5 100644 --- a/nodezator/widget/colorbutton.py +++ b/nodezator/widget/colorbutton.py @@ -13,47 +13,47 @@ ### local imports -from ourstdlibs.behaviour import empty_function +from ..ourstdlibs.behaviour import empty_function -from surfsman.draw import ( +from ..surfsman.draw import ( draw_checker_pattern, blit_aligned, ) -from surfsman.render import render_rect, combine_surfaces +from ..surfsman.render import render_rect, combine_surfaces -from classes2d.single import Object2D +from ..classes2d.single import Object2D -from imagesman.cache import IMAGE_SURFS_DB +from ..imagesman.cache import IMAGE_SURFS_DB -from surfsman.icon import render_layered_icon +from ..surfsman.icon import render_layered_icon -from alphamask.main import AlphaMask +from ..alphamask.main import AlphaMask -from fontsman.constants import ( +from ..fontsman.constants import ( ICON_FONT_PATH, ENC_SANS_BOLD_FONT_PATH, ) -from textman.render import render_text +from ..textman.render import render_text -from colorsman.viewer.main import view_colors +from ..colorsman.viewer.main import view_colors -from colorsman.editor.main import edit_colors +from ..colorsman.editor.main import edit_colors -from ourstdlibs.color.custom import ( +from ..ourstdlibs.color.custom import ( custom_format_color, validate_custom_color_format, ) -from colorsman.colors import ( +from ..colorsman.colors import ( BLACK, WHITE, COLORBUTTON_BG, TRANSP_COLOR_A, TRANSP_COLOR_B, ) -from pointsman2d.create import get_circle_points +from ..pointsman2d.create import get_circle_points ### constants @@ -585,7 +585,7 @@ def update_image(self): ## suitable position for index, surf in enumerate(color_surfs): - + x_offset = start + (index * step) blit_aligned( @@ -604,7 +604,7 @@ def on_mouse_release(self, event): It is required in order to comply with protocol used. We retrieve the mouse position from its "pos" attribute. - + Check pygame.event module documentation on pygame website for more info about this event object. @@ -698,7 +698,7 @@ def svg_repr(self): ] ): - + g.append( Element( 'polygon', @@ -752,7 +752,7 @@ def path_directives(x, y, width, height): no_of_colors = len(colors) for i, color in enumerate(colors, 1): - + ### if i == self.no_of_slots \ and no_of_colors > self.no_of_slots: diff --git a/nodezator/widget/intfloatentry/main.py b/nodezator/widget/intfloatentry/main.py index a0950ea6..2623afeb 100644 --- a/nodezator/widget/intfloatentry/main.py +++ b/nodezator/widget/intfloatentry/main.py @@ -17,34 +17,34 @@ ### local imports -from surfsman.render import render_rect +from ...surfsman.render import render_rect -from fontsman.constants import ( +from ...fontsman.constants import ( ENC_SANS_BOLD_FONT_HEIGHT, ENC_SANS_BOLD_FONT_PATH, ) -from ourstdlibs.behaviour import ( +from ...ourstdlibs.behaviour import ( empty_function, return_untouched, ) -from ourstdlibs.color.creation import get_contrasting_bw +from ...ourstdlibs.color.creation import get_contrasting_bw -from colorsman.colors import ( +from ...colorsman.colors import ( INT_FLOAT_ENTRY_FG, INT_FLOAT_ENTRY_BG, ) -from textman.cache import TEXT_SURFS_DB +from ...textman.cache import TEXT_SURFS_DB ## class for composition -from textman.entryedition.cursor import EntryCursor +from ...textman.entryedition.cursor import EntryCursor ## class extensions -from widget.intfloatentry.op import IntFloatOperations -from widget.intfloatentry.modes import IntFloatModes +from .op import IntFloatOperations +from .modes import IntFloatModes ### utility function @@ -312,7 +312,7 @@ class from the module winman.main. self.num_classes ) ) - + ## to guarantee the proper functioning of the ## feature, the arguments must always be positive @@ -401,7 +401,7 @@ class from the module winman.main. self.num_classes ) ) - + ## to guarantee the proper functioning of the ## feature, the arguments must always be positive diff --git a/nodezator/widget/intfloatentry/modes.py b/nodezator/widget/intfloatentry/modes.py index e91a2ca9..62158768 100644 --- a/nodezator/widget/intfloatentry/modes.py +++ b/nodezator/widget/intfloatentry/modes.py @@ -41,13 +41,13 @@ ### local imports -from pygameconstants import SCREEN_RECT +from ...pygameconstants import SCREEN_RECT -from surfsman.render import render_rect +from ...surfsman.render import render_rect -from classes2d.single import Object2D +from ...classes2d.single import Object2D -from loopman.exception import QuitAppException +from ...loopman.exception import QuitAppException ### constants @@ -117,7 +117,7 @@ def keyboard_edition_control(self): keyboard. """ for event in get_events(): - + if event.type == QUIT: raise QuitAppException elif event.type == KEYUP: @@ -238,7 +238,7 @@ def enable_expanded_view(self): ### (except we decrease the width a bit to ### provide a nice margin from the boundaries ### of the screen) - + new_rect = SCREEN_RECT.inflate(-40, 0) new_rect.height = self.rect.height @@ -281,7 +281,7 @@ def check_expanded_view_reversal(self): ### 'backups' attribute and update the image else: - + ( self.background, self.image, @@ -335,7 +335,7 @@ def mouse_edition_control(self): the mouse. """ for event in get_events(): - + if event.type == QUIT: raise QuitAppException ### if a shift key is pressed or released, @@ -347,7 +347,7 @@ def mouse_edition_control(self): ## shift key pressed elif event.type == KEYDOWN: - + if event.key in (K_LSHIFT, K_RSHIFT): self.change_shift_influence(True) @@ -437,16 +437,16 @@ def change_value_by_mouse_motion(self, mouse_pos): ## position of the mouse dragging origin with the ## horizontal distance between the center of the ## screen and the mouse position at the beginning - ## of this method + ## of this method if clamped_value == value: - self.dragging_origin_x += SCREEN_CENTERX - x_pos + self.dragging_origin_x += SCREEN_CENTERX - x_pos ## otherwise, set the clamped value as the new ## base value and reset the mouse dragging origin ## to the center of the screen - else: + else: self.base_value = clamped_value self.dragging_origin_x = SCREEN_CENTERX diff --git a/nodezator/widget/intfloatentry/op.py b/nodezator/widget/intfloatentry/op.py index 1a220044..585cf850 100644 --- a/nodezator/widget/intfloatentry/op.py +++ b/nodezator/widget/intfloatentry/op.py @@ -16,16 +16,16 @@ ### local imports -from classes2d.single import Object2D +from ...classes2d.single import Object2D -from loopman.exception import SwitchLoopException +from ...loopman.exception import SwitchLoopException -from ourstdlibs.behaviour import ( +from ...ourstdlibs.behaviour import ( empty_function, return_untouched, ) -from widget.intfloatentry.numeval import numeric_evaluation +from .numeval import numeric_evaluation INFS_AND_NANS = ( @@ -397,7 +397,7 @@ def evaluate_string(self, string): string or a string representing a numerical value with wrong syntax or numerical expression with wrong syntax); - + the error raised won't be caught, since this method is used in safe contexts (either with try/except clauses or with strings known to @@ -552,7 +552,7 @@ def set_range( msg = ( "value must be None or " - if self.allow_none + if self.allow_none else "value must be " diff --git a/nodezator/widget/literaldisplay.py b/nodezator/widget/literaldisplay.py index 738b83a5..491ed5e3 100644 --- a/nodezator/widget/literaldisplay.py +++ b/nodezator/widget/literaldisplay.py @@ -19,38 +19,38 @@ ### local imports -from ourstdlibs.behaviour import empty_function +from ..ourstdlibs.behaviour import empty_function -from surfsman.draw import blit_aligned, draw_depth_finish -from surfsman.render import render_rect, combine_surfaces -from surfsman.icon import render_layered_icon +from ..surfsman.draw import blit_aligned, draw_depth_finish +from ..surfsman.render import render_rect, combine_surfaces +from ..surfsman.icon import render_layered_icon -from classes2d.single import Object2D +from ..classes2d.single import Object2D -from textman.text import render_highlighted_line -from textman.render import ( +from ..textman.text import render_highlighted_line +from ..textman.render import ( fit_text, get_text_size, render_text, ) -from textman.viewer.main import view_text -from textman.editor.main import edit_text +from ..textman.viewer.main import view_text +from ..textman.editor.main import edit_text -from fontsman.constants import ( +from ..fontsman.constants import ( FIRA_MONO_BOLD_FONT_HEIGHT, FIRA_MONO_BOLD_FONT_PATH, ) -from syntaxman.utils import ( +from ..syntaxman.utils import ( AVAILABLE_SYNTAXES, SYNTAX_TO_MAPPING_FUNCTION, get_ready_theme, ) -from syntaxman.exception import SyntaxMappingError +from ..syntaxman.exception import SyntaxMappingError -from colorsman.colors import ( +from ..colorsman.colors import ( BLACK, WHITE, LITERAL_DISPLAY_BG, @@ -248,7 +248,7 @@ def on_mouse_release(self, event): it is required in order to comply with the mouse action protocol used; we retrieve the mouse position from its "pos" attribute; - + check pygame.event module documentation on pygame website for more info about this event object. @@ -337,7 +337,7 @@ def update_image(self): syntax_highlighting = 'python', if show_line_number: - + lineno_width, _ = get_text_size( '01', font_height=font_height, @@ -366,7 +366,7 @@ def update_image(self): except SyntaxMappingError: highlight_data = { - + ## store a dict item where the line index ## is the key and another dict is the value @@ -381,7 +381,7 @@ def update_image(self): (0, len(line_text)): 'normal' } - + ## for each line_index and respective line for line_index, line_text \ in enumerate(lines) @@ -440,7 +440,7 @@ def update_image(self): for line_number, line_text \ in enumerate(lines, 1): - + surf = render_text( text=str(line_number).rjust(2, '0'), font_height=font_height, @@ -577,7 +577,7 @@ def svg_repr(self): }, ) ) - + ### x, y = rect.topleft @@ -764,7 +764,7 @@ def svg_repr(self): text = pformat(self.value, width=20) if show_line_number: - + max_lineno_text = str(len(text.splitlines())) lineno_digits = len(max_lineno_text) @@ -818,7 +818,7 @@ def svg_repr(self): except SyntaxMappingError: highlight_data = { - + ## store a dict item where the line index ## is the key and another dict is the value @@ -833,7 +833,7 @@ def svg_repr(self): (0, len(line_text)): 'normal' } - + ## for each line_index and respective line for line_index, line_text \ in enumerate(lines) @@ -987,7 +987,7 @@ def svg_repr(self): for line_number, line_text \ in enumerate(lines, 1): - + y += font_height text_element = Element( diff --git a/nodezator/widget/literalentry.py b/nodezator/widget/literalentry.py index b63d5e2e..4e2c6992 100644 --- a/nodezator/widget/literalentry.py +++ b/nodezator/widget/literalentry.py @@ -42,34 +42,34 @@ ### local imports -from ourstdlibs.behaviour import ( +from ..ourstdlibs.behaviour import ( empty_function, ) -from ourstdlibs.color.creation import get_contrasting_bw +from ..ourstdlibs.color.creation import get_contrasting_bw -from classes2d.single import Object2D +from ..classes2d.single import Object2D -from surfsman.render import render_rect +from ..surfsman.render import render_rect -from fontsman.constants import ( +from ..fontsman.constants import ( FIRA_MONO_BOLD_FONT_HEIGHT, FIRA_MONO_BOLD_FONT_PATH, ) -from textman.editor.main import edit_text +from ..textman.editor.main import edit_text -from loopman.exception import ( +from ..loopman.exception import ( QuitAppException, SwitchLoopException, ) -from colorsman.colors import ( +from ..colorsman.colors import ( LITERAL_ENTRY_FG, LITERAL_ENTRY_BG, ) -from textman.entryedition.cursor import EntryCursor +from ..textman.entryedition.cursor import EntryCursor class LiteralEntry(Object2D): @@ -307,7 +307,7 @@ def update_image(self): def handle_events(self): """Iterate over event queue processing events.""" for event in get_events(): - + if event.type == QUIT: raise QuitAppException elif event.type == KEYUP: @@ -321,7 +321,7 @@ def handle_events(self): self.resume_editing() elif event.type == KEYDOWN: - + ### ignore keys below if event.key in ( @@ -435,7 +435,7 @@ def get_focus(self, event): required in order to comply with protocol used; when needed it can be used to retrieve the position of the mouse click, for instance. - + Check pygame.event module documentation on pygame website for more info about this event object. diff --git a/nodezator/widget/optionmenu/creation.py b/nodezator/widget/optionmenu/creation.py index b2a44a46..84ea6dd4 100644 --- a/nodezator/widget/optionmenu/creation.py +++ b/nodezator/widget/optionmenu/creation.py @@ -7,13 +7,13 @@ ### local imports -from surfsman.draw import blit_aligned, draw_border +from ...surfsman.draw import blit_aligned, draw_border -from surfsman.render import render_rect +from ...surfsman.render import render_rect -from surfsman.icon import render_layered_icon +from ...surfsman.icon import render_layered_icon -from textman.render import render_text +from ...textman.render import render_text ### constants diff --git a/nodezator/widget/optionmenu/main.py b/nodezator/widget/optionmenu/main.py index 4ed2c762..3ea443dd 100644 --- a/nodezator/widget/optionmenu/main.py +++ b/nodezator/widget/optionmenu/main.py @@ -12,25 +12,25 @@ ### local imports -from pygameconstants import SCREEN_RECT +from ...pygameconstants import SCREEN_RECT -from ourstdlibs.behaviour import ( +from ...ourstdlibs.behaviour import ( empty_function, empty_oblivious_function, ) -from ourstdlibs.dictutils import settings_to_hashable_repr +from ...ourstdlibs.dictutils import settings_to_hashable_repr -from classes2d.single import Object2D -from classes2d.collections import List2D +from ...classes2d.single import Object2D +from ...classes2d.collections import List2D -from fontsman.constants import ( +from ...fontsman.constants import ( ENC_SANS_BOLD_FONT_HEIGHT, ENC_SANS_BOLD_FONT_PATH, ) -from colorsman.colors import ( +from ...colorsman.colors import ( OPTION_MENU_FG, OPTION_MENU_BG, OPTION_MENU_HOVERED_FG, @@ -41,7 +41,7 @@ ## creation operations and objects -from widget.optionmenu.creation import ( +from .creation import ( STYLE_TO_ARROW_SURFS, get_arrow_surf, get_scroll_arrow_surfs, @@ -50,7 +50,7 @@ ) ## class extension -from widget.optionmenu.op import ( +from .op import ( OptionMenuLifetimeOperations ) @@ -106,7 +106,7 @@ def isliteral(value): ## 'option3' : option3_surf ## ## }, -## +## ## ( ## ## 'True', # antialiased @@ -713,7 +713,7 @@ def on_mouse_release(event): although not used, it is required in order to comply with protocol used; - + check pygame.event module documentation on pygame website for more info about this event object. diff --git a/nodezator/widget/optionmenu/op.py b/nodezator/widget/optionmenu/op.py index 1ce78a6c..eac45dcc 100644 --- a/nodezator/widget/optionmenu/op.py +++ b/nodezator/widget/optionmenu/op.py @@ -17,15 +17,15 @@ ### local imports -from pygameconstants import SCREEN, blit_on_screen +from ...pygameconstants import SCREEN, blit_on_screen -from classes2d.single import Object2D +from ...classes2d.single import Object2D -from loopman.exception import ( +from ...loopman.exception import ( QuitAppException, SwitchLoopException) -from colorsman.colors import BLACK +from ...colorsman.colors import BLACK class OptionMenuLifetimeOperations(Object2D): @@ -150,7 +150,7 @@ def reset_value_and_options( try: self.validate_value_and_options(value, options) except (ValueError, TypeError) as err: - + print(err) return @@ -187,7 +187,7 @@ def get_focus(self, event): required in order to comply with mouse action protocol; we use its "pos" attribute to retrieve the mouse position; - + check pygame.event module documentation on pygame website for more info about this event object. @@ -316,7 +316,7 @@ def scroll_when_hovering_scroll_arrow(self): left < mouse_x < right and not (top < mouse_y < bottom) ): - + self.scroll_vertically( -10 @@ -361,7 +361,7 @@ def choose_option(self, event): mouse action protocol; it is also necessary in this method, since its "pos" attribute is used to retrieve the mouse position; - + check pygame.event module documentation on pygame website for more info about this event object. diff --git a/nodezator/widget/optiontray/creation.py b/nodezator/widget/optiontray/creation.py index b67ed332..1dec821c 100644 --- a/nodezator/widget/optiontray/creation.py +++ b/nodezator/widget/optiontray/creation.py @@ -13,15 +13,15 @@ ### local imports -from surfsman.draw import blit_aligned, draw_border -from surfsman.render import render_rect +from ...surfsman.draw import blit_aligned, draw_border +from ...surfsman.render import render_rect -from classes2d.single import Object2D -from classes2d.collections import Iterable2D +from ...classes2d.single import Object2D +from ...classes2d.collections import Iterable2D -from textman.render import render_text +from ...textman.render import render_text -from colorsman.colors import OPTION_TRAY_OPTION_SEPARATOR +from ...colorsman.colors import OPTION_TRAY_OPTION_SEPARATOR ### class definition @@ -113,7 +113,7 @@ def create_surface_map(self): ## one being iterated as the selected one for selected_option in self.options: - + ## create copy of base surface base_copy = base_surf.copy() @@ -122,7 +122,7 @@ def create_surface_map(self): ## state for option in self.options: - + ## obtain a text object with a ## surface for that option; ## diff --git a/nodezator/widget/optiontray/main.py b/nodezator/widget/optiontray/main.py index 9784b318..495317ed 100644 --- a/nodezator/widget/optiontray/main.py +++ b/nodezator/widget/optiontray/main.py @@ -11,18 +11,18 @@ ### local imports -from ourstdlibs.behaviour import empty_function -from ourstdlibs.dictutils import settings_to_hashable_repr +from ...ourstdlibs.behaviour import empty_function +from ...ourstdlibs.dictutils import settings_to_hashable_repr -from textman.render import get_text_size +from ...textman.render import get_text_size -from fontsman.constants import ( +from ...fontsman.constants import ( ENC_SANS_BOLD_FONT_HEIGHT, ENC_SANS_BOLD_FONT_PATH, ) -from colorsman.colors import ( +from ...colorsman.colors import ( OPTION_TRAY_FG, OPTION_TRAY_BG, OPTION_TRAY_SELECTED_FG, @@ -30,11 +30,11 @@ ) ## class extension -from widget.optiontray.op import ( +from .op import ( OptionTrayLifetimeOperations, ) -from widget.optiontray.creation import ( +from .creation import ( OptionTrayCreationOperations, ) @@ -345,7 +345,7 @@ def validate_value_and_options(self, value, options): ## compare it with the maximum width allowed if total_width > self.max_width: - + raise ValueError( "sum of option width's must not" " surpass given 'max_width' when" @@ -504,7 +504,7 @@ def svg_repr(self): text_args = [ ( - str(option), + str(option), get_text_size( str(option), diff --git a/nodezator/widget/optiontray/op.py b/nodezator/widget/optiontray/op.py index 40af0735..23e9d0ca 100644 --- a/nodezator/widget/optiontray/op.py +++ b/nodezator/widget/optiontray/op.py @@ -1,7 +1,7 @@ """Option tray class extension with lifetime operations.""" ### local import -from classes2d.single import Object2D +from ...classes2d.single import Object2D class OptionTrayLifetimeOperations(Object2D): @@ -104,7 +104,7 @@ def reset_value_and_options( try: self.validate_value_and_options(value, options) except (ValueError, TypeError) as err: - + print(err) return @@ -152,7 +152,7 @@ def on_mouse_release(self, event): we retrieve the position of the mouse from it, to find which value was pressed; - + check pygame.event module documentation on pygame website for more info about this event object. diff --git a/nodezator/widget/stringentry.py b/nodezator/widget/stringentry.py index e12945b0..f2ae182d 100644 --- a/nodezator/widget/stringentry.py +++ b/nodezator/widget/stringentry.py @@ -37,37 +37,37 @@ ### local imports -from ourstdlibs.behaviour import ( +from ..ourstdlibs.behaviour import ( empty_function, return_untouched, ) -from ourstdlibs.stringutils import VALIDATION_COMMAND_MAP +from ..ourstdlibs.stringutils import VALIDATION_COMMAND_MAP -from ourstdlibs.color.creation import get_contrasting_bw +from ..ourstdlibs.color.creation import get_contrasting_bw -from classes2d.single import Object2D +from ..classes2d.single import Object2D -from surfsman.render import render_rect +from ..surfsman.render import render_rect -from fontsman.constants import ( +from ..fontsman.constants import ( ENC_SANS_BOLD_FONT_HEIGHT, ENC_SANS_BOLD_FONT_PATH, ) -from textman.editor.main import edit_text +from ..textman.editor.main import edit_text -from loopman.exception import ( +from ..loopman.exception import ( QuitAppException, SwitchLoopException, ) -from colorsman.colors import ( +from ..colorsman.colors import ( STRING_ENTRY_FG, STRING_ENTRY_BG, ) -from textman.entryedition.cursor import EntryCursor +from ..textman.entryedition.cursor import EntryCursor class StringEntry(Object2D): @@ -83,7 +83,7 @@ class StringEntry(Object2D): multi-line editing by pressing Ctrl-T. For instance, check this function call: - + function(**{key: value}) Where 'key' must always be a string, but can be any @@ -168,12 +168,12 @@ class from the module winman.main. validation_command (None, string or callable) if it is None, the instance is set up so that no validation is done. - + If it is a string, it must be a key in a preset map used to grab a valid command, for instance, the name of a built-in "str" method to use as the validation command. - + If it is a callable, it must accept a single argument and its return value is used to determine whether validation passed (when the @@ -385,7 +385,7 @@ def validation_command(self, validation_command): ### finally, let's store the validation command self._validation_command = command - + def get(self): """Return text content of widget.""" return self.value @@ -459,7 +459,7 @@ def update_image(self): def handle_events(self): """Iterate over event queue processing events.""" for event in get_events(): - + if event.type == QUIT: raise QuitAppException elif event.type == KEYUP: @@ -473,7 +473,7 @@ def handle_events(self): self.resume_editing() elif event.type == KEYDOWN: - + ### ignore keys below if event.key in ( @@ -587,7 +587,7 @@ def get_focus(self, event): required in order to comply with protocol used; when needed it can be used to retrieve the position of the mouse click, for instance. - + Check pygame.event module documentation on pygame website for more info about this event object. diff --git a/nodezator/widget/textdisplay.py b/nodezator/widget/textdisplay.py index 43aa2c66..2645e727 100644 --- a/nodezator/widget/textdisplay.py +++ b/nodezator/widget/textdisplay.py @@ -13,41 +13,41 @@ ### local imports -from ourstdlibs.behaviour import empty_function +from ..ourstdlibs.behaviour import empty_function -from ourstdlibs.stringutils import VALIDATION_COMMAND_MAP +from ..ourstdlibs.stringutils import VALIDATION_COMMAND_MAP -from surfsman.draw import blit_aligned, draw_depth_finish -from surfsman.render import render_rect, combine_surfaces -from surfsman.icon import render_layered_icon +from ..surfsman.draw import blit_aligned, draw_depth_finish +from ..surfsman.render import render_rect, combine_surfaces +from ..surfsman.icon import render_layered_icon -from classes2d.single import Object2D +from ..classes2d.single import Object2D -from textman.text import render_highlighted_line -from textman.render import ( +from ..textman.text import render_highlighted_line +from ..textman.render import ( fit_text, get_text_size, render_text, ) -from textman.viewer.main import view_text -from textman.editor.main import edit_text +from ..textman.viewer.main import view_text +from ..textman.editor.main import edit_text -from fontsman.constants import ( +from ..fontsman.constants import ( ENC_SANS_BOLD_FONT_HEIGHT, ENC_SANS_BOLD_FONT_PATH, FIRA_MONO_BOLD_FONT_PATH, ) -from syntaxman.utils import ( +from ..syntaxman.utils import ( AVAILABLE_SYNTAXES, SYNTAX_TO_MAPPING_FUNCTION, get_ready_theme, ) -from syntaxman.exception import SyntaxMappingError +from ..syntaxman.exception import SyntaxMappingError -from colorsman.colors import ( +from ..colorsman.colors import ( BLACK, WHITE, TEXT_DISPLAY_BG, @@ -185,10 +185,10 @@ def __init__( validation_command (None, string or callable) if it is None, the instance is set up so that no validation is done. - + If it is a string, it must be a key in a preset map used to grab a valid command. - + If it is a callable, it must accept a single argument and its return value is used to determine whether validation passed (when the @@ -384,7 +384,7 @@ def on_mouse_release(self, event): it is required in order to comply with the mouse action protocol used; we retrieve the mouse position from its "pos" attribute; - + check pygame.event module documentation on pygame website for more info about this event object. @@ -488,7 +488,7 @@ def update_image(self): syntax_highlighting = self.syntax_highlighting if show_line_number: - + lineno_width, _ = get_text_size( '01', font_height=font_height, @@ -510,14 +510,14 @@ def update_image(self): if syntax_highlighting: - + try: highlight_data = \ self.get_syntax_map(self.value) except SyntaxMappingError: highlight_data = { - + ## store a dict item where the line index ## is the key and another dict is the value @@ -532,7 +532,7 @@ def update_image(self): (0, len(line_text)): 'normal' } - + ## for each line_index and respective line for line_index, line_text \ in enumerate(lines) @@ -595,7 +595,7 @@ def update_image(self): for line_number, line_text \ in enumerate(lines, 1): - + if line_number > no_of_visible_lines: break surf = render_text( @@ -621,7 +621,7 @@ def update_image(self): for line_number, line_text \ in enumerate(lines, 1): - + surf = render_text( text=str(line_number).rjust(2, '0'), font_height=font_height, @@ -781,7 +781,7 @@ def svg_repr(self): }, ) ) - + ### x, y = rect.topleft @@ -967,7 +967,7 @@ def svg_repr(self): syntax_highlighting = self.syntax_highlighting if show_line_number: - + max_lineno_text = \ str(len(self.value.splitlines)) lineno_digits = len(max_lineno_text) @@ -1018,14 +1018,14 @@ def svg_repr(self): lines = self.value.splitlines()[:no_of_visible_lines] if syntax_highlighting: - + try: highlight_data = \ self.get_syntax_map(self.value) except SyntaxMappingError: highlight_data = { - + ## store a dict item where the line index ## is the key and another dict is the value @@ -1040,7 +1040,7 @@ def svg_repr(self): (0, len(line_text)): 'normal' } - + ## for each line_index and respective line for line_index, line_text \ in enumerate(lines) @@ -1199,7 +1199,7 @@ def svg_repr(self): in enumerate(lines, 1): y += font_height - + if line_number > no_of_visible_lines: break line_text = fit_text( @@ -1242,7 +1242,7 @@ def svg_repr(self): for line_number, line_text \ in enumerate(lines, 1): - + y += font_height text_element = Element( diff --git a/nodezator/winman/main.py b/nodezator/winman/main.py index d987fa77..28427417 100644 --- a/nodezator/winman/main.py +++ b/nodezator/winman/main.py @@ -8,53 +8,53 @@ ## general widgets and other tools -from config import APP_REFS +from ..config import APP_REFS -from userprefsman.main import USER_PREFS +from ..userprefsman.main import USER_PREFS -from dialog import ( +from ..dialog import ( create_and_show_dialog, show_dialog_from_key, ) -from pygameconstants import SCREEN_RECT, blit_on_screen +from ..pygameconstants import SCREEN_RECT, blit_on_screen -from appinfo import FULL_TITLE, ABBREVIATED_TITLE +from ..appinfo import FULL_TITLE, ABBREVIATED_TITLE -from ourstdlibs.path import get_custom_path_repr -from ourstdlibs.behaviour import empty_function +from ..ourstdlibs.path import get_custom_path_repr +from ..ourstdlibs.behaviour import empty_function -from ourstdlibs.collections.general import CallList +from ..ourstdlibs.collections.general import CallList -from ourstdlibs.pyl import save_pyl +from ..ourstdlibs.pyl import save_pyl -from ourstdlibs.path import save_timestamped_backup +from ..ourstdlibs.path import save_timestamped_backup -from our3rdlibs.userlogger import USER_LOGGER +from ..our3rdlibs.userlogger import USER_LOGGER -from our3rdlibs.behaviour import set_status_message +from ..our3rdlibs.behaviour import set_status_message -from logman.main import get_new_logger +from ..logman.main import get_new_logger -from fileman.main import select_path +from ..fileman.main import select_path -from recentfile import store_recent_file +from ..recentfile import store_recent_file -from surfsman.cache import UNHIGHLIGHT_SURF_MAP +from ..surfsman.cache import UNHIGHLIGHT_SURF_MAP -from surfsman.render import render_rect, render_separator +from ..surfsman.render import render_rect, render_separator -from classes2d.single import Object2D +from ..classes2d.single import Object2D -from colorsman.colors import GRAPH_BG, WINDOW_BG +from ..colorsman.colors import GRAPH_BG, WINDOW_BG -from memoryman import free_up_memory +from ..memoryman import free_up_memory ## widgets/tools for composition # related to node editing -from editing.main import EditingAssistant +from ..editing.main import EditingAssistant from graphman.main import GraphManager from graphman.nodepacksissues import ( @@ -220,7 +220,7 @@ def prepare_for_new_session(self): ("Select new node packs", 'select'), ("Cancel loading file", 'cancel'), ) - + answer = create_and_show_dialog( message, options, @@ -251,7 +251,7 @@ def prepare_for_new_session(self): ### as if we changed the file, so we save ### its current contents before assigning ### the new node packs - + if ( set(current_node_packs) != set(original_node_packs) @@ -259,7 +259,7 @@ def prepare_for_new_session(self): APP_REFS.data['node_packs'] = [ - str(path) + str(path) for path in current_node_packs ] @@ -290,7 +290,7 @@ def prepare_for_new_session(self): encoding='utf-8' ) - + ### try preparing graph manager for ### edition try: APP_REFS.gm.prepare_for_new_session() @@ -424,7 +424,7 @@ def set_state(self, state_name): ### assign behaviours to corresponding attributes for behaviour_name in BEHAVIOUR_NAMES: - + behaviour = behaviour_map[behaviour_name] setattr(self, behaviour_name, behaviour) From 458f32d518bbf58acfd36eca861a9a47ebcb5b86 Mon Sep 17 00:00:00 2001 From: pmp-p Date: Thu, 14 Jul 2022 00:34:34 +0200 Subject: [PATCH 3/8] rel import 2/x --- nodezator/audioplayer.py | 38 ++++----- nodezator/classes2d/surfaceswitcher.py | 4 +- nodezator/colorsman/editor/main.py | 2 +- nodezator/colorsman/editor/panel/colorsop.py | 24 +++--- nodezator/colorsman/editor/panel/data.py | 12 +-- nodezator/colorsman/editor/panel/main.py | 36 ++++----- nodezator/colorsman/editor/widgetop.py | 6 +- .../colorsman/editor/widgetsetup/button.py | 30 +++---- .../colorsman/editor/widgetsetup/constants.py | 2 +- .../colorsman/editor/widgetsetup/entry.py | 8 +- .../colorsman/editor/widgetsetup/label.py | 18 ++--- .../colorsman/editor/widgetsetup/scale.py | 8 +- nodezator/colorsman/picker/main.py | 33 ++++---- nodezator/colorsman/picker/op.py | 38 ++++----- nodezator/fontsman/preview/cache.py | 6 +- nodezator/fontsman/preview/render.py | 10 +-- nodezator/fontsman/viewer/main.py | 26 +++--- nodezator/fontsman/viewer/render.py | 12 +-- nodezator/graphman/callablenode/constants.py | 2 +- nodezator/graphman/callablenode/utils.py | 2 +- .../graphman/callablenode/vizprep/main.py | 34 ++++---- .../graphman/callablenode/vizprep/param.py | 12 +-- nodezator/graphman/socket/base.py | 2 +- nodezator/graphman/socket/input.py | 14 ++-- nodezator/graphman/socket/surfs.py | 12 +-- nodezator/imagesman/viewer/constants.py | 24 +++--- nodezator/imagesman/viewer/fullop.py | 22 ++--- nodezator/imagesman/viewer/main.py | 39 ++++----- nodezator/imagesman/viewer/normalop.py | 18 ++--- nodezator/our3rdlibs/scale.py | 8 +- nodezator/our3rdlibs/sortingeditor/main.py | 28 +++---- nodezator/our3rdlibs/sortingeditor/modes.py | 33 ++++---- .../ourstdlibs/collections/fldict/main.py | 2 +- nodezator/videopreview/cache.py | 16 ++-- nodezator/videopreview/constants.py | 2 +- nodezator/videopreview/previewer.py | 42 +++++----- nodezator/videopreview/render.py | 8 +- nodezator/widget/defaultholder.py | 12 +-- nodezator/widget/pathpreview/audio.py | 12 +-- nodezator/widget/pathpreview/base.py | 30 +++---- nodezator/widget/pathpreview/constants.py | 12 +-- nodezator/widget/pathpreview/font.py | 24 +++--- nodezator/widget/pathpreview/image.py | 26 +++--- nodezator/widget/pathpreview/path.py | 4 +- nodezator/widget/pathpreview/text.py | 81 ++++++++++--------- nodezator/widget/pathpreview/video.py | 47 ++++++----- nodezator/widget/sortingbutton.py | 24 +++--- 47 files changed, 449 insertions(+), 456 deletions(-) diff --git a/nodezator/audioplayer.py b/nodezator/audioplayer.py index 2c4f8f39..75a48464 100644 --- a/nodezator/audioplayer.py +++ b/nodezator/audioplayer.py @@ -34,43 +34,43 @@ ### local imports -from pygameconstants import ( +from .pygameconstants import ( SCREEN, SCREEN_RECT, FPS, maintain_fps, ) -from dialog import create_and_show_dialog +from .dialog import create_and_show_dialog -from logman.main import get_new_logger +from .logman.main import get_new_logger -from our3rdlibs.userlogger import USER_LOGGER +from .our3rdlibs.userlogger import USER_LOGGER -from ourstdlibs.behaviour import get_oblivious_callable +from .ourstdlibs.behaviour import get_oblivious_callable -from loopman.exception import ( +from .loopman.exception import ( QuitAppException, SwitchLoopException, ) -from classes2d.single import Object2D +from .classes2d.single import Object2D -from classes2d.surfaceswitcher import ( +from .classes2d.surfaceswitcher import ( SURF_SWITCHER_CLASS_MAP ) -from surfsman.draw import draw_border +from .surfsman.draw import draw_border -from surfsman.render import render_rect +from .surfsman.render import render_rect -from surfsman.icon import render_layered_icon +from .surfsman.icon import render_layered_icon -from textman.render import render_text +from .textman.render import render_text -from colorsman.colors import BLACK, WHITE +from .colorsman.colors import BLACK, WHITE -from widget.intfloatentry.main import IntFloatEntry +from .widget.intfloatentry.main import IntFloatEntry PlayingPausedObject = ( @@ -135,7 +135,7 @@ class AudioPlayer(Object2D): - + def __init__(self): """""" @@ -310,12 +310,12 @@ def handle_input(self): def handle_events(self): for event in get_events(): - + if event.type == QUIT: raise QuitAppException elif event.type == KEYUP: - + if event.key == K_ESCAPE: self.running = False @@ -325,7 +325,7 @@ def handle_events(self): self.on_mouse_click(event) elif event.type == MOUSEBUTTONUP: - + if event.button == 1: self.on_mouse_release(event) @@ -359,7 +359,7 @@ def handle_mouse_state(self): mouse_buttons_pressed[0] and volume_area.collidepoint(mouse_pos) ): - + self.volume = ( (mouse_x - volume_area.x) / volume_area.width ) diff --git a/nodezator/classes2d/surfaceswitcher.py b/nodezator/classes2d/surfaceswitcher.py index 9a419356..c7e8bbf5 100644 --- a/nodezator/classes2d/surfaceswitcher.py +++ b/nodezator/classes2d/surfaceswitcher.py @@ -5,9 +5,9 @@ ### local imports -from classes2d.single import SingleObjectBase +from .single import SingleObjectBase -from ourstdlibs.collections.general import FactoryDict +from ..ourstdlibs.collections.general import FactoryDict ### diff --git a/nodezator/colorsman/editor/main.py b/nodezator/colorsman/editor/main.py index fb07de23..714817a1 100644 --- a/nodezator/colorsman/editor/main.py +++ b/nodezator/colorsman/editor/main.py @@ -26,7 +26,7 @@ ## class for composition -from colorsman.editor.panel.main import ColorsPanel +from .panel.main import ColorsPanel class ColorsEditor( diff --git a/nodezator/colorsman/editor/panel/colorsop.py b/nodezator/colorsman/editor/panel/colorsop.py index ed8b7766..e2eb338f 100644 --- a/nodezator/colorsman/editor/panel/colorsop.py +++ b/nodezator/colorsman/editor/panel/colorsop.py @@ -8,35 +8,35 @@ ### local imports -from classes2d.collections import List2D +from ....classes2d.collections import List2D -from ourstdlibs.color.utils import ( +from ....ourstdlibs.color.utils import ( get_color_sorter_by_properties, ) -from ourstdlibs.color.creation import ( +from ....ourstdlibs.color.creation import ( random_color_from_existing, ) -from dialog import create_and_show_dialog +from ....dialog import create_and_show_dialog -from colorsman.color2d import Color2D +from ...color2d import Color2D -from colorsman.viewer.main import view_colors +from ...viewer.main import view_colors -from colorsman.picker.main import ( +from ...picker.main import ( pick_html_colors, pick_pygame_colors, ) -from colorsman.editor.panel.constants import ( +from .constants import ( COLOR_WIDGET_SIZE ) class ColorsOperations: """Colors-related operations for the colors panel.""" - + def set_colors(self, colors): """(Re)build list of color widgets from given colors. @@ -259,10 +259,10 @@ def sort_colors(self): def remove_duplicated_colors(self): """Remove widgets so each color appears only once.""" - ### reference widget list locally, for quick and + ### reference widget list locally, for quick and ### easier access widgets = self.widgets - + ### create two sets to keep track of colors we have ### already seen and widgets to be removed @@ -352,7 +352,7 @@ def remove_color_widgets(self, widgets_to_remove=()): ### reference the existing color widgets locally ### for quicker and easier access widgets = self.widgets - + ### if the iterable with widgets to remove is empty, ### use a list with a reference to the current widget ### instead diff --git a/nodezator/colorsman/editor/panel/data.py b/nodezator/colorsman/editor/panel/data.py index 890746d5..adb085f5 100644 --- a/nodezator/colorsman/editor/panel/data.py +++ b/nodezator/colorsman/editor/panel/data.py @@ -6,21 +6,21 @@ ### local imports -from ourstdlibs.pyl import load_pyl, save_pyl +from ....ourstdlibs.pyl import load_pyl, save_pyl -from ourstdlibs.color.custom import custom_format_color +from ....ourstdlibs.color.custom import custom_format_color -from dialog import create_and_show_dialog +from ....dialog import create_and_show_dialog -from fileman.main import select_path +from ....fileman.main import select_path class ImportExportOperations: """Operations to import/export colors.""" - + def import_colors(self): """Import colors from python literals in path(s).""" - + ### retrieve path(s) from file browser paths = select_path(caption="Select path(s)") diff --git a/nodezator/colorsman/editor/panel/main.py b/nodezator/colorsman/editor/panel/main.py index 49b3c387..422b3486 100644 --- a/nodezator/colorsman/editor/panel/main.py +++ b/nodezator/colorsman/editor/panel/main.py @@ -23,29 +23,23 @@ ### local imports -from pygameconstants import SCREEN +from ....pygameconstants import SCREEN -from classes2d.single import Object2D -from classes2d.collections import List2D +from ....classes2d.single import Object2D +from ....classes2d.collections import List2D -from surfsman.draw import draw_border_on_area -from surfsman.render import render_rect +from ....surfsman.draw import draw_border_on_area +from ....surfsman.render import render_rect -from surfsman.icon import render_layered_icon +from ....surfsman.icon import render_layered_icon -from colorsman.colors import BLACK, WINDOW_BG +from ....colorsman.colors import BLACK, WINDOW_BG -from colorsman.editor.panel.constants import ( - COLOR_WIDGET_SIZE - ) +from ....colorsman.editor.panel.constants import COLOR_WIDGET_SIZE -from colorsman.editor.panel.data import ( - ImportExportOperations - ) +from .data import ImportExportOperations -from colorsman.editor.panel.colorsop import ( - ColorsOperations - ) +from .colorsop import ColorsOperations ### module constants @@ -64,7 +58,7 @@ class ColorsPanel( ): """A panel to hold and display multiple colors.""" - + def __init__( self, colors_editor, @@ -182,7 +176,7 @@ def create_scroll_buttons(self): ) ): - + ## instantiate button obj = Object2D.from_surface( @@ -345,7 +339,7 @@ def move_widget(self, amount): ## of the rotation amount) elif index < new_index: - + slice_obj = slice(index, new_index+1) rotation_amount = -1 @@ -466,7 +460,7 @@ def on_mouse_release(self, event): ### the mouse (if there is one) for widget in self.widgets.get_colliding(scroll_area): - + ### if you find a color widget which collides ### with the mouse, make it the current color ### widget and break out of the "for loop" @@ -545,7 +539,7 @@ def draw(self): ### where the widget sits if current_widget.rect.colliderect(scroll_area): - + draw_border_on_area( image, current_widget.contrasting_color, diff --git a/nodezator/colorsman/editor/widgetop.py b/nodezator/colorsman/editor/widgetop.py index a792c6d4..4d254321 100644 --- a/nodezator/colorsman/editor/widgetop.py +++ b/nodezator/colorsman/editor/widgetop.py @@ -6,12 +6,12 @@ ### local imports -from ourstdlibs.color.largemaps import ( +from ...ourstdlibs.color.largemaps import ( HTML_COLOR_MAP, PYGAME_COLOR_MAP, ) -from ourstdlibs.color.conversion import ( +from ...ourstdlibs.color.conversion import ( COLOR_CONVERSION_MAP, hex_string_to_full_rgb, full_rgb_to_html_name, @@ -266,7 +266,7 @@ def update_from_name_entry( ## iterate over each item of the color map for name, color in color_map.items(): - + ## if the current color has the same value ## as one of the color from the map, then ## the color actually has a name, which is diff --git a/nodezator/colorsman/editor/widgetsetup/button.py b/nodezator/colorsman/editor/widgetsetup/button.py index edd9d69d..f01c006b 100644 --- a/nodezator/colorsman/editor/widgetsetup/button.py +++ b/nodezator/colorsman/editor/widgetsetup/button.py @@ -6,21 +6,21 @@ ### local imports -from ourstdlibs.collections.general import CallList +from ....ourstdlibs.collections.general import CallList -from ourstdlibs.behaviour import get_oblivious_callable +from ....ourstdlibs.behaviour import get_oblivious_callable -from textman.render import render_text +from ....textman.render import render_text -from surfsman.icon import render_layered_icon +from ....surfsman.icon import render_layered_icon -from surfsman.draw import draw_depth_finish -from surfsman.render import render_rect, combine_surfaces +from ....surfsman.draw import draw_depth_finish +from ....surfsman.render import render_rect, combine_surfaces -from classes2d.single import Object2D -from classes2d.collections import List2D +from ....classes2d.single import Object2D +from ....classes2d.collections import List2D -from colorsman.colors import ( +from ....colorsman.colors import ( BLACK, WHITE, BUTTON_FG, @@ -29,7 +29,7 @@ WINDOW_BG ) -from colorsman.editor.widgetsetup.constants import ( +from ....colorsman.editor.widgetsetup.constants import ( FONT_HEIGHT, TEXT_PADDING, ICON_HEIGHT, @@ -39,11 +39,11 @@ ## widgets -from widget.checkbutton import CheckButton +from ....widget.checkbutton import CheckButton -from widget.optionmenu.main import OptionMenu +from ....widget.optionmenu.main import OptionMenu -from widget.sortingbutton import SortingButton +from ....widget.sortingbutton import SortingButton def setup_buttons(self): @@ -471,7 +471,7 @@ def setup_buttons(self): ) ## "creation properties" option menu - + midleft = add_color_button.rect.move(5, 0).midright color_add_option_menu.rect.midleft = midleft @@ -487,7 +487,7 @@ def setup_buttons(self): ) ## property sorting button - + midleft = sort_colors_button.rect.move(5, 0).midright color_sorting_holder.rect.midleft = midleft diff --git a/nodezator/colorsman/editor/widgetsetup/constants.py b/nodezator/colorsman/editor/widgetsetup/constants.py index 14cbf26f..841abd43 100644 --- a/nodezator/colorsman/editor/widgetsetup/constants.py +++ b/nodezator/colorsman/editor/widgetsetup/constants.py @@ -1,7 +1,7 @@ """Constants for setting up the colors editor's widgets.""" ### local import -from fontsman.constants import ENC_SANS_BOLD_FONT_HEIGHT +from ....fontsman.constants import ENC_SANS_BOLD_FONT_HEIGHT ### height of text in pixels; also used as the height for diff --git a/nodezator/colorsman/editor/widgetsetup/entry.py b/nodezator/colorsman/editor/widgetsetup/entry.py index 556e5132..86b4da2f 100644 --- a/nodezator/colorsman/editor/widgetsetup/entry.py +++ b/nodezator/colorsman/editor/widgetsetup/entry.py @@ -2,10 +2,10 @@ ### local imports -from colorsman.editor.widgetsetup.constants import FONT_HEIGHT +from ...editor.widgetsetup.constants import FONT_HEIGHT ## extra utilities -from ourstdlibs.color.utils import ( +from ....ourstdlibs.color.utils import ( validate_hex_color_string, validate_html_color_name, validate_pygame_color_name, @@ -14,9 +14,9 @@ ## widgets -from widget.stringentry import StringEntry +from ....widget.stringentry import StringEntry -from widget.intfloatentry.main import IntFloatEntry +from ....widget.intfloatentry.main import IntFloatEntry def setup_entries(self): diff --git a/nodezator/colorsman/editor/widgetsetup/label.py b/nodezator/colorsman/editor/widgetsetup/label.py index fc0b3a8b..487d9a43 100644 --- a/nodezator/colorsman/editor/widgetsetup/label.py +++ b/nodezator/colorsman/editor/widgetsetup/label.py @@ -2,19 +2,19 @@ ### local imports -from textman.render import render_text +from ....textman.render import render_text -from surfsman.draw import blit_aligned -from surfsman.render import render_rect +from ....surfsman.draw import blit_aligned +from ....surfsman.render import render_rect -from surfsman.icon import render_layered_icon +from ....surfsman.icon import render_layered_icon -from classes2d.single import Object2D -from classes2d.collections import Set2D +from ....classes2d.single import Object2D +from ....classes2d.collections import Set2D -from colorsman.colors import BLACK, WINDOW_BG, WINDOW_FG +from ...colors import BLACK, WINDOW_BG, WINDOW_FG -from colorsman.editor.widgetsetup.constants import ( +from .constants import ( FONT_HEIGHT, TEXT_PADDING) @@ -64,7 +64,7 @@ def setup_labels(self): ) ### iterate over label text and position data, - ### building a custom set while you instantiate and + ### building a custom set while you instantiate and ### store the labels self.labels = Set2D( diff --git a/nodezator/colorsman/editor/widgetsetup/scale.py b/nodezator/colorsman/editor/widgetsetup/scale.py index 39a61e01..60095cd6 100644 --- a/nodezator/colorsman/editor/widgetsetup/scale.py +++ b/nodezator/colorsman/editor/widgetsetup/scale.py @@ -2,11 +2,11 @@ ### local imports -from imagesman.cache import IMAGE_SURFS_DB +from ....imagesman.cache import IMAGE_SURFS_DB -from classes2d.collections import List2D +from ....classes2d.collections import List2D -from our3rdlibs.scale import Scale +from ....our3rdlibs.scale import Scale @@ -80,7 +80,7 @@ def setup_scales(self): ("Hue", 0, 360, self.update_from_hls), ("Lightness", 50, 100, self.update_from_hls), - ("Saturation", 100, 100, self.update_from_hls), + ("Saturation", 100, 100, self.update_from_hls), ("Value", 100, 100, self.update_from_hsv), ("Red", 255, 255, self.update_from_rgb), diff --git a/nodezator/colorsman/picker/main.py b/nodezator/colorsman/picker/main.py index ccc59462..35c021b7 100644 --- a/nodezator/colorsman/picker/main.py +++ b/nodezator/colorsman/picker/main.py @@ -6,11 +6,11 @@ ### local imports -from pygameconstants import SCREEN_RECT +from ...pygameconstants import SCREEN_RECT -from ourstdlibs.color.utils import get_int_sequence_repr +from ...ourstdlibs.color.utils import get_int_sequence_repr -from ourstdlibs.color.conversion import ( +from ...ourstdlibs.color.conversion import ( full_rgb_to_hex_string, full_rgb_to_hls, full_rgb_to_html_name, @@ -18,41 +18,40 @@ full_rgba_to_luma, ) -from ourstdlibs.collections.general import ( +from ...ourstdlibs.collections.general import ( CallList, FactoryDict, ) -from ourstdlibs.behaviour import get_oblivious_callable +from ...ourstdlibs.behaviour import get_oblivious_callable -from classes2d.single import Object2D -from classes2d.collections import List2D +from ...classes2d.single import Object2D +from ...classes2d.collections import List2D -from surfsman.render import render_rect -from surfsman.draw import draw_border +from ...surfsman.render import render_rect +from ...surfsman.draw import draw_border -from textman.render import render_text +from ...textman.render import render_text -from textman.label.main import Label +from ...textman.label.main import Label -from fontsman.constants import ( +from ...fontsman.constants import ( ENC_SANS_BOLD_FONT_HEIGHT, ENC_SANS_BOLD_FONT_PATH, FIRA_MONO_BOLD_FONT_HEIGHT, FIRA_MONO_BOLD_FONT_PATH, ) -from colorsman.colors import ( +from ..colors import ( BUTTON_FG, BUTTON_BG, WINDOW_FG, WINDOW_BG, ) -from colorsman.picker.constants import ( - DEFAULT_LABEL_MESSAGE - ) +from .constants import DEFAULT_LABEL_MESSAGE + ## class extension -from colorsman.picker.op import Operations +from .op import Operations ### font settings diff --git a/nodezator/colorsman/picker/op.py b/nodezator/colorsman/picker/op.py index 1880b262..913d13e1 100644 --- a/nodezator/colorsman/picker/op.py +++ b/nodezator/colorsman/picker/op.py @@ -22,38 +22,38 @@ ### local imports -from pygameconstants import ( +from ...pygameconstants import ( SCREEN, SCREEN_RECT, blit_on_screen, ) -from ourstdlibs.color.largemaps import ( +from ...ourstdlibs.color.largemaps import ( HTML_COLOR_MAP, PYGAME_COLOR_MAP, ) -from ourstdlibs.color.custom import ( +from ...ourstdlibs.color.custom import ( custom_format_color, get_custom_sorted_colors, ) -from surfsman.icon import render_layered_icon +from ...surfsman.icon import render_layered_icon -from surfsman.cache import ( +from ...surfsman.cache import ( UNHIGHLIGHT_SURF_MAP, RECT_SURF_MAP, cache_screen_state, draw_cached_screen_state, ) -from loopman.main import LoopHolder +from ...loopman.main import LoopHolder -from colorsman.colors import BLACK, WHITE, WINDOW_BG +from ..colors import BLACK, WHITE, WINDOW_BG -from colorsman.color2d import Color2D +from ..color2d import Color2D -from colorsman.picker.constants import ( +from .constants import ( DEFAULT_LABEL_MESSAGE, ) @@ -290,7 +290,7 @@ def prepare_color_widgets( ## create more color objects if needed no_of_needed = ( - no_of_colors - len(existing_color2d_objs) + no_of_colors - len(existing_color2d_objs) ) if no_of_needed > 0: @@ -320,7 +320,7 @@ def prepare_color_widgets( for color_widget, color \ in zip(color_widgets, sorted_colors): - + ## set the color and size color_widget.set_color(color) @@ -383,7 +383,7 @@ def event_handling(self): ### settings for event in get_events(): - + ### quit the application if event.type == QUIT: self.quit() @@ -392,7 +392,7 @@ def event_handling(self): ### the loop elif event.type == KEYUP: - + if event.key == K_ESCAPE: self.cancel = True @@ -403,7 +403,7 @@ def event_handling(self): ### with the event object elif event.type == MOUSEBUTTONUP: - + if event.button == 1: self.on_mouse_release(event) @@ -413,7 +413,7 @@ def event_handling(self): elif event.type == MOUSEMOTION: self.on_mouse_motion(event) - + ### alias the event handling operation as the ### "gud operation" named 'handle_input' @@ -447,7 +447,7 @@ def on_mouse_release(self, event): ### if there is one for color_widget in self.color_widgets: - + ## if color widget collides, toggle the ## 'chosen' flag, redraw respective surfaces ## and the widget outline and break out of @@ -483,7 +483,7 @@ def on_mouse_release(self, event): ### one else: - + ## if a button collides, execute its mouse ## release action if it has one (passing the ## event object along) and break out of the @@ -492,7 +492,7 @@ def on_mouse_release(self, event): for button in self.buttons: if button.rect.collidepoint(mouse_pos): - + try: method = button.on_mouse_release except AttributeError: pass else: method(event) @@ -531,7 +531,7 @@ def on_mouse_motion(self, event): ## of the "for loop" if color_widget.rect.collidepoint(mouse_pos): - + ## set text of labels # retrieve color info diff --git a/nodezator/fontsman/preview/cache.py b/nodezator/fontsman/preview/cache.py index 0f62938a..050e504c 100644 --- a/nodezator/fontsman/preview/cache.py +++ b/nodezator/fontsman/preview/cache.py @@ -30,12 +30,12 @@ ### local imports -from ourstdlibs.dictutils import ( +from ...ourstdlibs.dictutils import ( settings_to_hashable_repr, hashable_repr_to_settings, ) -from fontsman.preview.render import render_font_preview +from ...fontsman.preview.render import render_font_preview class FontPreviewsDatabase(dict): @@ -43,7 +43,7 @@ class FontPreviewsDatabase(dict): Extends the built-in dict. """ - + def __missing__(self, key): """Create, store and return dict for given key. diff --git a/nodezator/fontsman/preview/render.py b/nodezator/fontsman/preview/render.py index 24b63920..02950ab4 100644 --- a/nodezator/fontsman/preview/render.py +++ b/nodezator/fontsman/preview/render.py @@ -9,17 +9,17 @@ ### local imports -from classes2d.single import Object2D +from ...classes2d.single import Object2D -from classes2d.collections import List2D +from ...classes2d.collections import List2D -from surfsman.render import render_rect +from ...surfsman.render import render_rect -from surfsman.draw import ( +from ...surfsman.draw import ( draw_not_found_icon, ) -from colorsman.colors import ( +from ...colorsman.colors import ( BLACK, WHITE, IMAGE_NOT_FOUND_FG, IMAGE_NOT_FOUND_BG, diff --git a/nodezator/fontsman/viewer/main.py b/nodezator/fontsman/viewer/main.py index d82d992c..49948ef6 100644 --- a/nodezator/fontsman/viewer/main.py +++ b/nodezator/fontsman/viewer/main.py @@ -31,23 +31,23 @@ ### local imports -from pygameconstants import SCREEN_RECT +from ...pygameconstants import SCREEN_RECT -from dialog import create_and_show_dialog +from ...dialog import create_and_show_dialog -from logman.main import get_new_logger +from ...logman.main import get_new_logger -from our3rdlibs.userlogger import USER_LOGGER +from ...our3rdlibs.userlogger import USER_LOGGER -from loopman.main import LoopHolder +from ...loopman.main import LoopHolder -from classes2d.single import Object2D +from ...classes2d.single import Object2D -from classes2d.collections import List2D +from ...classes2d.collections import List2D -from surfsman.render import render_rect +from ...surfsman.render import render_rect -from fontsman.viewer.render import render_char_info +from .render import render_char_info CHARS = ( @@ -144,7 +144,7 @@ def view_fonts(self, font_paths, index=0): self.loop() def prepare(self): - + font = self.font_obj_map[self.font_path] self.char_objs = List2D( @@ -197,13 +197,13 @@ def handle_key_states(self): def handle_events(self): - + for event in get_events(): - + if event.type == QUIT: self.quit() elif event.type == KEYUP: - + if event.key == K_ESCAPE: self.running = False diff --git a/nodezator/fontsman/viewer/render.py b/nodezator/fontsman/viewer/render.py index 41a7ae95..878d07cc 100644 --- a/nodezator/fontsman/viewer/render.py +++ b/nodezator/fontsman/viewer/render.py @@ -2,24 +2,24 @@ ### local imports -from classes2d.single import Object2D +from ...classes2d.single import Object2D -from fontsman.constants import ( +from ...fontsman.constants import ( FIRA_MONO_BOLD_FONT_HEIGHT, FIRA_MONO_BOLD_FONT_PATH) -from textman.render import render_text +from ...textman.render import render_text -from surfsman.render import combine_surfaces +from ...surfsman.render import combine_surfaces -from colorsman.colors import BLACK, WHITE +from ...colorsman.colors import BLACK, WHITE SIZE_FORMATTER = '{}x{}'.format def render_char_info(char, font): - + char_surf = font.render(char, True, BLACK, WHITE) surfs = [ diff --git a/nodezator/graphman/callablenode/constants.py b/nodezator/graphman/callablenode/constants.py index 1bee51fe..373886f2 100644 --- a/nodezator/graphman/callablenode/constants.py +++ b/nodezator/graphman/callablenode/constants.py @@ -1,7 +1,7 @@ """Constants for the callable node class.""" ### local import -from fontsman.constants import ENC_SANS_BOLD_FONT_HEIGHT +from ...fontsman.constants import ENC_SANS_BOLD_FONT_HEIGHT FONT_HEIGHT = ENC_SANS_BOLD_FONT_HEIGHT diff --git a/nodezator/graphman/callablenode/utils.py b/nodezator/graphman/callablenode/utils.py index 75a045d4..8db7519c 100644 --- a/nodezator/graphman/callablenode/utils.py +++ b/nodezator/graphman/callablenode/utils.py @@ -1,7 +1,7 @@ """Facility for widget data update for node classes.""" ### local import -from our3rdlibs.behaviour import indicate_unsaved +from ...our3rdlibs.behaviour import indicate_unsaved def update_with_widget( diff --git a/nodezator/graphman/callablenode/vizprep/main.py b/nodezator/graphman/callablenode/vizprep/main.py index ce3fcecd..69a53f4f 100644 --- a/nodezator/graphman/callablenode/vizprep/main.py +++ b/nodezator/graphman/callablenode/vizprep/main.py @@ -6,25 +6,25 @@ ### local imports -from config import APP_REFS +from ....config import APP_REFS -from ourstdlibs.collections.fldict.main import FlatListDict +from ....ourstdlibs.collections.fldict.main import FlatListDict -from classes2d.single import Object2D +from ....classes2d.single import Object2D -from textman.render import render_text +from ....textman.render import render_text -from rectsman.main import RectsManager +from ....rectsman.main import RectsManager -from colorsman.colors import ( +from ....colorsman.colors import ( NODE_CATEGORY_COLORS, NODE_TITLE, BLACK, ) -from graphman.socket.surfs import type_to_codename +from ....graphman.socket.surfs import type_to_codename -from graphman.callablenode.constants import ( +from ....graphman.callablenode.constants import ( FONT_HEIGHT, NODE_WIDTH, ) @@ -32,26 +32,26 @@ ## functions for injection -from graphman.callablenode.vizprep.param import ( +from ....graphman.callablenode.vizprep.param import ( create_parameter_objs ) -from graphman.callablenode.vizprep.varparam import ( +from ....graphman.callablenode.vizprep.varparam import ( create_var_parameter_objs ) ## class extension -from graphman.callablenode.vizprep.bodysetup.main import ( +from ....graphman.callablenode.vizprep.bodysetup.main import ( BodySetupOperations ) ## class for composition -from graphman.socket.output import OutputSocket +from ....graphman.socket.output import OutputSocket ## other objects for composition -from graphman.callablenode.surfs import ( +from ....graphman.callablenode.surfs import ( NODE_ROOFS_MAP, TOP_CORNERS_MAP, NORMAL_BOTTOM_CORNERS, @@ -363,7 +363,7 @@ def create_input_related_objects(self): ### instantiate a dict to hold objects indicating ### that a subparameter must be unpacked when - ### the node is executed + ### the node is executed self.subparam_unpacking_icon_flmap = ( FlatListDict() ) @@ -484,13 +484,13 @@ def create_output_sockets(self): ### create a new dictionary holding output socket ### instances mapped to the name of the output ### they represent (also reference it locally); - ### + ### ### here we use key-value pairs from the ordered ### output map, which is an ordered dict where ### each key is the name of the output and the ### value is the expected type of the output to be ### sent; - ### + ### ### the value is called "expected type" because ### the type isn't enforced, it only serves to ### indicate which type to expected, just like @@ -572,7 +572,7 @@ def create_bottom_objects(self): bottomleft_corner.rect.topright = \ self.foot.rect.topleft - # bottomright corner + # bottomright corner bottomright_corner = Object2D() bottomright_corner.image = NORMAL_BOTTOM_CORNERS[1] diff --git a/nodezator/graphman/callablenode/vizprep/param.py b/nodezator/graphman/callablenode/vizprep/param.py index 5ab9a516..c9f8889f 100644 --- a/nodezator/graphman/callablenode/vizprep/param.py +++ b/nodezator/graphman/callablenode/vizprep/param.py @@ -8,20 +8,20 @@ ### local imports -from graphman.widget.utils import WIDGET_CLASS_MAP +from ...widget.utils import WIDGET_CLASS_MAP -from graphman.callablenode.utils import update_with_widget +from ...callablenode.utils import update_with_widget -from graphman.socket.surfs import type_to_codename +from ...socket.surfs import type_to_codename ## classes for composition -from graphman.socket.input import InputSocket +from ...socket.input import InputSocket -from widget.defaultholder import DefaultHolder +from ....widget.defaultholder import DefaultHolder -from rectsman.main import RectsManager +from ....rectsman.main import RectsManager def create_parameter_objs(self, param_obj): diff --git a/nodezator/graphman/socket/base.py b/nodezator/graphman/socket/base.py index 5e648688..97b6ef63 100644 --- a/nodezator/graphman/socket/base.py +++ b/nodezator/graphman/socket/base.py @@ -1,5 +1,5 @@ -from classes2d.single import Object2D +from ...classes2d.single import Object2D class Socket(Object2D): diff --git a/nodezator/graphman/socket/input.py b/nodezator/graphman/socket/input.py index 97ae5a23..8cc7a94e 100644 --- a/nodezator/graphman/socket/input.py +++ b/nodezator/graphman/socket/input.py @@ -10,16 +10,16 @@ ### local imports -from dialog import create_and_show_dialog +from ...dialog import create_and_show_dialog -from our3rdlibs.behaviour import ( +from ...our3rdlibs.behaviour import ( indicate_unsaved, set_status_message, ) -from graphman.socket.base import Socket +from ..socket.base import Socket -from graphman.socket.surfs import CODENAME_TO_STYLE_MAP +from ..socket.surfs import CODENAME_TO_STYLE_MAP class InputSocket(Socket): @@ -65,7 +65,7 @@ def __init__( self.parameter_name = parameter_name self.subparameter_index = subparameter_index - ## store type codename and perform related setups + ## store type codename and perform related setups self.update_type_codename(type_codename) ### obtain rect from image and position it using @@ -97,7 +97,7 @@ def update_type_codename(self, type_codename): def on_right_mouse_release(self, event): if self.subparameter_index is None: return - + options = [ ("Mark input for unpacking", 'pack'), ("Unmark input for unpacking", 'unpack'), @@ -130,7 +130,7 @@ def on_right_mouse_release(self, event): self.unmark_for_unpacking() def mark_for_unpacking(self): - + if self.subparameter_index in ( self diff --git a/nodezator/graphman/socket/surfs.py b/nodezator/graphman/socket/surfs.py index 42da7e66..8206ca02 100644 --- a/nodezator/graphman/socket/surfs.py +++ b/nodezator/graphman/socket/surfs.py @@ -9,9 +9,9 @@ ### local imports -from surfsman.icon import render_layered_icon +from ...surfsman.icon import render_layered_icon -from colorsman.colors import ( +from ...colorsman.colors import ( ## hollow socket HOLLOW_SOCKET_OUTLINE, @@ -102,7 +102,7 @@ frozenset((int, float, None)) : 'number', - # list and tuple related + # list and tuple related list : 'list', tuple : 'tuple', @@ -147,7 +147,7 @@ ), - # list and tuple related + # list and tuple related 'list' : ( LIST_TYPE_OUTLINE, @@ -192,7 +192,7 @@ ### each value within the map CODENAME_TO_STYLE_MAP.update( - + ( codename, @@ -286,7 +286,7 @@ def type_to_codename(type_): for (outline_color, fill_color, svg_class_name, *_ ) \ in CODENAME_TO_STYLE_MAP.values(): - + SOCKET_AND_LINE_CSS += f''' g.node > circle.{svg_class_name} {{ diff --git a/nodezator/imagesman/viewer/constants.py b/nodezator/imagesman/viewer/constants.py index 477253d4..bdd04a7c 100644 --- a/nodezator/imagesman/viewer/constants.py +++ b/nodezator/imagesman/viewer/constants.py @@ -2,32 +2,30 @@ ### local imports -from pygameconstants import SCREEN_RECT +from ...pygameconstants import SCREEN_RECT -from classes2d.single import Object2D -from classes2d.collections import List2D +from ...classes2d.single import Object2D +from ...classes2d.collections import List2D -from fontsman.constants import ( +from ...fontsman.constants import ( ENC_SANS_BOLD_FONT_HEIGHT, ENC_SANS_BOLD_FONT_PATH) -from textman.label.main import Label +from ...textman.label.main import Label -from textman.render import render_text +from ...textman.render import render_text -from imagesman.cache import CachedImageObject +from ...surfsman.render import combine_surfaces -from surfsman.render import combine_surfaces +from ...surfsman.icon import render_layered_icon -from surfsman.icon import render_layered_icon - -from colorsman.colors import ( +from ...colorsman.colors import ( BLACK, WHITE, IMAGES_VIEWER_FG, IMAGES_VIEWER_BG, THUMB_BG) - +from ..cache import CachedImageObject VIEWER_BORDER_THICKNESS = 2 VIEWER_PADDING = 5 @@ -179,7 +177,7 @@ VIEWER_OBJS.append(SMALL_THUMB) -PATH_LABEL = Label( +PATH_LABEL = Label( text='dummy text', font_height = ENC_SANS_BOLD_FONT_HEIGHT, font_path = ENC_SANS_BOLD_FONT_PATH, diff --git a/nodezator/imagesman/viewer/fullop.py b/nodezator/imagesman/viewer/fullop.py index 7d6719b6..63cca6da 100644 --- a/nodezator/imagesman/viewer/fullop.py +++ b/nodezator/imagesman/viewer/fullop.py @@ -34,30 +34,30 @@ ### local imports -from pygameconstants import ( +from ...pygameconstants import ( SCREEN, SCREEN_RECT, blit_on_screen, ) -from surfsman.draw import draw_border_on_area +from ...surfsman.draw import draw_border_on_area -from classes2d.single import Object2D +from ...classes2d.single import Object2D -from loopman.exception import QuitAppException +from ...loopman.exception import QuitAppException -from surfsman.cache import ( +from ...surfsman.cache import ( UNHIGHLIGHT_SURF_MAP, draw_cached_screen_state, ) -from our3rdlibs.keyconst import KEYPAD_TO_COORDINATE_MAP +from ...our3rdlibs.keyconst import KEYPAD_TO_COORDINATE_MAP -from colorsman.colors import IMAGES_VIEWER_BORDER +from ...colorsman.colors import IMAGES_VIEWER_BORDER -from imagesman.cache import IMAGE_SURFS_DB +from ..cache import IMAGE_SURFS_DB -from imagesman.viewer.constants import ( +from .constants import ( VIEWER_BORDER_THICKNESS, LARGE_THUMB, PATH_LABEL) @@ -86,7 +86,7 @@ def full_prepare(self): def full_handle_input(self): for event in get_events(): - + ### TODO this will cause cleaning/tear down to ### skipped; address it, including the same ### behaviour occurring in other state managers @@ -94,7 +94,7 @@ def full_handle_input(self): if event.type == QUIT: raise QuitAppException() elif event.type == KEYDOWN: - + if event.key in (K_ESCAPE, K_f): self.enable_normal_mode() diff --git a/nodezator/imagesman/viewer/main.py b/nodezator/imagesman/viewer/main.py index d3549614..4a1a8007 100644 --- a/nodezator/imagesman/viewer/main.py +++ b/nodezator/imagesman/viewer/main.py @@ -6,42 +6,43 @@ ### local imports -from pygameconstants import ( +from ...pygameconstants import ( FPS, maintain_fps, ) -from ourstdlibs.behaviour import empty_function +from ...ourstdlibs.behaviour import empty_function -from classes2d.single import Object2D -from classes2d.collections import List2D +from ...classes2d.single import Object2D +from ...classes2d.collections import List2D -from surfsman.render import render_rect +from ...surfsman.render import render_rect -from surfsman.cache import ( +from ...surfsman.cache import ( cache_screen_state, draw_cached_screen_state ) -from imagesman.cache import IMAGE_SURFS_DB -from colorsman.colors import ( + +from ...colorsman.colors import ( IMAGES_VIEWER_FG, IMAGES_VIEWER_BG, THUMB_BG) +from ..cache import IMAGE_SURFS_DB -from imagesman.viewer.constants import ( - VIEWER_RECT, - VIEWER_ICON, - VIEWER_CAPTION, - SMALL_THUMB, - SMALL_THUMB_SETTINGS, - VIEWER_BORDER_THICKNESS, - VIEWER_PADDING) +from .constants import ( + VIEWER_RECT, + VIEWER_ICON, + VIEWER_CAPTION, + SMALL_THUMB, + SMALL_THUMB_SETTINGS, + VIEWER_BORDER_THICKNESS, + VIEWER_PADDING) -from imagesman.viewer.normalop import NormalModeOperations -from imagesman.viewer.fullop import FullModeOperations +from .normalop import NormalModeOperations +from .fullop import FullModeOperations ### TODO finish subpackage (implementing viewer) @@ -112,7 +113,7 @@ def view_images(self, image_paths): self.running = True while self.running: - + maintain_fps(FPS) self.handle_input() diff --git a/nodezator/imagesman/viewer/normalop.py b/nodezator/imagesman/viewer/normalop.py index 8bc743a3..5a37753a 100644 --- a/nodezator/imagesman/viewer/normalop.py +++ b/nodezator/imagesman/viewer/normalop.py @@ -29,20 +29,20 @@ ### local imports -from surfsman.draw import ( +from ...surfsman.draw import ( draw_border, draw_border_on_area, ) -from surfsman.cache import draw_cached_screen_state +from ...surfsman.cache import draw_cached_screen_state -from classes2d.single import Object2D +from ...classes2d.single import Object2D -from loopman.exception import QuitAppException +from ...loopman.exception import QuitAppException -from colorsman.colors import IMAGES_VIEWER_BORDER +from ...colorsman.colors import IMAGES_VIEWER_BORDER -from imagesman.viewer.constants import ( +from .constants import ( VIEWER_BORDER_THICKNESS, LARGE_THUMB, PATH_LABEL) @@ -58,11 +58,11 @@ def normal_prepare(self): def normal_handle_input(self): for event in get_events(): - + if event.type == QUIT: raise QuitAppException() elif event.type == KEYDOWN: - + if event.key == K_ESCAPE: self.running = False @@ -208,7 +208,7 @@ def normal_response_draw(self): for ( index, thumb_obj ) in enumerate(self.thumb_objects): - + thumb_rect = thumb_obj.rect if thumb_rect.colliderect(rect): diff --git a/nodezator/our3rdlibs/scale.py b/nodezator/our3rdlibs/scale.py index dccee158..a92c69e4 100644 --- a/nodezator/our3rdlibs/scale.py +++ b/nodezator/our3rdlibs/scale.py @@ -11,11 +11,11 @@ ### local imports -from ourstdlibs.behaviour import empty_function +from ..ourstdlibs.behaviour import empty_function -from classes2d.single import Object2D +from ..classes2d.single import Object2D -from surfsman.icon import render_layered_icon +from ..surfsman.icon import render_layered_icon ### constant definition @@ -28,7 +28,7 @@ chr(ordinal) for ordinal in (81, 82) ], - colors = [(18, 18, 18), (30, 130, 70)], + colors = [(18, 18, 18), (30, 130, 70)], dimension_name = 'height', dimension_value = 15, diff --git a/nodezator/our3rdlibs/sortingeditor/main.py b/nodezator/our3rdlibs/sortingeditor/main.py index 98ae73b8..a2717d1e 100644 --- a/nodezator/our3rdlibs/sortingeditor/main.py +++ b/nodezator/our3rdlibs/sortingeditor/main.py @@ -16,32 +16,32 @@ ### local imports -from pygameconstants import ( +from ...pygameconstants import ( SCREEN_RECT, FPS, maintain_fps, ) -from ourstdlibs.behaviour import get_oblivious_callable +from ...ourstdlibs.behaviour import get_oblivious_callable -from ourstdlibs.collections.general import CallList +from ...ourstdlibs.collections.general import CallList -from surfsman.draw import blit_aligned -from surfsman.render import render_rect +from ...surfsman.draw import blit_aligned +from ...surfsman.render import render_rect -from classes2d.single import Object2D -from classes2d.collections import List2D, Set2D +from ...classes2d.single import Object2D +from ...classes2d.collections import List2D, Set2D -from surfsman.icon import render_layered_icon +from ...surfsman.icon import render_layered_icon -from textman.render import render_text +from ...textman.render import render_text -from fontsman.constants import ( +from ...fontsman.constants import ( ENC_SANS_BOLD_FONT_HEIGHT, ENC_SANS_BOLD_FONT_PATH, ) -from colorsman.colors import ( +from ...colorsman.colors import ( BLACK, BUTTON_FG, BUTTON_BG, WINDOW_FG, WINDOW_BG, @@ -51,7 +51,7 @@ ) ## class extension -from our3rdlibs.sortingeditor.modes import ( +from ...our3rdlibs.sortingeditor.modes import ( SortingEditorModes ) @@ -106,7 +106,7 @@ def __init__(self): foreground_color=WINDOW_FG, background_color=WINDOW_BG ) - + for surf, surf_offset in ( (icon, (10, 10)), @@ -356,7 +356,7 @@ def sort_sequence(self, sorted_items, available_items): ### start the widget loop while self.running: - + ## maintain a constant framerate maintain_fps(FPS) diff --git a/nodezator/our3rdlibs/sortingeditor/modes.py b/nodezator/our3rdlibs/sortingeditor/modes.py index ec5359d1..b611a5cc 100644 --- a/nodezator/our3rdlibs/sortingeditor/modes.py +++ b/nodezator/our3rdlibs/sortingeditor/modes.py @@ -41,18 +41,19 @@ ### local imports -from ourstdlibs.behaviour import empty_function -from ourstdlibs.collections.general import CallList -from surfsman.draw import draw_border +from ...surfsman.draw import draw_border -from classes2d.single import Object2D +from ...classes2d.single import Object2D -from loopman.exception import QuitAppException +from ...loopman.exception import QuitAppException -from colorsman.colors import ITEM_OUTLINE +from ...colorsman.colors import ITEM_OUTLINE +from ...ourstdlibs.behaviour import empty_function + +from ...ourstdlibs.collections.general import CallList ### constant SCROLL_X_SPEED = 20 @@ -109,7 +110,7 @@ class SortingEditorModes(Object2D): def normal_mode_handle_events(self): """Event handling for the normal mode.""" for event in get_events(): - + ### raise custom exception if user tries to ### quit the app if event.type == QUIT: raise QuitAppException @@ -122,7 +123,7 @@ def normal_mode_handle_events(self): ### "sort_sequence" method) elif event.type == KEYUP: - + if event.key == K_ESCAPE: self.running = False @@ -155,7 +156,7 @@ def on_mouse_click(self, event): We use it to retrieve the mouse position when the mouse left button is pressed; it is also required in order to comply w/ the protocol used; - + Check pygame.event module documentation on pygame website for more info about this event object. @@ -177,12 +178,12 @@ def on_mouse_click(self, event): if item.rect.collidepoint(mouse_pos): break - + ### if we didn't break out of the "for loop", it ### means we didn't collide with any items, so ### we can exit the method by returning else: return - + ### otherwise, we have hit an item, so we enable ### the drag mode passing the references to both ### the list and the item which collided with the @@ -238,7 +239,7 @@ def scroll(self, speed): ### get vertical position of mouse _, y = get_mouse_pos() - ### pick list according to the area the mouse hovers + ### pick list according to the area the mouse hovers a_list = ( @@ -290,7 +291,7 @@ def scroll(self, speed): def drag_mode_handle_events(self): """Event handling for the drag mode.""" for event in get_events(): - + ### raise specific error if the user attempts ### to quit the app if event.type == QUIT: raise QuitAppException @@ -403,7 +404,7 @@ def enable_drag_mode(self, collection, obj): self.dragged_obj.rect.move_ip(0, -27) else: - + new_obj = Object2D.from_surface( surface = obj.image, value = obj.value, @@ -473,7 +474,7 @@ def on_mouse_release(self, event): We use it to retrieve the mouse position when the mouse left button is released; it is also required in order to comply w/ the protocol used; - + Check pygame.event module documentation on pygame website for more info about this event object. @@ -491,7 +492,7 @@ def on_mouse_release(self, event): ### of the "for loop" if button.rect.collidepoint(mouse_pos): - + try: method = getattr( button, 'on_mouse_release' ) diff --git a/nodezator/ourstdlibs/collections/fldict/main.py b/nodezator/ourstdlibs/collections/fldict/main.py index 0a2d9cbd..05d9ad0a 100644 --- a/nodezator/ourstdlibs/collections/fldict/main.py +++ b/nodezator/ourstdlibs/collections/fldict/main.py @@ -4,7 +4,7 @@ from collections.abc import Mapping ### local import -from ourstdlibs.behaviour import flatten_mapping_values +from ....ourstdlibs.behaviour import flatten_mapping_values ### XXX development note: in the future, the list class diff --git a/nodezator/videopreview/cache.py b/nodezator/videopreview/cache.py index ad7ab5ac..935bbd3c 100644 --- a/nodezator/videopreview/cache.py +++ b/nodezator/videopreview/cache.py @@ -39,18 +39,18 @@ ### local imports -from classes2d.single import Object2D +from ..classes2d.single import Object2D -from ourstdlibs.dictutils import ( +from ..ourstdlibs.dictutils import ( settings_to_hashable_repr, hashable_repr_to_settings, ) -from surfsman.render import render_rect +from ..surfsman.render import render_rect -from surfsman.draw import blit_aligned +from ..surfsman.draw import blit_aligned -from videopreview.render import render_video_data +from .render import render_video_data VIDEO_METADATA_MAP = {} @@ -61,7 +61,7 @@ class VideoDatabase(dict): Extends the built-in dict. """ - + def __missing__(self, key): """Create, store and return dict for given key. @@ -189,7 +189,7 @@ def __init__( ### XXX what to do about resizing and ### repositioning after using methods below? - + def change_video_settings(self, video_settings): """Change video settings and replace surface. @@ -252,7 +252,7 @@ def update(self): ) def update_video_metadata_and_previews(video_path): - + try: del VIDEO_METADATA_MAP[video_path] except KeyError: pass diff --git a/nodezator/videopreview/constants.py b/nodezator/videopreview/constants.py index 91c222e5..6caffc4e 100644 --- a/nodezator/videopreview/constants.py +++ b/nodezator/videopreview/constants.py @@ -9,7 +9,7 @@ ### local import -from ourstdlibs.mathutils import math_eval +from ..ourstdlibs.mathutils import math_eval def get_video_metadata(video_path): diff --git a/nodezator/videopreview/previewer.py b/nodezator/videopreview/previewer.py index e7731305..3eaf3617 100644 --- a/nodezator/videopreview/previewer.py +++ b/nodezator/videopreview/previewer.py @@ -16,40 +16,40 @@ ### local imports -from config import FFMPEG_AVAILABLE +from ..config import FFMPEG_AVAILABLE -from pygameconstants import ( +from ..pygameconstants import ( SCREEN, SCREEN_RECT, maintain_fps, ) -from ourstdlibs.behaviour import get_oblivious_callable +from ..ourstdlibs.behaviour import get_oblivious_callable -from loopman.exception import ( +from ..loopman.exception import ( QuitAppException, SwitchLoopException, ) -from classes2d.single import Object2D +from ..classes2d.single import Object2D -from surfsman.render import render_rect -from surfsman.draw import draw_border +from ..surfsman.render import render_rect +from ..surfsman.draw import draw_border -from textman.render import render_text +from ..textman.render import render_text -from colorsman.colors import BLACK, WHITE +from ..colorsman.colors import BLACK, WHITE -from widget.intfloatentry.main import IntFloatEntry +from ..widget.intfloatentry.main import IntFloatEntry -from videopreview.cache import ( - VIDEO_METADATA_MAP, - CachedVideoObject, - ) +from .cache import ( + VIDEO_METADATA_MAP, + CachedVideoObject, + ) class VideoPreviewer(Object2D): - + def __init__(self): """""" @@ -69,7 +69,7 @@ def __init__(self): { 'max_width' : 250, 'max_height' : 250, - + 'not_found_width' : 250, 'not_found_height' : 250, }, @@ -208,17 +208,17 @@ def handle_input(self): def handle_events(self): for event in get_events(): - + if event.type == QUIT: raise QuitAppException elif event.type == KEYUP: - + if event.key == K_ESCAPE: self.running = False elif event.type == MOUSEBUTTONDOWN: - + if event.button == 1: self.on_mouse_click(event) @@ -230,8 +230,8 @@ def on_mouse_click(self, event): if entry.rect.collidepoint(mouse_pos): entry.on_mouse_click(event) - - def update(self): + + def update(self): self.videopreview.update() def draw(self): diff --git a/nodezator/videopreview/render.py b/nodezator/videopreview/render.py index 12fc4f47..2cb9ea43 100644 --- a/nodezator/videopreview/render.py +++ b/nodezator/videopreview/render.py @@ -21,11 +21,11 @@ ### local imports -from config import FFMPEG_AVAILABLE +from ..config import FFMPEG_AVAILABLE -from videopreview.constants import get_video_metadata +from ..surfsman.draw import draw_not_found_icon -from surfsman.draw import draw_not_found_icon +from .constants import get_video_metadata ### TODO review/refactor @@ -107,7 +107,7 @@ def get_frames(video_path, metadata, max_width, max_height): ### with TemporaryDirectory() as string_dir_path: - + dirpath = Path(string_dir_path) command_text = ( diff --git a/nodezator/widget/defaultholder.py b/nodezator/widget/defaultholder.py index 6dbfecec..91ab3ea4 100644 --- a/nodezator/widget/defaultholder.py +++ b/nodezator/widget/defaultholder.py @@ -6,14 +6,14 @@ ### local imports -from fontsman.constants import ( +from ..fontsman.constants import ( ENC_SANS_BOLD_FONT_HEIGHT, ENC_SANS_BOLD_FONT_PATH, ) -from textman.label.main import Label +from ..textman.label.main import Label -from textman.render import fit_text +from ..textman.render import fit_text ### XXX the default holder could work as a button, @@ -38,14 +38,14 @@ class DefaultHolder(Label): Used to hold default values that are not supposed to be edited in a widget. - + When a parameter holds a default value editable by widget, then a custom widget is used, and the value can be both seen and edited in the widget. However, when the default value can't be edited in a widget, then this label serves as a displaying widget so that the user at least can know what is the default value. - + This widget displays a repr() version of the value it holds, so it is advised that you make sure the value used have a meaningful __repr__ method. @@ -159,7 +159,7 @@ def set(self, value): instantiating a CallableNode in order to replace the default value of each widget with the last value set by the user. - + Since this widget cannot be edited, but it was designed to just display the value it holds, the value attempted to be set is the same which is diff --git a/nodezator/widget/pathpreview/audio.py b/nodezator/widget/pathpreview/audio.py index 7e36f693..1beb74ae 100644 --- a/nodezator/widget/pathpreview/audio.py +++ b/nodezator/widget/pathpreview/audio.py @@ -2,15 +2,15 @@ ### local imports -from audioplayer import play_audio +from ...audioplayer import play_audio -from surfsman.icon import render_layered_icon +from ...surfsman.icon import render_layered_icon -from colorsman.colors import BLACK, WHITE +from ...colorsman.colors import BLACK, WHITE -from widget.pathpreview.base import _BasePreview +from .base import _BasePreview -from widget.pathpreview.constants import ( +from .constants import ( BUTTON_SURFS, BUTTON_WIDTH, BUTTON_HEIGHT, @@ -19,7 +19,7 @@ class AudioPreview(_BasePreview): - + ### button_surfs = list(BUTTON_SURFS) diff --git a/nodezator/widget/pathpreview/base.py b/nodezator/widget/pathpreview/base.py index 70af250e..fa6d9939 100644 --- a/nodezator/widget/pathpreview/base.py +++ b/nodezator/widget/pathpreview/base.py @@ -13,28 +13,28 @@ ### local imports -from ourstdlibs.behaviour import empty_function +from ...ourstdlibs.behaviour import empty_function -from fileman.main import select_path +from ...fileman.main import select_path -from classes2d.single import Object2D +from ...classes2d.single import Object2D -from fontsman.constants import ( +from ...fontsman.constants import ( ENC_SANS_BOLD_FONT_PATH, ENC_SANS_BOLD_FONT_HEIGHT, ) -from textman.render import render_text, fit_text +from ...textman.render import render_text, fit_text -from surfsman.render import render_rect +from ...surfsman.render import render_rect -from surfsman.draw import draw_depth_finish, blit_aligned +from ...surfsman.draw import draw_depth_finish, blit_aligned -from colorsman.colors import PATHPREVIEW_BG +from ...colorsman.colors import PATHPREVIEW_BG -from widget.intfloatentry.main import IntFloatEntry +from ..intfloatentry.main import IntFloatEntry -from widget.pathpreview.constants import ( +from .constants import ( ICON_SURF, BUTTON_SURFS, BUTTON_RECTS, @@ -186,7 +186,7 @@ def validate_value(self, value): ) elif not self.string_when_single: - + raise ValueError( "if 'string_when_single' is" " False, 'value' must always" @@ -260,7 +260,7 @@ def update_image(self): ### if there's just one path, though... else: - + ### define path self.current_path = ( @@ -333,7 +333,7 @@ def set( max_value = ( - 0 + 0 if isinstance(value, str) else len(value) - 1 @@ -364,7 +364,7 @@ def on_mouse_release(self, event): It is required in order to comply with protocol used. We retrieve the mouse position from its "pos" attribute. - + Check pygame.event module documentation on pygame website for more info about this event object. @@ -541,7 +541,7 @@ def svg_repr(self): for button_svg_repr, rect in zip( self.button_svg_reprs, self.button_rects ): - + x, y = ( a + b for a, b in zip( diff --git a/nodezator/widget/pathpreview/constants.py b/nodezator/widget/pathpreview/constants.py index 6fe6f6b7..9c11484b 100644 --- a/nodezator/widget/pathpreview/constants.py +++ b/nodezator/widget/pathpreview/constants.py @@ -9,11 +9,11 @@ ### local imports -from surfsman.render import combine_surfaces, render_rect +from ...surfsman.render import combine_surfaces, render_rect -from surfsman.icon import render_layered_icon +from ...surfsman.icon import render_layered_icon -from colorsman.colors import ( +from ...colorsman.colors import ( BLACK, PATHPREVIEW_BG, ) @@ -257,7 +257,7 @@ ## def get_missing_path_repr(rect): - + g = Element('g', {'class': 'file_not_found_shapes'}) g.append( @@ -295,7 +295,7 @@ def get_missing_path_repr(rect): 'ellipse', { - + 'cx': str(ellipse_rect.centerx), 'cy': str(ellipse_rect.centery), 'rx': str(ellipse_rect.width//2), @@ -319,7 +319,7 @@ def get_missing_path_repr(rect): 'line', { - + **{ key: value diff --git a/nodezator/widget/pathpreview/font.py b/nodezator/widget/pathpreview/font.py index a9792b03..0678c49b 100644 --- a/nodezator/widget/pathpreview/font.py +++ b/nodezator/widget/pathpreview/font.py @@ -20,30 +20,30 @@ ### local imports -from config import APP_REFS +from ...config import APP_REFS -from ourstdlibs.path import get_new_filename +from ...ourstdlibs.path import get_new_filename -from fontsman.preview.cache import ( +from ...fontsman.preview.cache import ( FONT_PREVIEWS_DB, update_cache_for_font_preview, ) -from fontsman.viewer.main import view_fonts +from ...fontsman.viewer.main import view_fonts -from surfsman.cache import NOT_FOUND_SURF_MAP +from ...surfsman.cache import NOT_FOUND_SURF_MAP -from surfsman.icon import render_layered_icon +from ...surfsman.icon import render_layered_icon -from colorsman.colors import ( +from ...colorsman.colors import ( BLACK, WHITE, PATHPREVIEW_BG, ) -from widget.pathpreview.base import _BasePreview +from .base import _BasePreview -from widget.pathpreview.constants import ( +from .constants import ( SP_BUTTON_SURFS, SP_BUTTON_RECTS, @@ -72,7 +72,7 @@ ### class definition class FontPreview(_BasePreview): - + height = 150 + 20 button_callable_names = SP_BUTTON_CALLABLE_NAMES @@ -342,7 +342,7 @@ def svg_path_repr(self): ), ]: - + g.append( Element( @@ -402,7 +402,7 @@ def svg_path_repr(self): value == name and key != current_path ): - + ## change value of name variable ## so the name is different diff --git a/nodezator/widget/pathpreview/image.py b/nodezator/widget/pathpreview/image.py index 189ac5e8..2d19dc71 100644 --- a/nodezator/widget/pathpreview/image.py +++ b/nodezator/widget/pathpreview/image.py @@ -9,29 +9,29 @@ ### local imports -from config import APP_REFS +from ...config import APP_REFS -from ourstdlibs.path import get_new_filename +from ...ourstdlibs.path import get_new_filename -from imagesman.cache import ( +from ...imagesman.cache import ( ORIGINAL_IMAGE_SURFS_MAP, IMAGE_SURFS_DB, update_cache_for_image, ) -from imagesman.viewer.main import view_images +from ...imagesman.viewer.main import view_images -from surfsman.icon import render_layered_icon +from ...surfsman.icon import render_layered_icon -from colorsman.colors import ( +from ...colorsman.colors import ( BLACK, WHITE, PATHPREVIEW_BG, THUMB_BG, ) -from widget.pathpreview.base import _BasePreview +from .base import _BasePreview -from widget.pathpreview.constants import ( +from .constants import ( SP_BUTTON_SURFS, SP_BUTTON_RECTS, BUTTON_WIDTH, @@ -43,7 +43,7 @@ class ImagePreview(_BasePreview): - + height = 175 + 20 button_callable_names = SP_BUTTON_CALLABLE_NAMES @@ -241,7 +241,7 @@ def svg_path_repr(self): current_path = self.current_path if current_path not in ORIGINAL_IMAGE_SURFS_MAP: - + g.append(get_missing_path_repr(rect)) g.append(super().svg_path_repr()) return g @@ -355,7 +355,7 @@ def svg_path_repr(self): ), ]: - + g.append( Element( @@ -371,7 +371,7 @@ def svg_path_repr(self): ) else: - + thumb_width, thumb_height = rect.size if current_path not in preview_surf_map: @@ -422,7 +422,7 @@ def svg_path_repr(self): value == name and key != current_path ): - + ## change value of name variable ## so the name is different diff --git a/nodezator/widget/pathpreview/path.py b/nodezator/widget/pathpreview/path.py index 38a11b95..8f8e52ca 100644 --- a/nodezator/widget/pathpreview/path.py +++ b/nodezator/widget/pathpreview/path.py @@ -2,9 +2,9 @@ ### local imports -from textman.viewer.main import view_text +from ...textman.viewer.main import view_text -from widget.pathpreview.base import _BasePreview +from .base import _BasePreview ### message when displaying value of widget diff --git a/nodezator/widget/pathpreview/text.py b/nodezator/widget/pathpreview/text.py index eadde744..e079d1b3 100644 --- a/nodezator/widget/pathpreview/text.py +++ b/nodezator/widget/pathpreview/text.py @@ -13,61 +13,62 @@ ### local imports -from dialog import create_and_show_dialog +from ...dialog import create_and_show_dialog -from logman.main import get_new_logger +from ...logman.main import get_new_logger -from our3rdlibs.userlogger import USER_LOGGER +from ...our3rdlibs.userlogger import USER_LOGGER -from textman.viewer.main import view_text +from ...textman.viewer.main import view_text -from surfsman.draw import ( +from ...surfsman.draw import ( draw_depth_finish, draw_not_found_icon, ) -from surfsman.icon import render_layered_icon +from ...surfsman.icon import render_layered_icon -from fontsman.constants import ( +from ...fontsman.constants import ( FIRA_MONO_BOLD_FONT_PATH, FIRA_MONO_BOLD_FONT_HEIGHT, ) -from textman.render import ( +from ...textman.render import ( fit_text, get_text_size, render_text, ) -from textman.text import render_highlighted_line +from ...textman.text import render_highlighted_line -from colorsman.colors import ( +from ...colorsman.colors import ( BLACK, WHITE, TEXTPREVIEW_FG, TEXTPREVIEW_BG, ) -from widget.pathpreview.base import _BasePreview +from ...syntaxman.utils import ( + SYNTAX_TO_MAPPING_FUNCTION, + get_ready_theme, + ) -from widget.pathpreview.constants import ( +from ...syntaxman.exception import SyntaxMappingError - SP_BUTTON_SURFS, - SP_BUTTON_RECTS, - BUTTON_WIDTH, - BUTTON_HEIGHT, - SP_BUTTON_SVG_REPRS, - SP_BUTTON_CALLABLE_NAMES, - get_missing_path_repr, - ) +from .base import _BasePreview -from syntaxman.utils import ( - SYNTAX_TO_MAPPING_FUNCTION, - get_ready_theme, - ) +from .constants import ( + SP_BUTTON_SURFS, + SP_BUTTON_RECTS, + BUTTON_WIDTH, + BUTTON_HEIGHT, + SP_BUTTON_SVG_REPRS, + SP_BUTTON_CALLABLE_NAMES, + get_missing_path_repr, + + ) -from syntaxman.exception import SyntaxMappingError GENERAL_TEXT_SETTINGS = { @@ -84,7 +85,7 @@ ### class definition class TextPreview(_BasePreview): - + height = 163 + 20 button_rects = SP_BUTTON_RECTS @@ -332,7 +333,7 @@ def blit_path_representation(self): syntax_highlighting, GENERAL_TEXT_SETTINGS, ) - + get_syntax_map = SYNTAX_TO_MAPPING_FUNCTION[ syntax_highlighting ] @@ -378,7 +379,7 @@ def blit_path_representation(self): draw_rect(image, background_color, rect) if show_line_number: - + lineno_width, _ = get_text_size( '01', font_height=font_height, @@ -400,14 +401,14 @@ def blit_path_representation(self): if syntax_highlighting: - + try: highlight_data = \ get_syntax_map(text) except SyntaxMappingError: highlight_data = { - + ## store a dict item where the line index ## is the key and another dict is the value @@ -422,7 +423,7 @@ def blit_path_representation(self): (0, len(line_text)): 'normal' } - + ## for each line_index and respective line for line_index, line_text \ in enumerate(lines) @@ -481,7 +482,7 @@ def blit_path_representation(self): for line_number, line_text \ in enumerate(lines, 1): - + if line_number > no_of_visible_lines: break surf = render_text( @@ -504,7 +505,7 @@ def blit_path_representation(self): for line_number, line_text \ in enumerate(lines, 1): - + surf = render_text( text=str(line_number).rjust(2, '0'), font_height=font_height, @@ -542,7 +543,7 @@ def svg_path_repr(self): try: text = path.read_text(encoding='utf-8') except (FileNotFoundError, IsADirectoryError): - + g.append(get_missing_path_repr(rect)) g.append(super().svg_path_repr()) return g @@ -566,7 +567,7 @@ def svg_path_repr(self): syntax_highlighting, GENERAL_TEXT_SETTINGS, ) - + get_syntax_map = SYNTAX_TO_MAPPING_FUNCTION[ syntax_highlighting ] @@ -633,7 +634,7 @@ def svg_path_repr(self): ) if show_line_number: - + max_lineno_text = str(len(text.splitlines())) lineno_digits = len(max_lineno_text) @@ -680,14 +681,14 @@ def svg_path_repr(self): if syntax_highlighting: - + try: highlight_data = \ get_syntax_map(text) except SyntaxMappingError: highlight_data = { - + ## store a dict item where the line index ## is the key and another dict is the value @@ -702,7 +703,7 @@ def svg_path_repr(self): (0, len(line_text)): 'normal' } - + ## for each line_index and respective line for line_index, line_text \ in enumerate(lines) @@ -855,7 +856,7 @@ def svg_path_repr(self): in enumerate(lines, 1): y += font_height - + if line_number > no_of_visible_lines: break line_text = fit_text( diff --git a/nodezator/widget/pathpreview/video.py b/nodezator/widget/pathpreview/video.py index 7106a2f0..c67133f9 100644 --- a/nodezator/widget/pathpreview/video.py +++ b/nodezator/widget/pathpreview/video.py @@ -13,15 +13,15 @@ ### local imports -from config import APP_REFS, FFMPEG_AVAILABLE +from ...config import APP_REFS, FFMPEG_AVAILABLE -from dialog import create_and_show_dialog +from ...dialog import create_and_show_dialog -from ourstdlibs.path import get_new_filename +from ...ourstdlibs.path import get_new_filename -from videopreview.previewer import preview_videos +from ...videopreview.previewer import preview_videos -from videopreview.cache import ( +from ...videopreview.cache import ( VIDEO_METADATA_MAP, VIDEO_DATA_DB, @@ -29,27 +29,26 @@ ) -from surfsman.draw import blit_aligned +from ...surfsman.draw import blit_aligned -from surfsman.icon import render_layered_icon +from ...surfsman.icon import render_layered_icon -from textman.render import render_multiline_text +from ...textman.render import render_multiline_text -from colorsman.colors import BLACK, PATHPREVIEW_BG +from ...colorsman.colors import BLACK, PATHPREVIEW_BG -from widget.pathpreview.base import _BasePreview +from .base import _BasePreview -from widget.pathpreview.constants import ( +from .constants import ( + SP_BUTTON_SURFS, + SP_BUTTON_RECTS, + BUTTON_WIDTH, + BUTTON_HEIGHT, + SP_BUTTON_SVG_REPRS, + SP_BUTTON_CALLABLE_NAMES, + get_missing_path_repr, - SP_BUTTON_SURFS, - SP_BUTTON_RECTS, - BUTTON_WIDTH, - BUTTON_HEIGHT, - SP_BUTTON_SVG_REPRS, - SP_BUTTON_CALLABLE_NAMES, - get_missing_path_repr, - - ) + ) NO_FFMPEG_TEXT = """ MUST INSTALL @@ -59,7 +58,7 @@ """.strip() class VideoPreview(_BasePreview): - + height = BUTTON_HEIGHT + 154 + 20 button_callable_names = SP_BUTTON_CALLABLE_NAMES @@ -367,7 +366,7 @@ def svg_path_repr(self): ), ]: - + g.append( Element( @@ -384,7 +383,7 @@ def svg_path_repr(self): ) else: - + thumb_width, thumb_height = rect.size if current_path not in preview_surf_map: @@ -406,7 +405,7 @@ def svg_path_repr(self): value == name and key != current_path ): - + ## change value of name variable ## so the name is different diff --git a/nodezator/widget/sortingbutton.py b/nodezator/widget/sortingbutton.py index 55cff3bd..c0f93137 100644 --- a/nodezator/widget/sortingbutton.py +++ b/nodezator/widget/sortingbutton.py @@ -11,27 +11,27 @@ ### local imports -from ourstdlibs.behaviour import empty_function +from ..ourstdlibs.behaviour import empty_function -from surfsman.draw import blit_aligned, draw_border -from surfsman.render import render_rect +from ..surfsman.draw import blit_aligned, draw_border +from ..surfsman.render import render_rect -from classes2d.single import Object2D +from ..classes2d.single import Object2D -from our3rdlibs.sortingeditor.main import sort_sequence +from ..our3rdlibs.sortingeditor.main import sort_sequence -from textman.render import render_text, fit_text +from ..textman.render import render_text, fit_text -from textman.viewer.main import view_text +from ..textman.viewer.main import view_text -from surfsman.icon import render_layered_icon +from ..surfsman.icon import render_layered_icon -from fontsman.constants import ( +from ..fontsman.constants import ( ENC_SANS_BOLD_FONT_HEIGHT, ENC_SANS_BOLD_FONT_PATH, ) -from colorsman.colors import ( +from ..colorsman.colors import ( BLACK, LIST_SORTING_BUTTON_FG, LIST_SORTING_BUTTON_BG, @@ -225,7 +225,7 @@ def on_mouse_release(self, event): It is required in order to comply with protocol used. We retrieve the mouse position from its "pos" attribute. - + Check pygame.event module documentation on pygame website for more info about this event object. @@ -415,7 +415,7 @@ def svg_repr(self): }, ) ) - + ### x, y = self.rect.topleft From 6d4b60af221b935c3e1915e6a51e8daefb4c5f63 Mon Sep 17 00:00:00 2001 From: pmp-p Date: Wed, 20 Jul 2022 18:39:13 +0200 Subject: [PATCH 4/8] rel import 3/x --- nodezator/graphman/builtinnode/main.py | 10 ++-- nodezator/graphman/callablenode/execution.py | 2 +- nodezator/graphman/callablenode/export.py | 34 ++++++------ .../graphman/callablenode/subparam/main.py | 24 ++++----- .../graphman/callablenode/subparam/segment.py | 16 +++--- .../callablenode/subparam/unpacking.py | 16 +++--- .../graphman/callablenode/subparam/widget.py | 24 ++++----- nodezator/graphman/callablenode/surfs.py | 18 +++---- nodezator/graphman/callablenode/vizop/main.py | 16 +++--- .../graphman/callablenode/vizop/reposition.py | 6 +-- .../vizprep/bodysetup/creation.py | 28 +++++----- .../callablenode/vizprep/bodysetup/main.py | 8 +-- .../graphman/callablenode/vizprep/varparam.py | 24 ++++----- nodezator/graphman/capsulenode/main.py | 10 ++-- nodezator/graphman/exception.py | 6 +-- nodezator/graphman/operatornode/constants.py | 4 +- nodezator/graphman/operatornode/execution.py | 2 +- nodezator/graphman/operatornode/export.py | 8 +-- nodezator/graphman/operatornode/main.py | 18 +++---- nodezator/graphman/operatornode/surfs.py | 28 +++++----- nodezator/graphman/operatornode/vizop.py | 12 ++--- nodezator/graphman/operatornode/vizprep.py | 14 ++--- nodezator/graphman/proxynode/constants.py | 4 +- nodezator/graphman/proxynode/export.py | 12 ++--- nodezator/graphman/proxynode/main.py | 10 ++-- nodezator/graphman/proxynode/segment.py | 2 +- nodezator/graphman/proxynode/surfs.py | 14 ++--- nodezator/graphman/proxynode/utils.py | 2 +- nodezator/graphman/proxynode/vizop/main.py | 14 ++--- .../graphman/proxynode/vizop/reposition.py | 2 +- nodezator/graphman/proxynode/vizprep.py | 24 ++++----- nodezator/graphman/proxynode/widget.py | 24 ++++----- nodezator/graphman/socket/output.py | 8 +-- nodezator/graphman/socket/placeholder.py | 6 +-- nodezator/graphman/socket/proxy.py | 8 +-- nodezator/graphman/stlibnode/main.py | 10 ++-- nodezator/graphman/textblock/check.py | 4 +- nodezator/graphman/textblock/constants.py | 2 +- nodezator/graphman/textblock/export.py | 10 ++-- nodezator/graphman/textblock/main.py | 16 +++--- nodezator/graphman/textblock/surf.py | 14 ++--- nodezator/graphman/widget/picker/main.py | 36 ++++++------- nodezator/graphman/widget/picker/subforms.py | 54 +++++++++---------- nodezator/our3rdlibs/iterablewidget/list.py | 32 +++++------ nodezator/our3rdlibs/iterablewidget/op.py | 12 ++--- nodezator/our3rdlibs/iterablewidget/surfs.py | 4 +- 46 files changed, 325 insertions(+), 327 deletions(-) diff --git a/nodezator/graphman/builtinnode/main.py b/nodezator/graphman/builtinnode/main.py index 631f4f1f..4660b419 100644 --- a/nodezator/graphman/builtinnode/main.py +++ b/nodezator/graphman/builtinnode/main.py @@ -6,17 +6,17 @@ ### local imports -from graphman.builtinnode.constants import ( +from .constants import ( BUILTIN_IDS_TO_CALLABLES_MAP, BUILTIN_IDS_TO_SIGNATURES_MAP, BUILTIN_IDS_TO_SIGNATURE_CALLABLES_MAP, BUILTIN_IDS_TO_SOURCE_VIEW_TEXT, ) -from colorsman.colors import BUILTIN_NODES_CATEGORY_COLOR +from ...colorsman.colors import BUILTIN_NODES_CATEGORY_COLOR ## superclass -from graphman.callablenode.main import CallableNode +from ..callablenode.main import CallableNode class BuiltinNode(CallableNode): @@ -42,7 +42,7 @@ def __init__(self, data, midtop=None): ### retrieve and store the main callable obj in its ### own attribute self.main_callable = ( - BUILTIN_IDS_TO_CALLABLES_MAP[data['builtin_id']] + BUILTIN_IDS_TO_CALLABLES_MAP[data['builtin_id']] ) ### also retrieve and store the callable used to @@ -106,7 +106,7 @@ def __init__(self, data, midtop=None): self.midtop = ( midtop - if midtop is not None + if midtop is not None else self.data['midtop'] diff --git a/nodezator/graphman/callablenode/execution.py b/nodezator/graphman/callablenode/execution.py index 44a8e932..90a1c9b2 100644 --- a/nodezator/graphman/callablenode/execution.py +++ b/nodezator/graphman/callablenode/execution.py @@ -1,7 +1,7 @@ ### local imports -from graphman.exception import ( +from ..exception import ( MissingInputError, WaitingInputException, diff --git a/nodezator/graphman/callablenode/export.py b/nodezator/graphman/callablenode/export.py index 454289bd..6a61d81d 100644 --- a/nodezator/graphman/callablenode/export.py +++ b/nodezator/graphman/callablenode/export.py @@ -9,22 +9,22 @@ ### local imports -from rectsman.main import RectsManager +from ...rectsman.main import RectsManager -from graphman.callablenode.constants import ( +from .constants import ( NODE_OUTLINE_THICKNESS, FONT_HEIGHT, ) -from graphman.callablenode.surfs import ( +from .surfs import ( TOP_CORNERS_MAP, UNPACKING_ICON_SURFS_MAP, ) -from pointsman2d.shape import cross_from_rect -from pointsman2d.transform import rotate_points +from ...pointsman2d.shape import cross_from_rect +from ...pointsman2d.transform import rotate_points -from colorsman.colors import ( +from ...colorsman.colors import ( BLACK, NODE_BODY_BG, @@ -74,7 +74,7 @@ ) def get_unpacking_icon_group(): - + rect, small_rect = UNPACKING_RECTS lines = [ @@ -99,12 +99,12 @@ def get_unpacking_icon_group(): g = Element('g', {'class': 'unpacking_icon'}) for line in lines: - + p1, p2 = line x1, y1 = map(str, p1) x2, y2 = map(str, p2) - + g.append( Element( @@ -486,7 +486,7 @@ def svg_repr(self): self.placeholder_add_buttons, self.widget_add_buttons, ): - + button_rect = button.rect.inflate(-2, -2) path_directives = 'M' @@ -515,7 +515,7 @@ def svg_repr(self): for button in self.widget_remove_buttons: button_rect = button.rect.inflate(-2, -2) - + path_directives = 'M' for x, y in rotate_points( @@ -543,7 +543,7 @@ def svg_repr(self): ) for button in self.subparam_up_buttons: - + button_bg_rect = button.rect.inflate(-2, -2) node_g.append( @@ -641,9 +641,9 @@ def svg_repr(self): for param_name, value in ( self.input_socket_live_flmap.items() ): - + if isinstance(value, dict): - + socket = ( value[0] @@ -668,7 +668,7 @@ def svg_repr(self): var_kind_map[param_name] == 'var_key' and value ): - + if 0 in ( self. subparam_keyword_entry_live_map @@ -760,7 +760,7 @@ def svg_repr(self): for param_name, kind in var_kind_map.items(): if kind == 'var_pos': - + for obj in ( self @@ -938,7 +938,7 @@ def draw_on_surf(self, surf): ### widgets, buttons and sockets for obj in chain( - + self.background_and_text_elements, self.live_widgets, diff --git a/nodezator/graphman/callablenode/subparam/main.py b/nodezator/graphman/callablenode/subparam/main.py index aacda81b..9951b761 100644 --- a/nodezator/graphman/callablenode/subparam/main.py +++ b/nodezator/graphman/callablenode/subparam/main.py @@ -6,21 +6,19 @@ ### local imports -from dialog import create_and_show_dialog +from ....dialog import create_and_show_dialog -from our3rdlibs.behaviour import indicate_unsaved +from ....our3rdlibs.behaviour import indicate_unsaved -from graphman.socket.input import InputSocket +from ...socket.input import InputSocket -from graphman.socket.surfs import type_to_codename +from ...socket.surfs import type_to_codename ## class extensions -from graphman.callablenode.subparam.widget import WidgetOps -from graphman.callablenode.subparam.segment import SegmentOps -from graphman.callablenode.subparam.unpacking import ( - UnpackingOps - ) +from .widget import WidgetOps +from .segment import SegmentOps +from .unpacking import UnpackingOps class SubparameterHandling( @@ -200,13 +198,13 @@ def update_keyword(self, input_socket): ### (the "if" and "elif" blocks below represent ### actual forbidden situations which cause ### SyntaxError when they happen in a function call). - ### + ### ### I'd prefer to handle the SyntaxError during the ### actual function call, but we are forced to do ### it here because during execution of the node ### the inputs for each subparameter are stored in ### a map using the keyword names as keys. - ### + ### ### This would make the duplicate keyword override ### the original one, causing the value of the ### original keyword to be lost and making the @@ -279,7 +277,7 @@ def fix_subparameter_indices(self, param_name): Works by ensuring subparameter indices go from 0 to n in increments of 1 (n = length - 1), that is, that there's no gap between the numbers. - + While looking for gaps in the subparameter indices, this function puts together a list with the data needed to fix the problem and delegates the actual @@ -315,7 +313,7 @@ def fix_subparameter_indices(self, param_name): ## tuple with both names in the 'changes' ## list - if current_index != right_index: + if current_index != right_index: needed_changes.append( (current_index, right_index) diff --git a/nodezator/graphman/callablenode/subparam/segment.py b/nodezator/graphman/callablenode/subparam/segment.py index 649ec663..1893fd38 100644 --- a/nodezator/graphman/callablenode/subparam/segment.py +++ b/nodezator/graphman/callablenode/subparam/segment.py @@ -6,21 +6,21 @@ ### local imports -from ourstdlibs.behaviour import remove_by_identity +from ....ourstdlibs.behaviour import remove_by_identity -from our3rdlibs.button import Button +from ....our3rdlibs.button import Button -from widget.stringentry import StringEntry +from ....widget.stringentry import StringEntry -from rectsman.main import RectsManager +from ....rectsman.main import RectsManager -from graphman.callablenode.surfs import ( +from ..surfs import ( ADD_BUTTON_SURF, SUBP_UP_BUTTON_SURF, SUBP_DOWN_BUTTON_SURF, ) -from graphman.callablenode.constants import FONT_HEIGHT +from ..constants import FONT_HEIGHT class SegmentOps: @@ -439,7 +439,7 @@ def react_to_severance(self, input_socket): ## also update the rectsman hierarchy in order ## to take the removal of the subparameter into ## account - + # remove the subparameter rectsman from the # subparameter rectsman map @@ -461,7 +461,7 @@ def react_to_severance(self, input_socket): ) remove_by_identity(subrectsman, rect_list) - + ## fix names of remaining subparameters self.fix_subparameter_indices(param_name) diff --git a/nodezator/graphman/callablenode/subparam/unpacking.py b/nodezator/graphman/callablenode/subparam/unpacking.py index 425c8c33..b05f86af 100644 --- a/nodezator/graphman/callablenode/subparam/unpacking.py +++ b/nodezator/graphman/callablenode/subparam/unpacking.py @@ -6,20 +6,20 @@ ### local imports -from ourstdlibs.behaviour import remove_by_identity +from ....ourstdlibs.behaviour import remove_by_identity -from our3rdlibs.behaviour import indicate_unsaved +from ....our3rdlibs.behaviour import indicate_unsaved -from classes2d.single import Object2D +from ....classes2d.single import Object2D -from widget.stringentry import StringEntry +from ....widget.stringentry import StringEntry -from rectsman.main import RectsManager +from ....rectsman.main import RectsManager -from graphman.callablenode.constants import FONT_HEIGHT +from ..constants import FONT_HEIGHT -from graphman.callablenode.surfs import ( - UNPACKING_ICON_SURFS_MAP, +from ..surfs import ( + UNPACKING_ICON_SURFS_MAP, ) diff --git a/nodezator/graphman/callablenode/subparam/widget.py b/nodezator/graphman/callablenode/subparam/widget.py index 255bb206..922022ca 100644 --- a/nodezator/graphman/callablenode/subparam/widget.py +++ b/nodezator/graphman/callablenode/subparam/widget.py @@ -6,21 +6,21 @@ ### local imports -from ourstdlibs.behaviour import remove_by_identity +from ....ourstdlibs.behaviour import remove_by_identity -from our3rdlibs.button import Button +from ....our3rdlibs.button import Button -from our3rdlibs.behaviour import indicate_unsaved +from ....our3rdlibs.behaviour import indicate_unsaved -from widget.stringentry import StringEntry +from ....widget.stringentry import StringEntry -from rectsman.main import RectsManager +from ....rectsman.main import RectsManager -from graphman.widget.utils import WIDGET_CLASS_MAP +from ...widget.utils import WIDGET_CLASS_MAP -from graphman.callablenode.utils import update_with_widget +from ..utils import update_with_widget -from graphman.callablenode.surfs import ( +from ..surfs import ( ADD_BUTTON_SURF, REMOVE_BUTTON_SURF, @@ -29,7 +29,7 @@ ) -from graphman.callablenode.constants import FONT_HEIGHT +from ..constants import FONT_HEIGHT class WidgetOps: @@ -688,7 +688,7 @@ def remove_subparameter_widget(self, widget): self.var_kind_map[param_name] == 'var_key' or subparam_index in subparams_for_unpacking ): - + obj_to_reposition = ( ( @@ -848,7 +848,7 @@ def remove_subparameter_widget(self, widget): ## also update the rectsman hierarchy in order ## to take the removal of the subparameter into ## account - + # remove the subparameter rectsman from the # subparameter rectsman map (we don't need # to catch the reference returned, because @@ -873,7 +873,7 @@ def remove_subparameter_widget(self, widget): ) remove_by_identity(subrectsman, rect_list) - + ## fix names of remaining subparameters self.fix_subparameter_indices(param_name) diff --git a/nodezator/graphman/callablenode/surfs.py b/nodezator/graphman/callablenode/surfs.py index 7c786d55..b64786a8 100644 --- a/nodezator/graphman/callablenode/surfs.py +++ b/nodezator/graphman/callablenode/surfs.py @@ -6,18 +6,18 @@ ### local imports -from ourstdlibs.collections.general import FactoryDict +from ...ourstdlibs.collections.general import FactoryDict -from surfsman.render import ( +from ...surfsman.render import ( render_rect, combine_surfaces, ) -from surfsman.icon import render_layered_icon +from ...surfsman.icon import render_layered_icon -from fontsman.constants import FIRA_MONO_BOLD_FONT_PATH +from ...fontsman.constants import FIRA_MONO_BOLD_FONT_PATH -from colorsman.colors import ( +from ...colorsman.colors import ( NODE_BODY_BG, COMMENTED_OUT_NODE_BG, @@ -42,7 +42,7 @@ ) -from graphman.callablenode.constants import ( +from ..callablenode.constants import ( NODE_WIDTH, NODE_BODY_HEAD_HEIGHT, NODE_OUTLINE_THICKNESS, @@ -85,7 +85,7 @@ def get_top_corners(fill_color): ## bottom_corner_surfs = tuple( - + render_layered_icon( chars = [chr(ordinal) for ordinal in (161, 162)], @@ -105,7 +105,7 @@ def get_top_corners(fill_color): for fill_color, flip_x, flip_y - + in ( ## normal bottom corners @@ -178,7 +178,7 @@ def get_body_head(fill_color): foot_surfs = ( - NORMAL_NODE_FOOT, COMMENTED_OUT_NODE_FOOT + NORMAL_NODE_FOOT, COMMENTED_OUT_NODE_FOOT ) = tuple( diff --git a/nodezator/graphman/callablenode/vizop/main.py b/nodezator/graphman/callablenode/vizop/main.py index 99d3f65c..6fc931e0 100644 --- a/nodezator/graphman/callablenode/vizop/main.py +++ b/nodezator/graphman/callablenode/vizop/main.py @@ -12,10 +12,10 @@ ### local imports -from pygameconstants import SCREEN +from ....pygameconstants import SCREEN ## function to extend class -from graphman.callablenode.vizop.reposition import ( +from .reposition import ( reposition_elements, ) @@ -46,7 +46,7 @@ def on_mouse_action(self, method_name, event): position of the mouse click in order to know over which object the mouse button was clicked/released. - + Check pygame.event module documentation on pygame website for more info about this event object. @@ -140,7 +140,7 @@ def on_right_mouse_release(self, event): position of the mouse click in order to know over which object the mouse button was clicked/released. - + Check pygame.event module documentation on pygame website for more info about this event object. @@ -152,9 +152,9 @@ def on_right_mouse_release(self, event): self.placeholder_sockets, self.output_sockets, ): - + if socket.rect.collidepoint(mouse_pos): - + try: method = socket.on_right_mouse_release except AttributeError: return @@ -171,7 +171,7 @@ def draw(self): ### widgets, buttons and sockets for obj in chain( - + self.background_and_text_elements, self.live_widgets, @@ -197,7 +197,7 @@ def draw_selection_outline(self, color): def check_sockets_for_segment_definition(self, event): """Check whether any socket collides w/ event.pos. - + event.pos is the position of a mouse left button release event. Any colliding socket must then be sent for line segment definition. diff --git a/nodezator/graphman/callablenode/vizop/reposition.py b/nodezator/graphman/callablenode/vizop/reposition.py index 50a1a468..d54aef2b 100644 --- a/nodezator/graphman/callablenode/vizop/reposition.py +++ b/nodezator/graphman/callablenode/vizop/reposition.py @@ -6,9 +6,9 @@ ### local imports -from rectsman.main import RectsManager +from ....rectsman.main import RectsManager -from graphman.callablenode.constants import ( +from ..constants import ( FONT_HEIGHT, BODY_CONTENT_OFFSET, @@ -232,7 +232,7 @@ def reposition_elements(self): rectsman = RectsManager( (socket_rect, button_rect).__iter__ ) - + # assign the defined top and add 4 pixels, to # push them just a bit down for extra padding rectsman.top = top + 4 diff --git a/nodezator/graphman/callablenode/vizprep/bodysetup/creation.py b/nodezator/graphman/callablenode/vizprep/bodysetup/creation.py index e3da89d3..70e2c427 100644 --- a/nodezator/graphman/callablenode/vizprep/bodysetup/creation.py +++ b/nodezator/graphman/callablenode/vizprep/bodysetup/creation.py @@ -13,26 +13,26 @@ ### local imports -from surfsman.draw import blit_aligned -from surfsman.render import render_rect +from .....surfsman.draw import blit_aligned +from .....surfsman.render import render_rect -from classes2d.single import Object2D +from .....classes2d.single import Object2D -from textman.render import render_text +from .....textman.render import render_text -from graphman.callablenode.surfs import ( +from ...surfs import ( BODY_HEAD_SURFS_MAP, KEYWORD_KEY_SURF, ) -from graphman.callablenode.constants import ( +from ...constants import ( NODE_WIDTH, FONT_HEIGHT, NODE_OUTLINE_THICKNESS, ) -from colorsman.colors import ( - NODE_OUTLINE, +from .....colorsman.colors import ( + NODE_OUTLINE, NODE_BODY_BG, COMMENTED_OUT_NODE_BG, NODE_LABELS, @@ -130,7 +130,7 @@ def create_body_surface(self): ### of variable kind) ## try retrieving the variable kind of the parameter - try: var_kind = self.var_kind_map[param_name] + try: var_kind = self.var_kind_map[param_name] ## if a KeyError is raised, then we have a regular ## parameter here, and the position of the text rect @@ -146,7 +146,7 @@ def create_body_surface(self): text_rect.left = top_rectsman.left + 10 ## position the text rect vertically - + # retrieve the list of rects controlled by # the rects manager of the parameter rect_list = \ @@ -161,7 +161,7 @@ def create_body_surface(self): if len( param_rectsman._get_all_rects.__self__ ) > 1: - + text_rect.bottom = param_rectsman.top text_rect.top += -2 @@ -205,7 +205,7 @@ def create_body_surface(self): asterisks = ( '*' if var_kind == "var_pos" - else '**' + else '**' ) text = asterisks + param_name @@ -274,7 +274,7 @@ def create_body_surface(self): ## on the body surface for output_socket_name in ordered_socket_names: - + ## grab the output socket output_socket = osl_map[output_socket_name] @@ -398,7 +398,7 @@ def create_body_surface(self): ### be using if 'var_key' in self.var_kind_map.values(): - + param_name = next( key for key, value in self.var_kind_map.items() diff --git a/nodezator/graphman/callablenode/vizprep/bodysetup/main.py b/nodezator/graphman/callablenode/vizprep/bodysetup/main.py index 76b603c4..e4d8f213 100644 --- a/nodezator/graphman/callablenode/vizprep/bodysetup/main.py +++ b/nodezator/graphman/callablenode/vizprep/bodysetup/main.py @@ -2,7 +2,7 @@ ### local imports -from graphman.callablenode.surfs import ( +from ...surfs import ( NORMAL_NODE_FOOT, COMMENTED_OUT_NODE_FOOT, NORMAL_BOTTOM_CORNERS, @@ -12,7 +12,7 @@ ) ## function for injection -from graphman.callablenode.vizprep.bodysetup.creation import ( +from ..bodysetup.creation import ( create_body_surface ) @@ -219,14 +219,14 @@ def assign_unpacking_icon_surfs(self): for param_name, param_kind in ( self.var_kind_map.items() ): - + for button in ( self .subparam_unpacking_icon_flmap [param_name] .values() ): - + button.image = UNPACKING_ICON_SURFS_MAP[ (param_kind, is_commented_out) ] diff --git a/nodezator/graphman/callablenode/vizprep/varparam.py b/nodezator/graphman/callablenode/vizprep/varparam.py index 148bda66..30ff5d33 100644 --- a/nodezator/graphman/callablenode/vizprep/varparam.py +++ b/nodezator/graphman/callablenode/vizprep/varparam.py @@ -8,34 +8,34 @@ ### local imports -from classes2d.single import Object2D +from ....classes2d.single import Object2D -from graphman.widget.utils import WIDGET_CLASS_MAP +from ...widget.utils import WIDGET_CLASS_MAP -from graphman.socket.surfs import type_to_codename +from ...socket.surfs import type_to_codename -from graphman.callablenode.utils import update_with_widget +from ...callablenode.utils import update_with_widget ## classes for composition -from our3rdlibs.button import Button +from ....our3rdlibs.button import Button -from graphman.socket.input import InputSocket -from graphman.socket.placeholder import PlaceholderSocket +from ...socket.input import InputSocket +from ...socket.placeholder import PlaceholderSocket -from widget.stringentry import StringEntry +from ....widget.stringentry import StringEntry -from rectsman.main import RectsManager +from ....rectsman.main import RectsManager -from graphman.callablenode.surfs import ( +from ...callablenode.surfs import ( ADD_BUTTON_SURF, REMOVE_BUTTON_SURF, SUBP_UP_BUTTON_SURF, - SUBP_DOWN_BUTTON_SURF, + SUBP_DOWN_BUTTON_SURF, UNPACKING_ICON_SURFS_MAP, ) -from graphman.callablenode.constants import FONT_HEIGHT +from ...callablenode.constants import FONT_HEIGHT def create_var_parameter_objs(self, param_obj): diff --git a/nodezator/graphman/capsulenode/main.py b/nodezator/graphman/capsulenode/main.py index 6a70df40..2551704a 100644 --- a/nodezator/graphman/capsulenode/main.py +++ b/nodezator/graphman/capsulenode/main.py @@ -2,7 +2,7 @@ ### local imports -from graphman.capsulenode.constants import ( +from .constants import ( CAPSULE_IDS_TO_CALLABLES_MAP, CAPSULE_IDS_TO_SIGNATURES_MAP, @@ -12,10 +12,10 @@ ) -from colorsman.colors import CAPSULE_NODES_CATEGORY_COLOR +from ...colorsman.colors import CAPSULE_NODES_CATEGORY_COLOR ## superclass -from graphman.callablenode.main import CallableNode +from ..callablenode.main import CallableNode class CapsuleNode(CallableNode): @@ -47,7 +47,7 @@ def __init__(self, data, midtop=None): self.signature_callable = \ self.main_callable = ( - CAPSULE_IDS_TO_CALLABLES_MAP[data['capsule_id']] + CAPSULE_IDS_TO_CALLABLES_MAP[data['capsule_id']] ) @@ -117,7 +117,7 @@ def __init__(self, data, midtop=None): self.midtop = ( midtop - if midtop is not None + if midtop is not None else self.data['midtop'] diff --git a/nodezator/graphman/exception.py b/nodezator/graphman/exception.py index cdd92b56..6917f772 100644 --- a/nodezator/graphman/exception.py +++ b/nodezator/graphman/exception.py @@ -4,7 +4,7 @@ from os import linesep ### local import -from appinfo import MAIN_CALLABLE_VAR_NAME +from ..appinfo import MAIN_CALLABLE_VAR_NAME ### raised when loading/processing a native file @@ -27,7 +27,7 @@ class NodeScriptsError(Exception): """ def __init__( - self, + self, scripts_not_loaded, scripts_missing_node_definition, not_actually_callables, @@ -319,7 +319,7 @@ class CategoryLackingScriptDirectoryError(Exception): class ScriptDirectoryLackingScriptError(Exception): """Raised when script directory lacks script.""" - + def __init__( self, node_pack_path, diff --git a/nodezator/graphman/operatornode/constants.py b/nodezator/graphman/operatornode/constants.py index 6d72c375..5ea306fe 100644 --- a/nodezator/graphman/operatornode/constants.py +++ b/nodezator/graphman/operatornode/constants.py @@ -9,12 +9,12 @@ ### local imports -from fontsman.constants import ( +from ...fontsman.constants import ( ENC_SANS_BOLD_FONT_PATH, ENC_SANS_BOLD_FONT_HEIGHT, ) -from colorsman.colors import ( +from ...colorsman.colors import ( OPERATION_NODE_NORMAL_BG, OPERATION_NODE_NORMAL_FG, diff --git a/nodezator/graphman/operatornode/execution.py b/nodezator/graphman/operatornode/execution.py index 2d47259c..eb7421e6 100644 --- a/nodezator/graphman/operatornode/execution.py +++ b/nodezator/graphman/operatornode/execution.py @@ -1,7 +1,7 @@ ### local imports -from graphman.exception import ( +from ..exception import ( MissingInputError, WaitingInputException, ) diff --git a/nodezator/graphman/operatornode/export.py b/nodezator/graphman/operatornode/export.py index c8cddfd1..b38eb12e 100644 --- a/nodezator/graphman/operatornode/export.py +++ b/nodezator/graphman/operatornode/export.py @@ -13,7 +13,7 @@ ### local imports -from graphman.operatornode.constants import ( +from .constants import ( OP_CHARS_HEIGHT, AB_CHARS_HEIGHT, NODE_OUTLINE_THICKNESS, @@ -21,9 +21,9 @@ CHAR_FILTERING_MAP, ) -from graphman.operatornode.surfs import CHAR_CENTERXS_MAP +from .surfs import CHAR_CENTERXS_MAP -from colorsman.colors import ( +from ...colorsman.colors import ( BLACK, @@ -194,7 +194,7 @@ def svg_repr(self): for ( (char, flag), centerx ) in zip(char_flag_pairs, centerxs): - + class_name = state + ( 'ab_text' if flag else 'op_text' ) diff --git a/nodezator/graphman/operatornode/main.py b/nodezator/graphman/operatornode/main.py index a9fbf5c5..fbe9b9c3 100644 --- a/nodezator/graphman/operatornode/main.py +++ b/nodezator/graphman/operatornode/main.py @@ -1,25 +1,25 @@ ### local imports -from config import APP_REFS +from ...config import APP_REFS -from ourstdlibs.meta import initialize_bases +from ...ourstdlibs.meta import initialize_bases ### class extensions -from graphman.operatornode.vizprep import ( +from .vizprep import ( VisualRelatedPreparations, ) -from graphman.operatornode.vizop import ( +from .vizop import ( VisualRelatedOperations, ) -from graphman.operatornode.execution import Execution +from .execution import Execution -from graphman.operatornode.export import Exporting +from .export import Exporting -from graphman.operatornode.constants import ( +from .constants import ( OPERATIONS_MAP, OPERATIONS_SIGNATURE_MAP, @@ -62,7 +62,7 @@ def __init__(self, data, midtop=None): self.signature_callable = \ self.main_callable = ( - OPERATIONS_MAP[data['operation_id']] + OPERATIONS_MAP[data['operation_id']] ) ### retrieve and store the signature object @@ -95,7 +95,7 @@ def __init__(self, data, midtop=None): self.midtop = ( midtop - if midtop is not None + if midtop is not None else data['midtop'] diff --git a/nodezator/graphman/operatornode/surfs.py b/nodezator/graphman/operatornode/surfs.py index eea21605..c81ce347 100644 --- a/nodezator/graphman/operatornode/surfs.py +++ b/nodezator/graphman/operatornode/surfs.py @@ -5,23 +5,23 @@ ### local imports -from ourstdlibs.collections.general import FactoryDict +from ...ourstdlibs.collections.general import FactoryDict -from classes2d.single import Object2D -from classes2d.collections import List2D +from ...classes2d.single import Object2D +from ...classes2d.collections import List2D -from fontsman.constants import ENC_SANS_BOLD_FONT_PATH +from ...fontsman.constants import ENC_SANS_BOLD_FONT_PATH -from textman.render import render_text +from ...textman.render import render_text -from surfsman.draw import draw_border -from surfsman.render import render_rect, unite_surfaces +from ...surfsman.draw import draw_border +from ...surfsman.render import render_rect, unite_surfaces -from surfsman.icon import render_layered_icon +from ...surfsman.icon import render_layered_icon -from graphman.socket.surfs import SOCKET_DIAMETER +from ..socket.surfs import SOCKET_DIAMETER -from graphman.operatornode.constants import ( +from .constants import ( FONT_HEIGHT, MAX_WIDTH, OPERATIONS_MAP, @@ -35,7 +35,7 @@ NODE_OUTLINE_THICKNESS, ) -from colorsman.colors import ( +from ...colorsman.colors import ( OPERATION_NODE_NORMAL_BG, OPERATION_NODE_NORMAL_FG, @@ -78,9 +78,9 @@ def get_node_surface( outline_color, param_text_settings, ): - + char_objs = List2D( - + Object2D.from_surface( render_text( @@ -175,7 +175,7 @@ def get_node_surface( params = [ - char + char for char, flag in zip(string, CHAR_FILTERING_MAP[string]) diff --git a/nodezator/graphman/operatornode/vizop.py b/nodezator/graphman/operatornode/vizop.py index 0bced2ac..6f82fc3a 100644 --- a/nodezator/graphman/operatornode/vizop.py +++ b/nodezator/graphman/operatornode/vizop.py @@ -12,7 +12,7 @@ ### local import -from pygameconstants import SCREEN +from ...pygameconstants import SCREEN class VisualRelatedOperations: @@ -36,7 +36,7 @@ def on_mouse_action(self, method_name, event): position of the mouse click in order to know over which object the mouse button was clicked/released. - + Check pygame.event module documentation on pygame website for more info about this event object. @@ -116,7 +116,7 @@ def on_right_mouse_release(self, event): position of the mouse click in order to know over which object the mouse button was clicked/released. - + Check pygame.event module documentation on pygame website for more info about this event object. @@ -127,9 +127,9 @@ def on_right_mouse_release(self, event): self.input_sockets, self.output_sockets, ): - + if obj.rect.collidepoint(mouse_pos): - + try: method = obj.on_right_mouse_release except AttributeError: pass else: method(event) @@ -146,7 +146,7 @@ def draw_selection_outline(self, color): def check_sockets_for_segment_definition(self, event): """Check whether any socket collides w/ event.pos. - + event.pos is the position of a mouse left button release event. If the output socket collides with it the socket must be sent for line segment diff --git a/nodezator/graphman/operatornode/vizprep.py b/nodezator/graphman/operatornode/vizprep.py index 9066e7ad..b427681e 100644 --- a/nodezator/graphman/operatornode/vizprep.py +++ b/nodezator/graphman/operatornode/vizprep.py @@ -6,27 +6,27 @@ ### local imports -from classes2d.single import Object2D +from ...classes2d.single import Object2D -from rectsman.main import RectsManager +from ...rectsman.main import RectsManager -from graphman.operatornode.surfs import ( +from .surfs import ( NORMAL_SURFS, COMMENTED_OUT_SURFS, LABEL_SURF_MAP, ) -from graphman.operatornode.constants import ( +from .constants import ( LABEL_AREA_HEIGHT, CHAR_FILTERING_MAP, ) -from graphman.socket.surfs import type_to_codename +from ..socket.surfs import type_to_codename ## classes for composition -from graphman.socket.input import InputSocket -from graphman.socket.output import OutputSocket +from ..socket.input import InputSocket +from ..socket.output import OutputSocket TYPE_CODENAME = type_to_codename(_empty) diff --git a/nodezator/graphman/proxynode/constants.py b/nodezator/graphman/proxynode/constants.py index 6ef4d8d1..8a0a87bc 100644 --- a/nodezator/graphman/proxynode/constants.py +++ b/nodezator/graphman/proxynode/constants.py @@ -1,9 +1,9 @@ ### local imports -from fontsman.constants import ENC_SANS_BOLD_FONT_HEIGHT +from ...fontsman.constants import ENC_SANS_BOLD_FONT_HEIGHT -from graphman.socket.surfs import SOCKET_DIAMETER +from ..socket.surfs import SOCKET_DIAMETER NODE_OUTLINE_THICKNESS = 2 diff --git a/nodezator/graphman/proxynode/export.py b/nodezator/graphman/proxynode/export.py index b427b373..237750f1 100644 --- a/nodezator/graphman/proxynode/export.py +++ b/nodezator/graphman/proxynode/export.py @@ -9,15 +9,15 @@ ### local imports -from pointsman2d.shape import cross_from_rect -from pointsman2d.transform import rotate_points +from ...pointsman2d.shape import cross_from_rect +from ...pointsman2d.transform import rotate_points -from graphman.proxynode.constants import ( +from .constants import ( NODE_OUTLINE_THICKNESS, FONT_HEIGHT, ) -from colorsman.colors import ( +from ...colorsman.colors import ( BLACK, @@ -182,7 +182,7 @@ def svg_repr(self): ### output socket node_g.append(self.output_socket.svg_repr()) - ### + ### try: self.widget @@ -225,7 +225,7 @@ def svg_repr(self): button_rect = ( self.remove_button.rect.inflate(-2, -2) ) - + path_directives = 'M' for x, y in rotate_points( diff --git a/nodezator/graphman/proxynode/main.py b/nodezator/graphman/proxynode/main.py index 95db4d9e..607323a3 100644 --- a/nodezator/graphman/proxynode/main.py +++ b/nodezator/graphman/proxynode/main.py @@ -1,19 +1,19 @@ ### class extensions -from graphman.proxynode.vizprep import ( +from .vizprep import ( VisualRelatedPreparations, ) -from graphman.proxynode.vizop.main import ( +from .vizop.main import ( VisualRelatedOperations, ) -from graphman.proxynode.widget import WidgetOps +from .widget import WidgetOps -from graphman.proxynode.segment import SegmentOps +from .segment import SegmentOps -from graphman.proxynode.export import Exporting +from .export import Exporting class ProxyNode( diff --git a/nodezator/graphman/proxynode/segment.py b/nodezator/graphman/proxynode/segment.py index f2371171..1eff1b49 100644 --- a/nodezator/graphman/proxynode/segment.py +++ b/nodezator/graphman/proxynode/segment.py @@ -1,6 +1,6 @@ -from graphman.socket.surfs import type_to_codename +from ..socket.surfs import type_to_codename class SegmentOps: diff --git a/nodezator/graphman/proxynode/surfs.py b/nodezator/graphman/proxynode/surfs.py index bd612bba..a6c25e4d 100644 --- a/nodezator/graphman/proxynode/surfs.py +++ b/nodezator/graphman/proxynode/surfs.py @@ -5,23 +5,23 @@ ### local imports -from textman.render import render_text +from ...textman.render import render_text -from surfsman.draw import draw_border -from surfsman.render import render_rect +from ...surfsman.draw import draw_border +from ...surfsman.render import render_rect -from surfsman.icon import render_layered_icon +from ...surfsman.icon import render_layered_icon -from graphman.proxynode.constants import ( +from .constants import ( FONT_HEIGHT, HEADER_HEIGHT, MAX_WIDTH, NODE_OUTLINE_THICKNESS, ) -from ourstdlibs.collections.general import FactoryDict +from ...ourstdlibs.collections.general import FactoryDict -from colorsman.colors import ( +from ...colorsman.colors import ( PROXY_NODE_NORMAL_BG, PROXY_NODE_NORMAL_FG, diff --git a/nodezator/graphman/proxynode/utils.py b/nodezator/graphman/proxynode/utils.py index 2ff10b33..dea0781a 100644 --- a/nodezator/graphman/proxynode/utils.py +++ b/nodezator/graphman/proxynode/utils.py @@ -1,5 +1,5 @@ -from our3rdlibs.behaviour import indicate_unsaved +from ...our3rdlibs.behaviour import indicate_unsaved def update_with_widget(data, key, widget): diff --git a/nodezator/graphman/proxynode/vizop/main.py b/nodezator/graphman/proxynode/vizop/main.py index 0292c0c2..42c62490 100644 --- a/nodezator/graphman/proxynode/vizop/main.py +++ b/nodezator/graphman/proxynode/vizop/main.py @@ -10,10 +10,10 @@ ### local imports -from pygameconstants import SCREEN +from ....pygameconstants import SCREEN ## function for injection -from graphman.proxynode.vizop.reposition import ( +from .reposition import ( reposition_elements, ) @@ -41,7 +41,7 @@ def on_mouse_action(self, method_name, event): position of the mouse click in order to know over which object the mouse button was clicked/released. - + Check pygame.event module documentation on pygame website for more info about this event object. @@ -118,7 +118,7 @@ def on_right_mouse_release(self, event): position of the mouse click in order to know over which object the mouse button was clicked/released. - + Check pygame.event module documentation on pygame website for more info about this event object. @@ -126,9 +126,9 @@ def on_right_mouse_release(self, event): mouse_pos = event.pos for obj in self.mouse_aware_objects: - + if obj.rect.collidepoint(mouse_pos): - + try: method = obj.on_right_mouse_release except AttributeError: pass else: method(event) @@ -145,7 +145,7 @@ def draw_selection_outline(self, color): def check_sockets_for_segment_definition(self, event): """Check whether any socket collides w/ event.pos. - + event.pos is the position of a mouse left button release event. If the output socket collides with it the socket must be sent for line segment diff --git a/nodezator/graphman/proxynode/vizop/reposition.py b/nodezator/graphman/proxynode/vizop/reposition.py index c3b8013e..95810482 100644 --- a/nodezator/graphman/proxynode/vizop/reposition.py +++ b/nodezator/graphman/proxynode/vizop/reposition.py @@ -1,5 +1,5 @@ -from graphman.proxynode.constants import ( +from ..constants import ( NODE_OUTLINE_THICKNESS, LABEL_X_PADDING, ) diff --git a/nodezator/graphman/proxynode/vizprep.py b/nodezator/graphman/proxynode/vizprep.py index e8907f89..eb76b800 100644 --- a/nodezator/graphman/proxynode/vizprep.py +++ b/nodezator/graphman/proxynode/vizprep.py @@ -10,36 +10,36 @@ ### local imports -from ourstdlibs.collections.general import CallList +from ...ourstdlibs.collections.general import CallList -from our3rdlibs.button import Button +from ...our3rdlibs.button import Button -from classes2d.single import Object2D +from ...classes2d.single import Object2D -from rectsman.main import RectsManager +from ...rectsman.main import RectsManager -from graphman.widget.utils import WIDGET_CLASS_MAP +from ..widget.utils import WIDGET_CLASS_MAP -from graphman.socket.surfs import type_to_codename +from ..socket.surfs import type_to_codename -from graphman.proxynode.utils import update_with_widget +from .utils import update_with_widget -from graphman.proxynode.surfs import ( +from .surfs import ( LABEL_SURF_MAP, HEADER_SURF_MAP, ADD_BUTTON_SURF, REMOVE_BUTTON_SURF, ) -from graphman.proxynode.constants import ( +from .constants import ( HEADER_LABEL_WIDTH_INCREMENT, ) ## classes for composition -from graphman.socket.proxy import ProxySocket -from graphman.socket.output import OutputSocket +from ..socket.proxy import ProxySocket +from ..socket.output import OutputSocket @@ -368,7 +368,7 @@ def update_label_surface(self): self.label.rect.size = self.label.image.get_size() def get_new_label_surface(self): - + return LABEL_SURF_MAP[ ( diff --git a/nodezator/graphman/proxynode/widget.py b/nodezator/graphman/proxynode/widget.py index d4244dab..04af92c2 100644 --- a/nodezator/graphman/proxynode/widget.py +++ b/nodezator/graphman/proxynode/widget.py @@ -6,27 +6,27 @@ ### local imports -from config import APP_REFS +from ...config import APP_REFS -from ourstdlibs.behaviour import remove_by_identity +from ...ourstdlibs.behaviour import remove_by_identity -from ourstdlibs.collections.general import CallList +from ...ourstdlibs.collections.general import CallList -from our3rdlibs.button import Button +from ...our3rdlibs.button import Button -from our3rdlibs.behaviour import indicate_unsaved +from ...our3rdlibs.behaviour import indicate_unsaved -from widget.stringentry import StringEntry +from ...widget.stringentry import StringEntry -from rectsman.main import RectsManager +from ...rectsman.main import RectsManager -from graphman.widget.utils import WIDGET_CLASS_MAP +from ..widget.utils import WIDGET_CLASS_MAP -from graphman.socket.surfs import type_to_codename +from ..socket.surfs import type_to_codename -from graphman.proxynode.utils import update_with_widget +from .utils import update_with_widget -from graphman.proxynode.surfs import ( +from .surfs import ( ADD_BUTTON_SURF, REMOVE_BUTTON_SURF, ) @@ -160,7 +160,7 @@ def remove_widget(self): ) for name in ('widget', 'remove_button'): - + obj = getattr(self, name) delattr(self, name) diff --git a/nodezator/graphman/socket/output.py b/nodezator/graphman/socket/output.py index 0f974214..ae8810a7 100644 --- a/nodezator/graphman/socket/output.py +++ b/nodezator/graphman/socket/output.py @@ -6,14 +6,14 @@ ### local imports -from graphman.socket.base import Socket +from .base import Socket -from graphman.socket.surfs import ( +from .surfs import ( HOLLOW_SOCKET_CIRCLE_SURF, CODENAME_TO_STYLE_MAP, ) -from colorsman.colors import HOLLOW_SOCKET_OUTLINE +from ...colorsman.colors import HOLLOW_SOCKET_OUTLINE class OutputSocket(Socket): @@ -61,7 +61,7 @@ def __init__( ## store output name argument self.output_name = output_name - ## store type codename and perform related setups + ## store type codename and perform related setups self.update_type_codename(type_codename) ### obtain rect from image and position it using diff --git a/nodezator/graphman/socket/placeholder.py b/nodezator/graphman/socket/placeholder.py index 5d840400..b9bd54b9 100644 --- a/nodezator/graphman/socket/placeholder.py +++ b/nodezator/graphman/socket/placeholder.py @@ -6,13 +6,13 @@ ### local imports -from graphman.socket.surfs import ( +from ..socket.surfs import ( HOLLOW_SOCKET_CIRCLE_SURF, ) -from graphman.socket.base import Socket +from ..socket.base import Socket -from colorsman.colors import HOLLOW_SOCKET_OUTLINE +from ...colorsman.colors import HOLLOW_SOCKET_OUTLINE class PlaceholderSocket(Socket): diff --git a/nodezator/graphman/socket/proxy.py b/nodezator/graphman/socket/proxy.py index 65dbb864..b652573d 100644 --- a/nodezator/graphman/socket/proxy.py +++ b/nodezator/graphman/socket/proxy.py @@ -6,14 +6,14 @@ ### local imports -from graphman.socket.surfs import ( +from .surfs import ( HOLLOW_SOCKET_CIRCLE_SURF, CODENAME_TO_STYLE_MAP, ) -from graphman.socket.base import Socket +from .base import Socket -from colorsman.colors import HOLLOW_SOCKET_OUTLINE +from ...colorsman.colors import HOLLOW_SOCKET_OUTLINE class ProxySocket(Socket): @@ -37,7 +37,7 @@ def __init__( ## node instance self.node = node - ## store type codename and perform related setups + ## store type codename and perform related setups self.update_type_codename(type_codename) ### obtain rect from image and position it using diff --git a/nodezator/graphman/stlibnode/main.py b/nodezator/graphman/stlibnode/main.py index 1dcef15f..34897f1e 100644 --- a/nodezator/graphman/stlibnode/main.py +++ b/nodezator/graphman/stlibnode/main.py @@ -6,7 +6,7 @@ ### local imports -from graphman.stlibnode.constants import ( +from .constants import ( STLIB_IDS_TO_CALLABLES_MAP, STLIB_IDS_TO_SIGNATURES_MAP, STLIB_IDS_TO_SIGNATURE_CALLABLES_MAP, @@ -14,12 +14,12 @@ STLIB_IDS_TO_SOURCE_VIEW_TEXT, ) -from colorsman.colors import ( +from ...colorsman.colors import ( STANDARD_LIB_NODES_CATEGORY_COLOR ) ## superclass -from graphman.callablenode.main import CallableNode +from ..callablenode.main import CallableNode class StandardLibNode(CallableNode): @@ -45,7 +45,7 @@ def __init__(self, data, midtop=None): ### retrieve and store the main callable obj in ### its own attribute self.main_callable = ( - STLIB_IDS_TO_CALLABLES_MAP[data['stlib_id']] + STLIB_IDS_TO_CALLABLES_MAP[data['stlib_id']] ) ### also retrieve and store the callable used to @@ -114,7 +114,7 @@ def __init__(self, data, midtop=None): self.midtop = ( midtop - if midtop is not None + if midtop is not None else self.data['midtop'] diff --git a/nodezator/graphman/textblock/check.py b/nodezator/graphman/textblock/check.py index c07051dd..95bbbb41 100644 --- a/nodezator/graphman/textblock/check.py +++ b/nodezator/graphman/textblock/check.py @@ -2,9 +2,9 @@ ### local imports -from ourstdlibs.stringutils import check_contains_non_whitespace +from ...ourstdlibs.stringutils import check_contains_non_whitespace -from ourstdlibs.exceptionutils import new_raiser_from_existing +from ...ourstdlibs.exceptionutils import new_raiser_from_existing ### utility function to validate text for text block diff --git a/nodezator/graphman/textblock/constants.py b/nodezator/graphman/textblock/constants.py index 7ef41a4c..f2d67dda 100644 --- a/nodezator/graphman/textblock/constants.py +++ b/nodezator/graphman/textblock/constants.py @@ -1,7 +1,7 @@ """Constants for the TextBlock class.""" ### local import -from fontsman.constants import ( +from ...fontsman.constants import ( FIRA_MONO_BOLD_FONT_HEIGHT, FIRA_MONO_BOLD_FONT_PATH) diff --git a/nodezator/graphman/textblock/export.py b/nodezator/graphman/textblock/export.py index 8c252744..f34c41c3 100644 --- a/nodezator/graphman/textblock/export.py +++ b/nodezator/graphman/textblock/export.py @@ -6,24 +6,24 @@ ### local imports -from textman.render import get_text_size +from ...textman.render import get_text_size -from syntaxman.utils import ( +from ...syntaxman.utils import ( SYNTAX_TO_MAPPING_FUNCTION, get_ready_theme, ) -from graphman.textblock.constants import ( +from .constants import ( OUTLINE_THICKNESS, FONT_HEIGHT, ) -from graphman.textblock.constants import ( +from .constants import ( FONT_HEIGHT, FONT_PATH, ) -from colorsman.colors import TEXT_BLOCK_OUTLINE +from ...colorsman.colors import TEXT_BLOCK_OUTLINE GENERAL_TEXT_KWARGS = { diff --git a/nodezator/graphman/textblock/main.py b/nodezator/graphman/textblock/main.py index 6eaefa87..ff273a08 100644 --- a/nodezator/graphman/textblock/main.py +++ b/nodezator/graphman/textblock/main.py @@ -10,15 +10,15 @@ ### local imports -from pygameconstants import SCREEN +from ...pygameconstants import SCREEN -from classes2d.single import Object2D +from ...classes2d.single import Object2D -from graphman.textblock.surf import get_text_block_surf -from graphman.textblock.check import check_text_block_text +from .surf import get_text_block_surf +from .check import check_text_block_text ### function for injection -from graphman.textblock.export import svg_repr +from .export import svg_repr class TextBlock(Object2D): @@ -55,7 +55,7 @@ def __init__(self, data, midtop=None): ### store the midtop position self.midtop = ( - midtop if midtop is not None + midtop if midtop is not None else self.data['midtop'] ) @@ -79,7 +79,7 @@ def on_mouse_action(self, method_name, event): Works by marking the text block as a target of the mouse release or mouse click action by change the values of the respective flags in specific ways. - + The flags are used to support the object selection and "move by dragging" features. @@ -91,7 +91,7 @@ def on_mouse_action(self, method_name, event): though we don't use it in this method, it is required in order to comply with protocol used; - + Check pygame.event module documentation on pygame website for more info about this event object. diff --git a/nodezator/graphman/textblock/surf.py b/nodezator/graphman/textblock/surf.py index f2a38821..d97200b8 100644 --- a/nodezator/graphman/textblock/surf.py +++ b/nodezator/graphman/textblock/surf.py @@ -6,15 +6,15 @@ ### local imports -from surfsman.draw import draw_border +from ...surfsman.draw import draw_border -from syntaxman.utils import get_ready_theme +from ...syntaxman.utils import get_ready_theme -from textman.text import get_highlighted_lines +from ...textman.text import get_highlighted_lines -from colorsman.colors import TEXT_BLOCK_OUTLINE +from ...colorsman.colors import TEXT_BLOCK_OUTLINE -from graphman.textblock.constants import ( +from .constants import ( FONT_HEIGHT, FONT_PATH, PADDING, @@ -58,7 +58,7 @@ def get_text_block_surf(text): text like the one in this function is guarded by try/exception clauses to prevent from errors when mapping the syntax. - + We don't do so here, because comments don't have wrong syntax. They either have special syntax ("todo" words) or no syntax at all. Thus, the probability of syntax @@ -114,7 +114,7 @@ def get_text_block_surf(text): ## and produce a copy which is inflated in both ## dimensions by the value of extra_space .inflate(extra_space, extra_space) - + ## and finally get its size .size ) diff --git a/nodezator/graphman/widget/picker/main.py b/nodezator/graphman/widget/picker/main.py index 22e596c3..978a4918 100644 --- a/nodezator/graphman/widget/picker/main.py +++ b/nodezator/graphman/widget/picker/main.py @@ -24,44 +24,44 @@ ### local imports -from translation import TRANSLATION_HOLDER as t +from ....translation import TRANSLATION_HOLDER as t -from pygameconstants import ( +from ....pygameconstants import ( SCREEN_RECT, FPS, maintain_fps, ) -from our3rdlibs.button import Button +from ....our3rdlibs.button import Button -from classes2d.single import Object2D +from ....classes2d.single import Object2D -from textman.render import render_text +from ....textman.render import render_text -from surfsman.draw import draw_border -from surfsman.render import render_rect +from ....surfsman.draw import draw_border +from ....surfsman.render import render_rect -from widget.optionmenu.main import OptionMenu +from ....widget.optionmenu.main import OptionMenu -from loopman.exception import ( +from ....loopman.exception import ( QuitAppException, SwitchLoopException, ) -from fontsman.constants import ENC_SANS_BOLD_FONT_HEIGHT +from ....fontsman.constants import ENC_SANS_BOLD_FONT_HEIGHT -from graphman.widget.utils import WIDGET_CLASS_MAP +from ..utils import WIDGET_CLASS_MAP -from colorsman.colors import ( +from ....colorsman.colors import ( BUTTON_FG, BUTTON_BG, WINDOW_FG, WINDOW_BG, CONTRAST_LAYER_COLOR, ) -from dialog import create_and_show_dialog +from ....dialog import create_and_show_dialog ## class extension -from graphman.widget.picker.subforms import SubformCreation +from .subforms import SubformCreation ### constants @@ -103,7 +103,7 @@ ### class definition -### XXX +### XXX ### you must decide what to do about the list widget ### increasing its height; should the widget picker ### contents be scrollable? ponder @@ -321,7 +321,7 @@ def reposition_form_elements(self): self.widget_subform.rect.bottom self.cancel_button.rect.y += 10 - ### then align the submit button topleft with the + ### then align the submit button topleft with the ### cancel button topright just a little bit more ### to the right self.submit_button.rect.topleft = \ @@ -407,7 +407,7 @@ def mouse_method_on_collision(self, method_name, event): mouse interaction protocol used; here we use it to retrieve the position of the mouse when the first button was released. - + Check pygame.event module documentation on pygame website for more info about this event object. @@ -564,7 +564,7 @@ def update(self): loop holder (that is, it must have handle_input, update, and draw methods). """ - + def draw(self): """Draw itself and widgets. diff --git a/nodezator/graphman/widget/picker/subforms.py b/nodezator/graphman/widget/picker/subforms.py index ff4bdc99..84931ade 100644 --- a/nodezator/graphman/widget/picker/subforms.py +++ b/nodezator/graphman/widget/picker/subforms.py @@ -11,46 +11,46 @@ ### local imports -from ourstdlibs.stringutils import VALIDATION_COMMAND_MAP +from ....ourstdlibs.stringutils import VALIDATION_COMMAND_MAP -from textman.render import render_text +from ....textman.render import render_text -from fontsman.constants import ENC_SANS_BOLD_FONT_HEIGHT +from ....fontsman.constants import ENC_SANS_BOLD_FONT_HEIGHT -from classes2d.single import Object2D -from classes2d.collections import List2D +from ....classes2d.single import Object2D +from ....classes2d.collections import List2D -from colorsman.colors import WINDOW_FG, WINDOW_BG +from ....colorsman.colors import WINDOW_FG, WINDOW_BG -from dialog import create_and_show_dialog +from ....dialog import create_and_show_dialog ## widgets -from widget.stringentry import StringEntry -from widget.literalentry import LiteralEntry -from widget.intfloatentry.main import IntFloatEntry +from ....widget.stringentry import StringEntry +from ....widget.literalentry import LiteralEntry +from ....widget.intfloatentry.main import IntFloatEntry -from widget.checkbutton import CheckButton -from widget.colorbutton import ColorButton -from widget.sortingbutton import SortingButton +from ....widget.checkbutton import CheckButton +from ....widget.colorbutton import ColorButton +from ....widget.sortingbutton import SortingButton -from widget.textdisplay import TextDisplay -from widget.literaldisplay import LiteralDisplay +from ....widget.textdisplay import TextDisplay +from ....widget.literaldisplay import LiteralDisplay -from widget.optionmenu.main import OptionMenu -from widget.optiontray.main import OptionTray +from ....widget.optionmenu.main import OptionMenu +from ....widget.optiontray.main import OptionTray -from widget.pathpreview.path import PathPreview -from widget.pathpreview.text import TextPreview -from widget.pathpreview.image import ImagePreview -from widget.pathpreview.audio import AudioPreview -from widget.pathpreview.video import VideoPreview -from widget.pathpreview.font import FontPreview +from ....widget.pathpreview.path import PathPreview +from ....widget.pathpreview.text import TextPreview +from ....widget.pathpreview.image import ImagePreview +from ....widget.pathpreview.audio import AudioPreview +from ....widget.pathpreview.video import VideoPreview +from ....widget.pathpreview.font import FontPreview -from our3rdlibs.iterablewidget.list import ListWidget -from our3rdlibs.iterablewidget.set import SetWidget +from ....our3rdlibs.iterablewidget.list import ListWidget +from ....our3rdlibs.iterablewidget.set import SetWidget FONT_HEIGHT = ENC_SANS_BOLD_FONT_HEIGHT @@ -1483,7 +1483,7 @@ def command(): ) options_list_widget.command = command - + ### format the subform key according to the kind ### of content used @@ -1683,7 +1683,7 @@ def command(): ) options_list_widget.command = command - + ### format the subform key according to the kind ### of content used diff --git a/nodezator/our3rdlibs/iterablewidget/list.py b/nodezator/our3rdlibs/iterablewidget/list.py index b8ffff22..cf4a962b 100644 --- a/nodezator/our3rdlibs/iterablewidget/list.py +++ b/nodezator/our3rdlibs/iterablewidget/list.py @@ -6,20 +6,20 @@ ### local imports -from ourstdlibs.behaviour import ( +from ...ourstdlibs.behaviour import ( empty_function, get_oblivious_callable, ) -from classes2d.single import Object2D -from classes2d.collections import List2D +from ...classes2d.single import Object2D +from ...classes2d.collections import List2D -from rectsman.main import RectsManager, rect_property +from ...rectsman.main import RectsManager, rect_property -from our3rdlibs.iterablewidget.surfs import ADD_BUTTON_SURF +from .surfs import ADD_BUTTON_SURF ## class extension -from our3rdlibs.iterablewidget.op import ( +from .op import ( ListWidgetLifetimeOperations, ) @@ -157,16 +157,16 @@ def __init__( ### rectsman protocol (check rectsman subpackage ### for more info on that); ### - ### also, though I can control all items plus the - ### add button with the rects manager of the - ### List2D instance in the "all_objects" - ### attribute, having a dedicated rects manager - ### instance may be useful in case I decide to add - ### other aesthetic elements, like a custom - ### background (in which case I'd need a create an - ### additional "rect" and would not want to add it - ### to the "all_objects" list, I'd just keep it - ### elsewhere as yield it in the "get_all_rects" + ### also, though I can control all items plus the + ### add button with the rects manager of the + ### List2D instance in the "all_objects" + ### attribute, having a dedicated rects manager + ### instance may be useful in case I decide to add + ### other aesthetic elements, like a custom + ### background (in which case I'd need a create an + ### additional "rect" and would not want to add it + ### to the "all_objects" list, I'd just keep it + ### elsewhere as yield it in the "get_all_rects" ### method) self._rects_man = RectsManager(self.get_all_rects) diff --git a/nodezator/our3rdlibs/iterablewidget/op.py b/nodezator/our3rdlibs/iterablewidget/op.py index 1d9b0706..818c308d 100644 --- a/nodezator/our3rdlibs/iterablewidget/op.py +++ b/nodezator/our3rdlibs/iterablewidget/op.py @@ -6,12 +6,12 @@ ### local imports -from ourstdlibs.behaviour import get_oblivious_callable +from ...ourstdlibs.behaviour import get_oblivious_callable -from classes2d.single import Object2D -from classes2d.collections import List2D +from ...classes2d.single import Object2D +from ...classes2d.collections import List2D -from our3rdlibs.iterablewidget.surfs import ( +from .surfs import ( MOVE_UP_BUTTON_SURF, MOVE_DOWN_BUTTON_SURF, REMOVE_BUTTON_SURF, @@ -253,7 +253,7 @@ def call_mouse_method(self, method_name, event): It is required in order to comply with protocol used. We retrieve the mouse position from its "pos" attribute. - + Check pygame.event module documentation on pygame website for more info about this event object. @@ -462,7 +462,7 @@ def set( ### also, if the length of the specified value ### isn't allowed, we also cancel the operation ### by returning earlier - + length = len(value) if not length >= self.min_len \ diff --git a/nodezator/our3rdlibs/iterablewidget/surfs.py b/nodezator/our3rdlibs/iterablewidget/surfs.py index fc965a94..e1163235 100644 --- a/nodezator/our3rdlibs/iterablewidget/surfs.py +++ b/nodezator/our3rdlibs/iterablewidget/surfs.py @@ -2,9 +2,9 @@ ### local imports -from surfsman.icon import render_layered_icon +from ...surfsman.icon import render_layered_icon -from colorsman.colors import ( +from ...colorsman.colors import ( LIST_WIDGET_BUTTON_FG, LIST_WIDGET_BUTTON_BG, LIST_WIDGET_REMOVE_BUTTON_FG) From cd03495e09dabe2afe121facd9b3c307fcaf86d4 Mon Sep 17 00:00:00 2001 From: pmp-p Date: Wed, 20 Jul 2022 19:18:51 +0200 Subject: [PATCH 5/8] 4/4 --- nodezator/editing/categorycolors.py | 54 +++++------ nodezator/editing/data.py | 60 ++++++------- nodezator/editing/export/form/image.py | 46 +++++----- nodezator/editing/export/form/python.py | 40 ++++----- nodezator/editing/export/main.py | 42 ++++----- nodezator/editing/reposition.py | 16 ++-- nodezator/editing/selection.py | 16 ++-- nodezator/graphman/builtinnode/export.py | 4 +- nodezator/graphman/capsulenode/export.py | 4 +- nodezator/graphman/editlogic.py | 8 +- nodezator/graphman/execution.py | 38 ++++---- nodezator/graphman/main.py | 46 +++++----- nodezator/graphman/nodepacksissues.py | 14 +-- nodezator/graphman/pythonrepr.py | 90 +++++++++---------- nodezator/graphman/scriptloading.py | 30 +++---- nodezator/graphman/socketparenthood/action.py | 8 +- nodezator/graphman/socketparenthood/draw.py | 6 +- nodezator/graphman/socketparenthood/main.py | 8 +- .../graphman/socketparenthood/support.py | 20 ++--- nodezator/graphman/socketparenthood/utils.py | 80 ++++++++--------- nodezator/graphman/stlibnode/export.py | 4 +- .../graphman/widget/creationpopupmenu.py | 6 +- nodezator/hideswitch.py | 10 +-- nodezator/mainloop.py | 5 +- nodezator/menu/behaviour.py | 20 ++--- nodezator/menu/command.py | 18 ++-- nodezator/menu/common.py | 8 +- nodezator/menu/hover.py | 8 +- nodezator/menu/iconfactory.py | 12 +-- nodezator/menu/main.py | 44 ++++----- nodezator/menu/scroll.py | 20 ++--- nodezator/menu/submenu/main.py | 26 +++--- nodezator/menu/submenu/scroll.py | 18 ++-- nodezator/menu/surffactory.py | 24 ++--- nodezator/our3rdlibs/iterablewidget/set.py | 2 +- nodezator/rectsman/utils.py | 2 +- nodezator/splashscreen/animsetup.py | 2 +- nodezator/splashscreen/constants.py | 4 +- nodezator/splashscreen/factoryfuncs.py | 36 ++++---- nodezator/splashscreen/main.py | 40 ++++----- nodezator/splashscreen/op.py | 20 ++--- nodezator/textman/label/autolabel.py | 4 +- nodezator/userprefsman/editionform.py | 58 ++++++------ nodezator/winman/fileop.py | 30 +++---- nodezator/winman/label.py | 12 +-- nodezator/winman/main.py | 28 +++--- nodezator/winman/menu.py | 44 ++++----- nodezator/winman/nodepacksforms/renaming.py | 56 ++++++------ nodezator/winman/nodepacksforms/selection.py | 52 +++++------ nodezator/winman/states/boxselection.py | 6 +- nodezator/winman/states/loadedfile.py | 20 ++--- nodezator/winman/states/movingobject.py | 6 +- nodezator/winman/states/nofile.py | 10 +-- nodezator/winman/states/segmentdef.py | 6 +- nodezator/winman/states/segmentsev.py | 6 +- nodezator/winman/switch.py | 8 +- 56 files changed, 654 insertions(+), 651 deletions(-) diff --git a/nodezator/editing/categorycolors.py b/nodezator/editing/categorycolors.py index 509023a2..70f2e2f8 100644 --- a/nodezator/editing/categorycolors.py +++ b/nodezator/editing/categorycolors.py @@ -25,55 +25,55 @@ ### local imports -from config import APP_REFS +from ..config import APP_REFS -from appinfo import NODE_CATEGORY_METADATA_FILENAME +from ..appinfo import NODE_CATEGORY_METADATA_FILENAME -from translation import TRANSLATION_HOLDER as t +from ..translation import TRANSLATION_HOLDER as t -from dialog import create_and_show_dialog +from ..dialog import create_and_show_dialog -from pygameconstants import ( +from ..pygameconstants import ( SCREEN, SCREEN_RECT, blit_on_screen, ) -from ourstdlibs.pyl import load_pyl, save_pyl +from ..ourstdlibs.pyl import load_pyl, save_pyl -from ourstdlibs.collections.general import CallList +from ..ourstdlibs.collections.general import CallList -from ourstdlibs.behaviour import ( +from ..ourstdlibs.behaviour import ( empty_function, get_oblivious_callable, ) -from our3rdlibs.button import Button +from ..our3rdlibs.button import Button -from our3rdlibs.behaviour import set_status_message +from ..our3rdlibs.behaviour import set_status_message -from classes2d.single import Object2D -from classes2d.collections import List2D +from ..classes2d.single import Object2D +from ..classes2d.collections import List2D -from fontsman.constants import ( +from ..fontsman.constants import ( ENC_SANS_BOLD_FONT_HEIGHT, ENC_SANS_BOLD_FONT_PATH, ) -from textman.render import render_text +from ..textman.render import render_text -from surfsman.cache import UNHIGHLIGHT_SURF_MAP +from ..surfsman.cache import UNHIGHLIGHT_SURF_MAP -from surfsman.draw import draw_border, draw_depth_finish +from ..surfsman.draw import draw_border, draw_depth_finish -from surfsman.render import render_rect +from ..surfsman.render import render_rect -from pointsman2d.create import get_circle_points +from ..pointsman2d.create import get_circle_points -from loopman.main import LoopHolder +from ..loopman.main import LoopHolder -from colorsman.colors import ( +from ..colorsman.colors import ( CONTRAST_LAYER_COLOR, GRAPH_BG, BUTTON_FG, BUTTON_BG, @@ -81,9 +81,9 @@ NODE_CATEGORY_COLORS, ) -from colorsman.color2d import Color2D +from ..colorsman.color2d import Color2D -from colorsman.picker.main import pick_colors +from ..colorsman.picker.main import pick_colors @@ -212,7 +212,7 @@ def build_form_widgets(self): color_widget.on_mouse_release = ( color_setting_command ) - + ### category_label = ( @@ -307,7 +307,7 @@ def build_form_widgets(self): ) def change_category_colors(self): - + ### try: node_packs = APP_REFS.data['node_packs'] @@ -398,7 +398,7 @@ def mouse_method_on_collision(self, method_name, event): mouse interaction protocol used; here we use it to retrieve the position of the mouse when the first button was released. - + Check pygame.event module documentation on pygame website for more info about this event object. @@ -445,14 +445,14 @@ def on_mouse_motion(self, event): for widget in self.widgets: if not isinstance(widget, List2D): continue - + if widget.rect.collidepoint(mouse_pos): self.hovered_rect = widget.rect break else: self.hovered_rect = None - + def finish_form(self): """Assign new category indices and exit loop.""" diff --git a/nodezator/editing/data.py b/nodezator/editing/data.py index a7f19164..04add10c 100644 --- a/nodezator/editing/data.py +++ b/nodezator/editing/data.py @@ -24,53 +24,53 @@ ### local imports -from config import APP_REFS +from ..config import APP_REFS -from logman.main import get_new_logger +from ..logman.main import get_new_logger -from translation import TRANSLATION_HOLDER as t +from ..translation import TRANSLATION_HOLDER as t -from dialog import create_and_show_dialog +from ..dialog import create_and_show_dialog -from our3rdlibs.userlogger import USER_LOGGER +from ..our3rdlibs.userlogger import USER_LOGGER -from ourstdlibs.exceptionutils import bool_func_from_raiser +from ..ourstdlibs.exceptionutils import bool_func_from_raiser -from our3rdlibs.behaviour import ( +from ..our3rdlibs.behaviour import ( indicate_unsaved, set_status_message, ) -from fontsman.constants import FIRA_MONO_BOLD_FONT_PATH +from ..fontsman.constants import FIRA_MONO_BOLD_FONT_PATH -from textman.viewer.main import view_text +from ..textman.viewer.main import view_text -from textman.editor.main import edit_text +from ..textman.editor.main import edit_text -from fileman.main import select_path +from ..fileman.main import select_path -from graphman.utils import yield_subgraphs +from ..graphman.utils import yield_subgraphs -from graphman.callablenode.main import CallableNode -from graphman.stlibnode.main import StandardLibNode -from graphman.builtinnode.main import BuiltinNode -from graphman.operatornode.main import OperatorNode -from graphman.capsulenode.main import CapsuleNode -from graphman.proxynode.main import ProxyNode -from graphman.textblock.main import TextBlock +from ..graphman.callablenode.main import CallableNode +from ..graphman.stlibnode.main import StandardLibNode +from ..graphman.builtinnode.main import BuiltinNode +from ..graphman.operatornode.main import OperatorNode +from ..graphman.capsulenode.main import CapsuleNode +from ..graphman.proxynode.main import ProxyNode +from ..graphman.textblock.main import TextBlock -from graphman.textblock.check import ( +from ..graphman.textblock.check import ( check_text_block_text, ) -from graphman.nodepacksissues import ( +from ..graphman.nodepacksissues import ( get_formatted_current_node_packs, check_node_packs, ) -from graphman.exception import NODE_PACK_ERRORS +from ..graphman.exception import NODE_PACK_ERRORS -from graphman.scriptloading import load_scripts +from ..graphman.scriptloading import load_scripts ### create logger for module @@ -99,7 +99,7 @@ def retrieve_callable_info(callable_obj): ### try retrieving the source code for the callable ### as the text containing info about the callable try: text = getsource(callable_obj) - + ### if it is not possible (for instance, the built-in ### function 'pow' can't have its source retrieved, ### even though it works with inspect.signature), @@ -107,9 +107,9 @@ def retrieve_callable_info(callable_obj): ### if the docstring is None except (OSError, TypeError): - + text = getdoc(callable_obj) - + if text is None: text = t.editing.data.no_source_available @@ -421,7 +421,7 @@ def comment_uncomment_nodes(self): toggled_states = set() for subgraph in yield_subgraphs(selected_nodes): - + ### sample the state of the nodes from one of ### them; it can be any node, we use the first ### one @@ -515,14 +515,14 @@ def select_node_packs(self): ### there are instantiated nodes from them if removed: - + removed_names = {path.name for path in removed} orphaned_nodes_ids = [] not_removable_packs = set() for node in APP_REFS.gm.nodes: - + if 'script_id' not in node.data: continue @@ -638,7 +638,7 @@ def unlink_all_node_packs_from_file(self): not_removable_packs = set() for node in APP_REFS.gm.nodes: - + if 'script_id' not in node.data: continue diff --git a/nodezator/editing/export/form/image.py b/nodezator/editing/export/form/image.py index f7083601..341b321b 100644 --- a/nodezator/editing/export/form/image.py +++ b/nodezator/editing/export/form/image.py @@ -24,47 +24,47 @@ ### local imports -from translation import TRANSLATION_HOLDER as t +from ....translation import TRANSLATION_HOLDER as t -from pygameconstants import ( +from ....pygameconstants import ( SCREEN_RECT, FPS, maintain_fps, blit_on_screen, ) -from dialog import create_and_show_dialog +from ....dialog import create_and_show_dialog -from fileman.main import create_path +from ....fileman.main import create_path -from ourstdlibs.collections.general import CallList +from ....ourstdlibs.collections.general import CallList -from ourstdlibs.behaviour import empty_function +from ....ourstdlibs.behaviour import empty_function -from our3rdlibs.button import Button +from ....our3rdlibs.button import Button -from classes2d.single import Object2D -from classes2d.collections import List2D +from ....classes2d.single import Object2D +from ....classes2d.collections import List2D -from fontsman.constants import ( +from ....fontsman.constants import ( ENC_SANS_BOLD_FONT_HEIGHT, ENC_SANS_BOLD_FONT_PATH, ) -from textman.render import render_text -from textman.label.main import Label +from ....textman.render import render_text +from ....textman.label.main import Label -from surfsman.cache import UNHIGHLIGHT_SURF_MAP +from ....surfsman.cache import UNHIGHLIGHT_SURF_MAP -from surfsman.draw import draw_border, draw_depth_finish -from surfsman.render import render_rect +from ....surfsman.draw import draw_border, draw_depth_finish +from ....surfsman.render import render_rect -from loopman.exception import ( +from ....loopman.exception import ( QuitAppException, SwitchLoopException, ) -from colorsman.colors import ( +from ....colorsman.colors import ( CONTRAST_LAYER_COLOR, GRAPH_BG, BUTTON_FG, BUTTON_BG, WINDOW_FG, WINDOW_BG, @@ -72,11 +72,11 @@ ## widgets -from widget.intfloatentry.main import IntFloatEntry +from ....widget.intfloatentry.main import IntFloatEntry -from widget.colorbutton import ColorButton +from ....widget.colorbutton import ColorButton -from widget.checkbutton import CheckButton +from ....widget.checkbutton import CheckButton ### constants @@ -354,7 +354,7 @@ def build_form_widgets(self): midleft = margins_label.rect.move(10, 0).midright for name in ('horizontal_margin', 'vertical_margin'): - + entry = IntFloatEntry( loop_holder=self, value=10, @@ -528,7 +528,7 @@ def change_filepath(self): return if suffix in ('.svg', '.html'): - + if self.preview_kind_checkbutton not in ( self.widgets ): @@ -688,7 +688,7 @@ def mouse_method_on_collision(self, method_name, event): mouse interaction protocol used; here we use it to retrieve the position of the mouse when the first button was released. - + Check pygame.event module documentation on pygame website for more info about this event object. diff --git a/nodezator/editing/export/form/python.py b/nodezator/editing/export/form/python.py index 1feb16b1..13ec0460 100644 --- a/nodezator/editing/export/form/python.py +++ b/nodezator/editing/export/form/python.py @@ -24,9 +24,9 @@ ### local imports -from translation import TRANSLATION_HOLDER as t +from ....translation import TRANSLATION_HOLDER as t -from pygameconstants import ( +from ....pygameconstants import ( SCREEN_RECT, FPS, maintain_fps, @@ -34,41 +34,41 @@ ) -from dialog import create_and_show_dialog +from ....dialog import create_and_show_dialog -from fileman.main import create_path +from ....fileman.main import create_path -from our3rdlibs.button import Button -from ourstdlibs.behaviour import empty_function +from ....our3rdlibs.button import Button +from ....ourstdlibs.behaviour import empty_function -from ourstdlibs.collections.general import CallList +from ....ourstdlibs.collections.general import CallList -from classes2d.single import Object2D -from classes2d.collections import List2D +from ....classes2d.single import Object2D +from ....classes2d.collections import List2D -from fontsman.constants import ( +from ....fontsman.constants import ( ENC_SANS_BOLD_FONT_HEIGHT, ENC_SANS_BOLD_FONT_PATH, ) -from textman.render import render_text -from textman.label.main import Label +from ....textman.render import render_text +from ....textman.label.main import Label -from surfsman.cache import UNHIGHLIGHT_SURF_MAP +from ....surfsman.cache import UNHIGHLIGHT_SURF_MAP -from surfsman.draw import draw_border, draw_depth_finish -from surfsman.render import render_rect +from ....surfsman.draw import draw_border, draw_depth_finish +from ....surfsman.render import render_rect -from loopman.exception import ( +from ....loopman.exception import ( QuitAppException, SwitchLoopException, ) -from our3rdlibs.iterablewidget.list import ListWidget +from ....our3rdlibs.iterablewidget.list import ListWidget -from widget.stringentry import StringEntry +from ....widget.stringentry import StringEntry -from colorsman.colors import ( +from ....colorsman.colors import ( CONTRAST_LAYER_COLOR, BUTTON_FG, BUTTON_BG, WINDOW_FG, WINDOW_BG, @@ -499,7 +499,7 @@ def mouse_method_on_collision(self, method_name, event): mouse interaction protocol used; here we use it to retrieve the position of the mouse when the first button was released. - + Check pygame.event module documentation on pygame website for more info about this event object. diff --git a/nodezator/editing/export/main.py b/nodezator/editing/export/main.py index e0c3e0ed..3787884c 100644 --- a/nodezator/editing/export/main.py +++ b/nodezator/editing/export/main.py @@ -33,37 +33,37 @@ ### local imports -from config import APP_REFS +from ...config import APP_REFS -from dialog import create_and_show_dialog +from ...dialog import create_and_show_dialog -from logman.main import get_new_logger +from ...logman.main import get_new_logger -from our3rdlibs.userlogger import USER_LOGGER +from ...our3rdlibs.userlogger import USER_LOGGER -from ourstdlibs.timeutils import friendly_delta_from_secs +from ...ourstdlibs.timeutils import friendly_delta_from_secs -from our3rdlibs.behaviour import set_status_message +from ...our3rdlibs.behaviour import set_status_message -from rectsman.main import RectsManager +from ...rectsman.main import RectsManager -from editing.export.form.image import ( +from .form.image import ( get_image_exporting_settings ) -from editing.export.form.python import ( +from .form.python import ( get_python_exporting_settings ) -from graphman.callablenode.export import CALLABLE_NODE_CSS -from graphman.proxynode.export import PROXY_NODE_CSS -from graphman.stlibnode.export import STLIB_NODE_CSS -from graphman.builtinnode.export import BUILTIN_NODE_CSS -from graphman.capsulenode.export import CAPSULE_NODE_CSS -from graphman.operatornode.export import OPERATOR_NODE_CSS -from graphman.textblock.export import TEXT_BLOCK_CSS -from graphman.socket.surfs import SOCKET_AND_LINE_CSS -from graphman.widget.export import WIDGET_CSS +from ...graphman.callablenode.export import CALLABLE_NODE_CSS +from ...graphman.proxynode.export import PROXY_NODE_CSS +from ...graphman.stlibnode.export import STLIB_NODE_CSS +from ...graphman.builtinnode.export import BUILTIN_NODE_CSS +from ...graphman.capsulenode.export import CAPSULE_NODE_CSS +from ...graphman.operatornode.export import OPERATOR_NODE_CSS +from ...graphman.textblock.export import TEXT_BLOCK_CSS +from ...graphman.socket.surfs import SOCKET_AND_LINE_CSS +from ...graphman.widget.export import WIDGET_CSS ### create logger for module @@ -212,7 +212,7 @@ def export_as_image(self): ### occured), show it to the user via a dialog if error_str: - + dialog_message = ( "An error ocurred while trying to" " export the layout. Check the user log" @@ -449,7 +449,7 @@ def export_file_as_web_markup( ### TODO implement missing blocks below if parent.is_file(): - + raise RuntimeError( "Exporting can't proceed;" f" {parent} must not be a file" @@ -523,7 +523,7 @@ def export_file_as_web_markup( ### unescape all css lines for index, line in enumerate(text.splitlines()): - + if line.strip() == '