Skip to content

Commit 7995f65

Browse files
author
Lennart Regebro
committed
Make it possible to pass in data into the Captable constructor
1 parent dcc5075 commit 7995f65

4 files changed

Lines changed: 65 additions & 17 deletions

File tree

CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ Changes
66

77
- Now includes default values when saving, making the OCF files larger.
88

9+
- It's now possible to pass in the data to the Captable object when
10+
creating it, instead of adding the data to the attribute lists later.
11+
912

1013
1.2.0b2 (2025-02-04)
1114
--------------------

docs/source/using.rst

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ but you then need to create ``File`` objects for each file, with dummy md5 hashe
4646
... id="d6c49a5a-257d-4b41-9f1d-073a77dfe719",
4747
... name={"legal_name": "Person Y"},
4848
... stakeholder_type="INDIVIDUAL",
49-
... comments=[],
5049
... )
5150
... )
5251

@@ -69,6 +68,20 @@ but you then need to create ``File`` objects for each file, with dummy md5 hashe
6968
... )
7069
... )
7170

71+
It is also possible to create the list of objects first, and pass them in to the
72+
Captable constructor::
73+
74+
>>> sh_list = [
75+
... api.Stakeholder(
76+
... object_type="STAKEHOLDER",
77+
... id="'917efd77a370-d1f9-14b4-d752-a5a94c6d",
78+
... name={"legal_name": "Person X"},
79+
... stakeholder_type="INDIVIDUAL",
80+
... )
81+
... }
82+
83+
>>> cap2 = Captable(stakeholders=sh_list)
84+
7285
And once you have filled in all the lists with all the information, you save
7386
the captable:
7487

@@ -102,12 +115,7 @@ A captable will then be created and Python objects will be stored in it.
102115
'pyocf example docs'
103116

104117
>>> cap.stakeholders # doctest: +NORMALIZE_WHITESPACE
105-
[Stakeholder(id='d6c49a5a-257d-4b41-9f1d-073a77dfe719', comments=[],
106-
object_type='STAKEHOLDER', name=Name(legal_name='Person Y', first_name=None,
107-
last_name=None), stakeholder_type=<StakeholderType.ENUM_INDIVIDUAL:
108-
'INDIVIDUAL'>, issuer_assigned_id=None, current_relationship=None,
109-
primary_contact=None, contact_info=None, addresses=None, tax_ids=None),
110-
Stakeholder(id='d6c49a5a-257d-4b41-9f1d-073a77dfe719', comments=[],
118+
[Stakeholder(id='d6c49a5a-257d-4b41-9f1d-073a77dfe719', comments=None,
111119
object_type='STAKEHOLDER', name=Name(legal_name='Person Y', first_name=None,
112120
last_name=None), stakeholder_type=<StakeholderType.ENUM_INDIVIDUAL:
113121
'INDIVIDUAL'>, issuer_assigned_id=None, current_relationship=None,

src/pyocf/captable.py

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,40 @@
4343

4444

4545
class Captable:
46-
manifest: ocfmanifestfile.OCFManifestFile = None
47-
documents: list[Document] = []
48-
financings: list[Financing] = []
49-
stakeholders: list[Stakeholder] = []
50-
stock_classes: list[StockClass] = []
51-
stock_legend_templates: list[StockLegendTemplate] = []
52-
stock_plans: list[StockPlan] = []
53-
transactions: list[Transaction] = []
54-
valuations: list[Valuation] = []
55-
vesting_terms: list[VestingTerms] = []
46+
manifest: ocfmanifestfile.OCFManifestFile
47+
documents: list[Document]
48+
financings: list[Financing]
49+
stakeholders: list[Stakeholder]
50+
stock_classes: list[StockClass]
51+
stock_legend_templates: list[StockLegendTemplate]
52+
stock_plans: list[StockPlan]
53+
transactions: list[Transaction]
54+
valuations: list[Valuation]
55+
vesting_terms: list[VestingTerms]
56+
57+
def __init__(
58+
self,
59+
manifest: ocfmanifestfile.OCFManifestFile = None,
60+
documents: list[Document] = None,
61+
financings: list[Financing] = None,
62+
stakeholders: list[Stakeholder] = None,
63+
stock_classes: list[StockClass] = None,
64+
stock_legend_templates: list[StockLegendTemplate] = None,
65+
stock_plans: list[StockPlan] = None,
66+
transactions: list[Transaction] = None,
67+
valuations: list[Valuation] = None,
68+
vesting_terms: list[VestingTerms] = None,
69+
):
70+
self.manifest = manifest
71+
self.documents = documents or []
72+
self.financings = financings or []
73+
self.stakeholders = stakeholders or []
74+
self.stock_classes = stock_classes or []
75+
self.stock_legend_templates = stock_legend_templates or []
76+
self.stock_plans = stock_plans or []
77+
self.transactions = transactions or []
78+
self.valuations = valuations or []
79+
self.vesting_terms = vesting_terms or []
5680

5781
@classmethod
5882
def load(cls, location):

tests/test_basic.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from pyocf.api import StakeholdersFile
88
from pyocf.api import Stakeholder
99
from pyocf.api import Name, Phone, CountryCode
10+
from pyocf.captable import Captable
1011

1112

1213
def test_basic_loading():
@@ -79,3 +80,15 @@ def test_constrained_strings():
7980

8081
with pytest.raises(ValueError):
8182
CountryCode("SPUT")
83+
84+
85+
def test_captable_init():
86+
stakeholders = [
87+
Stakeholder(
88+
id="steve",
89+
name=Name(legal_name="Stake Holder"),
90+
stakeholder_type=StakeholderType.ENUM_INDIVIDUAL,
91+
)
92+
]
93+
captable = Captable(stakeholders=stakeholders)
94+
assert captable.stakeholders[0].name.legal_name == "Stake Holder"

0 commit comments

Comments
 (0)