def parse_spec(spec, relative_to=None):
 def normalize_absolute_refs(ref):
  return strip_prefix(ref, u'//')
 spec_parts = spec.rsplit(u':', 1)
 if (len(spec_parts) == 1):
  spec_path = normalize_absolute_refs(spec_parts[0])
  target_name = os.path.basename(spec_path)
 else:
  (spec_path, target_name) = spec_parts
  if ((not spec_path) and relative_to):
   spec_path = relative_to
  spec_path = normalize_absolute_refs(spec_path)
 return (spec_path, target_name)

def parse_spec ( spec , relative_to = None ) : def normalize_absolute_refs ( ref ) : return strip_prefix ( ref , u'//' ) spec_parts = spec . rsplit ( u':' , 1 ) if ( len ( spec_parts ) == 1 ) : spec_path = normalize_absolute_refs ( spec_parts [ 0 ] ) target_name = os . path . basename ( spec_path ) else : ( spec_path , target_name ) = spec_parts if ( ( not spec_path ) and relative_to ) : spec_path = relative_to spec_path = normalize_absolute_refs ( spec_path ) return ( spec_path , target_name )
parse string with partition specification .