Make some init parameters optional
This commit is contained in:
parent
606537d959
commit
396f8d405a
|
@ -3,7 +3,7 @@ Logic for operations that depend on a whole collection of documents.
|
|||
"""
|
||||
import os
|
||||
|
||||
from redstring.parser import load, TagOptions, DocumentTag, TabOptions, DocumentTab, Document
|
||||
from redstring.parser import load, DocumentTag, DocumentTab, Document
|
||||
|
||||
|
||||
def generate_index_document(directory: str) -> Document:
|
||||
|
@ -64,8 +64,8 @@ def generate_index_document(directory: str) -> Document:
|
|||
docs = sorted(categories[category][topic], key=lambda x: x[0])
|
||||
doc_links = map(document_link, docs)
|
||||
value = '- ' + '<br>- '.join(doc_links)
|
||||
built_tags.append(DocumentTag(topic, value, TagOptions(), []))
|
||||
built_tags.append(DocumentTag(topic, value))
|
||||
|
||||
built_tabs.append(DocumentTab(category, built_tags, TabOptions()))
|
||||
built_tabs.append(DocumentTab(category, built_tags))
|
||||
|
||||
return Document(built_tabs)
|
||||
|
|
|
@ -4,7 +4,7 @@ Logic for reading and writing documents from files.
|
|||
import argparse
|
||||
from collections import OrderedDict
|
||||
import json
|
||||
from typing import Any, List, IO
|
||||
from typing import Any, List, IO, Optional
|
||||
|
||||
|
||||
#
|
||||
|
@ -98,10 +98,15 @@ class DocumentSubtag:
|
|||
"""
|
||||
A keyvalue describing a document subject.
|
||||
"""
|
||||
def __init__(self, name: str, value: str, options: TagOptions) -> None:
|
||||
def __init__(
|
||||
self,
|
||||
name: str,
|
||||
value: str,
|
||||
options: Optional[TagOptions] = None
|
||||
) -> None:
|
||||
self.name: str = name
|
||||
self.value: str = value
|
||||
self.options: TagOptions = options
|
||||
self.options: TagOptions = options if options is not None else TagOptions()
|
||||
|
||||
|
||||
class DocumentTag:
|
||||
|
@ -112,23 +117,28 @@ class DocumentTag:
|
|||
self,
|
||||
name: str,
|
||||
value: str,
|
||||
options: TagOptions,
|
||||
subtags: List[DocumentSubtag]
|
||||
options: Optional[TagOptions] = None,
|
||||
subtags: Optional[List[DocumentSubtag]] = None
|
||||
) -> None:
|
||||
self.name: str = name
|
||||
self.value = value
|
||||
self.options = options
|
||||
self.subtags = subtags
|
||||
self.value: str = value
|
||||
self.options: TagOptions = options if options is not None else TagOptions()
|
||||
self.subtags: list = subtags if subtags is not None else []
|
||||
|
||||
|
||||
class DocumentTab:
|
||||
"""
|
||||
A division of tags within a document.
|
||||
"""
|
||||
def __init__(self, name: str, tags: List[DocumentTag], options: TabOptions) -> None:
|
||||
self.name = name
|
||||
def __init__(
|
||||
self,
|
||||
name: str,
|
||||
tags: List[DocumentTag],
|
||||
options: Optional[TabOptions] = None
|
||||
) -> None:
|
||||
self.name: str = name
|
||||
self.tags: List[DocumentTag] = tags
|
||||
self.options: TabOptions = options
|
||||
self.options: TabOptions = options if options is not None else TabOptions()
|
||||
|
||||
def get_tag(self, name: str):
|
||||
for tag in self.tags:
|
||||
|
|
Loading…
Reference in New Issue