wcm Nikola Tags

convert ipynb/py doc imports as tags for nikola blog .meta files.

When user searches for notebook to blog with bbknikola python script also get the tags for the .meta file. Open up the .py file and convert this:

blogpost.py

import requests import os import re

Into:

blogpost.meta

blogpost blogpost 2015/02/31 00:00:00 requests, os, re

Categorie can be the name of the repo. Need a repo for Nikola scripts


In [26]:
import modulefinder
import runpy
import os
from walkdir import filtered_walk, dir_paths, all_paths, file_paths

In [22]:
mwcm = modulefinder.ModuleFinder()

In [23]:
mwcm.any_missing()


Out[23]:
[]

In [24]:
mwcm.run_script('/home/wcmckee/github/niketa/rgdsnatch.py')

In [35]:
mwcm.path


Out[35]:
['',
 '/home/wcmckee/ipython',
 '/usr/lib/python2.7',
 '/usr/lib/python2.7/plat-arm-linux-gnueabihf',
 '/usr/lib/python2.7/lib-tk',
 '/usr/lib/python2.7/lib-old',
 '/usr/lib/python2.7/lib-dynload',
 '/home/wcmckee/.local/lib/python2.7/site-packages',
 '/usr/local/lib/python2.7/dist-packages',
 '/usr/lib/python2.7/dist-packages',
 '/usr/lib/python2.7/dist-packages/PILcompat',
 '/usr/lib/python2.7/dist-packages/gtk-2.0',
 '/usr/lib/pymodules/python2.7',
 '/home/wcmckee/ipython/IPython/extensions']

In [39]:
mwcm.scan_code


Out[39]:
<bound method ModuleFinder.scan_code of <modulefinder.ModuleFinder instance at 0xb2304c38>>

In [10]:
from splinter import Browser
browser = Browser()

In [11]:
browser.visit('http://google.com')

In [12]:
browser.title


Out[12]:
u'Google'

In [9]:
browser.request_url


Out[9]:
'http://google.com'

In [15]:
#browser.click_link_by_href('http://www.google.co.nz/preferences')


---------------------------------------------------------------------------
error                                     Traceback (most recent call last)
<ipython-input-15-70fb754855d2> in <module>()
----> 1 browser.click_link_by_href('http://www.google.co.nz/preferences')

/usr/local/lib/python2.7/dist-packages/splinter/driver/__init__.pyc in click_link_by_href(self, href)
    300         Clicks in a link by its ``href`` attribute.
    301         """
--> 302         return self.find_link_by_href(href).first.click()
    303 
    304     def click_link_by_partial_href(self, partial_href):

/usr/local/lib/python2.7/dist-packages/splinter/driver/webdriver/__init__.pyc in find_link_by_href(self, href)
    327 
    328     def find_link_by_href(self, href):
--> 329         return self.find_by_xpath('//a[@href="%s"]' % href, original_find="link by href", original_query=href)
    330 
    331     def find_link_by_partial_href(self, partial_href):

/usr/local/lib/python2.7/dist-packages/splinter/driver/webdriver/__init__.pyc in find_by_xpath(self, xpath, original_find, original_query)
    364         original_find = original_find or "xpath"
    365         original_query = original_query or xpath
--> 366         return self.find_by(self.driver.find_elements_by_xpath, xpath, original_find=original_find, original_query=original_query)
    367 
    368     def find_by_name(self, name):

/usr/local/lib/python2.7/dist-packages/splinter/driver/webdriver/__init__.pyc in find_by(self, finder, selector, original_find, original_query)
    348         while time.time() < end_time:
    349             try:
--> 350                 elements = finder(selector)
    351                 if not isinstance(elements, list):
    352                     elements = [elements]

/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.pyc in find_elements_by_xpath(self, xpath)
    240             driver.find_elements_by_xpath("//div[contains(@class, 'foo')]")
    241         """
--> 242         return self.find_elements(by=By.XPATH, value=xpath)
    243 
    244     def find_element_by_link_text(self, link_text):

/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.pyc in find_elements(self, by, value)
    675 
    676         return self.execute(Command.FIND_ELEMENTS,
--> 677                              {'using': by, 'value': value})['value']
    678     @property
    679     def desired_capabilities(self):

/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.pyc in execute(self, driver_command, params)
    169 
    170         params = self._wrap_value(params)
--> 171         response = self.command_executor.execute(driver_command, params)
    172         if response:
    173             self.error_handler.check_response(response)

/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/remote_connection.pyc in execute(self, command, params)
    347         path = string.Template(command_info[1]).substitute(params)
    348         url = '%s%s' % (self._url, path)
--> 349         return self._request(command_info[0], url, body=data)
    350 
    351     def _request(self, method, url, body=None):

/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/remote_connection.pyc in _request(self, method, url, body)
    377                 body = None
    378             try:
--> 379                 self._conn.request(method, parsed_url.path, body, headers)
    380                 resp = self._conn.getresponse()
    381             except httplib.HTTPException:

/usr/lib/python2.7/httplib.pyc in request(self, method, url, body, headers)
    999     def request(self, method, url, body=None, headers={}):
   1000         """Send a complete request to the server."""
-> 1001         self._send_request(method, url, body, headers)
   1002 
   1003     def _set_content_length(self, body):

/usr/lib/python2.7/httplib.pyc in _send_request(self, method, url, body, headers)
   1033         for hdr, value in headers.iteritems():
   1034             self.putheader(hdr, value)
-> 1035         self.endheaders(body)
   1036 
   1037     def getresponse(self, buffering=False):

/usr/lib/python2.7/httplib.pyc in endheaders(self, message_body)
    995         else:
    996             raise CannotSendHeader()
--> 997         self._send_output(message_body)
    998 
    999     def request(self, method, url, body=None, headers={}):

/usr/lib/python2.7/httplib.pyc in _send_output(self, message_body)
    848             msg += message_body
    849             message_body = None
--> 850         self.send(msg)
    851         if message_body is not None:
    852             #message_body was not a string (i.e. it is a file) and

/usr/lib/python2.7/httplib.pyc in send(self, data)
    810         if self.sock is None:
    811             if self.auto_open:
--> 812                 self.connect()
    813             else:
    814                 raise NotConnected()

/usr/lib/python2.7/httplib.pyc in connect(self)
    791         """Connect to the host and port specified in __init__."""
    792         self.sock = self._create_connection((self.host,self.port),
--> 793                                            self.timeout, self.source_address)
    794 
    795         if self._tunnel_host:

/usr/lib/python2.7/socket.pyc in create_connection(address, timeout, source_address)
    569 
    570     if err is not None:
--> 571         raise err
    572     else:
    573         raise error("getaddrinfo returns an empty list")

error: [Errno 111] Connection refused

In [1]:
import time

In [19]:
#Code for open up web browser on library system and 
#acceot their t&c.
#Need to get web address to go to, and button find_by_name 
#to click.

