Changeset - a61b74308faf
[Not reviewed]
0 1 0
Brett Smith - 4 years ago 2020-03-25 04:13:18
brettcsmith@brettcsmith.org
rtutil: Make RT.parse a classmethod.

Because it works, and I can imagine it being useful to have this
method more handy to other code.
1 file changed with 3 insertions and 2 deletions:
0 comments (0 inline, 0 general)
conservancy_beancount/rtutil.py
Show inline comments
...
 
@@ -91,26 +91,27 @@ class RT:
 
                    attachment_id,
 
                    mimetypes.guess_extension(mimetype) or '.bin',
 
                )
 
            path_tail = 'Ticket/Attachment/{0[Transaction]}/{0[id]}/{1}'.format(
 
                attachment,
 
                filename,
 
            )
 
            return self._extend_url(path_tail)
 

	
 
    def exists(self, ticket_id: RTId, attachment_id: Optional[RTId]=None) -> bool:
 
        return self.url(ticket_id, attachment_id) is not None
 

	
 
    def parse(self, s: str) -> Optional[Tuple[str, Optional[str]]]:
 
        for regexp in self.PARSE_REGEXPS:
 
    @classmethod
 
    def parse(cls, s: str) -> Optional[Tuple[str, Optional[str]]]:
 
        for regexp in cls.PARSE_REGEXPS:
 
            match = regexp.match(s)
 
            if match is not None:
 
                ticket_id, attachment_id = match.groups()
 
                return (ticket_id, attachment_id)
 
        return None
 

	
 
    @functools.lru_cache()
 
    def ticket_url(self, ticket_id: RTId) -> Optional[str]:
 
        if self.rt.get_ticket(ticket_id) is None:
 
            return None
 
        return self._ticket_url(ticket_id)
 

	
0 comments (0 inline, 0 general)