def parse(cls, guid, match=True, media=None, strict=False): if not guid: return None # Parse Guid URI agent_name, uri = urlparse(guid) if not agent_name or not uri or not uri.netloc: return None # Construct `Guid` object result = Guid(uri.netloc, uri.query) # Match guid with agent, fill with details if match and cls.match(agent_name, result, uri, media): return result if strict: return None # No agent matching enabled, basic fill result.service = agent_name[agent_name.rfind('.') + 1:] result.id = uri.netloc return result
def parse(cls, guid, match=True, media=None, strict=False): if not guid: return cls(invalid=True, original=guid) # Parse Guid URI agent_id, uri = urlparse(guid) if not agent_id or not uri or not uri.netloc: return cls(invalid=True, agent_id=agent_id, original=guid) # Construct `Guid` object result = cls(uri.netloc, extra=uri.query, agent_id=agent_id, original=guid) # Match guid with agent, fill with details if match and cls.match(agent_id, result, uri, media): result.matched = True return result if strict: return result # No agent matching enabled, automatically match guid parameters log.warn( 'Unable to find agent mapping for %s://%s, result may be incorrect', agent_id, uri.netloc) result.service = agent_id[agent_id.rfind('.') + 1:] result.id = uri.netloc return result
def _valid(guid): if not guid: return False agent, uri = urlparse(guid) if agent in ['local', 'none']: return False return True
def _valid(guid): if not guid: return False agent, uri = urlparse(guid) if agent in ["local", "none"]: return False return True
def parse(cls, guid, map=True): if not guid: return None agent, uri = urlparse(guid) result = Guid(agent, uri.netloc, uri.query) # Nothing more to parse, return now if uri.path: cls.parse_path(result, uri) if map: return cls.map_guid(result) return result
def parse(cls, guid, match=True, media=None, strict=False): if not guid: return cls( invalid=True, original=guid ) # Parse Guid URI agent_id, uri = urlparse(guid) if not agent_id or not uri or not uri.netloc: return cls( invalid=True, agent_id=agent_id, original=guid ) # Construct `Guid` object result = cls( uri.netloc, extra=uri.query, agent_id=agent_id, original=guid ) # Match guid with agent, fill with details if match and cls.match(agent_id, result, uri, media): result.matched = True return result if strict: return result # No agent matching enabled, automatically match guid parameters log.warn('Unable to find agent mapping for %s://%s, result may be incorrect', agent_id, uri.netloc) result.service = agent_id[agent_id.rfind('.') + 1:] result.id = uri.netloc return result