# coding: utf-8

import pywikibot
from pywikibot import pagegenerators

import datetime
#import argparse
site = pywikibot.Site(fam='commons', code='commons')
site.throttle.setDelays(delay=0, writedelay=10)

cat = pywikibot.Category(site,'Category:Images from Wiki Loves Love 2019')
date = datetime.date(2019, 2, 28)
#result_page = pywikibot.Page(site, 'Commons:Wiki Loves Love 2019/image list/{:02d}'.format(date.day))
gen = pagegenerators.CategorizedPageGenerator(cat)
#wiki_text = ('{{Commons:Wiki Loves Love 2019/image list/header}}\n'
#            '<gallery>\n') 
#wiki_text += ' \n'.join(
pages= [page for page in gen if page.is_filepage() and page.oldest_file_info['timestamp'].date() > date]
    #)
#wiki_text += '\n</gallery>'

#result_page.text = wiki_text
#result_page.save('Creating or updating daily gallery of Wiki Loves Love 2019 files')
for page in pages:
    to_check = pywikibot.Category(site,'Category:Images from Wiki Loves Love 2019 to check')
    after_feb = pywikibot.Category(site,'Category:Images from Wiki Loves Love 2019 uploaded after February')
    if after_feb in page.categories():
        continue
    if pywikibot.Category(site,'Category:Images from Wiki Loves Love 2019 to check') in page.categories():
        page.change_category(to_check, after_feb,
                             summary='Changing category "to check" for "uploaded after February" for Wiki Loves Love')
    else:
        page.text = page.text + '\n[[Category:Images from Wiki Loves Love 2019 uploaded after February]]'
        page.save('Adding category "uploaded after February" for Wiki Loves Love')
