def to_join(obj):
 if isinstance(obj, (tuple, list)):
  alias = None
  method = None
  if (len(obj) == 3):
   alias = obj[2]
  elif (len(obj) == 4):
   (alias, method) = (obj[2], obj[3])
  elif ((len(obj) < 2) or (len(obj) > 4)):
   raise ArgumentError('Join object can have 1 to 4 items has {}: {}'.format(len(obj), obj))
  master = to_join_key(obj[0])
  detail = to_join_key(obj[1])
  return Join(master, detail, alias, method)
 elif hasattr(obj, 'get'):
  return Join(to_join_key(obj.get('master')), to_join_key(obj.get('detail')), obj.get('alias'), obj.get('method'))
 else:
  return Join(to_join_key(obj.master), to_join_key(obj.detail), obj.alias, obj.method)

def to_join ( obj ) : if isinstance ( obj , ( tuple , list ) ) : alias = None method = None if ( len ( obj ) == 3 ) : alias = obj [ 2 ] elif ( len ( obj ) == 4 ) : ( alias , method ) = ( obj [ 2 ] , obj [ 3 ] ) elif ( ( len ( obj ) < 2 ) or ( len ( obj ) > 4 ) ) : raise ArgumentError ( 'Join object can have 1 to 4 items has {}: {}' . format ( len ( obj ) , obj ) ) master = to_join_key ( obj [ 0 ] ) detail = to_join_key ( obj [ 1 ] ) return Join ( master , detail , alias , method ) elif hasattr ( obj , 'get' ) : return Join ( to_join_key ( obj . get ( 'master' ) ) , to_join_key ( obj . get ( 'detail' ) ) , obj . get ( 'alias' ) , obj . get ( 'method' ) ) else : return Join ( to_join_key ( obj . master ) , to_join_key ( obj . detail ) , obj . alias , obj . method )
utility conversion function that will create join tuple from an anonymous tuple .