I am not sure of the Russian interest in this website.
These are some funny languages
I am not sure of the Russian interest in this website.
These are some funny languages
I made this chore asigning application for a small college dorm. Its purpose is to randomly assign chores to residents with respect to gender. A male (m) will get a male chore or gender neutral chore (n) and female (f) will get a female chore or gender neutral chore. Note random is not fair. Good Luck
The files needed
gender firstname lastname
m john smith
f julie smith
m tom appleseed
gender chore
f clean womens bathroom
n mop hallway
m clean mens showers
ChoreApp.py
clean.icns - an icon file
pip install virtualenv
virtualenv venv
source venv/bin/activate
pip install xlwt py2app
Please place chore app code in a seperate directory differnet to the python virtual environment.
import os, sys,random, xlwt, time, datetime
from xlwt import *
#file imports
chore_file=open("../../../chores.txt", "r")
chores = chore_file.readlines()
#print chores
resident_file=open("../../../residents.txt", "r")
residents = resident_file.readlines()
#print residents
#create a psueode final enum
# m equals male
# f equals female
# n equals neutral
#creates excel file
book = xlwt.Workbook(encoding="utf-8")
sheet1 = book.add_sheet("Sheet 1")
font0 = Font()
font0.bold = True
style0 = XFStyle()
style0.font = font0
#error check
if len(chores) != len(residents):
print "Error:"
if len(chores) > len(residents):
sys.exit(" Too many chores")
else:
sys.exit(" Too many residents")
assignment = []
i = 0
while(residents):
rand = random.randrange(0, len(residents))
# retrieves the f or m before residents name
resident = residents[rand]
resident_gender = resident[0:1]
chore_gender = chores[i][0:1]
if(resident_gender == chore_gender) or (chore_gender == 'n'):
len_chore = len(chores[i])
len_resident = len(resident)
print resident[2:len_resident] + " " + chores[i][2:len_chore]
tupl = [resident[2:len_resident].replace('\n',''), chores[i][2:len_chore].replace('\n','')]
assignment.append(tupl)
residents.pop(rand)
i=i+1
#alphabetically sort
assignment.sort()
#write out alphabetically sorted chore list
j=1
date = datetime.datetime.now()
enddate = datetime.datetime.now() + datetime.timedelta(days=6)
sheet1.write(0,0,"Chore List For Week Of " + date.strftime('%m/%d') +" - "+ enddate.strftime('%m/%d'), style0)
for i in assignment:
sheet1.write(j,0,i[0])
sheet1.write(j,1,i[1])
sheet1.write(j+1,0,'')
j=j+2
#saves excell file
book.save("../../../chores"+ date.strftime('%Y_%m_%d') + ".xls")
#book.save("chores"+ date.strftime('%Y_%m_%d') + ".xls")
Change the the working direcotry to the chore_app and create a file called setup.py
cd chore_app
vim setup.py
"""
This is a setup.py script generated by py2applet
Usage:
python setup.py py2app
"""
from setuptools import setup
APP = ['ChoreApp.py']
DATA_FILES = ['chores.txt','residents.txt']
OPTIONS = {
'argv_emulation': True,
'iconfile': 'clean.icns',
'plist': {
'CFBundleName': "ChoreApp",
'CFBundleDisplayName': "ChoreApp",
'CFBundleGetInfoString': "App for assigning chore",
'CFBundleVersion': "0.2.0",
'CFBundleShortVersionString': "0.2.0",
'NSHumanReadableCopyright': u"Copyleft Devon Peel"
}
}
setup(
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)
Time to build the App
python setup.py py2app
Place the ChoreApp file created in the above command with the chores.txt file and residents.txt file in the same directory. Then click on the ChoreApp to generate the output file assigning chores to residents.
Install Chocolatey via PowerShell
iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
Install via Command Prompt
@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin
Create a repo
choco new <project name>
Edit the