/Doc/library/ic.rst

http://unladen-swallow.googlecode.com/ · ReStructuredText · 124 lines · 82 code · 42 blank · 0 comment · 0 complexity · a42f9f7639b5c55c17952ee3378ad135 MD5 · raw file

  1. :mod:`ic` --- Access to the Mac OS X Internet Config
  2. ====================================================
  3. .. module:: ic
  4. :platform: Mac
  5. :synopsis: Access to the Mac OS X Internet Config.
  6. :deprecated:
  7. This module provides access to various internet-related preferences set through
  8. :program:`System Preferences` or the :program:`Finder`.
  9. .. note::
  10. This module has been removed in Python 3.x.
  11. .. index:: module: icglue
  12. There is a low-level companion module :mod:`icglue` which provides the basic
  13. Internet Config access functionality. This low-level module is not documented,
  14. but the docstrings of the routines document the parameters and the routine names
  15. are the same as for the Pascal or C API to Internet Config, so the standard IC
  16. programmers' documentation can be used if this module is needed.
  17. The :mod:`ic` module defines the :exc:`error` exception and symbolic names for
  18. all error codes Internet Config can produce; see the source for details.
  19. .. exception:: error
  20. Exception raised on errors in the :mod:`ic` module.
  21. The :mod:`ic` module defines the following class and function:
  22. .. class:: IC([signature[, ic]])
  23. Create an Internet Config object. The signature is a 4-character creator code of
  24. the current application (default ``'Pyth'``) which may influence some of ICs
  25. settings. The optional *ic* argument is a low-level ``icglue.icinstance``
  26. created beforehand, this may be useful if you want to get preferences from a
  27. different config file, etc.
  28. .. function:: launchurl(url[, hint])
  29. parseurl(data[, start[, end[, hint]]])
  30. mapfile(file)
  31. maptypecreator(type, creator[, filename])
  32. settypecreator(file)
  33. These functions are "shortcuts" to the methods of the same name, described
  34. below.
  35. IC Objects
  36. ----------
  37. :class:`IC` objects have a mapping interface, hence to obtain the mail address
  38. you simply get ``ic['MailAddress']``. Assignment also works, and changes the
  39. option in the configuration file.
  40. The module knows about various datatypes, and converts the internal IC
  41. representation to a "logical" Python data structure. Running the :mod:`ic`
  42. module standalone will run a test program that lists all keys and values in your
  43. IC database, this will have to serve as documentation.
  44. If the module does not know how to represent the data it returns an instance of
  45. the ``ICOpaqueData`` type, with the raw data in its :attr:`data` attribute.
  46. Objects of this type are also acceptable values for assignment.
  47. Besides the dictionary interface, :class:`IC` objects have the following
  48. methods:
  49. .. method:: IC.launchurl(url[, hint])
  50. Parse the given URL, launch the correct application and pass it the URL. The
  51. optional *hint* can be a scheme name such as ``'mailto:'``, in which case
  52. incomplete URLs are completed with this scheme. If *hint* is not provided,
  53. incomplete URLs are invalid.
  54. .. method:: IC.parseurl(data[, start[, end[, hint]]])
  55. Find an URL somewhere in *data* and return start position, end position and the
  56. URL. The optional *start* and *end* can be used to limit the search, so for
  57. instance if a user clicks in a long text field you can pass the whole text field
  58. and the click-position in *start* and this routine will return the whole URL in
  59. which the user clicked. As above, *hint* is an optional scheme used to complete
  60. incomplete URLs.
  61. .. method:: IC.mapfile(file)
  62. Return the mapping entry for the given *file*, which can be passed as either a
  63. filename or an :func:`FSSpec` result, and which need not exist.
  64. The mapping entry is returned as a tuple ``(version, type, creator, postcreator,
  65. flags, extension, appname, postappname, mimetype, entryname)``, where *version*
  66. is the entry version number, *type* is the 4-character filetype, *creator* is
  67. the 4-character creator type, *postcreator* is the 4-character creator code of
  68. an optional application to post-process the file after downloading, *flags* are
  69. various bits specifying whether to transfer in binary or ascii and such,
  70. *extension* is the filename extension for this file type, *appname* is the
  71. printable name of the application to which this file belongs, *postappname* is
  72. the name of the postprocessing application, *mimetype* is the MIME type of this
  73. file and *entryname* is the name of this entry.
  74. .. method:: IC.maptypecreator(type, creator[, filename])
  75. Return the mapping entry for files with given 4-character *type* and *creator*
  76. codes. The optional *filename* may be specified to further help finding the
  77. correct entry (if the creator code is ``'????'``, for instance).
  78. The mapping entry is returned in the same format as for *mapfile*.
  79. .. method:: IC.settypecreator(file)
  80. Given an existing *file*, specified either as a filename or as an :func:`FSSpec`
  81. result, set its creator and type correctly based on its extension. The finder
  82. is told about the change, so the finder icon will be updated quickly.