Closed RinkeHoekstra closed 4 years ago
In the 2020
version I took a simpler approach. It helps that it's purely python3
, so it simplifies the function as well :)
My approach: check if it has the attribute of identifier
(which is the official property that should be accessed, _identifier
exists under the hood, if I recall correctly).
See:
identifier
)Ah was not aware that there was a "2020" version that included refactoring. Perhaps good to call that out somewhere (and get rid of stale branches on GitHub?).
I still think it's safer to check the type than using hasattr
.
Currently the first line in the most inner loop of process
is an instantiation of Item
. With that said, I agree that your suggestion is safer for maintainability reasons.
Really a bad idea. Just do a type check on the
url_pattern
to see if it's an instance ofResource
(orItem
if you want to be precise), and then take the_identifier
property. Alternatively: override the__str__
method in the class definition ofItem
.https://github.com/CLARIAH/COW/blob/83fc6de665a6104a92914899c2e887b8658736b0/src/converter/csvw.py#L750