File: compare_schemas.py

package info (click to toggle)
rudof 0.1.146%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 10,048 kB
  • sloc: python: 1,288; makefile: 32; sh: 1
file content (43 lines) | stat: -rw-r--r-- 897 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from pyrudof import Rudof, RudofConfig, ShExFormatter, 

rudof = Rudof(RudofConfig())

schema1 = """
 PREFIX : <http://example.org/>
 PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
 :Person {
    :name xsd:string ;
    :age xsd:integer ;
    :weight xsd:float ;
    :worksFor @:Company
 } 
 :Company {
    :name xsd:string ;
    :employee @:Person
 }"""

# rudof.read_data_str(schema1)

schema2 = """
 PREFIX ex: <http://example.org/> 
 PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
 ex:Person {
    ex:name xsd:string ;
    ex:birthDate xsd:date ;
    ex:worksFor @ex:Company
}
ex:Company {
   ex:name xsd:string
}
"""
print("Comparing schemas:");
result = result = rudof.compare_schemas_str(
    schema1, schema2, 
    "shex", "shex", 
    "shexc", "shexc", 
    None, None, 
    "http://example.org/Person", "http://example.org/Person",

    )

print(f"Schemas compared: {result.as_json()}")