Skip to content

Commit 2472a17

Browse files
no need to pass meta to contentnode anymore
1 parent 7e964fa commit 2472a17

File tree

4 files changed

+17
-23
lines changed

4 files changed

+17
-23
lines changed

syrinx/node.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,21 @@ class ContentNode:
1414
front: Dict[str, str]
1515
buildPage: bool
1616
path: str
17-
meta: BuildMetaInfo
1817
config: SyrinxConfiguration
1918
isLeaf: bool
2019

21-
def __init__(self, meta: BuildMetaInfo, config: SyrinxConfiguration):
20+
def __init__(self, config: SyrinxConfiguration):
2221
self.buildPage = False
2322
self.leaves = []
2423
self.branches = []
2524
self.front = {}
26-
self.meta = meta
2725
self.config = config
2826
self.isLeaf = False
2927

28+
@property
29+
def meta(self) -> BuildMetaInfo:
30+
return self.config.meta
31+
3032
@property
3133
def sequenceNumber(self) -> int:
3234
if 'SequenceNumber' in self.front:

syrinx/read.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,14 @@ def read_file(fpath: str) -> Tuple[Dict, str]:
5555

5656
def read(root_dir: str, config: SyrinxConfiguration) -> ContentNode:
5757

58-
meta = config.meta
5958
content_dir = join(root_dir, 'content')
6059

6160
tree: Dict[str, ContentNode] = dict()
62-
root = ContentNode(meta, config)
61+
root = ContentNode(config)
6362
root.name = ''
64-
root.meta = meta
6563
for (dirpath, _, fnames) in walk(content_dir):
6664

67-
indexNode = ContentNode(meta, config)
65+
indexNode = ContentNode(config)
6866
indexNode.name = basename(dirpath)
6967
if dirpath == content_dir:
7068
indexNode = root
@@ -91,7 +89,7 @@ def read(root_dir: str, config: SyrinxConfiguration) -> ContentNode:
9189
node = indexNode
9290
node.buildPage = True
9391
else:
94-
node = ContentNode(meta, config)
92+
node = ContentNode(config)
9593
node.name = name
9694
node.isLeaf = True
9795
node.buildPage = True if config.leaf_pages else False

tests/node.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ class ContentNodeTests(TestCase):
66

77
def test_follows_buildPage(self):
88
from syrinx.node import ContentNode
9-
node = ContentNode(None, None)
9+
config = Mock()
10+
node = ContentNode(config)
1011
node.name = 'foo_bar'
1112
node.front = dict()
1213
self.assertEqual(node.title, 'Foo Bar')
@@ -32,8 +33,7 @@ def test_includeInSitemap(self, cfg, fm, bld, url, exp):
3233
config = Mock()
3334
config.sitemap = cfg
3435
config.domain = url
35-
meta = Mock()
36-
node = ContentNode(meta, config)
36+
node = ContentNode(config)
3737
node.name = 'b'
3838
node.front = dict()
3939
node.buildPage = bld

tests/node_lastmodified.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ def test_lastModified_direct_entry(self):
1313
"""Test that direct LastModified entry is converted to datetime"""
1414
config = Mock()
1515
config.branches = Branches({})
16-
meta = Mock()
1716

18-
node = ContentNode(meta, config)
17+
node = ContentNode(config)
1918
node.front = {'LastModified': '2025-10-01T12:00:00'}
2019

2120
result = node.lastModified
@@ -29,9 +28,8 @@ def test_lastModified_branch_lookup(self):
2928
'main': datetime(2025, 12, 6, 13, 15, 24, 42024, tzinfo=UTC),
3029
}
3130
config.branches = Branches(branches_dict)
32-
meta = Mock()
3331

34-
node = ContentNode(meta, config)
32+
node = ContentNode(config)
3533
node.front = {'LastModifiedBranch': 'main'}
3634

3735
result = node.lastModified
@@ -46,9 +44,8 @@ def test_lastModified_branch_lookup_different_branch(self):
4644
'feature-branch': datetime(2025, 11, 15, 10, 30, 0, tzinfo=UTC),
4745
}
4846
config.branches = Branches(branches_dict)
49-
meta = Mock()
5047

51-
node = ContentNode(meta, config)
48+
node = ContentNode(config)
5249
node.front = {'LastModifiedBranch': 'feature-branch'}
5350

5451
result = node.lastModified
@@ -62,9 +59,8 @@ def test_lastModified_direct_takes_precedence(self):
6259
'main': datetime(2025, 12, 6, 13, 15, 24, tzinfo=UTC),
6360
}
6461
config.branches = Branches(branches_dict)
65-
meta = Mock()
6662

67-
node = ContentNode(meta, config)
63+
node = ContentNode(config)
6864
node.front = {
6965
'LastModified': '2025-09-01T08:00:00',
7066
'LastModifiedBranch': 'main'
@@ -78,9 +74,8 @@ def test_lastModified_no_entries(self):
7874
"""Test that None is returned when no entries present"""
7975
config = Mock()
8076
config.branches = Branches({})
81-
meta = Mock()
8277

83-
node = ContentNode(meta, config)
78+
node = ContentNode(config)
8479
node.front = {}
8580

8681
self.assertIsNone(node.lastModified)
@@ -92,9 +87,8 @@ def test_lastModified_unknown_branch_raises_error(self):
9287
'main': datetime(2025, 12, 6, 13, 15, 24, tzinfo=UTC),
9388
}
9489
config.branches = Branches(branches_dict)
95-
meta = Mock()
9690

97-
node = ContentNode(meta, config)
91+
node = ContentNode(config)
9892
node.front = {'LastModifiedBranch': 'nonexistent-branch'}
9993

10094
with self.assertRaises(UnknownBranchError) as cm:

0 commit comments

Comments
 (0)