Update attributeManager.py

This commit is contained in:
chrys87 2018-05-25 12:56:03 +02:00 committed by GitHub
parent 18b700f846
commit a541622870
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -41,38 +41,116 @@ class attributeManager():
)) #end attribute )) #end attribute
return attribute in defaultAttributes return attribute in defaultAttributes
def formatAttributes(self, attribute, attributeFormatString = None): def formatAttributes(self, attribute, attributeFormatString = None):
# "black",
# "red",
# "green",
# "brown",
# "blue",
# "magenta",
# "cyan",
# "white",
# "default" # white.
# _order_
# "fg",
# "bg",
# "bold",
# "italics",
# "underscore",
# "strikethrough",
# "reverse",
# "blink"
# "fontsieze"
# "fontfamily"
if not attributeFormatString: if not attributeFormatString:
attributeFormatString = self.env['runtime']['settingsManager'].getSetting('general', 'attributeFormatString') attributeFormatString = self.env['runtime']['settingsManager'].getSetting('general', 'attributeFormatString')
if not attributeFormatString: if not attributeFormatString:
return '' return ''
if attributeFormatString == '': if attributeFormatString == '':
return '' return ''
if not attribute:
return ''
if len(attribute) != 10:
return ''
# 0 FG color (name)
try: try:
attributeFormatString = attributeFormatString.replace('fenrirBGColor', self.env['runtime']['screenDriver'].getFenrirBGColor(attribute)) attributeFormatString = attributeFormatString.replace('fenrirFGColor', _(attribute[0]))
except Exception as e: except Exception as e:
pass attributeFormatString = attributeFormatString.replace('fenrirFGColor', '')
# 1 BG color (name)
try: try:
attributeFormatString = attributeFormatString.replace('fenrirFGColor', self.env['runtime']['screenDriver'].getFenrirFGColor(attribute)) attributeFormatString = attributeFormatString.replace('fenrirBGColor', _(attribute[1]))
except Exception as e: except Exception as e:
pass attributeFormatString = attributeFormatString.replace('fenrirBGColor', '')
# 2 bold (True/ False)
try: try:
attributeFormatString = attributeFormatString.replace('fenrirUnderline', self.env['runtime']['screenDriver'].getFenrirUnderline(attribute)) if attribute[2]:
attributeFormatString = attributeFormatString.replace('fenrirBold', _('bold'))
except Exception as e: except Exception as e:
pass pass
attributeFormatString = attributeFormatString.replace('fenrirBold', '')
# 3 italics (True/ False)
try: try:
attributeFormatString = attributeFormatString.replace('fenrirBold', self.env['runtime']['screenDriver'].getFenrirBold(attribute)) if attribute[3]:
attributeFormatString = attributeFormatString.replace('fenrirItalics', _('italic'))
except Exception as e: except Exception as e:
pass pass
attributeFormatString = attributeFormatString.replace('fenrirItalics', '')
# 4 underline (True/ False)
try: try:
attributeFormatString = attributeFormatString.replace('fenrirBlink', self.env['runtime']['screenDriver'].getFenrirBlink(attribute)) if attribute[4]:
attributeFormatString = attributeFormatString.replace('fenrirUnderline', _('underline'))
except Exception as e: except Exception as e:
pass pass
attributeFormatString = attributeFormatString.replace('fenrirUnderline', '')
# 5 strikethrough (True/ False)
try: try:
attributeFormatString = attributeFormatString.replace('fenrirFontSize', self.env['runtime']['screenDriver'].getFenrirFontSize(attribute)) if attribute[5]:
attributeFormatString = attributeFormatString.replace('fenrirStrikethrough', _('strikethrough'))
except Exception as e: except Exception as e:
pass pass
attributeFormatString = attributeFormatString.replace('fenrirStrikethrough', '')
# 6 reverse (True/ False)
try: try:
attributeFormatString = attributeFormatString.replace('fenrirFont', self.env['runtime']['screenDriver'].getFenrirFont(attribute)) if attribute[6]:
attributeFormatString = attributeFormatString.replace('fenrirReverse', _('reverse'))
except Exception as e: except Exception as e:
pass pass
attributeFormatString = attributeFormatString.replace('fenrirReverse', '')
# 7 blink (True/ False)
try:
if attribute[7]:
attributeFormatString = attributeFormatString.replace('fenrirBlink', _('blink'))
except Exception as e:
pass
attributeFormatString = attributeFormatString.replace('fenrirBlink', '')
# 8 font size (int/ string)
try:
try:
attributeFormatString = attributeFormatString.replace('fenrirFontSize', int(attribute[8]))
except:
pass
try:
attributeFormatString = attributeFormatString.replace('fenrirFontSize', str(attribute[8]))
except:
pass
except Exception as e:
pass
attributeFormatString = attributeFormatString.replace('fenrirFontSize', _('default'))
# 9 font family (string)
try:
attributeFormatString = attributeFormatString.replace('fenrirFont', attribute[9])
except Exception as e:
pass
attributeFormatString = attributeFormatString.replace('fenrirFont', _('default'))
return attributeFormatString return attributeFormatString