Skip to content

Commit 29b6b25

Browse files
committed
Address comments
1 parent 8e40280 commit 29b6b25

6 files changed

Lines changed: 35 additions & 22 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This package is for implementing the software needs of the E3SM Communications t
88

99
`e3sm-comms-e3sm-org-reviewer`
1010
- input:
11-
- From WordPress under Tools > Export: xml file of WordPress pages, xml file of WordPress posts. Note: your export will go to your local machine. Example transfer command: `scp local_path/wordpress_posts.xml forsyth@perlmutter.nersc.gov:perlmutter_path/wordpress_posts.xml`.
11+
- From WordPress under Tools > Export: xml file of WordPress pages, xml file of WordPress posts. Note: your export will go to your local machine. Example transfer command: `scp local_path/wordpress_posts.xml user@host:/remote/path/wordpress_posts.xml`.
1212
- From output of `e3sm-comms-website-reviewer`: txt file of hierarchical outline of Confluence pages, txt file of sensitive terms found on Confluence pages
1313
- Other: txt file of whitelisted e3sm.org pages, txt file of e3sm.org pages expected to be archived, txt file of sensitive terms, txt file of known-ok e3sm.org pages (that is, script is picking up errors we don't care about), txt file of keep-unchanged e3sm.org pages (that is, pages we don't want to change)
1414
- output: 3 Markdown summary reports: (1) An analysis of the e3sm.org paths, (2) An analysis of the sensitive terms found, (3) the key action items
@@ -31,7 +31,7 @@ This package is for implementing the software needs of the E3SM Communications t
3131
- From WordPress under Tools > Export: xml file of WordPress pages, xml file of WordPress posts
3232
- From output of `e3sm-comms-website-reviewer`: txt file of hierarchical outline of Confluence pages
3333
- Other: txt file of sensitive terms, txt file of whitelisted e3sm.org pages
34-
- output: Markdown summary report of sensitive terms found in exported WordPress data
34+
- output: 5 files under `output/exported_xml_reviewer/`: (1) `wordpress_sensitive_terms_report.md`, (2) `wordpress_hierarchical_outline.txt`, (3) `wordpress_navigation_issues_report.md`, (4) `wordpress_invalid_internal_links_report.md`, (5) `wordpress_published_pages_link_report.md`
3535

3636
### Confluence API commands (require Confluence token)
3737

e3sm_comms/exported_xml_reviewer/main.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,24 @@
1818
# Configuration
1919
# -----------------------------------------------------------------------------
2020

21+
# Required inputs:
2122
INPUT_XML_PAGES: str = f"{IO_DIR}/input/exported_xml_reviewer/wordpress_pages.xml"
2223
INPUT_XML_POSTS: str = f"{IO_DIR}/input/exported_xml_reviewer/wordpress_posts.xml"
23-
INPUT_CONFLUENCE_HIERARCHY: str = ""
2424
INPUT_SEARCH_PHRASES: str = f"{IO_DIR}/input/shared/sensitive_terms.txt"
25-
INPUT_WHITELIST: str = ""
2625
INPUT_REQUESTED_LINKS: str = f"{IO_DIR}/input/exported_xml_reviewer/requested_links.csv"
2726
INPUT_KNOWN_OK_LINKS: str = f"{IO_DIR}/input/exported_xml_reviewer/known_ok_links.txt"
2827

