def _traffic_crime(statute, name, level, disposition): chapter = statute[:3] if chapter.isdigit(): statute_range = [481, 482, 483] + list(range(801, 826)) chapter_num = int(chapter) if chapter_num == 813: if ChargeClassifier._is_dimissed(disposition): question_string = "Was the charge dismissed pursuant to a court-ordered diversion program?" options = {"Yes": DivertedDuii(), "No": DismissedCharge()} return ChargeClassifier._build_ambiguous_charge_type_with_question( question_string, options) else: return AmbiguousChargeTypeWithQuestion([Duii()]) if chapter_num in statute_range: if "felony" in level or "misdemeanor" in level: if ChargeClassifier._is_dimissed(disposition): return AmbiguousChargeTypeWithQuestion( [DismissedCharge()]) else: return AmbiguousChargeTypeWithQuestion( [TrafficOffense()]) else: return AmbiguousChargeTypeWithQuestion( [TrafficViolation()]) if name == "pedestrian j-walking": return AmbiguousChargeTypeWithQuestion([TrafficViolation()]) if "infraction" in level: return AmbiguousChargeTypeWithQuestion([TrafficViolation()])
def __classifications_list( self) -> Iterator[AmbiguousChargeTypeWithQuestion]: name = self.name.lower() yield ChargeClassifier._juvenile_charge(self.violation_type) yield ChargeClassifier._parking_ticket(self.violation_type) yield ChargeClassifier._fare_violation(name) yield ChargeClassifier._civil_offense(self.statute, name) yield ChargeClassifier._criminal_forfeiture(self.statute) yield ChargeClassifier._traffic_crime(self.statute, name, self.level, self.disposition) yield ChargeClassifier._marijuana_violation(name, self.level) yield ChargeClassifier._violation(self.level, name) criminal_charge = next( (c for c in ChargeClassifier._criminal_charge( self.statute, self.section, self.name, self.level, self.birth_year, self.disposition) if c), None, ) if criminal_charge and ChargeClassifier._is_dimissed(self.disposition): yield AmbiguousChargeTypeWithQuestion([DismissedCharge()]) elif criminal_charge: yield criminal_charge
charge_classes: List[Type[ChargeType]] = [] for _, module_name, _ in pkgutil.iter_modules( charge_types.__path__): # type: ignore # mypy issue #1422 module = import_module(f"{charge_types.__name__}.{module_name}") attrs = list(module.__dict__.values()) charge_subclass_attrs = list( filter(lambda attr: _is_proper_charge_subclass(attr), attrs)) charge_classes += charge_subclass_attrs return charge_classes @composite def _build_charge_strategy(draw: Callable[[SearchStrategy], Any], charge_type: ChargeType, case: CaseSummary) -> SearchStrategy[Charge]: if charge_type == DismissedCharge(): disposition_status = one_of(just(DispositionStatus.DISMISSED), just(DispositionStatus.NO_COMPLAINT), just(DispositionStatus.DIVERTED)) else: disposition_status = one_of(just(DispositionStatus.CONVICTED), just(DispositionStatus.UNRECOGNIZED)) disposition_date = just( DateWithFuture(date=draw(dates(max_value=date(9000, 12, 31))))) disposition = builds(Disposition, status=disposition_status, date=disposition_date) arrest_date = just( DateWithFuture(date=draw(dates(max_value=date(9000, 12, 31))))) probation_revoked_date = one_of( none(),