def getLabel(labelAttr): '''Get the label from a dot label attribute. Argument(s): labelAttr (str): Dot label attribute ''' # If it starts with a quote, then the label is between quotes : we # don't take these quotes if StringUtils.isStrBetweenDoubleQuotes(labelAttr): return labelAttr[1:-1].replace('\\n', '\n') return labelAttr
def getColor(colorAttr): '''Return the QColor of a dot color attribute. Argument(s): colorAttr (str): Color attribute ''' if StringUtils.isStrBetweenDoubleQuotes(colorAttr): # Remove double quotes colorAttr = colorAttr[1:-1].strip() # Hexa to QColor if NodeDotColorUtils.isHexaColor(colorAttr): return QColor(colorAttr) # Color name to QColor if NodeDotColorUtils.colorNameExists(colorAttr): return QColor(NodeDotColorUtils.dictColorNamesHexa[colorAttr]) # Transparent color if NodeDotColorUtils.isTransparentColor(colorAttr): return QColor(Qt.transparent) # HSV to QColor if NodeDotColorUtils.isHSVColor(colorAttr): hsv = re.findall(realNumberPattern, colorAttr) return QColor.fromHsvF(float(hsv[0]), float(hsv[1]), float(hsv[2])) # Color list if NodeDotColorUtils.isColorList(colorAttr): return QColor(Qt.black) # In this case, we can only have a color name else: if NodeDotColorUtils.colorNameExists(colorAttr): return QColor(NodeDotColorUtils.dictColorNamesHexa[colorAttr]) # Transparent color if NodeDotColorUtils.isTransparentColor(colorAttr): return QColor(Qt.transparent) # Normaly whe should never reach this case return None
def isColorValid(colorAttr): '''Return True if the dot color attribute is valid, else False. Argument(s): colorAttr (str): Color attribute ''' if StringUtils.isStrBetweenDoubleQuotes(colorAttr): # Remove double quotes colorAttr = colorAttr[1:-1].strip() # Hexa color if NodeDotColorUtils.isHexaColor(colorAttr): return True # Color name if NodeDotColorUtils.colorNameExists(colorAttr): return True # Transparent color if NodeDotColorUtils.isTransparentColor(colorAttr): return True # HSV Color if NodeDotColorUtils.isHSVColor(colorAttr): return True # Color list if NodeDotColorUtils.isColorList(colorAttr): return True # In this case, we can only have a color name else: if NodeDotColorUtils.colorNameExists(colorAttr): return True # Transparent color if NodeDotColorUtils.isTransparentColor(colorAttr): return True return False