def eventize(self, granularity):
        """ This splits the JSON information found at self.events into the
        several events. For this there are three different levels of time
        consuming actions: 1-soft, 2-medium and 3-hard.

        Level 1 provides events about commits
        Level 2 provides events about files
        Level 3 provides other events (not used so far)

        :param granularity: Levels of time consuming actions to calculate events
        :type granularity: integer

        :returns: Pandas dataframe with splitted events.
        :rtype: pandas.DataFrame
        """

        changeset = {}
        # First level granularity
        changeset[Gerrit.CHANGESET_ID] = []
        changeset[Gerrit.CHANGESET_EVENT] = []
        changeset[Gerrit.CHANGESET_DATE] = []
        changeset[Gerrit.CHANGESET_OWNER] = []
        changeset[Gerrit.CHANGESET_EMAIL] = []
        changeset[Gerrit.CHANGESET_VALUE] = []
        changeset[Gerrit.CHANGESET_REPO] = []

        events = pandas.DataFrame()

        for item in self.items:
            changeset_data = item["data"]
            if granularity >= 1:
                # Changeset submission date: filling a new event
                changeset[Gerrit.CHANGESET_ID].append(changeset_data["number"])
                changeset[Gerrit.CHANGESET_EVENT].append(Gerrit.EVENT_OPEN)
                changeset[Gerrit.CHANGESET_DATE].append(dt.fromtimestamp(int(changeset_data["createdOn"])))
                changeset[Gerrit.CHANGESET_REPO].append(changeset_data["project"])
                value = email = "notknown"
                if "name" in changeset_data["owner"].keys():
                    value = changeset_data["owner"]["name"]
                elif "username" in changeset_data["owner"].keys():
                    value = changeset_data["owner"]["username"]
                elif "email" in changeset_data["owner"].keys():
                    value = changeset_data["owner"]["email"]
                    email = changeset_data["owner"]["email"]
                changeset[Gerrit.CHANGESET_OWNER].append(value)
                changeset[Gerrit.CHANGESET_EMAIL].append(email)
                changeset[Gerrit.CHANGESET_VALUE].append(-10)

                # Adding the closing status updates (if there was any)
                if changeset_data["status"] == 'ABANDONED' or \
                   changeset_data["status"] == 'MERGED':
                    closing_date = dt.fromtimestamp(int(changeset_data["lastUpdated"]))
                    changeset[Gerrit.CHANGESET_ID].append(changeset_data["number"])
                    changeset[Gerrit.CHANGESET_EVENT].append(Gerrit.EVENT_ +
                                                             changeset_data["status"])
                    changeset[Gerrit.CHANGESET_DATE].append(closing_date)
                    changeset[Gerrit.CHANGESET_REPO].append(changeset_data["project"])
                    value = email = "notknown"
                    if "name" in changeset_data["owner"].keys():
                        value = changeset_data["owner"]["name"]
                    if "username" in changeset_data["owner"].keys():
                        value = changeset_data["owner"]["username"]
                    if "email" in changeset_data["owner"].keys():
                        value = changeset_data["owner"]["email"]
                        email = changeset_data["owner"]["email"]
                    changeset[Gerrit.CHANGESET_OWNER].append(value)
                    changeset[Gerrit.CHANGESET_EMAIL].append(email)
                    changeset[Gerrit.CHANGESET_VALUE].append(-10)

            if granularity >= 2:
                # Adding extra info about the patchsets
                for patchset in changeset_data["patchSets"]:
                    changeset[Gerrit.CHANGESET_ID].append(changeset_data["number"])
                    changeset[Gerrit.CHANGESET_EVENT].append(Gerrit.EVENT_ + "PATCHSET_SENT")
                    changeset[Gerrit.CHANGESET_DATE].append(
                        dt.fromtimestamp(int(patchset["createdOn"])))
                    changeset[Gerrit.CHANGESET_REPO].append(changeset_data["project"])
                    try:
                        email = "patchset_noname"
                        if "name" in patchset["author"].keys():
                            value = patchset["author"]["name"]
                        if "username" in patchset["author"].keys():
                            value = patchset["author"]["username"]
                        if "email" in patchset["author"].keys():
                            value = patchset["author"]["email"]
                            email = patchset["author"]["email"]
                    except KeyError:
                        value = "patchset_noname"
                    changeset[Gerrit.CHANGESET_OWNER].append(value)
                    changeset[Gerrit.CHANGESET_EMAIL].append(email)
                    changeset[Gerrit.CHANGESET_VALUE].append(-10)
                    # print (patchset)
                    if "approvals" in patchset.keys():
                        for approval in patchset["approvals"]:
                            if approval["type"] != "Code-Review":
                                continue
                            changeset[Gerrit.CHANGESET_ID].append(changeset_data["number"])
                            changeset[Gerrit.CHANGESET_EVENT].append(
                                Gerrit.EVENT_ +
                                "PATCHSET_APPROVAL_" + approval["type"])
                            changeset[Gerrit.CHANGESET_DATE].append(
                                dt.fromtimestamp(int(approval["grantedOn"])))
                            changeset[Gerrit.CHANGESET_REPO].append(changeset_data["project"])
                            email = "approval_noname"
                            if "name" in approval["by"].keys():
                                value = approval["by"]["name"]
                            elif "username" in approval["by"].keys():
                                value = approval["by"]["username"]
                            elif "email" in approval["by"].keys():
                                value = approval["by"]["email"]
                                email = approval["by"]["email"]
                            changeset[Gerrit.CHANGESET_OWNER].append(value)
                            changeset[Gerrit.CHANGESET_EMAIL].append(email)
                            changeset[Gerrit.CHANGESET_VALUE].append(int(approval["value"]))

            if granularity >= 3:
                # TDB
                pass

        # Done in this way to have an order (and not a direct cast)
        events[Gerrit.CHANGESET_ID] = changeset[Gerrit.CHANGESET_ID]
        events[Gerrit.CHANGESET_EVENT] = changeset[Gerrit.CHANGESET_EVENT]
        events[Gerrit.CHANGESET_DATE] = changeset[Gerrit.CHANGESET_DATE]
        events[Gerrit.CHANGESET_OWNER] = changeset[Gerrit.CHANGESET_OWNER]
        events[Gerrit.CHANGESET_EMAIL] = changeset[Gerrit.CHANGESET_EMAIL]
        events[Gerrit.CHANGESET_VALUE] = changeset[Gerrit.CHANGESET_VALUE]
        events[Gerrit.CHANGESET_REPO] = changeset[Gerrit.CHANGESET_REPO]

        return events
