Skip to content

Commit 8ea56bb

Browse files
committed
fix synchro...
1 parent 19e549d commit 8ea56bb

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

scripts/synchro.py

+12-10
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@
6868
SERVICE wikibase:label {bd:serviceParam wikibase:language "fr".} }'''
6969

7070
class Query(object):
71+
verbosity_level = 0
72+
7173
building_types = [
7274
16970, # église
7375
2977, # cathédrale
@@ -113,13 +115,13 @@ class Query(object):
113115
373074, # suffragan diocese
114116
]
115117
dateformat = '%Y-%m-%d %H:%M:%S'
116-
verbosity_level = 0
117118

118-
def __init__(self):
119+
def __init__(self, verbosity_level):
119120
self.cache_places = {}
120121
self.cache_churches = {}
121122
self.cache_dioceses = {}
122123
self.cache_parishes = {}
124+
self.verbosity_level = verbosity_level
123125

124126
@staticmethod
125127
def decode(string):
@@ -414,13 +416,15 @@ def populate_fields(self, values, wikidata_id):
414416
return fields
415417

416418
class Processor(object):
419+
batch_size = 100
417420
client = OpenChurchClient()
418-
q = Query()
419421
redis_url = os.getenv('REDIS_URL')
420422
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
424428

425429
def process_batch(self, data, method, run_id):
426430
batches = Query.split_into_batches(data, self.batch_size)
@@ -476,7 +480,7 @@ def process_entity(self):
476480
self.process_batch(data, method, run_id)
477481
else:
478482
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)
480484
else:
481485
self.clean_entity(1)
482486
self.process_batch(data, method, 1)
@@ -504,7 +508,5 @@ def get_redis_key(type, origin, to):
504508
parser.add_argument("-v", "--verbose", action="count", default=0, help="Augmente le niveau de verbosité (utilisez -vvv pour plus de détails).")
505509
args = parser.parse_args()
506510

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)
510512
processor.process_entity()

0 commit comments

Comments
 (0)