Re: MIME and metadata stuff



Here is a short script I wrote that may help edit the metadata file. It
may also be useful as a way of backing up the metadata in a human readable
format.

It needs python to run, and probably won't work if the bsddb module was
compiled with a different version to what is being used by gnome.  It
outputs a script that when run, will reconstruct your metadata db.  You
will need gnome-python (the pygnome package on red hat) to run the output.

I have only tested it on a red hat 5.x box, so it may have troubles on
newer boxes with db-2.0 and db-1.85 installed on them.

James.

--
Email: james@daa.com.au
WWW:   http://www.daa.com.au/~james/


On 17 Oct 1999, Bruce Stephens wrote:

> sopwith@redhat.com (Elliot Lee) writes:
> 
> > If you do 'rm ~/.gnome/metadata.db' does it start to work again? 
> > This might be corrupted metadata or something.
> 
> Yes, that works.  Probably it's just old metadata: I've been compiling
> new versions of GNOME for some time, so probably something at some
> time changed.
> 
> Anyway, removing that file works for new URLs.  I can recreate the
> couple of old ones; they aren't important.
> 
> Thanks.
> 
> 
> -- 
>         FAQ: Frequently-Asked Questions at http://www.gnome.org/gnomefaq
>          To unsubscribe: mail gnome-list-request@gnome.org with 
>                        "unsubscribe" as the Subject.
> 
#!/usr/bin/env python

import sys, os, string, bsddb

if len(sys.argv) < 2:
	sys.argv.append('%s/.gnome/metadata.db' % os.environ['HOME'])

db = bsddb.hashopen(sys.argv[1], 'r')

print "#!/usr/bin/env python"
print "import gnome.metadata"
print

set_pattern = 'gnome.metadata.set(%s, %s, %s)'
regex_pattern = 'gnome.metadata.regex_add(%s, %s, %s)'
type_pattern = 'gnome.metadata.type_add(%s, %s, %s)'

for key in db.keys():
	split = string.split(key, '\0')
	data = db[key]

	if split[0] == 'file':
		print set_pattern % (`split[1]`, `split[2]`, `data`)
	if split[0] == 'regex':
		print regex_pattern % (`split[1]`, `split[2]`, `data`)
	if split[0] == 'type':
		print type_pattern % (`split[1]`, `split[2]`, `key`)
db.close()



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]