Last active
December 21, 2015 20:09
-
-
Save doobeh/6359150 to your computer and use it in GitHub Desktop.
Turn it into a dict...!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Usage: | |
CheatSheeter.py <inputxml> | |
CheatSheeter.py -h | --help | |
""" | |
import lxml.etree as et | |
from docopt import docopt | |
from jinja2 import Environment, FileSystemLoader | |
env = Environment(loader = FileSystemLoader('./')) | |
template = env.get_template('template.html') | |
def make(inFile): | |
tree = et.parse(inFile) | |
root = tree.getroot() | |
filetitle = root.attrib['title'] | |
author = root.attrib['author'] | |
version = root.attrib['version'] | |
categories = [] | |
for category in root: | |
title = category.attrib['title'] | |
#print title | |
category_keys = [] | |
for key in category: | |
text = key.text.encode('utf-8') | |
description = key.attrib['description'] | |
#print text, description | |
category_keys.append({'text': text, 'description': description}) | |
my_dictionary = {'title': title, 'keys': category_keys} | |
categories.append(my_dictionary) | |
with open("./%s.html" % filetitle, 'w' ) as f1: | |
f1.write(template.render( | |
filetitle = filetitle, | |
author = author, | |
version = version, | |
categories = categories)) | |
if __name__ == '__main__': | |
args = docopt(__doc__) | |
make(args['<inputxml>']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en" class="no-js"> | |
<head> | |
{% if filetitle %} | |
<title>{{filetitle}}</title> | |
{% else %} | |
<title>Cheatsheet</title> | |
{% endif %} | |
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> | |
<meta name="viewport" content="width=1000" /> | |
<meta name="robots" content="noindex"> | |
<link rel="stylesheet" type="text/css" media="all" href="reset.css"> | |
<link rel="stylesheet" type="text/css" media="all" href="style.css"> | |
<meta name="DC.format" content="text/html"> | |
<meta name="DC.language" content="en"> | |
<script src="js/jquery-1.8.1.min.js"></script> | |
<script src="js/jquery.isotope.min.js"></script> | |
<script src="js/site.js"></script> | |
</head> | |
<body onload="initialize()"> | |
<section id="items"> | |
<div class="box"> | |
<h1>{{filetitle}}</h1> | |
<p>by {{ author }}</p> | |
<small>v{{ version }}</small> | |
</div> | |
{% for category in categories %} | |
<table> | |
<caption>{{ category.title }}</caption> | |
{% for key in category.keys %} | |
<tr> | |
<th>{{ key.text }}</th> | |
<td>{{ key.description }}</td> | |
</tr> | |
{% endfor %}} | |
</table> | |
{% endfor %} | |
</section> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<keycommands title="Vim Cheatsheet" author="XedMada" version="1.0"> | |
<category title="Modes"> | |
<key description="insert, start of line">i,I</key> | |
<key description="append, at end of line">a,A</key> | |
<key description="new line below, above">o,O</key> | |
<key description="visual, linewise">v,V</key> | |
<key description="grid visual selection">⌃v</key> | |
</category> | |
<category title="Movement"> | |
<key description="left, down, up, right">h,j,k,l</key> | |
<key description="{start, end} of line">{0,$}</key> | |
<key description="first non-blank character of line">{^}</key> | |
<key description="first non-blank {next, previous} line">⏎,</key> | |
<key description="{start, line x, end} of file">:{0,#,$}</key> | |
<key description="{next, previous} word">{w,b}</key> | |
<key description="First, middle, last line of screen">H,M,L</key> | |
<key description="First, last line of document">gg,G</key> | |
<key description="matching bracket">%</key> | |
</category> | |
<category title="Editing"> | |
<key description="replace">r</key> | |
<key description="change, line">c,cc</key> | |
<key description="join line with the following">J</key> | |
<key description="delete & insert">s</key> | |
<key description="change case, line">~,g~~</key> | |
<key description="{upper, lower} line">g{UU,uu}</key> | |
<key description="apply last edit">.</key> | |
<key description="undo, redo">u,⌃r</key> | |
<key description="indent line right, left">>>,<<</key> | |
<key description="auto-indent line">==</key> | |
</category> | |
<category title="Search & Replace"> | |
<key description="search foo">/foo</key> | |
<key description="next, previous result">n,?</key> | |
<key description="substitute bar for foo">%s/foo/bar/</key> | |
<key description="substitute globally">%s//g</key> | |
<key description="confirm substitutes">%s//c</key> | |
<key description="confirm, skip, quit">y,b,q</key> | |
<key description="matching bracket">%</key> | |
<key description="find under cursor">*</key> | |
</category> | |
<category title="Cut & Paste"> | |
<key description="delete, delete line">d,dd</key> | |
<key description="cut current, previous character">x,X</key> | |
<key description="yank, line">y,yy</key> | |
<key description="paste buffer after, before">p,P</key> | |
<key description="set {#,a} register">"{#,a}k</key> | |
<key description="retrive {#,a} register">"{#,a}p</key> | |
<key description="display registers">:reg</key> | |
</category> | |
<category title="Files"> | |
<key description="foo save Filename">:w</key> | |
<key description="save and quit">:wq,ZZ</key> | |
<key description="save as">:saveas</key> | |
<key description="quit, force">:q,q!</key> | |
<key description="revert">:e!</key> | |
<key description="next, previous buffer">:bn,bp</key> | |
<key description="delete buffer">:bd</key> | |
</category> | |
<category title="Fuzzyy"> | |
<key description="file">⌘F</key> | |
<key description="buffer">⌘B</key> | |
<key description="tag">⌘A</key> | |
<key description="open in new tab">⌃l</key> | |
<key description="open in horizontal, vertical split">⌃j,k</key> | |
</category> | |
<category title="Nerd Tree"> | |
<key description="NERD Tree">,n</key> | |
<key description="open in new tab, silent">t,T</key> | |
<key description="open in horizontal, vertical split">i,s</key> | |
<key description="toggle directory, recursively">o,O</key> | |
<key description="close parent, children recursively">x,X</key> | |
<key description="go to parent, root">p,P</key> | |
<key description="move tree root up a dir">u</key> | |
<key description="change tree root to current selected">C</key> | |
<key description="refresh current directory">R</key> | |
<key description="hidden toggle">I</key> | |
<key description="file filter, files toggle">f,F</key> | |
<key description="bookmarks">B</key> | |
</category> | |
<category title="Environment"> | |
<key description="line wrap">,w</key> | |
<key description="invisibles">,l</key> | |
<key description="text size">⌘+,-</key> | |
<key description="refresh">⌃l</key> | |
<key description="indent guides">,ig</key> | |
</category> | |
<category title="Spelling"> | |
<key description="toggle spelling">,s</key> | |
<key description="show suggestions">z=</key> | |
<key description="whitelist">zg</key> | |
<key description="blacklist">zw</key> | |
</category> | |
<category title="View"> | |
<key description="scroll">??</key> | |
<key description="scroll forward, backward screen">⌃f,b</key> | |
<key description="zoom window">,z</key> | |
<key description="full screen">⌘⏎</key> | |
<key description="new tab">⌘T</key> | |
<key description="view tab #">⌘#</key> | |
<key description="next, previous tab">⌘},{</key> | |
<key description="make viewports equal">,e</key> | |
<key description="switch viewsports">⌘hjkl</key> | |
<key description="cycle viewports">⌃ww</key> | |
<key description="in/decrease viewport">⌃w +,-</key> | |
</category> | |
<category title="Folding"> | |
<key description="open fold, all">zo,zR</key> | |
<key description="close fold, all">zc,zM</key> | |
<key description="in/decrease fold">zm,r</key> | |
<key description="fold range #">zf#</key> | |
</category> | |
<category title="Macros"> | |
<key description="record macro #">q#</key> | |
<key description="stop recording">q</key> | |
<key description="run macro #">@#</key> | |
</category> | |
<category title="Tools"> | |
<key description="HexColors">,h</key> | |
<key description="show syntax groups">⌃s</key> | |
<key description="comment line">⌘/</key> | |
<key description="show hex/ascii">ga</key> | |
<key description="in/decrement number">⌃a,x</key> | |
<key description="show syntax name">⌃s</key> | |
<key description="convert DOS breaks">%s/⌃V⌃M/⌃V⌃M/g</key> | |
</category> | |
</keycommands> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment