Ejemplo n.º 1
0
def generate_menu_items(amount):
    date = Datetime()
    food = Food()
    business = Business()
    text = Text()
    code = Code()
    num = Numbers()

    model = "core.menuitem"
    items = []
    count = 1

    for _ in range(amount):
        fields = {"created": date.datetime(), "modified": date.datetime(), "title": food.dish()}
        fields["slug"] = f'{fields["title"].replace(" ", "-")}-{code.issn()}'
        fields["content"] = text.quote()
        fields["price"] = num.between(1, 100)
        fields["category"] = None
        fields["draft"] = False

        single = {
            "model": model,
            "pk": count,
            "fields": fields
        }

        count += 1
        items.append(single)

    with open("menu.json", "w") as f:
        json.dump(items, f, cls=DjangoJSONEncoder)
Ejemplo n.º 2
0
def generate_menu():
    g = Food('et')
    b = Business('et')
    for _ in range(7):
        cat = MenuItemCategory()
        cat.title = g.dish()
        cat.save()
        for _ in range(10):
            m = MenuItem()
            m.title = g.dish()
            m.price = randint(2, 9)
            m.category = cat
            m.save()
Ejemplo n.º 3
0
def generate_initial_date(obs=50):
    data = []
    for i in range(1, obs):
        in_stock = random.choice([True, False])
        item = {
            'id': i,
            'name': random.choice([Food().fruit(),
                                   Food().vegetable()]),
            'in_stock': in_stock,
            'quantity': random.randint(1, 20) if in_stock else 0,
            'price': round(random.uniform(0.89, 3.99), 2)
        }
        data.append(item)
    return data
Ejemplo n.º 4
0
def generate_medicines(kit_name: str, quantity: int = 15) -> None:
    kit = Kit.objects.filter(name=kit_name).first()

    if not kit:
        user = get_user_model().objects.create(username=Person().username())
        kit = Kit(name=kit_name, user=user)
        kit.save()

    print(f'Creating {quantity} fake medicines')

    for _ in range(quantity):
        Medication.objects.create(
            name=Food().fruit(),
            description=Text().title(),
            expiration_date=Datetime().date(start=2015, end=2025),
            kit=kit,
        )

    return None
Ejemplo n.º 5
0
def generate_drugs(kit_name: str, quantity: int = 15) -> None:
    kit = Kit.objects.filter(name=kit_name).first()

    if not kit:
        kit = Kit(name=kit_name)
        kit.save()

    for _ in range(quantity):
        drug = Drug(
            name=Food().fruit(),
            description=Text().title(),
            expiration_date=Datetime().date(start=2015, end=2025),
            kit=kit,
        )

        drug.save()

    print(f'Created {quantity} fake drugs')

    return None
