def parse(self, f, negate=False):
        """
        Parse rules from the given file-like object.  This is used both for
        `blueprintignore`(5) and for `blueprint-rules`(1).
        """
        for pattern in f:
            pattern = pattern.rstrip()

            # Comments and blank lines.
            if '' == pattern or '#' == pattern[0]:
                continue

            # Negated lines.
            if '!' == pattern[0]:
                pattern = pattern[1:]
                ignored = negate
            else:
                ignored = not negate

            # Normalize file resources, which don't need the : and type
            # qualifier, into the same format as others, like packages.
            if ':' == pattern[0]:
                try:
                    restype, pattern = pattern[1:].split(':', 2)
                except __HOLE__:
                    continue
            else:
                restype = 'file'

            # Ignore a package and its dependencies or unignore a single
            # package.  Empirically, the best balance of power and
            # granularity comes from this arrangement.  Take
            # build-esseantial's mutual dependence with dpkg-dev as an
            # example of why.
            if 'package' == restype:
                try:
                    manager, package = pattern.split('/')
                except ValueError:
                    logging.warning('invalid package rule "{0}"'.
                                    format(pattern))
                    continue
                self['package'].append((manager, package, ignored))
                if not ignored:
                    for dep in getattr(deps,
                                       manager,
                                       lambda(arg): [])(package):
                        self['package'].append((manager, dep, ignored))

            elif 'service' == restype:
                try:
                    manager, service = pattern.split('/')
                except ValueError:
                    logging.warning('invalid service rule "{0}"'.
                                    format(pattern))
                    continue
                self['service'].append((manager, service, ignored))

            # Ignore or unignore a file, glob, or directory tree.
            else:
                self[restype].append((pattern, ignored))

        return self
dataset/ETHPy150Open devstructure/blueprint/blueprint/rules.py/Rules.parse