Skip to content

Commit c43803e

Browse files
authored
Merge pull request #34 from LeakIX/re-export-public-models
Re-export all public models from __init__.py
2 parents 7b800c9 + 74bccb1 commit c43803e

3 files changed

Lines changed: 120 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ and this project adheres to
88

99
## [Unreleased]
1010

11+
### Changed
12+
13+
- Re-export all public models from `__init__.py` and define `__all__`
14+
([1dcfbef], [#21])
15+
- Tests now import from `l9format` package directly instead of
16+
`l9format.l9format` ([e8aef2e], [#21])
17+
1118
## [1.4.0] - 2026-02-07
1219

1320
### Added
@@ -125,6 +132,8 @@ and this project adheres to
125132

126133
<!-- Commit links -->
127134

135+
[1dcfbef]: https://github.com/LeakIX/l9format-python/commit/1dcfbef
136+
[e8aef2e]: https://github.com/LeakIX/l9format-python/commit/e8aef2e
128137
[8f45e82]: https://github.com/LeakIX/l9format-python/commit/8f45e82
129138
[82245e9]: https://github.com/LeakIX/l9format-python/commit/82245e9
130139
[fac243d]: https://github.com/LeakIX/l9format-python/commit/fac243d
@@ -183,3 +192,4 @@ and this project adheres to
183192
[#15]: https://github.com/LeakIX/l9format-python/pull/15
184193
[#16]: https://github.com/LeakIX/l9format-python/pull/16
185194
[#18]: https://github.com/LeakIX/l9format-python/pull/18
195+
[#21]: https://github.com/LeakIX/l9format-python/issues/21

l9format/__init__.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,67 @@
11
__version__ = "1.4.0"
2+
3+
from l9format.l9format import (
4+
Certificate,
5+
DatasetSummary,
6+
GeoLocation,
7+
GeoPoint,
8+
L9Aggregation,
9+
L9AMQPEvent,
10+
L9DNSEvent,
11+
L9Event,
12+
L9FTPEvent,
13+
L9HttpEvent,
14+
L9LDAPEvent,
15+
L9LeakEvent,
16+
L9MemcachedEvent,
17+
L9MongoDBEvent,
18+
L9MySQLEvent,
19+
L9PostgreSQLEvent,
20+
L9RDPEvent,
21+
L9RedisEvent,
22+
L9RTSPEvent,
23+
L9ServiceEvent,
24+
L9SIPEvent,
25+
L9SMTPEvent,
26+
L9SSHEvent,
27+
L9SSLEvent,
28+
L9TelnetEvent,
29+
L9VNCEvent,
30+
Network,
31+
ServiceCredentials,
32+
Software,
33+
SoftwareModule,
34+
)
35+
36+
__all__ = [
37+
"Certificate",
38+
"DatasetSummary",
39+
"GeoLocation",
40+
"GeoPoint",
41+
"L9Aggregation",
42+
"L9AMQPEvent",
43+
"L9DNSEvent",
44+
"L9Event",
45+
"L9FTPEvent",
46+
"L9HttpEvent",
47+
"L9LDAPEvent",
48+
"L9LeakEvent",
49+
"L9MemcachedEvent",
50+
"L9MongoDBEvent",
51+
"L9MySQLEvent",
52+
"L9PostgreSQLEvent",
53+
"L9RDPEvent",
54+
"L9RedisEvent",
55+
"L9RTSPEvent",
56+
"L9ServiceEvent",
57+
"L9SIPEvent",
58+
"L9SMTPEvent",
59+
"L9SSHEvent",
60+
"L9SSLEvent",
61+
"L9TelnetEvent",
62+
"L9VNCEvent",
63+
"Network",
64+
"ServiceCredentials",
65+
"Software",
66+
"SoftwareModule",
67+
]

tests/test_l9format.py

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import os
33
from pathlib import Path
44

5-
from l9format import l9format
5+
from l9format import L9Event
66

77
TESTS_DIR = Path(os.path.dirname(__file__))
88

@@ -16,13 +16,13 @@
1616
def test_l9event_json_from_reference_repository():
1717
path = TESTS_DIR / "l9event.json"
1818
c = json.load(open(str(path), "r"))
19-
l9format.L9Event.from_dict(c)
19+
L9Event.from_dict(c)
2020

2121

2222
def test_l9events_form_ip4scout():
2323
for path in IP4SCOUT_FILES:
2424
c = json.load(open(str(path), "r"))
25-
l9format.L9Event.from_dict(c)
25+
L9Event.from_dict(c)
2626

2727

2828
def test_iso8601_nanosecond_parsing():
@@ -36,10 +36,50 @@ def test_iso8601_nanosecond_parsing():
3636
c = json.load(open(str(path), "r"))
3737
# Use a timestamp with nanosecond precision (9 decimal places)
3838
c["time"] = "2023-10-05T23:30:36.823867784Z"
39-
event = l9format.L9Event.from_dict(c)
39+
event = L9Event.from_dict(c)
4040
assert event.time.year == 2023
4141
assert event.time.month == 10
4242
assert event.time.day == 5
4343
assert event.time.hour == 23
4444
assert event.time.minute == 30
4545
assert event.time.second == 36
46+
47+
48+
def test_all_models_importable_from_package():
49+
"""Verify all public models are importable from the l9format package."""
50+
import l9format
51+
52+
expected_models = [
53+
"Certificate",
54+
"DatasetSummary",
55+
"GeoLocation",
56+
"GeoPoint",
57+
"L9Aggregation",
58+
"L9AMQPEvent",
59+
"L9DNSEvent",
60+
"L9Event",
61+
"L9FTPEvent",
62+
"L9HttpEvent",
63+
"L9LDAPEvent",
64+
"L9LeakEvent",
65+
"L9MemcachedEvent",
66+
"L9MongoDBEvent",
67+
"L9MySQLEvent",
68+
"L9PostgreSQLEvent",
69+
"L9RDPEvent",
70+
"L9RedisEvent",
71+
"L9RTSPEvent",
72+
"L9ServiceEvent",
73+
"L9SIPEvent",
74+
"L9SMTPEvent",
75+
"L9SSHEvent",
76+
"L9SSLEvent",
77+
"L9TelnetEvent",
78+
"L9VNCEvent",
79+
"Network",
80+
"ServiceCredentials",
81+
"Software",
82+
"SoftwareModule",
83+
]
84+
for name in expected_models:
85+
assert hasattr(l9format, name), f"{name} not importable from l9format"

0 commit comments

Comments
 (0)