Ejemplo n.º 1
0
def create_user():
    person = mimesis.Generic().person
    return User(
        username=person.username(),
        first_name=person.first_name(),
        last_name=person.last_name(),
        middle_name=person.surname(),
    )
Ejemplo n.º 2
0
def create_note(tags: t.List[Tag] = None) -> Note:
    if tags is None:
        tags = []
    text = mimesis.Generic().text
    return Note(
        summary=text.title(),
        content=text.text(),
        tags=tags,
        author=create_user()
    )
Ejemplo n.º 3
0
def csv_5mb():
    import mimesis
    buf, chunks = None, []
    limit = 5 * 1024 * 1024
    while sys.getsizeof(buf) <= limit:
        g = mimesis.Generic()
        chunk = "\n".join(("{},{}".format(g.person.full_name(),
                                          g.person.email())
                           for _ in range(10000)))
        chunks.append(chunk)
        buf = ''.join(chunks)

    yield buf[len(chunk):limit]
Ejemplo n.º 4
0
def generic(request):
    return mimesis.Generic(request.param)
Ejemplo n.º 5
0
from ssms.models import ProductIngredient, OrderProduct, Ingredient, Client, Product, Admin, Order

import random

import mimesis

provider = mimesis.Generic()
provider.add_provider(mimesis.Personal)
provider.add_provider(mimesis.Food)
provider.add_provider(mimesis.Numbers)
provider.add_provider(mimesis.Text)


def get_random_ingredients(amount):
    ingredients = Ingredient.get_all()
    return random.sample(ingredients, amount)


def get_random_ingredient():
    ingredients = Ingredient.get_all()
    return random.choice(ingredients)


def get_random_products(amount):
    products = Product.get_all()
    return random.sample(products, amount)


def get_random_product():
    products = Product.get_all()
    return random.choice(products)
Ejemplo n.º 6
0
from datetime import datetime, timedelta
from pathlib import Path
from uuid import UUID

import mimesis
import random

from PyQt5.QtGui import QColor
from mycartable.defaults.matiere import (
    MATIERE_GROUPE_BASE,
    MATIERES_BASE,
)
from pony.orm import db_session, flush, Database

#
gen = mimesis.Generic("fr")
#
class Faker:
    def __init__(self, db: Database):
        self.db = db
        self.tmpdir = Path(tempfile.gettempdir()) / "mkdbdev"
        self.tmpdir.mkdir(exist_ok=True)

    def f_datetime(self, start=None, end=None, **kwargs):
        end = end or datetime.utcnow()
        start = start or end - timedelta(days=400)
        now = datetime.now()
        while True:
            res = gen.datetime.datetime(start=start.year, end=now.year + 1)
            if start < res <= end:
                return res
Ejemplo n.º 7
0
import random
import mimesis

#make red recessive in the future
colors = ['grey', 'white', 'blue', 'black', 'red']
patterns = ['bar', 'barless', 'tchecker', 'checker']
langofnames = ['en']


class pigeon:
    def __init__(self, color1, color2, wingpattern, namey):
        self.color1 = color1
        self.color2 = color2
        self.pattern = wingpattern
        self.name = namey


data = mimesis.Generic('en')
x = pigeon(colors[random.randrange(0, len(colors))],
           colors[random.randrange(0, len(colors))],
           patterns[random.randrange(0, len(patterns))],
           data.personal.full_name())
print('a {} {} pigeon with {} {} pattern, named {}'.format(
    data.personal.gender(0, 1), x.color1, x.color2, x.pattern, x.name))
print('they have this to say: \n\n{}: {}'.format(x.name, data.text.quote()))
print('they drive a {} {}'.format(data.datetime.year(1935, 2018),
                                  data.transport.car()))
print('{} runs {}'.format(x.name, data.business.company()))
Ejemplo n.º 8
0
    engine = sqlalchemy.create_engine(app.settings.database.uri)
    connection = engine.connect()
    connection.execute("select")

    sqlalchemy.orm.configure_mappers()

    print(80 * "=")
    input("press Enter to drop and create the database...")

    db_metadata.drop_all()
    db_metadata.create_all()

    s = Session()

    gen_de = mimesis.Generic('de')

    department_pps = Department(name='Piratenpartei Schweiz')
    department_zs = Department(name='Zentralschweiz')
    department_ppd = Department(name='Piratenpartei Deutschland')

    subject_area_pps_in = SubjectArea(name='Innerparteiliches',
                                      department=department_pps)
    subject_area_zs_in = SubjectArea(name='Innerparteiliches',
                                     department=department_zs)
    subject_area_pps_pol = SubjectArea(name='Politik',
                                       department=department_pps)
    subject_area_ppd_allg = SubjectArea(name='Allgemein',
                                        department=department_ppd)

    ug1 = Group(name="Deppengruppe")
Ejemplo n.º 9
0
from fastapi import FastAPI
from pydantic import BaseModel
import pika
from os import environ
import mimesis
import json

gen = mimesis.Generic()


class Object(BaseModel):
    id: int
    name: str
    content: str


app = FastAPI()

EXCHANGE = "ebs"


@app.get('/health')
def health_check():
    return "Ready"


@app.get("/objects/{object_id}")
def get_object(object_id: int) -> Object:
    return Object(id=object_id, name="dump", content="lorem?")