home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 May / maximum-cd-2010-05.iso / DiscContents / boxee-0.9.20.10711.exe / system / python / Lib / plat-mac / icopen.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-07-20  |  2.0 KB  |  69 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.4)
  3.  
  4. """icopen patch
  5.  
  6. OVERVIEW
  7.  
  8. icopen patches MacOS Python to use the Internet Config file mappings to select
  9. the type and creator for a file.
  10.  
  11. Version 1 released to the public domain 3 November 1999
  12. by Oliver Steele (steele@cs.brandeis.edu).
  13.  
  14. DETAILS
  15.  
  16. This patch causes files created by Python's open(filename, 'w') command (and
  17. by functions and scripts that call it) to set the type and creator of the file
  18. to the type and creator associated with filename's extension (the
  19. portion of the filename after the last period), according to Internet Config.
  20. Thus, a script that creates a file foo.html will create one that opens in whatever
  21. browser you've set to handle *.html files, and so on.
  22.  
  23. Python IDE uses its own algorithm to select the type and creator for saved
  24. editor windows, so this patch won't effect their types.
  25.  
  26. As of System 8.6 at least, Internet Config is built into the system, and the
  27. file mappings are accessed from the Advanced pane of the Internet control
  28. panel.  User Mode (in the Edit menu) needs to be set to Advanced in order to
  29. access this pane.
  30.  
  31. INSTALLATION
  32.  
  33. Put this file in your Python path, and create a file named {Python}:sitecustomize.py
  34. that contains:
  35.         import icopen
  36.  
  37. (If {Python}:sitecustomizer.py already exists, just add the 'import' line to it.)
  38.  
  39. The next time you launch PythonInterpreter or Python IDE, the patch will take
  40. effect.
  41. """
  42. import __builtin__
  43. _builtin_open = globals().get('_builtin_open', __builtin__.open)
  44.  
  45. def _open_with_typer(*args):
  46.     file = _builtin_open(*args)
  47.     filename = args[0]
  48.     mode = 'r'
  49.     if args[1:]:
  50.         mode = args[1]
  51.     
  52.     if mode[0] == 'w':
  53.         error = error
  54.         settypecreator = settypecreator
  55.         import ic
  56.         
  57.         try:
  58.             settypecreator(filename)
  59.         except error:
  60.             pass
  61.         except:
  62.             None<EXCEPTION MATCH>error
  63.         
  64.  
  65.     None<EXCEPTION MATCH>error
  66.     return file
  67.  
  68. __builtin__.open = _open_with_typer
  69.