(a) No person shall operate a motor vehicle or motorcycle upon any street or highway in a weaving or zigzag course unless such irregular course is necessary for safe operation or in compliance with law.
(b) Whoever violates any provision of this section is guilty of a minor misdemeanor on a first offense; on a second offense within one year after the first offense, the person is guilty of a misdemeanor of the fourth degree; on each subsequent offense within one year after the first offense, the person is guilty of a misdemeanor of the third degree.