Xqt added a comment.

  Why not in such way:
  
    def my_upload_function():
        def collector(old, new):
            replacements[old] = new
    
        replacements = {}
        bot = UploadRobot(['A.jpg', 'b.jpg'])
        bot.post_processor = collector
        bot.run()
    
        return replacements
  
  or
  
    def my_upload_function():
        def collector(old, new):
            replacements.append((old, new))
    
        replacements = []
        bot = UploadRobot(['A.jpg', 'b.jpg'])
        bot.post_processor = collector
        bot.run()
    
        return replacements
  
  Or process the filename directly instead of returning the last value (note: 
your example gets only the last filename but UploadRobot is able to upload 
multiple files):
  
    def my_upload_function()
    ...
    
    def main()
        filename = my_upload_funtion()
        print(filename)
  
  you can delegate the statements dealing with the filename into the 
post_processing function:
  
    def collector(old, new):
        print(new)
    
    def my_upload_function()
    ...
    
    def main()
        my_upload_funtion()
  
  I do not know your special needance of your uploader function. Maybe you 
could share the code to clarify.

TASK DETAIL
  https://phabricator.wikimedia.org/T360837

EMAIL PREFERENCES
  https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: Xqt
Cc: Xqt, Aklapper, pywikibot-bugs-list, Ninovolador, mevo, Isabelladantes1983, 
Themindcoder, Adamm71, Jersione, Hellket777, LisafBia6531, 786, Biggs657, 
PotsdamLamb, Jyoo1011, JohnsonLee01, Juan90264, SHEKH, Dijkstra, Alter-paule, 
Beast1978, Un1tY, Khutuck, Zkhalido, Hook696, Kent7301, joker88john, Viztor, 
CucyNoiD, Wenyi, Gaboe420, Giuliamocci, Cpaulf30, Af420, Bsandipan, Tbscho, 
MayS, Lewizho99, Mdupont, JJMC89, Maathavan, Dvorapa, Altostratus, Neuronton, 
Avicennasis, mys_721tx, jayvdb, Masti, Alchimista
_______________________________________________
pywikibot-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to