Skip to content

Commit e138a49

Browse files
1.19.1
1 parent e958b21 commit e138a49

35 files changed

+248
-71
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ isort: .build_history/isort
4747

4848
.build_history/black: .build_history .build_history/isort $(FILES)
4949
@echo "Formatting code"
50+
$(VENV) metametameta poetry
5051
$(VENV) black dedlin --exclude .venv
5152
$(VENV) black tests --exclude .venv
5253
$(VENV) black scripts --exclude .venv

dedlin/__about__.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
"""Metadata for dedlin."""
2+
3+
__all__ = [
4+
"__title__",
5+
"__version__",
6+
"__description__",
7+
"__author__",
8+
"__author_email__",
9+
"__keywords__",
10+
"__status__",
11+
"__license__",
12+
"__readme__",
13+
"__repository__",
14+
"__homepage__",
15+
"__documentation__"
16+
]
17+
18+
__title__ = "dedlin"
19+
__version__ = "1.19.0"
20+
__description__ = "Line editor, edlin clone with many improvements"
21+
__author__ = "Matthew Martin"
22+
__author_email__ = "matthewdeanmartin@gmail.com"
23+
__keywords__ = ['editor', 'edlin', 'line editor']
24+
__status__ = "5 - Production/Stable"
25+
__license__ = "MIT"
26+
__readme__ = "README.md"
27+
__repository__ = "https://github.com/matthewdeanmartin/dedlin"
28+
__homepage__ = "https://github.com/matthewdeanmartin/dedlin"
29+
__documentation__ = "https://github.com/matthewdeanmartin/dedlin"

dedlin/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Dedlin is an edlin clone with additional features. Possibly useful as a sed-like DSL or as an editor
33
for AI function calls.
44
"""
5+
56
from dedlin.command_sources import (
67
CommandGenerator,
78
InteractiveGenerator,

dedlin/__main__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
--verbose Displaying all debugging info.
1919
--blind_mode Optimize for blind users (experimental).
2020
"""
21+
2122
import logging
2223
import logging.config
2324
import sys
@@ -35,6 +36,7 @@
3536
from dedlin.main import Dedlin
3637
from dedlin.outputters import rich_output, talking_outputter
3738
from dedlin.outputters.plain import plain_printer
39+
from __about__ import __version__
3840

3941
dotenv.load_dotenv()
4042

@@ -43,7 +45,7 @@
4345

4446
def main() -> None:
4547
"""Main function."""
46-
arguments = docopt(__doc__, version="1.4.0")
48+
arguments = docopt(__doc__, version=__version__)
4749

