### Navigation

- index
- modules |
- CCHR 1.0 documentation »
- Module code »
- src »

# Source code for src.region

    __all__ = ['regions', 'Region', 'get_region']

    regions = ['al', 'ak', 'az', 'ar', 'ca', 'co', 'ct', 'de', 'dc', 'fl', 'ga',
              'hi', 'id', 'il', 'in', 'ia', 'ks', 'ky', 'la', 'me', 'md', 'ma',
              'mi', 'mn', 'ms', 'mo', 'mt', 'ne', 'nb', 'nb|ne', 'nv', 'nh', 'nj',
              'nm', 'ny', 'nc', 'nd', 'oh', 'ok', 'or', 'pa', 'ri', 'sc', 'sd',
              'tn', 'tx', 'ut', 'vt', 'va', 'wa', 'wv', 'wi', 'wy', 'wvfbi',
              'ncic', 'unknown']

    #to apply global rules do not return a value on region function
    class Region(object):
        def __init__(self, state):
            self.state = state.lower().split('|')

        def __str__(self):
            return str(self.state)

        def priority(self):
            return 10

        def get_state(self):
            return self.state

    def get_region(region):
        region = region.lower()
        if region in regions:
            return regions[region]

        raise RuleParsingError('Unknown region: %r' % region)

    regions = dict((st, Region(st)) for st in regions)

### Navigation

- index
- modules |
- CCHR 1.0 documentation »
- Module code »
- src »