( str )
return v, u
Parse an SVG value which may or may not have units attached
  This version is greatly simplified in that it only allows: no units,
  units of px, and units of %.  Everything else, it returns None for.
  There is a more general routine to consider in scour.py if more
  generality is ever needed.
Parse an SVG value which may or may not have units attached
  This version is greatly simplified in that it only allows: no units,
  units of px, and units of %.  Everything else, it returns None for.
  There is a more general routine to consider in scour.py if more
  generality is ever needed.
Parse an SVG value which may or may not have units attached This version is greatly simplified in that it only allows : no units units of px and units of % . Everything else it returns None for . There is a more general routine to consider in scour . py if more generality is ever needed .
def parseLengthWithUnits( str ):
  '''
  Parse an SVG value which may or may not have units attached
  This version is greatly simplified in that it only allows: no units,
  units of px, and units of %.  Everything else, it returns None for.
  There is a more general routine to consider in scour.py if more
  generality is ever needed.
  '''
  u = 'px'
  s = str.strip()
  if s[-2:] == 'px':
    s = s[:-2]
  elif s[-1:] == '%':
    u = '%'
    s = s[:-1]
  try:
    v = float( s )
  except:
    return None, None
  return v, u
def parseLengthWithUnits ( str ) : u = 'px' s = str . strip ( ) if s [ - 2 : ] == 'px' : s = s [ : - 2 ] elif s [ - 1 : ] == '%' : u = '%' s = s [ : - 1 ] try : v = float ( s ) except : return None , None return v , u