bbknikola

BroBeurKids Nikola

This script deals with creating data for BroBeurKids/wcmckee Nikola site.

The directory to look at is brobeurkidsdotcom/posts or folder

wcmckee.com /posts

/github folders are scanned with the input for folders. It's basically a search for notebook, then turn notebook into a blog posts.

Arrow is used to generate the date (YR/MONTH/DAY), and time(HR : MIN: SEC)

This is where ipynb files are kept.

This script generates the .meta files needed.

The meta file is called the same as the ipynb. It also contains the slug and title, and date. The date is collected by looking at the save date of the ipynb.

In [1]:
import os
import getpass
from walkdir import filtered_walk, dir_paths, all_paths, file_paths
import arrow
import nikola
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-96b2a19b16ef> in <module>()
      1 import os
      2 import getpass
----> 3 from walkdir import filtered_walk, dir_paths, all_paths, file_paths
      4 import arrow
      5 import nikola

ImportError: No module named 'walkdir'
In [2]:
raw = arrow.utcnow()
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-2-0238ea21b791> in <module>()
----> 1 raw = arrow.utcnow()

NameError: name 'arrow' is not defined
In [35]:
print raw
2015-02-19T02:30:06.851557+00:00
In [45]:
def returntime():
    return raw.strftime('%H:%M:%S')
In [47]:
returntime()
Out[47]:
'02:30:06'
In [36]:
yraw = raw.strftime("%Y")
mntaw = raw.strftime("%m")
dytaw = raw.strftime("%d")
#gmtz.strftime("%Y")
In [37]:
fulda = yraw + '/' + mntaw + '/' + dytaw
In [48]:
fultim = fulda + ' ' + returntime()
In [49]:
#fultim
Out[49]:
'2015/02/19 02:30:06'
In [9]:
#gtur = getpass.getuser()
In [10]:
#lisbbkn = os.listdir('/home/' + gtur + '/brobeurkidsdotcom/posts')
In [12]:
#lisbbkn
Out[12]:
['.ipynb_checkpoints',
 'when-you-have-then-you-can.ipynb',
 'when-you-have-then-you-can.py',
 'Untitled.txt']
In [14]:
#for lisb in lisbbkn:
#    if '.ipynb' in lisb:
#        print lisb  
.ipynb_checkpoints
when-you-have-then-you-can.ipynb
In [1]:
#Name of notebook you want to turn into a blog
In [65]:
nbog = raw_input('Name of notebook to blog: ')
Name of notebook to blog: pgguserdel
In [66]:
#Search for blog through folders. 
In [67]:
files = file_paths(filtered_walk('/home/wcmckee/github/', depth=100, included_files=[nbog + '.ipynb']))
In [68]:
#print files
<generator object file_paths at 0xb22d03c8>
In [69]:
opblog = ('/home/wcmckee/github/')
In [74]:
podir = ('/home/wcmckee/github/wcmckee.com/posts/')
In [75]:
podir
Out[75]:
'/home/wcmckee/github/wcmckee.com/posts/'
In [70]:
for fie in files:
    #print fie
    print fie
    os.system('cp ' + fie + ' ' + podir)
/home/wcmckee/github/wcmckee.com/posts/pgguserdel.ipynb
/home/wcmckee/github/signinlca/pgguserdel.ipynb
In [71]:
opeza = open(podir + nbog + '.meta', 'w')
opeza.write(nbog + '\n' + nbog + '\n' + fultim)
opeza.close()
In [ ]:
 
In [ ]:
os.chdir('/home/wcmckee/github/wcmckee.com/')
os.system('nikola build')

Comments

Comments powered by Disqus