Skip to content

Commit

Permalink
Change package name to counterweight (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshKarpel authored Dec 20, 2023
1 parent cdb236c commit ee5bfae
Show file tree
Hide file tree
Showing 50 changed files with 421 additions and 424 deletions.
2 changes: 1 addition & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
branch = True

source =
reprisal/
counterweight/
tests/

[report]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# Reprisal
# Counterweight
4 changes: 2 additions & 2 deletions codegen/generate_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from more_itertools import flatten

from reprisal.styles.styles import BorderEdge, BorderKind, Flex, Typography
from counterweight.styles.styles import BorderEdge, BorderKind, Flex, Typography


def literal_vals(obj: object, field: str) -> tuple[str, ...]:
Expand Down Expand Up @@ -305,7 +305,7 @@ def literal_vals(obj: object, field: str) -> tuple[str, ...]:
},
}

utils_path = Path(__file__).resolve().parent.parent / "reprisal" / "styles" / "utilities.py"
utils_path = Path(__file__).resolve().parent.parent / "counterweight" / "styles" / "utilities.py"

utils_text = utils_path.read_text().splitlines(keepends=False)

Expand Down
File renamed without changes.
3 changes: 3 additions & 0 deletions counterweight/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from counterweight.cli import cli

cli()
4 changes: 2 additions & 2 deletions reprisal/_context_vars.py → counterweight/_context_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from reprisal.events import AnyEvent
from reprisal.hooks.impls import Hooks
from counterweight.events import AnyEvent
from counterweight.hooks.impls import Hooks

current_event_queue: ContextVar[Queue[AnyEvent]] = ContextVar("current_event_queue")
current_hook_idx: ContextVar[int] = ContextVar("current_hook_idx")
Expand Down
File renamed without changes.
32 changes: 16 additions & 16 deletions reprisal/app.py → counterweight/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,29 @@

from structlog import get_logger

