<commit_before>"""Dependency handling for ports."""

from __future__ import absolute_import

import collections

from .port import Port

__all__ = ['Dependent', 'Dependency']


class DependHandler(object):
    """Common declarations to both Dependent and Dependency."""

    # The type of dependencies
    BUILD   = 0
    EXTRACT = 1
    FETCH   = 2
    LIB     = 3
    RUN     = 4
    PATCH   = 5

    #: The dependencies for a given stage
    STAGE2DEPENDS = {
      Port.CONFIG:     (),
      Port.DEPEND:     (),
      Port.CHECKSUM:   (),
      Port.FETCH:      (FETCH,),
      Port.BUILD:      (EXTRACT, PATCH, LIB, BUILD),
      Port.INSTALL:    (LIB, RUN),
      Port.PACKAGE:    (),
      Port.PKGINSTALL: (LIB, RUN),
    }


class Dependent(DependHandler):
    """Tracks the dependants for a Port."""

    # The dependent status
    FAILURE  = -1  #: The port failed and/or cannot resolve dependants
    UNRESOLV = 0   #: Port does not satisfy dependants
    RESOLV   = 1   #: Dependants resolved

    def __init__(self, port):
        """Initialise the databases of dependants."""
        from ..env import flags

        DependHandler.__init__(self)
        self._dependants = [[], [], [], [], [], []]  #: All dependants
        self.port = port  #: The port whom we handle
        self.priority = port.priority
        self.propogate = True
        if flags["mode"] == "install" and port.install_status > flags["stage"]:
            self.status = Dependent.RESOLV
            # TODO: Change to actually check if we are resolved
        else:
            self.status = Dependent.UNRESOLV<commit_msg>Explicitly set the dependencies for the PACKAGE stage.<commit_after>"""Dependency handling for ports."""

from __future__ import absolute_import

import collections

from .port import Port

__all__ = ['Dependent', 'Dependency']


class DependHandler(object):
    """Common declarations to both Dependent and Dependency."""

    # The type of dependencies
    BUILD   = 0
    EXTRACT = 1
    FETCH   = 2
    LIB     = 3
    RUN     = 4
    PATCH   = 5

    #: The dependencies for a given stage
    STAGE2DEPENDS = {
      Port.CONFIG:     (),
      Port.DEPEND:     (),
      Port.CHECKSUM:   (),
      Port.FETCH:      (FETCH,),
      Port.BUILD:      (EXTRACT, PATCH, LIB, BUILD),
      Port.INSTALL:    (LIB, RUN),
      Port.PACKAGE:    (LIB, RUN),
      Port.PKGINSTALL: (LIB, RUN),
    }


class Dependent(DependHandler):
    """Tracks the dependants for a Port."""

    # The dependent status
    FAILURE  = -1  #: The port failed and/or cannot resolve dependants
    UNRESOLV = 0   #: Port does not satisfy dependants
    RESOLV   = 1   #: Dependants resolved

    def __init__(self, port):
        """Initialise the databases of dependants."""
        from ..env import flags

        DependHandler.__init__(self)
        self._dependants = [[], [], [], [], [], []]  #: All dependants
        self.port = port  #: The port whom we handle
        self.priority = port.priority
        self.propogate = True
        if flags["mode"] == "install" and port.install_status > flags["stage"]:
            self.status = Dependent.RESOLV
            # TODO: Change to actually check if we are resolved
        else:
            self.status = Dependent.UNRESOLV
{'fraction_non_alphanumeric': 0.11128095383674717, 'fraction_numerical': 0.006114338122898196, 'mean_word_length': 2.2524850894632205, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1332532', 'n_tokens_mistral': 1024, 'n_tokens_neox': 937, 'n_words': 298}