How to write a code upwind scheme

I want to write the upwind scheme of the picture. I tried to write a version but it seems to be wrong. Can anyone give me some suggestions? Thanks.

Below is my code

Sw1_upwind = ufl.conditional(ufl.ge(avg(lambda_w(Sw_n)*dot(w_w1, n_e)), 0), Sw_n("+"), Sw_n("-"))