4850
_ = run(
4951
arguments["<file>"],

dedlin/ai_interface.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Code for AI
33
"""
4+
45
import asyncio
56

67
import dotenv
@@ -24,7 +25,7 @@
2425
class AiClient:
2526
"""Client for AI"""
2627

27-
def __init__(self)->None:
28+
def __init__(self) -> None:
2829
"""Initialize the client"""
2930
self.client = AsyncOpenAI()
3031
self.model = "gpt-3.5-turbo"

dedlin/basic_types.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
"""
22
Basic classes and mypy types
33
"""
4+
45
import dataclasses
56
import logging
67
from enum import Enum, auto
78
from typing import Generator, Optional, Protocol, runtime_checkable
89

9-
from pydantic import validator
10+
from pydantic import field_validator
1011
from pydantic.dataclasses import dataclass
1112

1213
logger = logging.getLogger(__name__)
@@ -99,7 +100,8 @@ class LineRange:
99100
repeat: int = 1
100101

101102
# problem when doc is 0 lines long
102-
@validator("start", allow_reuse=True)
103+
@field_validator("start")
104+
@classmethod
103105
@classmethod
104106
def start_must_be_one_or_more(cls, start: int) -> int:
105107
"""Start must be 1 or more
@@ -112,7 +114,8 @@ def start_must_be_one_or_more(cls, start: int) -> int:
112114
raise ValueError("start must be one or more")
113115
return start
114116

115-
@validator("offset", allow_reuse=True)
117+
@field_validator("offset")
118+
@classmethod
116119
@classmethod
117120
def offset_zero_or_more(cls, offset: int) -> int:
118121
"""Offset must be zero or more
@@ -125,7 +128,8 @@ def offset_zero_or_more(cls, offset: int) -> int:
125128
return offset
126129

127130
@classmethod
128-
@validator("repeat", allow_reuse=True)
131+
@field_validator("repeat")
132+
@classmethod
129133
def repeat_zero_or_more(cls, repeat: int) -> int:
130134
"""Repeat must be zero or more
131135
@@ -167,7 +171,7 @@ def validate(self) -> bool:
167171
logger.warning(f"Invalid line range: {self}")
168172
return validate
169173

170-
def to_slice(self)->slice:
174+
def to_slice(self) -> slice:
171175
"""Convert to a slice
172176
173177
Returns:
@@ -461,4 +465,3 @@ def generate(
461465
Returns:
462466
Generator[str, None, None]: The strings
463467
"""
464-

dedlin/command_sources.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
44
These handle history, syntax highlighting, and auto-suggestion.
55
"""
6+
67
from pathlib import Path
78
from typing import Generator, Iterable, Optional
89

@@ -101,7 +102,7 @@ def questionary_command_handler(prompt: str = "*") -> Generator[str, None, None]
101102

102103

103104
class CommandGeneratorProtocol:
104-
def __init__(self, path: Path)->None:
105+
def __init__(self, path: Path) -> None:
105106
"""Initialize the generator.
106107
107108
Args:
@@ -125,7 +126,7 @@ def generate(
125126
class CommandGenerator:
126127
"""Get a typed command from a file"""
127128

128-
def __init__(self, path: Path)->None:
129+
def __init__(self, path: Path) -> None:
129130
"""Initialize the generator.
130131
131132
Args:
@@ -160,7 +161,7 @@ def generate(
160161
class InMemoryCommandGenerator:
161162
"""A bunch of predefined commands"""
162163

163-
def __init__(self, commands: Iterable[Command])->None:
164+
def __init__(self, commands: Iterable[Command]) -> None:
164165
"""Initialize the generator.
165166
166167
Args:
@@ -183,7 +184,7 @@ def generate(
183184
class StringCommandGenerator:
184185
"""Get a typed command from a string"""
185186

186-
def __init__(self, source: str)->None:
187+
def __init__(self, source: str) -> None:
187188
"""Initialize the generator.
188189
189190
Args:

dedlin/document.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Abstract document class.
33
"""
4+
45
import logging
56
import random
67
from typing import Generator, Optional
@@ -27,7 +28,7 @@ class EditStatus:
2728

2829
# noinspection PyShadowingBuiltins
2930
# pylint: disable=redefined-builtin
30-
def print(*args, **kwargs)->None:
31+
def print(*args, **kwargs) -> None:
3132
"""Discourage accidental usage of print.
3233
3334
Args:
@@ -237,7 +238,7 @@ def copy(self, line_range: Optional[LineRange], target_line: int) -> None:
237238
self.current_line = target_line
238239
logger.debug(f"Copied {line_range} to {target_line}")
239240

240-
def move(self, line_range: Optional[LineRange], target_line: int)->None:
241+
def move(self, line_range: Optional[LineRange], target_line: int) -> None:
241242
"""Move lines to target_line.
242243
243244
Args:

dedlin/file_converters.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Primative printing support"""
2+
23
from pathlib import Path
34

45
from markdown_it import MarkdownIt

dedlin/file_system.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
44
This could be document lines or macro lines.
55
"""
6+
67
from pathlib import Path
78
from typing import Optional
89

dedlin/flash.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Flashy stuff
33
"""
4+
45
from art import tprint
56

67

dedlin/history_feature.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Manage history on file system
33
"""
4+
45
from pathlib import Path
56
from typing import Optional
67

dedlin/logging_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Dedupe some logging code
33
"""
4+
45
from typing import Any
56

67

dedlin/main.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
66
77
"""
8+
89
import asyncio
910
import logging
1011
import os
@@ -425,7 +426,7 @@ def print_ai_help(self, command: Command) -> None:
425426
ask = ChatCompletionMessageParam(content=content, role="user")
426427
asyncio.run(client.completion([ask]))
427428

428-
def feedback(self, string: str, end:str="\n", no_comment: bool = False) -> None:
429+
def feedback(self, string: str, end: str = "\n", no_comment: bool = False) -> None:
429430
"""Output feedback to the user.
430431
431432
Args:
@@ -445,7 +446,7 @@ def feedback(self, string: str, end:str="\n", no_comment: bool = False) -> None:
445446
if self.verbose:
446447
logger.info(string)
447448

448-
def echo_if_needed(self, string:str, end:str="\n") -> None:
449+
def echo_if_needed(self, string: str, end: str = "\n") -> None:
449450
"""Echos a string to the outputter if needed.
450451
451452
Args:
@@ -498,7 +499,7 @@ def save_document(self, phrases: Optional[Phrases] = None) -> None:
498499
file_system.save_and_overwrite(self.file_path, self.doc.lines, self.preferred_line_break)
499500
self.doc.dirty = False
500501

501-
def save_macro(self)->None:
502+
def save_macro(self) -> None:
502503
"""Save the document to the file"""
503504

504505
file_system.save_and_overwrite(

dedlin/outputters/plain.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Abstraction over print-to-standard-out.
33
"""
4+
45
from typing import Optional
56

67

dedlin/outputters/rich_output.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Make the output of the program more readable."""
2+
23
from typing import Optional
34

45
from rich.console import Console

dedlin/outputters/talking_outputter.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Make text editor hypothetically usable while blind."""
2+
23
import logging
34
from typing import Optional
45

dedlin/parsers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Code that turns strings to command objects
33
"""
4+
45
import logging
56
from typing import Iterable, Optional
67

dedlin/pygments_code.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Attempt to make basic syntax highlighting work for the dedlin DSL.
33
"""
4+
45
from pygments.lexer import RegexLexer
56
from pygments.token import Comment, Keyword, Text
67

dedlin/string_comands.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Pass string commands to python."""
2+
23
import textwrap
34

45
from dedlin.basic_types import Command, Commands
@@ -28,7 +29,7 @@ def block_commands(lines: list[str], command: Command) -> list[str]:
2829
return block.split("\n")
2930

3031

31-
def process_strings(lines: list[str], command: Command)->None:
32+
def process_strings(lines: list[str], command: Command) -> None:
3233
"""Apply string function to each line.
3334
3435
Args:

dedlin/text/help_text.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,12 @@
109109
"""
110110

111111
if __name__ == "__main__":
112+
112113
def run() -> None:
113114
"""Example"""
114115
print(HELP_TEXT)
115116
for key, value in SPECIFIC_HELP.items():
116117
print(f"\n{key} commands\n")
117118
print(value)
118-
run()
119+
120+
run()

dedlin/tools/export.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Export to file formats, particularly markdown
33
"""
4+
45
import mistune
56

67

dedlin/tools/info_bar.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
An info bar that runs after each command, replaces bottom bar in a full screen editor
33
"""
4+
45
from typing import Generator
56

67
from textstat import textstat

dedlin/tools/spelling_overlay.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Create overlay of spelling markers
33
"""
4+
45
from spellchecker import SpellChecker
56

67
spell = SpellChecker()

dedlin/tools/web.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Fetch lines from web, assuming html, turn into text
33
"""
4+
45
import html2text
56
import requests
67

dedlin/utils/file_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
File and path manipulation
33
"""
4+
45
import os
56

67

log.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)