Compare commits
No commits in common. "852f47237413a55fe4e3320b98a4bef2fcdb4fed" and "e0306bf3a58c435aac7451d0eaa6936bd436cb53" have entirely different histories.
852f472374
...
e0306bf3a5
@ -753,7 +753,10 @@ class Headline:
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def tags(self):
|
def tags(self):
|
||||||
return list(self.shallow_tags) + self.parent.tags
|
if isinstance(self.parent, OrgDoc):
|
||||||
|
return list(self.shallow_tags)
|
||||||
|
else:
|
||||||
|
return list(self.shallow_tags) + self.parent.tags
|
||||||
|
|
||||||
def add_tag(self, tag: str):
|
def add_tag(self, tag: str):
|
||||||
self.shallow_tags.append(tag)
|
self.shallow_tags.append(tag)
|
||||||
@ -2277,17 +2280,6 @@ class OrgDoc:
|
|||||||
def path(self):
|
def path(self):
|
||||||
return self._path
|
return self._path
|
||||||
|
|
||||||
@property
|
|
||||||
def tags(self) -> list[str]:
|
|
||||||
for kw in self.keywords:
|
|
||||||
if kw.key == "FILETAGS":
|
|
||||||
return kw.value.strip(':').split(':')
|
|
||||||
return []
|
|
||||||
|
|
||||||
@property
|
|
||||||
def shallow_tags(self) -> list[str]:
|
|
||||||
return self.tags
|
|
||||||
|
|
||||||
## Querying
|
## Querying
|
||||||
def get_links(self):
|
def get_links(self):
|
||||||
for headline in self.headlines:
|
for headline in self.headlines:
|
||||||
|
@ -889,23 +889,6 @@ class TestSerde(unittest.TestCase):
|
|||||||
h1_2_h2 = h1_2.children[0]
|
h1_2_h2 = h1_2.children[0]
|
||||||
self.assertEqual(sorted(h1_2_h2.tags), ['filetag', 'otherh1tag', 'otherh2tag'])
|
self.assertEqual(sorted(h1_2_h2.tags), ['filetag', 'otherh1tag', 'otherh2tag'])
|
||||||
|
|
||||||
def test_shallow_tag_property_read_13(self):
|
|
||||||
with open(os.path.join(DIR, "13-tags.org")) as f:
|
|
||||||
orig = f.read()
|
|
||||||
doc = loads(orig)
|
|
||||||
|
|
||||||
self.assertEqual(doc.shallow_tags, ['filetag'])
|
|
||||||
|
|
||||||
h1_1, h1_2 = doc.getTopHeadlines()
|
|
||||||
self.assertEqual(sorted(h1_1.shallow_tags), ['h1tag'])
|
|
||||||
self.assertEqual(sorted(h1_2.shallow_tags), ['otherh1tag'])
|
|
||||||
|
|
||||||
h1_1_h2 = h1_1.children[0]
|
|
||||||
self.assertEqual(sorted(h1_1_h2.shallow_tags), ['h2tag'])
|
|
||||||
|
|
||||||
h1_2_h2 = h1_2.children[0]
|
|
||||||
self.assertEqual(sorted(h1_2_h2.shallow_tags), ['otherh2tag'])
|
|
||||||
|
|
||||||
def print_tree(tree, indentation=0, headline=None):
|
def print_tree(tree, indentation=0, headline=None):
|
||||||
for element in tree:
|
for element in tree:
|
||||||
print(" " * indentation * 2, "EL:", element)
|
print(" " * indentation * 2, "EL:", element)
|
||||||
|
Loading…
Reference in New Issue
Block a user