<commit_before>from zope.interface import Attribute
from zope.interface import Interface
from zope.interface import implements


class IPackageEvent(Interface):
    """
    An event involving a package
    """
    path = Attribute('Path to package')


class IPackageAdded(IPackageEvent):
    """
    A package is added to the repository
    """


class IPackageRemoved(IPackageEvent):
    """
    A package is removed to the repository
    """    


class PackageEvent(object):
    """
    Baseclass for pacakage events
    """
    implements(IPackageEvent)

    def __init__(self, index_manager, path):
        self.im = index_manager
        self.path = path

##     def redispatch(self):
##         self.obj.registry.notify(self, self.obj)

##     @staticmethod
##     def channel_dispatch(event):
##         """
##         Resdispatches any object event with the original event and the
##         object contained
##         """
##         event.redispatch()


class PackageAdded(PackageEvent):
    implements(IPackageAdded)

    
class PackageRemoved(PackageEvent):
    implements(IPackageRemoved)<commit_msg>delelgate pkginfo creation to event itself<commit_after>from zope.interface import Attribute
from zope.interface import Interface
from zope.interface import implements


class IPackageEvent(Interface):
    """
    An event involving a package
    """
    path = Attribute('Path to package')


class IPackageAdded(IPackageEvent):
    """
    A package is added to the repository
    """


class IPackageRemoved(IPackageEvent):
    """
    A package is removed to the repository
    """    


class PackageEvent(object):
    """
    Baseclass for pacakage events
    """
    implements(IPackageEvent)

    def __init__(self, index_manager, path=None, name=None, version=None):
        self.name = name
        self.version = version
        self.im = index_manager
        self.path = path

        if self.name is None and self.path:
            info = self.im.pkginfo_from_file(path)
            self.name = info.name
            self.version = info.version

##     def redispatch(self):
##         self.obj.registry.notify(self, self.obj)

##     @staticmethod
##     def channel_dispatch(event):
##         """
##         Resdispatches any object event with the original event and the
##         object contained
##         """
##         event.redispatch()


class PackageAdded(PackageEvent):
    implements(IPackageAdded)

    
class PackageRemoved(PackageEvent):
    implements(IPackageRemoved)
{'fraction_non_alphanumeric': 0.09590131317150816, 'fraction_numerical': 0.0, 'mean_word_length': 2.809090909090909, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6677194', 'n_tokens_mistral': 704, 'n_tokens_neox': 682, 'n_words': 186}