本文整理汇总了Python中database.DatabaseManager.check_keyboard_exist方法的典型用法代码示例。如果您正苦于以下问题:Python DatabaseManager.check_keyboard_exist方法的具体用法?Python DatabaseManager.check_keyboard_exist怎么用?Python DatabaseManager.check_keyboard_exist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类database.DatabaseManager
的用法示例。
在下文中一共展示了DatabaseManager.check_keyboard_exist方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save_file
# 需要导入模块: from database import DatabaseManager [as 别名]
# 或者: from database.DatabaseManager import check_keyboard_exist [as 别名]
def save_file(self):
if self.validate():
self.clear_file_error()
filepath = str(self.file_path_tview.text())
fileinfo = QFileInfo(filepath)
filename = str(int(time.time())) + "_" + fileinfo.fileName()
keyboard_name = "Unknown"
with open(filepath, encoding="utf-8") as search:
for line in search:
line = line.rstrip() # remove '\n' at end of line
if "NAME" in line:
name_line = line
name_list = name_line.split('=', 1)
if len(name_list) > 0:
keyboard_name = name_list[1]
if keyboard_name == "Unknown":
self.show_file_error("SCIM table name header not found")
elif DatabaseManager.check_keyboard_exist(keyboard_name):
self.show_file_error("Keyboard already exists")
else:
shutil.copyfile(filepath, self.table_path + "\\" + filename)
DatabaseManager.add_keyboard(keyboard_name, filename)
self.file_path_tview.setText("")
self.update_table()