本文整理汇总了Python中Console.get_integer方法的典型用法代码示例。如果您正苦于以下问题:Python Console.get_integer方法的具体用法?Python Console.get_integer怎么用?Python Console.get_integer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Console
的用法示例。
在下文中一共展示了Console.get_integer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: edit_dvd
# 需要导入模块: import Console [as 别名]
# 或者: from Console import get_integer [as 别名]
def edit_dvd(db):
title, identity = find_dvd(db, "edit")
if title is None:
return
title = Console.get_string("Title", "title", title)
if not title:
return
cursor = db.cursor()
cursor.execute("SELECT dvds.year, dvds.duration, directors.name "
"FROM dvds, directors "
"WHERE dvds.director_id = directors.id AND "
"dvds.id=:id", dict(id=identity))
year, duration, director = cursor.fetchone()
director = Console.get_string("Director", "director", director)
if not director:
return
year = Console.get_integer("Year", "year", year, 1896,
datetime.date.today().year)
duration = Console.get_integer("Duration (minutes)", "minutes",
duration, minimum=0, maximum=60*48)
director_id = get_and_set_director(db, director)
cursor.execute("UPDATE dvds SET title=:title, year=:year, "
"duration=:duration, director_id=:director_id "
"WHERE id=:identity", locals())
db.commit()
示例2: add_dvd
# 需要导入模块: import Console [as 别名]
# 或者: from Console import get_integer [as 别名]
def add_dvd(db):
title = Console.get_string("Title", "title")
if not title:
return
director = Console.get_string("Director", "director")
if not director:
return
year = Console.get_integer("Year", "year", minimum=1896,
maximum=datetime.date.today().year)
duration = Console.get_integer("Duration (minutes)", "minutes",
minimum=0, maximum=60*48)
db[title] = (director, year, duration)
db.sync()
示例3: find_dvd
# 需要导入模块: import Console [as 别名]
# 或者: from Console import get_integer [as 别名]
def find_dvd(db, message):
message = "(Start of) title to " + message
cursor = db.cursor()
while True:
start = Console.get_string(message, "title")
if not start:
return (None, None)
cursor.execute("SELECT title, id FROM dvds "
"WHERE title LIKE ? ORDER BY title",
(start + "%",))
records = cursor.fetchall()
if len(records) == 0:
print("There are no dvds starting with", start)
continue
elif len(records) == 1:
return records[0]
elif len(records) > DISPLAY_LIMIT:
print("Too many dvds ({0}) start with {1}; try entering "
"more of the title".format(len(records), start))
continue
else:
for i, record in enumerate(records):
print("{0}: {1}".format(i + 1, record[0]))
which = Console.get_integer("Number (or 0 to cancel)",
"number", minimum=1, maximum=len(records))
return records[which - 1] if which != 0 else (None, None)
示例4: retrieve_car_details
# 需要导入模块: import Console [as 别名]
# 或者: from Console import get_integer [as 别名]
def retrieve_car_details(previous_license):
license = Console.get_string("License", "license",
previous_license)
if not license:
return previous_license, None
license = license.upper()
ok, *data = handle_request("GET_CAR_DETAILS", license)
if not ok:
print(data[0])
while True:
start = Console.get_string("Start of license", "license")
if not start:
return previous_license, None
start = start.upper()
ok, *data = handle_request("GET_LICENSES_STARTING_WITH",
start)
if not data[0]:
print("No licence starts with " + start)
continue
for i, license in enumerate(data[0]):
print("({0}) {1}".format(i + 1, license))
answer = Console.get_integer("Enter choice (0 to cancel)",
minimum=0, maximum=len(data[0]))
if answer == 0:
return previous_license, None
license = data[0][answer - 1]
ok, *data = handle_request("GET_CAR_DETAILS", license)
if not ok:
print(data[0])
return previous_license, None
break
return license, CarTuple(*data)
示例5: find_dvd
# 需要导入模块: import Console [as 别名]
# 或者: from Console import get_integer [as 别名]
def find_dvd(db, message):
message = "(Start of) title to " + message
while True:
matches = []
start = Console.get_string(message, "title")
if not start:
return None
for title in db:
if title.lower().startswith(start.lower()):
matches.append(title)
if len(matches) == 0:
print("There are no dvds starting with", start)
continue
elif len(matches) == 1:
return matches[0]
elif len(matches) > DISPLAY_LIMIT:
print("Too many dvds start with {0}; try entering "
"more of the title".format(start))
continue
else:
matches = sorted(matches, key=str.lower)
for i, match in enumerate(matches):
print("{0}: {1}".format(i + 1, match))
which = Console.get_integer("Number (or 0 to cancel)",
"number", minimum=1, maximum=len(matches))
return matches[which - 1] if which != 0 else None
示例6: delete_dance
# 需要导入模块: import Console [as 别名]
# 或者: from Console import get_integer [as 别名]
def delete_dance():
get_dances()
index = Console.get_integer("Choice index of dance to delete", default=0)
data = handle_request("DEL_DANCE", index)
if not data[0]:
print "ERROR:", data[1]
print "Dance successfully deleted."
print
示例7: delete_genre
# 需要导入模块: import Console [as 别名]
# 或者: from Console import get_integer [as 别名]
def delete_genre():
get_genres()
index = Console.get_integer("Choice index of genre to delete", default=0)
data = handle_request("DEL_GENRE", index)
if not data[0]:
print "ERROR:", data[1]
print "Genre successfully deleted."
print
示例8: new_registration
# 需要导入模块: import Console [as 别名]
# 或者: from Console import get_integer [as 别名]
def new_registration(previous_license):
license = Console.get_string("License", "license")
if not license:
return previous_license
license = license.upper()
seats = Console.get_integer("Seats", "seats", 4, 0)
if not (1 < seats < 10):
return previous_license
mileage = Console.get_integer("Mileage", "mileage", 0, 0)
owner = Console.get_string("Owner", "owner")
if not owner:
return previous_license
ok, *data = handle_request("NEW_REGISTRATION", license, seats, mileage, owner)
if not ok:
print(data[0])
else:
print("Car {0} successfully registered".format(license))
return license
示例9: add_dvd
# 需要导入模块: import Console [as 别名]
# 或者: from Console import get_integer [as 别名]
def add_dvd(db):
title = Console.get_string("Title", "title")
if not title:
return
director = Console.get_string("Director", "director")
if not director:
return
year = Console.get_integer("Year", "year", minimum=1896,
maximum=datetime.date.today().year)
duration = Console.get_integer("Duration (minutes)", "minutes",
minimum=0, maximum=60*48)
director_id = get_and_set_director(db, director)
cursor = db.cursor()
cursor.execute("INSERT INTO dvds "
"(title, year, duration, director_id) "
"VALUES (?, ?, ?, ?)",
(title, year, duration, director_id))
db.commit()
示例10: remove_discrete_record
# 需要导入模块: import Console [as 别名]
# 或者: from Console import get_integer [as 别名]
def remove_discrete_record(db):
identity = Console.get_integer("Delete record number", "id", minimum=0)
if id is None:
return
ans = Console.get_bool("Remove {0}?".format(identity), "no")
if ans:
cursor = db.cursor()
cursor.execute("DELETE FROM discrete_records WHERE id=?", (identity,))
db.commit()
示例11: find_bookmark
# 需要导入模块: import Console [as 别名]
# 或者: from Console import get_integer [as 别名]
def find_bookmark(db, message):
message = "Number of bookmark to " + message
number = Console.get_integer(message, "number", minimum=0,
maximum=len(db))
if number == 0:
return None
number -= 1
for i, name in enumerate(sorted(db, key=str.lower)):
if i == number:
return name
示例12: edit_dvd
# 需要导入模块: import Console [as 别名]
# 或者: from Console import get_integer [as 别名]
def edit_dvd(db):
old_title = find_dvd(db, "edit")
if old_title is None:
return
title = Console.get_string("Title", "title", old_title)
if not title:
return
director, year, duration = db[old_title]
director = Console.get_string("Director", "director", director)
if not director:
return
year = Console.get_integer("Year", "year", year, 1896,
datetime.date.today().year)
duration = Console.get_integer("Duration (minutes)", "minutes",
duration, minimum=0, maximum=60*48)
db[title] = (director, year, duration)
if title != old_title:
del db[old_title]
db.sync()
示例13: new_registration
# 需要导入模块: import Console [as 别名]
# 或者: from Console import get_integer [as 别名]
def new_registration(previous_myLicense):
myLicense = Console.get_string("License", "license")
if not myLicense:
return previous_myLicense
myLicense = myLicense.upper()
seats = Console.get_integer("Seats", "seats", 4, 0)
#if not (1 < seats < 10):
# return previous_myLicense
mileage = Console.get_integer("Mileage", "mileage", 0, 0)
owner = Console.get_string("Owner", "owner")
#if not owner:
# return previous_myLicense
# quito un *data y ponto data =
ok, data = handle_request("NEW_REGISTRATION", myLicense, seats,
mileage, owner)
if not ok:
print(data[0])
else:
print("Car {0} successfully registered".format(myLicense))
return myLicense
示例14: change_mileage
# 需要导入模块: import Console [as 别名]
# 或者: from Console import get_integer [as 别名]
def change_mileage(previous_license):
license, car = retrieve_car_details(previous_license)
if car is None:
return previous_license
mileage = Console.get_integer("Mileage", "mileage", car.mileage, 0)
if mileage == 0:
return license
ok, *data = handle_request("CHANGE_MILEAGE", license, mileage)
if not ok:
print(data[0])
else:
print("Mileage successfully changed")
return license
示例15: add_record
# 需要导入模块: import Console [as 别名]
# 或者: from Console import get_integer [as 别名]
def add_record(db):
machine_name = Console.get_string("Machine", "machine")
if not machine_name:
return
machine_memory = Console.get_integer("Memory (MB)", "memory",
minimum=0, maximum=5000)
machine_freq = Console.get_float("Frequency (GHz)", "frequency",
minimum=0, maximum=5)
input_size = Console.get_integer("Input size", "input_size", minimum=0,
maximum=5000*1024)
if not input_size:
return
exec_time = Console.get_float("Execution time (seconds)", "execution time",
minimum=0, maximum=1000000)
if not exec_time:
return
machine_id = get_and_set_machine(db, machine_name, machine_freq, machine_memory)
cursor = db.cursor()
cursor.execute("INSERT INTO records "
"(input_size, exec_time, machine_id) "
"VALUES (?, ?, ?)",
(input_size, exec_time, machine_id))
db.commit()