[Erp5-report] r40522 nicolas - /erp5/trunk/products/Formulator/Widget.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Tue Nov 23 11:24:15 CET 2010
Author: nicolas
Date: Tue Nov 23 11:24:14 2010
New Revision: 40522
URL: http://svn.erp5.org?rev=40522&view=rev
Log:
Small optimization, there no need to calculate len of dictionaries or list:
bool([]) == bool({}) == False
Modified:
erp5/trunk/products/Formulator/Widget.py
Modified: erp5/trunk/products/Formulator/Widget.py
URL: http://svn.erp5.org/erp5/trunk/products/Formulator/Widget.py?rev=40522&r1=40521&r2=40522&view=diff
==============================================================================
--- erp5/trunk/products/Formulator/Widget.py [utf8] (original)
+++ erp5/trunk/products/Formulator/Widget.py [utf8] Tue Nov 23 11:24:14 2010
@@ -260,23 +260,27 @@ class Widget:
value = value.decode('utf-8')
draw_frame_tag_name = '{%s}%s' % (DRAW_URI, 'frame')
draw_frame_node = Element(draw_frame_tag_name, nsmap=NSMAP)
- if len(attr_dict.get(draw_frame_tag_name, {})) > 0:
- draw_frame_node.attrib.update(attr_dict.get(draw_frame_tag_name, {}).pop(0))
+ draw_frame_attribute_dict = attr_dict.get(draw_frame_tag_name)
+ if draw_frame_attribute_dict:
+ draw_frame_node.attrib.update(draw_frame_attribute_dict)
draw_tag_name = '{%s}%s' % (DRAW_URI, 'text-box')
draw_node = Element(draw_tag_name, nsmap=NSMAP)
- if len(attr_dict.get(draw_tag_name, {})) > 0:
- draw_node.attrib.update(attr_dict.get(draw_tag_name, {}).pop(0))
+ fraw_tag_attribute_dict = attr_dict.get(draw_tag_name)
+ if fraw_tag_attribute_dict:
+ draw_node.attrib.update(fraw_tag_attribute_dict)
text_p_tag_name = '{%s}%s' % (TEXT_URI, 'p')
text_p_node = Element(text_p_tag_name, nsmap=NSMAP)
- if len(attr_dict.get(text_p_tag_name, {})) > 0:
- text_p_node.attrib.update(attr_dict.get(text_p_tag_name, {}).pop(0))
+ text_p_attribute_dict = attr_dict.get(text_p_tag_name)
+ if text_p_attribute_dict:
+ text_p_node.attrib.update(text_p_attribute_dict)
text_span_tag_name = '{%s}%s' % (TEXT_URI, 'span')
text_span_node = Element(text_span_tag_name, nsmap=NSMAP)
- if len(attr_dict.get(text_span_tag_name, {})) > 0:
- text_span_node.attrib.update(attr_dict.get(text_span_tag_name, {}).pop(0))
+ text_span_attribute_dict = attr_dict.get(text_span_tag_name)
+ if text_span_attribute_dict:
+ text_span_node.attrib.update(text_span_attribute_dict)
text_p_node.append(text_span_node)
draw_node.append(text_p_node)
More information about the Erp5-report
mailing list