PageRenderTime 37ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/documentation_files/compileall.py

https://github.com/kensington/kdevelop-python
Python | 90 lines | 44 code | 21 blank | 25 comment | 15 complexity | 5c6c431d09161503426db6eb8c909b37 MD5 | raw file
  1. #!/usr/bin/env python2.7
  2. # -*- coding: utf-8 -*-
  3. """:synopsis: Tools for byte-compiling all Python source files in a directory tree.
  4. This module provides some utility functions to support installing Python
  5. libraries. These functions compile Python source files in a directory tree.
  6. This module can be used to create the cached byte-code files at library
  7. installation time, which makes them available for use even by users who don't
  8. have write permission to the library directories.
  9. Command-line use
  10. ----------------
  11. This module can work as a script (using :program:`python -m compileall`) to
  12. compile Python sources.
  13. """
  14. def compile_dir(dir,maxlevels,ddir,force,rx,quiet):
  15. """
  16. Recursively descend the directory tree named by *dir*, compiling all :file:`.py`
  17. files along the way.
  18. The *maxlevels* parameter is used to limit the depth of the recursion; it
  19. defaults to ``10``.
  20. If *ddir* is given, it is prepended to the path to each file being compiled
  21. for use in compilation time tracebacks, and is also compiled in to the
  22. byte-code file, where it will be used in tracebacks and other messages in
  23. cases where the source file does not exist at the time the byte-code file is
  24. executed.
  25. If *force* is true, modules are re-compiled even if the timestamps are up to
  26. date.
  27. If *rx* is given, its search method is called on the complete path to each
  28. file considered for compilation, and if it returns a true value, the file
  29. is skipped.
  30. If *quiet* is true, nothing is printed to the standard output unless errors
  31. occur.
  32. """
  33. pass
  34. def compile_file(fullname,ddir,force,rx,quiet):
  35. """
  36. Compile the file with path *fullname*.
  37. If *ddir* is given, it is prepended to the path to the file being compiled
  38. for use in compilation time tracebacks, and is also compiled in to the
  39. byte-code file, where it will be used in tracebacks and other messages in
  40. cases where the source file does not exist at the time the byte-code file is
  41. executed.
  42. If *rx* is given, its search method is passed the full path name to the
  43. file being compiled, and if it returns a true value, the file is not
  44. compiled and ``True`` is returned.
  45. If *quiet* is true, nothing is printed to the standard output unless errors
  46. occur.
  47. """
  48. pass
  49. def compile_path(skip_curdir,maxlevels,force):
  50. """
  51. Byte-compile all the :file:`.py` files found along ``sys.path``. If
  52. *skip_curdir* is true (the default), the current directory is not included
  53. in the search. All other parameters are passed to the :func:`compile_dir`
  54. function. Note that unlike the other compile functions, ``maxlevels``
  55. defaults to ``0``.
  56. To force a recompile of all the :file:`.py` files in the :file:`Lib/`
  57. subdirectory and all its subdirectories::
  58. import compileall
  59. compileall.compile_dir('Lib/', force=True)
  60. # Perform same compilation, excluding files in .svn directories.
  61. import re
  62. compileall.compile_dir('Lib/', rx=re.compile('/[.]svn'), force=True)
  63. """
  64. pass