arcp.parse

Parse arcp URIs.

Use is_arcp_uri() to detect of an URI string is using the arcp: URI scheme, in which case parse_arcp() can be used to split it into its components.

The urlparse() function can be used as a replacement for urllib.parse.urlparse() - supporting any URIs. If the URI is using the arcp: URI scheme, additional components are available as from parse_arcp().

class arcp.parse.ARCPParseResult(*args)[source]

Result of parsing an arcp URI.

This class does not detect if the arcp URI was valid according to the specification.

This class extends urlllib.parse.ParseResult adding arcp properties, some of which may be None.

hash

A tuple (hash_method,hash_hex) if the prefix is “ni”, otherwise None.

name

The URI’s authority without arcp prefix.

ni

The arcp ni string if the prefix is “ni”, otherwise None.

ni_uri(authority='')[source]

The ni URI (RFC6920) if the prefix is “ni”, otherwise None.

If the authority parameter is provided, it will be used in the returned URI.

ni_well_known(base='')[source]

The ni .well-known URI (RFC5785) if the prefix is “ni”, otherwise None.

The parameter base, if provided, should be an absolute URI like "http://example.com/" - a relative URI is returned otherwise.

nih_uri()[source]

The nih URI (RFC6920) if the prefix is “ni”, otherwise None.

prefix

The arcp prefix, e.g. “uuid”, “ni”, “name” or None if no prefix was present.

uuid

The arcp UUID if the prefix is “uuid”, otherwise None.

arcp.parse.is_arcp_uri(uri)[source]

Return True if the uri string uses the arcp scheme, otherwise False.

arcp.parse.parse_arcp(uri)[source]

Parse an arcp URI string into its constituent parts.

The returned object is similar to urllib.parse.urlparse() in that it is a tuple of (scheme,netloc,path,params,query,fragment) with equally named properties, but it also adds properties for arcp fields:

  • prefix – arcp authority prefix, e.g. “uuid”, “ni” or “name”, or None if prefix is missing
  • name – arcp authority without prefix, e.g. “a4889890-a50a-4f14-b4e7-5fd83683a2b5” or “example.com”
  • uuid – a uuid.UUID object if prefix is “uuid”, otherwise None
  • ni – the arcp alg-val value according to RFC6920 if prefix is “ni”, otherwise None
  • hash – the hash method and hash as a hexstring if prefix is “ni”, otherwise None
arcp.parse.urlparse(uri)[source]

Parse any URI string into constituent parts.

The returned object is similar to urllib.parse.urlparse() in that it is a tuple of (scheme,netloc,path,params,query,fragment) with equally named properties, but if the URI scheme is “arcp” this also adds arcp properties as in parse_arcp().