mirror of
https://github.com/1j01/textual-paint.git
synced 2024-09-11 15:56:03 +03:00
Auto-organize imports
I don't really like the style of wrapping to different points depending on where the opening parenthesis is, especially when it wraps for just one item, and these changes may remove some semantic grouping or ordering (i.e. by importance), but I don't think I put THAT much thought into it, and I think I can accept some lack of control, to freely use the Organize Imports command in VS Code, which does nicely automate grouping imports of different types.
This commit is contained in:
parent
179cceed57
commit
769ccee30e
@ -10,9 +10,12 @@ __license__ = "MIT"
|
||||
|
||||
# Set version string when in a git repository
|
||||
# to distinguish production from development versions.
|
||||
from os.path import exists, dirname
|
||||
|
||||
from os.path import dirname, exists
|
||||
from subprocess import check_output
|
||||
|
||||
DEVELOPMENT = exists(dirname(__file__) + "/../../.git")
|
||||
"""Whether running from a Git repository."""
|
||||
|
||||
if DEVELOPMENT:
|
||||
__version__ = "development " + check_output(["git", "describe", "--tags"], cwd=dirname(__file__)).strip().decode()
|
||||
|
@ -4,7 +4,7 @@ import argparse
|
||||
import os
|
||||
import re
|
||||
|
||||
from .__init__ import __version__, DEVELOPMENT
|
||||
from .__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__}')
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
from textual._border import BORDER_CHARS, BORDER_LOCATIONS
|
||||
|
||||
|
||||
def force_ascii_borders() -> None:
|
||||
"""Force all borders to use ASCII characters."""
|
||||
|
||||
|
@ -2,14 +2,15 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
import os
|
||||
import sys
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from textual.app import ScreenStackError
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .paint import PaintApp
|
||||
from .gallery import GalleryApp
|
||||
from .paint import PaintApp
|
||||
|
||||
def restart_program() -> None:
|
||||
"""Restarts the current program, after resetting terminal state, and cleaning up file objects and descriptors."""
|
||||
@ -62,7 +63,8 @@ def restart_program() -> None:
|
||||
def restart_on_changes(app: PaintApp|GalleryApp) -> None:
|
||||
"""Restarts the current program when a file is changed"""
|
||||
|
||||
from watchdog.events import PatternMatchingEventHandler, FileSystemEvent, EVENT_TYPE_CLOSED, EVENT_TYPE_OPENED
|
||||
from watchdog.events import (EVENT_TYPE_CLOSED, EVENT_TYPE_OPENED,
|
||||
FileSystemEvent, PatternMatchingEventHandler)
|
||||
from watchdog.observers import Observer
|
||||
|
||||
class RestartHandler(PatternMatchingEventHandler):
|
||||
|
@ -3,21 +3,19 @@ from typing import Any, Callable
|
||||
from rich.segment import Segment
|
||||
from rich.style import Style
|
||||
from textual import events
|
||||
from textual.color import Color as Color
|
||||
from textual.containers import Container, Horizontal, Vertical
|
||||
from textual.css.query import NoMatches
|
||||
from textual.geometry import Offset
|
||||
from textual.message import Message
|
||||
from textual.reactive import reactive, var
|
||||
from textual.strip import Strip
|
||||
from textual.color import Color as Color
|
||||
from textual.widget import Widget
|
||||
from textual.widgets import Button, Input, Label
|
||||
from textual.containers import Container
|
||||
|
||||
from .args import args
|
||||
from .localization.i18n import get as _
|
||||
from .windows import DialogWindow
|
||||
from .args import args
|
||||
|
||||
|
||||
# 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.
|
||||
|
@ -1,12 +1,12 @@
|
||||
from pathlib import Path
|
||||
from typing import Callable, Iterable
|
||||
from rich.style import Style
|
||||
|
||||
from rich.style import Style
|
||||
from rich.text import Text, TextType
|
||||
from textual.reactive import var
|
||||
from textual.widgets import DirectoryTree, Tree
|
||||
from textual.widgets._tree import TreeNode, TOGGLE_STYLE
|
||||
from textual.widgets._directory_tree import DirEntry
|
||||
from textual.widgets._tree import TOGGLE_STYLE, TreeNode
|
||||
|
||||
from .args import args
|
||||
|
||||
|
@ -27,6 +27,7 @@ SOFTWARE.
|
||||
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class FIGletFontWriter:
|
||||
"""Used to write FIGlet fonts.
|
||||
|
||||
|
@ -1,16 +1,15 @@
|
||||
import os
|
||||
from typing import Any, Callable
|
||||
|
||||
from textual.containers import Container
|
||||
from textual.containers import Container, Horizontal
|
||||
from textual.widget import Widget
|
||||
from textual.widgets import Button, Input, Tree, Label
|
||||
from textual.containers import Horizontal
|
||||
from textual.widgets import Button, Input, Label, Tree
|
||||
from textual.widgets._directory_tree import DirEntry
|
||||
from textual.containers import Container
|
||||
|
||||
from .enhanced_directory_tree import EnhancedDirectoryTree
|
||||
from .localization.i18n import get as _
|
||||
from .windows import DialogWindow
|
||||
from .enhanced_directory_tree import EnhancedDirectoryTree
|
||||
|
||||
|
||||
class FileDialogWindow(DialogWindow):
|
||||
"""A dialog window that lets the user select a file."""
|
||||
|
@ -12,8 +12,8 @@ from textual.containers import HorizontalScroll, ScrollableContainer
|
||||
from textual.widgets import Footer, Header, Static
|
||||
|
||||
from .__init__ import __version__
|
||||
from .auto_restart import restart_on_changes, restart_program
|
||||
from .ansi_art_document import AnsiArtDocument
|
||||
from .auto_restart import restart_on_changes, restart_program
|
||||
|
||||
parser = argparse.ArgumentParser(description='ANSI art gallery', usage='%(prog)s [folder]', prog="python -m src.textual_paint.gallery")
|
||||
parser.add_argument('folder', nargs='?', default=None, help='Path to a folder containing ANSI art.')
|
||||
|
@ -31,13 +31,14 @@ SOFTWARE.
|
||||
import asyncio
|
||||
import inspect
|
||||
import os
|
||||
from typing import Any, Iterable, Literal, NamedTuple, Optional, Type, TypeGuard
|
||||
from typing import (Any, Iterable, Literal, NamedTuple, Optional, Type,
|
||||
TypeGuard)
|
||||
|
||||
from rich.highlighter import ReprHighlighter
|
||||
from rich.markup import escape
|
||||
from rich.segment import Segment
|
||||
from rich.style import Style
|
||||
from rich.text import Text
|
||||
from rich.highlighter import ReprHighlighter
|
||||
from textual import events
|
||||
from textual.app import ComposeResult
|
||||
from textual.color import Color, ColorParseError
|
||||
@ -55,12 +56,15 @@ from textual.message import Message
|
||||
from textual.reactive import var
|
||||
from textual.strip import Strip
|
||||
from textual.widget import Widget
|
||||
from textual.widgets import Button, DataTable, Input, Static, TabPane, TabbedContent, Tree
|
||||
from textual.widgets import (Button, DataTable, Input, Static, TabbedContent,
|
||||
TabPane, Tree)
|
||||
from textual.widgets.tree import TreeNode
|
||||
# from textual.css._style_properties import BorderDefinition
|
||||
|
||||
from .launch_editor import launch_editor
|
||||
|
||||
# from textual.css._style_properties import BorderDefinition
|
||||
|
||||
|
||||
# Instrument style setting in order to link to the source code where inline styles are set.
|
||||
# TODO: make optional for performance
|
||||
inline_style_call_stacks: dict[DOMNode, dict[str, list[inspect.FrameInfo]]] = {}
|
||||
@ -367,9 +371,9 @@ class PropertiesTree(Tree[object]):
|
||||
@property
|
||||
def AAA_deal_with_it(self) -> dict[str, Any]:
|
||||
"""This property gives a grab bag of different types to test the tree."""
|
||||
import traceback
|
||||
from enum import Enum
|
||||
from typing import NamedTuple
|
||||
import traceback
|
||||
return {
|
||||
"a_string": "DEAL WITH IT 😎",
|
||||
"an_int": 42,
|
||||
|
@ -13,10 +13,10 @@ Ported to Python using ChatGPT.
|
||||
"""
|
||||
|
||||
import os
|
||||
import shlex
|
||||
import subprocess
|
||||
import platform
|
||||
import re
|
||||
import shlex
|
||||
import subprocess
|
||||
import sys
|
||||
from typing import Any, TypeGuard
|
||||
|
||||
|
@ -1,16 +1,17 @@
|
||||
import re
|
||||
from typing import Any, Callable
|
||||
|
||||
from rich.text import Text
|
||||
from textual import events
|
||||
from textual.containers import Container
|
||||
from textual.dom import NoScreen
|
||||
from textual.message import Message
|
||||
from textual.reactive import var
|
||||
from textual.widgets import Button, Static
|
||||
from textual.message import Message
|
||||
from textual.dom import NoScreen
|
||||
from rich.text import Text
|
||||
|
||||
from .localization.i18n import markup_hotkey, get_hotkey, get_direction
|
||||
from .args import args
|
||||
from .localization.i18n import get_direction, get_hotkey, markup_hotkey
|
||||
|
||||
|
||||
def to_snake_case(name: str) -> str:
|
||||
name = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name)
|
||||
|
@ -2,65 +2,64 @@
|
||||
|
||||
"""Textual Paint is a detailed MS Paint clone that runs in the terminal."""
|
||||
|
||||
import asyncio
|
||||
import math
|
||||
import os
|
||||
from pathlib import Path
|
||||
import re
|
||||
import shlex
|
||||
import asyncio
|
||||
from enum import Enum
|
||||
from random import random
|
||||
import sys
|
||||
from typing import Any, Coroutine, Optional, Callable, Iterator
|
||||
from enum import Enum
|
||||
from pathlib import Path
|
||||
from random import random
|
||||
from typing import Any, Callable, Coroutine, Iterator, Optional
|
||||
from uuid import uuid4
|
||||
|
||||
from PIL import Image, UnidentifiedImageError
|
||||
from pyfiglet import Figlet, FigletFont # type: ignore
|
||||
from rich.segment import Segment
|
||||
from rich.style import Style
|
||||
from rich.text import Text
|
||||
from textual import events, on, work
|
||||
from textual.filter import LineFilter
|
||||
from textual.message import Message
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.containers import Container, Vertical, Horizontal
|
||||
from textual.geometry import Offset, Region, Size
|
||||
from textual.css._style_properties import BorderDefinition
|
||||
from textual.reactive import var, reactive
|
||||
from textual.scrollbar import ScrollBar
|
||||
from textual.strip import Strip
|
||||
from textual.dom import DOMNode
|
||||
from textual.widget import Widget
|
||||
from textual.widgets import Button, Static, Input, Header, RadioSet, RadioButton
|
||||
from textual.widgets._header import HeaderIcon
|
||||
from textual.binding import Binding
|
||||
from textual.color import Color
|
||||
from PIL import Image, UnidentifiedImageError
|
||||
from textual.containers import Container, Horizontal, Vertical
|
||||
from textual.css._style_properties import BorderDefinition
|
||||
from textual.dom import DOMNode
|
||||
from textual.filter import LineFilter
|
||||
from textual.geometry import Offset, Region, Size
|
||||
from textual.message import Message
|
||||
from textual.reactive import reactive, var
|
||||
from textual.scrollbar import ScrollBar
|
||||
from textual.strip import Strip
|
||||
from textual.widget import Widget
|
||||
from textual.widgets import (Button, Header, Input, RadioButton, RadioSet,
|
||||
Static)
|
||||
from textual.widgets._header import HeaderIcon
|
||||
from textual.worker import get_current_worker # type: ignore
|
||||
from pyfiglet import Figlet, FigletFont # type: ignore
|
||||
|
||||
from .palette_data import DEFAULT_PALETTE, IRC_PALETTE
|
||||
from .ansi_art_document import AnsiArtDocument, FormatReadNotSupported, FormatWriteNotSupported, Selection, SAVE_DISABLED_FORMATS
|
||||
from .graphics_primitives import (
|
||||
bresenham_walk,
|
||||
polygon_walk,
|
||||
polyline_walk,
|
||||
is_inside_polygon,
|
||||
bezier_curve_walk,
|
||||
quadratic_curve_walk,
|
||||
midpoint_ellipse,
|
||||
flood_fill,
|
||||
)
|
||||
from .menus import MenuBar, Menu, MenuItem, Separator
|
||||
from .windows import Window, DialogWindow, CharacterSelectorDialogWindow, MessageBox, get_warning_icon, get_question_icon, get_paint_icon
|
||||
from .scrollbars import ASCIIScrollBarRender
|
||||
from .file_dialogs import SaveAsDialogWindow, OpenDialogWindow
|
||||
from .edit_colors import EditColorsDialogWindow
|
||||
from .localization.i18n import get as _, load_language, remove_hotkey
|
||||
from .rasterize_ansi_art import rasterize
|
||||
from .wallpaper import get_config_dir, set_wallpaper
|
||||
from .auto_restart import restart_on_changes, restart_program
|
||||
from .args import args, get_help_text
|
||||
|
||||
from .__init__ import __version__
|
||||
from .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,
|
||||
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,
|
||||
Window, get_paint_icon, get_question_icon,
|
||||
get_warning_icon)
|
||||
|
||||
MAX_FILE_SIZE = 500000 # 500 KB
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
|
||||
from math import ceil, floor
|
||||
|
||||
from rich.color import Color
|
||||
from rich.segment import Segment, Segments
|
||||
from rich.style import Style
|
||||
|
@ -1,7 +1,8 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def get_desktop_environment() -> str:
|
||||
"""
|
||||
|
@ -1,20 +1,20 @@
|
||||
from typing import Any, Callable
|
||||
from typing_extensions import Self
|
||||
from typing import Any, Callable, ClassVar
|
||||
|
||||
from textual import events, on
|
||||
from textual.dom import DOMNode, NoScreen
|
||||
from textual.message import Message
|
||||
from textual.app import ComposeResult
|
||||
from textual.containers import Container
|
||||
from textual.geometry import Offset
|
||||
from textual.reactive import var
|
||||
from textual.widget import Widget
|
||||
from textual.widgets import Button, Static, DataTable
|
||||
from textual.containers import Container, Horizontal, Vertical
|
||||
from textual.css.query import NoMatches
|
||||
from textual.dom import DOMNode, NoScreen
|
||||
from textual.geometry import Offset
|
||||
from textual.message import Message
|
||||
from textual.reactive import var
|
||||
from textual.widget import Widget
|
||||
from textual.widgets import Button, DataTable, Static
|
||||
from typing_extensions import Self
|
||||
|
||||
from .localization.i18n import get as _
|
||||
from .args import args
|
||||
from .localization.i18n import get as _
|
||||
|
||||
|
||||
class WindowTitleBar(Container):
|
||||
"""A title bar widget."""
|
||||
|
Loading…
Reference in New Issue
Block a user