IPython Quick Referance Project

This notebook is part of a github project to develop alternate file formats of the %quickref magic text. The formats include HTML, pdf, and png.

  • Built by: Damon Allen
  • Last modified: September 10, 2015

In [1]:
cd Git_quickref_project


[Errno 2] No such file or directory: 'Git_quickref_project'
/home/damon/Documents/CODE/Programing/Python/IPython/Quickref/Git_quickref_project

In [2]:
!ls


Basic_Help.png		     Parse_flags.py
Basic_Help.svg		     Parse_flags.py~
Basic_Help.svg~		     Parse_flags.pyc
Basic IPython Help.pdf	     __pycache__
Build_dict.py		     Quick_ref_dic.pkl
Build_dict.py~		     quickref_text_1.txt
Build_dict.pyc		     quickref_text_magic.py
Helpful_projects	     quickref_text_magic.py~
HTML_Basic_Help_Table.html   quick_ref.txt
HTML_Magic_Only_Table.html   Quick_ref_with_library.ipynb
HTML_Table_funcs.py	     README.md
index.html~		     README.md~
IPython Instructions.pdf     SVG_Table_Builder.ipynb
IPython Magic Only Help.pdf  SVG_Table_Builder.py
load_quickref_text_magic.py  SVG_Table_Builder.py~
Magic_only.png		     SVG_Table_Classes.py
Magic_only.svg		     SVG_Table_Classes.py~
Magic_only.svg~		     SVG_Table_Class-lib test.ipynb
MIT License		     Test.py
MIT Liscne~		     Test.py~
modification_code.py	     Test.pyc
open_a_url.py~		     vul2.txt
open_html_in_new_tab.py      vul3.txt
open_html_in_new_tab.py~     vul.txt

Import Libraries


In [3]:
from pprint import pprint as pr
from collections import OrderedDict as Or_dict
from Parse_flags import *
from Build_dict import *
from HTML_Table_funcs import *
import pickle
from IPython.display import HTML
from numpy import floor

Use the %quickref_text magic text to build a dictionary


In [14]:
%quickref

In [4]:
%run load_quickref_text_magic.py
quickref_text = %quickref_text
lines = quickref_text.split('\n')
print(len(lines))
#pr(lines)


308

In [5]:
Quick_ref_dic = build_dict(lines)
with open("Quick_ref_dic.pkl",'wb') as f:
    pickle.dump(dict(Quick_ref_dic),f)
#pr(Quick_ref_dic)

Build the HTML Tables


In [6]:
#%run HTML_Table_funcs
_T_L = build_HTML_table(Quick_ref_dic, end_key='System commands')
_T_R = build_HTML_table(Quick_ref_dic, Start_key='System commands', end_key='The following magic functions')
double_table = Table_container([616,488],[_T_L, _T_R])
with open('HTML_Basic_Help_Table.html','w') as f:
    f.write(double_table)
Basic_help = HTML(double_table)
#pr(Table_list)
%run open_html_in_new_tab.py
open_html(double_table) #open the html output in a new tab
#HTML(double_table) #doesn't deispllay in the notebook correctly

In [7]:
#%run HTML_Table_funcs
T_List=[]
magic_cmds = len(list(Quick_ref_dic['The following magic functions are currently available:'].keys())) - 1
A=floor(magic_cmds/3)
B=magic_cmds-A*3
if B ==2:
    col_B = A + 1
else:
    col_B = A
if B==1:
    col_C = A + 1
else:
    col_C = A
col_A = A
#magic_cmds = build_HTML_table(Quick_ref_dic, Start_key='The following magic functions')
T_List.append(build_HTML_table(Quick_ref_dic, Start_key='The following magic functions', max_line=(col_A+2)))
T_List.append(build_HTML_table(Quick_ref_dic, Start_key='The following magic functions', max_line=col_B, start_later = col_A))
T_List.append(build_HTML_table(Quick_ref_dic, Start_key='The following magic functions',  start_later = (col_A+col_B)))
triple_table = Table_container([640,625,612],T_List)
with open('HTML_Magic_Only_Table.html','w') as f:
    f.write(triple_table)
Magic_help = HTML(triple_table)
%run open_html_in_new_tab.py
open_html(triple_table) #open the html output in a new tab
#HTML(triple_table) #doesn't deispllay in the notebook correctly

In [9]:
#build_HTML_table(
print(magic_cmds)
print(36*2+37)
print(111-98)


124
109
13

There are Problems with rendering the output HTML in the IPython Notebook but here are old screenshots.


In [9]:
from IPython.display import Image
PWD = !pwd
Image(filename=PWD[0]+'/Basic_Help.png')


Out[9]:

In [10]:
Image(filename=PWD[0]+'/Magic_only.png')


Out[10]:

In [11]:
%quickref