<commit_before>from pyjenkins.interfaces import IJenkins
from pyjenkins.backend.enums import HttpStatus
from pyjenkins.backend.jsonparser import JsonParser
from pyjenkins.job import Job, JobStatus

class Jenkins(IJenkins):

    def __init__(self, http, json=JsonParser()):
        """
        @type http: pyjenkins.interfaces.IHttp
        @type json: pyjenkins.interfaces.IJsonParser
        """
        self.http= http
        self.json= json
        self.statusMap = {'red':        JobStatus.FAILING,
                          'red_anime':  JobStatus.FAILING,
                          'blue':       JobStatus.OK,
                          'blue_anime': JobStatus.OK,
                          'grey':       JobStatus.UNKNOWN,
                          'grey_anime': JobStatus.UNKNOWN,
                          'disabled':   JobStatus.UNKNOWN
                          }

    def listJobs(self):
        """
        @return: list of Jobs
        @rtype: [pyjenkins.job.Job]
        """
        result= None
        jobs= self._getJsonJobs({'tree':'jobs[name,color]'})

        if jobs is not None:
            result= [Job(job['name'], self.statusMap[job['color']]) for job in jobs]

        return result

    def _getJsonJobs(self, parameters):
        result= None
        (json, status) = self.http.request('api/json', parameters)

        if status == HttpStatus.OK:
            data= self.json.parse(json)
            if 'jobs' in data:
                result= data['jobs']

        return result<commit_msg>Added all possible job colours from http://javadoc.jenkins-ci.org/hudson/model/BallColor.html<commit_after>from pyjenkins.interfaces import IJenkins
from pyjenkins.backend.enums import HttpStatus
from pyjenkins.backend.jsonparser import JsonParser
from pyjenkins.job import Job, JobStatus

class Jenkins(IJenkins):

    def __init__(self, http, json=JsonParser()):
        """
        @type http: pyjenkins.interfaces.IHttp
        @type json: pyjenkins.interfaces.IJsonParser
        """
        self.http= http
        self.json= json
        self.statusMap = {'aborted':        JobStatus.UNKNOWN,
                          'aborted_anime':  JobStatus.UNKNOWN,
                          'blue':           JobStatus.OK,
                          'blue_anime':     JobStatus.OK,
                          'disabled':       JobStatus.UNKNOWN,
                          'disabled_anime': JobStatus.UNKNOWN,
                          'grey':           JobStatus.UNKNOWN,
                          'grey_anime':     JobStatus.UNKNOWN,
                          'notbuilt':       JobStatus.UNKNOWN,
                          'notbuilt_anime': JobStatus.UNKNOWN,
                          'red':            JobStatus.FAILING,
                          'red_anime':      JobStatus.FAILING,
                          'yellow':         JobStatus.FAILING,
                          'yellow_anime':   JobStatus.FAILING,
                          }

    def listJobs(self):
        """
        @return: list of Jobs
        @rtype: [pyjenkins.job.Job]
        """
        result= None
        jobs= self._getJsonJobs({'tree':'jobs[name,color]'})

        if jobs is not None:
            result= [Job(job['name'], self.statusMap[job['color']]) for job in jobs]

        return result

    def _getJsonJobs(self, parameters):
        result= None
        (json, status) = self.http.request('api/json', parameters)

        if status == HttpStatus.OK:
            data= self.json.parse(json)
            if 'jobs' in data:
                result= data['jobs']

        return result
{'fraction_non_alphanumeric': 0.10262130507529281, 'fraction_numerical': 0.0, 'mean_word_length': 1.5750179468772434, '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': '5962951', 'n_tokens_mistral': 1005, 'n_tokens_neox': 975, 'n_words': 211}