Page [[commons:File:Beth and Alex’s wedding in Bayamón, Puerto Rico, 2018.jpg]] saved
Sleeping for 18.7 seconds, 2019-03-07 13:09:07
Page [[commons:File:Birthday Celebrations.jpg]] saved
Sleeping for 18.8 seconds, 2019-03-07 13:09:27
Page [[commons:File:Bloody red.jpg]] saved
Sleeping for 19.0 seconds, 2019-03-07 13:09:47
Page [[commons:File:Candle spotlight.jpg]] saved
Sleeping for 18.8 seconds, 2019-03-07 13:10:07
Page [[commons:File:Cinco De Mayo Celeb.jpg]] saved
Sleeping for 19.0 seconds, 2019-03-07 13:10:27
Page [[commons:File:Cinco De Mayo Celebrations at Japan.jpg]] saved
Sleeping for 9.0 seconds, 2019-03-07 13:10:47
Page [[commons:File:Cinco De Mayo Celebrations.jpg]] saved
Sleeping for 9.0 seconds, 2019-03-07 13:10:57
Page [[commons:File:Cinco De Mayo Feliz.jpg]] saved
Sleeping for 9.0 seconds, 2019-03-07 13:11:07
Page [[commons:File:Cinco de Mayo.jpg]] saved
Sleeping for 9.0 seconds, 2019-03-07 13:11:17
Page [[commons:File:Cinco De Mayo.jpg]] saved
Sleeping for 8.9 seconds, 2019-03-07 13:11:27
Page [[commons:File:CincoDe Mayo Celebrations.jpg]] saved
Sleeping for 9.0 seconds, 2019-03-07 13:11:37
Page [[commons:File:Companions for life!.jpg]] saved
Sleeping for 9.1 seconds, 2019-03-07 13:11:47
Page [[commons:File:Comraderie.jpg]] saved
Sleeping for 9.0 seconds, 2019-03-07 13:11:57
Page [[commons:File:Cutie Dog for True Love .JPG]] saved
Sleeping for 9.0 seconds, 2019-03-07 13:12:07
Page [[commons:File:Cutie Doggie Love.JPG]] saved
Sleeping for 8.6 seconds, 2019-03-07 13:12:18
Page [[commons:File:Evenings and Mornings.jpg]] saved
Sleeping for 8.9 seconds, 2019-03-07 13:12:27
Page [[commons:File:Feliz Cinco De Mayo.jpg]] saved
Sleeping for 8.9 seconds, 2019-03-07 13:12:37
Page [[commons:File:Floral Carpet, Onam.jpg]] saved
Sleeping for 9.0 seconds, 2019-03-07 13:12:47
Page [[commons:File:Friends in celebration.jpg]] saved
Sleeping for 9.0 seconds, 2019-03-07 13:12:57
Page [[commons:File:Fujimi-Inari Taisha.jpg]] saved
Sleeping for 8.9 seconds, 2019-03-07 13:13:07
Page [[commons:File:Grandpa love.jpg]] saved
Sleeping for 8.9 seconds, 2019-03-07 13:13:17
Page [[commons:File:Hanami at Japan.jpg]] saved
Sleeping for 9.0 seconds, 2019-03-07 13:13:27
Page [[commons:File:Heart Shape 2.jpg]] saved
Sleeping for 8.9 seconds, 2019-03-07 13:13:37
Page [[commons:File:Heart Shape 3.jpg]] saved
Sleeping for 9.0 seconds, 2019-03-07 13:13:47
Page [[commons:File:Heart Shape 4.jpg]] saved
Sleeping for 8.9 seconds, 2019-03-07 13:13:58
Page [[commons:File:Heart Shape 5.jpg]] saved
Sleeping for 8.9 seconds, 2019-03-07 13:14:08
Page [[commons:File:Heart Shape 6.jpg]] saved
Sleeping for 8.9 seconds, 2019-03-07 13:14:18
Page [[commons:File:Heart Shape 7.jpg]] saved
Sleeping for 8.9 seconds, 2019-03-07 13:14:28
Page [[commons:File:Heart Shape 8.jpg]] saved
Sleeping for 8.9 seconds, 2019-03-07 13:14:38
Page [[commons:File:Heart shape.jpg]] saved
Sleeping for 9.0 seconds, 2019-03-07 13:14:47
Page [[commons:File:Heart Shape.jpg]] saved
Sleeping for 8.9 seconds, 2019-03-07 13:14:58
Page [[commons:File:His Her.jpg]] saved
Sleeping for 8.9 seconds, 2019-03-07 13:15:08
Page [[commons:File:Indígena Poblano Mirror Effect.jpg]] saved
Sleeping for 8.9 seconds, 2019-03-07 13:15:18
Page [[commons:File:Japanese Couple Dolls.JPG]] saved
Sleeping for 8.9 seconds, 2019-03-07 13:15:28
Page [[commons:File:Japanese Wedding Love Doll with Sunset scene by Trisorn Triboon 01.jpg]] saved
Sleeping for 9.1 seconds, 2019-03-07 13:15:37
Page [[commons:File:Japanese Wedding Love Doll with Sunset scene by Trisorn Triboon 02.jpg]] saved
Sleeping for 8.9 seconds, 2019-03-07 13:15:48
Page [[commons:File:Japanese Wedding Love Doll with Sunset scene by Trisorn Triboon 03.jpg]] saved
Sleeping for 9.0 seconds, 2019-03-07 13:15:58
Page [[commons:File:Japanese Wedding Love Doll with Sunset scene by Trisorn Triboon 04.jpg]] saved
Sleeping for 9.1 seconds, 2019-03-07 13:16:07
Page [[commons:File:Japanese Wedding Love Doll with Sunset scene by Trisorn Triboon 05.jpg]] saved
Sleeping for 9.1 seconds, 2019-03-07 13:16:17
Page [[commons:File:Japanese Wedding Love Doll with Sunset scene by Trisorn Triboon 06.jpg]] saved
Sleeping for 9.0 seconds, 2019-03-07 13:16:28
Page [[commons:File:Japanese wedding Traditional dolls.JPG]] saved
Sleeping for 8.9 seconds, 2019-03-07 13:16:38
Page [[commons:File:Kanya Bhoj.jpg]] saved
Sleeping for 9.0 seconds, 2019-03-07 13:16:48
Page [[commons:File:Kerala Feast Modern Style.jpg]] saved
Sleeping for 9.0 seconds, 2019-03-07 13:16:58
Page [[commons:File:Kerala Traditional Muslim Marriage.jpg]] saved
Sleeping for 8.9 seconds, 2019-03-07 13:17:08
Page [[commons:File:Lead Me.jpg]] saved
Sleeping for 8.8 seconds, 2019-03-07 13:17:18
Page [[commons:File:Liebe-Angie-Herzog 2009.jpg]] saved
Sleeping for 9.0 seconds, 2019-03-07 13:17:28
Page [[commons:File:Little doggie for Love.JPG]] saved
Sleeping for 9.0 seconds, 2019-03-07 13:17:38
Page [[commons:File:Love At First Sight.jpg]] saved
Sleeping for 8.9 seconds, 2019-03-07 13:17:48
Page [[commons:File:Love under stars and on top of gravel.jpg]] saved
Sleeping for 9.0 seconds, 2019-03-07 13:17:58
Page [[commons:File:Love, never old!.jpg]] saved
Sleeping for 8.9 seconds, 2019-03-07 13:18:08
Page [[commons:File:Lovers at park.jpg]] saved
Sleeping for 9.0 seconds, 2019-03-07 13:18:18
Page [[commons:File:Narnala fort trip.jpg]] saved
Sleeping for 9.0 seconds, 2019-03-07 13:18:28
Page [[commons:File:Peace & Love.jpg]] saved
Sleeping for 8.9 seconds, 2019-03-07 13:18:38
Page [[commons:File:Pink Rose for Love.JPG]] saved
Sleeping for 8.6 seconds, 2019-03-07 13:18:48
Page [[commons:File:Pink Roses for Wiki Loves Love 2019-1.JPG]] saved
Sleeping for 9.0 seconds, 2019-03-07 13:18:58
Page [[commons:File:Pink roses for Wiki Loves Love 2019.JPG]] saved
Sleeping for 9.0 seconds, 2019-03-07 13:19:08
Page [[commons:File:Plant a love.jpg]] saved
Sleeping for 8.9 seconds, 2019-03-07 13:19:18
Page [[commons:File:Ready for Matsuri, Japan.jpg]] saved
Sleeping for 8.9 seconds, 2019-03-07 13:19:28
Page [[commons:File:Red Rose for Love .JPG]] saved
Sleeping for 8.9 seconds, 2019-03-07 13:19:38
Page [[commons:File:Santhoshwideangles001.jpg]] saved
Sleeping for 9.0 seconds, 2019-03-07 13:19:48
Page [[commons:File:Santhoshwideangles002.jpg]] saved
Sleeping for 8.9 seconds, 2019-03-07 13:19:58
Page [[commons:File:Santhoshwideangles003.jpg]] saved
Sleeping for 8.9 seconds, 2019-03-07 13:20:08
Page [[commons:File:Selfie through railway over bridge.jpg]] saved
Sleeping for 8.9 seconds, 2019-03-07 13:20:18
Page [[commons:File:Sleeping girl.jpg]] saved
Sleeping for 8.9 seconds, 2019-03-07 13:20:28
Page [[commons:File:Spring Welcoming Tradition, Japan.jpg]] saved
Sleeping for 8.9 seconds, 2019-03-07 13:20:38
Page [[commons:File:Tea Ceremony, Japan.jpg]] saved
Sleeping for 9.0 seconds, 2019-03-07 13:20:48
Page [[commons:File:Thai Doll of Couple for lasting Love.JPG]] saved
Sleeping for 9.0 seconds, 2019-03-07 13:20:58
Page [[commons:File:Times Together.jpg]] saved
Sleeping for 9.0 seconds, 2019-03-07 13:21:08
Page [[commons:File:Togetherness Anywhere.jpg]] saved
Sleeping for 9.0 seconds, 2019-03-07 13:21:18
Page [[commons:File:Two and One.jpg]] saved
Sleeping for 8.9 seconds, 2019-03-07 13:21:28
Page [[commons:File:Valentine Love.jpg]] saved
Sleeping for 8.9 seconds, 2019-03-07 13:21:38
Page [[commons:File:Violind and beloved roses.jpg]] saved
Sleeping for 9.0 seconds, 2019-03-07 13:21:48
Page [[commons:File:VISHU Kani.jpg]] saved
Sleeping for 8.9 seconds, 2019-03-07 13:21:58
Page [[commons:File:Voladores de Palo Papantla.jpg]] saved
Sleeping for 9.0 seconds, 2019-03-07 13:22:08
Page [[commons:File:Wanna be my boyfriend for Wiki Loves Love 2019.JPG]] saved
Sleeping for 9.0 seconds, 2019-03-07 13:22:18
Page [[commons:File:We laugh we Love.JPG]] saved
Sleeping for 9.0 seconds, 2019-03-07 13:22:28
Page [[commons:File:Welcome to the world.jpg]] saved
Sleeping for 8.9 seconds, 2019-03-07 13:22:38
Page [[commons:File:When spring came there were no worries except where to be happiest!".jpg]] saved
Sleeping for 8.6 seconds, 2019-03-07 13:22:48
Page [[commons:File:Wherever you go.jpg]] saved
Sleeping for 8.9 seconds, 2019-03-07 13:22:58
Page [[commons:File:Wiki Loves Love 2019 -th.JPG]] saved
Sleeping for 9.0 seconds, 2019-03-07 13:23:08
Page [[commons:File:Wiki Loves Love 2019 in Thailand.jpg]] saved
Sleeping for 8.9 seconds, 2019-03-07 13:23:18
Page [[commons:File:Wiki Loves Love-thailand 2019.JPG]] saved
Sleeping for 9.0 seconds, 2019-03-07 13:23:28
Page [[commons:File:Wooden couple of Love from Kenya .jpg]] saved