# -*- coding: utf-8 -*-import osimport timefrom PySide6.QtGui import QColorfrom language import Languagefrom theme import Themeimport wcwidth# helperclass StringUtils:@staticmethoddef contains(string, substring):return string.find(substring) != -1class FileUtils:@staticmethoddef get_name(filename):return os.path.splitext(filename)[0]@staticmethoddef get_fullname(name, ext = '.xml'):if ext in name:return namereturn name + extclass DateUtils:@staticmethoddef get_year():return time.strftime('%Y', time.localtime(time.time()))@staticmethoddef get_date():return time.strftime('%Y-%m-%d',time.localtime(time.time()))class ColorUtils:@staticmethoddef hex2rgb(color):value = int(color[1:], 16)rgb_color = QColor(value)rgb_color = QColor(rgb_color.red(), rgb_color.green(), rgb_color.blue())return rgb_color.rgb()class LanguageUtils:@staticmethoddef validate(language):languages = [Language.Chinese.value, Language.English.value]return language in languagesclass ThemeUtils:@staticmethoddef validate(theme):theme = FileUtils.get_fullname(theme)return theme in Theme.get_all_themes()class WidthHelper():def format_text(text, width=30):count = wcwidth.wcswidth(text) - len(text)width = width - count if width >= count else 0fill = ' 'return '{0:{1}{2}{3}}'.format(text, fill, '^', width)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。