home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_976 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-08-06  |  1.1 KB  |  30 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. from __future__ import with_statement
  5. __license__ = 'GPL v3'
  6. __copyright__ = '2009, John Schember <john@nachtimwald.com>'
  7. import re
  8. from calibre.ebooks.metadata import MetaInformation
  9.  
  10. def get_metadata(stream, extract_cover = True):
  11.     mi = MetaInformation(_('Unknown'), [
  12.         _('Unknown')])
  13.     stream.seek(0)
  14.     mdata = u''
  15.     for x in range(0, 4):
  16.         line = stream.readline().decode('utf-8', 'replace')
  17.         if line == '':
  18.             break
  19.             continue
  20.         mdata += line
  21.     
  22.     mdata = mdata[:100]
  23.     mo = re.search('(?u)^[ ]*(?P<title>.+)[ ]*(\n{3}|(\r\n){3}|\r{3})[ ]*(?P<author>.+)[ ]*(\n|\r\n|\r)$', mdata)
  24.     if mo != None:
  25.         mi.title = mo.group('title')
  26.         mi.authors = mo.group('author').split(',')
  27.     
  28.     return mi
  29.  
  30.