<commit_before>from PLC.Faults import *
from PLC.Method import Method
from PLC.Parameter import Parameter, Mixed
from PLC.PCUs import PCU, PCUs
from PLC.Auth import PasswordAuth

class GetPCUs(Method):
    """
    Return an array of structs containing details about PCUs. If
    pcu_id_list is specified, only the specified PCUs will be queried.

    Admin may query all PCUs. Non-admins may only query the PCUs at
    their sites.
    """

    roles = ['admin', 'pi', 'tech']

    accepts = [
        PasswordAuth(),
        [PCU.fields['pcu_id']]
        ]

    returns = [PCU.fields]

    def call(self, auth, pcu_ids = None):
	# If we are not admin, make sure to only return our own PCUs
        if 'admin' not in self.caller['roles']:
            if not pcu_ids:
                pcu_ids = []
                sites = Sites(self.api, self.caller['site_ids']).values()
                for site in sites:
                    pcu_ids = set(pcu_ids).union(site['pcu_ids'])

        pcus = PCUs(self.api, pcu_ids).values()

	# turn each pcu into a real dict
	pcus = [dict(pcu.items()) for pcu in pcus]

	return PCUs(self.api, pcu_ids).values()<commit_msg>- return the right thing<commit_after>from PLC.Faults import *
from PLC.Method import Method
from PLC.Parameter import Parameter, Mixed
from PLC.PCUs import PCU, PCUs
from PLC.Auth import PasswordAuth

class GetPCUs(Method):
    """
    Return an array of structs containing details about PCUs. If
    pcu_id_list is specified, only the specified PCUs will be queried.

    Admin may query all PCUs. Non-admins may only query the PCUs at
    their sites.
    """

    roles = ['admin', 'pi', 'tech']

    accepts = [
        PasswordAuth(),
        [PCU.fields['pcu_id']]
        ]

    returns = [PCU.fields]

    def call(self, auth, pcu_ids = None):
	# If we are not admin, make sure to only return our own PCUs
        if 'admin' not in self.caller['roles']:
            if not pcu_ids:
                pcu_ids = []
                sites = Sites(self.api, self.caller['site_ids']).values()
                for site in sites:
                    pcu_ids = set(pcu_ids).union(site['pcu_ids'])

        pcus = PCUs(self.api, pcu_ids).values()

	# turn each pcu into a real dict
	pcus = [dict(pcu.items()) for pcu in pcus]

	return pcus
{'fraction_non_alphanumeric': 0.10397553516819572, 'fraction_numerical': 0.0, 'mean_word_length': 2.4332833583208395, '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': '4785547', 'n_tokens_mistral': 767, 'n_tokens_neox': 725, 'n_words': 244}