def get_PerformanceCode(doc, trialid, code=True):
    """
    Returns the performance of the monkey in the given trial either as code or
    abbreviation.

    Args:
        doc (odml.doc.BaseDocument):
            odML Document of reach-to-grasp project
        trialid (int):
            ID of wanted trial
        code (boolean):
            If True (default), integer code of trial performance is returned
            If False, abbreviation of trial performance is returned

    Returns:
        (int or string):
            performance code or abbreviation for wanted trial
    """
    def ff1(x): return x.name == 'Trial_%03i' % trialid
    sec = [s for s in doc.itersections(filter_func=ff1)][0]

    def ff2(x): return x.name == 'PerformanceCode'
    output = [p for p in sec.iterproperties(filter_func=ff2)][0].values[0]

    if code:
        return output

    else:
        def ff3(x): return x.name == 'PerformanceCodes'
        sec = [s for s in doc.itersections(filter_func=ff3)][0]

        def ff4(x): return x.name == 'pc_%i' % output
        output = [p for p in sec.iterproperties(filter_func=ff4)][0].values[0]

        return output