Ejemplo n.º 6
0
    def ii_push_record(self, in_record: object) -> bool:
        """
        Responsible for pushing records out.
        Called when an input record is being sent to the plugin.
        :param in_record: The data for the incoming record.
        :return: False if there's a downstream error, or if there's an error with the field name, otherwise True.
        """

        if not self.parent.is_initialized:
            return False

        #create the new fields
        record_value = None
        for field in enumerate(self.record_info_out):
            if field[1].name == 'address_full_address':
                mimesis_object = Address(self.parent.Locale)
                record_value = mimesis_object.address()
            if field[1].name == 'address_coordinates':
                mimesis_object = Address(self.parent.Locale)
                record_value = str(mimesis_object.coordinates())
            if field[1].name == 'address_country':
                mimesis_object = Address(self.parent.Locale)
                record_value = mimesis_object.country()
            if field[1].name == 'address_postal_code':
                mimesis_object = Address(self.parent.Locale)
                record_value = mimesis_object.postal_code()
            if field[1].name == 'code_imei':
                mimesis_object = Code(self.parent.Locale)
                record_value = mimesis_object.imei()
            if field[1].name == 'code_isbn':
                mimesis_object = Code(self.parent.Locale)
                record_value = mimesis_object.isbn()
            if field[1].name == 'code_pin':
                mimesis_object = Code(self.parent.Locale)
                record_value = mimesis_object.pin()
            if field[1].name == 'food_dish':
                mimesis_object = Food(self.parent.Locale)
                record_value = mimesis_object.dish()
            if field[1].name == 'food_fruit':
                mimesis_object = Food(self.parent.Locale)
                record_value = mimesis_object.fruit()
            if field[1].name == 'food_vegetables':
                mimesis_object = Food(self.parent.Locale)
                record_value = mimesis_object.vegetable()
            '''if field[1].name == 'game_gaming_platform':
                mimesis_object = Games(self.parent.Locale)
                record_value = mimesis_object.gaming_platform()
            if field[1].name == 'game_titles':
                mimesis_object = Games(self.parent.Locale)
                record_value = mimesis_object.game()'''
            if field[1].name == 'person_blood_type':
                mimesis_object = Person(self.parent.Locale)
                record_value = mimesis_object.blood_type()
            if field[1].name == 'person_email':
                mimesis_object = Person(self.parent.Locale)
                record_value = mimesis_object.email()
            if field[1].name == 'person_full_name':
                mimesis_object = Person(self.parent.Locale)
                record_value = mimesis_object.full_name()
            if field[1].name == 'person_nationality':
                mimesis_object = Person(self.parent.Locale)
                record_value = mimesis_object.nationality()
            if field[1].name == 'person_occupation':
                mimesis_object = Person(self.parent.Locale)
                record_value = mimesis_object.occupation()
            if field[1].name == 'person_telephone':
                mimesis_object = Person(self.parent.Locale)
                record_value = mimesis_object.telephone()
            if field[1].name == 'science_atomic_number':
                mimesis_object = Science(self.parent.Locale)
                record_value = str(mimesis_object.atomic_number())
            if field[1].name == 'science_chemical_element':
                mimesis_object = Science(self.parent.Locale)
                record_value = mimesis_object.chemical_element()
            if field[1].name == 'transport_airplane':
                mimesis_object = Transport(self.parent.Locale)
                record_value = mimesis_object.airplane()
            if field[1].name == 'transport_car':
                mimesis_object = Transport(self.parent.Locale)
                record_value = mimesis_object.car()
            if field[1].name == 'transport_truck':
                mimesis_object = Transport(self.parent.Locale)
                record_value = mimesis_object.truck()
            if field[1].name == 'transport_vehicle_reg_code':
                mimesis_object = Transport(self.parent.Locale)
                record_value = mimesis_object.vehicle_registration_code()
                #pdb.set_trace()
            self.record_info_out[field[0]].set_from_string(self.record_creator, record_value)
        out_record = self.record_creator.finalize_record()
        #self.parent.output_anchor.push_record(out_record, False)
        self.record_creator.reset()


        # Copy the data from the incoming record into the outgoing record.
        self.record_creator.reset()
        self.record_copier.done_adding()
        self.record_copier.copy(self.record_creator, in_record)

        # Push the record downstream and quit if there's a downstream error.
        if not self.parent.output_anchor.push_record(out_record):
            return False

        return True
