當前位置: 首頁>>代碼示例>>Python>>正文


Python ChangeList.as_xml方法代碼示例

本文整理匯總了Python中resync.change_list.ChangeList.as_xml方法的典型用法代碼示例。如果您正苦於以下問題:Python ChangeList.as_xml方法的具體用法?Python ChangeList.as_xml怎麽用?Python ChangeList.as_xml使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在resync.change_list.ChangeList的用法示例。


在下文中一共展示了ChangeList.as_xml方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: write_change_list

# 需要導入模塊: from resync.change_list import ChangeList [as 別名]
# 或者: from resync.change_list.ChangeList import as_xml [as 別名]
 def write_change_list(self,outfile=None,ref_sitemap=None,newref_sitemap=None,
                       empty=None,links=None,dump=None):
     cl = ChangeList(ln=links)
     if (not empty):
         # 1. Get and parse reference sitemap
         old_rl = self.read_reference_resource_list(ref_sitemap)
         # 2. Depending on whether a newref_sitemap was specified, either read that 
         # or build resource_list from files on disk
         if (newref_sitemap is None):
             # Get resource list from disk
             new_rl = self.resource_list
         else:
             new_rl = self.read_reference_resource_list(newref_sitemap,name='new reference')
         # 3. Calculate change list
         (same,updated,deleted,created)=old_rl.compare(new_rl)   
         cl.add_changed_resources( updated, change='updated' )
         cl.add_changed_resources( deleted, change='deleted' )
         cl.add_changed_resources( created, change='created' )
     # 4. Write out change list
     kwargs = { 'pretty_xml': True,
                'mapper' : self.mapper }
     if (self.max_sitemap_entries is not None):
         kwargs['max_sitemap_entries'] = self.max_sitemap_entries
     if (outfile is None):
         print cl.as_xml(**kwargs)
     else:
         cl.write(basename=outfile,**kwargs)
     self.write_dump_if_requested(cl,dump)
開發者ID:semantalytics,項目名稱:resync,代碼行數:30,代碼來源:client.py

示例2: write_change_list

# 需要導入模塊: from resync.change_list import ChangeList [as 別名]
# 或者: from resync.change_list.ChangeList import as_xml [as 別名]
 def write_change_list(self,paths=None,outfile=None,ref_sitemap=None,newref_sitemap=None,
                       empty=None,links=None,dump=None):
     """Write a change list
     
     Unless the both ref_sitemap and newref_sitemap are specified then the Change 
     List is calculated between the reference an the current state of files on
     disk. The files on disk are scanned based either on the paths setting or
     else on the mappings.
     """
     cl = ChangeList(ln=links)
     if (not empty):
         # 1. Get and parse reference sitemap
         old_rl = self.read_reference_resource_list(ref_sitemap)
         # 2. Depending on whether a newref_sitemap was specified, either read that 
         # or build resource list from files on disk
         if (newref_sitemap is None):
             # Get resource list from disk
             new_rl = self.build_resource_list(paths=paths,set_path=dump)
         else:
             new_rl = self.read_reference_resource_list(newref_sitemap,name='new reference')
         # 3. Calculate change list
         (same,updated,deleted,created)=old_rl.compare(new_rl)   
         cl.add_changed_resources( updated, change='updated' )
         cl.add_changed_resources( deleted, change='deleted' )
         cl.add_changed_resources( created, change='created' )
     # 4. Write out change list
     cl.mapper = self.mapper
     cl.pretty_xml = self.pretty_xml
     if (self.max_sitemap_entries is not None):
         cl.max_sitemap_entries = self.max_sitemap_entries
     if (outfile is None):
         print cl.as_xml()
     else:
         cl.write(basename=outfile)
     self.write_dump_if_requested(cl,dump)
開發者ID:EHRI,項目名稱:resync,代碼行數:37,代碼來源:client.py

示例3: test_build_ex_28