def eventize ( self , granularity ) : changeset = { } changeset [ Gerrit . CHANGESET_ID ] = [ ] changeset [ Gerrit . CHANGESET_EVENT ] = [ ] changeset [ Gerrit . CHANGESET_DATE ] = [ ] changeset [ Gerrit . CHANGESET_OWNER ] = [ ] changeset [ Gerrit . CHANGESET_EMAIL ] = [ ] changeset [ Gerrit . CHANGESET_VALUE ] = [ ] changeset [ Gerrit . CHANGESET_REPO ] = [ ] events = pandas . DataFrame ( ) for item in self . items : changeset_data = item [ "data" ] if granularity >= 1 : changeset [ Gerrit . CHANGESET_ID ] . append ( changeset_data [ "number" ] ) changeset [ Gerrit . CHANGESET_EVENT ] . append ( Gerrit . EVENT_OPEN ) changeset [ Gerrit . CHANGESET_DATE ] . append ( dt . fromtimestamp ( int ( changeset_data [ "createdOn" ] ) ) ) changeset [ Gerrit . CHANGESET_REPO ] . append ( changeset_data [ "project" ] ) value = email = "notknown" if "name" in changeset_data [ "owner" ] . keys ( ) : value = changeset_data [ "owner" ] [ "name" ] elif "username" in changeset_data [ "owner" ] . keys ( ) : value = changeset_data [ "owner" ] [ "username" ] elif "email" in changeset_data [ "owner" ] . keys ( ) : value = changeset_data [ "owner" ] [ "email" ] email = changeset_data [ "owner" ] [ "email" ] changeset [ Gerrit . CHANGESET_OWNER ] . append ( value ) changeset [ Gerrit . CHANGESET_EMAIL ] . append ( email ) changeset [ Gerrit . CHANGESET_VALUE ] . append ( - 10 ) if changeset_data [ "status" ] == 'ABANDONED' or changeset_data [ "status" ] == 'MERGED' : closing_date = dt . fromtimestamp ( int ( changeset_data [ "lastUpdated" ] ) ) changeset [ Gerrit . CHANGESET_ID ] . append ( changeset_data [ "number" ] ) changeset [ Gerrit . CHANGESET_EVENT ] . append ( Gerrit . EVENT_ + changeset_data [ "status" ] ) changeset [ Gerrit . CHANGESET_DATE ] . append ( closing_date ) changeset [ Gerrit . CHANGESET_REPO ] . append ( changeset_data [ "project" ] ) value = email = "notknown" if "name" in changeset_data [ "owner" ] . keys ( ) : value = changeset_data [ "owner" ] [ "name" ] if "username" in changeset_data [ "owner" ] . keys ( ) : value = changeset_data [ "owner" ] [ "username" ] if "email" in changeset_data [ "owner" ] . keys ( ) : value = changeset_data [ "owner" ] [ "email" ] email = changeset_data [ "owner" ] [ "email" ] changeset [ Gerrit . CHANGESET_OWNER ] . append ( value ) changeset [ Gerrit . CHANGESET_EMAIL ] . append ( email ) changeset [ Gerrit . CHANGESET_VALUE ] . append ( - 10 ) if granularity >= 2 : for patchset in changeset_data [ "patchSets" ] : changeset [ Gerrit . CHANGESET_ID ] . append ( changeset_data [ "number" ] ) changeset [ Gerrit . CHANGESET_EVENT ] . append ( Gerrit . EVENT_ + "PATCHSET_SENT" ) changeset [ Gerrit . CHANGESET_DATE ] . append ( dt . fromtimestamp ( int ( patchset [ "createdOn" ] ) ) ) changeset [ Gerrit . CHANGESET_REPO ] . append ( changeset_data [ "project" ] ) try : email = "patchset_noname" if "name" in patchset [ "author" ] . keys ( ) : value = patchset [ "author" ] [ "name" ] if "username" in patchset [ "author" ] . keys ( ) : value = patchset [ "author" ] [ "username" ] if "email" in patchset [ "author" ] . keys ( ) : value = patchset [ "author" ] [ "email" ] email = patchset [ "author" ] [ "email" ] except KeyError : value = "patchset_noname" changeset [ Gerrit . CHANGESET_OWNER ] . append ( value ) changeset [ Gerrit . CHANGESET_EMAIL ] . append ( email ) changeset [ Gerrit . CHANGESET_VALUE ] . append ( - 10 ) if "approvals" in patchset . keys ( ) : for approval in patchset [ "approvals" ] : if approval [ "type" ] != "Code-Review" : continue changeset [ Gerrit . CHANGESET_ID ] . append ( changeset_data [ "number" ] ) changeset [ Gerrit . CHANGESET_EVENT ] . append ( Gerrit . EVENT_ + "PATCHSET_APPROVAL_" + approval [ "type" ] ) changeset [ Gerrit . CHANGESET_DATE ] . append ( dt . fromtimestamp ( int ( approval [ "grantedOn" ] ) ) ) changeset [ Gerrit . CHANGESET_REPO ] . append ( changeset_data [ "project" ] ) email = "approval_noname" if "name" in approval [ "by" ] . keys ( ) : value = approval [ "by" ] [ "name" ] elif "username" in approval [ "by" ] . keys ( ) : value = approval [ "by" ] [ "username" ] elif "email" in approval [ "by" ] . keys ( ) : value = approval [ "by" ] [ "email" ] email = approval [ "by" ] [ "email" ] changeset [ Gerrit . CHANGESET_OWNER ] . append ( value ) changeset [ Gerrit . CHANGESET_EMAIL ] . append ( email ) changeset [ Gerrit . CHANGESET_VALUE ] . append ( int ( approval [ "value" ] ) ) if granularity >= 3 : pass events [ Gerrit . CHANGESET_ID ] = changeset [ Gerrit . CHANGESET_ID ] events [ Gerrit . CHANGESET_EVENT ] = changeset [ Gerrit . CHANGESET_EVENT ] events [ Gerrit . CHANGESET_DATE ] = changeset [ Gerrit . CHANGESET_DATE ] events [ Gerrit . CHANGESET_OWNER ] = changeset [ Gerrit . CHANGESET_OWNER ] events [ Gerrit . CHANGESET_EMAIL ] = changeset [ Gerrit . CHANGESET_EMAIL ] events [ Gerrit . CHANGESET_VALUE ] = changeset [ Gerrit . CHANGESET_VALUE ] events [ Gerrit . CHANGESET_REPO ] = changeset [ Gerrit . CHANGESET_REPO ] return events
This splits the JSON information found at self.events into the
        several events. For this there are three different levels of time
        consuming actions: 1-soft, 2-medium and 3-hard.

        Level 1 provides events about commits
        Level 2 provides events about files
        Level 3 provides other events (not used so far)

        :param granularity: Levels of time consuming actions to calculate events
        :type granularity: integer

        :returns: Pandas dataframe with splitted events.
        :rtype: pandas.DataFrame