from splinter import Browser

with Browser() as browser:
    # Visit URL
    url = "http://www.google.com"
    browser.visit(url)
    browser.fill('q', 'artcontrol')
    # Find and click the 'search' button
    button = browser.find_by_name('btnG')
    # Interact with elements
    button.click()
    time.sleep(5)
    if browser.is_text_present('artcontrol.me'):
        print "Yes, the official website was found!"
    else:
        print "No, it wasn't found... We need to improve our SEO techniques"


Yes, the official website was found!

In [ ]:


In [27]:
mwcm.report()


  Name                      File
  ----                      ----
m ConfigParser              /usr/lib/python2.7/ConfigParser.py
m Cookie                    /usr/lib/python2.7/Cookie.py
P OpenSSL                   /usr/lib/python2.7/dist-packages/OpenSSL/__init__.py
m OpenSSL.SSL               /usr/lib/python2.7/dist-packages/OpenSSL/SSL.py
m OpenSSL._util             /usr/lib/python2.7/dist-packages/OpenSSL/_util.py
m OpenSSL.crypto            /usr/lib/python2.7/dist-packages/OpenSSL/crypto.py
m OpenSSL.rand              /usr/lib/python2.7/dist-packages/OpenSSL/rand.py
m OpenSSL.version           /usr/lib/python2.7/dist-packages/OpenSSL/version.py
m Queue                     /usr/lib/python2.7/Queue.py
m StringIO                  /usr/lib/python2.7/StringIO.py
m UserDict                  /usr/lib/python2.7/UserDict.py
m _LWPCookieJar             /usr/lib/python2.7/_LWPCookieJar.py
m _MozillaCookieJar         /usr/lib/python2.7/_MozillaCookieJar.py
m __builtin__               
m __future__                /usr/lib/python2.7/__future__.py
m __main__                  /home/wcmckee/github/niketa/rgdsnatch.py
m _abcoll                   /usr/lib/python2.7/_abcoll.py
m _bisect                   
m _cffi_backend             /usr/lib/python2.7/dist-packages/_cffi_backend.arm-linux-gnueabihf.so
m _codecs                   
m _collections              
m _ctypes                   /usr/lib/python2.7/lib-dynload/_ctypes.arm-linux-gnueabihf.so
m _functools                
m _hashlib                  /usr/lib/python2.7/lib-dynload/_hashlib.arm-linux-gnueabihf.so
m _heapq                    
m _io                       
m _json                     /usr/lib/python2.7/lib-dynload/_json.arm-linux-gnueabihf.so
m _locale                   
m _md5                      
m _osx_support              /usr/lib/python2.7/_osx_support.py
m _random                   
m _sha                      
m _sha256                   
m _sha512                   
m _socket                   
m _sre                      
m _ssl                      /usr/lib/python2.7/lib-dynload/_ssl.arm-linux-gnueabihf.so
m _struct                   
m _sysconfigdata            /usr/lib/python2.7/_sysconfigdata.py
m _sysconfigdata_nd         /usr/lib/python2.7/plat-arm-linux-gnueabihf/_sysconfigdata_nd.py
m _threading_local          /usr/lib/python2.7/_threading_local.py
m _warnings                 
m _weakref                  
m _weakrefset               /usr/lib/python2.7/_weakrefset.py
m abc                       /usr/lib/python2.7/abc.py
m array                     
m atexit                    /usr/lib/python2.7/atexit.py
P backports                 /home/wcmckee/.local/lib/python2.7/site-packages/backports/__init__.py
P backports.ssl_match_hostname /home/wcmckee/.local/lib/python2.7/site-packages/backports/ssl_match_hostname/__init__.py
m base64                    /usr/lib/python2.7/base64.py
m bdb                       /usr/lib/python2.7/bdb.py
m binascii                  
m bisect                    /usr/lib/python2.7/bisect.py
m bz2                       /usr/lib/python2.7/lib-dynload/bz2.arm-linux-gnueabihf.so
m cPickle                   
m cStringIO                 
m calendar                  /usr/lib/python2.7/calendar.py
P certifi                   /home/wcmckee/.local/lib/python2.7/site-packages/certifi/__init__.py
m certifi.core              /home/wcmckee/.local/lib/python2.7/site-packages/certifi/core.py
P cffi                      /usr/lib/python2.7/dist-packages/cffi/__init__.py
m cffi.api                  /usr/lib/python2.7/dist-packages/cffi/api.py
m cffi.commontypes          /usr/lib/python2.7/dist-packages/cffi/commontypes.py
m cffi.cparser              /usr/lib/python2.7/dist-packages/cffi/cparser.py
m cffi.ffiplatform          /usr/lib/python2.7/dist-packages/cffi/ffiplatform.py
m cffi.gc_weakref           /usr/lib/python2.7/dist-packages/cffi/gc_weakref.py
m cffi.lock                 /usr/lib/python2.7/dist-packages/cffi/lock.py
m cffi.model                /usr/lib/python2.7/dist-packages/cffi/model.py
m cffi.vengine_cpy          /usr/lib/python2.7/dist-packages/cffi/vengine_cpy.py
m cffi.vengine_gen          /usr/lib/python2.7/dist-packages/cffi/vengine_gen.py
m cffi.verifier             /usr/lib/python2.7/dist-packages/cffi/verifier.py
m cgi                       /usr/lib/python2.7/cgi.py
m cmd                       /usr/lib/python2.7/cmd.py
m codecs                    /usr/lib/python2.7/codecs.py
m collections               /usr/lib/python2.7/collections.py
m configparser              /usr/lib/python2.7/dist-packages/configparser.py
m configparser_helpers      /usr/lib/python2.7/dist-packages/configparser_helpers.py
m contextlib                /usr/lib/python2.7/contextlib.py
m cookielib                 /usr/lib/python2.7/cookielib.py
m copy                      /usr/lib/python2.7/copy.py
m copy_reg                  /usr/lib/python2.7/copy_reg.py
P cryptography              /usr/lib/python2.7/dist-packages/cryptography/__init__.py
m cryptography.__about__    /usr/lib/python2.7/dist-packages/cryptography/__about__.py
P cryptography.hazmat       /usr/lib/python2.7/dist-packages/cryptography/hazmat/__init__.py
P cryptography.hazmat.bindings /usr/lib/python2.7/dist-packages/cryptography/hazmat/bindings/__init__.py
P cryptography.hazmat.bindings.openssl /usr/lib/python2.7/dist-packages/cryptography/hazmat/bindings/openssl/__init__.py
m cryptography.hazmat.bindings.openssl.binding /usr/lib/python2.7/dist-packages/cryptography/hazmat/bindings/openssl/binding.py
m cryptography.hazmat.bindings.utils /usr/lib/python2.7/dist-packages/cryptography/hazmat/bindings/utils.py
P ctypes                    /usr/lib/python2.7/ctypes/__init__.py
m ctypes._endian            /usr/lib/python2.7/ctypes/_endian.py
m ctypes.util               /usr/lib/python2.7/ctypes/util.py
m datetime                  
m decimal                   /usr/lib/python2.7/decimal.py
m difflib                   /usr/lib/python2.7/difflib.py
m dis                       /usr/lib/python2.7/dis.py
P distutils                 /usr/lib/python2.7/distutils/__init__.py
m distutils.archive_util    /usr/lib/python2.7/distutils/archive_util.py
m distutils.cmd             /usr/lib/python2.7/distutils/cmd.py
P distutils.command         /usr/lib/python2.7/distutils/command/__init__.py
m distutils.config          /usr/lib/python2.7/distutils/config.py
m distutils.core            /usr/lib/python2.7/distutils/core.py
m distutils.debug           /usr/lib/python2.7/distutils/debug.py
m distutils.dep_util        /usr/lib/python2.7/distutils/dep_util.py
m distutils.dir_util        /usr/lib/python2.7/distutils/dir_util.py
m distutils.dist            /usr/lib/python2.7/distutils/dist.py
m distutils.errors          /usr/lib/python2.7/distutils/errors.py
m distutils.extension       /usr/lib/python2.7/distutils/extension.py
m distutils.fancy_getopt    /usr/lib/python2.7/distutils/fancy_getopt.py
m distutils.file_util       /usr/lib/python2.7/distutils/file_util.py
m distutils.log             /usr/lib/python2.7/distutils/log.py
m distutils.spawn           /usr/lib/python2.7/distutils/spawn.py
m distutils.sysconfig       /usr/lib/python2.7/distutils/sysconfig.py
m distutils.text_file       /usr/lib/python2.7/distutils/text_file.py
m distutils.util            /usr/lib/python2.7/distutils/util.py
m distutils.version         /usr/lib/python2.7/distutils/version.py
m distutils.versionpredicate /usr/lib/python2.7/distutils/versionpredicate.py
m doctest                   /usr/lib/python2.7/doctest.py
m dummy_thread              /usr/lib/python2.7/dummy_thread.py
m dummy_threading           /usr/lib/python2.7/dummy_threading.py
P email                     /usr/lib/python2.7/email/__init__.py
m email._parseaddr          /usr/lib/python2.7/email/_parseaddr.py
m email.base64mime          /usr/lib/python2.7/email/base64mime.py
m email.charset             /usr/lib/python2.7/email/charset.py
m email.encoders            /usr/lib/python2.7/email/encoders.py
m email.errors              /usr/lib/python2.7/email/errors.py
m email.feedparser          /usr/lib/python2.7/email/feedparser.py
m email.generator           /usr/lib/python2.7/email/generator.py
m email.header              /usr/lib/python2.7/email/header.py
m email.iterators           /usr/lib/python2.7/email/iterators.py
m email.message             /usr/lib/python2.7/email/message.py
P email.mime                /usr/lib/python2.7/email/mime/__init__.py
m email.parser              /usr/lib/python2.7/email/parser.py
m email.quoprimime          /usr/lib/python2.7/email/quoprimime.py
m email.utils               /usr/lib/python2.7/email/utils.py
P encodings                 /usr/lib/python2.7/encodings/__init__.py
m encodings.aliases         /usr/lib/python2.7/encodings/aliases.py
m errno                     
m exceptions                
m fcntl                     
m fnmatch                   /usr/lib/python2.7/fnmatch.py
m ftplib                    /usr/lib/python2.7/ftplib.py
m functools                 /usr/lib/python2.7/functools.py
m gc                        
m genericpath               /usr/lib/python2.7/genericpath.py
m getopt                    /usr/lib/python2.7/getopt.py
m getpass                   /usr/lib/python2.7/getpass.py
m gettext                   /usr/lib/python2.7/gettext.py
m grp                       
m gzip                      /usr/lib/python2.7/gzip.py
m hashlib                   /usr/lib/python2.7/hashlib.py
m heapq                     /usr/lib/python2.7/heapq.py
m httplib                   /usr/lib/python2.7/httplib.py
m imp                       
P importlib                 /usr/lib/python2.7/importlib/__init__.py
m inspect                   /usr/lib/python2.7/inspect.py
m io                        /usr/lib/python2.7/io.py
m itertools                 
P json                      /usr/lib/python2.7/json/__init__.py
m json.decoder              /usr/lib/python2.7/json/decoder.py
m json.encoder              /usr/lib/python2.7/json/encoder.py
m json.scanner              /usr/lib/python2.7/json/scanner.py
m keyword                   /usr/lib/python2.7/keyword.py
m linecache                 /usr/lib/python2.7/linecache.py
m locale                    /usr/lib/python2.7/locale.py
P logging                   /usr/lib/python2.7/logging/__init__.py
m marshal                   
m math                      
m md5                       /usr/lib/python2.7/md5.py
m mimetools                 /usr/lib/python2.7/mimetools.py
m mimetypes                 /usr/lib/python2.7/mimetypes.py
P ndg                       /usr/lib/pymodules/python2.7/ndg/__init__.py
P ndg.httpsclient           /usr/lib/pymodules/python2.7/ndg/httpsclient/__init__.py
m ndg.httpsclient.ssl_peer_verification /usr/lib/pymodules/python2.7/ndg/httpsclient/ssl_peer_verification.py
m ndg.httpsclient.subj_alt_name /usr/lib/pymodules/python2.7/ndg/httpsclient/subj_alt_name.py
m netrc                     /usr/lib/python2.7/netrc.py
m ntpath                    /usr/lib/python2.7/ntpath.py
m nturl2path                /usr/lib/python2.7/nturl2path.py
m numbers                   /usr/lib/python2.7/numbers.py
m opcode                    /usr/lib/python2.7/opcode.py
m operator                  
m optparse                  /usr/lib/python2.7/optparse.py
m os                        /usr/lib/python2.7/os.py
m os2emxpath                /usr/lib/python2.7/os2emxpath.py
m pdb                       /usr/lib/python2.7/pdb.py
m pickle                    /usr/lib/python2.7/pickle.py
m pkgutil                   /usr/lib/python2.7/pkgutil.py
m platform                  /usr/lib/python2.7/platform.py
m plistlib                  /usr/lib/python2.7/plistlib.py
P ply                       /usr/lib/python2.7/dist-packages/ply/__init__.py
m ply.lex                   /usr/lib/python2.7/dist-packages/ply/lex.py
m ply.yacc                  /usr/lib/python2.7/dist-packages/ply/yacc.py
m posix                     
m posixpath                 /usr/lib/python2.7/posixpath.py
m pprint                    /usr/lib/python2.7/pprint.py
P praw                      /usr/local/lib/python2.7/dist-packages/praw/__init__.py
m praw.decorators           /usr/local/lib/python2.7/dist-packages/praw/decorators.py
m praw.errors               /usr/local/lib/python2.7/dist-packages/praw/errors.py
m praw.handlers             /usr/local/lib/python2.7/dist-packages/praw/handlers.py
m praw.helpers              /usr/local/lib/python2.7/dist-packages/praw/helpers.py
m praw.internal             /usr/local/lib/python2.7/dist-packages/praw/internal.py
m praw.objects              /usr/local/lib/python2.7/dist-packages/praw/objects.py
m praw.settings             /usr/local/lib/python2.7/dist-packages/praw/settings.py
m pwd                       
m py_compile                /usr/lib/python2.7/py_compile.py
P pyasn1                    /usr/lib/python2.7/dist-packages/pyasn1/__init__.py
P pyasn1.codec              /usr/lib/python2.7/dist-packages/pyasn1/codec/__init__.py
P pyasn1.codec.ber          /usr/lib/python2.7/dist-packages/pyasn1/codec/ber/__init__.py
m pyasn1.codec.ber.decoder  /usr/lib/python2.7/dist-packages/pyasn1/codec/ber/decoder.py
m pyasn1.codec.ber.eoo      /usr/lib/python2.7/dist-packages/pyasn1/codec/ber/eoo.py
P pyasn1.codec.cer          /usr/lib/python2.7/dist-packages/pyasn1/codec/cer/__init__.py
m pyasn1.codec.cer.decoder  /usr/lib/python2.7/dist-packages/pyasn1/codec/cer/decoder.py
P pyasn1.codec.der          /usr/lib/python2.7/dist-packages/pyasn1/codec/der/__init__.py
m pyasn1.codec.der.decoder  /usr/lib/python2.7/dist-packages/pyasn1/codec/der/decoder.py
P pyasn1.compat             /usr/lib/python2.7/dist-packages/pyasn1/compat/__init__.py
m pyasn1.compat.octets      /usr/lib/python2.7/dist-packages/pyasn1/compat/octets.py
m pyasn1.debug              /usr/lib/python2.7/dist-packages/pyasn1/debug.py
m pyasn1.error              /usr/lib/python2.7/dist-packages/pyasn1/error.py
P pyasn1.type               /usr/lib/python2.7/dist-packages/pyasn1/type/__init__.py
m pyasn1.type.base          /usr/lib/python2.7/dist-packages/pyasn1/type/base.py
m pyasn1.type.char          /usr/lib/python2.7/dist-packages/pyasn1/type/char.py
m pyasn1.type.constraint    /usr/lib/python2.7/dist-packages/pyasn1/type/constraint.py
m pyasn1.type.error         /usr/lib/python2.7/dist-packages/pyasn1/type/error.py
m pyasn1.type.namedtype     /usr/lib/python2.7/dist-packages/pyasn1/type/namedtype.py
m pyasn1.type.namedval      /usr/lib/python2.7/dist-packages/pyasn1/type/namedval.py
m pyasn1.type.tag           /usr/lib/python2.7/dist-packages/pyasn1/type/tag.py
m pyasn1.type.tagmap        /usr/lib/python2.7/dist-packages/pyasn1/type/tagmap.py
m pyasn1.type.univ          /usr/lib/python2.7/dist-packages/pyasn1/type/univ.py
m pyasn1.type.useful        /usr/lib/python2.7/dist-packages/pyasn1/type/useful.py
P pycparser                 /usr/lib/python2.7/dist-packages/pycparser/__init__.py
m pycparser.ast_transforms  /usr/lib/python2.7/dist-packages/pycparser/ast_transforms.py
m pycparser.c_ast           /usr/lib/python2.7/dist-packages/pycparser/c_ast.py
m pycparser.c_lexer         /usr/lib/python2.7/dist-packages/pycparser/c_lexer.py
m pycparser.c_parser        /usr/lib/python2.7/dist-packages/pycparser/c_parser.py
m pycparser.plyparser       /usr/lib/python2.7/dist-packages/pycparser/plyparser.py
m pyexpat                   /usr/lib/python2.7/lib-dynload/pyexpat.arm-linux-gnueabihf.so
m quopri                    /usr/lib/python2.7/quopri.py
m random                    /usr/lib/python2.7/random.py
m re                        /usr/lib/python2.7/re.py
m readline                  /usr/lib/python2.7/lib-dynload/readline.arm-linux-gnueabihf.so
m repr                      /usr/lib/python2.7/repr.py
P requests                  /usr/local/lib/python2.7/dist-packages/requests/__init__.py
m requests.adapters         /usr/local/lib/python2.7/dist-packages/requests/adapters.py
m requests.api              /usr/local/lib/python2.7/dist-packages/requests/api.py
m requests.auth             /usr/local/lib/python2.7/dist-packages/requests/auth.py
m requests.certs            /usr/local/lib/python2.7/dist-packages/requests/certs.py
m requests.compat           /usr/local/lib/python2.7/dist-packages/requests/compat.py
m requests.cookies          /usr/local/lib/python2.7/dist-packages/requests/cookies.py
m requests.exceptions       /usr/local/lib/python2.7/dist-packages/requests/exceptions.py
m requests.hooks            /usr/local/lib/python2.7/dist-packages/requests/hooks.py
m requests.models           /usr/local/lib/python2.7/dist-packages/requests/models.py
P requests.packages         /usr/local/lib/python2.7/dist-packages/requests/packages/__init__.py
P requests.packages.chardet /usr/local/lib/python2.7/dist-packages/requests/packages/chardet/__init__.py
m requests.packages.chardet.big5freq /usr/local/lib/python2.7/dist-packages/requests/packages/chardet/big5freq.py
m requests.packages.chardet.big5prober /usr/local/lib/python2.7/dist-packages/requests/packages/chardet/big5prober.py
m requests.packages.chardet.chardistribution /usr/local/lib/python2.7/dist-packages/requests/packages/chardet/chardistribution.py
m requests.packages.chardet.charsetgroupprober /usr/local/lib/python2.7/dist-packages/requests/packages/chardet/charsetgroupprober.py
m requests.packages.chardet.charsetprober /usr/local/lib/python2.7/dist-packages/requests/packages/chardet/charsetprober.py
m requests.packages.chardet.codingstatemachine /usr/local/lib/python2.7/dist-packages/requests/packages/chardet/codingstatemachine.py
m requests.packages.chardet.compat /usr/local/lib/python2.7/dist-packages/requests/packages/chardet/compat.py
m requests.packages.chardet.constants /usr/local/lib/python2.7/dist-packages/requests/packages/chardet/constants.py
m requests.packages.chardet.cp949prober /usr/local/lib/python2.7/dist-packages/requests/packages/chardet/cp949prober.py
m requests.packages.chardet.escprober /usr/local/lib/python2.7/dist-packages/requests/packages/chardet/escprober.py
m requests.packages.chardet.escsm /usr/local/lib/python2.7/dist-packages/requests/packages/chardet/escsm.py
m requests.packages.chardet.eucjpprober /usr/local/lib/python2.7/dist-packages/requests/packages/chardet/eucjpprober.py
m requests.packages.chardet.euckrfreq /usr/local/lib/python2.7/dist-packages/requests/packages/chardet/euckrfreq.py
m requests.packages.chardet.euckrprober /usr/local/lib/python2.7/dist-packages/requests/packages/chardet/euckrprober.py
m requests.packages.chardet.euctwfreq /usr/local/lib/python2.7/dist-packages/requests/packages/chardet/euctwfreq.py
m requests.packages.chardet.euctwprober /usr/local/lib/python2.7/dist-packages/requests/packages/chardet/euctwprober.py
m requests.packages.chardet.gb2312freq /usr/local/lib/python2.7/dist-packages/requests/packages/chardet/gb2312freq.py
m requests.packages.chardet.gb2312prober /usr/local/lib/python2.7/dist-packages/requests/packages/chardet/gb2312prober.py
m requests.packages.chardet.hebrewprober /usr/local/lib/python2.7/dist-packages/requests/packages/chardet/hebrewprober.py
m requests.packages.chardet.jisfreq /usr/local/lib/python2.7/dist-packages/requests/packages/chardet/jisfreq.py
m requests.packages.chardet.jpcntx /usr/local/lib/python2.7/dist-packages/requests/packages/chardet/jpcntx.py
m requests.packages.chardet.langbulgarianmodel /usr/local/lib/python2.7/dist-packages/requests/packages/chardet/langbulgarianmodel.py
m requests.packages.chardet.langcyrillicmodel /usr/local/lib/python2.7/dist-packages/requests/packages/chardet/langcyrillicmodel.py
m requests.packages.chardet.langgreekmodel /usr/local/lib/python2.7/dist-packages/requests/packages/chardet/langgreekmodel.py
m requests.packages.chardet.langhebrewmodel /usr/local/lib/python2.7/dist-packages/requests/packages/chardet/langhebrewmodel.py
m requests.packages.chardet.langhungarianmodel /usr/local/lib/python2.7/dist-packages/requests/packages/chardet/langhungarianmodel.py
m requests.packages.chardet.langthaimodel /usr/local/lib/python2.7/dist-packages/requests/packages/chardet/langthaimodel.py
m requests.packages.chardet.latin1prober /usr/local/lib/python2.7/dist-packages/requests/packages/chardet/latin1prober.py
m requests.packages.chardet.mbcharsetprober /usr/local/lib/python2.7/dist-packages/requests/packages/chardet/mbcharsetprober.py
m requests.packages.chardet.mbcsgroupprober /usr/local/lib/python2.7/dist-packages/requests/packages/chardet/mbcsgroupprober.py
m requests.packages.chardet.mbcssm /usr/local/lib/python2.7/dist-packages/requests/packages/chardet/mbcssm.py
m requests.packages.chardet.sbcharsetprober /usr/local/lib/python2.7/dist-packages/requests/packages/chardet/sbcharsetprober.py
m requests.packages.chardet.sbcsgroupprober /usr/local/lib/python2.7/dist-packages/requests/packages/chardet/sbcsgroupprober.py
m requests.packages.chardet.sjisprober /usr/local/lib/python2.7/dist-packages/requests/packages/chardet/sjisprober.py
m requests.packages.chardet.universaldetector /usr/local/lib/python2.7/dist-packages/requests/packages/chardet/universaldetector.py
m requests.packages.chardet.utf8prober /usr/local/lib/python2.7/dist-packages/requests/packages/chardet/utf8prober.py
P requests.packages.urllib3 /usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/__init__.py
m requests.packages.urllib3._collections /usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/_collections.py
m requests.packages.urllib3.connection /usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/connection.py
m requests.packages.urllib3.connectionpool /usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/connectionpool.py
P requests.packages.urllib3.contrib /usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/contrib/__init__.py
m requests.packages.urllib3.contrib.pyopenssl /usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/contrib/pyopenssl.py
m requests.packages.urllib3.exceptions /usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/exceptions.py
m requests.packages.urllib3.fields /usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/fields.py
m requests.packages.urllib3.filepost /usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/filepost.py
P requests.packages.urllib3.packages /usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/packages/__init__.py
m requests.packages.urllib3.packages.ordered_dict /usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/packages/ordered_dict.py
m requests.packages.urllib3.packages.six /usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/packages/six.py
P requests.packages.urllib3.packages.ssl_match_hostname /usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/packages/ssl_match_hostname/__init__.py
m requests.packages.urllib3.packages.ssl_match_hostname._implementation /usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/packages/ssl_match_hostname/_implementation.py
m requests.packages.urllib3.poolmanager /usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/poolmanager.py
m requests.packages.urllib3.request /usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/request.py
m requests.packages.urllib3.response /usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/response.py
P requests.packages.urllib3.util /usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/util/__init__.py
m requests.packages.urllib3.util.connection /usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/util/connection.py
m requests.packages.urllib3.util.request /usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/util/request.py
m requests.packages.urllib3.util.response /usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/util/response.py
m requests.packages.urllib3.util.retry /usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/util/retry.py
m requests.packages.urllib3.util.ssl_ /usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/util/ssl_.py
m requests.packages.urllib3.util.timeout /usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/util/timeout.py
m requests.packages.urllib3.util.url /usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/util/url.py
m requests.sessions         /usr/local/lib/python2.7/dist-packages/requests/sessions.py
m requests.status_codes     /usr/local/lib/python2.7/dist-packages/requests/status_codes.py
m requests.structures       /usr/local/lib/python2.7/dist-packages/requests/structures.py
m requests.utils            /usr/local/lib/python2.7/dist-packages/requests/utils.py
m rfc822                    /usr/lib/python2.7/rfc822.py
m select                    
m shlex                     /usr/lib/python2.7/shlex.py
m shutil                    /usr/lib/python2.7/shutil.py
m signal                    
P simplejson                /usr/lib/python2.7/dist-packages/simplejson/__init__.py
m simplejson._speedups      /usr/lib/python2.7/dist-packages/simplejson/_speedups.arm-linux-gnueabihf.so
m simplejson.compat         /usr/lib/python2.7/dist-packages/simplejson/compat.py
m simplejson.decoder        /usr/lib/python2.7/dist-packages/simplejson/decoder.py
m simplejson.encoder        /usr/lib/python2.7/dist-packages/simplejson/encoder.py
m simplejson.ordered_dict   /usr/lib/python2.7/dist-packages/simplejson/ordered_dict.py
m simplejson.scanner        /usr/lib/python2.7/dist-packages/simplejson/scanner.py
m six                       /usr/local/lib/python2.7/dist-packages/six.py
m socket                    /usr/lib/python2.7/socket.py
m sre_compile               /usr/lib/python2.7/sre_compile.py
m sre_constants             /usr/lib/python2.7/sre_constants.py
m sre_parse                 /usr/lib/python2.7/sre_parse.py
m ssl                       /usr/lib/python2.7/ssl.py
m stat                      /usr/lib/python2.7/stat.py
m string                    /usr/lib/python2.7/string.py
m strop                     
m struct                    /usr/lib/python2.7/struct.py
m subprocess                /usr/lib/python2.7/subprocess.py
m sys                       
m tarfile                   /usr/lib/python2.7/tarfile.py
m tempfile                  /usr/lib/python2.7/tempfile.py
m termios                   /usr/lib/python2.7/lib-dynload/termios.arm-linux-gnueabihf.so
m textwrap                  /usr/lib/python2.7/textwrap.py
m thread                    
m threading                 /usr/lib/python2.7/threading.py
m time                      
m timeit                    /usr/lib/python2.7/timeit.py
m token                     /usr/lib/python2.7/token.py
m tokenize                  /usr/lib/python2.7/tokenize.py
m traceback                 /usr/lib/python2.7/traceback.py
m types                     /usr/lib/python2.7/types.py
P unittest                  /usr/lib/python2.7/unittest/__init__.py
m unittest.case             /usr/lib/python2.7/unittest/case.py
m unittest.loader           /usr/lib/python2.7/unittest/loader.py
m unittest.main             /usr/lib/python2.7/unittest/main.py
m unittest.result           /usr/lib/python2.7/unittest/result.py
m unittest.runner           /usr/lib/python2.7/unittest/runner.py
m unittest.signals          /usr/lib/python2.7/unittest/signals.py
m unittest.suite            /usr/lib/python2.7/unittest/suite.py
m unittest.util             /usr/lib/python2.7/unittest/util.py
m update_checker            /usr/local/lib/python2.7/dist-packages/update_checker.py
m urllib                    /usr/lib/python2.7/urllib.py
m urllib2                   /usr/lib/python2.7/urllib2.py
m urlparse                  /usr/lib/python2.7/urlparse.py
m uu                        /usr/lib/python2.7/uu.py
m uuid                      /usr/lib/python2.7/uuid.py
m warnings                  /usr/lib/python2.7/warnings.py
m weakref                   /usr/lib/python2.7/weakref.py
P xml                       /usr/lib/python2.7/xml/__init__.py
P xml.parsers               /usr/lib/python2.7/xml/parsers/__init__.py
m xml.parsers.expat         /usr/lib/python2.7/xml/parsers/expat.py
m zipfile                   /usr/lib/python2.7/zipfile.py
m zipimport                 
m zlib                      

