@@ -0,0 +1,1589 @@
+#!/usr/bin/python%0A# -*- coding: ISO-8859-15 -*-%0A# =============================================================================%0A# Copyright (c) 2010 Tom Kralidis%0A#%0A# Authors : Tom Kralidis %3Ctomkralidis@hotmail.com%3E%0A#%0A# Contact email: tomkralidis@hotmail.com%0A# =============================================================================%0A%0A# simple process to harvest CSW catalogues via Harvest operations%0A%0Aimport sys%0Afrom owslib.csw import CatalogueServiceWeb%0A%0Astop = 0%0Aflag = 0%0Amaxrecords = 10%0A%0Aif len(sys.argv) %3C 3:%0A    print 'Usage: %25s %3Csource_catalogue_url%3E %3Cdestination_catalogue_url%3E %5Bmaxrecords%5D' %5C%0A        %25 sys.argv%5B0%5D%0A    sys.exit(1)%0A%0Asrc = CatalogueServiceWeb(sys.argv%5B1%5D)%0Adest = CatalogueServiceWeb(sys.argv%5B2%5D)%0A%0Aif len(sys.argv) == 4:%0A    maxrecords = sys.argv%5B3%5D%0A%0Awhile stop == 0:%0A    if flag == 0:  # first run, start from 0%0A        startposition = 0%0A    else:  # subsequent run, startposition is now paged%0A        startposition = src.results%5B'nextrecord'%5D%0A%0A    src.getrecords(esn='brief', startposition=startposition, maxrecords=maxrecords)%0A%0A    print src.results%0A%0A    if src.results%5B'nextrecord'%5D == 0 %5C%0A        or src.results%5B'returned'%5D == 0:  # end the loop, exhausted all records%0A        stop = 1%0A        break%0A%0A    # harvest each record to destination CSW%0A    for i in list(src.records):%0A        source = '%25s?service=CSW&version=2.0.2&request=GetRecordById&id=%25s' %25 %5C%0A            (sys.argv%5B1%5D, i)%0A        dest.harvest(source=source, %5C%0A            resourcetype='http://www.isotc211.org/2005/gmd')%0A        #print dest.request%0A        #print dest.response%0A%0A    flag = 1%0A

add CSW harvest example