~ubuntu-branches/ubuntu/karmic/calibre/karmic

« back to all changes in this revision

Viewing changes to src/calibre/ebooks/metadata/imp.py

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-07-30 12:49:41 UTC
  • mto: This revision was merged to the branch mainline in revision 13.
  • Revision ID: james.westby@ubuntu.com-20090730124941-kviipg9ypwgppulc
Tags: upstream-0.6.3+dfsg
ImportĀ upstreamĀ versionĀ 0.6.3+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 
5
5
import sys, os
6
6
 
7
 
from calibre.ebooks.metadata import MetaInformation
 
7
from calibre.ebooks.metadata import MetaInformation, string_to_authors
8
8
 
9
9
MAGIC = ['\x00\x01BOOKDOUG', '\x00\x02BOOKDOUG']
10
10
 
34
34
        if title:
35
35
            mi.title = title
36
36
        if author:
37
 
            src = author.split('&')
38
 
            authors = []
39
 
            for au in src:
40
 
                authors += au.split(',')
41
 
            mi.authors = authors
 
37
            mi.authors = string_to_authors(author)
42
38
            mi.author = author
43
39
        if category:
44
40
            mi.category = category
46
42
        msg = u'Couldn\'t read metadata from imp: %s with error %s'%(mi.title, unicode(err))
47
43
        print >>sys.stderr, msg.encode('utf8')
48
44
    return mi
49
 
        
50
 
            
51
 
def main(args=sys.argv):
52
 
    if len(args) != 2:
53
 
        print >>sys.stderr, _('Usage: imp-meta file.imp')
54
 
        print >>sys.stderr, _('No filename specified.')
55
 
        return 1
56
 
    
57
 
    path = os.path.abspath(os.path.expanduser(args[1]))
58
 
    print get_metadata(open(path, 'rb'))
59
 
    return 0
60
 
 
61
 
if __name__ == '__main__':
62
 
    sys.exit(main())