Browse Source

Remove extra spaces in file path

master
venkataakhil 1 year ago
parent
commit
04c16f8dcf
  1. 20
      smart_service/apis/master_api.py

20
smart_service/apis/master_api.py

@ -16,6 +16,9 @@ site_name = cstr(frappe.local.site)
base_url = os.path.expanduser(
"~") + "/frappe-bench/sites/" + site_name + "/public/files"
base_path = os.path.expanduser(
"~") + "/frappe-bench/sites/" + site_name + "/public"
@frappe.whitelist(allow_guest=True)
def masters1():
@ -432,8 +435,7 @@ def change_file_dir():
def file_not_exists():
base_path = os.path.expanduser(
"~") + "/frappe-bench/sites/" + site_name + "/public"
file_data = frappe.db.sql('''
select parent,step_name,file from tabProcedure_Details where content_type = 'File' order by parent; ;''', as_dict=1)
@ -451,3 +453,17 @@ def file_not_exists():
outfile.write(json.dumps(changed_file_list))
except Exception as e:
pass
def remove_extra_spacces_in_file_path():
import re
file_path_not_exists = base_path + "/files/json_files/1.json"
with open(file_path_not_exists, 'r') as outfile:
data = json.load(outfile)
for d in data:
res_str = re.sub("/files/ /", "/files/", d['file'])
res_str = re.sub("/files/ ", "/files/", res_str)
frappe.db.sql(f'''
update tabProcedure_Details set file = '{res_str}' where name = '{d['name']}';
''')
frappe.db.commit()

Loading…
Cancel
Save