# 需要導入模塊: from resync.change_list import ChangeList [as 別名]
# 或者: from resync.change_list.ChangeList import as_xml [as 別名]
 def test_build_ex_28(self):
     cl = ChangeList()
     cl.up = "http://example.com/dataset1/capabilitylist.xml"
     cl.md_from = "2013-01-03T00:00:00Z"
     c1 = Resource(uri="http://example.com/res2.pdf",
                   lastmod="2013-01-03T18:00:00Z",
                   change="updated",
                   md5="1584abdf8ebdc9802ac0c6a7402c03b6",
                   length=8876,
                   mime_type="application/pdf" )
     c1.link_set(rel="describedby",
                 href="http://example.com/res2_dublin-core_metadata.xml",
                 modified="2013-01-01T12:00:00Z",
                 type="application/xml")
     c2 = Resource(uri="http://example.com/res2_dublin-core_metadata.xml",
                   lastmod="2013-01-03T19:00:00Z",
                   change="updated",
                   mime_type="application/xml")
     c2.link_set(rel="describes",
                 href="http://example.com/res2.pdf",
                 modified="2013-01-03T18:00:00Z",
                 hash="md5:1584abdf8ebdc9802ac0c6a7402c03b6",
                 length="8876",
                 type="application/pdf")
     c2.link_set(rel="profile",
                 href="http://purl.org/dc/elements/1.1/")
     cl.add( [c1,c2] )
     self._assert_xml_equal_ex( cl.as_xml(), 'resourcesync_ex_28' )
開發者ID:,項目名稱:,代碼行數:30,代碼來源:

示例4: test_build_ex_27

# 需要導入模塊: from resync.change_list import ChangeList [as 別名]
# 或者: from resync.change_list.ChangeList import as_xml [as 別名]
 def test_build_ex_27(self):
     cl = ChangeList()
     cl.up = "http://example.com/dataset1/capabilitylist.xml"
     cl.md_from = "2013-01-03T00:00:00Z"
     c1 = Resource(uri="http://example.com/res4",
                   lastmod="2013-01-03T17:00:00Z",
                   change="updated",
                   sha256="f4OxZX_x_DFGFDgghgdfb6rtSx-iosjf6735432nklj",
                   length=56778,
                   mime_type="application/json" )
     c1.link_set(rel="http://www.openarchives.org/rs/terms/patch",
                 href="http://example.com/res4-json-patch",
                 modified="2013-01-03T17:00:00Z",
                 hash="sha-256:y66dER_t_HWEIKpesdkeb7rtSc-ippjf9823742opld", #FIXME - inconsistent
                 length=73,
                 type="application/json-patch")
     c2 = Resource(uri="http://example.com/res5-full.tiff",
                   lastmod="2013-01-03T18:00:00Z",
                   change="updated",
                   sha256="f4OxZX_x_FO5LcGBSKHWXfwtSx-j1ncoSt3SABJtkGk",
                   length="9788456778",
                   mime_type="image/tiff")
     c2.link_set(rel="http://www.openarchives.org/rs/terms/patch",
                 href="http://example.com/res5-diff",
                 modified="2013-01-03T18:00:00Z",
                 hash="sha-256:h986gT_t_87HTkjHYE76G558hY-jdfgy76t55sadJUYT",
                 length=4533,
                 type="application/x-tiff-diff" )
     cl.add( [c1,c2] )
     self._assert_xml_equal_ex( cl.as_xml(), 'resourcesync_ex_27' )
開發者ID:,項目名稱:,代碼行數:32,代碼來源:

示例5: test_build_ex_24

