Merge pull request #35 from seanmavley/master
.py files made PEP8 compliant & Rename of .py files.
This commit is contained in:
@@ -1,7 +1,5 @@
|
|||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
|
||||||
#
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import xml.sax
|
import xml.sax
|
||||||
@@ -14,8 +12,8 @@ SRC = 'src/gnome-shell'
|
|||||||
|
|
||||||
inkscape_process = None
|
inkscape_process = None
|
||||||
|
|
||||||
def main(SRC):
|
|
||||||
|
|
||||||
|
def main(SRC):
|
||||||
def optimize_png(png_file):
|
def optimize_png(png_file):
|
||||||
if os.path.exists(OPTIPNG):
|
if os.path.exists(OPTIPNG):
|
||||||
process = subprocess.Popen([OPTIPNG, '-quiet', '-o7', png_file])
|
process = subprocess.Popen([OPTIPNG, '-quiet', '-o7', png_file])
|
||||||
@@ -37,7 +35,10 @@ def main(SRC):
|
|||||||
output = output[1:]
|
output = output[1:]
|
||||||
|
|
||||||
def start_inkscape():
|
def start_inkscape():
|
||||||
process = subprocess.Popen([INKSCAPE, '--shell'], bufsize=0, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
|
process = subprocess.Popen(
|
||||||
|
[INKSCAPE, '--shell'], bufsize=0,
|
||||||
|
stdin=subprocess.PIPE, stdout=subprocess.PIPE
|
||||||
|
)
|
||||||
wait_for_prompt(process)
|
wait_for_prompt(process)
|
||||||
return process
|
return process
|
||||||
|
|
||||||
@@ -45,7 +46,9 @@ def main(SRC):
|
|||||||
global inkscape_process
|
global inkscape_process
|
||||||
if inkscape_process is None:
|
if inkscape_process is None:
|
||||||
inkscape_process = start_inkscape()
|
inkscape_process = start_inkscape()
|
||||||
wait_for_prompt(inkscape_process, '%s -i %s -e %s' % (icon_file, rect, output_file))
|
wait_for_prompt(inkscape_process,
|
||||||
|
'%s -i %s -e %s' % (icon_file, rect, output_file)
|
||||||
|
)
|
||||||
optimize_png(output_file)
|
optimize_png(output_file)
|
||||||
|
|
||||||
class ContentHandler(xml.sax.ContentHandler):
|
class ContentHandler(xml.sax.ContentHandler):
|
||||||
@@ -54,6 +57,7 @@ def main(SRC):
|
|||||||
LAYER = 2
|
LAYER = 2
|
||||||
OTHER = 3
|
OTHER = 3
|
||||||
TEXT = 4
|
TEXT = 4
|
||||||
|
|
||||||
def __init__(self, path, force=False, filter=None):
|
def __init__(self, path, force=False, filter=None):
|
||||||
self.stack = [self.ROOT]
|
self.stack = [self.ROOT]
|
||||||
self.inside = [self.ROOT]
|
self.inside = [self.ROOT]
|
||||||
@@ -86,13 +90,13 @@ def main(SRC):
|
|||||||
if name == "text" and ('inkscape:label' in attrs) and attrs['inkscape:label'] == 'context':
|
if name == "text" and ('inkscape:label' in attrs) and attrs['inkscape:label'] == 'context':
|
||||||
self.stack.append(self.TEXT)
|
self.stack.append(self.TEXT)
|
||||||
self.inside.append(self.TEXT)
|
self.inside.append(self.TEXT)
|
||||||
self.text='context'
|
self.text = 'context'
|
||||||
self.chars = ""
|
self.chars = ""
|
||||||
return
|
return
|
||||||
elif name == "text" and ('inkscape:label' in attrs) and attrs['inkscape:label'] == 'icon-name':
|
elif name == "text" and ('inkscape:label' in attrs) and attrs['inkscape:label'] == 'icon-name':
|
||||||
self.stack.append(self.TEXT)
|
self.stack.append(self.TEXT)
|
||||||
self.inside.append(self.TEXT)
|
self.inside.append(self.TEXT)
|
||||||
self.text='icon-name'
|
self.text = 'icon-name'
|
||||||
self.chars = ""
|
self.chars = ""
|
||||||
return
|
return
|
||||||
elif name == "rect":
|
elif name == "rect":
|
||||||
@@ -100,7 +104,6 @@ def main(SRC):
|
|||||||
|
|
||||||
self.stack.append(self.OTHER)
|
self.stack.append(self.OTHER)
|
||||||
|
|
||||||
|
|
||||||
def endElement(self, name):
|
def endElement(self, name):
|
||||||
stacked = self.stack.pop()
|
stacked = self.stack.pop()
|
||||||
if self.inside[-1] == stacked:
|
if self.inside[-1] == stacked:
|
||||||
@@ -174,4 +177,4 @@ def main(SRC):
|
|||||||
print ("Error: No such file", file)
|
print ("Error: No such file", file)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
main(SRC)
|
main(SRC)
|
@@ -11,11 +11,13 @@ SRC = os.path.join('.', 'src/gtk3')
|
|||||||
|
|
||||||
inkscape_process = None
|
inkscape_process = None
|
||||||
|
|
||||||
|
|
||||||
def optimize_png(png_file):
|
def optimize_png(png_file):
|
||||||
if os.path.exists(OPTIPNG):
|
if os.path.exists(OPTIPNG):
|
||||||
process = subprocess.Popen([OPTIPNG, '-quiet', '-o7', png_file])
|
process = subprocess.Popen([OPTIPNG, '-quiet', '-o7', png_file])
|
||||||
process.wait()
|
process.wait()
|
||||||
|
|
||||||
|
|
||||||
def wait_for_prompt(process, command=None):
|
def wait_for_prompt(process, command=None):
|
||||||
if command is not None:
|
if command is not None:
|
||||||
process.stdin.write((command+'\n').encode('utf-8'))
|
process.stdin.write((command+'\n').encode('utf-8'))
|
||||||
@@ -31,24 +33,33 @@ def wait_for_prompt(process, command=None):
|
|||||||
output += process.stdout.read(1)
|
output += process.stdout.read(1)
|
||||||
output = output[1:]
|
output = output[1:]
|
||||||
|
|
||||||
|
|
||||||
def start_inkscape():
|
def start_inkscape():
|
||||||
process = subprocess.Popen([INKSCAPE, '--shell'], bufsize=0, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
|
process = subprocess.Popen(
|
||||||
|
[INKSCAPE, '--shell'],
|
||||||
|
bufsize=0, stdin=subprocess.PIPE, stdout=subprocess.PIPE
|
||||||
|
)
|
||||||
wait_for_prompt(process)
|
wait_for_prompt(process)
|
||||||
return process
|
return process
|
||||||
|
|
||||||
|
|
||||||
def inkscape_render_rect(icon_file, rect, output_file):
|
def inkscape_render_rect(icon_file, rect, output_file):
|
||||||
global inkscape_process
|
global inkscape_process
|
||||||
if inkscape_process is None:
|
if inkscape_process is None:
|
||||||
inkscape_process = start_inkscape()
|
inkscape_process = start_inkscape()
|
||||||
wait_for_prompt(inkscape_process, '%s -i %s -e %s' % (icon_file, rect, output_file))
|
wait_for_prompt(inkscape_process,
|
||||||
|
'%s -i %s -e %s' %
|
||||||
|
(icon_file, rect, output_file))
|
||||||
optimize_png(output_file)
|
optimize_png(output_file)
|
||||||
|
|
||||||
|
|
||||||
class ContentHandler(xml.sax.ContentHandler):
|
class ContentHandler(xml.sax.ContentHandler):
|
||||||
ROOT = 0
|
ROOT = 0
|
||||||
SVG = 1
|
SVG = 1
|
||||||
LAYER = 2
|
LAYER = 2
|
||||||
OTHER = 3
|
OTHER = 3
|
||||||
TEXT = 4
|
TEXT = 4
|
||||||
|
|
||||||
def __init__(self, path, force=False, filter=None):
|
def __init__(self, path, force=False, filter=None):
|
||||||
self.stack = [self.ROOT]
|
self.stack = [self.ROOT]
|
||||||
self.inside = [self.ROOT]
|
self.inside = [self.ROOT]
|
||||||
@@ -81,13 +92,13 @@ class ContentHandler(xml.sax.ContentHandler):
|
|||||||
if name == "text" and ('inkscape:label' in attrs) and attrs['inkscape:label'] == 'context':
|
if name == "text" and ('inkscape:label' in attrs) and attrs['inkscape:label'] == 'context':
|
||||||
self.stack.append(self.TEXT)
|
self.stack.append(self.TEXT)
|
||||||
self.inside.append(self.TEXT)
|
self.inside.append(self.TEXT)
|
||||||
self.text='context'
|
self.text = 'context'
|
||||||
self.chars = ""
|
self.chars = ""
|
||||||
return
|
return
|
||||||
elif name == "text" and ('inkscape:label' in attrs) and attrs['inkscape:label'] == 'icon-name':
|
elif name == "text" and ('inkscape:label' in attrs) and attrs['inkscape:label'] == 'icon-name':
|
||||||
self.stack.append(self.TEXT)
|
self.stack.append(self.TEXT)
|
||||||
self.inside.append(self.TEXT)
|
self.inside.append(self.TEXT)
|
||||||
self.text='icon-name'
|
self.text = 'icon-name'
|
||||||
self.chars = ""
|
self.chars = ""
|
||||||
return
|
return
|
||||||
elif name == "rect":
|
elif name == "rect":
|
||||||
@@ -95,7 +106,6 @@ class ContentHandler(xml.sax.ContentHandler):
|
|||||||
|
|
||||||
self.stack.append(self.OTHER)
|
self.stack.append(self.OTHER)
|
||||||
|
|
||||||
|
|
||||||
def endElement(self, name):
|
def endElement(self, name):
|
||||||
stacked = self.stack.pop()
|
stacked = self.stack.pop()
|
||||||
if self.inside[-1] == stacked:
|
if self.inside[-1] == stacked:
|
||||||
@@ -165,5 +175,3 @@ else:
|
|||||||
else:
|
else:
|
||||||
print ("Error: No such file", file)
|
print ("Error: No such file", file)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
@@ -11,11 +11,13 @@ SRC = os.path.join('.', 'src/gtk3')
|
|||||||
|
|
||||||
inkscape_process = None
|
inkscape_process = None
|
||||||
|
|
||||||
|
|
||||||
def optimize_png(png_file):
|
def optimize_png(png_file):
|
||||||
if os.path.exists(OPTIPNG):
|
if os.path.exists(OPTIPNG):
|
||||||
process = subprocess.Popen([OPTIPNG, '-quiet', '-o7', png_file])
|
process = subprocess.Popen([OPTIPNG, '-quiet', '-o7', png_file])
|
||||||
process.wait()
|
process.wait()
|
||||||
|
|
||||||
|
|
||||||
def wait_for_prompt(process, command=None):
|
def wait_for_prompt(process, command=None):
|
||||||
if command is not None:
|
if command is not None:
|
||||||
process.stdin.write((command+'\n').encode('utf-8'))
|
process.stdin.write((command+'\n').encode('utf-8'))
|
||||||
@@ -31,24 +33,34 @@ def wait_for_prompt(process, command=None):
|
|||||||
output += process.stdout.read(1)
|
output += process.stdout.read(1)
|
||||||
output = output[1:]
|
output = output[1:]
|
||||||
|
|
||||||
|
|
||||||
def start_inkscape():
|
def start_inkscape():
|
||||||
process = subprocess.Popen([INKSCAPE, '--shell'], bufsize=0, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
|
process = subprocess.Popen(
|
||||||
|
[INKSCAPE, '--shell'], bufsize=0,
|
||||||
|
stdin=subprocess.PIPE, stdout=subprocess.PIPE
|
||||||
|
)
|
||||||
wait_for_prompt(process)
|
wait_for_prompt(process)
|
||||||
return process
|
return process
|
||||||
|
|
||||||
|
|
||||||
def inkscape_render_rect(icon_file, rect, output_file):
|
def inkscape_render_rect(icon_file, rect, output_file):
|
||||||
global inkscape_process
|
global inkscape_process
|
||||||
if inkscape_process is None:
|
if inkscape_process is None:
|
||||||
inkscape_process = start_inkscape()
|
inkscape_process = start_inkscape()
|
||||||
wait_for_prompt(inkscape_process, '--export-dpi=180 %s -i %s -e %s' % (icon_file, rect, output_file))
|
wait_for_prompt(inkscape_process,
|
||||||
|
'--export-dpi=180 %s -i %s -e %s'
|
||||||
|
% (icon_file, rect, output_file)
|
||||||
|
)
|
||||||
optimize_png(output_file)
|
optimize_png(output_file)
|
||||||
|
|
||||||
|
|
||||||
class ContentHandler(xml.sax.ContentHandler):
|
class ContentHandler(xml.sax.ContentHandler):
|
||||||
ROOT = 0
|
ROOT = 0
|
||||||
SVG = 1
|
SVG = 1
|
||||||
LAYER = 2
|
LAYER = 2
|
||||||
OTHER = 3
|
OTHER = 3
|
||||||
TEXT = 4
|
TEXT = 4
|
||||||
|
|
||||||
def __init__(self, path, force=False, filter=None):
|
def __init__(self, path, force=False, filter=None):
|
||||||
self.stack = [self.ROOT]
|
self.stack = [self.ROOT]
|
||||||
self.inside = [self.ROOT]
|
self.inside = [self.ROOT]
|
||||||
@@ -81,13 +93,13 @@ class ContentHandler(xml.sax.ContentHandler):
|
|||||||
if name == "text" and ('inkscape:label' in attrs) and attrs['inkscape:label'] == 'context':
|
if name == "text" and ('inkscape:label' in attrs) and attrs['inkscape:label'] == 'context':
|
||||||
self.stack.append(self.TEXT)
|
self.stack.append(self.TEXT)
|
||||||
self.inside.append(self.TEXT)
|
self.inside.append(self.TEXT)
|
||||||
self.text='context'
|
self.text = 'context'
|
||||||
self.chars = ""
|
self.chars = ""
|
||||||
return
|
return
|
||||||
elif name == "text" and ('inkscape:label' in attrs) and attrs['inkscape:label'] == 'icon-name':
|
elif name == "text" and ('inkscape:label' in attrs) and attrs['inkscape:label'] == 'icon-name':
|
||||||
self.stack.append(self.TEXT)
|
self.stack.append(self.TEXT)
|
||||||
self.inside.append(self.TEXT)
|
self.inside.append(self.TEXT)
|
||||||
self.text='icon-name'
|
self.text = 'icon-name'
|
||||||
self.chars = ""
|
self.chars = ""
|
||||||
return
|
return
|
||||||
elif name == "rect":
|
elif name == "rect":
|
||||||
@@ -95,7 +107,6 @@ class ContentHandler(xml.sax.ContentHandler):
|
|||||||
|
|
||||||
self.stack.append(self.OTHER)
|
self.stack.append(self.OTHER)
|
||||||
|
|
||||||
|
|
||||||
def endElement(self, name):
|
def endElement(self, name):
|
||||||
stacked = self.stack.pop()
|
stacked = self.stack.pop()
|
||||||
if self.inside[-1] == stacked:
|
if self.inside[-1] == stacked:
|
||||||
@@ -165,5 +176,3 @@ else:
|
|||||||
else:
|
else:
|
||||||
print ("Error: No such file", file)
|
print ("Error: No such file", file)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
@@ -5,17 +5,20 @@ import sys
|
|||||||
import xml.sax
|
import xml.sax
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
|
||||||
INKSCAPE = '/usr/bin/inkscape'
|
INKSCAPE = '/usr/bin/inkscape'
|
||||||
OPTIPNG = '/usr/bin/optipng'
|
OPTIPNG = '/usr/bin/optipng'
|
||||||
SRC = os.path.join('.', 'src/metacity')
|
SRC = os.path.join('.', 'src/metacity')
|
||||||
|
|
||||||
inkscape_process = None
|
inkscape_process = None
|
||||||
|
|
||||||
|
|
||||||
def optimize_png(png_file):
|
def optimize_png(png_file):
|
||||||
if os.path.exists(OPTIPNG):
|
if os.path.exists(OPTIPNG):
|
||||||
process = subprocess.Popen([OPTIPNG, '-quiet', '-o7', png_file])
|
process = subprocess.Popen([OPTIPNG, '-quiet', '-o7', png_file])
|
||||||
process.wait()
|
process.wait()
|
||||||
|
|
||||||
|
|
||||||
def wait_for_prompt(process, command=None):
|
def wait_for_prompt(process, command=None):
|
||||||
if command is not None:
|
if command is not None:
|
||||||
process.stdin.write((command+'\n').encode('utf-8'))
|
process.stdin.write((command+'\n').encode('utf-8'))
|
||||||
@@ -31,24 +34,33 @@ def wait_for_prompt(process, command=None):
|
|||||||
output += process.stdout.read(1)
|
output += process.stdout.read(1)
|
||||||
output = output[1:]
|
output = output[1:]
|
||||||
|
|
||||||
|
|
||||||
def start_inkscape():
|
def start_inkscape():
|
||||||
process = subprocess.Popen([INKSCAPE, '--shell'], bufsize=0, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
|
process = subprocess.Popen(
|
||||||
|
[INKSCAPE, '--shell'],
|
||||||
|
bufsize=0, stdin=subprocess.PIPE, stdout=subprocess.PIPE
|
||||||
|
)
|
||||||
wait_for_prompt(process)
|
wait_for_prompt(process)
|
||||||
return process
|
return process
|
||||||
|
|
||||||
|
|
||||||
def inkscape_render_rect(icon_file, rect, output_file):
|
def inkscape_render_rect(icon_file, rect, output_file):
|
||||||
global inkscape_process
|
global inkscape_process
|
||||||
if inkscape_process is None:
|
if inkscape_process is None:
|
||||||
inkscape_process = start_inkscape()
|
inkscape_process = start_inkscape()
|
||||||
wait_for_prompt(inkscape_process, '%s -i %s -e %s' % (icon_file, rect, output_file))
|
wait_for_prompt(inkscape_process,
|
||||||
|
'%s -i %s -e %s' % (icon_file, rect, output_file)
|
||||||
|
)
|
||||||
optimize_png(output_file)
|
optimize_png(output_file)
|
||||||
|
|
||||||
|
|
||||||
class ContentHandler(xml.sax.ContentHandler):
|
class ContentHandler(xml.sax.ContentHandler):
|
||||||
ROOT = 0
|
ROOT = 0
|
||||||
SVG = 1
|
SVG = 1
|
||||||
LAYER = 2
|
LAYER = 2
|
||||||
OTHER = 3
|
OTHER = 3
|
||||||
TEXT = 4
|
TEXT = 4
|
||||||
|
|
||||||
def __init__(self, path, force=False, filter=None):
|
def __init__(self, path, force=False, filter=None):
|
||||||
self.stack = [self.ROOT]
|
self.stack = [self.ROOT]
|
||||||
self.inside = [self.ROOT]
|
self.inside = [self.ROOT]
|
||||||
@@ -87,7 +99,7 @@ class ContentHandler(xml.sax.ContentHandler):
|
|||||||
elif name == "text" and ('inkscape:label' in attrs) and attrs['inkscape:label'] == 'icon-name':
|
elif name == "text" and ('inkscape:label' in attrs) and attrs['inkscape:label'] == 'icon-name':
|
||||||
self.stack.append(self.TEXT)
|
self.stack.append(self.TEXT)
|
||||||
self.inside.append(self.TEXT)
|
self.inside.append(self.TEXT)
|
||||||
self.text='icon-name'
|
self.text = 'icon-name'
|
||||||
self.chars = ""
|
self.chars = ""
|
||||||
return
|
return
|
||||||
elif name == "rect":
|
elif name == "rect":
|
||||||
@@ -95,7 +107,6 @@ class ContentHandler(xml.sax.ContentHandler):
|
|||||||
|
|
||||||
self.stack.append(self.OTHER)
|
self.stack.append(self.OTHER)
|
||||||
|
|
||||||
|
|
||||||
def endElement(self, name):
|
def endElement(self, name):
|
||||||
stacked = self.stack.pop()
|
stacked = self.stack.pop()
|
||||||
if self.inside[-1] == stacked:
|
if self.inside[-1] == stacked:
|
||||||
@@ -165,5 +176,3 @@ else:
|
|||||||
else:
|
else:
|
||||||
print ("Error: No such file", file)
|
print ("Error: No such file", file)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
@@ -11,11 +11,13 @@ SRC = os.path.join('.', 'src/unity')
|
|||||||
|
|
||||||
inkscape_process = None
|
inkscape_process = None
|
||||||
|
|
||||||
|
|
||||||
def optimize_png(png_file):
|
def optimize_png(png_file):
|
||||||
if os.path.exists(OPTIPNG):
|
if os.path.exists(OPTIPNG):
|
||||||
process = subprocess.Popen([OPTIPNG, '-quiet', '-o7', png_file])
|
process = subprocess.Popen([OPTIPNG, '-quiet', '-o7', png_file])
|
||||||
process.wait()
|
process.wait()
|
||||||
|
|
||||||
|
|
||||||
def wait_for_prompt(process, command=None):
|
def wait_for_prompt(process, command=None):
|
||||||
if command is not None:
|
if command is not None:
|
||||||
process.stdin.write((command+'\n').encode('utf-8'))
|
process.stdin.write((command+'\n').encode('utf-8'))
|
||||||
@@ -31,24 +33,33 @@ def wait_for_prompt(process, command=None):
|
|||||||
output += process.stdout.read(1)
|
output += process.stdout.read(1)
|
||||||
output = output[1:]
|
output = output[1:]
|
||||||
|
|
||||||
|
|
||||||
def start_inkscape():
|
def start_inkscape():
|
||||||
process = subprocess.Popen([INKSCAPE, '--shell'], bufsize=0, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
|
process = subprocess.Popen(
|
||||||
|
[INKSCAPE, '--shell'],
|
||||||
|
bufsize=0, stdin=subprocess.PIPE, stdout=subprocess.PIPE
|
||||||
|
)
|
||||||
wait_for_prompt(process)
|
wait_for_prompt(process)
|
||||||
return process
|
return process
|
||||||
|
|
||||||
|
|
||||||
def inkscape_render_rect(icon_file, rect, output_file):
|
def inkscape_render_rect(icon_file, rect, output_file):
|
||||||
global inkscape_process
|
global inkscape_process
|
||||||
if inkscape_process is None:
|
if inkscape_process is None:
|
||||||
inkscape_process = start_inkscape()
|
inkscape_process = start_inkscape()
|
||||||
wait_for_prompt(inkscape_process, '%s -i %s -e %s' % (icon_file, rect, output_file))
|
wait_for_prompt(inkscape_process,
|
||||||
|
'%s -i %s -e %s' % (icon_file, rect, output_file)
|
||||||
|
)
|
||||||
optimize_png(output_file)
|
optimize_png(output_file)
|
||||||
|
|
||||||
|
|
||||||
class ContentHandler(xml.sax.ContentHandler):
|
class ContentHandler(xml.sax.ContentHandler):
|
||||||
ROOT = 0
|
ROOT = 0
|
||||||
SVG = 1
|
SVG = 1
|
||||||
LAYER = 2
|
LAYER = 2
|
||||||
OTHER = 3
|
OTHER = 3
|
||||||
TEXT = 4
|
TEXT = 4
|
||||||
|
|
||||||
def __init__(self, path, force=False, filter=None):
|
def __init__(self, path, force=False, filter=None):
|
||||||
self.stack = [self.ROOT]
|
self.stack = [self.ROOT]
|
||||||
self.inside = [self.ROOT]
|
self.inside = [self.ROOT]
|
||||||
@@ -81,13 +92,13 @@ class ContentHandler(xml.sax.ContentHandler):
|
|||||||
if name == "text" and ('inkscape:label' in attrs) and attrs['inkscape:label'] == 'context':
|
if name == "text" and ('inkscape:label' in attrs) and attrs['inkscape:label'] == 'context':
|
||||||
self.stack.append(self.TEXT)
|
self.stack.append(self.TEXT)
|
||||||
self.inside.append(self.TEXT)
|
self.inside.append(self.TEXT)
|
||||||
self.text='context'
|
self.text = 'context'
|
||||||
self.chars = ""
|
self.chars = ""
|
||||||
return
|
return
|
||||||
elif name == "text" and ('inkscape:label' in attrs) and attrs['inkscape:label'] == 'icon-name':
|
elif name == "text" and ('inkscape:label' in attrs) and attrs['inkscape:label'] == 'icon-name':
|
||||||
self.stack.append(self.TEXT)
|
self.stack.append(self.TEXT)
|
||||||
self.inside.append(self.TEXT)
|
self.inside.append(self.TEXT)
|
||||||
self.text='icon-name'
|
self.text = 'icon-name'
|
||||||
self.chars = ""
|
self.chars = ""
|
||||||
return
|
return
|
||||||
elif name == "rect":
|
elif name == "rect":
|
||||||
@@ -95,7 +106,6 @@ class ContentHandler(xml.sax.ContentHandler):
|
|||||||
|
|
||||||
self.stack.append(self.OTHER)
|
self.stack.append(self.OTHER)
|
||||||
|
|
||||||
|
|
||||||
def endElement(self, name):
|
def endElement(self, name):
|
||||||
stacked = self.stack.pop()
|
stacked = self.stack.pop()
|
||||||
if self.inside[-1] == stacked:
|
if self.inside[-1] == stacked:
|
||||||
@@ -165,5 +175,3 @@ else:
|
|||||||
else:
|
else:
|
||||||
print ("Error: No such file", file)
|
print ("Error: No such file", file)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
Reference in New Issue
Block a user