From 9046cfec898e1330971f173a0b44a52b30db4a72 Mon Sep 17 00:00:00 2001 From: Vilaboa Date: Wed, 13 Nov 2024 12:30:57 +0100 Subject: [PATCH] IMP hacer libcnmc compatible con Py3 --- libcnmc/cir_4_2015/F9.py | 9 +++------ libcnmc/core/__init__.py | 11 ++++------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/libcnmc/cir_4_2015/F9.py b/libcnmc/cir_4_2015/F9.py index e0b3c5d3..e10a5c57 100644 --- a/libcnmc/cir_4_2015/F9.py +++ b/libcnmc/cir_4_2015/F9.py @@ -4,10 +4,7 @@ from libcnmc.core import StopMultiprocessBased from libcnmc.utils import get_srid, convert_srid, format_f, parse_geom -try: - from cStringIO import StringIO -except: - from StringIO import StringIO +from io import BytesIO class F9(StopMultiprocessBased): @@ -229,7 +226,7 @@ def writer(self): if self.file_output: fio = open(self.file_output, 'wb') else: - fio = StringIO() + fio = BytesIO() while True: try: item = self.output_q.get() @@ -257,7 +254,7 @@ def writer(self): if self.file_modificaciones: fio_mod = open(self.file_modificaciones, 'wb') else: - fio_mod = StringIO() + fio_mod = BytesIO() while True: try: diff --git a/libcnmc/core/__init__.py b/libcnmc/core/__init__.py index 2bcaa587..897e918a 100644 --- a/libcnmc/core/__init__.py +++ b/libcnmc/core/__init__.py @@ -4,10 +4,7 @@ import os import sys from datetime import datetime -try: - from cStringIO import StringIO -except: - from StringIO import StringIO +from io import BytesIO import traceback try: @@ -141,7 +138,7 @@ def writer(self): if self.file_output: fio = open(self.file_output, 'wb') else: - fio = StringIO() + fio = BytesIO() fitxer = csv.writer(fio, delimiter=';', lineterminator='\n') if self.file_header: fitxer.writerow(self.file_header) @@ -170,7 +167,7 @@ def writer_mod(self): if self.file_modificaciones: fio_mod = open(self.file_modificaciones, 'wb') else: - fio_mod = StringIO() + fio_mod = BytesIO() while True: try: @@ -217,7 +214,7 @@ def calc(self): sys.stderr.flush() if self.interactive: sys.stderr.write("Correcte? ") - raw_input() + input() sys.stderr.flush() start = datetime.now() processes = [multiprocessing.Process(target=self.consumer)