68
68
SERVICE wikibase:label {bd:serviceParam wikibase:language "fr".} }'''
69
69
70
70
class Query (object ):
71
+ verbosity_level = 0
72
+
71
73
building_types = [
72
74
16970 , # église
73
75
2977 , # cathédrale
@@ -113,13 +115,13 @@ class Query(object):
113
115
373074 , # suffragan diocese
114
116
]
115
117
dateformat = '%Y-%m-%d %H:%M:%S'
116
- verbosity_level = 0
117
118
118
- def __init__ (self ):
119
+ def __init__ (self , verbosity_level ):
119
120
self .cache_places = {}
120
121
self .cache_churches = {}
121
122
self .cache_dioceses = {}
122
123
self .cache_parishes = {}
124
+ self .verbosity_level = verbosity_level
123
125
124
126
@staticmethod
125
127
def decode (string ):
@@ -414,13 +416,15 @@ def populate_fields(self, values, wikidata_id):
414
416
return fields
415
417
416
418
class Processor (object ):
419
+ batch_size = 100
417
420
client = OpenChurchClient ()
418
- q = Query ()
419
421
redis_url = os .getenv ('REDIS_URL' )
420
422
redis_client = redis .from_url (redis_url )
421
- verbosity_level = 0
422
- type = 'diocece'
423
- batch_size = 100
423
+
424
+ def __init__ (self , verbosity_level , type ):
425
+ self .q = Query (verbosity_level = verbosity_level )
426
+ self .verbosity_level = verbosity_level
427
+ self .type = type
424
428
425
429
def process_batch (self , data , method , run_id ):
426
430
batches = Query .split_into_batches (data , self .batch_size )
@@ -476,7 +480,7 @@ def process_entity(self):
476
480
self .process_batch (data , method , run_id )
477
481
else :
478
482
self .clean_entity (int (run_id ) + 1 )
479
- self .process_batch (data , method , run_id )
483
+ self .process_batch (data , method , int ( run_id ) + 1 )
480
484
else :
481
485
self .clean_entity (1 )
482
486
self .process_batch (data , method , 1 )
@@ -504,7 +508,5 @@ def get_redis_key(type, origin, to):
504
508
parser .add_argument ("-v" , "--verbose" , action = "count" , default = 0 , help = "Augmente le niveau de verbosité (utilisez -vvv pour plus de détails)." )
505
509
args = parser .parse_args ()
506
510
507
- processor = Processor ()
508
- processor .verbosity_level = args .verbose
509
- processor .type = args .entity_only
511
+ processor = Processor (verbosity_level = args .verbose , type = args .entity_only )
510
512
processor .process_entity ()
0 commit comments