1 from ...types import serializable
2 from ...util import none_or
4 from .util import consume_tags
7 class Contributor(serializable.Type):
11 __slots__ = ('id', 'user_text')
14 'id': lambda e: int(e.text),
15 'username': lambda e: str(e.text),
16 'ip': lambda e: str(e.text)
19 def __init__(self, id, user_text):
20 self.id = none_or(id, int)
22 User ID : int | `None` (if not specified in the XML)
24 User ID of a user if the contributor is signed into an account
25 in the while making the contribution and `None` when
26 contributors are not signed in.
29 self.user_text = none_or(user_text, str)
31 User name or IP address : str | `None` (if not specified in the XML)
33 If a user is logged in, this will reflect the users accout
34 name. If the user is not logged in, this will usually be
35 recorded as the IPv4 or IPv6 address in the XML.
39 def from_element(cls, element):
40 values = consume_tags(cls.TAG_MAP, element)
44 values.get('username', values.get('ip'))