# Path: src/zinc/defaults.py

# 
# Path: src/zinc/pathfilter.py
# class PathFilter(object):
# 
#     class Rule(object):
#         def __init__(self, pattern, match_action):
#             assert match_action in (Match.ACCEPT, Match.REJECT)
#             self.pattern = pattern
#             self.match_action = match_action
# 
#         def match(self, path):
#             if fnmatch.fnmatch(path, self.pattern):
#                 return self.match_action
#             return Match.UNKNOWN
# 
#     def __init__(self, rules):
#         self._rules = rules
# 
#     def match(self, path):
#         """Tests the path against all rules in this filter"""
#         for rule in self._rules:
#             if rule.match(path) == Match.ACCEPT:
#                 return True
#             elif rule.match(path) == Match.REJECT:
#                 return False
#         return True
# 
#     @staticmethod
#     def from_rule_list(rule_list):
#         """Read from a dict. `version` is ignored"""
#         rules = []
#         for rule_string in rule_list:
#             rule_string = rule_string.strip()
#             rule_comps = rule_string.split()
#             match_action_string = rule_comps[0]
#             if match_action_string == '+':
#                 match_action = Match.ACCEPT
#             elif match_action_string == '-':
#                 match_action = Match.REJECT
#             else:
#                 raise ValueError("unknown match type: %s" %
#                                  (match_action_string))
#             pattern = string.join(rule_comps[1:], ' ')
#             rules.append(PathFilter.Rule(pattern, match_action))
#         return PathFilter(rules)


import json
import UserDict
import jsonschema
from functools import wraps
from pkg_resources import resource_string
from .defaults import defaults
from .pathfilter import PathFilter
            'id': self.id,
            'bundles': self._bundle_info_by_name,
            'format': self._format,
        }

    @property
    def id(self):
        return self._id

    @property
    def format(self):
        return self._format

    @classmethod
    def from_dict(cls, d, mutable=True):
        # TODO: handle format appropriately
        index = cls(id=d['id'], mutable=mutable)
        index._format = d['format']
        index._bundle_info_by_name = d['bundles']
        return index

    @classmethod
    def _load_schema(cls):
        schema_string = resource_string('zinc.resources.schemas.v1', 'catalog.json')
        return json.loads(schema_string)

    def _get_bundle_info(self, bundle_name):
        info = self._bundle_info_by_name.get(bundle_name)
        if info is not None and self.is_mutable:
            if info.get('next-version'):  # clean mispelled 'next_version' key

# Path: src/zinc/defaults.py

# 
# Path: src/zinc/pathfilter.py
# class PathFilter(object):
# 
#     class Rule(object):
#         def __init__(self, pattern, match_action):
#             assert match_action in (Match.ACCEPT, Match.REJECT)
#             self.pattern = pattern
#             self.match_action = match_action
# 
#         def match(self, path):
#             if fnmatch.fnmatch(path, self.pattern):
#                 return self.match_action
#             return Match.UNKNOWN
# 
#     def __init__(self, rules):
#         self._rules = rules
# 
#     def match(self, path):
#         """Tests the path against all rules in this filter"""
#         for rule in self._rules:
#             if rule.match(path) == Match.ACCEPT:
#                 return True
#             elif rule.match(path) == Match.REJECT:
#                 return False
#         return True
# 
#     @staticmethod
#     def from_rule_list(rule_list):
#         """Read from a dict. `version` is ignored"""
#         rules = []
#         for rule_string in rule_list:
#             rule_string = rule_string.strip()
#             rule_comps = rule_string.split()
#             match_action_string = rule_comps[0]
#             if match_action_string == '+':
#                 match_action = Match.ACCEPT
#             elif match_action_string == '-':
#                 match_action = Match.REJECT
#             else:
#                 raise ValueError("unknown match type: %s" %
#                                  (match_action_string))
#             pattern = string.join(rule_comps[1:], ' ')
#             rules.append(PathFilter.Rule(pattern, match_action))
#         return PathFilter(rules)


# Path: src/zinc/models.py
import json
import UserDict
import jsonschema
from functools import wraps
from pkg_resources import resource_string
from .defaults import defaults
from .pathfilter import PathFilter

            'id': self.id,
            'bundles': self._bundle_info_by_name,
            'format': self._format,
        }

    @property
    def id(self):
        return self._id

    @property
    def format(self):
        return self._format

    @classmethod
    def from_dict(cls, d, mutable=True):
        # TODO: handle format appropriately
        index = cls(id=d['id'], mutable=mutable)
        index._format = d['format']
        index._bundle_info_by_name = d['bundles']
        return index

    @classmethod
    def _load_schema(cls):
        schema_string = resource_string('zinc.resources.schemas.v1', 'catalog.json')
        return json.loads(schema_string)

    def _get_bundle_info(self, bundle_name):
        info = self._bundle_info_by_name.get(bundle_name)
        if info is not None and self.is_mutable:
            if info.get('next-version'):  # clean mispelled 'next_version' key

                del info['next-version']