Missing modules:
? Carbon imported from plistlib
? Carbon.File imported from plistlib
? Carbon.Files imported from plistlib
? EasyDialogs imported from getpass
? MacOS imported from platform
? SOCKS imported from ftplib
? _dummy_thread imported from cffi.lock, configparser_helpers
? _dummy_threading imported from dummy_threading
? _emx_link imported from os
? _scproxy imported from urllib
? _subprocess imported from subprocess
? _sysconfigdata_d imported from _sysconfigdata
? _thread imported from cffi.cparser, cffi.lock, configparser_helpers
? _winreg imported from mimetypes, platform, urllib
? _xmlplus imported from xml
? builtins imported from requests.packages.urllib3.packages.six
? ce imported from os
? cffi._pycparser imported from -
? ctypes.macholib.dyld imported from ctypes.util
? gestalt imported from platform
? http imported from requests.compat
? http.client imported from requests.packages.urllib3.connection
? http.cookies imported from requests.compat
? importlib.reload imported from simplejson.compat
? java.lang imported from platform
? msvcrt imported from getpass, subprocess
? netbios imported from uuid
? nt imported from ntpath, os
? ordereddict imported from configparser
? org.python.core imported from copy, pickle
? os.path imported from cffi.ffiplatform, distutils.file_util, os, pkgutil, ply.lex, ply.yacc, requests.certs, shlex, shutil
? os2 imported from os
? packages.ssl_match_hostname.CertificateError imported from requests.packages.urllib3.connectionpool
? packages.ssl_match_hostname.match_hostname imported from requests.packages.urllib3.connection
? packages.urllib3.Retry imported from requests.adapters
? packages.urllib3.util.Timeout imported from requests.adapters
? packages.urllib3.util.parse_url imported from requests.models
? queue imported from requests.packages.urllib3.connectionpool
? riscos imported from os
? riscosenviron imported from os
? riscospath imported from os
? rourl2path imported from urllib
? six.moves.urllib.parse imported from praw, praw.objects
? urllib.parse imported from requests.compat, requests.packages.urllib3.poolmanager, requests.packages.urllib3.request
? urllib.request imported from requests.compat
? vms_lib imported from platform
? win32api imported from platform
? win32con imported from platform
? win32pipe imported from platform
? win32wnet imported from uuid