Ejemplo n.º 7
0
    def pi_push_all_records(self, n_record_limit: int) -> bool:
        """
        Called when a tool has no incoming data connection.
        :param n_record_limit: Set it to <0 for no limit, 0 for no records, and >0 to specify the number of records.
        :return: True for success, False for failure.
        """

        if not self.is_initialized:
            return False

        # Save a reference to the RecordInfo passed into this function in the global namespace, so we can access it later.
        record_info_out = Sdk.RecordInfo(self.alteryx_engine)

        # Adds the new field to the record.
        for field in self.column_name:
            self.output_field = record_info_out.add_field(field, self.output_type, size=self.field_size)

        # Lets the downstream tools know what the outgoing record metadata will look like, based on record_info_out.
        self.output_anchor.init(record_info_out)
        # Creating a new, empty record creator based on record_info_out's record layout.
        record_creator = record_info_out.construct_record_creator()

        #import pdb; pdb.set_trace()

        #sophs code:
        for record in range(self.record_limit):
            for field in enumerate(record_info_out):
                if field[1].name == 'address_full_address':
                    mimesis_object = Address(self.Locale)
                    record_value = mimesis_object.address()
                if field[1].name == 'address_coordinates':
                    mimesis_object = Address(self.Locale)
                    record_value = str(mimesis_object.coordinates())
                if field[1].name == 'address_country':
                    mimesis_object = Address(self.Locale)
                    record_value = mimesis_object.country()
                if field[1].name == 'address_postal_code':
                    mimesis_object = Address(self.Locale)
                    record_value = mimesis_object.postal_code()
                if field[1].name == 'code_imei':
                    mimesis_object = Code(self.Locale)
                    record_value = mimesis_object.imei()
                if field[1].name == 'code_isbn':
                    mimesis_object = Code(self.Locale)
                    record_value = mimesis_object.isbn()
                if field[1].name == 'code_pin':
                    mimesis_object = Code(self.Locale)
                    record_value = mimesis_object.pin()
                if field[1].name == 'food_dish':
                    mimesis_object = Food(self.Locale)
                    record_value = mimesis_object.dish()
                if field[1].name == 'food_fruit':
                    mimesis_object = Food(self.Locale)
                    record_value = mimesis_object.fruit()
                if field[1].name == 'food_vegetables':
                    mimesis_object = Food(self.Locale)
                    record_value = mimesis_object.vegetable()
                '''if field[1].name == 'game_gaming_platform':
                    mimesis_object = Games(self.Locale)
                    record_value = mimesis_object.gaming_platform()
                if field[1].name == 'game_titles':
                    mimesis_object = Games(self.Locale)
                    record_value = mimesis_object.game()'''
                if field[1].name == 'person_blood_type':
                    mimesis_object = Person(self.Locale)
                    record_value = mimesis_object.blood_type()
                if field[1].name == 'person_email':
                    mimesis_object = Person(self.Locale)
                    record_value = mimesis_object.email()
                if field[1].name == 'person_full_name':
                    mimesis_object = Person(self.Locale)
                    record_value = mimesis_object.full_name()
                if field[1].name == 'person_nationality':
                    mimesis_object = Person(self.Locale)
                    record_value = mimesis_object.nationality()
                if field[1].name == 'person_occupation':
                    mimesis_object = Person(self.Locale)
                    record_value = mimesis_object.occupation()
                if field[1].name == 'person_telephone':
                    mimesis_object = Person(self.Locale)
                    record_value = mimesis_object.telephone()
                if field[1].name == 'science_atomic_number':
                    mimesis_object = Science(self.Locale)
                    record_value = str(mimesis_object.atomic_number())
                if field[1].name == 'science_chemical_element':
                    mimesis_object = Science(self.Locale)
                    record_value = mimesis_object.chemical_element()
                if field[1].name == 'transport_airplane':
                    mimesis_object = Transport(self.Locale)
                    record_value = mimesis_object.airplane()
                if field[1].name == 'transport_car':
                    mimesis_object = Transport(self.Locale)
                    record_value = mimesis_object.car()
                if field[1].name == 'transport_truck':
                    mimesis_object = Transport(self.Locale)
                    record_value = mimesis_object.truck()
                if field[1].name == 'transport_vehicle_reg_code':
                    mimesis_object = Transport(self.Locale)
                    record_value = mimesis_object.vehicle_registration_code()
                record_info_out[field[0]].set_from_string(record_creator, record_value)
            out_record = record_creator.finalize_record()
            self.output_anchor.push_record(out_record, False)
            record_creator.reset()


        # Make sure that the output anchor is closed.
        self.output_anchor.close()
        return True
