1
0
mirror of https://github.com/certbot/certbot.git synced 2026-01-26 07:41:33 +03:00

Fix certbot.compat.os docs (#8209)

* Don't document stdlib os.

* Move isort out of docstring.

* fix os import

* fix comment length
This commit is contained in:
Brad Warren
2020-08-13 17:24:31 -07:00
committed by GitHub
parent f93b90f87a
commit 2d62dec7ec

View File

@@ -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).