This is an automated email from the ASF dual-hosted git repository.

humbedooh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git


The following commit(s) were added to refs/heads/master by this push:
     new d065941  add a convert_lf option for fixing LF line endings on the fly 
with f=f
     new 6b1fe8f  Merge branch 'master' of 
github.com:apache/incubator-ponymail-foal
d065941 is described below

commit d065941c953bdcbdbce0e91260bc9f2d2dd41ad4
Author: Daniel Gruno <[email protected]>
AuthorDate: Wed Aug 19 10:31:09 2020 +0200

    add a convert_lf option for fixing LF line endings on the fly with f=f
    
    also remove unused imports that were lingering..
    This new feature is disabled by default, as it breaks unit testing.
    Need to find a way around that.
---
 tools/archiver.py | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/tools/archiver.py b/tools/archiver.py
index 32c2597..cbe66e4 100755
--- a/tools/archiver.py
+++ b/tools/archiver.py
@@ -54,8 +54,6 @@ import traceback
 import typing
 import uuid
 
-import certifi
-import chardet
 import formatflowed
 import netaddr
 import yaml
@@ -193,14 +191,20 @@ class Body:
     def encode(self, charset="utf-8", errors="strict"):
         return self.string.encode(charset, errors=errors)
 
-    def unflow(self):
+    def unflow(self, convert_lf = False):
         if self.string:
             if self.flowed:
-                return formatflowed.convertToWrapped(
-                    self.string.encode(self.character_set, errors="ignore"),
+                # Convert lone LF to CRLF if found
+                if convert_lf:
+                    fixed_string = "\r\n".join([x.strip() for x in 
self.string.split("\n")])
+                else:
+                    fixed_string = self.string
+                flow_fixed = formatflowed.convertToWrapped(
+                    fixed_string.encode(self.character_set, errors="ignore"),
                     wrap_fixed=False,
                     character_set=self.character_set,
                 )
+                return flow_fixed
         return self.string
 
 

Reply via email to