mscroggs / KLBFAX

KLBFAX
http://www.klbfax.co.uk
MIT License
6 stars 1 forks source link

abstract point counting away into a separate class? #7

Closed afiodorov closed 9 years ago

afiodorov commented 9 years ago

Hi Scroggsy. I just heard the beeping noise and I checked out the KLB fax. Twitting about points is wonderful!

But wouldn't it make sense to move point counting to a separate class instead of having the following lines everywhere:

def generate_content(self):
    import json
    with open('/home/pi/.klb/points') as f:
        data = json.load(f)
    house = "Slytherin"
    if house in data:
        data[house]+=2
    else:
        data[house]=2

    with open('/home/pi/.klb/points','w') as f:
        json.dump(data,f)
    from twitter import update_status
    update_status(status="2 points to Slytherin!")

?

mscroggs commented 9 years ago

Yep, was thinking of making this class