Skip to content

Commit

Permalink
update regex
Browse files Browse the repository at this point in the history
  • Loading branch information
r-akemii committed Dec 2, 2024
1 parent b64a4da commit d48de4a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
- name: Prepare links for DEV
if: ${{ (github.event_name == 'pull_request') && (env.HAS_SECRETS == 'true') }}
run: |
python -c "from docs.replace_regex import replace_regex; replace_regex('test')"
python -c "from docs.replace_regex import replace_regex; replace_regex(f'test/{${{ github.event.number }}}')"
- name: Prepare links for DEVELOP
if: ${{ (github.ref == 'refs/heads/develop') && (github.event_name == 'push')}}
Expand Down Expand Up @@ -84,8 +84,7 @@ jobs:
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: 'us-east-1' # optional: defaults to us-east-1
SOURCE_DIR: 'docs/build/html/' # optional: defaults to entire repository
# DEST_DIR: 'dev/${{ github.event.number }}/python/' # optional: defaults to entire repository
DEST_DIR: 'test/python/' # optional: defaults to entire repository
DEST_DIR: 'test/${{ github.event.number }}/python/' # optional: defaults to entire repository

- name: Upload home page to DEV on S3
if: ${{ (github.event_name == 'pull_request') && (env.HAS_SECRETS == 'true') }}
Expand All @@ -98,8 +97,7 @@ jobs:
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: 'us-east-1' # optional: defaults to us-east-1
SOURCE_DIR: 'docs/build/html/'
# DEST_DIR: 'dev/${{ github.event.number }}/' # optional: defaults to entire repository
DEST_DIR: 'test/' # optional: defaults to entire repository
DEST_DIR: 'test/${{ github.event.number }}/' # optional: defaults to entire repository

- name: Upload python to DEVELOP on S3
if: ${{ (github.ref == 'refs/heads/develop') && (github.event_name == 'push') && (env.HAS_SECRETS == 'true') }}
Expand Down
14 changes: 11 additions & 3 deletions docs/replace_regex.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,20 @@ def replace_regex(event):
if file.endswith((".drawio", ".txt", ".omx")):
continue
full_path = os.path.join(root, file)
print(full_path)
with open(full_path, "rb") as f, mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ) as s:
content = s.read().decode("utf-8")

# Find and replace regex containing the site
modified_content = re.sub(r"www.aequilibrae.com/latest/", rf"www.aequilibrae.com/{event}/", content)
# Find and replace regex containing the website
modified_content = re.sub(
r"www.aequilibrae.com/latest/python/", rf"www.aequilibrae.com/{event}/python/", content
)

if "/" in event:
modified_content = re.sub(
r"www.aequilibrae.com/latest/qgis/",
rf"www.aequilibrae.com/{event.split('/')[0]}/qgis/",
modified_content,
)

# Write modified content back to file
with open(full_path, "w", encoding="utf-8") as w:
Expand Down

0 comments on commit d48de4a

Please sign in to comment.