Skip to content

Commit

Permalink
Merge pull request #44 from gisce/Fix_mida_descripcio
Browse files Browse the repository at this point in the history
Fix mida descripcio
  • Loading branch information
guilleJB committed Oct 21, 2014
2 parents 857c179 + 529c9ae commit 6411865
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
10 changes: 7 additions & 3 deletions libcnmc/res_4603/LAT.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import math

from libcnmc.core import MultiprocessBased
from libcnmc.utils import get_id_expedient
from libcnmc.utils import get_id_expedient, tallar_text


class LAT(MultiprocessBased):
Expand Down Expand Up @@ -112,11 +112,15 @@ def consumer(self):
else:
capacitat = int(round(cap))

#Descripció
origen = tallar_text(tram['origen'], 50)
final = tallar_text(tram['final'], 50)

output = [
'A%s' % tram['name'],
tram['cini'] or '',
tram['origen'] or '',
tram['final'] or '',
origen or '',
final or '',
codi['codi'] or '',
comunitat,
comunitat,
Expand Down
10 changes: 7 additions & 3 deletions libcnmc/res_4603/LBT.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import sys

from libcnmc.core import MultiprocessBased
from libcnmc.utils import get_id_expedient
from libcnmc.utils import get_id_expedient, tallar_text

QUIET = False

Expand Down Expand Up @@ -130,11 +130,15 @@ def consumer(self):
else:
capacitat = int(round(cap))

#Descripció
origen = tallar_text(edge['start_node'], 50)
final = tallar_text(edge['end_node'], 50)

output = [
'B%s' % linia['name'],
linia['cini'] or '',
edge['start_node'][1] or '',
edge['end_node'][1] or '',
origen or '',
final or '',
codi['codi'] or '',
comunitat,
comunitat,
Expand Down
6 changes: 6 additions & 0 deletions libcnmc/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,9 @@ def get_id_expedient(connection, expedients_id):
if id_expedients:
id_expedient = id_expedients[0]
return id_expedient

def tallar_text(text, long):
if len(text) > long:
return text[:long-3] + '...'
else:
return text

0 comments on commit 6411865

Please sign in to comment.