# 需要導入模塊: from resync.change_list import ChangeList [as 別名]
# 或者: from resync.change_list.ChangeList import as_xml [as 別名]
 def test_build_ex_24(self):
     cl = ChangeList()
     cl.up = "http://example.com/dataset1/capabilitylist.xml"
     cl.md_from = "2013-01-03T00:00:00Z"
     c1 = Resource(uri="http://example.com/res1",
                   lastmod="2013-01-03T18:00:00Z",
                   change="updated",
                   md5="1584abdf8ebdc9802ac0c6a7402c03b6",
                   length=8876,
                   mime_type="text/html")
     # Resource.link_set with add or change link depending on one with 
     # the particular rel exists unless allow_duplicates=True. 
     # Resource.link_add will always add. Test both here...
     c1.link_set(rel="duplicate",
                 href="http://mirror1.example.com/res1",
                 pri="1",
                 modified="2013-01-03T18:00:00Z")
     c1.link_set(rel="duplicate",
                 href="http://mirror2.example.com/res1",
                 pri="2",
                 modified="2013-01-03T18:00:00Z",
                 allow_duplicates=True)
     c1.link_add(rel="duplicate",
                 href="gsiftp://gridftp.example.com/res1",
                 pri="3",
                 modified="2013-01-03T18:00:00Z")
     cl.add( c1 )
     self._assert_xml_equal_ex( cl.as_xml(), 'resourcesync_ex_24' )
開發者ID:,項目名稱:,代碼行數:30,代碼來源:

示例6: test07_as_xml

# 需要導入模塊: from resync.change_list import ChangeList [as 別名]
# 或者: from resync.change_list.ChangeList import as_xml [as 別名]
 def test07_as_xml(self):
     cl = ChangeList()
     cl.md_from = '1970-01-01T00:00:00Z'
     cl.add( Resource('a',timestamp=1,change='updated') )
     cl.add( Resource('b',timestamp=2,change='updated') )
     xml = cl.as_xml()
     self.assertTrue( re.search(r'<rs:md .*capability="changelist"', xml), 'XML has capability' )
     self.assertTrue( re.search(r'<rs:md .*from="\d\d\d\d\-\d\d\-\d\dT\d\d:\d\d:\d\dZ"', xml), 'XML has from to seconds precision (and not more)' )
     self.assertTrue( re.search(r'<url><loc>a</loc><lastmod>1970-01-01T00:00:01Z</lastmod>', xml), 'XML has resource a' ) 
開發者ID:,項目名稱:,代碼行數:11,代碼來源:

示例7: test_build_ex_31

# 需要導入模塊: from resync.change_list import ChangeList [as 別名]
# 或者: from resync.change_list.ChangeList import as_xml [as 別名]
 def test_build_ex_31(self):
     cl = ChangeList()
     cl.up = "http://example.com/dataset1/capabilitylist.xml"
     cl.md_from = "2013-01-03T00:00:00Z"
     c1 = Resource(uri="http://original.example.com/res1.html",
                   lastmod="2013-01-03T07:00:00Z",
                   change="updated",
                   md5="1584abdf8ebdc9802ac0c6a7402c03b6",
                   length=8876,
                   mime_type="text/html" )
     cl.add( c1 )
     self._assert_xml_equal_ex( cl.as_xml(), 'resourcesync_ex_31' )
開發者ID:,項目名稱:,代碼行數:14,代碼來源:

示例8: test_build_ex_03

# 需要導入模塊: from resync.change_list import ChangeList [as 別名]
# 或者: from resync.change_list.ChangeList import as_xml [as 別名]
 def test_build_ex_03(self):
     """Simple Change List document """
     cl = ChangeList()
     cl.md_from = '2013-01-02T00:00:00Z'
     cl.md_until= '2013-01-03T00:00:00Z'
     cl.add( Resource(uri='http://example.com/res2.pdf',
                      lastmod='2013-01-02T13:00:00Z',
                      change="updated") )
     cl.add( Resource(uri='http://example.com/res3.tiff',
                      lastmod='2013-01-02T18:00:00Z',
                      change='deleted') )
     ex_xml = self._open_ex('resourcesync_ex_3').read()
     self._assert_xml_equal( cl.as_xml(), ex_xml )
開發者ID:,項目名稱:,代碼行數:15,代碼來源:

