mirror of
https://github.com/1j01/textual-paint.git
synced 2024-08-17 11:50:38 +03:00
Convert relative imports to absolute
They honestly seem like a half-baked language feature. - Relative imports don't allow running a script via shebang line. - Relative imports don't work without a package, which means they don't work in situations other than when absolute imports also work, as far as I understand it. - Relative imports don't work with pytest-textual-snapshot currently, so I'm changing it to absolute imports in order to set up testing.
This commit is contained in:
parent
ed97f0afb0
commit
f1da33ca8e
@ -357,10 +357,6 @@ Also, note that it might not work with your Git GUI of choice; you may need to u
|
||||
|
||||
- Make sure to run the program from the root directory of the repository.
|
||||
|
||||
> `ImportError: attempted relative import with no known parent package`
|
||||
|
||||
- `paint.py` can only be run as a module, not as a script. I just... I haven't had the heart to remove the shebang line.
|
||||
|
||||
### Linting
|
||||
|
||||
```bash
|
||||
|
@ -21,7 +21,7 @@ from textual_paint.export_templates import (CUSTOM_CONSOLE_HTML_FORMAT,
|
||||
CUSTOM_CONSOLE_SVG_FORMAT)
|
||||
from textual_paint.palette_data import IRC_PALETTE
|
||||
|
||||
from .localization.i18n import get as _
|
||||
from textual_paint.localization.i18n import get as _
|
||||
|
||||
DEBUG_REGION_UPDATES = False
|
||||
|
||||
|
@ -4,7 +4,7 @@ import argparse
|
||||
import os
|
||||
import re
|
||||
|
||||
from .__init__ import DEVELOPMENT, __version__
|
||||
from textual_paint.__init__ import DEVELOPMENT, __version__
|
||||
|
||||
parser = argparse.ArgumentParser(description='Paint in the terminal.', usage='%(prog)s [options] [filename]', prog="textual-paint")
|
||||
parser.add_argument('--version', action='version', version=f'%(prog)s {__version__}')
|
||||
|
@ -9,8 +9,8 @@ from typing import TYPE_CHECKING
|
||||
from textual.app import ScreenStackError
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .gallery import GalleryApp
|
||||
from .paint import PaintApp
|
||||
from textual_paint.gallery import GalleryApp
|
||||
from textual_paint.paint import PaintApp
|
||||
|
||||
def restart_program() -> None:
|
||||
"""Restarts the current program, after resetting terminal state, and cleaning up file objects and descriptors."""
|
||||
|
@ -15,9 +15,9 @@ from textual.strip import Strip
|
||||
from textual.widget import Widget
|
||||
from textual.widgets import Button, Input, Label
|
||||
|
||||
from .args import args
|
||||
from .localization.i18n import get as _
|
||||
from .windows import DialogWindow
|
||||
from textual_paint.args import args
|
||||
from textual_paint.localization.i18n import get as _
|
||||
from textual_paint.windows import DialogWindow
|
||||
|
||||
# https://github.com/kouzhudong/win2k/blob/ce6323f76d5cd7d136b74427dad8f94ee4c389d2/trunk/private/shell/win16/comdlg/color.c#L38-L43
|
||||
# These are a fallback in case colors are not received from some driver.
|
||||
|
@ -10,7 +10,7 @@ from textual.widgets import DirectoryTree, Tree
|
||||
from textual.widgets._directory_tree import DirEntry
|
||||
from textual.widgets._tree import TOGGLE_STYLE, TreeNode
|
||||
|
||||
from .args import args
|
||||
from textual_paint.args import args
|
||||
|
||||
# Vague skeuomorphism
|
||||
# FILE_ICON = Text.from_markup("[#aaaaaa on #ffffff]=[/] " if args.ascii_only else "📄 ")
|
||||
|
@ -8,9 +8,9 @@ from textual.widget import Widget
|
||||
from textual.widgets import Button, Input, Label, Tree
|
||||
from textual.widgets._directory_tree import DirEntry
|
||||
|
||||
from .enhanced_directory_tree import EnhancedDirectoryTree
|
||||
from .localization.i18n import get as _
|
||||
from .windows import DialogWindow
|
||||
from textual_paint.enhanced_directory_tree import EnhancedDirectoryTree
|
||||
from textual_paint.localization.i18n import get as _
|
||||
from textual_paint.windows import DialogWindow
|
||||
|
||||
|
||||
class FileDialogWindow(DialogWindow):
|
||||
|
@ -13,9 +13,9 @@ from textual.containers import Container, ScrollableContainer
|
||||
from textual.reactive import Reactive, var
|
||||
from textual.widgets import Footer, Header, Static
|
||||
|
||||
from .__init__ import __version__
|
||||
from .ansi_art_document import AnsiArtDocument
|
||||
from .auto_restart import restart_on_changes, restart_program
|
||||
from textual_paint.__init__ import __version__
|
||||
from textual_paint.ansi_art_document import AnsiArtDocument
|
||||
from textual_paint.auto_restart import restart_on_changes, restart_program
|
||||
|
||||
parser = argparse.ArgumentParser(description='ANSI art gallery', usage='%(prog)s [path]', prog="python -m src.textual_paint.gallery")
|
||||
parser.add_argument('path', nargs='?', default=None, help='Path to a folder containing ANSI art, or an ANSI file.')
|
||||
@ -98,7 +98,7 @@ class GalleryApp(App[None]):
|
||||
if not args.inspect_layout:
|
||||
return
|
||||
# importing the inspector adds instrumentation which can slow down startup
|
||||
from .inspector import Inspector
|
||||
from textual_paint.inspector import Inspector
|
||||
inspector = Inspector()
|
||||
inspector.display = False
|
||||
yield inspector
|
||||
@ -263,7 +263,7 @@ class GalleryApp(App[None]):
|
||||
if not args.inspect_layout:
|
||||
return
|
||||
# importing the inspector adds instrumentation which can slow down startup
|
||||
from .inspector import Inspector
|
||||
from textual_paint.inspector import Inspector
|
||||
inspector = self.query_one(Inspector)
|
||||
inspector.display = not inspector.display
|
||||
if not inspector.display:
|
||||
|
@ -5,7 +5,7 @@ from typing import TYPE_CHECKING, Iterator
|
||||
from textual.geometry import Offset, Region
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .paint import AnsiArtDocument
|
||||
from textual_paint.paint import AnsiArtDocument
|
||||
|
||||
|
||||
def bresenham_walk(x0: int, y0: int, x1: int, y1: int) -> Iterator[tuple[int, int]]:
|
||||
|
@ -60,7 +60,7 @@ from textual.widgets import (Button, DataTable, Input, Static, TabbedContent,
|
||||
TabPane, Tree)
|
||||
from textual.widgets.tree import TreeNode
|
||||
|
||||
from .launch_editor import launch_editor
|
||||
from textual_paint.launch_editor import launch_editor
|
||||
|
||||
# from textual.css._style_properties import BorderDefinition
|
||||
|
||||
|
@ -11,8 +11,8 @@ from textual.message import Message
|
||||
from textual.reactive import var
|
||||
from textual.widgets import Button, Static
|
||||
|
||||
from .args import args
|
||||
from .localization.i18n import get_direction, get_hotkey, markup_hotkey
|
||||
from textual_paint.args import args
|
||||
from textual_paint.localization.i18n import get_direction, get_hotkey, markup_hotkey
|
||||
|
||||
|
||||
def to_snake_case(name: str) -> str:
|
||||
|
@ -38,26 +38,26 @@ from textual.widgets import (Button, Header, Input, RadioButton, RadioSet,
|
||||
from textual.widgets._header import HeaderIcon
|
||||
from textual.worker import get_current_worker # type: ignore
|
||||
|
||||
from .__init__ import __version__
|
||||
from .ansi_art_document import (SAVE_DISABLED_FORMATS, AnsiArtDocument,
|
||||
from textual_paint.__init__ import __version__
|
||||
from textual_paint.ansi_art_document import (SAVE_DISABLED_FORMATS, AnsiArtDocument,
|
||||
FormatReadNotSupported,
|
||||
FormatWriteNotSupported, Selection)
|
||||
from .args import args, get_help_text
|
||||
from .auto_restart import restart_on_changes, restart_program
|
||||
from .edit_colors import EditColorsDialogWindow
|
||||
from .file_dialogs import OpenDialogWindow, SaveAsDialogWindow
|
||||
from .graphics_primitives import (bezier_curve_walk, bresenham_walk,
|
||||
from textual_paint.args import args, get_help_text
|
||||
from textual_paint.auto_restart import restart_on_changes, restart_program
|
||||
from textual_paint.edit_colors import EditColorsDialogWindow
|
||||
from textual_paint.file_dialogs import OpenDialogWindow, SaveAsDialogWindow
|
||||
from textual_paint.graphics_primitives import (bezier_curve_walk, bresenham_walk,
|
||||
flood_fill, is_inside_polygon,
|
||||
midpoint_ellipse, polygon_walk,
|
||||
polyline_walk, quadratic_curve_walk)
|
||||
from .localization.i18n import get as _
|
||||
from .localization.i18n import load_language, remove_hotkey
|
||||
from .menus import Menu, MenuBar, MenuItem, Separator
|
||||
from .palette_data import DEFAULT_PALETTE, IRC_PALETTE
|
||||
from .rasterize_ansi_art import rasterize
|
||||
from .scrollbars import ASCIIScrollBarRender
|
||||
from .wallpaper import get_config_dir, set_wallpaper
|
||||
from .windows import (CharacterSelectorDialogWindow, DialogWindow, MessageBox,
|
||||
from textual_paint.localization.i18n import get as _
|
||||
from textual_paint.localization.i18n import load_language, remove_hotkey
|
||||
from textual_paint.menus import Menu, MenuBar, MenuItem, Separator
|
||||
from textual_paint.palette_data import DEFAULT_PALETTE, IRC_PALETTE
|
||||
from textual_paint.rasterize_ansi_art import rasterize
|
||||
from textual_paint.scrollbars import ASCIIScrollBarRender
|
||||
from textual_paint.wallpaper import get_config_dir, set_wallpaper
|
||||
from textual_paint.windows import (CharacterSelectorDialogWindow, DialogWindow, MessageBox,
|
||||
Window, get_paint_icon, get_question_icon,
|
||||
get_warning_icon)
|
||||
|
||||
@ -3009,7 +3009,7 @@ Columns: {len(palette) // 2}
|
||||
if not args.inspect_layout:
|
||||
return
|
||||
# importing the inspector adds instrumentation which can slow down startup
|
||||
from .inspector import Inspector
|
||||
from textual_paint.inspector import Inspector
|
||||
inspector = self.query_one(Inspector)
|
||||
inspector.display = not inspector.display
|
||||
if not inspector.display:
|
||||
@ -3108,7 +3108,7 @@ Columns: {len(palette) // 2}
|
||||
if not args.inspect_layout:
|
||||
return
|
||||
# importing the inspector adds instrumentation which can slow down startup
|
||||
from .inspector import Inspector
|
||||
from textual_paint.inspector import Inspector
|
||||
inspector = Inspector()
|
||||
inspector.display = False
|
||||
yield inspector
|
||||
@ -4033,7 +4033,7 @@ Columns: {len(palette) // 2}
|
||||
if args.ascii_only:
|
||||
args.ascii_only_icons = True
|
||||
|
||||
from .ascii_borders import force_ascii_borders
|
||||
from textual_paint.ascii_borders import force_ascii_borders
|
||||
force_ascii_borders()
|
||||
|
||||
RadioButton.BUTTON_INNER = "*" # "*", "o", "O", "@"
|
||||
|
@ -14,8 +14,8 @@ from textual.widget import Widget
|
||||
from textual.widgets import Button, DataTable, Static
|
||||
from typing_extensions import Self
|
||||
|
||||
from .args import args
|
||||
from .localization.i18n import get as _
|
||||
from textual_paint.args import args
|
||||
from textual_paint.localization.i18n import get as _
|
||||
|
||||
|
||||
class WindowTitleBar(Container):
|
||||
|
Loading…
Reference in New Issue
Block a user