Usuari:ArxivaBot/scripts/cawiki/archivebot cawiki.py: diferència entre les revisions

Contingut suprimit Contingut afegit
mCap resum de modificació
Etiqueta: editor de codi 2017
done no tenia en compte el temps que du exposada la plantilla
Etiqueta: editor de codi 2017
Línia 17:
 
"""
 
 
# TODO: canviar els `'{year}' in` contemplant tots tels casos ja que '{year}' pot ser '{month}', '{monthname}', etc.
 
 
Linha 40 ⟶ 37:
self.patterns = Patterns()
self.month_dict = {}
self.reldelta_keys = {
'y': {'en': 'years', 'ca': 'anys'},
'm': {'en': 'months', 'ca': 'mesos'},
'w': {'en': 'weeks', 'ca': 'setmanes'},
'd': {'en': 'days', 'ca': 'dies'},
'h': {'en': 'hours', 'ca': 'hores'},
'i': {'en': 'minutes', 'ca': 'minuts'},
's': {'en': 'seconds', 'ca': 'segons'}
}
 
def set_month_dict(self):
Linha 85 ⟶ 91:
@property
def summary(self):
period = {utils.reldelta_keys.get(self.unit)['ca']
'd': 'dies',
'y': 'anys',
'h': 'hores',
'm': 'mesos',
'w': 'setmanes',
'i': 'minuts'
}.get(self.unit)
return f'(més antic de {self.value} {period})'
 
Linha 203 ⟶ 202:
'localmonth', 'localweek'
)
self.std_time_items = self.standard_items[1:]
 
def __repr__(self):
Línia 217:
title = title.replace(f'{{{item}}}', '')
return title
 
@property
def has_time_param(self):
return any([item in self.bared_title for item in self.std_time_items])
 
@property
Linha 260 ⟶ 264:
 
def set_title_by_time_params(self, thread: 'Thread'):
if (thread.deprecated or thread.done) and thread.last_signature and self.has_time_param:
has_time_param = any(['{year}' in self.title, '{month}' in self.title])
if (thread.deprecated or thread.done) and thread.last_signature and has_time_param:
self.title = self.title.replace('{year}', f'{thread.last_signature.year}')
self.title = self.title.replace('{month}', f'{thread.last_signature.month:>02}')
Linha 345 ⟶ 348:
if algo.function != 'old' or not self.last_signature:
return None
timedelta = relativedelta(**{keysutils.reldelta_keys[algo.unit]['en']: algo.value})
keys = {
'y': 'years',
'm': 'months',
'w': 'weeks',
'd': 'days',
'h': 'hours',
'i': 'minutes',
's': 'seconds'
}
timedelta = relativedelta(**{keys[algo.unit]: algo.value})
expire = self.last_signature + timedelta
self.deprecated = datetime.now() > expire
 
def set_done(self, functionalgo: Algo):
if algo.function != 'done':
self.done = False
return
self.done = bool(utils.patterns.done.search(self.body))
timedelta = relativedelta(**{utils.reldelta_keys[algo.unit]['en']: algo.value})
expire = self.last_signature + timedelta
self.done = done and datetime.now() > expire
 
def set_source(self, title):
Linha 463 ⟶ 460:
 
def set_page(self):
if not any(f'{item}' in self.title for item in ('year', 'month')self.config.std_time_items):
self.page = ExtendedPage(site, self.title)
 
Linha 566 ⟶ 563:
body = talks[i + 1]
thread.set(title.strip(), body)
thread.set_done(self.config.algo.function)
done += int(thread.done)
thread.set_deprecated(self.config.algo)
Linha 583 ⟶ 580:
def __init__(self, page_site, page_title):
Page.__init__(self, page_site, page_title)
self.debug = Falseglobals().get('debug')
self.header = ''
self.inserting = 0