comparison libervia/backend/plugins/plugin_misc_uri_finder.py @ 4334:111dce64dcb5

plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic: Pydantic models are used more and more in Libervia, for the bridge API, and also to convert `domish.Element` to internal representation. Type hints have also been added in many places. rel 453
author Goffi <goffi@goffi.org>
date Tue, 03 Dec 2024 00:12:38 +0100
parents e0ae6ca806ba
children
comparison
equal deleted inserted replaced
4333:e94799a0908f 4334:111dce64dcb5
72 @param keys(list[unicode]): keys lookeds after 72 @param keys(list[unicode]): keys lookeds after
73 e.g.: "tickets", "merge-requests" 73 e.g.: "tickets", "merge-requests"
74 @return (dict[unicode, unicode]): map from key to found uri 74 @return (dict[unicode, unicode]): map from key to found uri
75 """ 75 """
76 keys_re = "|".join(keys) 76 keys_re = "|".join(keys)
77 label_re = r'\"(?P<label>[^\"]+)\"' 77 label_re = r"\"(?P<label>[^\"]+)\""
78 uri_re = re.compile( 78 uri_re = re.compile(
79 r"(?P<key>{keys_re})[ :]? +(?P<uri>xmpp:\S+)(?:.*use {label_re} label)?".format( 79 r"(?P<key>{keys_re})[ :]? +(?P<uri>xmpp:\S+)(?:.*use {label_re} label)?".format(
80 keys_re=keys_re, label_re=label_re 80 keys_re=keys_re, label_re=label_re
81 ), 81 ),
82 re.IGNORECASE 82 re.IGNORECASE,
83 ) 83 )
84 path = os.path.normpath(path) 84 path = os.path.normpath(path)
85 if not os.path.isdir(path) or not os.path.isabs(path): 85 if not os.path.isdir(path) or not os.path.isabs(path):
86 raise ValueError("path must be an absolute path to a directory") 86 raise ValueError("path must be an absolute path to a directory")
87 87