This file contains hidden or 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
| #!/bin/bash | |
| # A bash-wrapped version of http://www.commandlinefu.com/commands/view/9536/un-unzip-a-file | |
| if [ $# -eq 0 ]; then | |
| echo "Un-unzips a file without a root folder." | |
| echo "Usage: ununzip <filename>" | |
| exit 1 | |
| elif [ ! -e $1 ]; then | |
| echo "File not found: $1" | |
| exit 1 | |
| fi |
This file contains hidden or 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
| def elem2dict(node): | |
| """ | |
| Convert an lxml.etree node tree into a dict. | |
| """ | |
| d = {} | |
| for e in node.iterchildren(): | |
| key = e.tag.split('}')[1] if '}' in e.tag else e.tag | |
| value = e.text if e.text else elem2dict(e) | |
| d[key] = value | |
| return d |
NewerOlder