|
|
@ -1,6 +1,13 @@ |
|
|
|
import frappe |
|
|
|
import json |
|
|
|
import time |
|
|
|
import re |
|
|
|
import os |
|
|
|
from frappe.utils import cstr |
|
|
|
site_name = cstr(frappe.local.site) |
|
|
|
|
|
|
|
base_path = os.path.expanduser( |
|
|
|
"~") + "/frappe-bench/sites/" + site_name + "/public" |
|
|
|
|
|
|
|
# @frappe.whitelist(allow_guest=1) |
|
|
|
# def delete_all_publish(): |
|
|
@ -11,3 +18,50 @@ import time |
|
|
|
# except Exception as e: |
|
|
|
# return str(e) |
|
|
|
# return True |
|
|
|
|
|
|
|
def change_star_data(): |
|
|
|
count = frappe.db.sql(''' |
|
|
|
select count(*) from tabProcedure_Details where content like '%**%'; |
|
|
|
''', as_dict=1) |
|
|
|
print(count) |
|
|
|
updated_list = [] |
|
|
|
error_list = [] |
|
|
|
data = frappe.db.sql(''' |
|
|
|
select step_name,content_type,content,name,parent,replace(content,'**','abcxyz ') as new_content from tabProcedure_Details where content like '%**%'; |
|
|
|
''', as_dict=1) |
|
|
|
for v in data: |
|
|
|
try: |
|
|
|
result = re.split(r"abcxyz ", v['new_content'], flags=0) |
|
|
|
FLAG = 0 |
|
|
|
sts = '' |
|
|
|
if len(result) > 1: |
|
|
|
sts += result[0] |
|
|
|
for r in range(1, len(result)): |
|
|
|
if FLAG == 0: |
|
|
|
sts += '<b>' + result[r] + '</b>' |
|
|
|
FLAG = 1 |
|
|
|
else: |
|
|
|
sts += result[r] |
|
|
|
FLAG = 0 |
|
|
|
frappe.db.sql( |
|
|
|
f'''update tabProcedure_Details set content = "{sts}" where name = '{v['name']}'; ''') |
|
|
|
v['new_content'] = sts |
|
|
|
except Exception as e: |
|
|
|
error_list.append({v['name']: e}) |
|
|
|
updated_list.append(v) |
|
|
|
|
|
|
|
content_file = base_path + "/files/json_files/content_update.json" |
|
|
|
error_file = base_path + "/files/json_files/content_error.json" |
|
|
|
|
|
|
|
with open(error_file, 'w') as outfile: |
|
|
|
try: |
|
|
|
outfile.write(json.dumps(error_list)) |
|
|
|
except: |
|
|
|
pass |
|
|
|
with open(content_file, 'w') as outfile: |
|
|
|
try: |
|
|
|
outfile.write(json.dumps(updated_list)) |
|
|
|
except: |
|
|
|
pass |
|
|
|
return content_file |
|
|
|
|
|
|
|