Spaces:
Sleeping
Sleeping
sourabhzanwar
commited on
Commit
•
77d2366
1
Parent(s):
3cc9efa
updateed app.py, added file to check if v1 is already changed
Browse files
app.py
CHANGED
@@ -1,32 +1,32 @@
|
|
1 |
-
import pydantic
|
2 |
-
module_file_path = pydantic.__file__
|
3 |
|
4 |
-
module_file_path = module_file_path.split('pydantic')[0] + 'haystack'
|
5 |
|
6 |
-
import os
|
7 |
-
import fileinput
|
8 |
|
9 |
|
10 |
-
def replace_string_in_files(folder_path, old_str, new_str):
|
11 |
-
for subdir, dirs, files in os.walk(folder_path):
|
12 |
-
for file in files:
|
13 |
-
file_path = os.path.join(subdir, file)
|
14 |
|
15 |
# Check if the file is a text file (you can modify this condition based on your needs)
|
16 |
-
if file.endswith(".txt") or file.endswith(".py"):
|
17 |
-
# Open the file in place for editing
|
18 |
-
with fileinput.FileInput(file_path, inplace=True) as f:
|
19 |
-
for line in f:
|
20 |
-
# Replace the old string with the new string
|
21 |
-
print(line.replace(old_str, new_str), end='')
|
22 |
-
|
23 |
-
with open('change_log.txt','r') as f:
|
24 |
-
status = f.readlines()
|
25 |
-
|
26 |
-
if status[-1] != 'changed':
|
27 |
-
replace_string_in_files(module_file_path, 'from pydantic', 'from pydantic.v1')
|
28 |
-
with open('change_log.txt','w'):
|
29 |
-
f.write('changed')
|
30 |
|
31 |
|
32 |
|
|
|
1 |
+
#import pydantic
|
2 |
+
#module_file_path = pydantic.__file__
|
3 |
|
4 |
+
#module_file_path = module_file_path.split('pydantic')[0] + 'haystack'
|
5 |
|
6 |
+
#import os
|
7 |
+
#import fileinput
|
8 |
|
9 |
|
10 |
+
#def replace_string_in_files(folder_path, old_str, new_str):
|
11 |
+
# for subdir, dirs, files in os.walk(folder_path):
|
12 |
+
# for file in files:
|
13 |
+
# file_path = os.path.join(subdir, file)
|
14 |
|
15 |
# Check if the file is a text file (you can modify this condition based on your needs)
|
16 |
+
# if file.endswith(".txt") or file.endswith(".py"):
|
17 |
+
# # Open the file in place for editing
|
18 |
+
# with fileinput.FileInput(file_path, inplace=True) as f:
|
19 |
+
# for line in f:
|
20 |
+
# # Replace the old string with the new string
|
21 |
+
# print(line.replace(old_str, new_str), end='')
|
22 |
+
|
23 |
+
#with open('change_log.txt','r') as f:
|
24 |
+
# status = f.readlines()
|
25 |
+
|
26 |
+
#if status[-1] != 'changed':
|
27 |
+
# replace_string_in_files(module_file_path, 'from pydantic', 'from pydantic.v1')
|
28 |
+
# with open('change_log.txt','w'):
|
29 |
+
# f.write('changed')
|
30 |
|
31 |
|
32 |
|