Closed arbitrarypunter closed 3 years ago
Hi Adam,
Not sure re space delimited key/value pairs?
See the updated script via email, but the gist is that through adopting pydantic
to ensure data is valdidated we've moved away from literal dict/lists and towards typed models.
So you would access the same data by training_tab_data.mandatory.gdpr.completed_date
(noting also the field names changed, requiring a 0.Y.0 release as breaking change)
This also helps development with autocompletion in the IDE, as attributes (dot notation) can be autocompleted whereas dict keys usually can't.
Adam If if only i had read my email first before starting to look at this! Sorry for the noise. And thanks very much for your help.
Closing....
No problem!
Hi Just tried upgrading form 0.5.1 to 0.5.2 and indeed 0.6.0. Is it a deliberate change to move away from json formatted output to space delimited key/value pairs? for example with 0.5.2 i get this error pulling some basic information:
form this bit of code: personal_tab_data = people._scraper.get_personal_tab(i) print(personal_tab_data["membership_number"], personal_tab_data["forenames"], personal_tab_data["surname"], end=',', sep=',')
Traceback (most recent call last): File "/home/agoodall/compass/get-expiry-data.py", line 67, in
print(personal_tab_data["membership_number"], personal_tab_data["forenames"], personal_tab_data["surname"], end=',', sep=',')
TypeError: 'MemberDetails' object is not subscriptable
and in 0.6.0 i get a similar error while trying to pull data out of the training_tab_data Traceback (most recent call last): File "/home/agoodall/compass/test.py", line 30, in
print(training_tab_data["mandatory"]["GDPR"]['completed_date'])
TypeError: 'MemberTrainingTab' object is not subscriptable
Thanks