コード例 #1
0
 def get(self):
     """Implement GET for Source Description."""
     source_description = SourceDescription()
     source_description.describedby = self.source.describedby_uri
     source_description.add_capability_list(self.source.capability_list_uri)
     self.set_header("Content-Type", "application/xml")
     self.write(source_description.as_xml())
コード例 #2
0
ファイル: http.py プロジェクト: resync/resync-simulator
 def get(self):
     """Implement GET for Source Description."""
     source_description = SourceDescription()
     source_description.describedby = self.source.describedby_uri
     source_description.add_capability_list(self.source.capability_list_uri)
     self.set_header("Content-Type", "application/xml")
     self.write(source_description.as_xml())
コード例 #3
0
 def test02_one_caplist(self):
     rsd = SourceDescription()
     rsd.describedby = "http://example.org/about"
     self.assertEqual( len(rsd), 0 )
     rsd.md_at = None
     rsd.add_capability_list("http://example.org/ds1/cl.xml")
     self.assertEqual( len(rsd), 1 )
     self.assertEqual( rsd.as_xml(), '<?xml version=\'1.0\' encoding=\'UTF-8\'?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:rs="http://www.openarchives.org/rs/terms/"><rs:ln href="http://example.org/about" rel="describedby" /><rs:md capability="description" /><url><loc>http://example.org/ds1/cl.xml</loc><rs:md capability="capabilitylist" /></url></urlset>' )
コード例 #4
0
ファイル: client.py プロジェクト: EHRI/resync
 def write_source_description(self,capability_lists=None,outfile=None,links=None):
     """Write a ResourceSync Description document to outfile or STDOUT"""
     rsd = SourceDescription(ln=links)
     rsd.pretty_xml = self.pretty_xml
     if (capability_lists is not None):
         for uri in capability_lists:
             rsd.add_capability_list(uri)
     if (outfile is None):
         print rsd.as_xml()
     else:
         rsd.write(basename=outfile)
コード例 #5
0
 def write_source_description(self,
                              capability_lists=None,
                              outfile=None,
                              links=None):
     """Write a ResourceSync Description document to outfile or STDOUT"""
     rsd = SourceDescription(ln=links)
     rsd.pretty_xml = self.pretty_xml
     if (capability_lists is not None):
         for uri in capability_lists:
             rsd.add_capability_list(uri)
     if (outfile is None):
         print rsd.as_xml()
     else:
         rsd.write(basename=outfile)
コード例 #6
0
 def test_build_ex_12(self):
     """Source Description document with describedby links"""
     sd = SourceDescription()
     sd.describedby = 'http://example.com/info_about_source.xml'
     cl1 = CapabilityList( uri='http://example.com/capabilitylist1.xml' )
     cl1.describedby = 'http://example.com/info_about_set1_of_resources.xml'
     sd.add_capability_list( cl1 )
     cl2 = CapabilityList( uri='http://example.com/capabilitylist2.xml' )
     cl2.describedby = 'http://example.com/info_about_set2_of_resources.xml'
     sd.add_capability_list( cl2 )
     cl3 = CapabilityList( uri='http://example.com/capabilitylist3.xml' )
     cl3.describedby = 'http://example.com/info_about_set3_of_resources.xml'
     sd.add_capability_list( cl3 )
     ex_xml = self._open_ex('resourcesync_ex_12').read()
     self._assert_xml_equal( sd.as_xml(), ex_xml )
コード例 #7
0
# Print to file at args.resource_dir + "/resource-list.xml"
resource_list_file = open(args.resource_dir + "/resource-list.xml", "w")
resource_list_file.write(rl.as_xml())
resource_list_file.close()
print "Wrote resource list to: " + args.resource_dir + "/resource-list.xml"

timestamps.sort()

caps = CapabilityList()
caps.add_capability(rl, args.resource_url + "resource-list.xml")
if len(timestamps) > 0:
	caps.md['from'] = timestamps[0]

# Print to file at args.resource_dir + "/capability-list.xml"
capability_list_file = open(args.resource_dir + "/capability-list.xml", "w")
capability_list_file.write(caps.as_xml())
capability_list_file.close()

print "Wrote capability list to: " + args.resource_dir + "/capability-list.xml"

rsd = SourceDescription()
rsd.md_at = None
rsd.add_capability_list(args.resource_url + "capability-list.xml")

# Print to file at args.resource_dir + "/resourcesync"
source_description_file = open(args.resource_dir + "/resourcesync", "w")
source_description_file.write(rsd.as_xml())
source_description_file.close()

print "Wrote source description to: " + args.resource_dir + "/resourcesync"
コード例 #8
0
# Print to file at args.resource_dir + "/resource-list.xml"
resource_list_file = open(args.resource_dir + "/resource-list.xml", "w")
resource_list_file.write(rl.as_xml())
resource_list_file.close()
print "Wrote resource list to: " + args.resource_dir + "/resource-list.xml"

timestamps.sort()

caps = CapabilityList()
caps.add_capability(rl, args.resource_url + "resource-list.xml")
if len(timestamps) > 0:
    caps.md['from'] = timestamps[0]

# Print to file at args.resource_dir + "/capability-list.xml"
capability_list_file = open(args.resource_dir + "/capability-list.xml", "w")
capability_list_file.write(caps.as_xml())
capability_list_file.close()

print "Wrote capability list to: " + args.resource_dir + "/capability-list.xml"

rsd = SourceDescription()
rsd.md_at = None
rsd.add_capability_list(args.resource_url + "capability-list.xml")

# Print to file at args.resource_dir + "/resourcesync"
source_description_file = open(args.resource_dir + "/resourcesync", "w")
source_description_file.write(rsd.as_xml())
source_description_file.close()

print "Wrote source description to: " + args.resource_dir + "/resourcesync"