In [28]:
runpy.run_module('requests')


---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-28-e00a0160b4b3> in <module>()
----> 1 runpy.run_module('requests')

/usr/lib/python2.7/runpy.pyc in run_module(mod_name, init_globals, run_name, alter_sys)
    168        Returns the resulting top level namespace dictionary
    169     """
--> 170     mod_name, loader, code, fname = _get_module_details(mod_name)
    171     if run_name is None:
    172         run_name = mod_name

/usr/lib/python2.7/runpy.pyc in _get_module_details(mod_name)
    110         except ImportError, e:
    111             raise ImportError(("%s; %r is a package and cannot " +
--> 112                                "be directly executed") %(e, mod_name))
    113     code = loader.get_code(mod_name)
    114     if code is None:

ImportError: No module named requests.__main__; 'requests' is a package and cannot be directly executed

In [ ]:


In [29]:
nbog = raw_input('Name of notebook to tag: ')


Name of notebook to tag: wcmnikolatags

In [30]:
files = file_paths(filtered_walk('/home/wcmckee/github/', depth=100, included_files=[nbog + '.ipynb']))

In [35]:
#Easier to access ipynb and access the code import cell.
#Parse the notebook for import tags
#IPython module wrapper for returning list of imported modules
#from a ipynb file. 
#Get the list of modules for tags from this.

In [32]:
for fil in files:
    #print fil
    opfil = open(fil, 'r')
    print opfil.read()
    opfil.close()


{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "wcm Nikola Tags\n",
    "\n",
    "convert ipynb/py doc imports as tags for nikola blog .meta files.\n",
    "\n",
    "When user searches for notebook to blog with bbknikola python script also get the tags for the .meta file. Open up the .py file and convert this:\n",
    "\n",
    "blogpost.py\n",
    "\n",
    "import requests\n",
    "import os\n",
    "import re\n",
    "\n",
    "Into:\n",
    "\n",
    "blogpost.meta\n",
    "\n",
    "blogpost\n",
    "blogpost\n",
    "2015/02/31 00:00:00\n",
    "requests, os, re"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Categorie can be the name of the repo.\n",
    "Need a repo for Nikola scripts"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "import os\n",
    "from walkdir import filtered_walk, dir_paths, all_paths, file_paths\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Name of notebook to tag: wcmnikolatags\n"
     ]
    }
   ],
   "source": [
    "nbog = raw_input('Name of notebook to tag: ')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "files = file_paths(filtered_walk('/home/wcmckee/github/', depth=100, included_files=[nbog + '.py']))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<generator object file_paths at 0x97ece14>\n"
     ]
    }
   ],
   "source": [
    "print files"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "# coding: utf-8\n",
      "\n",
      "# wcm Nikola Tags\n",
      "# \n",
      "# convert ipynb/py doc imports as tags for nikola blog .meta files.\n",
      "# \n",
      "# When user searches for notebook to blog with bbknikola python script also get the tags for the .meta file. Open up the .py file and convert this:\n",
      "# \n",
      "# blogpost.py\n",
      "# \n",
      "# import requests\n",
      "# import os\n",
      "# import re\n",
      "# \n",
      "# Into:\n",
      "# \n",
      "# blogpost.meta\n",
      "# \n",
      "# blogpost\n",
      "# blogpost\n",
      "# 2015/02/31 00:00:00\n",
      "# requests, os, re\n",
      "\n",
      "# Categorie can be the name of the repo.\n",
      "# Need a repo for Nikola scripts\n",
      "\n",
      "# In[13]:\n",
      "\n",
      "import os\n",
      "from walkdir import filtered_walk, dir_paths, all_paths, file_paths\n",
      "\n",
      "\n",
      "# In[14]:\n",
      "\n",
      "nbog = raw_input('Name of notebook to tag: ')\n",
      "\n",
      "\n",
      "# In[15]:\n",
      "\n",
      "files = file_paths(filtered_walk('/home/wcmckee/github/', depth=100, included_files=[nbog + '.py']))\n",
      "\n",
      "\n",
      "# In[16]:\n",
      "\n",
      "print files\n",
      "\n",
      "\n",
      "# In[17]:\n",
      "\n",
      "for fil in files:\n",
      "    #print fil\n",
      "    opfil = open(fil, 'r')\n",
      "    print opfil.read()\n",
      "    opfil.close()\n",
      "\n",
      "\n",
      "# In[19]:\n",
      "\n",
      "opfilz = open(fil, 'r')\n",
      "\n",
      "opfilz.read()\n",
      "\n",
      "\n",
      "# In[1]:\n",
      "\n",
      "#python module that can be used to scan .py files and return\n",
      "#the imports as a list.\n",
      "\n",
      "\n",
      "# In[ ]:\n",
      "\n",
      "\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "for fil in files:\n",
    "    #print fil\n",
    "    opfil = open(fil, 'r')\n",
    "    print opfil.read()\n",
    "    opfil.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"\\n# coding: utf-8\\n\\n# wcm Nikola Tags\\n# \\n# convert ipynb/py doc imports as tags for nikola blog .meta files.\\n# \\n# When user searches for notebook to blog with bbknikola python script also get the tags for the .meta file. Open up the .py file and convert this:\\n# \\n# blogpost.py\\n# \\n# import requests\\n# import os\\n# import re\\n# \\n# Into:\\n# \\n# blogpost.meta\\n# \\n# blogpost\\n# blogpost\\n# 2015/02/31 00:00:00\\n# requests, os, re\\n\\n# Categorie can be the name of the repo.\\n# Need a repo for Nikola scripts\\n\\n# In[13]:\\n\\nimport os\\nfrom walkdir import filtered_walk, dir_paths, all_paths, file_paths\\n\\n\\n# In[14]:\\n\\nnbog = raw_input('Name of notebook to tag: ')\\n\\n\\n# In[15]:\\n\\nfiles = file_paths(filtered_walk('/home/wcmckee/github/', depth=100, included_files=[nbog + '.py']))\\n\\n\\n# In[16]:\\n\\nprint files\\n\\n\\n# In[17]:\\n\\nfor fil in files:\\n    #print fil\\n    opfil = open(fil, 'r')\\n    print opfil.read()\\n    opfil.close()\\n\\n\\n# In[19]:\\n\\nopfilz = open(fil, 'r')\\n\\nopfilz.read()\\n\\n\\n# In[1]:\\n\\n#python module that can be used to scan .py files and return\\n#the imports as a list.\\n\\n\\n# In[ ]:\\n\\n\\n\\n\""
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "opfilz = open(fil, 'r')\n",
    "\n",
    "opfilz.read()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "#python module that can be used to scan .py files and return\n",
    "#the imports as a list."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}


In [33]:
opfilz = open(fil, 'r')

opfilz.read()


Out[33]:
'{\n "cells": [\n  {\n   "cell_type": "markdown",\n   "metadata": {},\n   "source": [\n    "wcm Nikola Tags\\n",\n    "\\n",\n    "convert ipynb/py doc imports as tags for nikola blog .meta files.\\n",\n    "\\n",\n    "When user searches for notebook to blog with bbknikola python script also get the tags for the .meta file. Open up the .py file and convert this:\\n",\n    "\\n",\n    "blogpost.py\\n",\n    "\\n",\n    "import requests\\n",\n    "import os\\n",\n    "import re\\n",\n    "\\n",\n    "Into:\\n",\n    "\\n",\n    "blogpost.meta\\n",\n    "\\n",\n    "blogpost\\n",\n    "blogpost\\n",\n    "2015/02/31 00:00:00\\n",\n    "requests, os, re"\n   ]\n  },\n  {\n   "cell_type": "markdown",\n   "metadata": {},\n   "source": [\n    "Categorie can be the name of the repo.\\n",\n    "Need a repo for Nikola scripts"\n   ]\n  },\n  {\n   "cell_type": "code",\n   "execution_count": 20,\n   "metadata": {\n    "collapsed": false\n   },\n   "outputs": [],\n   "source": [\n    "import os\\n",\n    "from walkdir import filtered_walk, dir_paths, all_paths, file_paths\\n"\n   ]\n  },\n  {\n   "cell_type": "code",\n   "execution_count": 21,\n   "metadata": {\n    "collapsed": false\n   },\n   "outputs": [\n    {\n     "name": "stdout",\n     "output_type": "stream",\n     "text": [\n      "Name of notebook to tag: wcmnikolatags\\n"\n     ]\n    }\n   ],\n   "source": [\n    "nbog = raw_input(\'Name of notebook to tag: \')"\n   ]\n  },\n  {\n   "cell_type": "code",\n   "execution_count": 22,\n   "metadata": {\n    "collapsed": false\n   },\n   "outputs": [],\n   "source": [\n    "files = file_paths(filtered_walk(\'/home/wcmckee/github/\', depth=100, included_files=[nbog + \'.py\']))"\n   ]\n  },\n  {\n   "cell_type": "code",\n   "execution_count": 23,\n   "metadata": {\n    "collapsed": false\n   },\n   "outputs": [\n    {\n     "name": "stdout",\n     "output_type": "stream",\n     "text": [\n      "<generator object file_paths at 0x97ece14>\\n"\n     ]\n    }\n   ],\n   "source": [\n    "print files"\n   ]\n  },\n  {\n   "cell_type": "code",\n   "execution_count": 24,\n   "metadata": {\n    "collapsed": false,\n    "scrolled": true\n   },\n   "outputs": [\n    {\n     "name": "stdout",\n     "output_type": "stream",\n     "text": [\n      "\\n",\n      "# coding: utf-8\\n",\n      "\\n",\n      "# wcm Nikola Tags\\n",\n      "# \\n",\n      "# convert ipynb/py doc imports as tags for nikola blog .meta files.\\n",\n      "# \\n",\n      "# When user searches for notebook to blog with bbknikola python script also get the tags for the .meta file. Open up the .py file and convert this:\\n",\n      "# \\n",\n      "# blogpost.py\\n",\n      "# \\n",\n      "# import requests\\n",\n      "# import os\\n",\n      "# import re\\n",\n      "# \\n",\n      "# Into:\\n",\n      "# \\n",\n      "# blogpost.meta\\n",\n      "# \\n",\n      "# blogpost\\n",\n      "# blogpost\\n",\n      "# 2015/02/31 00:00:00\\n",\n      "# requests, os, re\\n",\n      "\\n",\n      "# Categorie can be the name of the repo.\\n",\n      "# Need a repo for Nikola scripts\\n",\n      "\\n",\n      "# In[13]:\\n",\n      "\\n",\n      "import os\\n",\n      "from walkdir import filtered_walk, dir_paths, all_paths, file_paths\\n",\n      "\\n",\n      "\\n",\n      "# In[14]:\\n",\n      "\\n",\n      "nbog = raw_input(\'Name of notebook to tag: \')\\n",\n      "\\n",\n      "\\n",\n      "# In[15]:\\n",\n      "\\n",\n      "files = file_paths(filtered_walk(\'/home/wcmckee/github/\', depth=100, included_files=[nbog + \'.py\']))\\n",\n      "\\n",\n      "\\n",\n      "# In[16]:\\n",\n      "\\n",\n      "print files\\n",\n      "\\n",\n      "\\n",\n      "# In[17]:\\n",\n      "\\n",\n      "for fil in files:\\n",\n      "    #print fil\\n",\n      "    opfil = open(fil, \'r\')\\n",\n      "    print opfil.read()\\n",\n      "    opfil.close()\\n",\n      "\\n",\n      "\\n",\n      "# In[19]:\\n",\n      "\\n",\n      "opfilz = open(fil, \'r\')\\n",\n      "\\n",\n      "opfilz.read()\\n",\n      "\\n",\n      "\\n",\n      "# In[1]:\\n",\n      "\\n",\n      "#python module that can be used to scan .py files and return\\n",\n      "#the imports as a list.\\n",\n      "\\n",\n      "\\n",\n      "# In[ ]:\\n",\n      "\\n",\n      "\\n",\n      "\\n",\n      "\\n"\n     ]\n    }\n   ],\n   "source": [\n    "for fil in files:\\n",\n    "    #print fil\\n",\n    "    opfil = open(fil, \'r\')\\n",\n    "    print opfil.read()\\n",\n    "    opfil.close()"\n   ]\n  },\n  {\n   "cell_type": "code",\n   "execution_count": 27,\n   "metadata": {\n    "collapsed": false,\n    "scrolled": true\n   },\n   "outputs": [\n    {\n     "data": {\n      "text/plain": [\n       "\\"\\\\n# coding: utf-8\\\\n\\\\n# wcm Nikola Tags\\\\n# \\\\n# convert ipynb/py doc imports as tags for nikola blog .meta files.\\\\n# \\\\n# When user searches for notebook to blog with bbknikola python script also get the tags for the .meta file. Open up the .py file and convert this:\\\\n# \\\\n# blogpost.py\\\\n# \\\\n# import requests\\\\n# import os\\\\n# import re\\\\n# \\\\n# Into:\\\\n# \\\\n# blogpost.meta\\\\n# \\\\n# blogpost\\\\n# blogpost\\\\n# 2015/02/31 00:00:00\\\\n# requests, os, re\\\\n\\\\n# Categorie can be the name of the repo.\\\\n# Need a repo for Nikola scripts\\\\n\\\\n# In[13]:\\\\n\\\\nimport os\\\\nfrom walkdir import filtered_walk, dir_paths, all_paths, file_paths\\\\n\\\\n\\\\n# In[14]:\\\\n\\\\nnbog = raw_input(\'Name of notebook to tag: \')\\\\n\\\\n\\\\n# In[15]:\\\\n\\\\nfiles = file_paths(filtered_walk(\'/home/wcmckee/github/\', depth=100, included_files=[nbog + \'.py\']))\\\\n\\\\n\\\\n# In[16]:\\\\n\\\\nprint files\\\\n\\\\n\\\\n# In[17]:\\\\n\\\\nfor fil in files:\\\\n    #print fil\\\\n    opfil = open(fil, \'r\')\\\\n    print opfil.read()\\\\n    opfil.close()\\\\n\\\\n\\\\n# In[19]:\\\\n\\\\nopfilz = open(fil, \'r\')\\\\n\\\\nopfilz.read()\\\\n\\\\n\\\\n# In[1]:\\\\n\\\\n#python module that can be used to scan .py files and return\\\\n#the imports as a list.\\\\n\\\\n\\\\n# In[ ]:\\\\n\\\\n\\\\n\\\\n\\""\n      ]\n     },\n     "execution_count": 27,\n     "metadata": {},\n     "output_type": "execute_result"\n    }\n   ],\n   "source": [\n    "opfilz = open(fil, \'r\')\\n",\n    "\\n",\n    "opfilz.read()"\n   ]\n  },\n  {\n   "cell_type": "code",\n   "execution_count": 26,\n   "metadata": {\n    "collapsed": true\n   },\n   "outputs": [],\n   "source": [\n    "#python module that can be used to scan .py files and return\\n",\n    "#the imports as a list."\n   ]\n  },\n  {\n   "cell_type": "code",\n   "execution_count": null,\n   "metadata": {\n    "collapsed": true\n   },\n   "outputs": [],\n   "source": []\n  }\n ],\n "metadata": {\n  "kernelspec": {\n   "display_name": "Python 2",\n   "language": "python",\n   "name": "python2"\n  },\n  "language_info": {\n   "codemirror_mode": {\n    "name": "ipython",\n    "version": 2\n   },\n   "file_extension": ".py",\n   "mimetype": "text/x-python",\n   "name": "python",\n   "nbconvert_exporter": "python",\n   "pygments_lexer": "ipython2",\n   "version": "2.7.3"\n  }\n },\n "nbformat": 4,\n "nbformat_minor": 0\n}\n'

In [34]:
#python module that can be used to scan .py files and return
#the imports as a list.

In [ ]: