<commit_before>from PLC.Faults import *
from PLC.Method import Method
from PLC.Parameter import Parameter, Mixed
from PLC.Persons import Person, Persons
from PLC.Auth import Auth

can_update = lambda (field, value): field in \
             ['first_name', 'last_name', 'title',
              'email', 'password', 'phone', 'url', 'bio']

class AddPerson(Method):
    """
    Adds a new account. Any fields specified in person_fields are
    used, otherwise defaults are used.

    Accounts are disabled by default. To enable an account, use
    SetPersonEnabled() or UpdatePerson().

    Returns the new person_id (> 0) if successful, faults otherwise.
    """

    roles = ['admin', 'pi']

    person_fields = dict(filter(can_update, Person.fields.items()))

    accepts = [
        Auth(),
        person_fields
        ]

    returns = Parameter(int, 'New person_id (> 0) if successful')


    def call(self, auth, person_fields):
        person_fields = dict(filter(can_update, person_fields.items()))
        person = Person(self.api, person_fields)<commit_msg>- explicitly set new person['enabled'] field to False<commit_after>from PLC.Faults import *
from PLC.Method import Method
from PLC.Parameter import Parameter, Mixed
from PLC.Persons import Person, Persons
from PLC.Auth import Auth

can_update = lambda (field, value): field in \
             ['first_name', 'last_name', 'title',
              'email', 'password', 'phone', 'url', 'bio']

class AddPerson(Method):
    """
    Adds a new account. Any fields specified in person_fields are
    used, otherwise defaults are used.

    Accounts are disabled by default. To enable an account, use
    UpdatePerson().

    Returns the new person_id (> 0) if successful, faults otherwise.
    """

    roles = ['admin', 'pi']

    person_fields = dict(filter(can_update, Person.fields.items()))

    accepts = [
        Auth(),
        person_fields
        ]

    returns = Parameter(int, 'New person_id (> 0) if successful')


    def call(self, auth, person_fields):
        person_fields = dict(filter(can_update, person_fields.items()))
        person_fields['enabled'] = False
        person = Person(self.api, person_fields)
{'fraction_non_alphanumeric': 0.11156835848193873, 'fraction_numerical': 0.001828989483310471, 'mean_word_length': 3.159695817490494, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '4591483', 'n_tokens_mistral': 636, 'n_tokens_neox': 599, 'n_words': 206}