代码拉取完成,页面将自动刷新
# -*- coding: utf-8 -*-
import os
import time
from PySide6.QtGui import QColor
from language import Language
from theme import Theme
import wcwidth
# helper
class StringUtils:
@staticmethod
def contains(string, substring):
return string.find(substring) != -1
class FileUtils:
@staticmethod
def get_name(filename):
return os.path.splitext(filename)[0]
@staticmethod
def get_fullname(name, ext = '.xml'):
if ext in name:
return name
return name + ext
class DateUtils:
@staticmethod
def get_year():
return time.strftime('%Y', time.localtime(time.time()))
@staticmethod
def get_date():
return time.strftime('%Y-%m-%d',time.localtime(time.time()))
class ColorUtils:
@staticmethod
def 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:
@staticmethod
def validate(language):
languages = [Language.Chinese.value, Language.English.value]
return language in languages
class ThemeUtils:
@staticmethod
def 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 0
fill = ' '
return '{0:{1}{2}{3}}'.format(text, fill, '^', width)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。