src/p4l/utils.py
changeset 113 c05567404888
parent 109 9328fa268f45
child 114 93b45b4f423c
equal deleted inserted replaced
112:ba6056f58516 113:c05567404888
     1 # -*- coding: utf-8 -*-
     1 # -*- coding: utf-8 -*-
     2 import codecs #@UnresolvedImport
     2 import codecs
     3 import logging
     3 import logging
     4 import math
     4 import math
     5 import sys
     5 import sys
       
     6 import unicodedata
     6 
     7 
     7 from django.conf import settings
     8 from django.conf import settings
     8 from django.db.models.query import QuerySet
       
     9 from django.db.models.query_utils import Q
       
    10 import requests #@UnresolvedImport
       
    11 from django.core.validators import URLValidator
     9 from django.core.validators import URLValidator
       
    10 import requests
    12 
    11 
    13 
    12 
    14 logger = logging.getLogger(__name__)
    13 logger = logging.getLogger(__name__)
    15 
    14 
    16 def show_progress(current_line, total_line, label, width, writer=None):
    15 def show_progress(current_line, total_line, label, width, writer=None):
   179                     l = o.label
   178                     l = o.label
   180                     o.save()
   179                     o.save()
   181                     found += 1
   180                     found += 1
   182                     writer = show_progress(i, total_objs, l, 50, writer=writer)
   181                     writer = show_progress(i, total_objs, l, 50, writer=writer)
   183     print("Processing Sparql Done. %d found on %d" % (found, total_objs))
   182     print("Processing Sparql Done. %d found on %d" % (found, total_objs))
       
   183 
       
   184 def strip_accents(value):
       
   185     return ''.join(c for c in unicodedata.normalize('NFD', value)
       
   186                   if unicodedata.category(c) != 'Mn')
   184     
   187