Add doc for compileall.compile_file
This commit is contained in:
parent
a8132ec27e
commit
c11ba768da
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
:mod:`compileall` --- Byte-compile Python libraries
|
:mod:`compileall` --- Byte-compile Python libraries
|
||||||
===================================================
|
===================================================
|
||||||
|
|
||||||
|
@ -50,14 +49,14 @@ compile Python sources.
|
||||||
|
|
||||||
Expand list with its content (file and directory names).
|
Expand list with its content (file and directory names).
|
||||||
|
|
||||||
.. versionadded:: 2.7
|
.. versionchanged:: 2.7
|
||||||
The ``-i`` option.
|
Added the ``-i`` option.
|
||||||
|
|
||||||
|
|
||||||
Public functions
|
Public functions
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
.. function:: compile_dir(dir[, maxlevels[, ddir[, force[, rx[, quiet]]]]])
|
.. function:: compile_dir(dir[, maxlevels[, ddir[, force[, rx[, quiet]]]]])
|
||||||
|
|
||||||
Recursively descend the directory tree named by *dir*, compiling all :file:`.py`
|
Recursively descend the directory tree named by *dir*, compiling all :file:`.py`
|
||||||
files along the way. The *maxlevels* parameter is used to limit the depth of
|
files along the way. The *maxlevels* parameter is used to limit the depth of
|
||||||
|
@ -72,6 +71,23 @@ Public functions
|
||||||
If *quiet* is true, nothing is printed to the standard output in normal
|
If *quiet* is true, nothing is printed to the standard output in normal
|
||||||
operation.
|
operation.
|
||||||
|
|
||||||
|
|
||||||
|
.. function:: compile_file(fullname[, ddir[, force[, rx[, quiet]]]])
|
||||||
|
|
||||||
|
Compile the file with path *fullname*. If *ddir* is given, it is used as the
|
||||||
|
base path from which the filename used in error messages will be generated.
|
||||||
|
If *force* is true, modules are re-compiled even if the timestamp is up to
|
||||||
|
date.
|
||||||
|
|
||||||
|
If *rx* is given, it specifies a regular expression which, if matched, will
|
||||||
|
prevent compilation; that expression is searched for in the full path.
|
||||||
|
|
||||||
|
If *quiet* is true, nothing is printed to the standard output in normal
|
||||||
|
operation.
|
||||||
|
|
||||||
|
.. versionadded:: 2.7
|
||||||
|
|
||||||
|
|
||||||
.. function:: compile_path([skip_curdir[, maxlevels[, force]]])
|
.. function:: compile_path([skip_curdir[, maxlevels[, force]]])
|
||||||
|
|
||||||
Byte-compile all the :file:`.py` files found along ``sys.path``. If
|
Byte-compile all the :file:`.py` files found along ``sys.path``. If
|
||||||
|
|
|
@ -9,7 +9,6 @@ recursing into subdirectories. (Even though it should do so for
|
||||||
packages -- for now, you'll have to deal with packages separately.)
|
packages -- for now, you'll have to deal with packages separately.)
|
||||||
|
|
||||||
See module py_compile for details of the actual byte-compilation.
|
See module py_compile for details of the actual byte-compilation.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
@ -31,7 +30,6 @@ def compile_dir(dir, maxlevels=10, ddir=None,
|
||||||
directory name that will show up in error messages)
|
directory name that will show up in error messages)
|
||||||
force: if 1, force compilation, even if timestamps are up-to-date
|
force: if 1, force compilation, even if timestamps are up-to-date
|
||||||
quiet: if 1, be quiet during compilation
|
quiet: if 1, be quiet during compilation
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if not quiet:
|
if not quiet:
|
||||||
print 'Listing', dir, '...'
|
print 'Listing', dir, '...'
|
||||||
|
@ -61,15 +59,16 @@ def compile_dir(dir, maxlevels=10, ddir=None,
|
||||||
return success
|
return success
|
||||||
|
|
||||||
def compile_file(fullname, ddir=None, force=0, rx=None, quiet=0):
|
def compile_file(fullname, ddir=None, force=0, rx=None, quiet=0):
|
||||||
"""Byte-compile file.
|
"""Byte-compile one file.
|
||||||
file: the file to byte-compile
|
|
||||||
|
Arguments (only fullname is required):
|
||||||
|
|
||||||
|
fullname: the file to byte-compile
|
||||||
ddir: if given, purported directory name (this is the
|
ddir: if given, purported directory name (this is the
|
||||||
directory name that will show up in error messages)
|
directory name that will show up in error messages)
|
||||||
force: if 1, force compilation, even if timestamps are up-to-date
|
force: if 1, force compilation, even if timestamps are up-to-date
|
||||||
quiet: if 1, be quiet during compilation
|
quiet: if 1, be quiet during compilation
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
success = 1
|
success = 1
|
||||||
name = os.path.basename(fullname)
|
name = os.path.basename(fullname)
|
||||||
if ddir is not None:
|
if ddir is not None:
|
||||||
|
@ -120,7 +119,6 @@ def compile_path(skip_curdir=1, maxlevels=0, force=0, quiet=0):
|
||||||
maxlevels: max recursion level (default 0)
|
maxlevels: max recursion level (default 0)
|
||||||
force: as for compile_dir() (default 0)
|
force: as for compile_dir() (default 0)
|
||||||
quiet: as for compile_dir() (default 0)
|
quiet: as for compile_dir() (default 0)
|
||||||
|
|
||||||
"""
|
"""
|
||||||
success = 1
|
success = 1
|
||||||
for dir in sys.path:
|
for dir in sys.path:
|
||||||
|
|
Loading…
Reference in New Issue