nanterre: prévient les erreurs unicode quand on pipe rsu-duplicates (#37038)
This commit is contained in:
parent
05f84733a8
commit
fd0ca4b6aa
|
@ -16,7 +16,8 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import sys
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from decimal import Decimal
|
||||
import datetime
|
||||
|
||||
|
@ -101,14 +102,14 @@ class Command(BaseCommand):
|
|||
for t in find_duplicates(count=count, limit=limit, days=days, ids=ids,
|
||||
progression=True):
|
||||
if verbosity > 1:
|
||||
print >>sys.stdout, (
|
||||
self.stdout.write(
|
||||
'New duplicates / persons scanned / persons total :'
|
||||
' %05d / %05d / %05d\r' % t),
|
||||
sys.stdout.flush()
|
||||
' %05d / %05d / %05d\r' % t)
|
||||
self.stdout.flush()
|
||||
if verbosity > 1:
|
||||
print
|
||||
if verbosity > 0 and t[0]:
|
||||
print 'Found %d new duplicates.' % t[0]
|
||||
self.stdout.write('Found %d new duplicates.' % t[0])
|
||||
elif command == 'delete':
|
||||
qs = Duplicate.objects.all()
|
||||
if limit:
|
||||
|
@ -120,7 +121,7 @@ class Command(BaseCommand):
|
|||
qs = qs[:count]
|
||||
if days:
|
||||
since = now() - datetime.timedelta(days=days)
|
||||
print 'Duplicates created after', since
|
||||
self.stdout.write('Duplicates created after', since)
|
||||
qs = qs.filter(created__gte=since)
|
||||
if false:
|
||||
qs = qs.filter(state=Duplicate.STATE_FALSE_POSITIVE)
|
||||
|
@ -133,6 +134,8 @@ class Command(BaseCommand):
|
|||
column_size = max(column_size, len(individu_caption(duplicate.first)),
|
||||
len(individu_caption(duplicate.second)))
|
||||
|
||||
self.stdout.write('%d duplicates\n' % qs.count())
|
||||
|
||||
if false:
|
||||
table = Table(['Declared false', 'ID', 'Name', 'ID', 'Name', 'Score'])
|
||||
table.add_rows([(d.modified.isoformat(), d.first_id, individu_caption(d.first),
|
||||
|
@ -142,7 +145,7 @@ class Command(BaseCommand):
|
|||
table.add_rows([(d.modified.isoformat(), d.first_id, individu_caption(d.first),
|
||||
d.second_id, individu_caption(d.second), d.content['dedup_choice'], d.score) for d in qs])
|
||||
|
||||
print u'| %6s | %*s | %6s | %*s | %5s |' % (
|
||||
self.stdout.write('| %6s | %*s | %6s | %*s | %5s |' % (
|
||||
'ID',
|
||||
column_size,
|
||||
u'État civil',
|
||||
|
@ -150,9 +153,9 @@ class Command(BaseCommand):
|
|||
column_size,
|
||||
u'État civil',
|
||||
'Score',
|
||||
)
|
||||
))
|
||||
for duplicate in qs:
|
||||
print '| %6d | %*s | %6d | %*s | %3d %% |' % (
|
||||
self.stdout.write('| %6d | %*s | %6d | %*s | %3d %% |' % (
|
||||
duplicate.first_id,
|
||||
column_size,
|
||||
individu_caption(duplicate.first),
|
||||
|
@ -160,4 +163,4 @@ class Command(BaseCommand):
|
|||
column_size,
|
||||
individu_caption(duplicate.second),
|
||||
duplicate.score * Decimal(100),
|
||||
)
|
||||
))
|
||||
|
|
Loading…
Reference in New Issue