<commit_before>from django.core.exceptions import ObjectDoesNotExist
from django.core.management.base import BaseCommand
from pos.models.user import User
from pyGE import GE


class Command(BaseCommand):
    help = 'Import crewmembers from Geekevents'

    def add_arguments(self, parser):
        parser.add_argument('--party', dest='party', nargs=1,
                            help='Party on GeekEvents')
        parser.add_argument('--username', dest='username', nargs=1,
                            help='GE API username')
        parser.add_argument('--password', dest='password', nargs=1,
                            help='GE API password')

    def handle(self, *args, **options):
        party = options['party'][0]
        username = options['username'][0]
        password = options['password'][0]

        ge = GE(
            party=party,
            user=username,
            password=password
        )

        crew = ge.get_crew()

        for id, data in crew.items():
            try:
                user = User.objects.get(card=data['user_card'])
            except ObjectDoesNotExist:
                if not data['user_card']:
                    continue
                user = User(
                    card=data['user_card'],
                    first_name=data['first_name'],
                    last_name=data['last_name'],
                    phone=data['phone'],
                    crew=data['crew'],
                    role=data['role'],
                    email=data['email'],
                    max_credit=0
                )
                user.save()
                print('Added new user {} {}'.format(data['first_name'], data['last_name']))<commit_msg>renames user to crew in ge import<commit_after>from django.core.exceptions import ObjectDoesNotExist
from django.core.management.base import BaseCommand
from pos.models.crew import Crew
from pyGE import GE


class Command(BaseCommand):
    help = 'Import crewmembers from Geekevents'

    def add_arguments(self, parser):
        parser.add_argument('--party', dest='party', nargs=1,
                            help='Party on GeekEvents')
        parser.add_argument('--username', dest='username', nargs=1,
                            help='GE API username')
        parser.add_argument('--password', dest='password', nargs=1,
                            help='GE API password')

    def handle(self, *args, **options):
        party = options['party'][0]
        username = options['username'][0]
        password = options['password'][0]

        ge = GE(
            party=party,
            user=username,
            password=password
        )

        crew = ge.get_crew()

        for id, data in crew.items():
            try:
                crew = Crew.objects.get(card=data['user_card'])
            except ObjectDoesNotExist:
                if not data['user_card']:
                    continue
                crew = Crew(
                    card=data['user_card'],
                    first_name=data['first_name'],
                    last_name=data['last_name'],
                    phone=data['phone'],
                    crew=data['crew'],
                    role=data['role'],
                    email=data['email'],
                    credit=0
                )
                crew.save()
                print('Added new user {} {}'.format(data['first_name'], data['last_name']))
{'fraction_non_alphanumeric': 0.11927144535840188, 'fraction_numerical': 0.004112808460634548, 'mean_word_length': 1.6374903175832687, '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': '2354344', 'n_tokens_mistral': 899, 'n_tokens_neox': 857, 'n_words': 187}