Skip to content

Commit

Permalink
Merge pull request #672 from gisce/feature/64476_libcnmc_Py3_compatible
Browse files Browse the repository at this point in the history
IMP hacer libcnmc compatible con Py3
  • Loading branch information
ecarreras authored Nov 18, 2024
2 parents b1357e0 + 9046cfe commit 51faa88
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
9 changes: 3 additions & 6 deletions libcnmc/cir_4_2015/F9.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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:
Expand Down
11 changes: 4 additions & 7 deletions libcnmc/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 51faa88

Please sign in to comment.