diff --git a/euroexange/euroexange.py b/euroexange/euroexange.py index 27ea313..94bd7f2 100644 --- a/euroexange/euroexange.py +++ b/euroexange/euroexange.py @@ -28,6 +28,16 @@ import pywikibot import jogobot +class EuroExangeBotJob(): + """ + Used for EuroExangeBot job queue + """ + + def __init__( self, **kwargs ): + + self.image = kwargs['image'] + + class EuroExangeBot( pywikibot.bot.BaseBot ): working_dir = os.path.dirname(os.path.realpath(__file__)) + "/../wdir" @@ -35,6 +45,8 @@ class EuroExangeBot( pywikibot.bot.BaseBot ): zip_file = "eurofxref-hist.zip" csv_file = "eurofxref-hist.csv" + jobs = [ EuroExangeBotJob( image="TEST_Euro_exchange_rate_to_TRY_-_Turkish_Currency_and_Debt_Crisis_2018.svg" ) ] + def __init__( self, genFactory, **kwargs ): # Init working directory @@ -47,6 +59,9 @@ class EuroExangeBot( pywikibot.bot.BaseBot ): # Make sure input data is uptodate self.update_data() + for job in type(self).jobs: + self.treat_job(job) + pass def init_wdir(self): @@ -160,6 +175,27 @@ class EuroExangeBot( pywikibot.bot.BaseBot ): os.path.join(self.wdir, type(self).csv_file)), path=self.wdir ) + def treat_job( self, job ): + """ + Handles working on specific jobs + + @param job: Job to work on + @type job: EuroExangeBotJob + """ + + # Log job + jogobot.output( "Work on Job {}".format(job.image) ) + + # Get file page + filepage = pywikibot.page.FilePage(pywikibot.Site(), job.image) + + # Stop if file not jet exists + if not filepage.exists(): + jogobot.output( "Work on Job {}".format(job.image), "ERROR" ) + raise pywikibot.NoPage( filepage ) + + + def main(*args): """