Created
December 5, 2017 18:56
-
-
Save brianredbeard/54e3df4bb35c11f8972bd0342ce25f9e to your computer and use it in GitHub Desktop.
Tool for fixing up CC output from The Noun Project
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
#!/usr/bin/env python3 | |
# Brian 'redbeard' Harrington | |
# License: GPLv3 | |
# For my presentations, I'm a huge fan of visual consistency and attribution | |
# This strips ugliness from assets from the noun projevct and outputs the things | |
# i need to attribute for my slides | |
` | |
import pathlib | |
import sys | |
from lxml import etree | |
def deleteNode(element): | |
for item in element: | |
item.getparent().remove(item) | |
def getNode(element): | |
for item in element: | |
return item.text | |
imagefile = pathlib.PurePath(sys.argv[1]) | |
root = etree.parse(imagefile.as_posix()).getroot() | |
author = root.xpath(".//*[text()[contains(.,'Created by')]]") | |
site = root.xpath(".//*[text()[contains(.,'the Noun Project')]]") | |
a = getNode(author) | |
s = getNode(site) | |
print(a + ". Retrieved", s) | |
deleteNode(author) | |
deleteNode(site) | |
et = etree.ElementTree(root) | |
outfile = imagefile.with_suffix('.strip.svg') | |
et.write(outfile.as_posix()) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment