def generate_fontconfig_pattern(d):
 props = []
 families = ''
 size = ''
 for key in 'family style variant weight stretch file size'.split():
  val = getattr(d, ('get_' + key))()
  if ((val is not None) and (val != [])):
   if (type(val) == list):
    val = [value_escape('\\\\\\1', str(x)) for x in val if (x is not None)]
    if (val != []):
     val = ','.join(val)
   props.append((':%s=%s' % (key, val)))
 return ''.join(props)

def generate_fontconfig_pattern ( d ) : props = [ ] families = '' size = '' for key in 'family style variant weight stretch file size' . split ( ) : val = getattr ( d , ( 'get_' + key ) ) ( ) if ( ( val is not None ) and ( val != [ ] ) ) : if ( type ( val ) == list ) : val = [ value_escape ( '\\\\\\1' , str ( x ) ) for x in val if ( x is not None ) ] if ( val != [ ] ) : val = ',' . join ( val ) props . append ( ( ':%s=%s' % ( key , val ) ) ) return '' . join ( props )
given a dictionary of key/value pairs .