File: generate.py

package info (click to toggle)
inkscape-open-symbols 1.2.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 10,112 kB
  • sloc: python: 22; makefile: 2
file content (56 lines) | stat: -rwxr-xr-x 1,675 bytes parent folder | download
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
56
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
    inkscapeSymbolGenerator: A inkscape symbol library generator
    Copyright (C) 2015 Xavier Julián Olmos

    See the file LICENSE for copying permission.
"""

import sys, os
import logging
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')