Skip to content

Commit

Permalink
just code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal Kaczmarczyk committed Mar 30, 2016
1 parent 950b8ef commit cdd8b44
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 12 deletions.
17 changes: 17 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>kaSvg</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.python.pydev.PyDevBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.python.pydev.pythonNature</nature>
</natures>
</projectDescription>
8 changes: 8 additions & 0 deletions .pydevproject
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?eclipse-pydev version="1.0"?><pydev_project>
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
<path>/${PROJECT_DIR_NAME}</path>
</pydev_pathproperty>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
</pydev_project>
Binary file added __init__.pyc
Binary file not shown.
24 changes: 12 additions & 12 deletions kaSvg.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ def append(self, other):

def indRepr(self, indentLevel=0):
''' prints itself with indentation '''
render = ["%s<%s%s"%(indentStr(indentLevel), self.prefix, self.tag)]
render = ["%s<%s%s" % (indentStr(indentLevel), self.prefix, self.tag)]
lines = 1
for i, att in enumerate(self.attributes):
if att != 'text':
render.append(' %s="%s"' % (att, self.attributes[att]))
# wrap line if too long, unless it's the last element
if len(''.join(render)) > lines*80 and i < len(self.attributes)-1:
render.append("\n%s" %(indentStr(indentLevel+1)))
if len(''.join(render)) > lines * 80 and i < len(self.attributes) - 1:
render.append("\n%s" % (indentStr(indentLevel + 1)))
lines = lines + 1

if 'text' in self.attributes:
Expand All @@ -63,7 +63,7 @@ def indRepr(self, indentLevel=0):
elif self.sub_elements:
render.append(">\n")
for elem in self.sub_elements:
render.append("%s" % elem.indRepr(indentLevel+1))
render.append("%s" % elem.indRepr(indentLevel + 1))
render.append("%s</%s%s>\n" % (indentStr(indentLevel), self.prefix, self.tag))
else:
render.append("/>\n")
Expand All @@ -72,7 +72,7 @@ def indRepr(self, indentLevel=0):

def indentStr(level):
''' Global function that returns indentation string'''
return level*" "
return level * " "

class SvgWindow(XmlElement):
def __init__(self, width, height, **attributes):
Expand All @@ -96,7 +96,7 @@ def useElement(self, xlinkId, x, y, **attributes):
self.append(XmlElement("use", **attributes))

def store(self, thatfilename):
with open(thatfilename,'w') as ff:
with open(thatfilename, 'w') as ff:
ff.write(str(self))
ff.close()

Expand All @@ -115,13 +115,13 @@ def __init__(self, name, **attrList):
def indRepr(self, indentLevel=0):
render = ["%s%s {\n" % (indentStr(indentLevel), self.name)]
for att in self.attributes:
render.append("%s%s: %s;\n" % (indentStr(indentLevel+1), att, self.attributes[att]))
render.append("%s%s: %s;\n" % (indentStr(indentLevel + 1), att, self.attributes[att]))
render.append("%s}\n" % (indentStr(indentLevel)))
return ''.join(render)

def append(self, **attrList):
'''not sure if it's ok'''
#self.attributes = {self.attributes, attrList}
# self.attributes = {self.attributes, attrList}
self.attributes = dict(zip(self.attributes, attrList))

class SvgStylesContainer(XmlElement):
Expand All @@ -134,10 +134,10 @@ def append(self, _SvgStyleDefinitionEntry):
def indRepr(self, indentLevel=0):
if self.styles:
render = ["%s<style type=\"text/css\">\n" % (indentStr(indentLevel))]
render.append("%s<![CDATA[\n" % (indentStr(indentLevel+1)))
render.append("%s<![CDATA[\n" % (indentStr(indentLevel + 1)))
for styleClass in self.styles:
render.append(styleClass.indRepr(indentLevel+2))
render.append("%s]]>\n" % (indentStr(indentLevel+1)))
render.append(styleClass.indRepr(indentLevel + 2))
render.append("%s]]>\n" % (indentStr(indentLevel + 1)))
render.append("%s</style>\n" % (indentStr(indentLevel)))
return ''.join(render)
else:
Expand Down Expand Up @@ -177,4 +177,4 @@ def __repr__(self):
return "<!-- [ " + self.text + " ] -->\n"
def indRepr(self, indentLevel):
return "%s%s" % (indentStr(indentLevel), self)


Binary file modified kaSvg.pyc
Binary file not shown.

0 comments on commit cdd8b44

Please sign in to comment.