|
|
@ -7,18 +7,29 @@ import frappe,json |
|
|
|
current_db_name = frappe.conf.get("db_name") |
|
|
|
import sys |
|
|
|
sys.tracebacklimit=0 |
|
|
|
import re |
|
|
|
|
|
|
|
class Procedure(Document): |
|
|
|
def validate(self): |
|
|
|
if self.procedure_details: |
|
|
|
for x in self.get("procedure_details"): |
|
|
|
if x.content: |
|
|
|
try: |
|
|
|
title = x.content.encode('cp1252').decode('UTF-8') |
|
|
|
x.content = title |
|
|
|
frappe.msgprint(str(title)) |
|
|
|
except Exception as e: |
|
|
|
pass |
|
|
|
# try: |
|
|
|
pass |
|
|
|
# title = x.content.encode('cp1252').decode('UTF-8') |
|
|
|
# frappe.msgprint(str(x.as_dict())+":" +str(title)) |
|
|
|
res_str = re.sub("–", "—", x.content) |
|
|
|
res_str = re.sub("—", "–", res_str) |
|
|
|
res_str = re.sub("‘", "‘", res_str) |
|
|
|
res_str = re.sub("’", "’", res_str) |
|
|
|
res_str = re.sub("“", "“", res_str) |
|
|
|
res_str = re.sub("â€", "”", res_str) |
|
|
|
|
|
|
|
|
|
|
|
x.content = res_str |
|
|
|
# frappe.msgprint(str(title)) |
|
|
|
# except Exception as e: |
|
|
|
# frappe.log_error("validate encoding",frappe.get_traceback()) |
|
|
|
if x.content_type == "File": |
|
|
|
if not x.file: |
|
|
|
frappe.throw("Please choose the file in row no " + str(x.idx)) |
|
|
|