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:
"""
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 =
▲ 'd': 'dies',
▲ 'h': 'hores',
▲ 'w': 'setmanes',
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:▼
▲ 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
▲ 'y': 'years',
▲ 'm': 'months',
▲ '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,
if algo.function != 'done':
self.done = False
return
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(
self.page = ExtendedPage(site, self.title)
Linha 566 ⟶ 563:
body = talks[i + 1]
thread.set(title.strip(), body)
thread.set_done(self.config.algo
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 =
self.header = ''
self.inserting = 0
|