@@ -360,6 +360,7 @@ def gather(self):
360
360
hh = raw_line [13 :15 ]
361
361
mm = raw_line [15 :17 ]
362
362
rnd = "%05d" % random .randint (1 ,10000 )
363
+ is_plaintext = (raw_line [37 ] == ' ' )
363
364
364
365
subdir = os .path .join ( self .o .variableExpansion (self .o .directory ), \
365
366
f"{ RxTime .year } { RxTime .month :02d} { RxTime .day :02d} " , f"{ self .o .source } " , \
@@ -368,16 +369,19 @@ def gather(self):
368
369
os .makedirs ( subdir )
369
370
370
371
BulletinFile = os .path .join ( subdir , f"{ Ahl } _{ dd } { hh } { mm } _{ rnd } " )
371
- bf = open (BulletinFile ,'w ' )
372
+ bf = open (BulletinFile ,'wb ' )
372
373
#logger.info( f"writing: {BulletinFile}" )
373
- bf .write ( f"{ Ahl .replace ('_' ,' ' )} { dd } { hh } { mm } \r \r \n " )
374
+ bf .write ( f"{ Ahl .replace ('_' ,' ' )} { dd } { hh } { mm } \r \r \n " . encode ( 'latin1' ) )
374
375
except Exception as ex :
375
376
logger .error ( "problem reading ob" , exc_info = True )
376
377
continue
377
- for l in raw_line .split ('\\ n' ):
378
- #l=l.replace('\\r','').replace('\\\\','\\').strip()+'\r\n'
379
- l = l .replace ('\\ r' ,'' ).strip ()+ '\r \n '
380
- bf .write (l )
378
+
379
+ if is_plaintext :
380
+ for l in raw_line .split ('\\ n' ):
381
+ l = l .replace ('\\ r' ,'\r ' ).strip ()+ '\n '
382
+ bf .write (l .encode ('latin1' ))
383
+ else :
384
+ bf .write (byte_line )
381
385
382
386
if bf :
383
387
bf .close ()
0 commit comments