-
Notifications
You must be signed in to change notification settings - Fork 95
/
generate.py
executable file
·55 lines (42 loc) · 1.62 KB
/
generate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
inkscapeSymbolGenerator: An Inkscape symbol library generator
Copyright (C) 2015 Xavier Julián Olmos
See the file LICENSE for copying permission.
"""
import os
from optparse import OptionParser
####Objetivo
#If select all merge all files in a single SVG and then
#If select file, clean it with SVGO
#Remove styles then
#Save
####Deberes
# Compactar el formato del script los ifs ver si existen alternativas
# Utilizar paths de python - construccion de paths pythonica.
# Utilizar el nombre del archivo.
# Buscar regex para eliminar etiquetas en cleanSVGStyles()
# Añadir contenido a un fichero.
# Migrar de OptionParser to https://docs.python.org/3/library/optparse.html
def _cleanSVGStyles(file):
print('Cleaning SVG....')
if __name__ == '__main__':
# Setup the command line arguments.
optp = OptionParser()
# Output verbosity options.
optp.add_option('-i', '--input', help='Input to generate icon, it ca be a folder', dest='input')
optp.add_option('-o', '--output', help='Output file', dest='output')
opts, args = optp.parse_args()
if opts.input and opts.output:
os.system('cat ' + opts.input + ' > ' + opts.output)
os.system('svgo ' + opts.output)
cleanSVGStyles(opts.output)
elif not opts.input and opts.output:
os.system('cat *.svg > ' + opts.output)
os.system('svgo ' + opts.output)
cleanSVGStyles(opts.output)
elif opts.input and not opts.output:
os.system('svgo ' + opts.input)
elif not opts.input and not opts.output:
optp.error('At list one value is required')