MacPython/FileMakerPro/DeliciousLibrary
This wiki is in the process of being archived due to lack of usage and the resources necessary to serve it — predominately to bots, crawlers, and LLM companies. Edits are discouraged.
Pages are preserved as they were at the time of archival. For current information, please visit python.org.
If a change to this archive is absolutely needed, requests can be made via the infrastructure@python.org mailing list.
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:
- ...Carbon.File.FSSpec not a good idea... will correct asap...
- ...will post Library.fp7 sample database asap...
- you have to adapt the path...
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 :-/