@@ -118,7 +118,12 @@ impl PyRudof {
118
118
shex_schema. map ( |s| PyShExSchema { inner : s. clone ( ) } )
119
119
}
120
120
121
- /// Obtains the current ShEx Schema
121
+ /// Compares two schemas provided as strings
122
+ /// Parameters: schema1, schema2: Strings containing the schemas to compare
123
+ /// mode1, mode2: Mode of the schemas, e.g. shex
124
+ /// format1, format2: Format of the schemas, e.g. shexc, turtle
125
+ /// label1, label2: Optional labels of the shapes to compare
126
+ /// base1, base2: Optional base IRIs to resolve relative IRIs in the schemas
122
127
#[ pyo3( signature = ( schema1, schema2, mode1, mode2, format1, format2, label1, label2, base1, base2) ) ]
123
128
pub fn compare_schemas_str (
124
129
& mut self ,
@@ -761,18 +766,21 @@ pub enum PyUmlGenerationMode {
761
766
PyNeighs { node : String } ,
762
767
}
763
768
769
+ /// UML Generation Mode
764
770
#[ pymethods]
765
771
impl PyUmlGenerationMode {
766
772
#[ new]
767
773
pub fn __init__ ( py : Python < ' _ > ) -> Self {
768
774
py. detach ( || PyUmlGenerationMode :: PyAllNodes { } )
769
775
}
770
776
777
+ /// Show all nodes
771
778
#[ staticmethod]
772
779
pub fn all ( ) -> Self {
773
780
PyUmlGenerationMode :: PyAllNodes { }
774
781
}
775
782
783
+ /// Show only the neighbours of a given node
776
784
#[ staticmethod]
777
785
pub fn neighs ( node : & str ) -> Self {
778
786
PyUmlGenerationMode :: PyNeighs {
@@ -804,13 +812,24 @@ pub struct PyShExSchema {
804
812
inner : ShExSchema ,
805
813
}
806
814
815
+ /// ShEx Schema representation
807
816
#[ pymethods]
808
817
impl PyShExSchema {
809
818
pub fn __repr__ ( & self ) -> String {
810
819
format ! ( "{}" , self . inner)
811
820
}
821
+
822
+ /* /// Converts the schema to JSON
823
+ pub fn as_json(&self) -> PyResult<String> {
824
+ let str = self
825
+ .inner
826
+ .as_json()
827
+ .map_err(|e| PyRudofError::str(e.to_string()))?;
828
+ Ok(str)
829
+ } */
812
830
}
813
831
832
+ /// DCTAP representation
814
833
#[ pyclass( name = "DCTAP" ) ]
815
834
pub struct PyDCTAP {
816
835
inner : DCTAP ,
@@ -827,6 +846,8 @@ impl PyDCTAP {
827
846
}
828
847
}
829
848
849
+ /// ShapeMap used for querying and validation
850
+ /// It can be converted to JSON
830
851
#[ pyclass( name = "QueryShapeMap" ) ]
831
852
pub struct PyQueryShapeMap {
832
853
inner : QueryShapeMap ,
@@ -837,21 +858,31 @@ impl PyQueryShapeMap {
837
858
fn __repr__ ( & self ) -> String {
838
859
format ! ( "{}" , self . inner)
839
860
}
861
+
862
+ /*pub fn as_json(&self) -> PyResult<String> {
863
+ let str = self
864
+ .inner
865
+ .as_json()
866
+ .map_err(|e| PyRudofError::str(e.to_string()))?;
867
+ Ok(str)
868
+ }*/
840
869
}
841
870
842
871
/// Shapes Comparator result
872
+ /// It contains the differences between two schemas
873
+ /// It can be converted to JSON
843
874
#[ pyclass( name = "ShaCo" ) ]
844
875
pub struct PyShaCo {
845
876
inner : ShaCo ,
846
877
}
847
878
848
879
#[ pymethods]
849
880
impl PyShaCo {
850
- fn __repr__ ( & self ) -> String {
881
+ pub fn __repr__ ( & self ) -> String {
851
882
format ! ( "{}" , self . inner)
852
883
}
853
884
854
- fn as_json ( & self ) -> PyResult < String > {
885
+ pub fn as_json ( & self ) -> PyResult < String > {
855
886
let str = self
856
887
. inner
857
888
. as_json ( )
@@ -868,9 +899,27 @@ pub struct PyCompareSchemaFormat {
868
899
869
900
#[ pymethods]
870
901
impl PyCompareSchemaFormat {
871
- fn __repr__ ( & self ) -> String {
902
+ pub fn __repr__ ( & self ) -> String {
872
903
format ! ( "{}" , self . inner)
873
904
}
905
+
906
+ pub fn __str__ ( & self ) -> String {
907
+ format ! ( "{}" , self . inner)
908
+ }
909
+
910
+ #[ staticmethod]
911
+ pub fn shexc ( ) -> Self {
912
+ Self {
913
+ inner : CompareSchemaFormat :: ShExC ,
914
+ }
915
+ }
916
+
917
+ #[ staticmethod]
918
+ pub fn turtle ( ) -> Self {
919
+ Self {
920
+ inner : CompareSchemaFormat :: Turtle ,
921
+ }
922
+ }
874
923
}
875
924
876
925
/// Mode of schema to compare, e.g. shex, ...
@@ -881,9 +930,20 @@ pub struct PyCompareSchemaMode {
881
930
882
931
#[ pymethods]
883
932
impl PyCompareSchemaMode {
884
- fn __repr__ ( & self ) -> String {
933
+ pub fn __repr__ ( & self ) -> String {
934
+ format ! ( "{}" , self . inner)
935
+ }
936
+
937
+ pub fn __str__ ( & self ) -> String {
885
938
format ! ( "{}" , self . inner)
886
939
}
940
+
941
+ #[ staticmethod]
942
+ pub fn shex ( ) -> Self {
943
+ Self {
944
+ inner : CompareSchemaMode :: ShEx ,
945
+ }
946
+ }
887
947
}
888
948
889
949
#[ pyclass( name = "ShaclSchema" ) ]
0 commit comments