'Reads the settings from the packet_net.ini file'

def read_settings(self):

    if six.PY3:
        config = configparser.ConfigParser()
    else:
        config = configparser.SafeConfigParser()
    _ini_path_raw = os.environ.get('PACKET_NET_INI_PATH')
    if _ini_path_raw:
        packet_ini_path = os.path.expanduser(os.path.expandvars(_ini_path_raw))
    else:
        packet_ini_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'packet_net.ini')
    config.read(packet_ini_path)
    self.items_per_page = 999
    if config.has_option(ini_section, 'items_per_page'):
        config.get(ini_section, 'items_per_page')
    packet_valid_device_states = ['active', 'inactive', 'queued', 'provisioning']
    self.packet_device_states = []
    if config.has_option(ini_section, 'device_states'):
        for device_state in config.get(ini_section, 'device_states').split(','):
            device_state = device_state.strip()
            if (device_state not in packet_valid_device_states):
                continue
            self.packet_device_states.append(device_state)
    else:
        self.packet_device_states = packet_valid_device_states
    cache_dir = os.path.expanduser(config.get(ini_section, 'cache_path'))
    if (not os.path.exists(cache_dir)):
        os.makedirs(cache_dir)
    self.cache_path_cache = (cache_dir + '/ansible-packet.cache')
    self.cache_path_index = (cache_dir + '/ansible-packet.index')
    self.cache_max_age = config.getint(ini_section, 'cache_max_age')
    if config.has_option(ini_section, 'nested_groups'):
        self.nested_groups = config.getboolean(ini_section, 'nested_groups')
    else:
        self.nested_groups = False
    if config.has_option(ini_section, 'replace_dash_in_groups'):
        self.replace_dash_in_groups = config.getboolean(ini_section, 'replace_dash_in_groups')
    else:
        self.replace_dash_in_groups = True
    group_by_options = ['group_by_device_id', 'group_by_hostname', 'group_by_facility', 'group_by_project', 'group_by_operating_system', 'group_by_plan_type', 'group_by_tags', 'group_by_tag_none']
    for option in group_by_options:
        if config.has_option(ini_section, option):
            setattr(self, option, config.getboolean(ini_section, option))
        else:
            setattr(self, option, True)
    try:
        pattern_include = config.get(ini_section, 'pattern_include')
        if (pattern_include and (len(pattern_include) > 0)):
            self.pattern_include = re.compile(pattern_include)
        else:
            self.pattern_include = None
    except configparser.NoOptionError:
        self.pattern_include = None
    try:
        pattern_exclude = config.get(ini_section, 'pattern_exclude')
        if (pattern_exclude and (len(pattern_exclude) > 0)):
            self.pattern_exclude = re.compile(pattern_exclude)
        else:
            self.pattern_exclude = None
    except configparser.NoOptionError:
        self.pattern_exclude = None
    self.projects = []
    configProjects = config.get(ini_section, 'projects')
    configProjects_exclude = config.get(ini_section, 'projects_exclude')
    if (configProjects == 'all'):
        for projectInfo in self.get_projects():
            if (projectInfo.name not in configProjects_exclude):
                self.projects.append(projectInfo.name)
    else:
        self.projects = configProjects.split(',')
