def elem_style(style_rules, cls, inherited_style):
 classes = cls.split()
 style = inherited_style.copy()
 for cls in classes:
  style.update(style_rules.get(cls, {}))
 wt = style.get(u'font-weight', None)
 pwt = inherited_style.get(u'font-weight', u'400')
 if (wt == u'bolder'):
  style[u'font-weight'] = {u'100': u'400', u'200': u'400', u'300': u'400', u'400': u'700', u'500': u'700'}.get(pwt, u'900')
 elif (wt == u'lighter'):
  style[u'font-weight'] = {u'600': u'400', u'700': u'400', u'800': u'700', u'900': u'700'}.get(pwt, u'100')
 return style

def elem_style ( style_rules , cls , inherited_style ) : classes = cls . split ( ) style = inherited_style . copy ( ) for cls in classes : style . update ( style_rules . get ( cls , { } ) ) wt = style . get ( u'font-weight' , None ) pwt = inherited_style . get ( u'font-weight' , u'400' ) if ( wt == u'bolder' ) : style [ u'font-weight' ] = { u'100' : u'400' , u'200' : u'400' , u'300' : u'400' , u'400' : u'700' , u'500' : u'700' } . get ( pwt , u'900' ) elif ( wt == u'lighter' ) : style [ u'font-weight' ] = { u'600' : u'400' , u'700' : u'400' , u'800' : u'700' , u'900' : u'700' } . get ( pwt , u'100' ) return style
find the effective style for the given element .