-
-
Save patrys/4276785 to your computer and use it in GitHub Desktop.
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
import glob | |
import os | |
from xml.etree import ElementTree | |
TEMP = './tmp.svg' | |
def rebrand(fname, brand): | |
svg = ElementTree.parse(fname) | |
for e in svg.iterfind(".//{http://www.w3.org/2000/svg}rect[@id='background']"): | |
e.set('style', 'fill:url(#%s);' % (brand,)) | |
svg.write(TEMP) | |
for fname in glob.glob('*svg'): | |
print fname | |
rebrand(fname, "RHEL7") | |
#os.system("inkscape --vacuum-defs -l ../getting-started/C/figures/%s %s" % (fname, TEMP)) | |
#os.unlink(TEMP) |
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 ruby | |
require "rexml/document" | |
include REXML | |
def rebrand(fname, brand) | |
svg = Document.new(File.new(fname, 'r')) | |
temp = | |
svg.root.each_element("/svg/g/rect[@id='background']") do |e| | |
e.attributes["style"] = "fill:url(##{brand});" | |
puts e | |
end | |
temp_f = File.new(TEMP,'w+') | |
temp_f.puts svg | |
temp_f.close | |
end | |
TEMP = './tmp.svg' | |
Dir.glob("*svg") do |fname| | |
puts fname | |
rebrand(fname, "RHEL7") | |
system "inkscape --vacuum-defs -l ../getting-started/C/figures/#{fname} #{TEMP}" | |
File.delete(TEMP) | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment