Transfer data from a DeliciousLibrary XML database to a FileMakerPro database
1 2 3 from pprint import pprint 4 from elementtree import /ElementTree 5 from appscript import * 6 from Carbon.File import FSSpec 7 8 9 FM_ID = 'com.filemaker.pro7' 10 FM_DB_PATH = '/Users/SOMEUSER/Desktop/Library.fp7' 11 FM_DB = 'Library' 12 FM_TABLE = 'Library' 13 14 15 DL_DB_PATH = '/Users/SOMEUSER/Library/Application Support/Delicious Library/Library Media Data.xml' 16 17 18 try: 19 fm = app(id=FM_ID) 20 except ApplicationNotFoundError: 21 print "FileMaker Pro 7 application has not been found." 22 sys.exit(0) 23 24 if not fm.databases[FM_DB].exists(): 25 try: 26 fm.open(FSSpec(FM_DB_PATH)) 27 except: 28 print "Can't open source database '%s'." % FM_DB_PATH 29 sys.exit(0) 30 31 if not fm.databases[FM_DB].tables[FM_TABLE].exists(): 32 print "Table '%s' doesn't exists in source database '%s'." % (FM_TABLE, FM_DB) 33 sys.exit(0) 34 35 t1 = fm.databases[FM_DB].tables[FM_TABLE] 36 37 38 39 tree = ElementTree.parse(DL_DB_PATH) 40 41 42 43 fields = t1.fields.name.get() 44 45 for el in tree.findall('//items/book'): 46 data = [ (el.get(f) or '') for f in fields ] 47 rec = fm.create(new=k.record, with_data=data, at=t1)
Footnotes:
Warning: you could use /ElementTree to edit the /DeliciousLibrary XML file, but don't forget it's not a database: you could corrupt your /DeliciousLibrary database in case of concurrent access. And no, /DeliciousLibrary is not (yet) scriptable :-/
MacPython/FileMakerPro/DeliciousLibrary (last edited 2008-11-15 14:00:51 by localhost)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4