def _peeloff_pi(arg):
 for a in Add.make_args(arg):
  if (a is S.Pi):
   K = S.One
   break
  elif a.is_Mul:
   (K, p) = a.as_two_terms()
   if ((p is S.Pi) and K.is_Rational):
    break
 else:
  return (arg, S.Zero)
 m1 = ((K % S.Half) * S.Pi)
 m2 = ((K * S.Pi) - m1)
 return ((arg - m2), m2)

def _peeloff_pi ( arg ) : for a in Add . make_args ( arg ) : if ( a is S . Pi ) : K = S . One break elif a . is_Mul : ( K , p ) = a . as_two_terms ( ) if ( ( p is S . Pi ) and K . is_Rational ) : break else : return ( arg , S . Zero ) m1 = ( ( K % S . Half ) * S . Pi ) m2 = ( ( K * S . Pi ) - m1 ) return ( ( arg - m2 ) , m2 )
split arg into two parts .