def __init__(self, playerList, pointPerWin=5):
        """
        The init function of the class.
        """
        if not (all(type(n) == player for n in playerList)):
            raise TypeError("playerList is not a list of only players")
        if type(pointPerWin) != int:
            raise TypeError('pointPerWin must be an int')

        self.playerList = playerList
        self.pointPerWin = pointPerWin
        self.numPlayers = len(self.playerList)
        if (self.numPlayers % 2) != 0:
            self.playerList.append(bye())
            self.numPlayers += 1
        self.matchRec = []
        self.tournRes = None
        self.round = 1

        names = []
        for py in self.playerList:
            names.append([py.name, 0, 0, 0])
        self.winLossRec = pd.DataFrame(
            names, columns=["Player", "Wins", "Losses", "Diff"])
        self.winLossRec.set_index("Player", inplace=True)
Esempio n. 2
0
    def add_name(name):
        if name in source_names:
            names.append({
                "name": name["Name"],
                "credit": ", ".join(name["Constructed"].split(" / ")),
                "language": name["Language"],
                "languages": [
                    language
                    for language in ("Sindarin", "English", "German")
                    if name[language] == "*" and
                    language != name["Language"]
                ],
                "meaning": name["English Meaning"],
                "citations": dict(
                    (klass, sorted([
                        parse_citation(citation)
                        for citation in citations.split(", ")
                        if citation

                    ], key=citation_index)) for klass, citations in (
                        ('manual', name["Manual Citations"]),
                        ('computed_sensitive', name["Computed Case-sensitive Citations"]),
                        ('computed_insensitive', name["Computed Case-insensitive Citations"]),
                    )
                ),
                "construction": [
                    definition_html(construct)
                    for construct in name["Construction"].split("; ")
                    if construct
                ],
                "notes": markup(name["Notes"])
            })
            source_names.pop(source_names.index(name))
Esempio n. 3
0
    def testToFailure(self):
        
        names = []

        while True:
            name = self.testNames()
            if name in names:
                raise Exception("Failed after %s tries" % len(names))
            else:
                names.append(name)
Esempio n. 4
0
    def testToFailure(self):

        names = []

        while True:
            name = self.testNames()
            if name in names:
                raise Exception("Failed after %s tries" % len(names))
            else:
                names.append(name)
    def reset(self):
        """
        A method to reset the tournament.
        """
        self.matchRec = []
        self.tournRes = None
        self.round = 1

        names = []
        for py in self.playerList:
            names.append([py.name, 0, 0, 0])
        self.winLossRec = pd.DataFrame(
            names, columns=["Player", "Wins", "Losses", "Diff"])
        self.winLossRec.set_index("Player", inplace=True)
    def testPersonInsertWithAdmin(self, db, dummy_users):
        persons = []
        names = []
        testAdminPerson = Person.query.filter_by(username='******').first()
        for _ in range(10):
            data = self.generateName()
            names.append(data)
            person = Person(firstName=data[0],
                            lastName=data[1],
                            username=data[2],
                            password='******',
                            addedBy=testAdminPerson.id)
            persons.append(person)
        for person in persons:
            db.session.add(person)
        db.session.commit()
        lastHash = b'0'
        for name in names:
            testUsername = name[2]
            queryPerson = Person.query.filter_by(username=testUsername).first()
            assert queryPerson.username == testUsername
            assert queryPerson.addedBy == testAdminPerson.id
            assert queryPerson.validatePassword('password')
            assert queryPerson.password != lastHash
            lastHash = queryPerson.password

        # Attempt to create user that does not have foreign key available,
        # should fail to do so.
        fkTestPerson = Person(firstName='Alice',
                              lastName='Invalid',
                              username='******',
                              password='******',
                              roleId=3)
        with pytest.raises(IntegrityError):
            db.session.add(fkTestPerson)
            db.session.commit()
        db.session.rollback()
    def valid(self):
        logger.info("Checking if valid")
        date = self.date.get()
        names = []
        if not re.match("\d{4}-\d{2}-\d{2} \d{2}:\d{2}",date):
            self.notif_text.set("Date format must be YYYY-MM-DD hh:mm")
            logger.info("Invalid date format")
            return False
        for values in self.teams:

            if values[1] in names:
                logger.info("Duplicate player name")
                self.notif_text.set("Two players can't have the same name!")
                return False
            names.append(values[1])

            if values[1] == None or values[2] == None:

                logger.info("Invalid name or team")
                self.notif_text.set("Name and Team must be entered")
                return False
        logger.info("valid")
        self.replay_entry['headers'] = self.replay_entry['headers'][:2]+[self.name.get(),self.mapname.get(),self.date.get()]
        return True
Esempio n. 8
0
import random
import string
import names
import pandas as pd
from random import randint

#Providing number of members
n = 30


def randomString(stringLength):
    """Generate a random string of fixed length """
    letters = string.ascii_lowercase
    return ''.join(random.choice(letters) for i in range(stringLength))


names = []

for i in range(n):
    # print ("Random String is ", randomString(randint(1, 9)) )
    names.append(randomString(randint(3, 12)))

print(names)

a = np.random.randint(100000, size=n)

print(a)

df = pd.DataFrame(data={"Name": names, "Income": a})
df.to_csv("datas.csv", sep=',', index=False)