28+
# Optional inputs:
29+
INPUT_CONFLUENCE_HIERARCHY: str = ""
30+
# INPUT_CONFLUENCE_HIERARCHY: str = (
31+
# f"{IO_DIR}/input/exported_xml_reviewer/hierarchical_outline.txt"
32+
# )
33+
INPUT_WHITELIST: str = ""
34+
# INPUT_WHITELIST: str = (
35+
# f"{IO_DIR}/input/exported_xml_reviewer/whitelisted_web_pages.txt"
36+
# )
37+
38+
# Outputs:
2939
OUTPUT_MARKDOWN_REPORT: str = (
3040
f"{IO_DIR}/output/exported_xml_reviewer/wordpress_sensitive_terms_report.md"
3141
)
@@ -1357,7 +1367,7 @@ def write_section(
13571367
f.write(
13581368
"| Published item | known archived links | published item, wrong URL, but redirection working | link does not work | valid e3sm.org links |\n"
13591369
)
1360-
f.write("| --- | --- | --- | --- | ---: |\n")
1370+
f.write("| --- | --- | --- | --- | --- |\n")
13611371

13621372
archived_total = 0
13631373
redirected_total = 0

e3sm_comms/page_reviewer/utils_base.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -354,20 +354,20 @@ def get_e3sm_url_status(e3sm_url: str) -> str:
354354
try:
355355
response = requests.get(e3sm_url, timeout=10)
356356
response.raise_for_status() # Raises HTTPError for 4xx/5xx responses
357-
e3sm_url_status = "link works not logged-in"
357+
return "link works not logged-in"
358358
except requests.exceptions.Timeout:
359-
e3sm_url_status = "link times out"
360-
except requests.exceptions.RequestException as e:
361-
error_message: str = f"{e}"
362-
if error_message.startswith(
363-
"503 Server Error: Service Temporarily Unavailable for url: https://e3sm.org"
364-
):
365-
e3sm_url_status = "link not whitelisted"
366-
else:
367-
e3sm_url_status = "link raises RequestException"
359+
return "link times out"
360+
except requests.exceptions.HTTPError as e:
361+
status_code = e.response.status_code if e.response is not None else None
362+
if status_code == 503 and (
363+
e.response.url if e.response is not None else ""
364+
).startswith("https://e3sm.org"):
365+
return "link not whitelisted"
366+
return "link raises RequestException"
367+
except requests.exceptions.RequestException:
368+
return "link raises RequestException"
368369
except Exception:
369-
e3sm_url_status = "link raises Exception"
370-
return e3sm_url_status
370+
return "link raises Exception"
371371

372372

373373
# Debugging ###################################################################

e3sm_comms/page_reviewer/utils_website_reviewer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def write_results(config: Config, page: ConfluencePage):
2626
with open(
2727
f"{config.output_dir}hierarchical_outline.txt", "a", encoding="utf-8"
2828
) as f:
29-
f.write(f"{page.depth * " "}{line_id}\n")
29+
f.write(f"{page.depth * ' '}{line_id}\n")
3030

3131
if "sensitive_terms" in config.requested_output:
3232
# Append if sensitive terms were found.

examples/review_terms.bash

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
# Before running:
2-
# e3sm.org > CMP Settings > CMP Advanced Setup: copy the list of pages to /global/homes/f/forsyth/ez/e3sm-comms-io/input/e3sm_org_reviewer/web_pages.txt
2+
# WordPress: Tools > Export > export pages (wordpress_pages.xml) and posts (wordpress_posts.xml)
3+
# Copy those XMLs into /global/homes/f/forsyth/ez/e3sm-comms-io/input/e3sm_org_reviewer/
4+
# e3sm.org > CMP Settings > CMP Advanced Setup: copy the list of pages to /global/homes/f/forsyth/ez/e3sm-comms-io/input/e3sm_org_reviewer/whitelisted_web_pages.txt
35
# Also confirm confluence_top_levels_partial.txt is the list of top levels you want to use, otherwise switch it out.
46

57
IO_DIR=/global/homes/f/forsyth/ez/e3sm-comms-io
68

79
echo "Count of top-level Confluence pages:"
810
wc -l ${IO_DIR}/input/website_reviewer/confluence_top_levels_partial.txt # Excludes MODEL, RESEARCH, DATA
9-
echo "Count of whitelisted e3sm.org pages":
10-
wc -l ${IO_DIR}/input/e3sm_org_reviewer/web_pages.txt
11+
echo "Count of whitelisted e3sm.org pages:"
12+
wc -l ${IO_DIR}/input/e3sm_org_reviewer/whitelisted_web_pages.txt
1113

1214
echo "Step 1. Review Confluence"
1315
echo "Note: this will require a Confluence login"
@@ -20,4 +22,4 @@ e3sm-comms-e3sm-org-reviewer
2022
echo "Output reports:"
2123
echo "1. ${IO_DIR}/output/e3sm_org_reviewer/path_report.md"
2224
echo "2. ${IO_DIR}/output/e3sm_org_reviewer/sensitive_terms.md"
23-
echo "3. ${IO_DIR}/output/e3sm_org_reviewer/action_items.md
25+
echo "3. ${IO_DIR}/output/e3sm_org_reviewer/action_items.md"

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ classifiers = [
1919

2020
dependencies = [
2121
"beautifulsoup4",
22+
"requests",
2223
]
2324

2425
[project.optional-dependencies]

0 commit comments

Comments
 (0)