lfoppiano commited on
Commit
cbd3b5d
·
verified ·
1 Parent(s): 9ae30cb

Delete replace_hw.py

Browse files
Files changed (1) hide show
  1. replace_hw.py +0 -41
replace_hw.py DELETED
@@ -1,41 +0,0 @@
1
- #!/usr/bin/env python3
2
- # filepath: replace_hello_world.py
3
-
4
- import os
5
- import urllib.parse
6
-
7
- def extract_filename(url):
8
- parsed = urllib.parse.urlsplit(url)
9
- return os.path.basename(parsed.path)
10
-
11
- def replace_in_file(file_path, old_text, new_text):
12
- with open(file_path, 'r', encoding='utf8') as file:
13
- content = file.read()
14
-
15
- if old_text not in content:
16
- return
17
-
18
- updated_content = content.replace(old_text, new_text)
19
- with open(file_path, 'w', encoding='utf8') as file:
20
- file.write(updated_content)
21
- print(f"Updated: {file_path}")
22
-
23
- def main():
24
- model_link = os.getenv("MODEL_DOWNLOAD_LINK")
25
- if not model_link:
26
- print("Error: MODEL_DOWNLOAD_LINK environment variable is not set.")
27
- return
28
-
29
- download_filename = extract_filename(model_link)
30
- print(f"Extracted filename: {download_filename}")
31
-
32
- # Recursively walk thru current directory
33
- for dirpath, _, filenames in os.walk(os.getcwd()):
34
- for filename in filenames:
35
- # Modify the following tuple to include any file extensions you wish to process
36
- if filename.endswith(('.html', '.ts', '.patch')):
37
- full_path = os.path.join(dirpath, filename)
38
- replace_in_file(full_path, "Hello World!", download_filename)
39
-
40
- if __name__ == '__main__':
41
- main()