Skip to content

Commit 8716f26

Browse files
committed
👋geektime docs
1 parent d514c8a commit 8716f26

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

main.py

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,13 +190,33 @@ def make_all_pdf(source, output, timeout, compress, power, port):
190190
try:
191191
os.popen("lsof -i:" + str(port) + " | grep -v 'PID' | awk '{print $2}' | xargs kill -9")
192192
parts_dir = os.path.join(dirname, "parts")
193-
part_dir = os.path.join(parts_dir, os.path.basename(dirname))
194-
if not os.path.exists(part_dir):
195-
os.makedirs(part_dir, exist_ok=True)
196193
pattern = r'https?://[^\s]+'
197194
fpath = os.path.join(dirname, "mkdocs.yml")
198195
data = yaml.safe_load(open(fpath))
199196
print(f'dirname: {dirname}')
197+
output_dir = f'{output}/{os.path.basename(os.path.dirname(dirname))}'
198+
if len(data.get('nav')) < 200:
199+
curr_pdf_name = f"{os.path.basename(dirname)}.pdf"
200+
curr_output_file = os.path.join(output_dir, curr_pdf_name)
201+
if os.path.exists(curr_output_file):
202+
if os.path.exists(parts_dir):
203+
shutil.rmtree(parts_dir)
204+
break
205+
else:
206+
curr_pdf_name = f"{os.path.basename(dirname)}-上.pdf"
207+
curr_output_file_1 = os.path.join(output_dir, curr_pdf_name)
208+
209+
curr_pdf_name = f"{os.path.basename(dirname)}-下.pdf"
210+
curr_output_file_2 = os.path.join(output_dir, curr_pdf_name)
211+
if os.path.exists(curr_output_file_1) and os.path.exists(curr_output_file_2):
212+
if os.path.exists(parts_dir):
213+
shutil.rmtree(parts_dir)
214+
break
215+
216+
part_dir = os.path.join(parts_dir, os.path.basename(dirname))
217+
if not os.path.exists(part_dir):
218+
os.makedirs(part_dir, exist_ok=True)
219+
200220
with tempfile.TemporaryDirectory() as tmpdir:
201221
shutil.copytree(dirname, tmpdir, dirs_exist_ok=True)
202222
for nav in data.get('nav'):
@@ -221,7 +241,7 @@ def make_all_pdf(source, output, timeout, compress, power, port):
221241
matches = re.findall(pattern, mk_data)
222242
images = []
223243
for match in matches:
224-
if 'static001.geekbang.org' not in match:
244+
if 'static001.geekbang.org/' not in match or 'image/' not in match:
225245
continue
226246
match = match if match.count(')') <= 0 else match[:match.index(')')]
227247
if match.count('('):
@@ -294,7 +314,6 @@ def make_all_pdf(source, output, timeout, compress, power, port):
294314
proc.kill()
295315
os.popen("lsof -i:" + str(port) + " | grep -v 'PID' | awk '{print $2}' | xargs kill -9")
296316

297-
output_dir = f'{output}/{os.path.basename(os.path.dirname(dirname))}'
298317
if not os.path.exists(output_dir):
299318
os.makedirs(output_dir, exist_ok=True)
300319

计算机基础/软件工程之美/docs/36 - DevOps工程师到底要做什么事情?.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ DevOps工程师做的事情,就是帮助团队基于DevOps原则来做事,
140140

141141
感谢阅读,如果你觉得这篇文章对你有一些启发,也欢迎把它分享给你的朋友。
142142

143-
![](https!%5B://static001.g%5D%28https://static001.geekbang.org/resource/image/78/9c/788180c8c6dd9b69b2784d2a780a239c.jpg%29eekbang.org/resource/image/78/9c/788180c8c6dd9b69b2784d2a780a239c.jpg)
143+
![](https://static001.geekbang.org/resource/image/78/9c/788180c8c6dd9b69b2784d2a780a239c.jpg)
144144
<div><strong>精选留言(12)</strong></div><ul>
145145
<li><span>林云</span> 👍(13) 💬(1)<p>需要指出“Devops工程师”是一个概念错误。事实上Devops并不是一个职位,如果按照文中所说:“Devops工程师帮助团队搭建CI&#47;CD工具”则应该叫做持续交付工具架构师,而这与文首所说:“运维工程师纷纷改名Devops工程师”在工程师的技术栈领域互相矛盾,难道所有持续交付系统都是由运维工程师搭建的吗?
146146

0 commit comments

Comments
 (0)