Ejemplo n.º 8
0
    def ii_push_record(self, in_record: object) -> bool:
        """
        Responsible for pushing records out.
        Called when an input record is being sent to the plugin.
        :param in_record: The data for the incoming record.
        :return: False if there's a downstream error, or if there's an error with the field name, otherwise True.
        """

        if not self.parent.is_initialized:
            return False

        #create the new fields
        record_value = None
        for field in enumerate(self.record_info_out):
            if field[1].name == 'number_float':
                mimesis_object = Numbers()
                record_value = str(
                    mimesis_object.float_number(end=10000, precision=6))
            if field[1].name == 'number_float_positive':
                mimesis_object = Numbers()
                record_value = str(
                    mimesis_object.float_number(start=0,
                                                end=10000,
                                                precision=6))
            if field[1].name == 'number_int':
                mimesis_object = Numbers()
                record_value = str(
                    mimesis_object.integer_number(start=-32767, end=32767))
            if field[1].name == 'number_int_positive':
                mimesis_object = Numbers()
                record_value = str(
                    mimesis_object.integer_number(start=0, end=32767))
            if field[1].name == 'address_street_address':
                mimesis_object = Address(self.Locale)
                record_value = mimesis_object.address()
            if field[1].name == 'address_coordinates':
                mimesis_object = Address(self.Locale)
                record_value = str(mimesis_object.coordinates())
            if field[1].name == 'address_country':
                mimesis_object = Address(self.Locale)
                record_value = mimesis_object.country(allow_random=True)
            if field[1].name == 'address_postal_code':
                mimesis_object = Address(self.Locale)
                record_value = mimesis_object.postal_code()
            if field[1].name == 'code_imei':
                mimesis_object = Code()
                record_value = mimesis_object.imei()
            if field[1].name == 'code_isbn':
                mimesis_object = Code()
                record_value = mimesis_object.isbn()
            if field[1].name == 'code_pin':
                mimesis_object = Code()
                record_value = mimesis_object.pin()
            if field[1].name == 'food_dish':
                mimesis_object = Food(self.Locale)
                record_value = mimesis_object.dish()
            if field[1].name == 'food_fruit':
                mimesis_object = Food(self.Locale)
                record_value = mimesis_object.fruit()
            if field[1].name == 'food_vegetables':
                mimesis_object = Food(self.Locale)
                record_value = mimesis_object.vegetable()
            if field[1].name == 'internet_url':
                mimesis_object = Internet()
                record_value = mimesis_object.home_page()
            if field[1].name == 'internet_ipv4':
                mimesis_object = Internet()
                record_value = mimesis_object.ip_v4()
            if field[1].name == 'internet_mac':
                mimesis_object = Internet()
                record_value = mimesis_object.mac_address()
            if field[1].name == 'person_blood_type':
                mimesis_object = Person(self.Locale)
                record_value = mimesis_object.blood_type()
            if field[1].name == 'person_email':
                mimesis_object = Person(self.Locale)
                record_value = mimesis_object.email()
            if field[1].name == 'person_full_name':
                mimesis_object = Person(self.Locale)
                record_value = mimesis_object.full_name()
            if field[1].name == 'person_nationality':
                mimesis_object = Person(self.Locale)
                record_value = mimesis_object.nationality()
            if field[1].name == 'person_occupation':
                mimesis_object = Person(self.Locale)
                record_value = mimesis_object.occupation()
            if field[1].name == 'person_telephone':
                mimesis_object = Person(self.Locale)
                record_value = mimesis_object.telephone()
            if field[1].name == 'science_atomic_number':
                mimesis_object = Science(self.Locale)
                record_value = str(mimesis_object.atomic_number())
            if field[1].name == 'science_chemical_element':
                mimesis_object = Science(self.Locale)
                record_value = mimesis_object.chemical_element()
            if field[1].name == 'transport_airplane':
                mimesis_object = Transport()
                record_value = mimesis_object.airplane()
            if field[1].name == 'transport_car':
                mimesis_object = Transport()
                record_value = mimesis_object.car()
            if field[1].name == 'transport_truck':
                mimesis_object = Transport()
                record_value = mimesis_object.truck()
            if field[1].name == 'transport_vehicle_reg_code':
                mimesis_object = Transport()
                record_value = mimesis_object.vehicle_registration_code()
            if field[1].name == 'business_company_name':
                mimesis_object = Business()
                record_value = mimesis_object.company()
            if field[1].name == 'business_company_type':
                mimesis_object = Business()
                record_value = mimesis_object.company_type()
            if field[1].name == 'file_filename':
                mimesis_object = File()
                record_value = mimesis_object.file_name()
            if field[1].name == 'file_file_extension':
                mimesis_object = File()
                record_value = mimesis_object.extension()
            if field[1].name == 'file_mime_type':
                mimesis_object = File()
                record_value = mimesis_object.mime_type()
            if field[1].name == 'file_size':
                mimesis_object = File()
                record_value = mimesis_object.size()
            self.record_info_out[field[0]].set_from_string(
                self.record_creator, record_value)
        out_record = self.record_creator.finalize_record()
        #self.parent.output_anchor.push_record(out_record, False)
        self.record_creator.reset()

        # Copy the data from the incoming record into the outgoing record.
        self.record_creator.reset()
        self.record_copier.done_adding()
        self.record_copier.copy(self.record_creator, in_record)

        # Push the record downstream and quit if there's a downstream error.
        if not self.parent.output_anchor.push_record(out_record):
            return False

        return True
