Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
* Stop accessing element attributes directly (unless absolutely necessary)
* More PEP8 ish style
* And much much more
  • Loading branch information
regebro committed Oct 24, 2017
1 parent 5ff4e04 commit d62eb13
Show file tree
Hide file tree
Showing 20 changed files with 224 additions and 387 deletions.
1 change: 1 addition & 0 deletions src/shoobx/rml2odt/directive.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"""
from z3c.rml import directive


class NotImplementedDirective(directive.RMLDirective):

def process(self):
Expand Down
10 changes: 2 additions & 8 deletions src/shoobx/rml2odt/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,13 @@


RMLSTYLE_HANDLERS = {
styles.ParagraphStyle: stylesheet.RegisterParagraphStyle
styles.ParagraphStyle: stylesheet.registerParagraphStyle
}


class ColorDefinition(directive.RMLDirective):
signature = rml_document.IColorDefinition

def process(self):
kwargs = dict(self.getAttributeValues())
id = kwargs.pop('id')
colorVal = self.element.attrib.get('value')
if colorVal.startswith('#'):
setattr(reportlab.lib.colors, id, reportlab.lib.colors.HexColor(colorVal))


class RegisterTTFont(directive.RMLDirective):
signature = rml_document.IRegisterTTFont
Expand Down
3 changes: 2 additions & 1 deletion src/shoobx/rml2odt/easyliststyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#

import re, sys, os.path
sys.path.append(os.path.dirname(__file__))
from odf.style import Style, TextProperties, ListLevelProperties
from odf.text import ListStyle,ListLevelStyleNumber,ListLevelStyleBullet

Expand All @@ -42,10 +41,12 @@
SHOW_ALL_LEVELS = True
SHOW_ONE_LEVEL = False


def styleFromString(name, specifiers, delim, spacing, showAllLevels):
specArray = specifiers.split(delim)
return styleFromList( name, specArray, spacing, showAllLevels )


def styleFromList( styleName, specArray, spacing, showAllLevels):
bullet = ""
fontname = ""
Expand Down
Loading

0 comments on commit d62eb13

Please sign in to comment.