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

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-07-30 12:49:41 UTC
  • mfrom: (1.3.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090730124941-qjdsmri25zt8zocn
Tags: 0.6.3+dfsg-0ubuntu1
* New upstream release. Please see http://calibre.kovidgoyal.net/new_in_6/
  for the list of new features and changes.
* remove_postinstall.patch: Update for new version.
* build_debug.patch: Does not apply any more, disable for now. Might not be
  necessary any more.
* debian/copyright: Fix reference to versionless GPL.
* debian/rules: Drop obsolete dh_desktop call.
* debian/rules: Add workaround for weird Python 2.6 setuptools behaviour of
  putting compiled .so files into src/calibre/plugins/calibre/plugins
  instead of src/calibre/plugins.
* debian/rules: Drop hal fdi moving, new upstream version does not use hal
  any more. Drop hal dependency, too.
* debian/rules: Install udev rules into /lib/udev/rules.d.
* Add debian/calibre.preinst: Remove unmodified
  /etc/udev/rules.d/95-calibre.rules on upgrade.
* debian/control: Bump Python dependencies to 2.6, since upstream needs
  it now.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
"""
6
6
import re, cStringIO, sys
7
7
 
8
 
from calibre.ebooks.metadata import MetaInformation, get_parser
 
8
from calibre.ebooks.metadata import MetaInformation, string_to_authors
9
9
 
10
10
title_pat    = re.compile(r'\{\\info.*?\{\\title(.*?)(?<!\\)\}', re.DOTALL)
11
11
author_pat   = re.compile(r'\{\\info.*?\{\\author(.*?)(?<!\\)\}', re.DOTALL)
76
76
        category = category_match.group(1).strip()
77
77
    mi = MetaInformation(title, author)
78
78
    if author:
79
 
        au = author.split(',')
80
 
        mi.authors = []
81
 
        for i in au:
82
 
            mi.authors.extend(i.split('&'))
 
79
        mi.authors = string_to_authors(author)
83
80
    mi.comments = comment
84
81
    mi.category = category
85
82
    return mi
166
163
        stream.write(src)
167
164
        stream.write(after)
168
165
    
169
 
def option_parser():
170
 
    return get_parser('rtf')
171
 
 
172
 
def main(args=sys.argv):
173
 
    parser = option_parser()
174
 
    options, args = parser.parse_args(args)
175
 
    if len(args) != 2:
176
 
        parser.print_help()
177
 
        sys.exit(1)
178
 
    stream = open(args[1], 'r+b')
179
 
    if options.authors:
180
 
        options.authors = options.authors.split(',')
181
 
    options.comments = options.comment 
182
 
    set_metadata(stream, options)
183
 
    mi = get_metadata(stream)
184
 
    return mi
185
 
 
186
 
if __name__ == '__main__':
187
 
    main()
 
 
b'\\ No newline at end of file'