format output file as input_name-clean.ext
This commit is contained in:
@@ -15,6 +15,8 @@
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<a class="btn btn-default" href="{{ request.route_url('home') }}">
|
||||
<span class="glyphicon glyphicon-chevron-left"></span> Retour</a>
|
||||
<input type="submit" name="form.submitted" value="Suivant" class="btn btn-primary">
|
||||
</div>
|
||||
{% else %}
|
||||
|
||||
@@ -13,31 +13,29 @@ import html
|
||||
def home(request):
|
||||
|
||||
message = ''
|
||||
file_name = ''
|
||||
output_name = ''
|
||||
file_url = ''
|
||||
input_encoding = ''
|
||||
libelle = ''
|
||||
|
||||
if 'form.submitted' in request.params:
|
||||
if request.POST['uploadfile'] != b'':
|
||||
input_file = request.POST['uploadfile'].file
|
||||
input_name = request.POST['uploadfile'].filename
|
||||
# récupère le fichier download, faire les controles et traiter
|
||||
message, input_encoding = process_file(request, input_file, input_name)
|
||||
message, input_encoding, output_name = process_file(request, input_file, input_name)
|
||||
# process without error ?
|
||||
if message == '':
|
||||
file_name = "clean_" + input_name
|
||||
file_url = request.static_url('html_cleanup:static/temp/') + file_name
|
||||
file_url = request.static_url('html_cleanup:static/temp/') + output_name
|
||||
if input_encoding == 'utf-8':
|
||||
libelle = "Votre fichier est nettoyé : "
|
||||
message = "Votre fichier est nettoyé : " + output_name
|
||||
else:
|
||||
libelle = "Votre fichier est converti et nettoyé : "
|
||||
message = "Votre fichier est converti et nettoyé : " + output_name
|
||||
|
||||
return {
|
||||
'page_title': "HTML cleanup",
|
||||
'message': message,
|
||||
'file_url': file_url,
|
||||
'file_name': file_name,
|
||||
'libelle': libelle,
|
||||
'file_name': output_name,
|
||||
}
|
||||
|
||||
def process_file(request, input_file, input_name):
|
||||
@@ -71,11 +69,11 @@ def process_file(request, input_file, input_name):
|
||||
|
||||
# Finally write the data to a temporary file
|
||||
input_filename = os.path.join(temp_folder, input_name)
|
||||
# supprimer le fichier s'il existe déjà
|
||||
# if temporary file exists then remove it
|
||||
if os.path.exists(input_filename):
|
||||
os.remove(input_filename)
|
||||
|
||||
# copie le fichier upload dans temp_file
|
||||
# copy input file to temp folder
|
||||
input_file.seek(0)
|
||||
with open(input_filename, 'wb') as output_file:
|
||||
shutil.copyfileobj(input_file, output_file)
|
||||
@@ -101,8 +99,14 @@ def process_file(request, input_file, input_name):
|
||||
f.write(input_buffer)
|
||||
|
||||
|
||||
# controls OK, cleanup input_file
|
||||
output_name = "clean_" + input_name
|
||||
# format output name by adding '-clean'
|
||||
slots = input_name.rsplit('.', 1)
|
||||
if len(slots) == 1:
|
||||
output_name = input_name + "-clean"
|
||||
else:
|
||||
output_name = slots[0].strip() + "-clean." + slots[1]
|
||||
|
||||
# controls OK, cleanup input_filename
|
||||
output_file = os.path.join(temp_folder, output_name)
|
||||
message = clean_html(input_filename, output_file)
|
||||
if message:
|
||||
@@ -110,7 +114,7 @@ def process_file(request, input_file, input_name):
|
||||
else:
|
||||
add_error2log(logfile_name, input_name, "*** Cleanup réussi. ***")
|
||||
|
||||
return message, input_encoding
|
||||
return message, input_encoding, output_name
|
||||
|
||||
def clean_html(input_file, output_file):
|
||||
# cleanup undesirable tags in html file
|
||||
@@ -260,8 +264,13 @@ def view_log(request):
|
||||
message = "Identifiant invalide !"
|
||||
|
||||
if 'form.erased' in request.params:
|
||||
if os.path.exists(logfile_name):
|
||||
os.remove(logfile_name)
|
||||
# effacer tous les fichiers du dossier temp
|
||||
with os.scandir(temp_folder) as entries:
|
||||
for entry in entries:
|
||||
if entry.is_file():
|
||||
os.unlink(entry.path)
|
||||
message = "Tous les fichiers du dossier TEMP sont effacés."
|
||||
|
||||
|
||||
return {
|
||||
'page_title': "Journal de Cleanup",
|
||||
|
||||
90
tests/Co Thien .html
Normal file
90
tests/Co Thien .html
Normal file
@@ -0,0 +1,90 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
|
||||
<title></title>
|
||||
<meta name="generator" content="LibreOffice 7.5.8.2 (Windows)"/>
|
||||
<meta name="author" content="GIAO NGUYEN NGOC"/>
|
||||
<meta name="created" content="2024-02-05T16:22:00"/>
|
||||
<meta name="changedby" content="GIAO NGUYEN NGOC"/>
|
||||
<meta name="changed" content="2024-02-05T16:28:00"/>
|
||||
<meta name="AppVersion" content="14.0000"/>
|
||||
<style type="text/css">
|
||||
@page { size: 21cm 29.7cm; margin: 2.5cm }
|
||||
p { line-height: 115%; text-align: left; orphans: 2; widows: 2; margin-bottom: 0.25cm; direction: ltr; background: transparent }
|
||||
</style>
|
||||
</head>
|
||||
<body lang="fr-FR" link="#000080" vlink="#800000" dir="ltr"><p style="line-height: 100%; margin-bottom: 0.49cm">
|
||||
<font face="Times, serif"><font size="4" style="font-size: 16pt">Cô
|
||||
Thiện </font></font>
|
||||
</p>
|
||||
<p style="line-height: 100%; margin-top: 0.49cm; margin-bottom: 0.49cm">
|
||||
</p>
|
||||
<p style="line-height: 100%; margin-top: 0.49cm; margin-bottom: 0.49cm">
|
||||
<font face="Times, serif"><font size="4" style="font-size: 16pt">1993,
|
||||
ở mãi tận Dole, sinh quán của nhà khoa học Louis Pasteur,
|
||||
vùng Jura cách « kinh đô ánh sáng » đến 360 km,
|
||||
bố tôi bảo « Cô chú Giao là khách Paris xuống
|
||||
chơi nhà ». Rồi chỉ một vài lần cô chú ghé
|
||||
nhà khi thì nghỉ lại một đêm lúc thì dùng cơm với gia
|
||||
đình rồi lại lên đường đi tiếp sang Thụy Sĩ hay
|
||||
xuống miền Nam, hai vị « khách Paris » ấy đã
|
||||
trở thành « Chú Giao, Cô Thiện ». </font></font>
|
||||
</p>
|
||||
<p style="line-height: 100%; margin-top: 0.49cm; margin-bottom: 0.49cm">
|
||||
<font face="Times, serif"><font size="4" style="font-size: 16pt">Năm
|
||||
1996 </font></font><font face="Times, serif"><font size="4" style="font-size: 16pt"><i>Cô
|
||||
Thiện</i></font></font><font face="Times, serif"><font size="4" style="font-size: 16pt">
|
||||
đưa tôi vào RFI làm việc, kiếm thêm tiền để đi học.
|
||||
Tôi vẫn thản nhiên với cách xưng hô như ở nhà và gọi
|
||||
bà phó ban tập Đài Phát Thanh Quốc Tế Pháp là </font></font><font face="Times, serif"><font size="4" style="font-size: 16pt"><i>Cô
|
||||
Thiện</i></font></font><font face="Times, serif"><font size="4" style="font-size: 16pt">.
|
||||
Ba năm sau cô nhất quyết đóng vai trò « bà mai »
|
||||
giới thiệu cho tôi một tấm chồng. Về làm dâu, đúng
|
||||
theo vai vế họ hàng, tôi phải gọi cô « là bà trẻ »
|
||||
vì cô là vai cô của mẹ chồng. Nhưng tôi vẫn giữ
|
||||
nguyên hai chữ </font></font><font face="Times, serif"><font size="4" style="font-size: 16pt"><i>Cô
|
||||
Thiện. </i></font></font>
|
||||
</p>
|
||||
<p style="line-height: 100%; margin-top: 0.49cm; margin-bottom: 0.49cm">
|
||||
<font face="Times, serif"><font size="4" style="font-size: 16pt">Cô
|
||||
về hưu, hai cô cháu vẫn « hẹn hò » một năm
|
||||
ba bốn lần. Khi thì đi vào viện bảo tàng xem triển lãm,
|
||||
hay đi xem phim ; lúc thì đi ăn hay uống cà phê trên
|
||||
Boulevard Saint Germain. Cô cháu chúng tôi có nhiều chuyện
|
||||
để nói với nhau lắm. Chuyện mình, chuyện xã hội,
|
||||
chuyện xưa, chuyện nay … </font></font>
|
||||
</p>
|
||||
<p style="line-height: 100%; margin-bottom: 0cm"><font face="Times, serif"><font size="4" style="font-size: 16pt">Giữa
|
||||
hai cô cháu là cả một chân tình. Tiếng Pháp có một chữ
|
||||
mà tôi rất trân trọng là « Tình Bạn-Amitié ».
|
||||
Trong tiếng Việt tôi không được phép dùng chữ ấy vì
|
||||
nói như thế là hỗn : </font></font><font face="Times, serif"><font size="4" style="font-size: 16pt"><i>Cô</i></font></font><font face="Times, serif"><font size="4" style="font-size: 16pt">
|
||||
là bề trên, là bạn của bố mẹ, là cấp trên trong công
|
||||
việc, là vai bà trẻ. Ngày 04/02/2024, sau 8 giờ tôi, hay
|
||||
tin </font></font><font face="Times, serif"><font size="4" style="font-size: 16pt"><i>Cô
|
||||
Thiện</i></font></font><font face="Times, serif"><font size="4" style="font-size: 16pt">
|
||||
mất, gọi thế nào liên hệ giữa hai cô cháu chúng tôi
|
||||
không còn quan trọng nữa. </font></font>
|
||||
</p>
|
||||
<p style="line-height: 100%; margin-top: 0.49cm; margin-bottom: 0.49cm">
|
||||
<font face="Times, serif"><font size="4" style="font-size: 16pt">Không
|
||||
còn quan trọng vì tôi vừa mất một người đã mang lại
|
||||
cho tôi rất, rất nhiều. Mất một người mà tôi rất,
|
||||
rất quý. Mất một người mà –lại cũng tiếng Việt,
|
||||
không cho phép tôi gọi là Mẹ, nhưng </font></font><font face="Times, serif"><font size="4" style="font-size: 16pt"><i>Tình</i></font></font><font face="Times, serif"><font size="4" style="font-size: 16pt">
|
||||
của </font></font><font face="Times, serif"><font size="4" style="font-size: 16pt"><i>Cô
|
||||
Thiện</i></font></font><font face="Times, serif"><font size="4" style="font-size: 16pt">
|
||||
cho tôi nhiều và đẹp hơn tất cả những gì mà cái vốn
|
||||
liếng tiếng Việt của tôi cho phép viết ra. Nhưng có lẽ
|
||||
không cách xưng hô nào thân mật và ý nghĩa hơn là hai
|
||||
chữ « Cô Thiện ». </font></font></p>
|
||||
<p style="line-height: 100%; margin-bottom: 0cm"><a name="_GoBack"></a>
|
||||
<font face="Times, serif"><font size="4" style="font-size: 16pt">Thanh
|
||||
Hà</font></font></p>
|
||||
<p style="line-height: 100%; margin-bottom: 0.35cm"><br/>
|
||||
<br/>
|
||||
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
139
tests/Em-toi.html
Normal file
139
tests/Em-toi.html
Normal file
@@ -0,0 +1,139 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
|
||||
<title></title>
|
||||
<meta name="generator" content="LibreOffice 7.5.8.2 (Windows)"/>
|
||||
<meta name="author" content="ASUS"/>
|
||||
<meta name="created" content="2024-02-05T08:12:00"/>
|
||||
<meta name="changedby" content="TTS"/>
|
||||
<meta name="changed" content="2024-02-05T09:00:00"/>
|
||||
<meta name="AppVersion" content="12.0000"/>
|
||||
<meta name="ICV" content="ABC6D6715056498EBB6A349125D30BA0_11"/>
|
||||
<meta name="KSOProductBuildVer" content="1033-12.2.0.13359"/>
|
||||
<style type="text/css">
|
||||
@page { size: 21cm 29.7cm; margin-left: 3.18cm; margin-right: 3.18cm; margin-top: 2.54cm; margin-bottom: 2.54cm }
|
||||
p { line-height: 115%; text-align: left; orphans: 2; widows: 2; margin-bottom: 0.25cm; direction: ltr; background: transparent }
|
||||
p.western { so-language: en-US }
|
||||
p.cjk { so-language: zh-CN }
|
||||
</style>
|
||||
</head>
|
||||
<body lang="fr-FR" link="#000080" vlink="#800000" dir="ltr"><p lang="en-US" class="western" align="center" style="line-height: 100%; margin-bottom: 0cm">
|
||||
<font face="Times New Roman, serif"><font size="3" style="font-size: 12pt"><span lang="vi-VN">EM
|
||||
TÔI</span></font></font></p>
|
||||
<p lang="vi-VN" class="western" align="center" style="line-height: 100%; margin-bottom: 0cm">
|
||||
<br/>
|
||||
|
||||
</p>
|
||||
<p lang="en-US" class="western" align="justify" style="line-height: 100%; margin-bottom: 0.21cm">
|
||||
<font face="Times New Roman, serif"><font size="3" style="font-size: 12pt"><span lang="vi-VN">4
|
||||
giờ sáng Việt Nam, tôi bỗng choàng thức dậy và mở
|
||||
email, dù giờ này, vào giờ này vào một </span></font></font><font face="Times New Roman, serif"><font size="3" style="font-size: 12pt"><span lang="fr-FR">đêm</span></font></font><font face="Times New Roman, serif"><font size="3" style="font-size: 12pt"><span lang="vi-VN">
|
||||
chủ nhật, tôi nghĩ sẽ không có ai dù ở Pháp hay Việt
|
||||
Nam gửi thư</span></font></font><font face="Times New Roman, serif"><font size="3" style="font-size: 12pt"><span lang="fr-FR">.</span></font></font><font face="Times New Roman, serif"><font size="3" style="font-size: 12pt"><span lang="vi-VN">
|
||||
</span></font></font>
|
||||
</p>
|
||||
<p lang="en-US" class="western" align="justify" style="line-height: 100%; margin-bottom: 0.21cm">
|
||||
<font face="Times New Roman, serif"><font size="3" style="font-size: 12pt"><span lang="vi-VN">Thế
|
||||
mà có. Tin rất buồn của anh Hà Dương Tường báo tin “
|
||||
tim của Thiện đã ngừng đập ”</span></font></font><font face="Times New Roman, serif"><font size="3" style="font-size: 12pt"><span lang="fr-FR">.</span></font></font></p>
|
||||
<p lang="en-US" class="western" align="justify" style="line-height: 100%; margin-bottom: 0.21cm">
|
||||
<font face="Times New Roman, serif"><font size="3" style="font-size: 12pt"><span lang="vi-VN">Tôi
|
||||
bàng hoàng, tim đau nhói, không thể tin được là em đã
|
||||
bỏ chúng tôi đột ngột, đột ngột ngay cả với em nữa.</span></font></font></p>
|
||||
<p lang="en-US" class="western" align="justify" style="line-height: 100%; margin-bottom: 0.21cm">
|
||||
“ <font face="Times New Roman, serif"><font size="3" style="font-size: 12pt"><span lang="vi-VN">Em
|
||||
không có chị gái, chị có thể làm chị của em được
|
||||
không ? ” Đó là câu Thiện nói với tôi hơn hai mươi
|
||||
năm trước, khi hai chị em mới quen nhau. Và Thiện dặn
|
||||
anh Giao : “ Anh tập trung lo cho bà chị già này đi
|
||||
thay vì mất thời gian lo những việc linh tinh ”</span></font></font><font face="Times New Roman, serif"><font size="3" style="font-size: 12pt"><span lang="fr-FR">.</span></font></font></p>
|
||||
<p lang="en-US" class="western" align="justify" style="line-height: 100%; margin-bottom: 0.21cm">
|
||||
<font face="Times New Roman, serif"><font size="3" style="font-size: 12pt"><span lang="vi-VN">Hai
|
||||
câu ấy đã đủ nói lên tấm lòng của Thiện đối với
|
||||
tôi, một tấm lòng th</span></font></font><font face="Times New Roman, serif"><font size="3" style="font-size: 12pt"><span lang="fr-FR">uỷ</span></font></font><font face="Times New Roman, serif"><font size="3" style="font-size: 12pt"><span lang="vi-VN">
|
||||
chung, lặng lẽ, không phô trương nhưng thấm đậm nghĩa
|
||||
tình.</span></font></font></p>
|
||||
<p lang="en-US" class="western" align="justify" style="line-height: 100%; margin-bottom: 0.21cm"><a name="_GoBack"></a>
|
||||
<font face="Times New Roman, serif"><font size="3" style="font-size: 12pt"><span lang="vi-VN">12
|
||||
năm tôi theo đuổi vụ kiện c</span></font></font><font face="Times New Roman, serif"><font size="3" style="font-size: 12pt"><span lang="fr-FR">á</span></font></font><font face="Times New Roman, serif"><font size="3" style="font-size: 12pt"><span lang="vi-VN">c
|
||||
công ty hóa chất Mỹ là 12 năm em luôn ở bên cạnh tôi
|
||||
âm thầm, không bao giờ lên tiếng, nhưng luôn có mặt khi
|
||||
tôi cần. Hai năm trước, Thiện gọi bảo cho tôi hai bức
|
||||
tranh, đem về bán vì lúc đó, tôi không còn tiền để
|
||||
trả chi phí pháp lý. Số tiền ấy, một nửa tôi trả nợ
|
||||
toà, một nửa mua hai vé máy bay cho luật sư tháng ba năm
|
||||
2024 về gặp lãnh đạo Việt Nam thông báo về tiến trình
|
||||
của vụ kiện. Chính em là người liên hệ với người
|
||||
mua để khi tranh về thì tiền được trao. Tháng mười
|
||||
2023, ông bà đi thăm con cháu về, còn dư một số tiền
|
||||
Việt, em lại cho tôi, nét chữ trên phong bì của Thiện
|
||||
còn đậm “ để chị lo cho nạn nhân da cam ”. </span></font></font>
|
||||
</p>
|
||||
<p lang="en-US" class="western" align="justify" style="line-height: 100%; margin-bottom: 0.21cm">
|
||||
<font face="Times New Roman, serif"><font size="3" style="font-size: 12pt"><span lang="vi-VN">Nghe
|
||||
tôi đi Thuỵ Sĩ theo lời mời của Hội Thuỵ sĩ - Việt
|
||||
Nam, Thiện và anh Giao còn đang bệnh không nhẹ, lặng lẽ
|
||||
mua vé “ để bà ấy không đi một mình ”. Cứ mỗi
|
||||
Noel hay dịp lễ, Thiện lại gọi tôi đi cùng ông bà, sợ
|
||||
tôi một mình lẻ loi.</span></font></font></p>
|
||||
<p lang="en-US" class="western" align="justify" style="line-height: 100%; margin-bottom: 0.21cm">
|
||||
<font face="Times New Roman, serif"><font size="3" style="font-size: 12pt"><span lang="vi-VN">Em
|
||||
Thiện của tôi là như vậy đấy. Sôi nổi, quyết đoán,
|
||||
làm gì cũng lanh lẹ “ vì khi em đi nằm vùng, rồi phụ
|
||||
trách thiếu nhi nên quen tổ chức rồi ”</span></font></font><font face="Times New Roman, serif"><font size="3" style="font-size: 12pt"><span lang="fr-FR">.</span></font></font></p>
|
||||
<p lang="en-US" class="western" align="justify" style="line-height: 100%; margin-bottom: 0.21cm">
|
||||
<font face="Times New Roman, serif"><font size="3" style="font-size: 12pt"><span lang="vi-VN">Gần
|
||||
đây, Thiện hay nói “ em buông bỏ hết, chuẩn bị ra đi
|
||||
cho thanh thản, chỉ mong đi trước anh Giao thôi ”.</span></font></font></p>
|
||||
<p lang="en-US" class="western" align="justify" style="line-height: 100%; margin-bottom: 0.21cm">
|
||||
<font face="Times New Roman, serif"><font size="3" style="font-size: 12pt"><span lang="vi-VN">Và
|
||||
hôm nay em đi, đi trước anh Giao như em muốn, đi nhanh chỉ
|
||||
trong mấy phút bác sĩ chưa kịp mổ để cứu trái tim của
|
||||
em, cũng chưa kịp cắt cái khối ung thư trong ngực em đáng
|
||||
lý sẽ thực hiện hai ngày nữa. Em đi nhanh, gọn nhưng em
|
||||
đã để một khoảng trống vô cùng lớn trong lòng chị,
|
||||
trong lòng tất cả những bạn bè yêu thương em trên khắp
|
||||
thế giới, vì khi sinh tiền, em đi đâu cũng nhận được
|
||||
sự kính trọng, yêu thương của bạn bè đón em, khiến
|
||||
chị cũng được hưởng lây</span></font></font><font face="Times New Roman, serif"><font size="3" style="font-size: 12pt"><span lang="vi-VN"><u>.</u></span></font></font></p>
|
||||
<p lang="en-US" class="western" align="justify" style="line-height: 100%; margin-bottom: 0.21cm">
|
||||
<font face="Times New Roman, serif"><font size="3" style="font-size: 12pt"><span lang="vi-VN">Thanh
|
||||
Thiện, em đi thanh thản, chị nhớ em ngàn lần vì cuộc
|
||||
chiến da cam mà em đã từng sát cánh bên chị vẫn còn
|
||||
kéo dài, chị càng cần em. </span></font></font>
|
||||
</p>
|
||||
<p lang="en-US" class="western" align="justify" style="line-height: 100%; margin-bottom: 0.21cm">
|
||||
<font face="Times New Roman, serif"><font size="3" style="font-size: 12pt"><span lang="vi-VN">Nhưng
|
||||
trên hết, VÌ EM LÀ EM THANH THIỆN </span></font></font>
|
||||
</p>
|
||||
<p lang="vi-VN" class="western" align="justify" style="line-height: 100%; margin-bottom: 0cm">
|
||||
<br/>
|
||||
|
||||
</p>
|
||||
<p lang="en-US" class="western" align="justify" style="line-height: 100%; margin-bottom: 0cm">
|
||||
<font face="Times New Roman, serif"><font size="3" style="font-size: 12pt"><span lang="vi-VN"> Chị
|
||||
Tố Nga của em </span></font></font>
|
||||
</p>
|
||||
<p lang="vi-VN" class="western" align="justify" style="line-height: 100%; margin-bottom: 0cm">
|
||||
<br/>
|
||||
|
||||
</p>
|
||||
<p lang="en-US" class="western" align="justify" style="line-height: 100%; margin-bottom: 0cm">
|
||||
<font face="Times New Roman, serif"><font size="3" style="font-size: 12pt"><span lang="vi-VN"> TP
|
||||
HCM ngày 5 tháng hai năm 2024 </span></font></font>
|
||||
</p>
|
||||
<p lang="vi-VN" class="western" align="justify" style="line-height: 100%; margin-bottom: 0cm">
|
||||
<br/>
|
||||
|
||||
</p>
|
||||
<p lang="vi-VN" class="western" align="justify" style="line-height: 100%; margin-bottom: 0cm">
|
||||
<br/>
|
||||
|
||||
</p>
|
||||
<p lang="vi-VN" class="western" align="justify" style="line-height: 100%; margin-bottom: 0cm">
|
||||
<br/>
|
||||
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user