As discussed before, this is a simple one line script to get it:

#!/bin/bash
echo "$1" | base64 -D | plutil -convert xml1 -o - -- -

This will give the plist in xml format with the relativePath rather easily figured out. You could also type this on a command line with the bask-file value inserted in the place of $1

I also attach an extension to Adam's read_bdsk_file.py that can read both the old and the new format.

Christiaan

#!/usr/bin/python

#
# Attempt to read relative path from BibDesk Bdsk-File fields.
# Useful only for debugging, since the archive format may change.
# 
# Call as `echo "xxxx" | python read_bdsk_file.py` where "xxxx" is the content of a
# Bdsk-File field.  Alternately, copy and use `pbpaste | python read_bdsk_file.py`.
#

import os, sys
import base64
from Foundation import *

# read base64 data from standard input and decode
decodedBytes = base64.b64decode(sys.stdin.read())

nsData = NSData.dataWithBytes_length_(decodedBytes, len(decodedBytes))
plist, fmt, error = NSPropertyListSerialization.propertyListFromData_mutabilityOption_format_errorDescription_(nsData, 0, None, None)

if plist is None:
    print "failed to decode archive due to error %s" % (error)
    exit(1)

# currently an implementation detail; may not be at position 6 in future
if ("relativePath" in plist):
    print plist["relativePath"]
elif ("$objects" in plist and len(plist["$objects"]) > 4):
    print plist["$objects"][4]
else:
    print "unknown format for property list %s" % (str(plist))

On 9 Apr 2019, at 10:05, Christiaan Hofman <cmhof...@gmail.com> wrote:

Yes, the format of the linked file data has changed. It is now just a plist and not an archive. If you decode it, it should be much clearer to read. 

Christiaan

Op di 9 apr. 2019 04:27 schreef Justin C. Walker via Bibdesk-users <bibdesk-users@lists.sourceforge.net:
Hi, all,

A while back, Adam provided a handy little snippet (read_bdsk_file) of python code to read the file entries in .bib files.  At some point recently, it stopped working, because

    print plist["relativePath"]
TypeError: 'NoneType' object has no attribute '__getitem__'

This seems to mean that the content of the bask-file entries has changed.  Is that the case, or has something else gone wrong?

Clues much appreciated.

Thanks!

Justin

--
Justin C. Walker, Curmudgeon-At-Large
Institute for the Absorption of Federal Funds
--------
If you're not confused,
You're not paying attention
--------

_______________________________________________
Bibdesk-users mailing list
Bibdesk-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-users

Reply via email to