Ejemplo n.º 9
0
 def fd2(self, seed):
     return Food(seed=seed)
Ejemplo n.º 10
0
print('\n')

print('#' * 5 + '地址' + '#' * 5)
business = Business('zh')
print(business.company())
print(business.company_type())
print('\n')

print('#' * 5 + '支付' + '#' * 5)
payment = Payment('zh')
print(payment.paypal())
print(payment.credit_card_expiration_date())
print('\n')

print('#' * 5 + '文字' + '#' * 5)
text = Text('zh')
print(text.alphabet())
print(text.answer())
print(text.quote())
print(text.title())
print(text.word())
print(text.words())
print(text.sentence())
print('\n')

print('#' * 5 + '食物' + '#' * 5)
food = Food('zh')
print(food.drink())
print(food.fruit())
print(food.spices())
print('\n')
Ejemplo n.º 11
0
from mimesis import Person
from mimesis import Address
from mimesis import Food

print("#" * 30 + " person " + "#" * 30)
person = Person('zh')
print(f'name: {person.surname() + "" + person.name()}')
print(f'sex: {person.sex()}')
print(f'academic degree: {person.academic_degree()}')

print("*" * 30 + " person data " + "*" * 30)
print('\n'.join(('%s:%s' % item for item in person._data.items())))

print("#" * 30 + " address " + "#" * 30)
address = Address("zh")
print(f'continent: {address.continent()}')
print(f'province: {address.province()}')
print(f'city: {address.city()}')
print(f'street name: {address.street_name()}')

print("*" * 30 + " address data " + "*" * 30)
print('\n'.join(('%s:%s' % item for item in address._data.items())))

print("#" * 30 + " food " + "#" * 30)
food = Food("zh")
print(f'dish: {food.dish()}')
print(f'drink: {food.drink()}')

print("*" * 30 + " food data " + "*" * 30)
print('\n'.join(('%s:%s' % item for item in food._data.items())))
Ejemplo n.º 12
0
import cProfile
from mimesis import Person, Numbers, Food, Datetime, Code
import random

person = Person('ru')
num = Numbers()
products = Food('ru')
card_code = Code()
date_time = Datetime()

array_transaction_type = ["Cash", "Card"]
array_product_prices = []
array_orders = []
array_orders_price = []
array_clients_id = []
array_transaction_id = []

file_clients = open('clients_table.txt', 'w')
file_products = open('products_table.txt', 'w')
file_bonuscards = open('bonuscards_table.txt', 'w')
file_orders = open('orders_table.txt', 'w')
file_transactions = open('transactions_table.txt', 'w')


def create_and_shuffle_array(size, array):
    for i in range(size):
        array.append(i)
    random.shuffle(array)


#client table
Ejemplo n.º 13
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
#  generation_name2.py
#
#  Copyright 2018 Roman <roman@roman-home>
#from generation name

from mimesis import Food
food = Food('en')


def create_name():
    a = food.drink()
    #print(a)
    return a
Ejemplo n.º 14
0
def food(locale):
    """

    :return:
    """
    return Food(locale)
Ejemplo n.º 15
0
 def _foods(self, seed):
     return Food(seed=seed), Food(seed=seed)