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

« back to all changes in this revision

Viewing changes to src/calibre/ebooks/metadata/meta.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:
9
9
from calibre.ebooks.metadata.opf2 import OPF
10
10
 
11
11
from calibre.customize.ui import get_file_type_metadata, set_file_type_metadata
12
 
from calibre.ebooks.metadata import MetaInformation
 
12
from calibre.ebooks.metadata import MetaInformation, string_to_authors
13
13
 
14
14
_METADATA_PRIORITIES = [
15
15
                       'html', 'htm', 'xhtml', 'xhtm',
28
28
    return os.path.splitext(path)[1][1:].lower()
29
29
 
30
30
def metadata_from_formats(formats):
 
31
    try:
 
32
        return _metadata_from_formats(formats)
 
33
    except:
 
34
        mi = metadata_from_filename(list(formats)[0])
 
35
        if not mi.authors:
 
36
            mi.authors = [_('Unknown')]
 
37
 
 
38
def _metadata_from_formats(formats):
31
39
    mi = MetaInformation(None, None)
32
40
    formats.sort(cmp=lambda x,y: cmp(METADATA_PRIORITIES[path_to_ext(x)],
33
41
                                     METADATA_PRIORITIES[path_to_ext(y)]))
119
127
        except IndexError:
120
128
            pass
121
129
        try:
122
 
            mi.authors = [match.group('author')]
123
 
        except IndexError:
124
 
            pass
125
 
        try:
126
 
            au = match.group('authors')
127
 
            aus = au.split(',')
128
 
            authors = []
129
 
            for a in aus:
130
 
                authors.extend(a.split('&'))
131
 
            mi.authors = authors
 
130
            au = match.group('author')
 
131
            aus = string_to_authors(au)
 
132
            mi.authors = aus
132
133
        except IndexError:
133
134
            pass
134
135
        try:
137
138
            pass
138
139
        try:
139
140
            si = match.group('series_index')
140
 
            mi.series_index = int(si)
 
141
            mi.series_index = float(si)
141
142
        except (IndexError, ValueError, TypeError):
142
143
            pass
143
144
        try: