@@ -810,61 +810,77 @@ expansions happen with the normal rules. If it's a URI, it tries to standardize
810810.. code-block :: python
811811
812812 from curies import Converter, Record
813- converter = Converter.from_extended_prefix_map([
814- Record(
815- prefix = " CHEBI" ,
816- prefix_synonyms = [" chebi" ],
817- uri_prefix = " http://purl.obolibrary.org/obo/CHEBI_" ,
818- uri_prefix_synonyms = [" https://identifiers.org/chebi:" ],
819- ),
820- ])
813+
814+ converter = Converter.from_extended_prefix_map(
815+ [
816+ Record(
817+ prefix = " CHEBI" ,
818+ prefix_synonyms = [" chebi" ],
819+ uri_prefix = " http://purl.obolibrary.org/obo/CHEBI_" ,
820+ uri_prefix_synonyms = [" https://identifiers.org/chebi:" ],
821+ ),
822+ ]
823+ )
821824
822825 # Expand CURIEs
823- >> > converter.expand_or_standardize(" CHEBI:138488" )
824- ' http://purl.obolibrary.org/obo/CHEBI_138488'
825- >> > converter.expand_or_standardize(" chebi:138488" )
826- ' http://purl.obolibrary.org/obo/CHEBI_138488'
826+ assert (
827+ converter.expand_or_standardize(" CHEBI:138488" )
828+ == " http://purl.obolibrary.org/obo/CHEBI_138488"
829+ )
830+ assert (
831+ converter.expand_or_standardize(" chebi:138488" )
832+ == " http://purl.obolibrary.org/obo/CHEBI_138488"
833+ )
827834
828835 # standardize URIs
829- >> > converter.expand_or_standardize(" http://purl.obolibrary.org/obo/CHEBI_138488" )
830- ' http://purl.obolibrary.org/obo/CHEBI_138488'
831- >> > converter.expand_or_standardize(" https://identifiers.org/chebi:138488" )
832- ' http://purl.obolibrary.org/obo/CHEBI_138488'
836+ assert (
837+ converter.expand_or_standardize(" http://purl.obolibrary.org/obo/CHEBI_138488" )
838+ == " http://purl.obolibrary.org/obo/CHEBI_138488"
839+ )
840+ assert (
841+ converter.expand_or_standardize(" https://identifiers.org/chebi:138488" )
842+ == " http://purl.obolibrary.org/obo/CHEBI_138488"
843+ )
833844
834845 # Handle cases that aren't valid w.r.t. the converter
835- >> > converter.expand_or_standardize(" missing:0000000" )
836- >> > converter.expand_or_standardize(" https://example.com/missing:0000000" )
846+ assert converter.expand_or_standardize(" missing:0000000" ) is None
847+ assert converter.expand_or_standardize(" https://example.com/missing:0000000" ) is None
837848
838849 A similar workflow is implemented in :meth: `curies.Converter.compress_or_standardize `
839850for compressing URIs where a CURIE might get passed.
840851
841852.. code-block :: python
842853
843854 from curies import Converter, Record
844- converter = Converter.from_extended_prefix_map([
845- Record(
846- prefix = " CHEBI" ,
847- prefix_synonyms = [" chebi" ],
848- uri_prefix = " http://purl.obolibrary.org/obo/CHEBI_" ,
849- uri_prefix_synonyms = [" https://identifiers.org/chebi:" ],
850- ),
851- ])
855+
856+ converter = Converter.from_extended_prefix_map(
857+ [
858+ Record(
859+ prefix = " CHEBI" ,
860+ prefix_synonyms = [" chebi" ],
861+ uri_prefix = " http://purl.obolibrary.org/obo/CHEBI_" ,
862+ uri_prefix_synonyms = [" https://identifiers.org/chebi:" ],
863+ ),
864+ ]
865+ )
852866
853867 # Compress URIs
854- >> > converter.compress_or_standardize(" http://purl.obolibrary.org/obo/CHEBI_138488" )
855- ' CHEBI:138488'
856- >> > converter.compress_or_standardize(" https://identifiers.org/chebi:138488" )
857- ' CHEBI:138488'
868+ assert (
869+ converter.compress_or_standardize(" http://purl.obolibrary.org/obo/CHEBI_138488" )
870+ == " CHEBI:138488"
871+ )
872+ assert (
873+ converter.compress_or_standardize(" https://identifiers.org/chebi:138488" )
874+ == " CHEBI:138488"
875+ )
858876
859877 # standardize CURIEs
860- >> > converter.compress_or_standardize(" CHEBI:138488" )
861- ' CHEBI:138488'
862- >> > converter.compress_or_standardize(" chebi:138488" )
863- ' CHEBI:138488'
878+ assert converter.compress_or_standardize(" CHEBI:138488" ) == " CHEBI:138488"
879+ assert converter.compress_or_standardize(" chebi:138488" ) == " CHEBI:138488"
864880
865881 # Handle cases that aren't valid w.r.t. the converter
866- >> > converter.compress_or_standardize(" missing:0000000" )
867- >> > converter.compress_or_standardize(" https://example.com/missing:0000000" )
882+ assert converter.compress_or_standardize(" missing:0000000" ) is None
883+ assert converter.compress_or_standardize(" https://example.com/missing:0000000" ) is None
868884
869885 Reusable data structures for references
870886=======================================
@@ -892,7 +908,7 @@ RDFlib is a pure Python package for manipulating RDF data. The following example
892908how to bind the extended prefix map from a :class: `curies.Converter ` to a graph
893909(:class: `rdflib.Graph `).
894910
895- .. code-block ::
911+ .. code-block :: python
896912
897913 import curies, rdflib
898914
@@ -903,7 +919,7 @@ how to bind the extended prefix map from a :class:`curies.Converter` to a graph
903919 A more flexible approach is to instantiate a namespace manager
904920(:class: `rdflib.namespace.NamespaceManager `) and bind directly to that.
905921
906- .. code-block ::
922+ .. code-block :: python
907923
908924 import curies, rdflib.namespace
909925
@@ -914,7 +930,7 @@ A more flexible approach is to instantiate a namespace manager
914930 URI references for use in RDFLib's graph class can be constructed from CURIEs using a
915931combination of :meth: `curies.Converter.expand ` and :class: `rdflib.URIRef `.
916932
917- .. code-block ::
933+ .. code-block :: python
918934
919935 import curies, rdflib
920936
0 commit comments