home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- from __future__ import with_statement
- __license__ = 'GPL v3'
- __copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
- __docformat__ = 'restructuredtext en'
- import sys
- import os
- import linecache
-
- def abs__file__():
- for m in sys.modules.values():
- if hasattr(m, '__loader__'):
- continue
-
-
- try:
- m.__file__ = os.path.abspath(m.__file__)
- continue
- except AttributeError:
- continue
- continue
-
-
-
-
-
- def aliasmbcs():
- import locale
- import codecs
- enc = locale.getdefaultlocale()[1]
- if enc.startswith('cp'):
-
- try:
- codecs.lookup(enc)
- except LookupError:
- import encodings
- encodings._cache[enc] = encodings._unknown
- encodings.aliases.aliases[enc] = 'mbcs'
- except:
- None<EXCEPTION MATCH>LookupError
-
-
- None<EXCEPTION MATCH>LookupError
-
-
- def add_calibre_vars():
- sys.resources_location = os.path.join(sys.app_dir, 'resources')
- sys.extensions_location = os.path.join(sys.app_dir, 'plugins')
- dv = os.environ.get('CALIBRE_DEVELOP_FROM', None)
- if dv and os.path.exists(dv):
- sys.path.insert(0, os.path.abspath(dv))
-
-
-
- def makepath(*paths):
- dir = os.path.abspath(os.path.join(*paths))
- return (dir, os.path.normcase(dir))
-
-
- def addpackage(sitedir, name):
- fullname = os.path.join(sitedir, name)
-
- try:
- f = open(fullname, 'rU')
- except IOError:
- return None
-
- f.__enter__()
-
- try:
- for line in f:
- if line.startswith(('import ', 'import\t')):
- exec line
- continue
-
- line = line.rstrip()
- (dir, dircase) = makepath(sitedir, line)
- if os.path.exists(dir):
- sys.path.append(dir)
- continue
- finally:
- pass
-
-
-
- def addsitedir(sitedir):
- (sitedir, sitedircase) = makepath(sitedir)
-
- try:
- names = os.listdir(sitedir)
- except os.error:
- return None
-
- dotpth = os.extsep + 'pth'
- names = _[1]
- for name in sorted(names):
- addpackage(sitedir, name)
-
-
-
- def run_entry_point():
- bname = sys.calibre_basename
- mod = sys.calibre_module
- func = sys.calibre_function
- sys.argv[0] = bname + '.exe'
- pmod = __import__(mod, fromlist = [
- 1], level = 0)
- return getattr(pmod, func)()
-
-
- def main():
- sys.frozen = 'windows_exe'
- sys.setdefaultencoding('utf-8')
- aliasmbcs()
-
- def fake_getline(filename, lineno, module_globals = None):
- return ''
-
- linecache.orig_getline = linecache.getline
- linecache.getline = fake_getline
- abs__file__()
- addsitedir(os.path.join(sys.app_dir, 'Lib', 'site-packages'))
- add_calibre_vars()
- return run_entry_point()
-
-