Skip to content

Commit 1a6bcd3

Browse files
committed
Extract changed files to reuse it in devguide.
1 parent b49be2a commit 1a6bcd3

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

build_docs.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,23 @@ def shell_out(cmd):
6363
raise
6464

6565

66+
def changed_files(directory, other):
67+
logging.info("Computing changed files")
68+
changed = []
69+
if directory[-1] != '/':
70+
directory += '/'
71+
for dirpath, dirnames, filenames in os.walk(directory):
72+
dir_rel = dirpath[len(directory):]
73+
for fn in filenames:
74+
local_path = os.path.join(dirpath, fn)
75+
rel_path = os.path.join(dir_rel, fn)
76+
target_path = os.path.join(other, rel_path)
77+
if (os.path.exists(target_path) and
78+
not _file_unchanged(target_path, local_path)):
79+
changed.append(rel_path)
80+
return changed
81+
82+
6683
def build_one(version, isdev, quick, sphinxbuild, build_root, www_root,
6784
skip_cache_invalidation=False, group='docs', git=False,
6885
log_directory='/var/log/docsbuild/'):
@@ -84,18 +101,7 @@ def build_one(version, isdev, quick, sphinxbuild, build_root, www_root,
84101
shell_out("cd Doc; make SPHINXBUILD=%s %s >> %s 2>&1" %
85102
(sphinxbuild, maketarget, os.path.join(log_directory, logname)))
86103

87-
logging.info("Computing changed files")
88-
changed = []
89-
for dirpath, dirnames, filenames in os.walk("Doc/build/html/"):
90-
dir_rel = dirpath[len("Doc/build/html/"):]
91-
for fn in filenames:
92-
local_path = os.path.join(dirpath, fn)
93-
rel_path = os.path.join(dir_rel, fn)
94-
target_path = os.path.join(target, rel_path)
95-
if (os.path.exists(target_path) and
96-
not _file_unchanged(target_path, local_path)):
97-
changed.append(rel_path)
98-
104+
changed = changed_files(os.path.join(checkout, "Doc/build/html"), target)
99105
logging.info("Copying HTML files to %s", target)
100106
shell_out("chown -R :{} Doc/build/html/".format(group))
101107
shell_out("chmod -R o+r Doc/build/html/")

0 commit comments

Comments
 (0)