[adwaita-icon-theme: 1/2] Lint with rubocop --fix
- From: Jakub Steiner <jimmac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [adwaita-icon-theme: 1/2] Lint with rubocop --fix
- Date: Fri, 26 Mar 2021 16:35:22 +0000 (UTC)
commit b0861f55d0958050a85c75f8f82051093bb4593f
Author: Joshua Peisach <itzswirlz2020 outlook com>
Date: Mon Dec 28 18:57:21 2020 -0500
Lint with rubocop --fix
Whitespace removal
Put spaces after commas
File.exists? is deprecated, use File.exist?
Use tabs correctly
Alignment with code
Put spaces after # and commas
render-symbolic.rb | 153 ++++++++++++++++++++++++++---------------------------
1 file changed, 76 insertions(+), 77 deletions(-)
---
diff --git a/render-symbolic.rb b/render-symbolic.rb
index 73dd0ff63..b628a9c6a 100755
--- a/render-symbolic.rb
+++ b/render-symbolic.rb
@@ -4,7 +4,6 @@ require "rexml/document"
require "fileutils"
include REXML
-
INKSCAPE = 'flatpak run org.inkscape.Inkscape'
# INKSCAPE = '/usr/bin/inkscape'
SRC = "src/symbolic/gnome-stencils.svg"
@@ -17,87 +16,87 @@ SVGO = '/usr/bin/svgo'
# SVGO = '/usr/local/bin/svgo' # it gets put here on some distros
def chopSVG(icon)
- FileUtils.mkdir_p(icon[:dir]) unless File.exists?(icon[:dir])
- unless (File.exists?(icon[:file]) && !icon[:forcerender])
- FileUtils.cp(SRC,icon[:file])
- puts " >> #{icon[:name]}"
- # extract the icon
- cmd = "#{INKSCAPE} -g #{icon[:file]} --select #{icon[:id]}
--verb=\"FitCanvasToSelection;EditInvertInAllLayers"
- cmd +=
";EditDelete;EditSelectAll;SelectionUnGroup;SelectionUnGroup;SelectionUnGroup;StrokeToPath;FileVacuum"
- cmd += ";FileSave;FileQuit;\" > /dev/null 2>&1"
- system(cmd)
- # remove bounding rectangle
- #bounding rectangle is now a path. needs to be removed
- svgcrop = Document.new(File.new(icon[:file], 'r'))
- svgcrop.root.each_element("//path") do |path|
- #puts(path.attributes['style'])
- if path.attributes['style'].include? 'fill:none;'
- #puts "DEBUG: found rect to remove #{path}"
- path.remove
- end
+ FileUtils.mkdir_p(icon[:dir]) unless File.exist?(icon[:dir])
+ unless (File.exist?(icon[:file]) && !icon[:forcerender])
+ FileUtils.cp(SRC, icon[:file])
+ puts " >> #{icon[:name]}"
+ # extract the icon
+ cmd = "#{INKSCAPE} -g #{icon[:file]} --select #{icon[:id]}
--verb=\"FitCanvasToSelection;EditInvertInAllLayers"
+ cmd +=
";EditDelete;EditSelectAll;SelectionUnGroup;SelectionUnGroup;SelectionUnGroup;StrokeToPath;FileVacuum"
+ cmd += ";FileSave;FileQuit;\" > /dev/null 2>&1"
+ system(cmd)
+ # remove bounding rectangle
+ # bounding rectangle is now a path. needs to be removed
+ svgcrop = Document.new(File.new(icon[:file], 'r'))
+ svgcrop.root.each_element("//path") do |path|
+ # puts(path.attributes['style'])
+ if path.attributes['style'].include? 'fill:none;'
+ # puts "DEBUG: found rect to remove #{path}"
+ path.remove
+ end
end
- icon_f = File.new(icon[:file],'w+')
- icon_f.puts svgcrop
- icon_f.close
- # remove as many extraneous elements as possible with SVGO
- cmd = "#{SVGO} --pretty --disable=convertShapeToPath --disable=convertPathData
--enable=removeStyleElement -i #{icon[:file]} -o #{icon[:file]} > /dev/null 2>&1"
- system(cmd)
- else
- puts " -- #{icon[:name]} already exists"
- end
-end #end of function
+ icon_f = File.new(icon[:file], 'w+')
+ icon_f.puts svgcrop
+ icon_f.close
+ # remove as many extraneous elements as possible with SVGO
+ cmd = "#{SVGO} --pretty --disable=convertShapeToPath --disable=convertPathData
--enable=removeStyleElement -i #{icon[:file]} -o #{icon[:file]} > /dev/null 2>&1"
+ system(cmd)
+ else
+ puts " -- #{icon[:name]} already exists"
+ end
+end # end of function
-def get_output_filename(d,n)
- if (/rtl$/.match(n))
- outfile = "#{d}/#{n.chomp('-rtl')}-symbolic-rtl.svg"
- else
- outfile = "#{d}/#{n}-symbolic.svg"
- end
- return outfile
+def get_output_filename(d, n)
+ if (/rtl$/.match(n))
+ outfile = "#{d}/#{n.chomp('-rtl')}-symbolic-rtl.svg"
+ else
+ outfile = "#{d}/#{n}-symbolic.svg"
+ end
+ return outfile
end
-#main
+# main
# Open SVG file.
svg = Document.new(File.new(SRC, 'r'))
-if (ARGV[0].nil?) #render all SVGs
- puts "Rendering from icons in #{SRC}"
- # Go through every layer.
- svg.root.each_element("/svg/g[@inkscape:groupmode='layer']") do |context|
- context_name = context.attributes.get_attribute("inkscape:label").value
- puts "Going through layer '" + context_name + "'"
- context.each_element("g") do |icon|
- #puts "DEBUG #{icon.attributes.get_attribute('id')}"
- dir = "#{PREFIX}/#{context_name}"
- icon_name = icon.attributes.get_attribute("inkscape:label").value
- # prevent rendering of icons ending in :
- if icon_name.end_with?("-alt", "-old", "-template", "-source", "-ltr", "-working")
- puts " ++ skipping icon '" + icon_name + "'"
- elsif icon_name =~ /\d$/
- puts " ++ skipping icon '" + icon_name + "'"
- else
- chopSVG({ :name => icon_name,
- :id => icon.attributes.get_attribute("id"),
- :dir => dir,
- :file => get_output_filename(dir, icon_name)})
- end
- end
- end
- puts "\nrendered all SVGs"
-else #only render the icons passed
- icons = ARGV
- ARGV.each do |icon_name|
- icon = svg.root.elements["//g[@inkscape:label='#{icon_name}']"]
- if icon_name == "process-working"
- dir = "#{PREFIX32}/#{icon.parent.attributes['inkscape:label']}"
- else
- dir = "#{PREFIX}/#{icon.parent.attributes['inkscape:label']}"
- end
- chopSVG({ :name => icon_name,
- :id => icon.attributes["id"],
- :dir => dir,
- :file => get_output_filename(dir, icon_name),
- :forcerender => true})
- end
- puts "\nrendered #{ARGV.length} icons"
+if (ARGV[0].nil?) # render all SVGs
+ puts "Rendering from icons in #{SRC}"
+ # Go through every layer.
+ svg.root.each_element("/svg/g[@inkscape:groupmode='layer']") do |context|
+ context_name = context.attributes.get_attribute("inkscape:label").value
+ puts "Going through layer '" + context_name + "'"
+ context.each_element("g") do |icon|
+ # puts "DEBUG #{icon.attributes.get_attribute('id')}"
+ dir = "#{PREFIX}/#{context_name}"
+ icon_name = icon.attributes.get_attribute("inkscape:label").value
+ # prevent rendering of icons ending in :
+ if icon_name.end_with?("-alt", "-old", "-template", "-source", "-ltr", "-working")
+ puts " ++ skipping icon '" + icon_name + "'"
+ elsif icon_name =~ /\d$/
+ puts " ++ skipping icon '" + icon_name + "'"
+ else
+ chopSVG({ :name => icon_name,
+ :id => icon.attributes.get_attribute("id"),
+ :dir => dir,
+ :file => get_output_filename(dir, icon_name) })
+ end
+ end
+ end
+ puts "\nrendered all SVGs"
+else # only render the icons passed
+ icons = ARGV
+ ARGV.each do |icon_name|
+ icon = svg.root.elements["//g[@inkscape:label='#{icon_name}']"]
+ if icon_name == "process-working"
+ dir = "#{PREFIX32}/#{icon.parent.attributes['inkscape:label']}"
+ else
+ dir = "#{PREFIX}/#{icon.parent.attributes['inkscape:label']}"
+ end
+ chopSVG({ :name => icon_name,
+ :id => icon.attributes["id"],
+ :dir => dir,
+ :file => get_output_filename(dir, icon_name),
+ :forcerender => true })
+ end
+ puts "\nrendered #{ARGV.length} icons"
end
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]