Skip to content

Commit c8f7f49

Browse files
committed
Use println instead of logger which is less verbose and simpler
1 parent 7ef807b commit c8f7f49

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

svgsFolderUrl2plantUmlSprites.groovy

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
@Grab('org.apache.xmlgraphics:batik-transcoder:1.16')
44
@Grab('org.apache.xmlgraphics:batik-codec:1.16')
55

6-
import java.util.logging.Logger
76
import groovy.cli.commons.CliBuilder
87
import groovy.json.JsonSlurper
98
import net.sourceforge.plantuml.klimt.sprite.SpriteGrayLevel
@@ -26,7 +25,6 @@ final PNGS_DIR = new File('pngs')
2625
PNGS_DIR.mkdirs()
2726
final SPRITES_LISTING = new SpritesListing(new File('sprites-list.md'), PNGS_DIR)
2827

29-
def log = Logger.getLogger("script")
3028
def cli = new CliBuilder(usage: "${this.class.getSimpleName()}.groovy [options] <svgs URL>", stopAtNonOption: false, footer: "Usage example: ./${this.class.getSimpleName()}.groovy https://github.com/gilbarbara/logos/tree/master/logos")
3129
cli.s(longOpt: 'scale', args: 1, argName: 'scale', "Scale (eg: 0.5 to reduce size to half) of generated sprites. Default value: $DEFAULT_SCALE")
3230
cli.c(longOpt: 'use-cache', "When specified, already downloaded files are not re-downloaded")
@@ -46,25 +44,24 @@ def svgsUrl = options.arguments()[0]
4644
def scaleFactor = options.s ?: DEFAULT_SCALE
4745
def useCache = options.c
4846

49-
listSvgsUrls(svgsUrl, log)
47+
listSvgsUrls(svgsUrl)
5048
.collect {
51-
downloadFile(it, TMP_DIR, useCache, log)
49+
downloadFile(it, TMP_DIR, useCache)
5250
}
5351
.collect {
54-
svg2Png(it, PNGS_DIR, log)
52+
svg2Png(it, PNGS_DIR)
5553
}
5654
.collect {
5755
scaleImage(it, scaleFactor)
5856
}
5957
.collect {
60-
png2PlantUmlSprite(it, SPRITES_DIR, log)
58+
png2PlantUmlSprite(it, SPRITES_DIR)
6159
}
6260
.each {
6361
SPRITES_LISTING.addSprite(it)
6462
}
6563

66-
static def listSvgsUrls(baseUrl, log) {
67-
log.info("Getting SVGs list ...")
64+
static def listSvgsUrls(baseUrl) {
6865
def matcher = baseUrl =~ /^https:\/\/github.com\/([^\/]+)\/([^\/]+)\/tree\/(.*)$/
6966
if (!matcher.matches()) {
7067
throw new IllegalArgumentException("Provided URL is not a GitHub folder URL")
@@ -96,8 +93,8 @@ static def getUrlJson(url) {
9693
.parseText(new URL(url).text)
9794
}
9895

99-
static def downloadFile(url, workDir, useCache, log) {
100-
log.info("Downloading ${url} ...")
96+
static def downloadFile(url, workDir, useCache) {
97+
println("Downloading ${url} ...")
10198
def fileName = Paths.get(new URI(url).path).fileName
10299
def svgFile = new File("$workDir/${fileName}")
103100
if (useCache && svgFile.exists()) {
@@ -108,8 +105,8 @@ static def downloadFile(url, workDir, useCache, log) {
108105
return svgFile
109106
}
110107

111-
static def svg2Png(svg, workDir, log) {
112-
log.info("Converting ${svg} to png ...")
108+
static def svg2Png(svg, workDir) {
109+
println("Converting ${svg} to png ...")
113110
def fileName = svg.name.replace(".svg",".png")
114111
def pngFile = new File("$workDir/$fileName")
115112
pngFile.delete()
@@ -135,8 +132,8 @@ static def scaleImage(png, scaleFactor) {
135132
return png
136133
}
137134

138-
static def png2PlantUmlSprite(png, outputDir, log) {
139-
log.info("Converting ${png} to puml ...")
135+
static def png2PlantUmlSprite(png, outputDir) {
136+
println("Converting ${png} to puml ...")
140137
BufferedImage im = ImageIO.read(png)
141138
removeAlpha(im)
142139
String spriteName = png.name.replace(".png","")

0 commit comments

Comments
 (0)