diff --git a/certbot/certbot/compat/os.py b/certbot/certbot/compat/os.py index d262409c1..b4aea054f 100644 --- a/certbot/certbot/compat/os.py +++ b/certbot/certbot/compat/os.py @@ -3,8 +3,11 @@ This compat modules is a wrapper of the core os module that forbids usage of spe (e.g. chown, chmod, getuid) that would be harmful to the Windows file security model of Certbot. This module is intended to replace standard os module throughout certbot projects (except acme). -isort:skip_file +This module has the same API as the os module in the Python standard library +except for the functions defined below. + """ +# isort:skip_file # pylint: disable=function-redefined from __future__ import absolute_import @@ -21,12 +24,15 @@ import os as std_os # pylint: disable=os-module-forbidden import sys as std_sys ourselves = std_sys.modules[__name__] -for attribute in dir(std_os): - # Check if the attribute does not already exist in our module. It could be internal attributes - # of the module (__name__, __doc__), or attributes from standard os already imported with - # `from os import *`. - if not hasattr(ourselves, attribute): - setattr(ourselves, attribute, getattr(std_os, attribute)) +# Adding all of stdlib os to this module confuses Sphinx so we skip this when +# building the documentation. +if not std_os.environ.get("CERTBOT_DOCS") == "1": + for attribute in dir(std_os): + # Check if the attribute does not already exist in our module. It could + # be internal attributes of the module (__name__, __doc__), or + # attributes from standard os already imported with `from os import *`. + if not hasattr(ourselves, attribute): + setattr(ourselves, attribute, getattr(std_os, attribute)) # Import our internal path module, then allow certbot.compat.os.path # to behave as a module (similarly to os.path).