Skip to main content
Join the official Python Developers Survey 2018 and win valuable prizes: Start the survey!

Easy data entry and validation.

Project description

Overview

EasyEntry enter data into a program and easily check if they are valid.

Uses dictionaries to define the properties of the data:

  • type: str, int, float, date, time, email, passwd and menu.
  • default: sets a default by pressing the return key
  • options: defines a list of allowed values: [‘a’, ‘b’,…]
  • minmax: sets minimum and maximum limits for a value: [0, 100]
  • required: defines the obligation or not to introduce a value: True or False
  • and others (See the property list).

Example:

import easyentry as ee

ee.global_required = True

person = {}
person['name'] = {'type':'str'}
person['city'] = {'type':'str', 'default':'Seville'}
person['age']  = {'type':'int', 'minmax': [0,100]}
person['height']  = {'type':'float'}
person['bicycle']  = {'type':'str', 'options': ['y','n']}
person['datetrip'] = {'type':'date', 'default': 'now'}
person['email'] = {'type':'email', 'required': False}

name = ee.entry('What is your name?', (person, 'name'))
city = ee.entry('What city you live?', (person, 'city'))
age = ee.entry('How old are you?', (person, 'age'))
height = ee.entry('Height?', (person, 'height'))
bicycle = ee.entry('Do you have a bicycle?', (person, 'bicycle'))
datetrip = ee.entry('Date of trip?', (person, 'datetrip'))
email = ee.entry('Your email address', (person, 'email'))

Creates a options menu

To build a menu:

person['info'] = {'type':'menu', 'title':'Select an option', 'options':['phone','mail','none'], 'rindex':True}
info = ee.entry('To receive information by...', (person, 'info'))

Options:

  • rindex: With True returns the number of the selected option
  • sorted: sort the list of options (True/False)

Output:

To receive information by...
(1) phone
(2) mail
(3) none
Select an option [3]:

Password

Enter a password:

person['passwd'] = {'type':'passwd'}

passwd = ee.entry('Enter password', (person, 'passwd'))
repeat = ee.entry('Repeat password', (person, 'passwd'))

if passwd == repeat:
    print(passwd)

Property list

Properties of the data types available:

  • str: required, options or minmax and default
  • int: required, options or minmax and default
  • float: required, options or minmax and default
  • date: required, options or mixmax and default:date or now
  • time: required, options or mixmax and default:time or now
  • password: required
  • email: required
  • menu: required, title, options, default, sorted and rindex

Constants

The constants are used to set the values that define the general behavior of EasyEntry:

# Message to be displayed when data is not valid:
# - You can type the message in your language
# - If the value is omitted, the default is the current (in English)

ee.error_message = 'Invalid input, please try again'

# Set format 'date' and 'time':
# - Date format: '%Y-%m-%d' -> YYYY-MM-DD (default)
# - Hour format: '%H:%M:%S' -> HH:MM:SS   (default)

ee.date_format = '%d-%m-%Y'
ee.time_format = '%H:%M'

# Set the type of numerical data (int and float):
# - True and value = '' : var int   -> return 0
#                         var float -> return 0.0
# - False (default) and value = '': return ''

ee.strict_return = False

# Establish whether it is mandatory to enter a valid value or
# an empty entry (press return) is allowed
# - True  -> You must enter a valid value in all fields
# - False -> The field can be empty (default)
# The value of the 'required' property of a field overrides
# the global value

ee.global_required = True

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
easyentry-0.0.9-py2.py3-none-any.whl (9.5 kB) Copy SHA256 hash SHA256 Wheel py2.py3 Sep 10, 2015
easyentry-0.0.9.tar.gz (19.6 kB) Copy SHA256 hash SHA256 Source None Sep 10, 2015

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page