コード例 #1
0
ファイル: test_payment.py プロジェクト: carlosveliz/mimesis
 def p2(self, seed):
     return Payment(seed=seed)
コード例 #2
0
def getting_started_example():
    generic = Generic()
    #generic = Generic(locales.EN)

    print('Month =', generic.datetime.month())
    print('Datetime =',
          generic.datetime.datetime(start=1900, end=2035,
                                    timezone=None))  # Type: datetime.datetime.
    print('IMEI =', generic.code.imei())
    print('Fruit =', generic.food.fruit())
    print('RNA =', generic.science.rna_sequence())

    print('Word =', generic.text.word())

    with generic.text.override_locale(locales.FR):
        print('Word =', generic.text.word())

    print('Word =', generic.text.word())

    generic = Generic('en')
    generic.add_provider(USASpecProvider)

    print('SSN =', generic.usa_provider.ssn())
    #print('CPF =', generic.usa_provider.cpf())  # AttributeError: 'USASpecProvider' object has no attribute 'cpf'.

    generic = Generic('pt-br')
    #generic = Generic(locales.PT_BR)
    generic.add_provider(BrazilSpecProvider)

    #print('SSN =', generic.brazil_provider.ssn())  # AttributeError: 'BrazilSpecProvider' object has no attribute 'ssn'.
    print('CPF =', generic.brazil_provider.cpf())

    #--------------------
    numbers = Numbers()

    print('Numbers =', numbers.between())  # Type: int.
    print('Numbers =', numbers.between(10, 10000000000000000))  # Type: int.

    #--------------------
    person = Person(locales.KO)

    print('Full name =', person.full_name(gender=Gender.FEMALE))
    print('Full name =', person.full_name(gender=Gender.MALE, reverse=True))

    with person.override_locale(locales.RU):
        print('Full name =', person.full_name())

    print('Full name =', person.full_name())
    print('Telephone =', person.telephone())
    print('Telephone =', person.telephone(mask='(###)-###-####'))
    print('Identifier =', person.identifier())
    print('Identifier =', person.identifier(mask='######-#######'))

    #--------------------
    de = Address('de')
    ru = Address('ru')

    print('Region =', de.region())
    print('Federal subject =', ru.federal_subject())
    print('Address =', de.address())
    print('Address =', ru.address())

    ko = Address('ko')

    print('Address =', ko.province(), ko.city(), ko.address())
    print('Zip code =', ko.zip_code())

    #--------------------
    business = Business('ko')

    #print('Price =', business.price(minimum=1.0, maximum=1000000000.0))  # Type: str.
    #print('Price =', business.price(minimum=1.0, maximum=1000000000.0)[:-2])  # Type: str.
    print('Price =',
          business.price(minimum=1.0, maximum=1000000000.0)[:-5])  # Type: str.

    #--------------------
    payment = Payment()

    print('Credit card =',
          payment.credit_card_number(card_type=None))  # Type: str.
コード例 #3
0
ファイル: test_payment.py プロジェクト: carlosveliz/mimesis
 def payment(self):
     return Payment()
コード例 #4
0
print('\n')

print('#' * 5 + '地址' + '#' * 5)
address = Address('zh')
print(address.coordinates())
print(address.city())
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')
コード例 #5
0
# Note: we don't ever store user passwords as clear text!!!
# To emulate salting and hashing the user passwords:
import hashlib
import uuid

# However, we should really use a dedicated password hashing
# package, such as passlib. However, this is out of scope
# for this demo (it would require further installation).
# import passlib

np.random.seed(42)  # To make our analysis reproducible

person = Person()
address = Address()
business = Business()
payment = Payment()
text = Text()

##################################################
### Define a couple of convenience functions:
##################################################


def hashed_passwd(passwd):
    """We should never entertain the idea of storing users' passwords
    as plaintext. This function performs a basic salting and hashing
    of a password input. This function should *never* be used in a
    production setting; if you need to securely store salted and hashed
    passwords, use a dedicated package such as passlib."""
    salt = uuid.uuid4().hex
    return hashlib.sha512(passwd.encode('utf-8')
コード例 #6
0
ファイル: test_payment.py プロジェクト: pmshenoy/mimesis
def payment():
    return Payment()
コード例 #7
0
 def _payments(self, seed):
     return Payment(seed=seed), Payment(seed=seed)