Apply black formatter.
Some checks are pending
Testing / pytest (push) Waiting to run
Testing / mypy (push) Waiting to run
Testing / formatting (push) Waiting to run
Testing / stability-extra-test (push) Waiting to run

This commit is contained in:
Sergio Martínez Portela 2024-08-18 22:44:00 +02:00
parent 2ec354c6c7
commit c4867f7ed3
4 changed files with 58 additions and 31 deletions

View File

@ -41,11 +41,12 @@ 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 = []
@ -56,21 +57,24 @@ 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:
@ -105,21 +109,24 @@ 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,
]
ContainerDomNode = Union[DrawerNode, DomNode = Union[
ListGroupNode, DrawerNode,
TableNode, PropertyNode,
BlockNode, ListGroupNode,
] TableNode,
TableSeparatorRow,
TableRow,
Text,
ListItem,
BlockNode,
]
ContainerDomNode = Union[
DrawerNode,
ListGroupNode,
TableNode,
BlockNode,
]
from .utils import get_raw_contents from .utils import get_raw_contents

View File

@ -1,7 +1,18 @@
import uuid import uuid
from .org_rw import (Bold, Code, Headline, Italic, Line, RawLine, ListItem, Strike, Text, from .org_rw import (
Underlined, Verbatim) Bold,
Code,
Headline,
Italic,
Line,
RawLine,
ListItem,
Strike,
Text,
Underlined,
Verbatim,
)
from .org_rw import dump_contents from .org_rw import dump_contents

View 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(orig, environment={ doc = loads(
'org-todo-keywords': "NEW_TODO_STATE | NEW_DONE_STATE" orig, environment={"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(orig, environment={ doc = loads(
'org-todo-keywords': "NEW_TODO_STATE | NEW_DONE_STATE" orig, environment={"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)

View File

@ -2,8 +2,17 @@ import collections
import unittest import unittest
from datetime import datetime from datetime import datetime
from org_rw import (Bold, Code, Italic, Line, Strike, Text, Underlined, from org_rw import (
Verbatim, get_raw_contents) Bold,
Code,
Italic,
Line,
Strike,
Text,
Underlined,
Verbatim,
get_raw_contents,
)
def timestamp_to_datetime(ts): def timestamp_to_datetime(ts):