Compare commits
No commits in common. "05718e1001ca9e0dee45aae3e9ed9df34728e7c3" and "991781a249617a99fd2aff4f33003f9ba1e1821b" have entirely different histories.
05718e1001
...
991781a249
@ -23,26 +23,6 @@ jobs:
|
|||||||
- run: pip install mypy
|
- run: pip install mypy
|
||||||
- run: mypy org_rw --check-untyped-defs
|
- run: mypy org_rw --check-untyped-defs
|
||||||
|
|
||||||
style-formatting:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Check out repository code
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
- run: apt-get update && apt-get install -y python3-pip
|
|
||||||
- run: pip install -e .
|
|
||||||
- run: pip install black
|
|
||||||
- run: black --check .
|
|
||||||
|
|
||||||
style-sorted-imports:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Check out repository code
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
- run: apt-get update && apt-get install -y python3-pip
|
|
||||||
- run: pip install -e .
|
|
||||||
- run: pip install isort
|
|
||||||
- run: isort --profile black --check .
|
|
||||||
|
|
||||||
stability-extra-test:
|
stability-extra-test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
@ -41,12 +41,11 @@ class ListGroupNode:
|
|||||||
self.children.append(child)
|
self.children.append(child)
|
||||||
|
|
||||||
def get_raw(self):
|
def get_raw(self):
|
||||||
return "\n".join([c.get_raw() for c in self.children])
|
return '\n'.join([c.get_raw() for c in self.children])
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<List: {}>".format(len(self.children))
|
return "<List: {}>".format(len(self.children))
|
||||||
|
|
||||||
|
|
||||||
class TableNode:
|
class TableNode:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.children = []
|
self.children = []
|
||||||
@ -57,24 +56,21 @@ class TableNode:
|
|||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<Table: {}>".format(len(self.children))
|
return "<Table: {}>".format(len(self.children))
|
||||||
|
|
||||||
|
|
||||||
class TableSeparatorRow:
|
class TableSeparatorRow:
|
||||||
def __init__(self, orig=None):
|
def __init__(self, orig=None):
|
||||||
self.orig = orig
|
self.orig = orig
|
||||||
|
|
||||||
|
|
||||||
class TableRow:
|
class TableRow:
|
||||||
def __init__(self, cells, orig=None):
|
def __init__(self, cells, orig=None):
|
||||||
self.cells = cells
|
self.cells = cells
|
||||||
self.orig = orig
|
self.orig = orig
|
||||||
|
|
||||||
|
|
||||||
class Text:
|
class Text:
|
||||||
def __init__(self, content):
|
def __init__(self, content):
|
||||||
self.content = content
|
self.content = content
|
||||||
|
|
||||||
def get_raw(self):
|
def get_raw(self):
|
||||||
return "".join(self.content.get_raw())
|
return ''.join(self.content.get_raw())
|
||||||
|
|
||||||
|
|
||||||
class ListItem:
|
class ListItem:
|
||||||
@ -109,24 +105,21 @@ class CodeBlock(BlockNode):
|
|||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<Code: {}>".format(len(self.lines or []))
|
return "<Code: {}>".format(len(self.lines or []))
|
||||||
|
|
||||||
|
DomNode = Union[DrawerNode,
|
||||||
|
PropertyNode,
|
||||||
|
ListGroupNode,
|
||||||
|
TableNode,
|
||||||
|
TableSeparatorRow,
|
||||||
|
TableRow,
|
||||||
|
Text,
|
||||||
|
ListItem,
|
||||||
|
BlockNode,
|
||||||
|
]
|
||||||
|
|
||||||
DomNode = Union[
|
ContainerDomNode = Union[DrawerNode,
|
||||||
DrawerNode,
|
ListGroupNode,
|
||||||
PropertyNode,
|
TableNode,
|
||||||
ListGroupNode,
|
BlockNode,
|
||||||
TableNode,
|
]
|
||||||
TableSeparatorRow,
|
|
||||||
TableRow,
|
|
||||||
Text,
|
|
||||||
ListItem,
|
|
||||||
BlockNode,
|
|
||||||
]
|
|
||||||
|
|
||||||
ContainerDomNode = Union[
|
|
||||||
DrawerNode,
|
|
||||||
ListGroupNode,
|
|
||||||
TableNode,
|
|
||||||
BlockNode,
|
|
||||||
]
|
|
||||||
|
|
||||||
from .utils import get_raw_contents
|
from .utils import get_raw_contents
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
from typing import Dict, Optional, TextIO
|
||||||
|
from datetime import timedelta
|
||||||
import collections
|
import collections
|
||||||
import difflib
|
import difflib
|
||||||
import logging
|
import logging
|
||||||
@ -8,21 +9,12 @@ import re
|
|||||||
import sys
|
import sys
|
||||||
from datetime import date, datetime, timedelta
|
from datetime import date, datetime, timedelta
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import (
|
from typing import cast, Iterator, List, Literal, Optional, Tuple, TypedDict, Union
|
||||||
Dict,
|
|
||||||
Iterator,
|
from .types import HeadlineDict
|
||||||
List,
|
|
||||||
Literal,
|
|
||||||
Optional,
|
|
||||||
TextIO,
|
|
||||||
Tuple,
|
|
||||||
TypedDict,
|
|
||||||
Union,
|
|
||||||
cast,
|
|
||||||
)
|
|
||||||
|
|
||||||
from . import dom
|
from . import dom
|
||||||
from .types import HeadlineDict
|
|
||||||
|
|
||||||
DEBUG_DIFF_CONTEXT = 10
|
DEBUG_DIFF_CONTEXT = 10
|
||||||
|
|
||||||
|
@ -1,19 +1,9 @@
|
|||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from .org_rw import (
|
from .org_rw import (Bold, Code, Headline, Italic, Line, RawLine, ListItem, Strike, Text,
|
||||||
Bold,
|
Underlined, Verbatim)
|
||||||
Code,
|
|
||||||
Headline,
|
from .org_rw import dump_contents
|
||||||
Italic,
|
|
||||||
Line,
|
|
||||||
ListItem,
|
|
||||||
RawLine,
|
|
||||||
Strike,
|
|
||||||
Text,
|
|
||||||
Underlined,
|
|
||||||
Verbatim,
|
|
||||||
dump_contents,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def get_hl_raw_contents(doc: Headline) -> str:
|
def get_hl_raw_contents(doc: Headline) -> str:
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
set -eu
|
|
||||||
|
|
||||||
cd "`dirname $0`"
|
|
||||||
cd ..
|
|
||||||
|
|
||||||
set -x
|
|
||||||
|
|
||||||
isort --profile black .
|
|
||||||
black .
|
|
@ -2,6 +2,9 @@ import os
|
|||||||
import unittest
|
import unittest
|
||||||
from datetime import datetime as DT
|
from datetime import datetime as DT
|
||||||
|
|
||||||
|
from org_rw import MarkerToken, MarkerType, Timestamp, dumps, load, loads, dom
|
||||||
|
import org_rw
|
||||||
|
|
||||||
from utils.assertions import (
|
from utils.assertions import (
|
||||||
BOLD,
|
BOLD,
|
||||||
CODE,
|
CODE,
|
||||||
@ -16,9 +19,6 @@ from utils.assertions import (
|
|||||||
Tokens,
|
Tokens,
|
||||||
)
|
)
|
||||||
|
|
||||||
import org_rw
|
|
||||||
from org_rw import MarkerToken, MarkerType, Timestamp, dom, dumps, load, loads
|
|
||||||
|
|
||||||
DIR = os.path.dirname(os.path.abspath(__file__))
|
DIR = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
|
||||||
|
|
||||||
@ -834,12 +834,12 @@ class TestSerde(unittest.TestCase):
|
|||||||
self.assertEqual(dumps(doc), orig)
|
self.assertEqual(dumps(doc), orig)
|
||||||
|
|
||||||
def test_add_todo_keywords_programatically(self):
|
def test_add_todo_keywords_programatically(self):
|
||||||
orig = """* NEW_TODO_STATE First entry
|
orig = '''* NEW_TODO_STATE First entry
|
||||||
|
|
||||||
* NEW_DONE_STATE Second entry"""
|
* NEW_DONE_STATE Second entry'''
|
||||||
doc = loads(
|
doc = loads(orig, environment={
|
||||||
orig, environment={"org-todo-keywords": "NEW_TODO_STATE | NEW_DONE_STATE"}
|
'org-todo-keywords': "NEW_TODO_STATE | NEW_DONE_STATE"
|
||||||
)
|
})
|
||||||
self.assertEqual(doc.headlines[0].is_todo, True)
|
self.assertEqual(doc.headlines[0].is_todo, True)
|
||||||
self.assertEqual(doc.headlines[0].is_done, False)
|
self.assertEqual(doc.headlines[0].is_done, False)
|
||||||
|
|
||||||
@ -849,14 +849,14 @@ class TestSerde(unittest.TestCase):
|
|||||||
self.assertEqual(dumps(doc), orig)
|
self.assertEqual(dumps(doc), orig)
|
||||||
|
|
||||||
def test_add_todo_keywords_in_file(self):
|
def test_add_todo_keywords_in_file(self):
|
||||||
orig = """#+TODO: NEW_TODO_STATE | NEW_DONE_STATE
|
orig = '''#+TODO: NEW_TODO_STATE | NEW_DONE_STATE
|
||||||
|
|
||||||
* NEW_TODO_STATE First entry
|
* NEW_TODO_STATE First entry
|
||||||
|
|
||||||
* NEW_DONE_STATE Second entry"""
|
* NEW_DONE_STATE Second entry'''
|
||||||
doc = loads(
|
doc = loads(orig, environment={
|
||||||
orig, environment={"org-todo-keywords": "NEW_TODO_STATE | NEW_DONE_STATE"}
|
'org-todo-keywords': "NEW_TODO_STATE | NEW_DONE_STATE"
|
||||||
)
|
})
|
||||||
self.assertEqual(doc.headlines[0].is_todo, True)
|
self.assertEqual(doc.headlines[0].is_todo, True)
|
||||||
self.assertEqual(doc.headlines[0].is_done, False)
|
self.assertEqual(doc.headlines[0].is_done, False)
|
||||||
|
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
"""Test the Timestamp object."""
|
"""Test the Timestamp object."""
|
||||||
|
|
||||||
from datetime import date, datetime
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from datetime import date, datetime
|
||||||
from org_rw import Timestamp
|
from org_rw import Timestamp
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,17 +2,8 @@ import collections
|
|||||||
import unittest
|
import unittest
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from org_rw import (
|
from org_rw import (Bold, Code, Italic, Line, Strike, Text, Underlined,
|
||||||
Bold,
|
Verbatim, get_raw_contents)
|
||||||
Code,
|
|
||||||
Italic,
|
|
||||||
Line,
|
|
||||||
Strike,
|
|
||||||
Text,
|
|
||||||
Underlined,
|
|
||||||
Verbatim,
|
|
||||||
get_raw_contents,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def timestamp_to_datetime(ts):
|
def timestamp_to_datetime(ts):
|
||||||
|
Loading…
Reference in New Issue
Block a user