How to use get_pure_path method in lisa

Best Python code snippet using lisa_python

renderer_html.py

Source:renderer_html.py Github

copy

Full Screen

...47 dict_, assets_img_ = ret.result()48 search_plus_index.update(dict_)49 assets_img.update(assets_img_)50 # 写入索引51 with open(get_pure_path(book.book_output, "search_plus_index.json"), 'w', encoding="utf-8") as f:52 f.write(json.dumps(search_plus_index, ensure_ascii=False))53 return assets_img54def _render_html(book_title, title, author, basePath, book_summary,55 prev_title, prev_relative_path, next_title, next_relative_path, href, book_path, book_output,56 language, i18n, github_url, base_assets, book_js):57 """生产HTML,返回索引"""58 # 解析页面59 base_assets_path = get_pure_path(*(basePath, base_assets) if base_assets else basePath) # 资源路径60 book_page, toc_tree, tag_katex, tag_mermaid, tag_prism, tag_lightbox, assets_img = parse_file(61 get_pure_path(book_path, href),62 basePath63 )64 # 组装页内导航65 toc = ""66 if len(toc_tree) > 0:67 toc = "<div id='anchor-navigation-ex-navbar'><i class='fa fa-anchor'></i><ul><li>" \68 "<span class='title-icon fa fa-hand-o-right'></span><a aria-label class='on-toolbar-action' href='' " \69 f"""onclick="$('.fa.fa-align-justify').parent()[0].click();">{i18n.get('SUMMARY_TOGGLE')}</a></li>"""70 for h1Toc in toc_tree:71 toc += "<li><span class='title-icon fa fa-hand-o-right'></span>" \72 "<a href='#" + h1Toc["url"] + "'><b>" + h1Toc["level"] + "</b>" + h1Toc["name"] + "</a></li>"73 if len(h1Toc["children"]) > 0:74 toc += "<ul>"75 for h2Toc in h1Toc["children"]:76 toc += "<li><span class='title-icon fa fa-hand-o-right'></span>" \77 "<a href='#" + h2Toc["url"] + "'><b>" + h2Toc["level"] + "</b>" + h2Toc["name"] + "</a></li>"78 if len(h2Toc["children"]) > 0:79 toc += "<ul>"80 for h3Toc in h2Toc["children"]:81 toc += "<li><span class='title-icon fa fa-hand-o-right'></span><a href='#" + h3Toc[82 "url"] + "'><b>" + h3Toc["level"] + "</b>" + h3Toc["name"] + "</a></li>"83 toc += "</ul>"84 toc += "</ul>"85 toc += "</ul></div><a href='#" + toc_tree[0]['url'] \86 + "' id='anchorNavigationExGoTop'><i class='fa fa-arrow-up'></i></a>"87 footer = f"""<footer class="page-footer"><span class="copyright">© {time.localtime().tm_year} {author}. 88All rights reserved.</span><span class="footer-modification">89<span id="busuanzi_container_site_uv" style="display:none">本站访客数 <span id="busuanzi_value_site_uv">90</span> 人次</span></span></footer>91<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>92<script>93{book_js}94</script>"""95 # js96 _js = {}97 if tag_katex:98 _js["katex"] = [get_pure_path(f"{base_assets_path}/lsbook/katex/katex.min.js"),99 get_pure_path(f"{base_assets_path}/lsbook/katex/contrib/auto-render.min.js")]100 if tag_lightbox:101 pass102 if tag_mermaid:103 _js["mermaid"] = [get_pure_path(f"{base_assets_path}/lsbook/mermaid/mermaid.min.js")]104 if tag_prism:105 _js["prism"] = [get_pure_path(f"{base_assets_path}/lsbook/prismjs/clipboard.min.js"),106 get_pure_path(f"{base_assets_path}/lsbook/prismjs/prism.js")]107 # 上下页108 previous_page_link = prev_relative_path != "" and previous_page_link_5_1.substitute(109 prev_title=prev_title,110 prev_relative_path=prev_relative_path111 ) or ""112 next_page_link = next_relative_path != "" and next_page_link_5_2.substitute(113 next_title=next_title,114 next_relative_path=next_relative_path,115 ) or ""116 # 组装正文117 book_body = book_body_4.substitute(118 previous_page_link=previous_page_link,119 next_page_link=next_page_link,120 title=title,121 basePath=basePath,122 toc=toc,123 footer=footer,124 book_page=book_page,125 SEARCH_RESULTS_TITLE=i18n.get("SEARCH_RESULTS_TITLE"),126 SEARCH_NO_RESULTS_TITLE=i18n.get("SEARCH_NO_RESULTS_TITLE")127 )128 # 组装身体129 body = html_body_2.substitute(130 book_summary=book_summary,131 book_body=book_body,132 basePath=basePath,133 language=language,134 LsBook_LINK=i18n.get("LsBook_LINK"),135 github_url=github_url,136 SEARCH_PLACEHOLDER=i18n.get("SEARCH_PLACEHOLDER"),137 js=_js,138 previous_page_link=prev_relative_path,139 next_page_link=next_relative_path140 )141 # 组装头142 head = html_head_1.substitute(143 title=f"{book_title} - {title}",144 author=author,145 base_assets_path=base_assets_path,146 next_relative_path=next_relative_path,147 css=css.substitute(base_assets_path=base_assets_path),148 description=title149 )150 # 组装整体151 page = html_root_0.substitute(152 head=head,153 body=body,154 lang=language,155 js=js.substitute(base_assets_path=base_assets_path)156 )157 out_path = get_pure_path(book_output, href)158 if os.path.basename(href).lower() == "readme.md":159 out_path = get_pure_path(os.path.dirname(out_path), "index.html")160 else:161 out_path = set_extension(out_path, ".html")162 with open(out_path, "w", encoding="utf-8") as f:163 f.write(page)164 body = re.sub(r"(<([^>]+)>)", "", book_page)165 body = re.sub(r"[\n ]+", "", body)166 url = get_pure_path(os.path.relpath(out_path, book_output))167 return {url: {168 "url": url,169 "title": title,170 "keywords": "",171 "body": body,...

Full Screen

Full Screen

path.py

Source:path.py Github

copy

Full Screen

...27 :param ext: 扩展名28 :return:29 """30 return get_filename_not_ext(filename) + ext31def get_pure_path(path, *paths):32 """获取路径,分隔符为 / """33 return Path(os.path.join(path, *paths)).as_posix()34def get_abs_path(path, *paths):35 """获取绝对路径"""36 return os.path.abspath(get_pure_path(path, *paths))37def get_rel_path(book_output, ref: str, current_ref: str):38 """转换为相对路径39 :param book_output: 书籍目录40 :param ref: 要转换的路径41 :param current_ref: 当前路径42 :return:43 """44 _ref = ref45 if os.path.basename(_ref).lower() == "readme.md":46 if os.path.dirname(ref):47 _ref = get_pure_path(os.path.relpath(os.path.dirname(ref)), "index.md")48 else:49 _ref = "index.md"50 return get_pure_path(get_filename_not_ext(51 os.path.relpath(52 get_pure_path(book_output, _ref),53 os.path.dirname(get_pure_path(book_output, current_ref))54 )55 ))56def get_relative_path(book_output, ref: str):57 """转换本页面相对于根的相对路径"""...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run lisa automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful