Compare commits
1 Commits
97db5686d8
...
c5845d670f
Author | SHA1 | Date | |
---|---|---|---|
![]() |
c5845d670f |
@ -820,17 +820,6 @@ class Headline:
|
|||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
def update_raw_contents(self, new_contents):
|
def update_raw_contents(self, new_contents):
|
||||||
# Clear elements
|
|
||||||
self.keywords = []
|
|
||||||
self.contents = []
|
|
||||||
self.list_items = []
|
|
||||||
self.table_rows = []
|
|
||||||
self.properties = []
|
|
||||||
self.structural = []
|
|
||||||
self.delimiters = []
|
|
||||||
self.scheduled = None
|
|
||||||
self.deadline = None
|
|
||||||
self.closed = None
|
|
||||||
|
|
||||||
reader = OrgDocReader(environment=self.doc.environment)
|
reader = OrgDocReader(environment=self.doc.environment)
|
||||||
reader.read(new_contents)
|
reader.read(new_contents)
|
||||||
@ -840,20 +829,19 @@ class Headline:
|
|||||||
# Probably can be done by just adding the headlines to this one's children
|
# Probably can be done by just adding the headlines to this one's children
|
||||||
raise NotImplementedError('new headlines on raw contents not supported yet. This probably should be simple, see comment on code.')
|
raise NotImplementedError('new headlines on raw contents not supported yet. This probably should be simple, see comment on code.')
|
||||||
|
|
||||||
for kw in reader.keywords:
|
# Clear elements
|
||||||
self.keywords.append(offset_linenum(self.start_line + 1, kw))
|
self.keywords = reader.keywords
|
||||||
|
self.contents = reader.contents
|
||||||
|
self.list_items = reader.list_items
|
||||||
|
self.table_rows = reader.table_rows
|
||||||
|
self.properties = reader.properties
|
||||||
|
self.structural = reader.structural
|
||||||
|
self.delimiters = reader.delimiters
|
||||||
|
|
||||||
for content in reader.contents:
|
# TODO: Support update of scheduled/deadline/closed line
|
||||||
self.contents.append(offset_linenum(self.start_line + 1, content))
|
self.scheduled = None
|
||||||
|
self.deadline = None
|
||||||
for list_item in reader.list_items:
|
self.closed = None
|
||||||
self.list_items.append(offset_linenum(self.start_line + 1, list_item))
|
|
||||||
|
|
||||||
for struct_item in reader.structural:
|
|
||||||
self.structural.append(offset_linenum(self.start_line + 1, struct_item))
|
|
||||||
|
|
||||||
for prop in reader.properties:
|
|
||||||
self.properties.append(offset_linenum(self.start_line + 1, prop))
|
|
||||||
|
|
||||||
# Environment is not used, as it's known
|
# Environment is not used, as it's known
|
||||||
|
|
||||||
@ -1074,20 +1062,6 @@ TableRow = collections.namedtuple(
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
ItemWithLineNum = Union[Keyword, RawLine, Property, ListItem, tuple[int, Any]]
|
|
||||||
def offset_linenum(offset: int, item: ItemWithLineNum) -> ItemWithLineNum:
|
|
||||||
if isinstance(item, tuple) and len(item) == 2 and isinstance(item[0], int):
|
|
||||||
return item
|
|
||||||
|
|
||||||
if isinstance(item, ListItem):
|
|
||||||
item.linenum += offset
|
|
||||||
return item
|
|
||||||
|
|
||||||
assert isinstance(item, (Keyword, RawLine, Property)), \
|
|
||||||
"Expected (Keyword|RawLine|Property), found {}".format(item)
|
|
||||||
return item._replace(linenum=item.linenum + offset)
|
|
||||||
|
|
||||||
|
|
||||||
# @TODO How are [YYYY-MM-DD HH:mm--HH:mm] and ([... HH:mm]--[... HH:mm]) differentiated ?
|
# @TODO How are [YYYY-MM-DD HH:mm--HH:mm] and ([... HH:mm]--[... HH:mm]) differentiated ?
|
||||||
# @TODO Consider recurrence annotations
|
# @TODO Consider recurrence annotations
|
||||||
class Timestamp:
|
class Timestamp:
|
||||||
|
Loading…
Reference in New Issue
Block a user