示例9: test_build_ex_30

# 需要導入模塊: from resync.change_list import ChangeList [as 別名]
# 或者: from resync.change_list.ChangeList import as_xml [as 別名]
 def test_build_ex_30(self):
     cl = ChangeList()
     cl.up = "http://example.com/dataset1/capabilitylist.xml"
     cl.md_from = "2013-01-03T00:00:00Z"
     c1 = Resource(uri="http://example.com/res1",
                   lastmod="2013-01-03T07:00:00Z",
                   change="updated",
                   md5="1584abdf8ebdc9802ac0c6a7402c03b6",
                   length=8876,
                   mime_type="text/html" )
     c1.link_add(rel="collection",
                 href="http://example.com/aggregation/0601007")
     cl.add( c1 )
     self._assert_xml_equal_ex( cl.as_xml(), 'resourcesync_ex_30' )
開發者ID:,項目名稱:,代碼行數:16,代碼來源:

示例10: test_build_ex_26

# 需要導入模塊: from resync.change_list import ChangeList [as 別名]
# 或者: from resync.change_list.ChangeList import as_xml [as 別名]
 def test_build_ex_26(self):
     cl = ChangeList()
     cl.up = "http://example.com/dataset1/capabilitylist.xml"
     cl.md_from = "2013-01-03T00:00:00Z"
     c1 = Resource(uri="http://example.com/res1.html",
                   lastmod="2013-01-03T18:00:00Z",
                   change="updated",
                   md5="1584abdf8ebdc9802ac0c6a7402c03b6",
                   length=8876 )
     c1.link_add(rel="canonical",
                 href="http://example.com/res1",
                 modified="2013-01-03T18:00:00Z")
     cl.add( c1 )
     self._assert_xml_equal_ex( cl.as_xml(), 'resourcesync_ex_26' )
開發者ID:,項目名稱:,代碼行數:16,代碼來源:

示例11: test20_as_xml

# 需要導入模塊: from resync.change_list import ChangeList [as 別名]
# 或者: from resync.change_list.ChangeList import as_xml [as 別名]
 def test20_as_xml(self):
     cl = ChangeList()
     cl.md_from = "1970-01-01T00:00:00Z"
     cl.add(Resource("a", timestamp=1, change="updated"))
     cl.add(Resource("b", timestamp=2, change="updated"))
     xml = cl.as_xml()
     self.assertTrue(re.search(r'<rs:md .*capability="changelist"', xml), "XML has capability")
     self.assertTrue(
         re.search(r'<rs:md .*from="\d\d\d\d\-\d\d\-\d\dT\d\d:\d\d:\d\dZ"', xml),
         "XML has from to seconds precision (and not more)",
     )
     self.assertTrue(
         re.search(r"<url><loc>a</loc><lastmod>1970-01-01T00:00:01Z</lastmod>", xml), "XML has resource a"
     )
開發者ID:EHRI,項目名稱:resync,代碼行數:16,代碼來源:test_change_list.py

示例12: test_build_ex_25

# 需要導入模塊: from resync.change_list import ChangeList [as 別名]
# 或者: from resync.change_list.ChangeList import as_xml [as 別名]
 def test_build_ex_25(self):
     cl = ChangeList()
     cl.up = "http://example.com/dataset1/capabilitylist.xml"
     cl.md_from = "2013-01-03T11:00:00Z"
     c1 = Resource(uri="http://example.com/res1",
                   lastmod="2013-01-03T18:00:00Z",
                   change="updated")
     c1.link_add(rel="alternate",
                 href="http://example.com/res1.html",
                 modified="2013-01-03T18:00:00Z",
                 type="text/html") #FIXME - inconsistent
     c1.link_add(rel="alternate",
                 href="http://example.com/res1.pdf",
                 modified="2013-01-03T18:00:00Z",
                 type="application/pdf")
     cl.add( c1 )
     self._assert_xml_equal_ex( cl.as_xml(), 'resourcesync_ex_25' )
