In [30]:
#Dict is
#item product in dict. 'product' : 'internet'
#'count' : salesnum
#'tags' : tags to add
#Discount. add senior and under 18 prices.
#Read arcive folders
#When an item is sold it is saved in archive folder
#There is also a temp folder it is saved to - this is
#used for customer recepits.
#select from archive folder the sales items you want
#to display on customer.
In [31]:
import os
import dominate
from dominate.tags import *
import getpass
import json
In [32]:
usrnam = getpass.getuser()
In [33]:
usrnam
Out[33]:
In [34]:
rarch = os.listdir('/home/wcmckee/sellcoffee/archive/')
In [35]:
rarch
Out[35]:
In [36]:
nevdict = dict()
In [37]:
#nevdict.update({
In [39]:
#json.loads(rejd)
In [40]:
for rac in rarch:
rejs = open('/home/wcmckee/sellcoffee/archive/' + rac, 'r')
#print rac
recd = rejs.read()
jrecd = json.loads(recd)
print jrecd['product']
print jrecd['amount']
print jrecd['date']
print jrecd['time']
rejs.close()
In [19]:
jrecd.keys()
Out[19]:
In [20]:
jrecd.values()
Out[20]:
In [27]:
doc = dominate.document(title='Sales Archive')
with doc.head:
link(rel='stylesheet', href='style.css')
script(type ='text/javascript', src='script.js')
#str(str2)
with div():
attr(cls='header')
h1('Sales Archive')
p(img('/imgs/getsdrawn-bw.png', src='/imgs/getsdrawn-bw.png'))
#p(img('imgs/15/01/02/ReptileLover82-reference.png', src= 'imgs/15/01/02/ReptileLover82-reference.png'))
#h1('Date ', str(artes.datetime))
#p(panz)
#p(bodycom)
with doc:
with div(id='body').add(ol()):
for rac in rarch:
rejs = open('/home/wcmckee/sellcoffee/archive/' + rac, 'r')
#print rac
recd = rejs.read()
jrecd = json.loads(recd)
p(jrecd['product'])
p(jrecd['amount'])
p(jrecd['date'])
p(jrecd['time'])
rejs.close()
#for flc in fulcom:
#p(h1(flc.title))
#p(img(imlocdir, src= imlocdir))
#p(img(flc.url, src = flc.url))
#p(str(flc.author))
#res = requests.get(flc.url, stream=True)
#with open(str(flc.author) + '-' + str(artes.date()) + '-reference.png', 'wb') as outfil:
# shutil.copyfileobj(res.raw, outfil)
# del res
#for flcz in flc.comments:
#p(flcz.body)
#for rdz in reliz:
#h1(rdz.title)
#a(rdz.url)
#p(img(rdz, src='%s' % rdz))
#print rdz
#p(img(rdz, src = rdz))
#p(rdz)
#print rdz.url
#if '.jpg' in rdz.url:
# img(rdz.urlz)
#else:
# a(rdz.urlz)
#h1(str(rdz.author))
#li(img(i.lower(), src='%s' % i))
with div():
attr(cls='body')
p('lcacoffee is open source')
#a('https://github.com/wcmckee/lcacoffee')
a('https://reddit.com/r/redditgetsdrawn')
#print doc
In [29]:
docre = doc.render()
#s = docre.decode('ascii', 'ignore')
yourstring = docre.encode('ascii', 'ignore').decode('ascii')
indfil = ('/home/' + usrnam + '/sellcoffee/index.html')
mkind = open(indfil, 'w')
mkind.write(yourstring)
mkind.close()
In [ ]: