diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b8c5849..5933a90 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,10 +11,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Set up Python 3.9 + - name: Set up Python 3.8 uses: actions/setup-python@v2 with: - python-version: 3.9 + python-version: 3.8 - name: Install dependencies run: | python -m pip install --upgrade pip diff --git a/README.md b/README.md index 4379dee..b72fb50 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ Rendering: Installation ------------ -Requirements: Python 3.9. +Requirements: Python 3.8. ```bash pip install . diff --git a/doc/readme.moi b/doc/readme.moi index 7a17e72..6e040a8 100755 --- a/doc/readme.moi +++ b/doc/readme.moi @@ -67,7 +67,7 @@ Rendering\: \2 {Installation} {installation} -Requirements: Python 3.9. +Requirements: Python 3.8. \code {bash} {pip install .} diff --git a/moire/default.py b/moire/default.py index cb50538..e451db1 100644 --- a/moire/default.py +++ b/moire/default.py @@ -1,6 +1,6 @@ import sys from argparse import ArgumentParser, Namespace -from typing import Any, Dict, List, Set +from typing import Any, Dict, List, Set, Tuple from textwrap import dedent from moire.moire import Moire @@ -71,7 +71,7 @@ def m(self, arg: Arguments) -> str: def formal(self, arg: Arguments) -> str: raise TagNotImplementedError("formal") - def _parse_code_arguments(self, arg: Arguments) -> tuple[str, str]: + def _parse_code_arguments(self, arg: Arguments) -> Tuple[str, str]: """Parse trimmed code and possible language identifier.""" if len(arg) == 1: return self.trim(self.parse(arg[0], spec={"trim": False})), "" diff --git a/moire/main.py b/moire/main.py index c17a38b..244c698 100755 --- a/moire/main.py +++ b/moire/main.py @@ -5,9 +5,9 @@ import logging import sys -from argparse import ArgumentParser, BooleanOptionalAction, Namespace +from argparse import ArgumentParser, Namespace from pathlib import Path -from typing import Optional +from typing import List, Optional from moire.default import Default from moire.moire import Moire @@ -16,8 +16,7 @@ __email__ = "me@enzet.ru" -def main(arguments: list[str] = None, top_class=None): - +def main(arguments: List[str] = None, top_class=None): if not arguments: arguments = sys.argv[1:] if not top_class: @@ -30,7 +29,7 @@ def main(arguments: list[str] = None, top_class=None): parser.add_argument("-i", "--input", help="Moire input file", required=True) parser.add_argument("-o", "--output", help="output file") parser.add_argument("-f", "--format", help="output format", required=True) - parser.add_argument("--wrap", action=BooleanOptionalAction, default=True) + parser.add_argument("--wrap", action="store_true", default=True) options: Namespace = parser.parse_args(arguments) diff --git a/moire/moire.py b/moire/moire.py index 5d26b52..b14f737 100644 --- a/moire/moire.py +++ b/moire/moire.py @@ -9,7 +9,7 @@ from dataclasses import dataclass from io import StringIO -from typing import Any, Callable, Optional +from typing import Any, Callable, Dict, List, Optional, Tuple __author__: str = "Sergey Vartanov" __email__: str = "me@enzet.ru" @@ -103,8 +103,8 @@ def find(self, text: str) -> Optional["Tree"]: @dataclass class Argument: - array: list - spec: dict[str, Any] + array: List + spec: Dict[str, Any] def __getitem__(self, key: int): return self.array[key] @@ -152,13 +152,13 @@ def is_letter_or_digit(char: str) -> bool: return "a" <= char <= "z" or "A" <= char <= "Z" or "0" <= char <= "9" -def lexer(text) -> (list[Lexeme], list[int]): +def lexer(text) -> (List[Lexeme], List[int]): """Parse formatted preprocessed text to a list of lexemes.""" in_tag: bool = False # Lexer position in tag name # Lexer position in space between tag name and first "{" in_space: bool = True - lexemes: list[Lexeme] = [] - positions: list[int] = [] + lexemes: List[Lexeme] = [] + positions: List[int] = [] tag_name: str = "" word: str = "" @@ -270,12 +270,12 @@ def get_intermediate(lexemes, positions, level, index=0): class Moire: name: str = "Empty format" - block_tags: list[str] = [] - escape_symbols: dict[str, str] = {} + block_tags: List[str] = [] + escape_symbols: Dict[str, str] = {} def __init__(self, file_name: Optional[str] = None): self.index: int = 0 - self.status: dict[str, Any] = {"missing_tags": set()} + self.status: Dict[str, Any] = {"missing_tags": set()} self.file_name: Optional[str] = file_name def init(self): @@ -298,13 +298,13 @@ def trim(self, text: str) -> str: text = text[:-1] return text - def get_ids(self, content: str) -> list[tuple[str, int]]: + def get_ids(self, content: str) -> List[Tuple[str, int]]: """Get all header identifiers. :param content: input content in the Moire format :return: list of tuples (id, level), level is 0 for labels """ - ids: list[tuple[str, int]] = [] + ids: List[Tuple[str, int]] = [] intermediate_representation = self.get_ir(content) for element in intermediate_representation: if isinstance(element, Tag): @@ -315,7 +315,7 @@ def get_ids(self, content: str) -> list[tuple[str, int]]: return ids def convert( - self, input_data: str, wrap: bool = True, in_block: bool = True + self, input_data: str, wrap: bool = True, in_block: bool = False ) -> str: """Convert Moire text without includes but with comments artifacts to selected format. @@ -361,7 +361,7 @@ def parse( in_block: bool = False, depth: int = 0, mode: str = "", - spec: Optional[dict[str, Any]] = None, + spec: Optional[Dict[str, Any]] = None, ) -> str: """Element parsing into formatted text. diff --git a/setup.py b/setup.py index 2247401..9c6bdd2 100644 --- a/setup.py +++ b/setup.py @@ -9,6 +9,7 @@ author="Sergey Vartanov", author_email="me@enzet.ru", description="Simple extendable markup", + python_requires=">=3.8", entry_points={ "console_scripts": ["moire=moire.main:main"], },