開發者ID:,項目名稱:,代碼行數:19,代碼來源:

示例13: test_build_ex_33

# 需要導入模塊: from resync.change_list import ChangeList [as 別名]
# 或者: from resync.change_list.ChangeList import as_xml [as 別名]
 def test_build_ex_33(self):
     cl = ChangeList()
     cl.up = "http://aggregator2.example.com/dataset1/capabilitylist.xml"
     cl.md_from = "2013-01-03T12:00:00Z"
     c1 = Resource(uri="http://aggregator2.example.com/res1.html",
                   lastmod="2013-01-04T09:00:00Z",
                   change="updated",
                   md5="1584abdf8ebdc9802ac0c6a7402c03b6",
                   length=8876,
                   mime_type="text/html" )
     c1.link_add(rel="via",
                 href="http://original.example.com/res1.html",
                 modified="2013-01-03T07:00:00Z",
                 hash="md5:1584abdf8ebdc9802ac0c6a7402c03b6",
                 length="8876",
                 type="text/html")
     cl.add( c1 )
     self._assert_xml_equal_ex( cl.as_xml(), 'resourcesync_ex_33' )
開發者ID:,項目名稱:,代碼行數:20,代碼來源:

示例14: test_build_ex_19

# 需要導入模塊: from resync.change_list import ChangeList [as 別名]
# 或者: from resync.change_list.ChangeList import as_xml [as 別名]
 def test_build_ex_19(self):
     """Change List with 4 changes, 'open' as no until"""
     cl = ChangeList()
     cl.up = 'http://example.com/dataset1/capabilitylist.xml'
     cl.md_from="2013-01-03T00:00:00Z"
     cl.add( Resource( uri='http://example.com/res1.html',
                       lastmod='2013-01-03T11:00:00Z',
                       change='created' ) )
     cl.add( Resource( uri='http://example.com/res2.pdf',
                       lastmod='2013-01-03T13:00:00Z',
                       change='updated' ) )
     cl.add( Resource( uri='http://example.com/res3.tiff',
                       lastmod='2013-01-03T18:00:00Z',
                       change='deleted' ) )
     cl.add( Resource( uri='http://example.com/res2.pdf',
                       lastmod='2013-01-03T21:00:00Z',
                       change='updated' ) )
     ex_xml = self._open_ex('resourcesync_ex_19').read()
     self._assert_xml_equal( cl.as_xml(), ex_xml )
開發者ID:,項目名稱:,代碼行數:21,代碼來源:

示例15: test_build_ex_21

# 需要導入模塊: from resync.change_list import ChangeList [as 別名]
# 或者: from resync.change_list.ChangeList import as_xml [as 別名]
 def test_build_ex_21(self):
     """Change List which points back to index"""
     cl = ChangeList()
     cl.up = 'http://example.com/dataset1/capabilitylist.xml'
     cl.index = 'http://example.com/dataset1/changelist.xml'
     cl.md_from="2013-01-02T00:00:00Z"
     cl.md_until="2013-01-03T00:00:00Z"
     cl.add( Resource( uri='http://example.com/res7.html',
                       lastmod='2013-01-02T12:00:00Z',
                       change='created' ) )
     cl.add( Resource( uri='http://example.com/res9.pdf',
                       lastmod='2013-01-02T13:00:00Z',
                       change='updated' ) )
     cl.add( Resource( uri='http://example.com/res5.tiff',
                       lastmod='2013-01-02T19:00:00Z',
                       change='deleted' ) )
     cl.add( Resource( uri='http://example.com/res7.html',
                       lastmod='2013-01-02T20:00:00Z',
                       change='updated' ) )
     ex_xml = self._open_ex('resourcesync_ex_21').read()
     self._assert_xml_equal( cl.as_xml(), ex_xml )
開發者ID:,項目名稱:,代碼行數:23,代碼來源:


注:本文中的resync.change_list.ChangeList.as_xml方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。