pytho****@googl*****
pytho****@googl*****
2011年 11月 14日 (月) 16:28:27 JST
2 new revisions: Revision: ab6318909407 Author: Arihiro TAKASE <hinac****@gmail*****> Date: Sun Nov 13 23:27:45 2011 Log: 差分翻訳 2.7.2: library/exceptions http://code.google.com/p/python-doc-ja/source/detail?r=ab6318909407 Revision: 584cc6cc6aad Author: Arihiro TAKASE <hinac****@gmail*****> Date: Sun Nov 13 23:28:08 2011 Log: merge http://code.google.com/p/python-doc-ja/source/detail?r=584cc6cc6aad ============================================================================== Revision: ab6318909407 Author: Arihiro TAKASE <hinac****@gmail*****> Date: Sun Nov 13 23:27:45 2011 Log: 差分翻訳 2.7.2: library/exceptions http://code.google.com/p/python-doc-ja/source/detail?r=ab6318909407 Modified: /library/exceptions.rst ======================================= --- /library/exceptions.rst Tue May 3 06:18:14 2011 +++ /library/exceptions.rst Sun Nov 13 23:27:45 2011 @@ -7,11 +7,6 @@ :synopsis: 標準の例外クラス群 -.. Exceptions should be class objects. The exceptions are defined in the module -.. :mod:`exceptions`. This module never needs to be imported explicitly: the -.. exceptions are provided in the built-in namespace as well as the -.. :mod:`exceptions` module. - 例外はクラスオブジェクトです。例外はモジュール :mod:`exceptions` で定義されています。このモジュールを明示的にインポートする必要はありませ ん。 例外は :mod:`exceptions` モジュールと同様に組み込み名前空間で与えられます。 @@ -22,12 +17,6 @@ statement: except -.. For class exceptions, in a :keyword:`try` statement with an :keyword:`except` -.. clause that mentions a particular class, that clause also handles any exception -.. classes derived from that class (but not exception classes from which *it* is -.. derived). Two exception classes that are not related via subclassing are never -.. equivalent, even if they have the same name. - :keyword:`try` 文の中で、 :keyword:`except` 節を使って特定の例外クラス について記述した場合、その節は指定した例外クラスから派生したクラスも 扱います (指定した例外クラスの派生元のクラスは含みません)。 @@ -37,15 +26,6 @@ .. index:: statement: raise -.. The built-in exceptions listed below can be generated by the interpreter or -.. built-in functions. Except where mentioned, they have an "associated value" -.. indicating the detailed cause of the error. This may be a string or a tuple -.. containing several items of information (e.g., an error code and a string -.. explaining the code). The associated value is the second argument to the -.. :keyword:`raise` statement. If the exception class is derived from the standard -.. root class :exc:`BaseException`, the associated value is present as the -.. exception instance's :attr:`args` attribute. - 以下に列挙した組み込み例外はインタプリタや組み込み関数によって生成され ます。特に注記しないかぎり、これらの例外はエラーの詳しい原因を示してい る、 "関連値 (associated value)" を持ちます。この値は文字列または複数 @@ -55,11 +35,6 @@ 関連値は例外インスタンスの :attr:`args` 属性中に置かれます。 -.. User code can raise built-in exceptions. This can be used to test an exception -.. handler or to report an error condition "just like" the situation in which the -.. interpreter raises the same exception; but beware that there is nothing to -.. prevent user code from raising an inappropriate error. - ユーザによるコードも組み込み例外を送出することができます。これは例外処 理をテストしたり、インタプリタがある例外を送出する状況と "ちょうど同じ ような" エラー条件であることを報告させるために使うことができます。しか @@ -67,66 +42,45 @@ ないので注意してください。 -.. The built-in exception classes can be sub-classed to define new exceptions; -.. programmers are encouraged to at least derive new exceptions from the -.. :exc:`Exception` class and not :exc:`BaseException`. More information on -.. defining exceptions is available in the Python Tutorial under -.. :ref:`tut-userexceptions`. - 組み込み例外クラスは新たな例外を定義するためにサブクラス化することができま す。 新しい例外は、少なくとも :exc:`Exception` クラスから派生することをお勧めし ます。 :exc:`BaseException` からは派生しないで下さい。例外を定義する上での詳しい情 報は、 Python チュートリアルの :ref:`tut-userexceptions` の項目にあります。 -.. The following exceptions are only used as base classes for other exceptions. - 以下の例外クラスは他の例外クラスの基底クラスとしてのみ使われます。 .. exception:: BaseException - .. The base class for all built-in exceptions. It is not meant to be directly - .. inherited by user-defined classes (for that use :exc:`Exception`). If - .. :func:`str` or :func:`unicode` is called on an instance of this class, the - .. representation of the argument(s) to the instance are returned or the empty - .. string when there were no arguments. All arguments are stored in :attr:`args` - .. as a tuple. - 全ての組み込み例外のルートクラスです。ユーザ定義例外が直接このクラ スを継承することは意図していません (そうした場合は :exc:`Exception` を使ってください)。このクラスに対して :func:`str` - や :func:`unicode` が呼ばれた場合、引数の文字列表現かまたは引数が無 + や :func:`unicode` が呼ばれた場合、引数の文字列表現か、引数が無 い時には空文字列が返されます。 - 全ての引数はタプルとして :attr:`args` に格納されます。 .. versionadded:: 2.5 + .. attribute:: args + + 例外コンストラクタに与えられた引数のタプルです。 + 組み込み例外は普通、エラーメッセージを与える一つの文字列だけを + 引数として呼ばれますが、中には (:exc:`IOError` など) いくつかの引数を + 必要とし、このタプルの要素に特別な意味を込めるものもあります。 .. exception:: Exception - .. All built-in, non-system-exiting exceptions are derived from this class. All - .. user-defined exceptions should also be derived from this class. - 全ての組み込み例外のうち、システム終了でないものはこのクラスから導 出されています。全てのユーザ定義例外はこのクラスの派生クラスであるべき です。 - - .. .. versionchanged:: 2.5 - .. .. Changed to inherit from :exc:`BaseException`. - .. versionchanged:: 2.5 :exc:`BaseException` を継承するように変更されました. .. exception:: StandardError - .. The base class for all built-in exceptions except :exc:`StopIteration`, - .. :exc:`GeneratorExit`, :exc:`KeyboardInterrupt` and :exc:`SystemExit`. - .. :exc:`StandardError` itself is derived from :exc:`Exception`. - :exc:`StopIteration`, :exc:`SystemExit`, :exc:`KeyboardInterrupt`, :exc:`SystemExit` 以外の、全ての組み込み例外の基底クラスです。 :exc:`StandardError` 自体は :exc:`Exception` の派生クラスです。 @@ -134,20 +88,18 @@ .. exception:: ArithmeticError - .. The base class for those built-in exceptions that are raised for various - .. arithmetic errors: :exc:`OverflowError`, :exc:`ZeroDivisionError`, - .. :exc:`FloatingPointError`. - 算術上の様々なエラーにおいて送出される組み込み例外 :exc:`OverflowError`, :exc:`ZeroDivisionError`, :exc:`FloatingPointError` の基底クラスです。 -.. exception:: LookupError - - .. The base class for the exceptions that are raised when a key or index used on - .. a mapping or sequence is invalid: :exc:`IndexError`, :exc:`KeyError`. This - .. can be raised directly by :func:`codecs.lookup`. +.. exception:: BufferError + + バッファ (:ref:`buffer <bufferobjects>`) に関連する演算が行えなかったと きに + 送出されます。 + + +.. exception:: LookupError マップ型またはシーケンス型に使われたキーやインデックスが無効な場合 に送出される例外 :exc:`IndexError` および :exc:`KeyError` の基底クラス @@ -156,13 +108,6 @@ .. exception:: EnvironmentError - .. The base class for exceptions that can occur outside the Python system: - .. :exc:`IOError`, :exc:`OSError`. When exceptions of this type are created with a - .. 2-tuple, the first item is available on the instance's :attr:`errno` attribute - .. (it is assumed to be an error number), and the second item is available on the - .. :attr:`strerror` attribute (it is usually the associated error message). The - .. tuple itself is also available on the :attr:`args` attribute. - Python システムの外部で起こる可能性のある例外 :exc:`IOError` および :exc:`OSError` の基底クラスです。この型の例外が 2 つの要素を持つ タプルで生成された場合、 1 番目の要素はインスタンスの :attr:`errno` @@ -173,12 +118,6 @@ .. versionadded:: 1.5.2 - .. When an :exc:`EnvironmentError` exception is instantiated with a 3-tuple, the - .. first two items are available as above, while the third item is available on the - .. :attr:`filename` attribute. However, for backwards compatibility, the - .. :attr:`args` attribute contains only a 2-tuple of the first two constructor - .. arguments. - :exc:`EnvironmentError` 例外が 3 要素のタプルで生成された場合、最初 の 2 つの要素は上記と同様に値を得ることができ、さらに 3 番目の要素は :attr:`filename` 属性で得ることができます。しかしながら、以前のバー @@ -186,12 +125,6 @@ した最初の 2 つの引数からなる 2 要素のタプルしか含みません。 - .. The :attr:`filename` attribute is ``None`` when this exception is created with - .. other than 3 arguments. The :attr:`errno` and :attr:`strerror` attributes are - .. also ``None`` when the instance was created with other than 2 or 3 arguments. - .. In this last case, :attr:`args` contains the verbatim constructor arguments as a - .. tuple. - この例外が 3 つ以外の引数で生成された場合、 :attr:`filename` 属性は ``None`` になります。この例外が 2 つまたは 3 つ以外の引数で生成された 場合、 :attr:`errno` および :attr:`strerror` 属性も ``None`` になり @@ -199,8 +132,6 @@ をそのままタプルの形で含んでいます。 -.. The following exceptions are the exceptions that are actually raised. - 以下の例外は実際に送出される例外です。 @@ -208,17 +139,11 @@ .. index:: statement: assert - .. Raised when an :keyword:`assert` statement fails. - :keyword:`assert` 文が失敗した場合に送出されます。 .. exception:: AttributeError - .. Raised when an attribute reference (see :ref:`attribute-references`) or - .. assignment fails. (When an object does not support attribute references or - .. attribute assignments at all, :exc:`TypeError` is raised.) - 属性の参照 (:ref:`attribute-references` を参照) や代入が失敗 した場合に送出されます (オブジェクトが属性の参照や属性の代入をまっ たくサポートしていない場合には :exc:`TypeError` が送出されます)。 @@ -226,11 +151,6 @@ .. exception:: EOFError - .. Raised when one of the built-in functions (:func:`input` or :func:`raw_input`) - .. hits an end-of-file condition (EOF) without reading any data. (N.B.: the - .. :meth:`file.read` and :meth:`file.readline` methods return an empty string - .. when they hit EOF.) - 組み込み関数 (:func:`input` または :func:`raw_input`) のいずれかで、 データを全く読まないうちにファイルの終端 (EOF) に到達した場合に送出 されます (注意: :meth:`file.read` および :meth:`file.readline` メソッド @@ -239,24 +159,15 @@ .. exception:: FloatingPointError - .. Raised when a floating point operation fails. This exception is always defined, - .. but can only be raised when Python is configured with the - .. :option:`--with-fpectl` option, or the :const:`WANT_SIGFPE_HANDLER` symbol is - .. defined in the :file:`pyconfig.h` file. - 浮動小数点演算が失敗した場合に送出されます。この例外は Python のどのバージョンでも常に定義されていますが、 Python が - :option:`--with-fpectl` オプションを有効にしてコンパイルされているか、 + ``--with-fpectl`` オプションを有効にしてコンパイルされているか、 :file:`pyconfig.h` ファイルにシンボル :const:`WANT_SIGFPE_HANDLER` が定義されている場合にのみ送出されます。 .. exception:: GeneratorExit - .. Raise when a :term:`generator`\'s :meth:`close` method is called. It - .. directly inherits from :exc:`BaseException` instead of :exc:`StandardError` since - .. it is technically not an error. - ジェネレータ (:term:`generator`) の :meth:`close` メソッドが呼び出 されたときに送出されます。この例外は厳密にはエラーではないので、 :exc:`StandardError` ではなく :exc:`BaseException` を直接継承していま す。 @@ -264,55 +175,35 @@ .. versionadded:: 2.5 - .. .. versionchanged:: 2.6 - .. .. Changed to inherit from :exc:`BaseException`. - .. versionchanged:: 2.6 :exc:`BaseException` を継承するように変更されました。 .. exception:: IOError - .. Raised when an I/O operation (such as a :keyword:`print` statement, the built-in - .. :func:`open` function or a method of a file object) fails for an I/O-related - .. reason, e.g., "file not found" or "disk full". - (:keyword:`print` 文、組み込みの :func:`open` またはファイルオブジェ クトに対するメソッドといった) I/O 操作が、例えば "ファイルが存在し ません" や "ディスクの空き領域がありません" といった I/O に関連した 理由で失敗した場合に送出されます。 - .. This class is derived from :exc:`EnvironmentError`. See the discussion above - .. for more information on exception instance attributes. - このクラスは :exc:`EnvironmentError` の派生クラスです。この例外 クラスのインスタンス属性に関する情報は上記の :exc:`EnvironmentError` に関する議論を参照してください。 - .. .. versionchanged:: 2.6 - .. .. Changed :exc:`socket.error` to use this as a base class. - .. versionchanged:: 2.6 :exc:`socket.error` は、この例外を基底クラスとして使うように変更され ました。 .. exception:: ImportError - .. Raised when an :keyword:`import` statement fails to find the module definition - .. or when a ``from ... import`` fails to find a name that is to be imported. - :keyword:`import` 文でモジュール定義を見つけられなかった場合や、 ``from ... import`` 文で指定した名前をインポートすることができなかった場 合に送出されます。 .. exception:: IndexError - .. Raised when a sequence subscript is out of range. (Slice indices are silently - .. truncated to fall in the allowed range; if an index is not a plain integer, - .. :exc:`TypeError` is raised.) - シーケンスのインデックス指定がシーケンスの範囲を超えている場合に送出 されます (スライスのインデックスはシーケンスの範囲に収まるように暗黙 のうちに調整されます; インデックスが通常の整数でない場合、 @@ -324,8 +215,6 @@ .. exception:: KeyError - .. Raised when a mapping (dictionary) key is not found in the set of existing keys. - マップ型 (辞書型) オブジェクトのキーが、オブジェクトのキー集合内に 見つからなかった場合に送出されます。 @@ -335,13 +224,6 @@ .. exception:: KeyboardInterrupt - .. Raised when the user hits the interrupt key (normally :kbd:`Control-C` or - .. :kbd:`Delete`). During execution, a check for interrupts is made regularly. - .. Interrupts typed when a built-in function :func:`input` or :func:`raw_input` is - .. waiting for input also raise this exception. The exception inherits from - .. :exc:`BaseException` so as to not be accidentally caught by code that catches - .. :exc:`Exception` and thus prevent the interpreter from exiting. - ユーザが割り込みキー (通常は :kbd:`Control-C` または :kbd:`Delete` キー) を押した場合に送出されます。割り込みが起きたかどうかはインタプリタの 実行中に定期的に調べられます。組み込み関数 :func:`input` や @@ -351,23 +233,12 @@ を継承しています。 - .. .. versionchanged:: 2.5 - .. .. Changed to inherit from :exc:`BaseException`. - .. versionchanged:: 2.5 :exc:`BaseException` を継承するように変更されました. .. exception:: MemoryError - .. Raised when an operation runs out of memory but the situation may still be - .. rescued (by deleting some objects). The associated value is a string indicating - .. what kind of (internal) operation ran out of memory. Note that because of the - .. underlying memory management architecture (C's :c:func:`malloc` function), the - .. interpreter may not always be able to completely recover from this situation; it - .. nevertheless raises an exception so that a stack traceback can be printed, in - .. case a run-away program was the cause. - ある操作中にメモリが不足したが、その状況は (オブジェクトをいくつか 消去することで) まだ復旧可能かもしれない場合に送出されます。例外の 関連値は、どんな種類の (内部) 操作がメモリ不足になっているか @@ -380,10 +251,6 @@ .. exception:: NameError - .. Raised when a local or global name is not found. This applies only to - .. unqualified names. The associated value is an error message that includes the - .. name that could not be found. - ローカルまたはグローバルの名前が見つからなかった場合に送出されます。 これは非限定の名前のみに適用されます。関連値は見つからなかった名前を 含むエラーメッセージです。 @@ -391,10 +258,6 @@ .. exception:: NotImplementedError - .. This exception is derived from :exc:`RuntimeError`. In user defined base - .. classes, abstract methods should raise this exception when they require derived - .. classes to override the method. - この例外は :exc:`RuntimeError` から派生しています。ユーザ定義の基底 クラスにおいて、抽象メソッドが派生クラスでオーバライドされることを 要求する場合、この例外を送出しなくてはなりません。 @@ -406,14 +269,6 @@ .. index:: module: errno - .. This exception is derived from :exc:`EnvironmentError`. It is raised when a - .. function returns a system-related error (not for illegal argument types or - .. other incidental errors). The :attr:`errno` attribute is a numeric error - .. code from :c:data:`errno`, and the :attr:`strerror` attribute is the - .. corresponding string, as would be printed by the C function :c:func:`perror`. - .. See the module :mod:`errno`, which contains names for the error codes defined - .. by the underlying operating system. - このクラスは :exc:`EnvironmentError` から派生しています。 関数がシステムに関連したエラーを返した場合に送出されます (引数の型が間違っている場合や、他の偶発的なエラーは除きます)。 @@ -423,10 +278,6 @@ オペレーティングシステムに依存したエラーコードの定義と名前については、 :mod:`errno` モジュールを参照して下さい。 - .. For exceptions that involve a file system path (such as :func:`chdir` or - .. :func:`unlink`), the exception instance will contain a third attribute, - .. :attr:`filename`, which is the file name passed to the function. - ファイルシステムのパスに関係する例外 (:func:`chdir` や :func:`unlink` など) では、例外インスタンスは 3 番目の属性 :attr:`filename` を持ちます。これは関数に渡されたファイル名です。 @@ -436,13 +287,6 @@ .. exception:: OverflowError - .. Raised when the result of an arithmetic operation is too large to be - .. represented. This cannot occur for long integers (which would rather raise - .. :exc:`MemoryError` than give up) and for most operations with plain integers, - .. which return a long integer instead. Because of the lack of standardization - .. of floating point exception handling in C, most floating point operations - .. also aren't checked. - 算術演算の結果が表現できない大きな値になった場合に送出されます。 これは long integer の演算と通常の整数に関するほとんどの操作では 起こりません (long integer の演算ではむしろ :exc:`MemoryError` が @@ -454,31 +298,18 @@ .. exception:: ReferenceError - .. This exception is raised when a weak reference proxy, created by the - .. :func:`weakref.proxy` function, is used to access an attribute of the referent - .. after it has been garbage collected. For more information on weak references, - .. see the :mod:`weakref` module. - :func:`weakref.proxy` によって生成された弱参照 (weak reference) プロキシを使って、ガーベジコレクションによって回収された後の参照対象 オブジェクトの属性にアクセスした場合に送出されます。弱参照については :mod:`weakref` モジュールを参照してください。 - .. .. versionadded:: 2.2 - .. .. Previously known as the :exc:`weakref.ReferenceError` exception. - .. versionadded:: 2.2 以前は :exc:`weakref.ReferenceError` 例外として知られていました。 .. exception:: RuntimeError - .. Raised when an error is detected that doesn't fall in any of the other - .. categories. The associated value is a string indicating what precisely went - .. wrong. (This exception is mostly a relic from a previous version of the - .. interpreter; it is not used very much any more.) - 他のカテゴリに分類できないエラーが検出された場合に送出されます。 関連値は、何が問題だったのかをより詳細に示す文字列です (この例外はほとんど過去のバージョンのインタプリタにおける遺物です。 @@ -487,11 +318,6 @@ .. exception:: StopIteration - .. Raised by an :term:`iterator`\'s :meth:`~iterator.next` method to signal that - .. there are no further values. This is derived from :exc:`Exception` rather - .. than :exc:`StandardError`, since this is not considered an error in its - .. normal application. - イテレータ (:term:`iterator`) の :meth:`~iterator.next` メソッドにより、 それ 以上要素がないことを知らせるために送出されます。 この例外は、通常の利用方法ではエラーとはみなされないため、 @@ -502,44 +328,37 @@ .. exception:: SyntaxError - .. Raised when the parser encounters a syntax error. This may occur in an - .. :keyword:`import` statement, in an :keyword:`exec` statement, in a call to the - .. built-in function :func:`eval` or :func:`input`, or when reading the initial - .. script or standard input (also interactively). - パーザが構文エラーに遭遇した場合に送出されます。この例外は :keyword:`import` 文、 :keyword:`exec` 文、組み込み関数 :func:`evel` や :func:`input` 、初期化スクリプトの読み込みや標準入 力で (対話的な実行時にも) 起こる可能性があります。 - .. Instances of this class have attributes :attr:`filename`, :attr:`lineno`, - .. :attr:`offset` and :attr:`text` for easier access to the details. :func:`str` - .. of the exception instance returns only the message. - このクラスのインスタンスは、例外の詳細に簡単にアクセスできるように するために、属性 :attr:`filename`, :attr:`lineno`, :attr:`offset`, :attr:`text` を持ちます。例外インスタンスに 対する :func:`str` はメッセージのみを返します。 -.. exception:: SystemError - - .. Raised when the interpreter finds an internal error, but the situation does not - .. look so serious to cause it to abandon all hope. The associated value is a - .. string indicating what went wrong (in low-level terms). +.. exception:: IndentationError + + 正しくないインデントに関する構文エラーの基底クラスです。これは + :exc:`SyntaxError` のサブクラスです。 + + +.. exception:: TabError + + タブとスペースを一貫しない方法でインデントに使っているときに送出されま す。 + これは :exc:`IndentationError` のサブクラスです。 + + +.. exception:: SystemError インタプリタが内部エラーを発見したが、その状況は全ての望みを棄てさ せるほど深刻ではないように思われる場合に送出されます。関連値は (下位層の言葉で) 何がまずいのかを示す文字列です。 - .. You should report this to the author or maintainer of your Python interpreter. - .. Be sure to report the version of the Python interpreter (``sys.version``; it is - .. also printed at the start of an interactive Python session), the exact error - .. message (the exception's associated value) and if possible the source of the - .. program that triggered the error. - Python の作者か、あなたの Python インタプリタを保守している人にこの エラーを報告してください。このとき、 Python インタプリタのバージョン (``sys.version``; Python の対話的セッションを開始した際にも出力 @@ -550,13 +369,6 @@ .. exception:: SystemExit - .. This exception is raised by the :func:`sys.exit` function. When it is not - .. handled, the Python interpreter exits; no stack traceback is printed. If the - .. associated value is a plain integer, it specifies the system exit status (passed - .. to C's :c:func:`exit` function); if it is ``None``, the exit status is zero; if - .. it has another type (such as a string), the object's value is printed and the - .. exit status is one. - この例外は :func:`sys.exit` 関数によって送出されます。この例外が 処理されなかった場合、スタックのトレースバックを全く表示することなく Python インタプリタは終了します。関連値が通常の整数であれば、 @@ -564,24 +376,12 @@ 値が ``None`` の場合、終了ステータスは 0 です。 (文字列のような) 他の 型の場合、そのオブジェクトの値が表示され、終了ステータスは 1 になりま す。 - .. Instances have an attribute :attr:`code` which is set to the proposed exit - .. status or error message (defaulting to ``None``). Also, this exception derives - .. directly from :exc:`BaseException` and not :exc:`StandardError`, since it is not - .. technically an error. - この例外のインスタンスは属性 :attr:`code` を持ちます。この値は終了 ステータスまたはエラーメッセージ (標準では ``None``) に設定されます。 また、この例外は厳密にはエラーではないため、 :exc:`StandardError` ではなく :exc:`BaseException` から派生しています。 - .. A call to :func:`sys.exit` is translated into an exception so that clean-up - .. handlers (:keyword:`finally` clauses of :keyword:`try` statements) can be - .. executed, and so that a debugger can execute a script without running the risk - .. of losing control. The :func:`os._exit` function can be used if it is - .. absolutely positively necessary to exit immediately (for example, in the child - .. process after a call to :func:`fork`). - :func:`sys.exit` は、クリーンアップのための処理 (:keyword:`try` 文の :keyword:`finally` 節) が実行されるようにするため、またデバッガが制 御不能になるリスクを冒さずにスクリプトを実行できるようにするために @@ -590,39 +390,24 @@ 関数を使うことができます。 - .. The exception inherits from :exc:`BaseException` instead of :exc:`StandardError` - .. or :exc:`Exception` so that it is not accidentally caught by code that catches - .. :exc:`Exception`. This allows the exception to properly propagate up and cause - .. the interpreter to exit. - この例外は :exc:`Exception` を捕まえるコードに間違って捕まえられな いように、 :exc:`StandardError` や :exc:`Exception` からではなく :exc:`BaseException` を継承しています。これにより、この例外は着 実に呼出し元の方に伝わっていってインタプリタを終了させます。 - .. .. versionchanged:: 2.5 - .. .. Changed to inherit from :exc:`BaseException`. - .. versionchanged:: 2.5 :exc:`BaseException` を継承するように変更されました。 .. exception:: TypeError - .. Raised when an operation or function is applied to an object of inappropriate - .. type. The associated value is a string giving details about the type mismatch. - 組み込み演算または関数が適切でない型のオブジェクトに対して適用され た際に送出されます。関連値は型の不整合に関して詳細を述べた文字列です。 .. exception:: UnboundLocalError - .. Raised when a reference is made to a local variable in a function or method, but - .. no value has been bound to that variable. This is a subclass of - .. :exc:`NameError`. - 関数やメソッド内のローカルな変数に対して参照を行ったが、その変数に は値が代入されていなかった場合に送出されます。 :exc:`NameError` のサブクラスです。 @@ -632,9 +417,6 @@ .. exception:: UnicodeError - .. Raised when a Unicode-related encoding or decoding error occurs. It is a - .. subclass of :exc:`ValueError`. - Unicode に関するエンコードまたはデコードのエラーが発生した際に送出 されます。 :exc:`ValueError` のサブクラスです。 @@ -643,9 +425,6 @@ .. exception:: UnicodeEncodeError - .. Raised when a Unicode-related error occurs during encoding. It is a subclass of - .. :exc:`UnicodeError`. - Unicode 関連のエラーがエンコード中に発生した際に送出されます。 :exc:`UnicodeError` のサブクラスです。 @@ -654,9 +433,6 @@ .. exception:: UnicodeDecodeError - .. Raised when a Unicode-related error occurs during decoding. It is a subclass of - .. :exc:`UnicodeError`. - Unicode 関連のエラーがデコード中に発生した際に送出されます。 :exc:`UnicodeError` のサブクラスです。 @@ -665,9 +441,6 @@ .. exception:: UnicodeTranslateError - .. Raised when a Unicode-related error occurs during translating. It is a subclass - .. of :exc:`UnicodeError`. - Unicode 関連のエラーがコード翻訳に発生した際に送出されます。 :exc:`UnicodeError` のサブクラスです。 @@ -676,30 +449,17 @@ .. exception:: ValueError - .. Raised when a built-in operation or function receives an argument that has the - .. right type but an inappropriate value, and the situation is not described by a - .. more precise exception such as :exc:`IndexError`. - 組み込み演算や関数が、正しい型だが適切でない値を受け取った場合や、 :exc:`IndexError` のような詳細な説明のできない状況で送出されます。 .. exception:: VMSError - .. Only available on VMS. Raised when a VMS-specific error occurs. - VMS においてのみ利用可能です。 VMS 特有のエラーが起こったときに送出され ます。 .. exception:: WindowsError - .. Raised when a Windows-specific error occurs or when the error number does not - .. correspond to an :c:data:`errno` value. The :attr:`winerror` and - .. :attr:`strerror` values are created from the return values of the - .. :c:func:`GetLastError` and :c:func:`FormatMessage` functions from the Windows - .. Platform API. The :attr:`errno` value maps the :attr:`winerror` value to - .. corresponding ``errno.h`` values. This is a subclass of :exc:`OSError`. - Windows 特有のエラーか、エラー番号が :c:data:`errno` 値に対応しない 場合に送出されます。 :attr:`winerrno` および :attr:`strerror` の値は Windows プラットフォーム API の関数 :c:func:`GetLastError` と @@ -710,9 +470,6 @@ .. versionadded:: 2.0 - .. .. versionchanged:: 2.5 - .. .. Previous versions put the :c:func:`GetLastError` codes into :attr:`errno`. - .. versionchanged:: 2.5 以前のバージョンは :c:func:`GetLastError` のコードを :attr:`errno` に入れていました。 @@ -720,75 +477,51 @@ .. exception:: ZeroDivisionError - .. Raised when the second argument of a division or modulo operation is zero. The - .. associated value is a string indicating the type of the operands and the - .. operation. - 除算またモジュロ演算における 2 番目の引数が 0 であった場合に送出されま す。 関連値は文字列で、その演算における被演算子と演算子の型を示します。 -.. The following exceptions are used as warning categories; see the :mod:`warnings` -.. module for more information. - 以下の例外は警告カテゴリとして使われます。詳細については :mod:`warnings` モジュールを参照してください。 .. exception:: Warning - .. Base class for warning categories. - 警告カテゴリの基底クラスです。 .. exception:: UserWarning - .. Base class for warnings generated by user code. - ユーザコードによって生成される警告の基底クラスです。 .. exception:: DeprecationWarning - .. Base class for warnings about deprecated features. - 廃止された機能に対する警告の基底クラスです。 .. exception:: PendingDeprecationWarning - .. Base class for warnings about features which will be deprecated in the future. - 将来廃止される予定の機能に対する警告の基底クラスです。 .. exception:: SyntaxWarning - .. Base class for warnings about dubious syntax - 曖昧な構文に対する警告の基底クラスです。 .. exception:: RuntimeWarning - .. Base class for warnings about dubious runtime behavior. - あいまいなランタイム挙動に対する警告の基底クラスです。 .. exception:: FutureWarning - .. Base class for warnings about constructs that will change semantically in the - .. future. - 将来意味構成が変わることになっている文の構成に対する警告の基底クラスで す。 .. exception:: ImportWarning - .. Base class for warnings about probable mistakes in module imports. - モジュールインポートの誤りと思われるものに対する警告の基底クラスです。 .. versionadded:: 2.5 @@ -796,9 +529,7 @@ .. exception:: UnicodeWarning - .. Base class for warnings related to Unicode. - - ユニコードに関連した警告の基底クラスです。 + Unicode に関連した警告の基底クラスです。 .. versionadded:: 2.5 @@ -806,8 +537,6 @@ 例外のクラス階層 ------------------- -.. The class hierarchy for built-in exceptions is: - 組み込み例外のクラス階層は以下のようになっています: ============================================================================== Revision: 584cc6cc6aad Author: Arihiro TAKASE <hinac****@gmail*****> Date: Sun Nov 13 23:28:08 2011 Log: merge http://code.google.com/p/python-doc-ja/source/detail?r=584cc6cc6aad Deleted: /glossary.rst.diff /glossary.rst.diff.html /tools/sphinxext/indexcontent.html.diff /tools/sphinxext/indexcontent.html.diff.html /tools/sphinxext/indexsidebar.html.diff /tools/sphinxext/patchlevel.py.diff /tools/sphinxext/patchlevel.py.diff.html /tools/sphinxext/pyspecific.py.diff /tools/sphinxext/pyspecific.py.diff.html /tools/sphinxext/susp-ignored.csv.diff /tools/sphinxext/susp-ignored.csv.diff.html /tools/sphinxext/suspicious.py.diff /tools/sphinxext/suspicious.py.diff.html ======================================= --- /glossary.rst.diff Sun Oct 30 17:04:23 2011 +++ /dev/null @@ -1,404 +0,0 @@ -@@ -10,33 +10,33 @@ - - ``>>>`` - The default Python prompt of the interactive shell. Often seen for code - examples which can be executed interactively in the interpreter. - - ``...`` - The default Python prompt of the interactive shell when entering code for - an indented code block or within a pair of matching left and right - delimiters (parentheses, square brackets or curly braces). - - 2to3 - A tool that tries to convert Python 2.x code to Python 3.x code by -- handling most of the incompatibilites which can be detected by parsing the -+ handling most of the incompatibilities which can be detected by parsing the - source and traversing the parse tree. - - 2to3 is available in the standard library as :mod:`lib2to3`; a standalone - entry point is provided as :file:`Tools/scripts/2to3`. See - :ref:`2to3-reference`. - - abstract base class -- Abstract Base Classes (abbreviated ABCs) complement :term:`duck-typing` by -+ :ref:`abstract-base-classes` complement :term:`duck-typing` by - providing a way to define interfaces when other techniques like - :func:`hasattr` would be clumsy. Python comes with many built-in ABCs for - data structures (in the :mod:`collections` module), numbers (in the - :mod:`numbers` module), and streams (in the :mod:`io` module). You can - create your own ABC with the :mod:`abc` module. - - argument - A value passed to a function or method, assigned to a named local - variable in the function body. A function or method may have both - positional arguments and keyword arguments in its definition. - Positional and keyword arguments may be variable-length: ``*`` accepts - or passes (if in the function definition or call) several positional -@@ -54,24 +54,27 @@ - BDFL - Benevolent Dictator For Life, a.k.a. `Guido van Rossum - <http://www.python.org/~guido/>`_, Python's creator. - - bytecode - Python source code is compiled into bytecode, the internal representation - of a Python program in the interpreter. The bytecode is also cached in - ``.pyc`` and ``.pyo`` files so that executing the same file is faster the - second time (recompilation from source to bytecode can be avoided). This - "intermediate language" is said to run on a :term:`virtual machine` - that executes the machine code corresponding to each bytecode. - -+ A list of bytecode instructions can be found in the documentation for -+ :ref:`the dis module <bytecodes>`. -+ - class - A template for creating user-defined objects. Class definitions - normally contain method definitions which operate on instances of the - class. - - classic class - Any class which does not inherit from :class:`object`. See - :term:`new-style class`. Classic classes will be removed in Python 3.0. - - coercion - The implicit conversion of an instance of one type to another during an - operation which involves two arguments of the same type. For example, -@@ -94,27 +97,28 @@ - written with this latter notation; the imaginary part is written with a - ``j`` suffix, e.g., ``3+1j``. To get access to complex equivalents of the - :mod:`math` module, use :mod:`cmath`. Use of complex numbers is a fairly - advanced mathematical feature. If you're not aware of a need for them, - it's almost certain you can safely ignore them. - - context manager - An object which controls the environment seen in a :keyword:`with` - statement by defining :meth:`__enter__` and :meth:`__exit__` methods. - See :pep:`343`. - - CPython -- The canonical implementation of the Python programming language. The -- term "CPython" is used in contexts when necessary to distinguish this -- implementation from others such as Jython or IronPython. -+ The canonical implementation of the Python programming language, as -+ distributed on `python.org <http://python.org>`_. The term "CPython" -+ is used when necessary to distinguish this implementation from others -+ such as Jython or IronPython. - - decorator - A function returning another function, usually applied as a function - transformation using the ``@wrapper`` syntax. Common examples for - decorators are :func:`classmethod` and :func:`staticmethod`. - - The decorator syntax is merely syntactic sugar, the following two - function definitions are semantically equivalent:: - - def f(...): - ... - f = staticmethod(f) -@@ -131,41 +135,40 @@ - :meth:`__set__`, or :meth:`__delete__`. When a class attribute is a - descriptor, its special binding behavior is triggered upon attribute - lookup. Normally, using *a.b* to get, set or delete an attribute looks up - the object named *b* in the class dictionary for *a*, but if *b* is a - descriptor, the respective descriptor method gets called. Understanding - descriptors is a key to a deep understanding of Python because they are - the basis for many features including functions, methods, properties, - class methods, static methods, and reference to super classes. - - For more information about descriptors' methods, see :ref:`descriptors`. - - dictionary -- An associative array, where arbitrary keys are mapped to values. The use -- of :class:`dict` closely resembles that for :class:`list`, but the keys can -- be any object with a :meth:`__hash__` function, not just integers. -- Called a hash in Perl. -+ An associative array, where arbitrary keys are mapped to values. The keys -+ can be any object with :meth:`__hash__` function and :meth:`__eq__` -+ methods. Called a hash in Perl. - - docstring - A string literal which appears as the first expression in a class, - function or module. While ignored when the suite is executed, it is - recognized by the compiler and put into the :attr:`__doc__` attribute - of the enclosing class, function or module. Since it is available via - introspection, it is the canonical place for documentation of the - object. - - duck-typing -- A pythonic programming style which determines an object's type by inspection -- of its method or attribute signature rather than by explicit relationship -- to some type object ("If it looks like a duck and quacks like a duck, it -+ A programming style which does not look at an object's type to determine -+ if it has the right interface; instead, the method or attribute is simply -+ called or used ("If it looks like a duck and quacks like a duck, it - must be a duck.") By emphasizing interfaces rather than specific types, - well-designed code improves its flexibility by allowing polymorphic - substitution. Duck-typing avoids tests using :func:`type` or - :func:`isinstance`. (Note, however, that duck-typing can be complemented - with :term:`abstract base class`\ es.) Instead, it typically employs - :func:`hasattr` tests or :term:`EAFP` programming. - - EAFP - Easier to ask for forgiveness than permission. This common Python coding - style assumes the existence of valid keys or attributes and catches - exceptions if the assumption proves false. This clean and fast style is - characterized by the presence of many :keyword:`try` and :keyword:`except` -@@ -173,117 +176,131 @@ - common to many other languages such as C. - - expression - A piece of syntax which can be evaluated to some value. In other words, - an expression is an accumulation of expression elements like literals, names, - attribute access, operators or function calls which all return a value. - In contrast to many other languages, not all language constructs are expressions. - There are also :term:`statement`\s which cannot be used as expressions, - such as :keyword:`print` or :keyword:`if`. Assignments are also statements, - not expressions. - - extension module -- A module written in C or C++, using Python's C API to interact with the core and -- with user code. -+ A module written in C or C++, using Python's C API to interact with the -+ core and with user code. - - finder - An object that tries to find the :term:`loader` for a module. It must - implement a method named :meth:`find_module`. See :pep:`302` for - details. - -+ floor division -+ Mathematical division that rounds down to nearest integer. The floor -+ division operator is ``//``. For example, the expression ``11 // 4`` -+ evaluates to ``2`` in contrast to the ``2.75`` returned by float true -+ division. Note that ``(-11) // 4`` is ``-3`` because that is ``-2.75`` -+ rounded *downward*. See :pep:`238`. -+ - function - A series of statements which returns some value to a caller. It can also - be passed zero or more arguments which may be used in the execution of - the body. See also :term:`argument` and :term:`method`. - - __future__ -- A pseudo module which programmers can use to enable new language features -+ A pseudo-module which programmers can use to enable new language features - which are not compatible with the current interpreter. For example, the - expression ``11/4`` currently evaluates to ``2``. If the module in which - it is executed had enabled *true division* by executing:: - - from __future__ import division - - the expression ``11/4`` would evaluate to ``2.75``. By importing the - :mod:`__future__` module and evaluating its variables, you can see when a - new feature was first added to the language and when it will become the - default:: - - >>> import __future__ - >>> __future__.division - _Feature((2, 2, 0, 'alpha', 2), (3, 0, 0, 'alpha', 0), 8192) - - garbage collection - The process of freeing memory when it is not used anymore. Python - performs garbage collection via reference counting and a cyclic garbage - collector that is able to detect and break reference cycles. - - .. index:: single: generator - - generator - A function which returns an iterator. It looks like a normal function -- except that values are returned to the caller using a :keyword:`yield` -- statement instead of a :keyword:`return` statement. Generator functions -- often contain one or more :keyword:`for` or :keyword:`while` loops which -- :keyword:`yield` elements back to the caller. The function execution is -- stopped at the :keyword:`yield` keyword (returning the result) and is -- resumed there when the next element is requested by calling the -- :meth:`next` method of the returned iterator. -+ except that it contains :keyword:`yield` statements for producing a series -+ a values usable in a for-loop or that can be retrieved one at a time with -+ the :func:`next` function. Each :keyword:`yield` temporarily suspends -+ processing, remembering the location execution state (including local -+ variables and pending try-statements). When the generator resumes, it -+ picks-up where it left-off (in contrast to functions which start fresh on -+ every invocation). - - .. index:: single: generator expression - - generator expression - An expression that returns an iterator. It looks like a normal expression - followed by a :keyword:`for` expression defining a loop variable, range, - and an optional :keyword:`if` expression. The combined expression - generates values for an enclosing function:: - - >>> sum(i*i for i in range(10)) # sum of squares 0, 1, 4, ... 81 - 285 - - GIL - See :term:`global interpreter lock`. - - global interpreter lock -- The lock used by Python threads to assure that only one thread -- executes in the :term:`CPython` :term:`virtual machine` at a time. -- This simplifies the CPython implementation by assuring that no two -- processes can access the same memory at the same time. Locking the -- entire interpreter makes it easier for the interpreter to be -- multi-threaded, at the expense of much of the parallelism afforded by -- multi-processor machines. Efforts have been made in the past to -- create a "free-threaded" interpreter (one which locks shared data at a -- much finer granularity), but so far none have been successful because -- performance suffered in the common single-processor case. -+ The mechanism used by the :term:`CPython` interpreter to assure that -+ only one thread executes Python :term:`bytecode` at a time. -+ This simplifies the CPython implementation by making the object model -+ (including critical built-in types such as :class:`dict`) implicitly -+ safe against concurrent access. Locking the entire interpreter -+ makes it easier for the interpreter to be multi-threaded, at the -+ expense of much of the parallelism afforded by multi-processor -+ machines. -+ -+ However, some extension modules, either standard or third-party, -+ are designed so as to release the GIL when doing computationally-intensive -+ tasks such as compression or hashing. Also, the GIL is always released -+ when doing I/O. -+ -+ Past efforts to create a "free-threaded" interpreter (one which locks -+ shared data at a much finer granularity) have not been successful -+ because performance suffered in the common single-processor case. It -+ is believed that overcoming this performance issue would make the -+ implementation much more complicated and therefore costlier to maintain. - - hashable - An object is *hashable* if it has a hash value which never changes during - its lifetime (it needs a :meth:`__hash__` method), and can be compared to - other objects (it needs an :meth:`__eq__` or :meth:`__cmp__` method). - Hashable objects which compare equal must have the same hash value. - - Hashability makes an object usable as a dictionary key and a set member, - because these data structures use the hash value internally. - - All of Python's immutable built-in objects are hashable, while no mutable - containers (such as lists or dictionaries) are. Objects which are - instances of user-defined classes are hashable by default; they all - compare unequal, and their hash value is their :func:`id`. - - IDLE - An Integrated Development Environment for Python. IDLE is a basic editor - and interpreter environment which ships with the standard distribution of -- Python. Good for beginners, it also serves as clear example code for -- those wanting to implement a moderately sophisticated, multi-platform GUI -- application. -+ Python. - - immutable - An object with a fixed value. Immutable objects include numbers, strings and - tuples. Such an object cannot be altered. A new object has to - be created if a different value has to be stored. They play an important - role in places where a constant hash value is needed, for example as a key - in a dictionary. - - integer division - Mathematical division discarding any remainder. For example, the - expression ``11/4`` currently evaluates to ``2`` in contrast to the - ``2.75`` returned by float division. Also called *floor division*. -@@ -340,24 +357,44 @@ - :meth:`next` method just raise :exc:`StopIteration` again. Iterators are - required to have an :meth:`__iter__` method that returns the iterator - object itself so every iterator is also iterable and may be used in most - places where other iterables are accepted. One notable exception is code - which attempts multiple iteration passes. A container object (such as a - :class:`list`) produces a fresh new iterator each time you pass it to the - :func:`iter` function or use it in a :keyword:`for` loop. Attempting this - with an iterator will just return the same exhausted iterator object used - in the previous iteration pass, making it appear like an empty container. - - More information can be found in :ref:`typeiter`. - -+ key function -+ A key function or collation function is a callable that returns a value -+ used for sorting or ordering. For example, :func:`locale.strxfrm` is -+ used to produce a sort key that is aware of locale specific sort -+ conventions. -+ -+ A number of tools in Python accept key functions to control how elements -+ are ordered or grouped. They include :func:`min`, :func:`max`, -+ :func:`sorted`, :meth:`list.sort`, :func:`heapq.nsmallest`, -+ :func:`heapq.nlargest`, and :func:`itertools.groupby`. -+ -+ There are several ways to create a key function. For example. the -+ :meth:`str.lower` method can serve as a key function for case insensitive -+ sorts. Alternatively, an ad-hoc key function can be built from a -+ :keyword:`lambda` expression such as ``lambda r: (r[0], r[2])``. Also, -+ the :mod:`operator` module provides three key function constuctors: -+ :func:`~operator.attrgetter`, :func:`~operator.itemgetter`, and -+ :func:`~operator.methodcaller`. See the :ref:`Sorting HOW TO -+ <sortinghowto>` for examples of how to create and use key functions. -+ - keyword argument - Arguments which are preceded with a ``variable_name=`` in the call. - The variable name designates the local name in the function to which the - value is assigned. ``**`` is used to accept or pass a dictionary of - keyword arguments. See :term:`argument`. - - lambda - An anonymous inline function consisting of a single :term:`expression` - which is evaluated when the function is called. The syntax to create - a lambda function is ``lambda [arguments]: expression`` - - LBYL -@@ -376,26 +413,29 @@ - return a list with the results. ``result = ["0x%02x" % x for x in - range(256) if x % 2 == 0]`` generates a list of strings containing - even hex numbers (0x..) in the range from 0 to 255. The :keyword:`if` - clause is optional. If omitted, all elements in ``range(256)`` are - processed. - - loader - An object that loads a module. It must define a method named - :meth:`load_module`. A loader is typically returned by a - :term:`finder`. See :pep:`302` for details. - - mapping -- A container object (such as :class:`dict`) which supports arbitrary key -- lookups using the special method :meth:`__getitem__`. -+ A container object that supports arbitrary key lookups and implements the -+ methods specified in the :class:`Mapping` or :class:`MutableMapping` -+ :ref:`abstract base classes <abstract-base-classes>`. Examples include -+ :class:`dict`, :class:`collections.defaultdict`, -+ :class:`collections.OrderedDict` and :class:`collections.Counter`. - - metaclass - The class of a class. Class definitions create a class name, a class - dictionary, and a list of base classes. The metaclass is responsible for - taking those three arguments and creating the class. Most object oriented - programming languages provide a default implementation. What makes Python - special is that it is possible to create custom metaclasses. Most users - never need this tool, but when the need arises, metaclasses can provide - powerful, elegant solutions. They have been used for logging attribute - access, adding thread-safety, tracking object creation, implementing - singletons, and many other tasks. - -@@ -533,20 +573,27 @@ - (") or an apostrophe ('). While they don't provide any functionality - not available with single-quoted strings, they are useful for a number - of reasons. They allow you to include unescaped single and double - quotes within a string and they can span multiple lines without the - use of the continuation character, making them especially useful when - writing docstrings. - - type - The type of a Python object determines what kind of object it is; every - object has a type. An object's type is accessible as its - :attr:`__class__` attribute or can be retrieved with ``type(obj)``. - -+ view -+ The objects returned from :meth:`dict.viewkeys`, :meth:`dict.viewvalues`, -+ and :meth:`dict.viewitems` are called dictionary views. They are lazy -+ sequences that will see changes in the underlying dictionary. To force -+ the dictionary view to become a full list use ``list(dictview)``. See -+ :ref:`dict-views`. -+ - virtual machine - A computer defined entirely in software. Python's virtual machine - executes the :term:`bytecode` emitted by the bytecode compiler. - - Zen of Python - Listing of Python design principles and philosophies that are helpful in - understanding and using the language. The listing can be found by typing - "``import this``" at the interactive prompt. ======================================= --- /glossary.rst.diff.html Sun Oct 30 17:04:23 2011 +++ /dev/null @@ -1,478 +0,0 @@ -<html> -<head> -<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> -<title>glossary.rst</title> -<style type="text/css"> -.highlight .hll { background-color: #ffffcc } -.highlight { background: #f8f8f8; } -.highlight .c { color: #408080; font-style: italic } /* Comment */ -.highlight .err { border: 1px solid #FF0000 } /* Error */ -.highlight .k { color: #008000; font-weight: bold } /* Keyword */ -.highlight .o { color: #666666 } /* Operator */ -.highlight .cm { color: #408080; font-style: italic } /* Comment.Multiline */ -.highlight .cp { color: #BC7A00 } /* Comment.Preproc */ -.highlight .c1 { color: #408080; font-style: italic } /* Comment.Single */ -.highlight .cs { color: #408080; font-style: italic } /* Comment.Special */ -.highlight .gd { color: #A00000 } /* Generic.Deleted */ -.highlight .ge { font-style: italic } /* Generic.Emph */ -.highlight .gr { color: #FF0000 } /* Generic.Error */ -.highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */ -.highlight .gi { color: #00A000 } /* Generic.Inserted */ -.highlight .go { color: #808080 } /* Generic.Output */ -.highlight .gp { color: #000080; font-weight: bold } /* Generic.Prompt */ -.highlight .gs { font-weight: bold } /* Generic.Strong */ -.highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ -.highlight .gt { color: #0040D0 } /* Generic.Traceback */ -.highlight .kc { color: #008000; font-weight: bold } /* Keyword.Constant */ -.highlight .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */ -.highlight .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */ -.highlight .kp { color: #008000 } /* Keyword.Pseudo */ -.highlight .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */ -.highlight .kt { color: #B00040 } /* Keyword.Type */ -.highlight .m { color: #666666 } /* Literal.Number */ -.highlight .s { color: #BA2121 } /* Literal.String */ -.highlight .na { color: #7D9029 } /* Name.Attribute */ -.highlight .nb { color: #008000 } /* Name.Builtin */ -.highlight .nc { color: #0000FF; font-weight: bold } /* Name.Class */ -.highlight .no { color: #880000 } /* Name.Constant */ -.highlight .nd { color: #AA22FF } /* Name.Decorator */ -.highlight .ni { color: #999999; font-weight: bold } /* Name.Entity */ -.highlight .ne { color: #D2413A; font-weight: bold } /* Name.Exception */ -.highlight .nf { color: #0000FF } /* Name.Function */ -.highlight .nl { color: #A0A000 } /* Name.Label */ -.highlight .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */ -.highlight .nt { color: #008000; font-weight: bold } /* Name.Tag */ -.highlight .nv { color: #19177C } /* Name.Variable */ -.highlight .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */ -.highlight .w { color: #bbbbbb } /* Text.Whitespace */ -.highlight .mf { color: #666666 } /* Literal.Number.Float */ -.highlight .mh { color: #666666 } /* Literal.Number.Hex */ -.highlight .mi { color: #666666 } /* Literal.Number.Integer */ -.highlight .mo { color: #666666 } /* Literal.Number.Oct */ -.highlight .sb { color: #BA2121 } /* Literal.String.Backtick */ -.highlight .sc { color: #BA2121 } /* Literal.String.Char */ -.highlight .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */ -.highlight .s2 { color: #BA2121 } /* Literal.String.Double */ -.highlight .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */ -.highlight .sh { color: #BA2121 } /* Literal.String.Heredoc */ -.highlight .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */ -.highlight .sx { color: #008000 } /* Literal.String.Other */ -.highlight .sr { color: #BB6688 } /* Literal.String.Regex */ -.highlight .s1 { color: #BA2121 } /* Literal.String.Single */ -.highlight .ss { color: #19177C } /* Literal.String.Symbol */ -.highlight .bp { color: #008000 } /* Name.Builtin.Pseudo */ -.highlight .vc { color: #19177C } /* Name.Variable.Class */ -.highlight .vg { color: #19177C } /* Name.Variable.Global */ -.highlight .vi { color: #19177C } /* Name.Variable.Instance */ -.highlight .il { color: #666666 } /* Literal.Number.Integer.Long */ -</style> -</head> -<body> -<div class="highlight"><pre><span class="gu">@@ -10,33 +10,33 @@</span> - - ``>>>`` - The default Python prompt of the interactive shell. Often seen for code - examples which can be executed interactively in the interpreter. - - ``...`` - The default Python prompt of the interactive shell when entering code for - an indented code block or within a pair of matching left and right - delimiters (parentheses, square brackets or curly braces). - - 2to3 - A tool that tries to convert Python 2.x code to Python 3.x code by -<span class="gd">- handling most of the incompatibilites which can be detected by parsing the</span> -<span class="gi">+ handling most of the incompatibilities which can be detected by parsing the</span> - source and traversing the parse tree. - - 2to3 is available in the standard library as :mod:`lib2to3`; a standalone - entry point is provided as :file:`Tools/scripts/2to3`. See - :ref:`2to3-reference`. - - abstract base class -<span class="gd">- Abstract Base Classes (abbreviated ABCs) complement :term:`duck-typing` by</span> -<span class="gi">+ :ref:`abstract-base-classes` complement :term:`duck-typing` by</span> - providing a way to define interfaces when other techniques like - :func:`hasattr` would be clumsy. Python comes with many built-in ABCs for - data structures (in the :mod:`collections` module), numbers (in the - :mod:`numbers` module), and streams (in the :mod:`io` module). You can - create your own ABC with the :mod:`abc` module. - - argument - A value passed to a function or method, assigned to a named local - variable in the function body. A function or method may have both - positional arguments and keyword arguments in its definition. - Positional and keyword arguments may be variable-length: ``*`` accepts - or passes (if in the function definition or call) several positional -<span class="gu">@@ -54,24 +54,27 @@</span> - BDFL - Benevolent Dictator For Life, a.k.a. `Guido van Rossum - <http://www.python.org/~guido/>`_, Python's creator. - - bytecode - Python source code is compiled into bytecode, the internal representation - of a Python program in the interpreter. The bytecode is also cached in - ``.pyc`` and ``.pyo`` files so that executing the same file is faster the - second time (recompilation from source to bytecode can be avoided). This - "intermediate language" is said to run on a :term:`virtual machine` - that executes the machine code corresponding to each bytecode. - -<span class="gi">+ A list of bytecode instructions can be found in the documentation for</span> -<span class="gi">+ :ref:`the dis module <bytecodes>`.</span> -<span class="gi">+</span> - class - A template for creating user-defined objects. Class definitions - normally contain method definitions which operate on instances of the - class. - - classic class - Any class which does not inherit from :class:`object`. See - :term:`new-style class`. Classic classes will be removed in Python 3.0. - - coercion - The implicit conversion of an instance of one type to another during an - operation which involves two arguments of the same type. For example, -<span class="gu">@@ -94,27 +97,28 @@</span> - written with this latter notation; the imaginary part is written with a - ``j`` suffix, e.g., ``3+1j``. To get access to complex equivalents of the - :mod:`math` module, use :mod:`cmath`. Use of complex numbers is a fairly - advanced mathematical feature. If you're not aware of a need for them, - it's almost certain you can safely ignore them. - - context manager - An object which controls the environment seen in a :keyword:`with` - statement by defining :meth:`__enter__` and :meth:`__exit__` methods. - See :pep:`343`. - - CPython -<span class="gd">- The canonical implementation of the Python programming language. The</span> -<span class="gd">- term "CPython" is used in contexts when necessary to distinguish this</span> -<span class="gd">- implementation from others such as Jython or IronPython.</span> -<span class="gi">+ The canonical implementation of the Python programming language, as</span> -<span class="gi">+ distributed on `python.org <http://python.org>`_. The term "CPython"</span> -<span class="gi">+ is used when necessary to distinguish this implementation from others</span> -<span class="gi">+ such as Jython or IronPython.</span> - - decorator - A function returning another function, usually applied as a function - transformation using the ``@wrapper`` syntax. Common examples for - decorators are :func:`classmethod` and :func:`staticmethod`. - - The decorator syntax is merely syntactic sugar, the following two - function definitions are semantically equivalent:: - - def f(...): - ... - f = staticmethod(f) -<span class="gu">@@ -131,41 +135,40 @@</span> - :meth:`__set__`, or :meth:`__delete__`. When a class attribute is a - descriptor, its special binding behavior is triggered upon attribute - lookup. Normally, using *a.b* to get, set or delete an attribute looks up - the object named *b* in the class dictionary for *a*, but if *b* is a - descriptor, the respective descriptor method gets called. Understanding - descriptors is a key to a deep understanding of Python because they are - the basis for many features including functions, methods, properties, - class methods, static methods, and reference to super classes. - - For more information about descriptors' methods, see :ref:`descriptors`. - - dictionary -<span class="gd">- An associative array, where arbitrary keys are mapped to values. The use</span> -<span class="gd">- of :class:`dict` closely resembles that for :class:`list`, but the keys can</span> -<span class="gd">- be any object with a :meth:`__hash__` function, not just integers.</span> -<span class="gd">- Called a hash in Perl.</span> -<span class="gi">+ An associative array, where arbitrary keys are mapped to values. The keys</span> -<span class="gi">+ can be any object with :meth:`__hash__` function and :meth:`__eq__`</span> -<span class="gi">+ methods. Called a hash in Perl.</span> - - docstring - A string literal which appears as the first expression in a class, - function or module. While ignored when the suite is executed, it is - recognized by the compiler and put into the :attr:`__doc__` attribute - of the enclosing class, function or module. Since it is available via - introspection, it is the canonical place for documentation of the - object. - - duck-typing -<span class="gd">- A pythonic programming style which determines an object's type by inspection</span> -<span class="gd">- of its method or attribute signature rather than by explicit relationship</span> -<span class="gd">- to some type object ("If it looks like a duck and quacks like a duck, it</span> -<span class="gi">+ A programming style which does not look at an object's type to determine</span> -<span class="gi">+ if it has the right interface; instead, the method or attribute is simply</span> -<span class="gi">+ called or used ("If it looks like a duck and quacks like a duck, it</span> - must be a duck.") By emphasizing interfaces rather than specific types, - well-designed code improves its flexibility by allowing polymorphic - substitution. Duck-typing avoids tests using :func:`type` or - :func:`isinstance`. (Note, however, that duck-typing can be complemented - with :term:`abstract base class`\ es.) Instead, it typically employs - :func:`hasattr` tests or :term:`EAFP` programming. - - EAFP - Easier to ask for forgiveness than permission. This common Python coding - style assumes the existence of valid keys or attributes and catches - exceptions if the assumption proves false. This clean and fast style is - characterized by the presence of many :keyword:`try` and :keyword:`except` -<span class="gu">@@ -173,117 +176,131 @@</span> - common to many other languages such as C. - - expression - A piece of syntax which can be evaluated to some value. In other words, - an expression is an accumulation of expression elements like literals, names, - attribute access, operators or function calls which all return a value. - In contrast to many other languages, not all language constructs are expressions. - There are also :term:`statement`\s which cannot be used as expressions, - such as :keyword:`print` or :keyword:`if`. Assignments are also statements, - not expressions. - - extension module -<span class="gd">- A module written in C or C++, using Python's C API to interact with the core and</span> -<span class="gd">- with user code.</span> -<span class="gi">+ A module written in C or C++, using Python's C API to interact with the</span> -<span class="gi">+ core and with user code.</span> - - finder - An object that tries to find the :term:`loader` for a module. It must - implement a method named :meth:`find_module`. See :pep:`302` for - details. - -<span class="gi">+ floor division</span> -<span class="gi">+ Mathematical division that rounds down to nearest integer. The floor</span> -<span class="gi">+ division operator is ``//``. For example, the expression ``11 // 4``</span> -<span class="gi">+ evaluates to ``2`` in contrast to the ``2.75`` returned by float true</span> -<span class="gi">+ division. Note that ``(-11) // 4`` is ``-3`` because that is ``-2.75``</span> -<span class="gi">+ rounded *downward*. See :pep:`238`.</span> -<span class="gi">+</span> - function - A series of statements which returns some value to a caller. It can also - be passed zero or more arguments which may be used in the execution of - the body. See also :term:`argument` and :term:`method`. - - __future__ -<span class="gd">- A pseudo module which programmers can use to enable new language features</span> -<span class="gi">+ A pseudo-module which programmers can use to enable new language features</span> - which are not compatible with the current interpreter. For example, the - expression ``11/4`` currently evaluates to ``2``. If the module in which - it is executed had enabled *true division* by executing:: - - from __future__ import division - - the expression ``11/4`` would evaluate to ``2.75``. By importing the - :mod:`__future__` module and evaluating its variables, you can see when a - new feature was first added to the language and when it will become the - default:: - - >>> import __future__ - >>> __future__.division - _Feature((2, 2, 0, 'alpha', 2), (3, 0, 0, 'alpha', 0), 8192) - - garbage collection - The process of freeing memory when it is not used anymore. Python - performs garbage collection via reference counting and a cyclic garbage - collector that is able to detect and break reference cycles. - - .. index:: single: generator - - generator - A function which returns an iterator. It looks like a normal function -<span class="gd">- except that values are returned to the caller using a :keyword:`yield`</span> -<span class="gd">- statement instead of a :keyword:`return` statement. Generator functions</span> -<span class="gd">- often contain one or more :keyword:`for` or :keyword:`while` loops which</span> -<span class="gd">- :keyword:`yield` elements back to the caller. The function execution is</span> -<span class="gd">- stopped at the :keyword:`yield` keyword (returning the result) and is</span> -<span class="gd">- resumed there when the next element is requested by calling the</span> -<span class="gd">- :meth:`next` method of the returned iterator.</span> -<span class="gi">+ except that it contains :keyword:`yield` statements for producing a series</span> -<span class="gi">+ a values usable in a for-loop or that can be retrieved one at a time with</span> -<span class="gi">+ the :func:`next` function. Each :keyword:`yield` temporarily suspends</span> -<span class="gi">+ processing, remembering the location execution state (including local</span> -<span class="gi">+ variables and pending try-statements). When the generator resumes, it</span> -<span class="gi">+ picks-up where it left-off (in contrast to functions which start fresh on</span> -<span class="gi">+ every invocation).</span> - - .. index:: single: generator expression - - generator expression - An expression that returns an iterator. It looks like a normal expression - followed by a :keyword:`for` expression defining a loop variable, range, - and an optional :keyword:`if` expression. The combined expression - generates values for an enclosing function:: - - >>> sum(i*i for i in range(10)) # sum of squares 0, 1, 4, ... 81 - 285 - - GIL - See :term:`global interpreter lock`. - - global interpreter lock -<span class="gd">- The lock used by Python threads to assure that only one thread</span> -<span class="gd">- executes in the :term:`CPython` :term:`virtual machine` at a time.</span> -<span class="gd">- This simplifies the CPython implementation by assuring that no two</span> -<span class="gd">- processes can access the same memory at the same time. Locking the</span> -<span class="gd">- entire interpreter makes it easier for the interpreter to be</span> -<span class="gd">- multi-threaded, at the expense of much of the parallelism afforded by</span> -<span class="gd">- multi-processor machines. Efforts have been made in the past to</span> -<span class="gd">- create a "free-threaded" interpreter (one which locks shared data at a</span> -<span class="gd">- much finer granularity), but so far none have been successful because</span> -<span class="gd">- performance suffered in the common single-processor case.</span> -<span class="gi">+ The mechanism used by the :term:`CPython` interpreter to assure that</span> -<span class="gi">+ only one thread executes Python :term:`bytecode` at a time.</span> -<span class="gi">+ This simplifies the CPython implementation by making the object model</span> -<span class="gi">+ (including critical built-in types such as :class:`dict`) implicitly</span> -<span class="gi">+ safe against concurrent access. Locking the entire interpreter</span> -<span class="gi">+ makes it easier for the interpreter to be multi-threaded, at the</span> -<span class="gi">+ expense of much of the parallelism afforded by multi-processor</span> -<span class="gi">+ machines.</span> -<span class="gi">+</span> -<span class="gi">+ However, some extension modules, either standard or third-party,</span> -<span class="gi">+ are designed so as to release the GIL when doing computationally-intensive</span> -<span class="gi">+ tasks such as compression or hashing. Also, the GIL is always released</span> -<span class="gi">+ when doing I/O.</span> -<span class="gi">+</span> -<span class="gi">+ Past efforts to create a "free-threaded" interpreter (one which locks</span> -<span class="gi">+ shared data at a much finer granularity) have not been successful</span> -<span class="gi">+ because performance suffered in the common single-processor case. It</span> -<span class="gi">+ is believed that overcoming this performance issue would make the</span> -<span class="gi">+ implementation much more complicated and therefore costlier to maintain.</span> - - hashable - An object is *hashable* if it has a hash value which never changes during - its lifetime (it needs a :meth:`__hash__` method), and can be compared to - other objects (it needs an :meth:`__eq__` or :meth:`__cmp__` method). - Hashable objects which compare equal must have the same hash value. - - Hashability makes an object usable as a dictionary key and a set member, - because these data structures use the hash value internally. - - All of Python's immutable built-in objects are hashable, while no mutable - containers (such as lists or dictionaries) are. Objects which are - instances of user-defined classes are hashable by default; they all - compare unequal, and their hash value is their :func:`id`. - - IDLE - An Integrated Development Environment for Python. IDLE is a basic editor - and interpreter environment which ships with the standard distribution of -<span class="gd">- Python. Good for beginners, it also serves as clear example code for</span> -<span class="gd">- those wanting to implement a moderately sophisticated, multi-platform GUI</span> -<span class="gd">- application.</span> -<span class="gi">+ Python.</span> - - immutable - An object with a fixed value. Immutable objects include numbers, strings and - tuples. Such an object cannot be altered. A new object has to - be created if a different value has to be stored. They play an important - role in places where a constant hash value is needed, for example as a key - in a dictionary. - - integer division - Mathematical division discarding any remainder. For example, the - expression ``11/4`` currently evaluates to ``2`` in contrast to the - ``2.75`` returned by float division. Also called *floor division*. -<span class="gu">@@ -340,24 +357,44 @@</span> - :meth:`next` method just raise :exc:`StopIteration` again. Iterators are - required to have an :meth:`__iter__` method that returns the iterator - object itself so every iterator is also iterable and may be used in most - places where other iterables are accepted. One notable exception is code - which attempts multiple iteration passes. A container object (such as a - :class:`list`) produces a fresh new iterator each time you pass it to the - :func:`iter` function or use it in a :keyword:`for` loop. Attempting this - with an iterator will just return the same exhausted iterator object used - in the previous iteration pass, making it appear like an empty container. - - More information can be found in :ref:`typeiter`. - -<span class="gi">+ key function</span> -<span class="gi">+ A key function or collation function is a callable that returns a value</span> -<span class="gi">+ used for sorting or ordering. For example, :func:`locale.strxfrm` is</span> -<span class="gi">+ used to produce a sort key that is aware of locale specific sort</span> -<span class="gi">+ conventions.</span> -<span class="gi">+</span> -<span class="gi">+ A number of tools in Python accept key functions to control how elements</span> -<span class="gi">+ are ordered or grouped. They include :func:`min`, :func:`max`,</span> -<span class="gi">+ :func:`sorted`, :meth:`list.sort`, :func:`heapq.nsmallest`,</span> -<span class="gi">+ :func:`heapq.nlargest`, and :func:`itertools.groupby`.</span> -<span class="gi">+</span> -<span class="gi">+ There are several ways to create a key function. For example. the</span> -<span class="gi">+ :meth:`str.lower` method can serve as a key function for case insensitive</span> -<span class="gi">+ sorts. Alternatively, an ad-hoc key function can be built from a</span> -<span class="gi">+ :keyword:`lambda` expression such as ``lambda r: (r[0], r[2])``. Also,</span> -<span class="gi">+ the :mod:`operator` module provides three key function constuctors:</span> -<span class="gi">+ :func:`~operator.attrgetter`, :func:`~operator.itemgetter`, and</span> -<span class="gi">+ :func:`~operator.methodcaller`. See the :ref:`Sorting HOW TO</span> -<span class="gi">+ <sortinghowto>` for examples of how to create and use key functions.</span> -<span class="gi">+</span> - keyword argument - Arguments which are preceded with a ``variable_name=`` in the call. - The variable name designates the local name in the function to which the - value is assigned. ``**`` is used to accept or pass a dictionary of - keyword arguments. See :term:`argument`. - - lambda - An anonymous inline function consisting of a single :term:`expression` - which is evaluated when the function is called. The syntax to create - a lambda function is ``lambda [arguments]: expression`` - - LBYL -<span class="gu">@@ -376,26 +413,29 @@</span> - return a list with the results. ``result = ["0x%02x" % x for x in - range(256) if x % 2 == 0]`` generates a list of strings containing - even hex numbers (0x..) in the range from 0 to 255. The :keyword:`if` - clause is optional. If omitted, all elements in ``range(256)`` are - processed. - - loader - An object that loads a module. It must define a method named - :meth:`load_module`. A loader is typically returned by a - :term:`finder`. See :pep:`302` for details. - - mapping -<span class="gd">- A container object (such as :class:`dict`) which supports arbitrary key</span> -<span class="gd">- lookups using the special method :meth:`__getitem__`.</span> -<span class="gi">+ A container object that supports arbitrary key lookups and implements the</span> -<span class="gi">+ methods specified in the :class:`Mapping` or :class:`MutableMapping`</span> -<span class="gi">+ :ref:`abstract base classes <abstract-base-classes>`. Examples include</span> -<span class="gi">+ :class:`dict`, :class:`collections.defaultdict`,</span> -<span class="gi">+ :class:`collections.OrderedDict` and :class:`collections.Counter`.</span> - - metaclass - The class of a class. Class definitions create a class name, a class - dictionary, and a list of base classes. The metaclass is responsible for - taking those three arguments and creating the class. Most object oriented - programming languages provide a default implementation. What makes Python - special is that it is possible to create custom metaclasses. Most users - never need this tool, but when the need arises, metaclasses can provide - powerful, elegant solutions. They have been used for logging attribute - access, adding thread-safety, tracking object creation, implementing - singletons, and many other tasks. - -<span class="gu">@@ -533,20 +573,27 @@</span> - (") or an apostrophe ('). While they don't provide any functionality - not available with single-quoted strings, they are useful for a number - of reasons. They allow you to include unescaped single and double - quotes within a string and they can span multiple lines without the - use of the continuation character, making them especially useful when - writing docstrings. - - type - The type of a Python object determines what kind of object it is; every - object has a type. An object's type is accessible as its - :attr:`__class__` attribute or can be retrieved with ``type(obj)``. - -<span class="gi">+ view</span> -<span class="gi">+ The objects returned from :meth:`dict.viewkeys`, :meth:`dict.viewvalues`,</span> -<span class="gi">+ and :meth:`dict.viewitems` are called dictionary views. They are lazy</span> -<span class="gi">+ sequences that will see changes in the underlying dictionary. To force</span> -<span class="gi">+ the dictionary view to become a full list use ``list(dictview)``. See</span> -<span class="gi">+ :ref:`dict-views`.</span> -<span class="gi">+</span> - virtual machine - A computer defined entirely in software. Python's virtual machine - executes the :term:`bytecode` emitted by the bytecode compiler. - - Zen of Python - Listing of Python design principles and philosophies that are helpful in - understanding and using the language. The listing can be found by typing - "``import this``" at the interactive prompt. -</pre></div> - -</body> -</html> ======================================= --- /tools/sphinxext/indexcontent.html.diff Sun Oct 30 17:04:23 2011 +++ /dev/null @@ -1,30 +0,0 @@ -@@ -1,27 +1,27 @@ - {% extends "defindex.html" %} - {% block tables %} - <p><strong>Parts of the documentation:</strong></p> - <table class="contentstable" align="center"><tr> - <td width="50%"> - <p class="biglink"><a class="biglink" href="{{ pathto("whatsnew/" + version) }}">What's new in Python {{ version }}?</a><br/> - <span class="linkdescr">or <a href="{{ pathto("whatsnew/index") }}">all "What's new" documents</a> since 2.0</span></p> - <p class="biglink"><a class="biglink" href="{{ pathto("tutorial/index") }}">Tutorial</a><br/> - <span class="linkdescr">start here</span></p> -- <p class="biglink"><a class="biglink" href="{{ pathto("using/index") }}">Using Python</a><br/> -- <span class="linkdescr">how to use Python on different platforms</span></p> - <p class="biglink"><a class="biglink" href="{{ pathto("library/index") }}">Library Reference</a><br/> - <span class="linkdescr">keep this under your pillow</span></p> - <p class="biglink"><a class="biglink" href="{{ pathto("reference/index") }}">Language Reference</a><br/> - <span class="linkdescr">describes syntax and language elements</span></p> -+ <p class="biglink"><a class="biglink" href="{{ pathto("using/index") }}">Python Setup and Usage</a><br/> -+ <span class="linkdescr">how to use Python on different platforms</span></p> - <p class="biglink"><a class="biglink" href="{{ pathto("howto/index") }}">Python HOWTOs</a><br/> - <span class="linkdescr">in-depth documents on specific topics</span></p> - </td><td width="50%"> - <p class="biglink"><a class="biglink" href="{{ pathto("extending/index") }}">Extending and Embedding</a><br/> - <span class="linkdescr">tutorial for C/C++ programmers</span></p> - <p class="biglink"><a class="biglink" href="{{ pathto("c-api/index") }}">Python/C API</a><br/> - <span class="linkdescr">reference for C/C++ programmers</span></p> - <p class="biglink"><a class="biglink" href="{{ pathto("install/index") }}">Installing Python Modules</a><br/> - <span class="linkdescr">information for installers & sys-admins</span></p> - <p class="biglink"><a class="biglink" href="{{ pathto("distutils/index") }}">Distributing Python Modules</a><br/> - <span class="linkdescr">sharing modules with others</span></p> - <p class="biglink"><a class="biglink" href="{{ pathto("documenting/index") }}">Documenting Python</a><br/> ======================================= --- /tools/sphinxext/indexcontent.html.diff.html Sun Oct 30 17:04:23 2011 +++ /dev/null @@ -1,104 +0,0 @@ -<html> -<head> -<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> -<title>tools/sphinxext/indexcontent.html</title> -<style type="text/css"> -.highlight .hll { background-color: #ffffcc } -.highlight { background: #f8f8f8; } -.highlight .c { color: #408080; font-style: italic } /* Comment */ -.highlight .err { border: 1px solid #FF0000 } /* Error */ -.highlight .k { color: #008000; font-weight: bold } /* Keyword */ -.highlight .o { color: #666666 } /* Operator */ -.highlight .cm { color: #408080; font-style: italic } /* Comment.Multiline */ -.highlight .cp { color: #BC7A00 } /* Comment.Preproc */ -.highlight .c1 { color: #408080; font-style: italic } /* Comment.Single */ -.highlight .cs { color: #408080; font-style: italic } /* Comment.Special */ -.highlight .gd { color: #A00000 } /* Generic.Deleted */ -.highlight .ge { font-style: italic } /* Generic.Emph */ -.highlight .gr { color: #FF0000 } /* Generic.Error */ -.highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */ -.highlight .gi { color: #00A000 } /* Generic.Inserted */ -.highlight .go { color: #808080 } /* Generic.Output */ -.highlight .gp { color: #000080; font-weight: bold } /* Generic.Prompt */ -.highlight .gs { font-weight: bold } /* Generic.Strong */ -.highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ -.highlight .gt { color: #0040D0 } /* Generic.Traceback */ -.highlight .kc { color: #008000; font-weight: bold } /* Keyword.Constant */ -.highlight .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */ -.highlight .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */ -.highlight .kp { color: #008000 } /* Keyword.Pseudo */ -.highlight .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */ -.highlight .kt { color: #B00040 } /* Keyword.Type */ -.highlight .m { color: #666666 } /* Literal.Number */ -.highlight .s { color: #BA2121 } /* Literal.String */ -.highlight .na { color: #7D9029 } /* Name.Attribute */ -.highlight .nb { color: #008000 } /* Name.Builtin */ -.highlight .nc { color: #0000FF; font-weight: bold } /* Name.Class */ -.highlight .no { color: #880000 } /* Name.Constant */ -.highlight .nd { color: #AA22FF } /* Name.Decorator */ -.highlight .ni { color: #999999; font-weight: bold } /* Name.Entity */ -.highlight .ne { color: #D2413A; font-weight: bold } /* Name.Exception */ -.highlight .nf { color: #0000FF } /* Name.Function */ -.highlight .nl { color: #A0A000 } /* Name.Label */ -.highlight .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */ -.highlight .nt { color: #008000; font-weight: bold } /* Name.Tag */ -.highlight .nv { color: #19177C } /* Name.Variable */ -.highlight .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */ -.highlight .w { color: #bbbbbb } /* Text.Whitespace */ -.highlight .mf { color: #666666 } /* Literal.Number.Float */ -.highlight .mh { color: #666666 } /* Literal.Number.Hex */ -.highlight .mi { color: #666666 } /* Literal.Number.Integer */ -.highlight .mo { color: #666666 } /* Literal.Number.Oct */ -.highlight .sb { color: #BA2121 } /* Literal.String.Backtick */ -.highlight .sc { color: #BA2121 } /* Literal.String.Char */ -.highlight .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */ -.highlight .s2 { color: #BA2121 } /* Literal.String.Double */ -.highlight .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */ -.highlight .sh { color: #BA2121 } /* Literal.String.Heredoc */ -.highlight .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */ -.highlight .sx { color: #008000 } /* Literal.String.Other */ -.highlight .sr { color: #BB6688 } /* Literal.String.Regex */ -.highlight .s1 { color: #BA2121 } /* Literal.String.Single */ -.highlight .ss { color: #19177C } /* Literal.String.Symbol */ -.highlight .bp { color: #008000 } /* Name.Builtin.Pseudo */ -.highlight .vc { color: #19177C } /* Name.Variable.Class */ -.highlight .vg { color: #19177C } /* Name.Variable.Global */ -.highlight .vi { color: #19177C } /* Name.Variable.Instance */ -.highlight .il { color: #666666 } /* Literal.Number.Integer.Long */ -</style> -</head> -<body> -<div class="highlight"><pre><span class="gu">@@ -1,27 +1,27 @@</span> - {% extends "defindex.html" %} - {% block tables %} - <p><strong>Parts of the documentation:</strong></p> - <table class="contentstable" align="center"><tr> - <td width="50%"> - <p class="biglink"><a class="biglink" href="{{ pathto("whatsnew/" + version) }}">What's new in Python {{ version }}?</a><br/> - <span class="linkdescr">or <a href="{{ pathto("whatsnew/index") }}">all "What's new" documents</a> since 2.0</span></p> - <p class="biglink"><a class="biglink" href="{{ pathto("tutorial/index") }}">Tutorial</a><br/> - <span class="linkdescr">start here</span></p> -<span class="gd">- <p class="biglink"><a class="biglink" href="{{ pathto("using/index") }}">Using Python</a><br/></span> -<span class="gd">- <span class="linkdescr">how to use Python on different platforms</span></p></span> - <p class="biglink"><a class="biglink" href="{{ pathto("library/index") }}">Library Reference</a><br/> - <span class="linkdescr">keep this under your pillow</span></p> - <p class="biglink"><a class="biglink" href="{{ pathto("reference/index") }}">Language Reference</a><br/> - <span class="linkdescr">describes syntax and language elements</span></p> -<span class="gi">+ <p class="biglink"><a class="biglink" href="{{ pathto("using/index") }}">Python Setup and Usage</a><br/></span> -<span class="gi">+ <span class="linkdescr">how to use Python on different platforms</span></p></span> - <p class="biglink"><a class="biglink" href="{{ pathto("howto/index") }}">Python HOWTOs</a><br/> - <span class="linkdescr">in-depth documents on specific topics</span></p> - </td><td width="50%"> - <p class="biglink"><a class="biglink" href="{{ pathto("extending/index") }}">Extending and Embedding</a><br/> - <span class="linkdescr">tutorial for C/C++ programmers</span></p> - <p class="biglink"><a class="biglink" href="{{ pathto("c-api/index") }}">Python/C API</a><br/> - <span class="linkdescr">reference for C/C++ programmers</span></p> - <p class="biglink"><a class="biglink" href="{{ pathto("install/index") }}">Installing Python Modules</a><br/> - <span class="linkdescr">information for installers &amp; sys-admins</span></p> - <p class="biglink"><a class="biglink" href="{{ pathto("distutils/index") }}">Distributing Python Modules</a><br/> - <span class="linkdescr">sharing modules with others</span></p> - <p class="biglink"><a class="biglink" href="{{ pathto("documenting/index") }}">Documenting Python</a><br/> -</pre></div> - -</body> -</html> ======================================= --- /tools/sphinxext/indexsidebar.html.diff Sun Oct 30 17:04:23 2011 +++ /dev/null @@ -1,23 +0,0 @@ -@@ -1,19 +1,19 @@ - <h3>Download</h3> - <p><a href="{{ pathto('download') }}">Download these documents</a></p> - <h3>Docs for other versions</h3> - <ul> -- <li><a href="http://docs.python.org/2.7/">Python 2.7 (stable)</a></li> -- <li><a href="http://docs.python.org/3.1/">Python 3.1 (stable)</a></li> -- <li><a href="http://docs.python.org/dev/py3k/">Python 3.2 (in development)</a></li> -+ <li><a href="http://docs.python.org/2.6/">Python 2.6 (stable)</a></li> -+ <li><a href="http://docs.python.org/3.2/">Python 3.2 (stable)</a></li> -+ <li><a href="http://docs.python.org/dev/">Python 3.3 (in development)</a></li> - <li><a href="http://www.python.org/doc/versions/">Old versions</a></li> - </ul> - - <h3>Other resources</h3> - <ul> - {# XXX: many of these should probably be merged in the main docs #} - <li><a href="http://www.python.org/doc/faq/">FAQs</a></li> - <li><a href="http://www.python.org/doc/essays/">Guido's Essays</a></li> - <li><a href="http://www.python.org/doc/newstyle/">New-style Classes</a></li> - <li><a href="http://www.python.org/dev/peps/">PEP Index</a></li> - <li><a href="http://wiki.python.org/moin/BeginnersGuide">Beginner's Guide</a></li> - <li><a href="http://wiki.python.org/moin/PythonBooks">Book List</a></li> ======================================= --- /tools/sphinxext/patchlevel.py.diff Sun Oct 30 17:04:23 2011 +++ /dev/null @@ -1,27 +0,0 @@ -@@ -32,25 +32,25 @@ - finally: - f.close() - - release = version = '%s.%s' % (d['PY_MAJOR_VERSION'], d['PY_MINOR_VERSION']) - micro = int(d['PY_MICRO_VERSION']) - if micro != 0: - release += '.' + str(micro) - - level = d['PY_RELEASE_LEVEL'] - suffixes = { - 'PY_RELEASE_LEVEL_ALPHA': 'a', - 'PY_RELEASE_LEVEL_BETA': 'b', -- 'PY_RELEASE_LEVEL_GAMMA': 'c', -+ 'PY_RELEASE_LEVEL_GAMMA': 'rc', - } - if level != 'PY_RELEASE_LEVEL_FINAL': - release += suffixes[level] + str(int(d['PY_RELEASE_SERIAL'])) - return version, release - - - def get_sys_version_info(): - major, minor, micro, level, serial = sys.version_info - release = version = '%s.%s' % (major, minor) - if micro: - release += '.%s' % micro - if level != 'final': ======================================= --- /tools/sphinxext/patchlevel.py.diff.html Sun Oct 30 17:04:23 2011 +++ /dev/null @@ -1,101 +0,0 @@ -<html> -<head> -<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> -<title>tools/sphinxext/patchlevel.py</title> -<style type="text/css"> -.highlight .hll { background-color: #ffffcc } -.highlight { background: #f8f8f8; } -.highlight .c { color: #408080; font-style: italic } /* Comment */ -.highlight .err { border: 1px solid #FF0000 } /* Error */ -.highlight .k { color: #008000; font-weight: bold } /* Keyword */ -.highlight .o { color: #666666 } /* Operator */ -.highlight .cm { color: #408080; font-style: italic } /* Comment.Multiline */ -.highlight .cp { color: #BC7A00 } /* Comment.Preproc */ -.highlight .c1 { color: #408080; font-style: italic } /* Comment.Single */ -.highlight .cs { color: #408080; font-style: italic } /* Comment.Special */ -.highlight .gd { color: #A00000 } /* Generic.Deleted */ -.highlight .ge { font-style: italic } /* Generic.Emph */ -.highlight .gr { color: #FF0000 } /* Generic.Error */ -.highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */ -.highlight .gi { color: #00A000 } /* Generic.Inserted */ -.highlight .go { color: #808080 } /* Generic.Output */ -.highlight .gp { color: #000080; font-weight: bold } /* Generic.Prompt */ -.highlight .gs { font-weight: bold } /* Generic.Strong */ -.highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ -.highlight .gt { color: #0040D0 } /* Generic.Traceback */ -.highlight .kc { color: #008000; font-weight: bold } /* Keyword.Constant */ -.highlight .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */ -.highlight .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */ -.highlight .kp { color: #008000 } /* Keyword.Pseudo */ -.highlight .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */ -.highlight .kt { color: #B00040 } /* Keyword.Type */ -.highlight .m { color: #666666 } /* Literal.Number */ -.highlight .s { color: #BA2121 } /* Literal.String */ -.highlight .na { color: #7D9029 } /* Name.Attribute */ -.highlight .nb { color: #008000 } /* Name.Builtin */ -.highlight .nc { color: #0000FF; font-weight: bold } /* Name.Class */ -.highlight .no { color: #880000 } /* Name.Constant */ -.highlight .nd { color: #AA22FF } /* Name.Decorator */ -.highlight .ni { color: #999999; font-weight: bold } /* Name.Entity */ -.highlight .ne { color: #D2413A; font-weight: bold } /* Name.Exception */ -.highlight .nf { color: #0000FF } /* Name.Function */ -.highlight .nl { color: #A0A000 } /* Name.Label */ -.highlight .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */ -.highlight .nt { color: #008000; font-weight: bold } /* Name.Tag */ -.highlight .nv { color: #19177C } /* Name.Variable */ -.highlight .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */ -.highlight .w { color: #bbbbbb } /* Text.Whitespace */ -.highlight .mf { color: #666666 } /* Literal.Number.Float */ -.highlight .mh { color: #666666 } /* Literal.Number.Hex */ -.highlight .mi { color: #666666 } /* Literal.Number.Integer */ -.highlight .mo { color: #666666 } /* Literal.Number.Oct */ -.highlight .sb { color: #BA2121 } /* Literal.String.Backtick */ -.highlight .sc { color: #BA2121 } /* Literal.String.Char */ -.highlight .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */ -.highlight .s2 { color: #BA2121 } /* Literal.String.Double */ -.highlight .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */ -.highlight .sh { color: #BA2121 } /* Literal.String.Heredoc */ -.highlight .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */ -.highlight .sx { color: #008000 } /* Literal.String.Other */ -.highlight .sr { color: #BB6688 } /* Literal.String.Regex */ -.highlight .s1 { color: #BA2121 } /* Literal.String.Single */ -.highlight .ss { color: #19177C } /* Literal.String.Symbol */ -.highlight .bp { color: #008000 } /* Name.Builtin.Pseudo */ -.highlight .vc { color: #19177C } /* Name.Variable.Class */ -.highlight .vg { color: #19177C } /* Name.Variable.Global */ -.highlight .vi { color: #19177C } /* Name.Variable.Instance */ -.highlight .il { color: #666666 } /* Literal.Number.Integer.Long */ -</style> -</head> -<body> -<div class="highlight"><pre><span class="gu">@@ -32,25 +32,25 @@</span> - finally: - f.close() - - release = version = '%s.%s' % (d['PY_MAJOR_VERSION'], d['PY_MINOR_VERSION']) - micro = int(d['PY_MICRO_VERSION']) - if micro != 0: - release += '.' + str(micro) - - level = d['PY_RELEASE_LEVEL'] - suffixes = { - 'PY_RELEASE_LEVEL_ALPHA': 'a', - 'PY_RELEASE_LEVEL_BETA': 'b', -<span class="gd">- 'PY_RELEASE_LEVEL_GAMMA': 'c',</span> -<span class="gi">+ 'PY_RELEASE_LEVEL_GAMMA': 'rc',</span> - } - if level != 'PY_RELEASE_LEVEL_FINAL': - release += suffixes[level] + str(int(d['PY_RELEASE_SERIAL'])) - return version, release - - - def get_sys_version_info(): - major, minor, micro, level, serial = sys.version_info - release = version = '%s.%s' % (major, minor) - if micro: - release += '.%s' % micro - if level != 'final': -</pre></div> - -</body> -</html> ======================================= --- /tools/sphinxext/pyspecific.py.diff Sun Oct 30 17:04:23 2011 +++ /dev/null @@ -1,100 +0,0 @@ -@@ -25,24 +25,25 @@ - self.body.append(self.starttag(node, 'p', CLASS=node['type'])) - text = versionlabels[node['type']] % node['version'] - if len(node): - text += ': ' - else: - text += '.' - self.body.append('<span class="versionmodified">%s</span>' % text) - - from sphinx.writers.html import HTMLTranslator - from sphinx.locale import versionlabels - HTMLTranslator.visit_versionmodified = new_visit_versionmodified - -+ - # Support for marking up and linking to bugs.python.org issues - - def issue_role(typ, rawtext, text, lineno, inliner, options={}, content=[]): - issue = utils.unescape(text) - text = 'issue ' + issue - refnode = nodes.reference(text, text, refuri=ISSUE_URI % issue) - return [refnode], [] - - - # Support for marking up implementation details - - from sphinx.util.compat import Directive -@@ -90,67 +91,58 @@ - 'string-conversions', 'string-methods', 'strings', 'subscriptions', 'truth', - 'try', 'types', 'typesfunctions', 'typesmapping', 'typesmethods', - 'typesmodules', 'typesseq', 'typesseq-mutable', 'unary', 'while', 'with', - 'yield' - ] - - from os import path - from time import asctime - from pprint import pformat - from docutils.io import StringOutput - from docutils.utils import new_document - --try: -- from sphinx.builders import Builder --except ImportError: -- # using Sphinx < 0.6, which has a different package layout -- from sphinx.builder import Builder -- # monkey-patch toctree directive to accept (and ignore) the :numbered: flag -- from sphinx.directives.other import toctree_directive -- toctree_directive.options['numbered'] = toctree_directive.options['glob'] -- --try: -- from sphinx.writers.text import TextWriter --except ImportError: -- from sphinx.textwriter import TextWriter -+from sphinx.builders import Builder -+from sphinx.writers.text import TextWriter - - - class PydocTopicsBuilder(Builder): - name = 'pydoc-topics' - - def init(self): - self.topics = {} - - def get_outdated_docs(self): - return 'all pydoc topics' - - def get_target_uri(self, docname, typ=None): - return '' # no URIs - - def write(self, *ignored): - writer = TextWriter(self) -- for label in self.status_iterator(pydoc_topic_labels, 'building topics... '): -+ for label in self.status_iterator(pydoc_topic_labels, -+ 'building topics... ', -+ length=len(pydoc_topic_labels)): - if label not in self.env.labels: - self.warn('label %r not in documentation' % label) - continue - docname, labelid, sectname = self.env.labels[label] - doctree = self.env.get_and_resolve_doctree(docname, self) - document = new_document('<section node>') - document.append(doctree.ids[labelid]) - destination = StringOutput(encoding='utf-8') - writer.write(document, destination) - self.topics[label] = writer.output - - def finish(self): -- f = open(path.join(self.outdir, 'pydoc_topics.py'), 'w') -+ f = open(path.join(self.outdir, 'topics.py'), 'w') - try: - f.write('# Autogenerated by Sphinx on %s\n' % asctime()) - f.write('topics = ' + pformat(self.topics) + '\n') - finally: - f.close() - - - # Support for checking for suspicious markup - - import suspicious - - ======================================= --- /tools/sphinxext/pyspecific.py.diff.html Sun Oct 30 17:04:23 2011 +++ /dev/null @@ -1,174 +0,0 @@ -<html> -<head> -<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> -<title>tools/sphinxext/pyspecific.py</title> -<style type="text/css"> -.highlight .hll { background-color: #ffffcc } -.highlight { background: #f8f8f8; } -.highlight .c { color: #408080; font-style: italic } /* Comment */ -.highlight .err { border: 1px solid #FF0000 } /* Error */ -.highlight .k { color: #008000; font-weight: bold } /* Keyword */ -.highlight .o { color: #666666 } /* Operator */ -.highlight .cm { color: #408080; font-style: italic } /* Comment.Multiline */ -.highlight .cp { color: #BC7A00 } /* Comment.Preproc */ -.highlight .c1 { color: #408080; font-style: italic } /* Comment.Single */ -.highlight .cs { color: #408080; font-style: italic } /* Comment.Special */ -.highlight .gd { color: #A00000 } /* Generic.Deleted */ -.highlight .ge { font-style: italic } /* Generic.Emph */ -.highlight .gr { color: #FF0000 } /* Generic.Error */ -.highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */ -.highlight .gi { color: #00A000 } /* Generic.Inserted */ -.highlight .go { color: #808080 } /* Generic.Output */ -.highlight .gp { color: #000080; font-weight: bold } /* Generic.Prompt */ -.highlight .gs { font-weight: bold } /* Generic.Strong */ -.highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ -.highlight .gt { color: #0040D0 } /* Generic.Traceback */ -.highlight .kc { color: #008000; font-weight: bold } /* Keyword.Constant */ -.highlight .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */ -.highlight .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */ -.highlight .kp { color: #008000 } /* Keyword.Pseudo */ -.highlight .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */ -.highlight .kt { color: #B00040 } /* Keyword.Type */ -.highlight .m { color: #666666 } /* Literal.Number */ -.highlight .s { color: #BA2121 } /* Literal.String */ -.highlight .na { color: #7D9029 } /* Name.Attribute */ -.highlight .nb { color: #008000 } /* Name.Builtin */ -.highlight .nc { color: #0000FF; font-weight: bold } /* Name.Class */ -.highlight .no { color: #880000 } /* Name.Constant */ -.highlight .nd { color: #AA22FF } /* Name.Decorator */ -.highlight .ni { color: #999999; font-weight: bold } /* Name.Entity */ -.highlight .ne { color: #D2413A; font-weight: bold } /* Name.Exception */ -.highlight .nf { color: #0000FF } /* Name.Function */ -.highlight .nl { color: #A0A000 } /* Name.Label */ -.highlight .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */ -.highlight .nt { color: #008000; font-weight: bold } /* Name.Tag */ -.highlight .nv { color: #19177C } /* Name.Variable */ -.highlight .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */ -.highlight .w { color: #bbbbbb } /* Text.Whitespace */ -.highlight .mf { color: #666666 } /* Literal.Number.Float */ -.highlight .mh { color: #666666 } /* Literal.Number.Hex */ -.highlight .mi { color: #666666 } /* Literal.Number.Integer */ -.highlight .mo { color: #666666 } /* Literal.Number.Oct */ -.highlight .sb { color: #BA2121 } /* Literal.String.Backtick */ -.highlight .sc { color: #BA2121 } /* Literal.String.Char */ -.highlight .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */ -.highlight .s2 { color: #BA2121 } /* Literal.String.Double */ -.highlight .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */ -.highlight .sh { color: #BA2121 } /* Literal.String.Heredoc */ -.highlight .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */ -.highlight .sx { color: #008000 } /* Literal.String.Other */ -.highlight .sr { color: #BB6688 } /* Literal.String.Regex */ -.highlight .s1 { color: #BA2121 } /* Literal.String.Single */ -.highlight .ss { color: #19177C } /* Literal.String.Symbol */ -.highlight .bp { color: #008000 } /* Name.Builtin.Pseudo */ -.highlight .vc { color: #19177C } /* Name.Variable.Class */ -.highlight .vg { color: #19177C } /* Name.Variable.Global */ -.highlight .vi { color: #19177C } /* Name.Variable.Instance */ -.highlight .il { color: #666666 } /* Literal.Number.Integer.Long */ -</style> -</head> -<body> -<div class="highlight"><pre><span class="gu">@@ -25,24 +25,25 @@</span> - self.body.append(self.starttag(node, 'p', CLASS=node['type'])) - text = versionlabels[node['type']] % node['version'] - if len(node): - text += ': ' - else: - text += '.' - self.body.append('<span class="versionmodified">%s</span>' % text) - - from sphinx.writers.html import HTMLTranslator - from sphinx.locale import versionlabels - HTMLTranslator.visit_versionmodified = new_visit_versionmodified - -<span class="gi">+</span> - # Support for marking up and linking to bugs.python.org issues - - def issue_role(typ, rawtext, text, lineno, inliner, options={}, content=[]): - issue = utils.unescape(text) - text = 'issue ' + issue - refnode = nodes.reference(text, text, refuri=ISSUE_URI % issue) - return [refnode], [] - - - # Support for marking up implementation details - - from sphinx.util.compat import Directive -<span class="gu">@@ -90,67 +91,58 @@</span> - 'string-conversions', 'string-methods', 'strings', 'subscriptions', 'truth', - 'try', 'types', 'typesfunctions', 'typesmapping', 'typesmethods', - 'typesmodules', 'typesseq', 'typesseq-mutable', 'unary', 'while', 'with', - 'yield' - ] - - from os import path - from time import asctime - from pprint import pformat - from docutils.io import StringOutput - from docutils.utils import new_document - -<span class="gd">-try:</span> -<span class="gd">- from sphinx.builders import Builder</span> -<span class="gd">-except ImportError:</span> -<span class="gd">- # using Sphinx < 0.6, which has a different package layout</span> -<span class="gd">- from sphinx.builder import Builder</span> -<span class="gd">- # monkey-patch toctree directive to accept (and ignore) the :numbered: flag</span> -<span class="gd">- from sphinx.directives.other import toctree_directive</span> -<span class="gd">- toctree_directive.options['numbered'] = toctree_directive.options['glob']</span> -<span class="gd">-</span> -<span class="gd">-try:</span> -<span class="gd">- from sphinx.writers.text import TextWriter</span> -<span class="gd">-except ImportError:</span> -<span class="gd">- from sphinx.textwriter import TextWriter</span> -<span class="gi">+from sphinx.builders import Builder</span> -<span class="gi">+from sphinx.writers.text import TextWriter</span> - - - class PydocTopicsBuilder(Builder): - name = 'pydoc-topics' - - def init(self): - self.topics = {} - - def get_outdated_docs(self): - return 'all pydoc topics' - - def get_target_uri(self, docname, typ=None): - return '' # no URIs - - def write(self, *ignored): - writer = TextWriter(self) -<span class="gd">- for label in self.status_iterator(pydoc_topic_labels, 'building topics... '):</span> -<span class="gi">+ for label in self.status_iterator(pydoc_topic_labels,</span> -<span class="gi">+ 'building topics... ',</span> -<span class="gi">+ length=len(pydoc_topic_labels)):</span> - if label not in self.env.labels: - self.warn('label %r not in documentation' % label) - continue - docname, labelid, sectname = self.env.labels[label] - doctree = self.env.get_and_resolve_doctree(docname, self) - document = new_document('<section node>') - document.append(doctree.ids[labelid]) - destination = StringOutput(encoding='utf-8') - writer.write(document, destination) - self.topics[label] = writer.output - - def finish(self): -<span class="gd">- f = open(path.join(self.outdir, 'pydoc_topics.py'), 'w')</span> -<span class="gi">+ f = open(path.join(self.outdir, 'topics.py'), 'w')</span> - try: - f.write('# Autogenerated by Sphinx on %s\n' % asctime()) - f.write('topics = ' + pformat(self.topics) + '\n') - finally: - f.close() - - - # Support for checking for suspicious markup - - import suspicious - - -</pre></div> - -</body> -</html> ======================================= --- /tools/sphinxext/susp-ignored.csv.diff Sun Oct 30 17:04:23 2011 +++ /dev/null @@ -1,149 +0,0 @@ -@@ -155,12 +155,148 @@ - whatsnew/2.3,,::, - whatsnew/2.3,,:config, - whatsnew/2.3,,:Critical, - whatsnew/2.3,,:Error, - whatsnew/2.3,,:Problem, - whatsnew/2.3,,:root, - whatsnew/2.3,,:Warning, - whatsnew/2.4,,::, - whatsnew/2.4,,:System, - whatsnew/2.5,,:memory,:memory: - whatsnew/2.5,,:step,[start:stop:step] - whatsnew/2.5,,:stop,[start:stop:step] -+distutils/examples,267,`,This is the description of the ``foobar`` package. -+documenting/fromlatex,39,:func,:func:`str(object)` -+documenting/fromlatex,39,`,:func:`str(object)` -+documenting/fromlatex,39,`,``str(object)`` -+documenting/fromlatex,55,.. deprecated:,.. deprecated:: 2.5 -+documenting/fromlatex,66,.. note:,.. note:: -+documenting/fromlatex,76,:samp,":samp:`open({filename}, {mode})`" -+documenting/fromlatex,76,`,":samp:`open({filename}, {mode})`" -+documenting/fromlatex,80,`,``'c'`` -+documenting/fromlatex,80,`,`Title <URL>`_ -+documenting/fromlatex,80,`,``code`` -+documenting/fromlatex,80,`,`Title <URL>`_ -+documenting/fromlatex,99,:file,:file:`C:\\Temp\\my.tmp` -+documenting/fromlatex,99,`,:file:`C:\\Temp\\my.tmp` -+documenting/fromlatex,99,`,"``open(""C:\Temp\my.tmp"")``" -+documenting/fromlatex,129,.. function:,.. function:: do_foo(bar) -+documenting/fromlatex,141,.. function:,".. function:: open(filename[, mode[, buffering]])" -+documenting/fromlatex,152,.. function:,.. function:: foo_* -+documenting/fromlatex,152,:noindex,:noindex: -+documenting/fromlatex,162,.. describe:,.. describe:: a == b -+documenting/fromlatex,168,.. cmdoption:,.. cmdoption:: -O -+documenting/fromlatex,168,.. envvar:,.. envvar:: PYTHONINSPECT -+documenting/rest,33,`,``text`` -+documenting/rest,47,:rolename,:rolename:`content` -+documenting/rest,47,`,:rolename:`content` -+documenting/rest,103,::,This is a normal text paragraph. The next paragraph is a code sample:: -+documenting/rest,130,`,`Link text <http://target>`_ -+documenting/rest,187,.. function:,.. function:: foo(x) -+documenting/rest,187,:bar,:bar: no -+documenting/rest,208,.. rubric:,.. rubric:: Footnotes -+faq/programming,,:reduce,"print (lambda Ru,Ro,Iu,Io,IM,Sx,Sy:reduce(lambda x,y:x+y,map(lambda y," -+faq/programming,,:reduce,"Sx=Sx,Sy=Sy:reduce(lambda x,y:x+y,map(lambda x,xc=Ru,yc=yc,Ru=Ru,Ro=Ro," -+faq/programming,,:chr,">=4.0) or 1+f(xc,yc,x*x-y*y+xc,2.0*x*y+yc,k-1,f):f(xc,yc,x,y,k,f):chr(" -+faq/programming,,::,for x in sequence[::-1]: -+faq/windows,229,:EOF, @ setlocal enableextensions & python -x %~f0 %* & goto :EOF -+faq/windows,393,:REG,.py :REG_SZ: c:\<path to python>\python.exe -u %s %s -+library/bisect,,:hi,all(val >= x for val in a[i:hi]) -+library/bisect,,:hi,all(val > x for val in a[i:hi]) -+library/http.client,52,:port,host:port -+library/nntplib,,:bytes,:bytes -+library/nntplib,,:lines,:lines -+library/nntplib,,:lines,"['xref', 'from', ':lines', ':bytes', 'references', 'date', 'message-id', 'subject']" -+library/nntplib,,:bytes,"['xref', 'from', ':lines', ':bytes', 'references', 'date', 'message-id', 'subject']" -+library/pickle,567,:memory,"conn = sqlite3.connect("":memory:"")" -+library/profile,293,:lineno,"(sort by filename:lineno)," -+library/socket,,::,"(10, 1, 6, '', ('2001:888:2000:d::a2', 80, 0, 0))]" -+library/stdtypes,,:end,s[start:end] -+library/stdtypes,,:end,s[start:end] -+license,,`,* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY -+license,,`,* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND -+license,,`,"``Software''), to deal in the Software without restriction, including" -+license,,`,"THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND," -+reference/lexical_analysis,704,`,$ ? ` -+whatsnew/2.7,735,:Sunday,'2009:4:Sunday' -+whatsnew/2.7,862,::,"export PYTHONWARNINGS=all,error:::Cookie:0" -+whatsnew/2.7,862,:Cookie,"export PYTHONWARNINGS=all,error:::Cookie:0" -+whatsnew/2.7,,::,>>> urlparse.urlparse('http://[1080::8:800:200C:417A]/foo') -+whatsnew/2.7,,::,"ParseResult(scheme='http', netloc='[1080::8:800:200C:417A]'," -+documenting/markup,33,.. sectionauthor:,.. sectionauthor:: Guido van Rossum <guido****@pytho*****> -+documenting/markup,42,:mod,:mod:`parrot` -- Dead parrot access -+documenting/markup,42,`,:mod:`parrot` -- Dead parrot access -+documenting/markup,42,.. module:,.. module:: parrot -+documenting/markup,42,:platform,":platform: Unix, Windows" -+documenting/markup,42,:synopsis,:synopsis: Analyze and reanimate dead parrots. -+documenting/markup,42,.. moduleauthor:,.. moduleauthor:: Eric Cleese <eric****@pytho*****> -+documenting/markup,42,.. moduleauthor:,.. moduleauthor:: John Idle <john****@pytho*****> -+documenting/markup,88,:noindex,:noindex: -+documenting/markup,95,.. function:,.. function:: spam(eggs) -+documenting/markup,95,:noindex,:noindex: -+documenting/markup,101,.. method:,.. method:: FileInput.input(...) -+documenting/markup,121,.. cfunction:,".. cfunction:: PyObject* PyType_GenericAlloc(PyTypeObject *type, Py_ssize_t nitems)" -+documenting/markup,131,.. cmember:,.. cmember:: PyObject* PyTypeObject.tp_bases -+documenting/markup,150,.. cvar:,.. cvar:: PyObject* PyClass_Type -+documenting/markup,179,.. function:,".. function:: Timer.repeat([repeat=3[, number=1000000]])" -+documenting/markup,209,.. cmdoption:,.. cmdoption:: -m <module> -+documenting/markup,227,.. describe:,.. describe:: opcode -+documenting/markup,256,.. highlightlang:,.. highlightlang:: c -+documenting/markup,276,.. literalinclude:,.. literalinclude:: example.py -+documenting/markup,291,:rolename,:rolename:`content` -+documenting/markup,291,`,:rolename:`content` -+documenting/markup,296,:role,:role:`title <target>` -+documenting/markup,296,`,:role:`title <target>` -+documenting/markup,302,:meth,:meth:`~Queue.Queue.get` -+documenting/markup,302,`,:meth:`~Queue.Queue.get` -+documenting/markup,350,:func,:func:`filter` -+documenting/markup,350,`,:func:`filter` -+documenting/markup,350,:func,:func:`foo.filter` -+documenting/markup,350,`,:func:`foo.filter` -+documenting/markup,356,:func,:func:`open` -+documenting/markup,356,`,:func:`open` -+documenting/markup,356,:func,:func:`.open` -+documenting/markup,356,`,:func:`.open` -+documenting/markup,435,:file,... is installed in :file:`/usr/lib/python2.{x}/site-packages` ... -+documenting/markup,435,`,... is installed in :file:`/usr/lib/python2.{x}/site-packages` ... -+documenting/markup,454,:kbd,:kbd:`C-x C-f` -+documenting/markup,454,`,:kbd:`C-x C-f` -+documenting/markup,454,:kbd,:kbd:`Control-x Control-f` -+documenting/markup,454,`,:kbd:`Control-x Control-f` -+documenting/markup,468,:mailheader,:mailheader:`Content-Type` -+documenting/markup,468,`,:mailheader:`Content-Type` -+documenting/markup,477,:manpage,:manpage:`ls(1)` -+documenting/markup,477,`,:manpage:`ls(1)` -+documenting/markup,493,:menuselection,:menuselection:`Start --> Programs` -+documenting/markup,493,`,:menuselection:`Start --> Programs` -+documenting/markup,508,`,``code`` -+documenting/markup,526,:file,:file: -+documenting/markup,526,`,``code`` -+documenting/markup,561,:ref,:ref:`label-name` -+documenting/markup,561,`,:ref:`label-name` -+documenting/markup,565,:ref,"It refers to the section itself, see :ref:`my-reference-label`." -+documenting/markup,565,`,"It refers to the section itself, see :ref:`my-reference-label`." -+documenting/markup,574,:ref,:ref: -+documenting/markup,595,.. note:,.. note:: -+documenting/markup,622,.. versionadded:,.. versionadded:: 2.5 -+documenting/markup,647,::,.. impl-detail:: -+documenting/markup,647,::,.. impl-detail:: This shortly mentions an implementation detail. -+documenting/markup,667,.. seealso:,.. seealso:: -+documenting/markup,667,:mod,Module :mod:`zipfile` -+documenting/markup,667,`,Module :mod:`zipfile` -+documenting/markup,667,:mod,Documentation of the :mod:`zipfile` standard module. -+documenting/markup,667,`,Documentation of the :mod:`zipfile` standard module. -+documenting/markup,667,`,"`GNU tar manual, Basic Tar Format <http://link>`_" -+documenting/markup,681,.. centered:,.. centered:: -+documenting/markup,726,.. toctree:,.. toctree:: -+documenting/markup,726,:maxdepth,:maxdepth: 2 -+documenting/markup,742,.. index:,.. index:: -+documenting/markup,772,.. index:,".. index:: BNF, grammar, syntax, notation" -+documenting/markup,803,`,"unaryneg ::= ""-"" `integer`" -+documenting/markup,808,.. productionlist:,.. productionlist:: -+documenting/markup,808,`,"try1_stmt: ""try"" "":"" `suite`" -+documenting/markup,808,`,": (""except"" [`expression` ["","" `target`]] "":"" `suite`)+" -+documenting/markup,808,`,": [""else"" "":"" `suite`]" -+documenting/markup,808,`,": [""finally"" "":"" `suite`]" -+documenting/markup,808,`,"try2_stmt: ""try"" "":"" `suite`" -+documenting/markup,808,`,": ""finally"" "":"" `suite`" -+library/urllib2,67,:close,Connection:close ======================================= --- /tools/sphinxext/susp-ignored.csv.diff.html Sun Oct 30 17:04:23 2011 +++ /dev/null @@ -1,223 +0,0 @@ -<html> -<head> -<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> -<title>tools/sphinxext/susp-ignored.csv</title> -<style type="text/css"> -.highlight .hll { background-color: #ffffcc } -.highlight { background: #f8f8f8; } -.highlight .c { color: #408080; font-style: italic } /* Comment */ -.highlight .err { border: 1px solid #FF0000 } /* Error */ -.highlight .k { color: #008000; font-weight: bold } /* Keyword */ -.highlight .o { color: #666666 } /* Operator */ -.highlight .cm { color: #408080; font-style: italic } /* Comment.Multiline */ -.highlight .cp { color: #BC7A00 } /* Comment.Preproc */ -.highlight .c1 { color: #408080; font-style: italic } /* Comment.Single */ -.highlight .cs { color: #408080; font-style: italic } /* Comment.Special */ -.highlight .gd { color: #A00000 } /* Generic.Deleted */ -.highlight .ge { font-style: italic } /* Generic.Emph */ -.highlight .gr { color: #FF0000 } /* Generic.Error */ -.highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */ -.highlight .gi { color: #00A000 } /* Generic.Inserted */ -.highlight .go { color: #808080 } /* Generic.Output */ -.highlight .gp { color: #000080; font-weight: bold } /* Generic.Prompt */ -.highlight .gs { font-weight: bold } /* Generic.Strong */ -.highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ -.highlight .gt { color: #0040D0 } /* Generic.Traceback */ -.highlight .kc { color: #008000; font-weight: bold } /* Keyword.Constant */ -.highlight .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */ -.highlight .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */ -.highlight .kp { color: #008000 } /* Keyword.Pseudo */ -.highlight .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */ -.highlight .kt { color: #B00040 } /* Keyword.Type */ -.highlight .m { color: #666666 } /* Literal.Number */ -.highlight .s { color: #BA2121 } /* Literal.String */ -.highlight .na { color: #7D9029 } /* Name.Attribute */ -.highlight .nb { color: #008000 } /* Name.Builtin */ -.highlight .nc { color: #0000FF; font-weight: bold } /* Name.Class */ -.highlight .no { color: #880000 } /* Name.Constant */ -.highlight .nd { color: #AA22FF } /* Name.Decorator */ -.highlight .ni { color: #999999; font-weight: bold } /* Name.Entity */ -.highlight .ne { color: #D2413A; font-weight: bold } /* Name.Exception */ -.highlight .nf { color: #0000FF } /* Name.Function */ -.highlight .nl { color: #A0A000 } /* Name.Label */ -.highlight .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */ -.highlight .nt { color: #008000; font-weight: bold } /* Name.Tag */ -.highlight .nv { color: #19177C } /* Name.Variable */ -.highlight .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */ -.highlight .w { color: #bbbbbb } /* Text.Whitespace */ -.highlight .mf { color: #666666 } /* Literal.Number.Float */ -.highlight .mh { color: #666666 } /* Literal.Number.Hex */ -.highlight .mi { color: #666666 } /* Literal.Number.Integer */ -.highlight .mo { color: #666666 } /* Literal.Number.Oct */ -.highlight .sb { color: #BA2121 } /* Literal.String.Backtick */ -.highlight .sc { color: #BA2121 } /* Literal.String.Char */ -.highlight .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */ -.highlight .s2 { color: #BA2121 } /* Literal.String.Double */ -.highlight .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */ -.highlight .sh { color: #BA2121 } /* Literal.String.Heredoc */ -.highlight .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */ -.highlight .sx { color: #008000 } /* Literal.String.Other */ -.highlight .sr { color: #BB6688 } /* Literal.String.Regex */ -.highlight .s1 { color: #BA2121 } /* Literal.String.Single */ -.highlight .ss { color: #19177C } /* Literal.String.Symbol */ -.highlight .bp { color: #008000 } /* Name.Builtin.Pseudo */ -.highlight .vc { color: #19177C } /* Name.Variable.Class */ -.highlight .vg { color: #19177C } /* Name.Variable.Global */ -.highlight .vi { color: #19177C } /* Name.Variable.Instance */ -.highlight .il { color: #666666 } /* Literal.Number.Integer.Long */ -</style> -</head> -<body> -<div class="highlight"><pre><span class="gu">@@ -155,12 +155,148 @@</span> - whatsnew/2.3,,::, - whatsnew/2.3,,:config, - whatsnew/2.3,,:Critical, - whatsnew/2.3,,:Error, - whatsnew/2.3,,:Problem, - whatsnew/2.3,,:root, - whatsnew/2.3,,:Warning, - whatsnew/2.4,,::, - whatsnew/2.4,,:System, - whatsnew/2.5,,:memory,:memory: - whatsnew/2.5,,:step,[start:stop:step] - whatsnew/2.5,,:stop,[start:stop:step] -<span class="gi">+distutils/examples,267,`,This is the description of the ``foobar`` package.</span> -<span class="gi">+documenting/fromlatex,39,:func,:func:`str(object)`</span> -<span class="gi">+documenting/fromlatex,39,`,:func:`str(object)`</span> -<span class="gi">+documenting/fromlatex,39,`,``str(object)``</span> -<span class="gi">+documenting/fromlatex,55,.. deprecated:,.. deprecated:: 2.5</span> -<span class="gi">+documenting/fromlatex,66,.. note:,.. note::</span> -<span class="gi">+documenting/fromlatex,76,:samp,":samp:`open({filename}, {mode})`"</span> -<span class="gi">+documenting/fromlatex,76,`,":samp:`open({filename}, {mode})`"</span> -<span class="gi">+documenting/fromlatex,80,`,``'c'``</span> -<span class="gi">+documenting/fromlatex,80,`,`Title <URL>`_</span> -<span class="gi">+documenting/fromlatex,80,`,``code``</span> -<span class="gi">+documenting/fromlatex,80,`,`Title <URL>`_</span> -<span class="gi">+documenting/fromlatex,99,:file,:file:`C:\\Temp\\my.tmp`</span> -<span class="gi">+documenting/fromlatex,99,`,:file:`C:\\Temp\\my.tmp`</span> -<span class="gi">+documenting/fromlatex,99,`,"``open(""C:\Temp\my.tmp"")``"</span> -<span class="gi">+documenting/fromlatex,129,.. function:,.. function:: do_foo(bar)</span> -<span class="gi">+documenting/fromlatex,141,.. function:,".. function:: open(filename[, mode[, buffering]])"</span> -<span class="gi">+documenting/fromlatex,152,.. function:,.. function:: foo_*</span> -<span class="gi">+documenting/fromlatex,152,:noindex,:noindex:</span> -<span class="gi">+documenting/fromlatex,162,.. describe:,.. describe:: a == b</span> -<span class="gi">+documenting/fromlatex,168,.. cmdoption:,.. cmdoption:: -O</span> -<span class="gi">+documenting/fromlatex,168,.. envvar:,.. envvar:: PYTHONINSPECT</span> -<span class="gi">+documenting/rest,33,`,``text``</span> -<span class="gi">+documenting/rest,47,:rolename,:rolename:`content`</span> -<span class="gi">+documenting/rest,47,`,:rolename:`content`</span> -<span class="gi">+documenting/rest,103,::,This is a normal text paragraph. The next paragraph is a code sample::</span> -<span class="gi">+documenting/rest,130,`,`Link text <http://target>`_</span> -<span class="gi">+documenting/rest,187,.. function:,.. function:: foo(x)</span> -<span class="gi">+documenting/rest,187,:bar,:bar: no</span> -<span class="gi">+documenting/rest,208,.. rubric:,.. rubric:: Footnotes</span> -<span class="gi">+faq/programming,,:reduce,"print (lambda Ru,Ro,Iu,Io,IM,Sx,Sy:reduce(lambda x,y:x+y,map(lambda y,"</span> -<span class="gi">+faq/programming,,:reduce,"Sx=Sx,Sy=Sy:reduce(lambda x,y:x+y,map(lambda x,xc=Ru,yc=yc,Ru=Ru,Ro=Ro,"</span> -<span class="gi">+faq/programming,,:chr,">=4.0) or 1+f(xc,yc,x*x-y*y+xc,2.0*x*y+yc,k-1,f):f(xc,yc,x,y,k,f):chr("</span> -<span class="gi">+faq/programming,,::,for x in sequence[::-1]:</span> -<span class="gi">+faq/windows,229,:EOF, @ setlocal enableextensions & python -x %~f0 %* & goto :EOF</span> -<span class="gi">+faq/windows,393,:REG,.py :REG_SZ: c:\<path to python>\python.exe -u %s %s</span> -<span class="gi">+library/bisect,,:hi,all(val >= x for val in a[i:hi])</span> -<span class="gi">+library/bisect,,:hi,all(val > x for val in a[i:hi])</span> -<span class="gi">+library/http.client,52,:port,host:port</span> -<span class="gi">+library/nntplib,,:bytes,:bytes</span> -<span class="gi">+library/nntplib,,:lines,:lines</span> -<span class="gi">+library/nntplib,,:lines,"['xref', 'from', ':lines', ':bytes', 'references', 'date', 'message-id', 'subject']"</span> -<span class="gi">+library/nntplib,,:bytes,"['xref', 'from', ':lines', ':bytes', 'references', 'date', 'message-id', 'subject']"</span> -<span class="gi">+library/pickle,567,:memory,"conn = sqlite3.connect("":memory:"")"</span> -<span class="gi">+library/profile,293,:lineno,"(sort by filename:lineno),"</span> -<span class="gi">+library/socket,,::,"(10, 1, 6, '', ('2001:888:2000:d::a2', 80, 0, 0))]"</span> -<span class="gi">+library/stdtypes,,:end,s[start:end]</span> -<span class="gi">+library/stdtypes,,:end,s[start:end]</span> -<span class="gi">+license,,`,* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY</span> -<span class="gi">+license,,`,* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND</span> -<span class="gi">+license,,`,"``Software''), to deal in the Software without restriction, including"</span> -<span class="gi">+license,,`,"THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,"</span> -<span class="gi">+reference/lexical_analysis,704,`,$ ? `</span> -<span class="gi">+whatsnew/2.7,735,:Sunday,'2009:4:Sunday'</span> -<span class="gi">+whatsnew/2.7,862,::,"export PYTHONWARNINGS=all,error:::Cookie:0"</span> -<span class="gi">+whatsnew/2.7,862,:Cookie,"export PYTHONWARNINGS=all,error:::Cookie:0"</span> -<span class="gi">+whatsnew/2.7,,::,>>> urlparse.urlparse('http://[1080::8:800:200C:417A]/foo')</span> -<span class="gi">+whatsnew/2.7,,::,"ParseResult(scheme='http', netloc='[1080::8:800:200C:417A]',"</span> -<span class="gi">+documenting/markup,33,.. sectionauthor:,.. sectionauthor:: Guido van Rossum <guido****@pytho*****></span> -<span class="gi">+documenting/markup,42,:mod,:mod:`parrot` -- Dead parrot access</span> -<span class="gi">+documenting/markup,42,`,:mod:`parrot` -- Dead parrot access</span> -<span class="gi">+documenting/markup,42,.. module:,.. module:: parrot</span> -<span class="gi">+documenting/markup,42,:platform,":platform: Unix, Windows"</span> -<span class="gi">+documenting/markup,42,:synopsis,:synopsis: Analyze and reanimate dead parrots.</span> -<span class="gi">+documenting/markup,42,.. moduleauthor:,.. moduleauthor:: Eric Cleese <eric****@pytho*****></span> -<span class="gi">+documenting/markup,42,.. moduleauthor:,.. moduleauthor:: John Idle <john****@pytho*****></span> -<span class="gi">+documenting/markup,88,:noindex,:noindex:</span> -<span class="gi">+documenting/markup,95,.. function:,.. function:: spam(eggs)</span> -<span class="gi">+documenting/markup,95,:noindex,:noindex:</span> -<span class="gi">+documenting/markup,101,.. method:,.. method:: FileInput.input(...)</span> -<span class="gi">+documenting/markup,121,.. cfunction:,".. cfunction:: PyObject* PyType_GenericAlloc(PyTypeObject *type, Py_ssize_t nitems)"</span> -<span class="gi">+documenting/markup,131,.. cmember:,.. cmember:: PyObject* PyTypeObject.tp_bases</span> -<span class="gi">+documenting/markup,150,.. cvar:,.. cvar:: PyObject* PyClass_Type</span> -<span class="gi">+documenting/markup,179,.. function:,".. function:: Timer.repeat([repeat=3[, number=1000000]])"</span> -<span class="gi">+documenting/markup,209,.. cmdoption:,.. cmdoption:: -m <module></span> -<span class="gi">+documenting/markup,227,.. describe:,.. describe:: opcode</span> -<span class="gi">+documenting/markup,256,.. highlightlang:,.. highlightlang:: c</span> -<span class="gi">+documenting/markup,276,.. literalinclude:,.. literalinclude:: example.py</span> -<span class="gi">+documenting/markup,291,:rolename,:rolename:`content`</span> -<span class="gi">+documenting/markup,291,`,:rolename:`content`</span> -<span class="gi">+documenting/markup,296,:role,:role:`title <target>`</span> -<span class="gi">+documenting/markup,296,`,:role:`title <target>`</span> -<span class="gi">+documenting/markup,302,:meth,:meth:`~Queue.Queue.get`</span> -<span class="gi">+documenting/markup,302,`,:meth:`~Queue.Queue.get`</span> -<span class="gi">+documenting/markup,350,:func,:func:`filter`</span> -<span class="gi">+documenting/markup,350,`,:func:`filter`</span> -<span class="gi">+documenting/markup,350,:func,:func:`foo.filter`</span> -<span class="gi">+documenting/markup,350,`,:func:`foo.filter`</span> -<span class="gi">+documenting/markup,356,:func,:func:`open`</span> -<span class="gi">+documenting/markup,356,`,:func:`open`</span> -<span class="gi">+documenting/markup,356,:func,:func:`.open`</span> -<span class="gi">+documenting/markup,356,`,:func:`.open`</span> -<span class="gi">+documenting/markup,435,:file,... is installed in :file:`/usr/lib/python2.{x}/site-packages` ...</span> -<span class="gi">+documenting/markup,435,`,... is installed in :file:`/usr/lib/python2.{x}/site-packages` ...</span> -<span class="gi">+documenting/markup,454,:kbd,:kbd:`C-x C-f`</span> -<span class="gi">+documenting/markup,454,`,:kbd:`C-x C-f`</span> -<span class="gi">+documenting/markup,454,:kbd,:kbd:`Control-x Control-f`</span> -<span class="gi">+documenting/markup,454,`,:kbd:`Control-x Control-f`</span> -<span class="gi">+documenting/markup,468,:mailheader,:mailheader:`Content-Type`</span> -<span class="gi">+documenting/markup,468,`,:mailheader:`Content-Type`</span> -<span class="gi">+documenting/markup,477,:manpage,:manpage:`ls(1)`</span> -<span class="gi">+documenting/markup,477,`,:manpage:`ls(1)`</span> -<span class="gi">+documenting/markup,493,:menuselection,:menuselection:`Start --> Programs`</span> -<span class="gi">+documenting/markup,493,`,:menuselection:`Start --> Programs`</span> -<span class="gi">+documenting/markup,508,`,``code``</span> -<span class="gi">+documenting/markup,526,:file,:file:</span> -<span class="gi">+documenting/markup,526,`,``code``</span> -<span class="gi">+documenting/markup,561,:ref,:ref:`label-name`</span> -<span class="gi">+documenting/markup,561,`,:ref:`label-name`</span> -<span class="gi">+documenting/markup,565,:ref,"It refers to the section itself, see :ref:`my-reference-label`."</span> -<span class="gi">+documenting/markup,565,`,"It refers to the section itself, see :ref:`my-reference-label`."</span> -<span class="gi">+documenting/markup,574,:ref,:ref:</span> -<span class="gi">+documenting/markup,595,.. note:,.. note::</span> -<span class="gi">+documenting/markup,622,.. versionadded:,.. versionadded:: 2.5</span> -<span class="gi">+documenting/markup,647,::,.. impl-detail::</span> -<span class="gi">+documenting/markup,647,::,.. impl-detail:: This shortly mentions an implementation detail.</span> -<span class="gi">+documenting/markup,667,.. seealso:,.. seealso::</span> -<span class="gi">+documenting/markup,667,:mod,Module :mod:`zipfile`</span> -<span class="gi">+documenting/markup,667,`,Module :mod:`zipfile`</span> -<span class="gi">+documenting/markup,667,:mod,Documentation of the :mod:`zipfile` standard module.</span> -<span class="gi">+documenting/markup,667,`,Documentation of the :mod:`zipfile` standard module.</span> -<span class="gi">+documenting/markup,667,`,"`GNU tar manual, Basic Tar Format <http://link>`_"</span> -<span class="gi">+documenting/markup,681,.. centered:,.. centered::</span> -<span class="gi">+documenting/markup,726,.. toctree:,.. toctree::</span> -<span class="gi">+documenting/markup,726,:maxdepth,:maxdepth: 2</span> -<span class="gi">+documenting/markup,742,.. index:,.. index::</span> -<span class="gi">+documenting/markup,772,.. index:,".. index:: BNF, grammar, syntax, notation"</span> -<span class="gi">+documenting/markup,803,`,"unaryneg ::= ""-"" `integer`"</span> -<span class="gi">+documenting/markup,808,.. productionlist:,.. productionlist::</span> -<span class="gi">+documenting/markup,808,`,"try1_stmt: ""try"" "":"" `suite`"</span> -<span class="gi">+documenting/markup,808,`,": (""except"" [`expression` ["","" `target`]] "":"" `suite`)+"</span> -<span class="gi">+documenting/markup,808,`,": [""else"" "":"" `suite`]"</span> -<span class="gi">+documenting/markup,808,`,": [""finally"" "":"" `suite`]"</span> -<span class="gi">+documenting/markup,808,`,"try2_stmt: ""try"" "":"" `suite`"</span> -<span class="gi">+documenting/markup,808,`,": ""finally"" "":"" `suite`"</span> -<span class="gi">+library/urllib2,67,:close,Connection:close</span> -</pre></div> - -</body> -</html> ======================================= --- /tools/sphinxext/suspicious.py.diff Sun Oct 30 17:04:23 2011 +++ /dev/null @@ -1,229 +0,0 @@ -@@ -32,95 +32,96 @@ - * problematic texts are the same - * line numbers are close to each other (5 lines up or down) - * the rule text is completely contained into the source line - - The simplest way to create the ignored.csv file is by copying - undesired entries from suspicious.csv (possibly trimming the last - field.) - - Copyright 2009 Gabriel A. Genellina - - """ - --import os, sys -+import os -+import re - import csv --import re -+import sys -+ - from docutils import nodes -- --try: -- from sphinx.builders import Builder --except ImportError: -- from sphinx.builder import Builder -- -+from sphinx.builders import Builder - - detect_all = re.compile(ur''' - ::(?=[^=])| # two :: (but NOT ::=) - :[a-zA-Z][a-zA-Z0-9]+| # :foo - `| # ` (seldom used by itself) - (?<!\.)\.\.[ \t]*\w+: # .. foo: (but NOT ... else:) - ''', re.UNICODE | re.VERBOSE).finditer - -+ - class Rule: - def __init__(self, docname, lineno, issue, line): -- "A rule for ignoring issues" -+ """A rule for ignoring issues""" - self.docname = docname # document to which this rule applies - self.lineno = lineno # line number in the original source; - # this rule matches only near that. - # None -> don't care - self.issue = issue # the markup fragment that triggered this rule - self.line = line # text of the container element (single line only) - - -+ -+class dialect(csv.excel): -+ """Our dialect: uses only linefeed as newline.""" -+ lineterminator = '\n' -+ -+ - class CheckSuspiciousMarkupBuilder(Builder): - """ -- Checks for possibly invalid markup that may leak into the output -+ Checks for possibly invalid markup that may leak into the output. - """ - name = 'suspicious' - - def init(self): - # create output file - self.log_file_name = os.path.join(self.outdir, 'suspicious.csv') - open(self.log_file_name, 'w').close() - # load database of previously ignored issues -- self.load_rules(os.path.join(os.path.dirname(__file__), 'susp-ignored.csv')) -+ self.load_rules(os.path.join(os.path.dirname(__file__), -+ 'susp-ignored.csv')) - - def get_outdated_docs(self): - return self.env.found_docs - - def get_target_uri(self, docname, typ=None): - return '' - - def prepare_writing(self, docnames): -- ### PYTHON PROJECT SPECIFIC ### -- for name in set(docnames): -- if name.split('/', 1)[0] == 'documenting': -- docnames.remove(name) -- ### PYTHON PROJECT SPECIFIC ### -+ pass - - def write_doc(self, docname, doctree): -- self.any_issue = False # set when any issue is encountered in this document -+ # set when any issue is encountered in this document -+ self.any_issue = False - self.docname = docname - visitor = SuspiciousVisitor(doctree, self) - doctree.walk(visitor) - - def finish(self): - return - - def check_issue(self, line, lineno, issue): - if not self.is_ignored(line, lineno, issue): - self.report_issue(line, lineno, issue) - - def is_ignored(self, line, lineno, issue): -- """Determine whether this issue should be ignored. -- """ -+ """Determine whether this issue should be ignored.""" - docname = self.docname - for rule in self.rules: - if rule.docname != docname: continue - if rule.issue != issue: continue - # Both lines must match *exactly*. This is rather strict, - # and probably should be improved. - # Doing fuzzy matches with levenshtein distance could work, - # but that means bringing other libraries... - # Ok, relax that requirement: just check if the rule fragment - # is contained in the document line - if rule.line not in line: continue - # Check both line numbers. If they're "near" -@@ -135,103 +136,103 @@ - if not self.any_issue: self.info() - self.any_issue = True - self.write_log_entry(lineno, issue, text) - self.warn('[%s:%d] "%s" found in "%-.120s"' % ( - self.docname.encode(sys.getdefaultencoding(),'replace'), - lineno, - issue.encode(sys.getdefaultencoding(),'replace'), - text.strip().encode(sys.getdefaultencoding(),'replace'))) - self.app.statuscode = 1 - - def write_log_entry(self, lineno, issue, text): - f = open(self.log_file_name, 'ab') -- writer = csv.writer(f) -+ writer = csv.writer(f, dialect) - writer.writerow([self.docname.encode('utf-8'), -- lineno, -- issue.encode('utf-8'), -- text.strip().encode('utf-8')]) -- del writer -+ lineno, -+ issue.encode('utf-8'), -+ text.strip().encode('utf-8')]) - f.close() - - def load_rules(self, filename): - """Load database of previously ignored issues. - - A csv file, with exactly the same format as suspicious.csv - Fields: document name (normalized), line number, issue, surrounding text - """ - self.info("loading ignore rules... ", nonl=1) - self.rules = rules = [] - try: f = open(filename, 'rb') - except IOError: return - for i, row in enumerate(csv.reader(f)): - if len(row) != 4: -- raise ValueError("wrong format in %s, line %d: %s" % (filename, i+1, row)) -+ raise ValueError( -+ "wrong format in %s, line %d: %s" % (filename, i+1, row)) - docname, lineno, issue, text = row - docname = docname.decode('utf-8') - if lineno: lineno = int(lineno) - else: lineno = None - issue = issue.decode('utf-8') - text = text.decode('utf-8') - rule = Rule(docname, lineno, issue, text) - rules.append(rule) - f.close() - self.info('done, %d rules loaded' % len(self.rules)) - - - def get_lineno(node): -- "Obtain line number information for a node" -+ """Obtain line number information for a node.""" - lineno = None - while lineno is None and node: - node = node.parent - lineno = node.line - return lineno - - - def extract_line(text, index): - """text may be a multiline string; extract - only the line containing the given character index. - - >>> extract_line("abc\ndefgh\ni", 6) - >>> 'defgh' - >>> for i in (0, 2, 3, 4, 10): - ... print extract_line("abc\ndefgh\ni", i) - abc - abc - abc - defgh - defgh - i - """ - p = text.rfind('\n', 0, index) + 1 - q = text.find('\n', index) -- if q<0: q = len(text) -+ if q < 0: -+ q = len(text) - return text[p:q] - - - class SuspiciousVisitor(nodes.GenericNodeVisitor): - - lastlineno = 0 - - def __init__(self, document, builder): - nodes.GenericNodeVisitor.__init__(self, document) - self.builder = builder - - def default_visit(self, node): - if isinstance(node, (nodes.Text, nodes.image)): # direct text containers - text = node.astext() - # lineno seems to go backwards sometimes (?) - self.lastlineno = lineno = max(get_lineno(node) or 0, self.lastlineno) - seen = set() # don't report the same issue more than only once per line - for match in detect_all(text): -- #import pdb; pdb.set_trace() - issue = match.group() - line = extract_line(text, match.start()) - if (issue, line) not in seen: - self.builder.check_issue(line, lineno, issue) - seen.add((issue, line)) - - unknown_visit = default_visit - - def visit_document(self, node): - self.lastlineno = 0 - - def visit_comment(self, node): ======================================= --- /tools/sphinxext/suspicious.py.diff.html Sun Oct 30 17:04:23 2011 +++ /dev/null @@ -1,303 +0,0 @@ -<html> -<head> -<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> -<title>tools/sphinxext/suspicious.py</title> -<style type="text/css"> -.highlight .hll { background-color: #ffffcc } -.highlight { background: #f8f8f8; } -.highlight .c { color: #408080; font-style: italic } /* Comment */ -.highlight .err { border: 1px solid #FF0000 } /* Error */ -.highlight .k { color: #008000; font-weight: bold } /* Keyword */ -.highlight .o { color: #666666 } /* Operator */ -.highlight .cm { color: #408080; font-style: italic } /* Comment.Multiline */ -.highlight .cp { color: #BC7A00 } /* Comment.Preproc */ -.highlight .c1 { color: #408080; font-style: italic } /* Comment.Single */ -.highlight .cs { color: #408080; font-style: italic } /* Comment.Special */ -.highlight .gd { color: #A00000 } /* Generic.Deleted */ -.highlight .ge { font-style: italic } /* Generic.Emph */ -.highlight .gr { color: #FF0000 } /* Generic.Error */ -.highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */ -.highlight .gi { color: #00A000 } /* Generic.Inserted */ -.highlight .go { color: #808080 } /* Generic.Output */ -.highlight .gp { color: #000080; font-weight: bold } /* Generic.Prompt */ -.highlight .gs { font-weight: bold } /* Generic.Strong */ -.highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ -.highlight .gt { color: #0040D0 } /* Generic.Traceback */ -.highlight .kc { color: #008000; font-weight: bold } /* Keyword.Constant */ -.highlight .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */ -.highlight .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */ -.highlight .kp { color: #008000 } /* Keyword.Pseudo */ -.highlight .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */ -.highlight .kt { color: #B00040 } /* Keyword.Type */ -.highlight .m { color: #666666 } /* Literal.Number */ -.highlight .s { color: #BA2121 } /* Literal.String */ -.highlight .na { color: #7D9029 } /* Name.Attribute */ -.highlight .nb { color: #008000 } /* Name.Builtin */ -.highlight .nc { color: #0000FF; font-weight: bold } /* Name.Class */ -.highlight .no { color: #880000 } /* Name.Constant */ -.highlight .nd { color: #AA22FF } /* Name.Decorator */ -.highlight .ni { color: #999999; font-weight: bold } /* Name.Entity */ -.highlight .ne { color: #D2413A; font-weight: bold } /* Name.Exception */ -.highlight .nf { color: #0000FF } /* Name.Function */ -.highlight .nl { color: #A0A000 } /* Name.Label */ -.highlight .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */ -.highlight .nt { color: #008000; font-weight: bold } /* Name.Tag */ -.highlight .nv { color: #19177C } /* Name.Variable */ -.highlight .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */ -.highlight .w { color: #bbbbbb } /* Text.Whitespace */ -.highlight .mf { color: #666666 } /* Literal.Number.Float */ -.highlight .mh { color: #666666 } /* Literal.Number.Hex */ -.highlight .mi { color: #666666 } /* Literal.Number.Integer */ -.highlight .mo { color: #666666 } /* Literal.Number.Oct */ -.highlight .sb { color: #BA2121 } /* Literal.String.Backtick */ -.highlight .sc { color: #BA2121 } /* Literal.String.Char */ -.highlight .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */ -.highlight .s2 { color: #BA2121 } /* Literal.String.Double */ -.highlight .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */ -.highlight .sh { color: #BA2121 } /* Literal.String.Heredoc */ -.highlight .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */ -.highlight .sx { color: #008000 } /* Literal.String.Other */ -.highlight .sr { color: #BB6688 } /* Literal.String.Regex */ -.highlight .s1 { color: #BA2121 } /* Literal.String.Single */ -.highlight .ss { color: #19177C } /* Literal.String.Symbol */ -.highlight .bp { color: #008000 } /* Name.Builtin.Pseudo */ -.highlight .vc { color: #19177C } /* Name.Variable.Class */ -.highlight .vg { color: #19177C } /* Name.Variable.Global */ -.highlight .vi { color: #19177C } /* Name.Variable.Instance */ -.highlight .il { color: #666666 } /* Literal.Number.Integer.Long */ -</style> -</head> -<body> -<div class="highlight"><pre><span class="gu">@@ -32,95 +32,96 @@</span> - * problematic texts are the same - * line numbers are close to each other (5 lines up or down) - * the rule text is completely contained into the source line - - The simplest way to create the ignored.csv file is by copying - undesired entries from suspicious.csv (possibly trimming the last - field.) - - Copyright 2009 Gabriel A. Genellina - - """ - -<span class="gd">-import os, sys</span> -<span class="gi">+import os</span> -<span class="gi">+import re</span> - import csv -<span class="gd">-import re</span> -<span class="gi">+import sys</span> -<span class="gi">+</span> - from docutils import nodes -<span class="gd">-</span> -<span class="gd">-try:</span> -<span class="gd">- from sphinx.builders import Builder</span> -<span class="gd">-except ImportError:</span> -<span class="gd">- from sphinx.builder import Builder</span> -<span class="gd">-</span> -<span class="gi">+from sphinx.builders import Builder</span> - - detect_all = re.compile(ur''' - ::(?=[^=])| # two :: (but NOT ::=) - :[a-zA-Z][a-zA-Z0-9]+| # :foo - `| # ` (seldom used by itself) - (?<!\.)\.\.[ \t]*\w+: # .. foo: (but NOT ... else:) - ''', re.UNICODE | re.VERBOSE).finditer - -<span class="gi">+</span> - class Rule: - def __init__(self, docname, lineno, issue, line): -<span class="gd">- "A rule for ignoring issues"</span> -<span class="gi">+ """A rule for ignoring issues"""</span> - self.docname = docname # document to which this rule applies - self.lineno = lineno # line number in the original source; - # this rule matches only near that. - # None -> don't care - self.issue = issue # the markup fragment that triggered this rule - self.line = line # text of the container element (single line only) - - -<span class="gi">+</span> -<span class="gi">+class dialect(csv.excel):</span> -<span class="gi">+ """Our dialect: uses only linefeed as newline."""</span> -<span class="gi">+ lineterminator = '\n'</span> -<span class="gi">+</span> -<span class="gi">+</span> - class CheckSuspiciousMarkupBuilder(Builder): - """ -<span class="gd">- Checks for possibly invalid markup that may leak into the output</span> -<span class="gi">+ Checks for possibly invalid markup that may leak into the output.</span> - """ - name = 'suspicious' - - def init(self): - # create output file - self.log_file_name = os.path.join(self.outdir, 'suspicious.csv') - open(self.log_file_name, 'w').close() - # load database of previously ignored issues -<span class="gd">- self.load_rules(os.path.join(os.path.dirname(__file__), 'susp-ignored.csv'))</span> -<span class="gi">+ self.load_rules(os.path.join(os.path.dirname(__file__),</span> -<span class="gi">+ 'susp-ignored.csv'))</span> - - def get_outdated_docs(self): - return self.env.found_docs - - def get_target_uri(self, docname, typ=None): - return '' - - def prepare_writing(self, docnames): -<span class="gd">- ### PYTHON PROJECT SPECIFIC ###</span> -<span class="gd">- for name in set(docnames):</span> -<span class="gd">- if name.split('/', 1)[0] == 'documenting':</span> -<span class="gd">- docnames.remove(name)</span> -<span class="gd">- ### PYTHON PROJECT SPECIFIC ###</span> -<span class="gi">+ pass</span> - - def write_doc(self, docname, doctree): -<span class="gd">- self.any_issue = False # set when any issue is encountered in this document</span> -<span class="gi">+ # set when any issue is encountered in this document</span> -<span class="gi">+ self.any_issue = False</span> - self.docname = docname - visitor = SuspiciousVisitor(doctree, self) - doctree.walk(visitor) - - def finish(self): - return - - def check_issue(self, line, lineno, issue): - if not self.is_ignored(line, lineno, issue): - self.report_issue(line, lineno, issue) - - def is_ignored(self, line, lineno, issue): -<span class="gd">- """Determine whether this issue should be ignored.</span> -<span class="gd">- """</span> -<span class="gi">+ """Determine whether this issue should be ignored."""</span> - docname = self.docname - for rule in self.rules: - if rule.docname != docname: continue - if rule.issue != issue: continue - # Both lines must match *exactly*. This is rather strict, - # and probably should be improved. - # Doing fuzzy matches with levenshtein distance could work, - # but that means bringing other libraries... - # Ok, relax that requirement: just check if the rule fragment - # is contained in the document line - if rule.line not in line: continue - # Check both line numbers. If they're "near" -<span class="gu">@@ -135,103 +136,103 @@</span> - if not self.any_issue: self.info() - self.any_issue = True - self.write_log_entry(lineno, issue, text) - self.warn('[%s:%d] "%s" found in "%-.120s"' % ( - self.docname.encode(sys.getdefaultencoding(),'replace'), - lineno, - issue.encode(sys.getdefaultencoding(),'replace'), - text.strip().encode(sys.getdefaultencoding(),'replace'))) - self.app.statuscode = 1 - - def write_log_entry(self, lineno, issue, text): - f = open(self.log_file_name, 'ab') -<span class="gd">- writer = csv.writer(f)</span> -<span class="gi">+ writer = csv.writer(f, dialect)</span> - writer.writerow([self.docname.encode('utf-8'), -<span class="gd">- lineno,</span> -<span class="gd">- issue.encode('utf-8'),</span> -<span class="gd">- text.strip().encode('utf-8')])</span> -<span class="gd">- del writer</span> -<span class="gi">+ lineno,</span> -<span class="gi">+ issue.encode('utf-8'),</span> -<span class="gi">+ text.strip().encode('utf-8')])</span> - f.close() - - def load_rules(self, filename): - """Load database of previously ignored issues. - - A csv file, with exactly the same format as suspicious.csv - Fields: document name (normalized), line number, issue, surrounding text - """ - self.info("loading ignore rules... ", nonl=1) - self.rules = rules = [] - try: f = open(filename, 'rb') - except IOError: return - for i, row in enumerate(csv.reader(f)): - if len(row) != 4: -<span class="gd">- raise ValueError("wrong format in %s, line %d: %s" % (filename, i+1, row))</span> -<span class="gi">+ raise ValueError(</span> -<span class="gi">+ "wrong format in %s, line %d: %s" % (filename, i+1, row))</span> - docname, lineno, issue, text = row - docname = docname.decode('utf-8') - if lineno: lineno = int(lineno) - else: lineno = None - issue = issue.decode('utf-8') - text = text.decode('utf-8') - rule = Rule(docname, lineno, issue, text) - rules.append(rule) - f.close() - self.info('done, %d rules loaded' % len(self.rules)) - - - def get_lineno(node): -<span class="gd">- "Obtain line number information for a node"</span> -<span class="gi">+ """Obtain line number information for a node."""</span> - lineno = None - while lineno is None and node: - node = node.parent - lineno = node.line - return lineno - - - def extract_line(text, index): - """text may be a multiline string; extract - only the line containing the given character index. - - >>> extract_line("abc\ndefgh\ni", 6) - >>> 'defgh' - >>> for i in (0, 2, 3, 4, 10): - ... print extract_line("abc\ndefgh\ni", i) - abc - abc - abc - defgh - defgh - i - """ - p = text.rfind('\n', 0, index) + 1 - q = text.find('\n', index) -<span class="gd">- if q<0: q = len(text)</span> -<span class="gi">+ if q < 0:</span> -<span class="gi">+ q = len(text)</span> - return text[p:q] - - - class SuspiciousVisitor(nodes.GenericNodeVisitor): - - lastlineno = 0 - - def __init__(self, document, builder): - nodes.GenericNodeVisitor.__init__(self, document) - self.builder = builder - - def default_visit(self, node): - if isinstance(node, (nodes.Text, nodes.image)): # direct text containers - text = node.astext() - # lineno seems to go backwards sometimes (?) - self.lastlineno = lineno = max(get_lineno(node) or 0, self.lastlineno) - seen = set() # don't report the same issue more than only once per line - for match in detect_all(text): -<span class="gd">- #import pdb; pdb.set_trace()</span> - issue = match.group() - line = extract_line(text, match.start()) - if (issue, line) not in seen: - self.builder.check_issue(line, lineno, issue) - seen.add((issue, line)) - - unknown_visit = default_visit - - def visit_document(self, node): - self.lastlineno = 0 - - def visit_comment(self, node): -</pre></div> - -</body> -</html>