from reprisal._context_vars import current_event_queue
from reprisal._utils import drain_queue
from reprisal.cell_paint import CellPaint
from reprisal.components import AnyElement, Component, Div, component
from reprisal.control import Control
from reprisal.events import AnyEvent, KeyPressed, MouseDown, MouseMoved, MouseUp, StateSet, TerminalResized
from reprisal.geometry import Position
from reprisal.hooks.impls import UseEffect
from reprisal.input import read_keys, start_input_control, stop_input_control
from reprisal.layout import build_layout_tree
from reprisal.logging import configure_logging
from reprisal.output import (
from counterweight._context_vars import current_event_queue
from counterweight._utils import drain_queue
from counterweight.cell_paint import CellPaint
from counterweight.components import AnyElement, Component, Div, component
from counterweight.control import Control
from counterweight.events import AnyEvent, KeyPressed, MouseDown, MouseMoved, MouseUp, StateSet, TerminalResized
from counterweight.geometry import Position
from counterweight.hooks.impls import UseEffect
from counterweight.input import read_keys, start_input_control, stop_input_control
from counterweight.layout import build_layout_tree
from counterweight.logging import configure_logging
from counterweight.output import (
CLEAR_SCREEN,
paint_to_instructions,
start_mouse_reporting,
start_output_control,
stop_mouse_reporting,
stop_output_control,
)
from reprisal.paint import Paint, paint_layout
from reprisal.shadow import ShadowNode, update_shadow
from reprisal.styles import Span, Style
from reprisal.styles.styles import CellStyle, Color, Flex
from counterweight.paint import Paint, paint_layout
from counterweight.shadow import ShadowNode, update_shadow
from counterweight.styles import Span, Style
from counterweight.styles.styles import CellStyle, Color, Flex

BLANK = CellPaint(
char=" ",
Expand Down
4 changes: 2 additions & 2 deletions reprisal/cell_paint.py → counterweight/cell_paint.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

from pydantic import Field

from reprisal.styles.styles import CellStyle
from reprisal.types import FrozenForbidExtras
from counterweight.styles.styles import CellStyle
from counterweight.types import FrozenForbidExtras


class CellPaint(FrozenForbidExtras):
Expand Down
12 changes: 6 additions & 6 deletions reprisal/cli.py → counterweight/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
from click import echo
from typer import Option, Typer

from reprisal._context_vars import current_event_queue
from reprisal.constants import PACKAGE_NAME, __version__
from reprisal.events import AnyEvent
from reprisal.input import read_keys, start_input_control, stop_input_control
from reprisal.logging import tail_devlog
from reprisal.output import start_mouse_reporting, stop_mouse_reporting
from counterweight._context_vars import current_event_queue
from counterweight.constants import PACKAGE_NAME, __version__
from counterweight.events import AnyEvent
from counterweight.input import read_keys, start_input_control, stop_input_control
from counterweight.logging import tail_devlog
from counterweight.output import start_mouse_reporting, stop_mouse_reporting

cli = Typer(
name=PACKAGE_NAME,
Expand Down
12 changes: 6 additions & 6 deletions reprisal/components.py → counterweight/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

from pydantic import Field

from reprisal.cell_paint import CellPaint
from reprisal.control import Control
from reprisal.events import KeyPressed, MouseDown, MouseUp
from reprisal.styles import Style
from reprisal.styles.styles import CellStyle
from reprisal.types import FrozenForbidExtras
from counterweight.cell_paint import CellPaint
from counterweight.control import Control
from counterweight.events import KeyPressed, MouseDown, MouseUp
from counterweight.styles import Style
from counterweight.styles.styles import CellStyle
from counterweight.types import FrozenForbidExtras

P = ParamSpec("P")

Expand Down
2 changes: 1 addition & 1 deletion reprisal/constants.py → counterweight/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
import sys
from importlib import metadata

PACKAGE_NAME = "reprisal"
PACKAGE_NAME = "counterweight"
__version__ = metadata.version(PACKAGE_NAME)
__python_version__ = ".".join(map(str, sys.version_info))
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions reprisal/events.py → counterweight/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

from pydantic import Field

from reprisal.geometry import Position
from reprisal.types import FrozenForbidExtras
from counterweight.geometry import Position
from counterweight.types import FrozenForbidExtras


class Timestamped(FrozenForbidExtras):
Expand Down
File renamed without changes.
13 changes: 13 additions & 0 deletions counterweight/hooks/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from counterweight.hooks.hooks import use_effect, use_ref, use_state
from counterweight.hooks.types import Deps, Getter, Ref, Setter, Setup

__all__ = [
"use_state",
"use_ref",
"use_effect",
"Getter",
"Setter",
"Setup",
"Deps",
"Ref",
]
4 changes: 2 additions & 2 deletions reprisal/hooks/hooks.py → counterweight/hooks/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from typing import TypeVar, overload

from reprisal._context_vars import current_hook_state
from reprisal.hooks.types import Deps, Getter, Ref, Setter, Setup
from counterweight._context_vars import current_hook_state
from counterweight.hooks.types import Deps, Getter, Ref, Setter, Setup

T = TypeVar("T")

Expand Down
10 changes: 5 additions & 5 deletions reprisal/hooks/impls.py → counterweight/hooks/impls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

from pydantic import Field

from reprisal._context_vars import current_event_queue, current_hook_idx
from reprisal.errors import InconsistentHookExecution
from reprisal.events import StateSet
from reprisal.hooks.types import Deps, Getter, Ref, Setter, Setup
from reprisal.types import ForbidExtras
from counterweight._context_vars import current_event_queue, current_hook_idx
from counterweight.errors import InconsistentHookExecution
from counterweight.events import StateSet
from counterweight.hooks.types import Deps, Getter, Ref, Setter, Setup
from counterweight.types import ForbidExtras


class UseState(ForbidExtras):
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions reprisal/input.py → counterweight/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
from parsy import ParseError
from structlog import get_logger

from reprisal.events import AnyEvent
from reprisal.keys import vt_inputs
from counterweight.events import AnyEvent
from counterweight.keys import vt_inputs

logger = get_logger()

Expand Down
4 changes: 2 additions & 2 deletions reprisal/keys.py → counterweight/keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from parsy import Parser, any_char, char_from, decimal_digit, generate, string
from structlog import get_logger

from reprisal.events import AnyEvent, KeyPressed, MouseDown, MouseMoved, MouseUp
from reprisal.geometry import Position
from counterweight.events import AnyEvent, KeyPressed, MouseDown, MouseMoved, MouseUp
from counterweight.geometry import Position

logger = get_logger()

Expand Down
12 changes: 6 additions & 6 deletions reprisal/layout.py → counterweight/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
from pydantic import Field, NonNegativeInt
from structlog import get_logger

from reprisal._utils import halve_integer, partition_int
from reprisal.cell_paint import wrap_cells
from reprisal.components import AnyElement, Component
from reprisal.geometry import Position
from reprisal.styles.styles import BorderEdge
from reprisal.types import ForbidExtras
from counterweight._utils import halve_integer, partition_int
from counterweight.cell_paint import wrap_cells
from counterweight.components import AnyElement, Component
from counterweight.geometry import Position
from counterweight.styles.styles import BorderEdge
from counterweight.types import ForbidExtras

logger = get_logger()

Expand Down
2 changes: 1 addition & 1 deletion reprisal/logging.py → counterweight/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import structlog
from structlog import WriteLoggerFactory

from reprisal.constants import PACKAGE_NAME
from counterweight.constants import PACKAGE_NAME

DEVLOG_FILE = Path(gettempdir()) / f"{PACKAGE_NAME}.log"

Expand Down
6 changes: 3 additions & 3 deletions reprisal/output.py → counterweight/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

from structlog import get_logger

from reprisal.geometry import Position
from reprisal.paint import Paint
from reprisal.styles.styles import CellStyle
from counterweight.geometry import Position
from counterweight.paint import Paint
from counterweight.styles.styles import CellStyle

CURSOR_ON = "\x1b[?25h"
CURSOR_OFF = "\x1b[?25l"
Expand Down
14 changes: 7 additions & 7 deletions reprisal/paint.py → counterweight/paint.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

from structlog import get_logger

from reprisal._utils import halve_integer
from reprisal.cell_paint import CellPaint, wrap_cells
from reprisal.components import AnyElement, Div, Text
from reprisal.geometry import Position
from reprisal.layout import BoxDimensions, Edge, LayoutBox, Rect
from reprisal.styles import Border
from reprisal.styles.styles import BorderEdge, CellStyle, Margin, Padding
from counterweight._utils import halve_integer
from counterweight.cell_paint import CellPaint, wrap_cells
from counterweight.components import AnyElement, Div, Text
from counterweight.geometry import Position
from counterweight.layout import BoxDimensions, Edge, LayoutBox, Rect
from counterweight.styles import Border
from counterweight.styles.styles import BorderEdge, CellStyle, Margin, Padding

logger = get_logger()

Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions reprisal/shadow.py → counterweight/shadow.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
from pydantic import Field
from structlog import get_logger

from reprisal._context_vars import current_hook_idx, current_hook_state
from reprisal.components import AnyElement, Component
from reprisal.hooks.impls import Hooks
from reprisal.types import FrozenForbidExtras
from counterweight._context_vars import current_hook_idx, current_hook_state
from counterweight.components import AnyElement, Component
from counterweight.hooks.impls import Hooks
from counterweight.types import FrozenForbidExtras

logger = get_logger()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from reprisal.styles.styles import Border, BorderKind, Margin, Padding, Span, Style
from counterweight.styles.styles import Border, BorderKind, Margin, Padding, Span, Style

__all__ = [
"Style",
Expand Down
4 changes: 2 additions & 2 deletions reprisal/styles/styles.py → counterweight/styles/styles.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from cachetools import LRUCache
from pydantic import Field, NonNegativeInt, PositiveInt

from reprisal._utils import merge
from reprisal.types import FrozenForbidExtras
from counterweight._utils import merge
from counterweight.types import FrozenForbidExtras

if TYPE_CHECKING:
pass
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from reprisal.styles import Margin, Style
from reprisal.styles.styles import Border, BorderEdge, BorderKind, CellStyle, Color, Flex, Padding, Typography
from counterweight.styles import Margin, Style
from counterweight.styles.styles import Border, BorderEdge, BorderKind, CellStyle, Color, Flex, Padding, Typography

# Start generated

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# Reprisal
# Counterweight
10 changes: 5 additions & 5 deletions examples/borders.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
from more_itertools import flatten
from structlog import get_logger

from reprisal.app import app
from reprisal.components import Div, Text, component
from reprisal.events import KeyPressed
from reprisal.hooks import use_ref, use_state
from reprisal.styles.utilities import *
from counterweight.app import app
from counterweight.components import Div, Text, component
from counterweight.events import KeyPressed
from counterweight.hooks import use_ref, use_state
from counterweight.styles.utilities import *

logger = get_logger()

Expand Down
12 changes: 6 additions & 6 deletions examples/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
from more_itertools import grouper
from structlog import get_logger

from reprisal.app import app
from reprisal.cell_paint import CellPaint
from reprisal.components import Chunk, Div, Text, component
from reprisal.hooks import use_effect, use_state
from reprisal.styles.styles import COLORS_BY_NAME
from reprisal.styles.utilities import *
from counterweight.app import app
from counterweight.cell_paint import CellPaint
from counterweight.components import Chunk, Div, Text, component
from counterweight.hooks import use_effect, use_state
from counterweight.styles.styles import COLORS_BY_NAME
from counterweight.styles.utilities import *

logger = get_logger()

Expand Down
16 changes: 8 additions & 8 deletions examples/end_to_end.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

from structlog import get_logger

from reprisal.app import app
from reprisal.components import Div, Text, component
from reprisal.events import KeyPressed
from reprisal.hooks import Setter, use_effect, use_ref, use_state
from reprisal.keys import Key
from reprisal.styles import Border, BorderKind, Style
from reprisal.styles.styles import Flex, Padding
from reprisal.styles.utilities import (
from counterweight.app import app
from counterweight.components import Div, Text, component
from counterweight.events import KeyPressed
from counterweight.hooks import Setter, use_effect, use_ref, use_state
from counterweight.keys import Key
from counterweight.styles import Border, BorderKind, Style
from counterweight.styles.styles import Flex, Padding
from counterweight.styles.utilities import (
border_amber_700,
border_lime_700,
border_rose_500,
Expand Down
Loading

0 comments on commit ee5bfae

Please sign in to comment.