MCPcopy Create free account
hub / github.com/andreikop/python-ws-discovery / matchScope

Function matchScope

wsdiscovery/util.py:155–185  ·  view source on GitHub ↗
(src, target, matchBy)

Source from the content-addressed store, hash-verified

153
154
155def matchScope(src, target, matchBy):
156
157 MATCH_BY_LDAP = "http://schemas.xmlsoap.org/ws/2005/04/discovery/ldap"
158 MATCH_BY_URI = "http://schemas.xmlsoap.org/ws/2005/04/discovery/rfc2396"
159 MATCH_BY_UUID = "http://schemas.xmlsoap.org/ws/2005/04/discovery/uuid"
160 MATCH_BY_STRCMP = "http://schemas.xmlsoap.org/ws/2005/04/discovery/strcmp0"
161
162 if matchBy == "" or matchBy == None or matchBy == MATCH_BY_LDAP or matchBy == MATCH_BY_URI or matchBy == MATCH_BY_UUID:
163 src = URI(src)
164 target = URI(target)
165 if src.getScheme().lower() != target.getScheme().lower():
166 return False
167 if src.getAuthority().lower() != target.getAuthority().lower():
168 return False
169 srcPath = src.getPathExQueryFragment()
170 targetPath = target.getPathExQueryFragment()
171 if srcPath == targetPath:
172 return True
173 elif targetPath.startswith(srcPath):
174 n = len(srcPath)
175 if targetPath[n - 1] == srcPath[n - 1] == '/':
176 return True
177 if targetPath[n] == '/':
178 return True
179 return False
180 else:
181 return False
182 elif matchBy == MATCH_BY_STRCMP:
183 return src == target
184 else:
185 return False
186
187
188def isTypeInList(ttype, types):

Callers 1

isScopeInListFunction · 0.85

Calls 4

getSchemeMethod · 0.95
getAuthorityMethod · 0.95
URIClass · 0.85

Tested by

no test coverage detected