Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9a24a988f4 | |||
| 7bb77e86f6 | |||
| 297adc62ec | |||
| b6c7a74519 | |||
| 81e541ef1d |
@@ -94,6 +94,14 @@ class ChartsBot( ):
|
|||||||
# Set locale to 'de_DE.UTF-8'
|
# Set locale to 'de_DE.UTF-8'
|
||||||
locale.setlocale(locale.LC_ALL, 'de_DE.UTF-8')
|
locale.setlocale(locale.LC_ALL, 'de_DE.UTF-8')
|
||||||
|
|
||||||
|
# provisional-onwiki-activation
|
||||||
|
page_active = pywikibot.Page( self.site, "Benutzer:JogoBot/active" )
|
||||||
|
text_active = page_active.get()
|
||||||
|
|
||||||
|
if "true" not in text_active.lower():
|
||||||
|
pywikibot.output( "Bot ist deaktiviert!" )
|
||||||
|
return False
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
"""Process each page from the generator."""
|
"""Process each page from the generator."""
|
||||||
for page in self.generator:
|
for page in self.generator:
|
||||||
@@ -215,6 +223,7 @@ def main(*args):
|
|||||||
# pages from the wiki simultaneously.
|
# pages from the wiki simultaneously.
|
||||||
gen = pagegenerators.PreloadingGenerator(gen)
|
gen = pagegenerators.PreloadingGenerator(gen)
|
||||||
bot = ChartsBot(gen, always, force_reload)
|
bot = ChartsBot(gen, always, force_reload)
|
||||||
|
if bot:
|
||||||
bot.run()
|
bot.run()
|
||||||
else:
|
else:
|
||||||
pywikibot.showHelp()
|
pywikibot.showHelp()
|
||||||
|
|||||||
@@ -66,7 +66,8 @@ class CountryList():
|
|||||||
|
|
||||||
# Check if page exits
|
# Check if page exits
|
||||||
if not self.page.exists():
|
if not self.page.exists():
|
||||||
return False
|
raise CountryListError( "CountryList " +
|
||||||
|
str(wikilink.title) + " does not exists!" )
|
||||||
|
|
||||||
# Initialise attributes
|
# Initialise attributes
|
||||||
__attr = ( "wikicode", "entry", "chartein", "_chartein_raw",
|
__attr = ( "wikicode", "entry", "chartein", "_chartein_raw",
|
||||||
@@ -156,11 +157,18 @@ class CountryList():
|
|||||||
# For belgian list we need to select subsection of country
|
# For belgian list we need to select subsection of country
|
||||||
belgian = self.detect_belgian()
|
belgian = self.detect_belgian()
|
||||||
|
|
||||||
|
# Select Singles-Section
|
||||||
|
# Catch Error if we have none
|
||||||
|
try:
|
||||||
if belgian:
|
if belgian:
|
||||||
singles_section = self.wikicode.get_sections(
|
singles_section = self.wikicode.get_sections(
|
||||||
matches=belgian )[0].get_sections( matches="Singles" )[0]
|
matches=belgian )[0].get_sections( matches="Singles" )[0]
|
||||||
else:
|
else:
|
||||||
singles_section = self.wikicode.get_sections(matches="Singles")[0]
|
singles_section = self.wikicode.get_sections(
|
||||||
|
matches="Singles" )[0]
|
||||||
|
|
||||||
|
except IndexError:
|
||||||
|
raise CountryListError( "No Singles-Section found!")
|
||||||
|
|
||||||
# Since we have multiple categories in some countrys we need
|
# Since we have multiple categories in some countrys we need
|
||||||
# to select the first wrapping template
|
# to select the first wrapping template
|
||||||
@@ -230,7 +238,15 @@ class CountryList():
|
|||||||
If param is not present raise Error
|
If param is not present raise Error
|
||||||
"""
|
"""
|
||||||
if self.entry.has( "Chartein" ):
|
if self.entry.has( "Chartein" ):
|
||||||
self._chartein_raw = self.entry.get("Chartein").value.strip()
|
self._chartein_raw = self.entry.get("Chartein").value
|
||||||
|
|
||||||
|
# Remove possible ref-tags
|
||||||
|
for ref in self._chartein_raw.ifilter_tags(matches="ref"):
|
||||||
|
self._chartein_raw.remove( ref )
|
||||||
|
|
||||||
|
# Remove whitespace
|
||||||
|
self._chartein_raw = str(self._chartein_raw).strip()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise CountryListEntryError( "Template Parameter 'Chartein' is \
|
raise CountryListEntryError( "Template Parameter 'Chartein' is \
|
||||||
missing!" )
|
missing!" )
|
||||||
@@ -256,7 +272,14 @@ missing!" )
|
|||||||
If param is not present raise Error
|
If param is not present raise Error
|
||||||
"""
|
"""
|
||||||
if self.entry.has( "Titel" ):
|
if self.entry.has( "Titel" ):
|
||||||
self._titel_raw = self.entry.get("Titel").value.strip()
|
self._titel_raw = self.entry.get("Titel").value
|
||||||
|
|
||||||
|
# Remove possible ref-tags
|
||||||
|
for ref in self._titel_raw.ifilter_tags(matches="ref"):
|
||||||
|
self._titel_raw.remove( ref )
|
||||||
|
|
||||||
|
# Remove whitespace
|
||||||
|
self._titel_raw = str(self._titel_raw).strip()
|
||||||
else:
|
else:
|
||||||
raise CountryListEntryError( "Template Parameter 'Titel' is \
|
raise CountryListEntryError( "Template Parameter 'Titel' is \
|
||||||
missing!" )
|
missing!" )
|
||||||
@@ -321,7 +344,14 @@ missing!" )
|
|||||||
If param is not present raise Error
|
If param is not present raise Error
|
||||||
"""
|
"""
|
||||||
if self.entry.has( "Interpret" ):
|
if self.entry.has( "Interpret" ):
|
||||||
self._interpret_raw = self.entry.get("Interpret").value.strip()
|
self._interpret_raw = self.entry.get("Interpret").value
|
||||||
|
|
||||||
|
# Remove possible ref-tags
|
||||||
|
for ref in self._interpret_raw.ifilter_tags(matches="ref"):
|
||||||
|
self._interpret_raw.remove( ref )
|
||||||
|
|
||||||
|
# Remove whitespace
|
||||||
|
self._interpret_raw = str(self._interpret_raw).strip()
|
||||||
else:
|
else:
|
||||||
raise CountryListEntryError( "Template Parameter 'Interpret' is \
|
raise CountryListEntryError( "Template Parameter 'Interpret' is \
|
||||||
missing!" )
|
missing!" )
|
||||||
|
|||||||
@@ -143,11 +143,8 @@ class SummaryPageEntry():
|
|||||||
# Get current year
|
# Get current year
|
||||||
current_year = datetime.now().year
|
current_year = datetime.now().year
|
||||||
|
|
||||||
# Store old link.title
|
|
||||||
link_title = self.countrylist_wikilink.title
|
|
||||||
|
|
||||||
# If list is from last year, replace year
|
# If list is from last year, replace year
|
||||||
if (current_year - 1) in link_title:
|
if (current_year - 1) in self.countrylist_wikilink.title:
|
||||||
self.countrylist_wikilink.title.replace( (current_year - 1),
|
self.countrylist_wikilink.title.replace( (current_year - 1),
|
||||||
current_year )
|
current_year )
|
||||||
|
|
||||||
@@ -160,7 +157,11 @@ class SummaryPageEntry():
|
|||||||
# Maybe fallback to last years list
|
# Maybe fallback to last years list
|
||||||
except CountryListError:
|
except CountryListError:
|
||||||
|
|
||||||
self.countrylist_wikilink.title = link_title
|
# If list is from last year, replace year
|
||||||
|
if (current_year ) in self.countrylist_wikilink.title:
|
||||||
|
self.countrylist_wikilink.title.replace( current_year,
|
||||||
|
(current_year - 1) )
|
||||||
|
|
||||||
self.countrylist = CountryList( self.countrylist_wikilink )
|
self.countrylist = CountryList( self.countrylist_wikilink )
|
||||||
|
|
||||||
self.maybe_parse_countrylist()
|
self.maybe_parse_countrylist()
|
||||||
|
|||||||
Reference in New Issue
Block a user