示例#1
0
def encode_QR(words, picture=None, colorized=True, save_name="", save_dir=""):
    if picture != None:
        picture = picture.strip('''"'"''')
        pair = os.path.split(picture)
        if "." not in pair[1]:
            print("错误的文件名!")
            return
        picture_full_name = pair[1].split(".")
        name = picture_full_name[0]
        extension = picture_full_name[1]
        if save_name == "":
            save_name = name + "_toQR"
        if "." not in save_name and len(extension) != 0:
            save_name += "." + extension

    print("保存文件名为:{}".format(save_name))
    save_dir = save_dir if save_dir != "" else os.getcwd()
    print("保存地址为:{}".format(save_dir))
    myqr.run(words,
             picture=picture,
             colorized=colorized,
             save_name=save_name,
             save_dir=save_dir)
    path = PathUtil(save_dir + '\\' + save_name)
    print("生成QR图片已保存到:{}".format(path.get_path()))
示例#2
0
def read_qrcode():
    qr_add = input("输入QR图片地址:")
    qr_add = qr_add.strip('''"'"''')
    if os.path.isfile(qr_add):
        path = PathUtil(qr_add)
        qr_add = path.get_path()

    print("正在解码。。。")
    return decode_QR(qr_add)
示例#3
0
def __main__():
    for language in ["English", "Chinese"]:
        agenda = Agenda(language, "test theme")
        session = Session(datetime(2020, 11, 5, 16, 40))
        session.append_event(duration=20,
                             role_name="Sergeant at Arms (SAA)",
                             role_taker=MemberInfo({
                                 "English Name": "Bonnie Wang",
                                 "Chinese Name": "Baoni",
                                 "Speech Records": [],
                                 "Role Records": [],
                             }),
                             event="Registration/Greeting",
                             show_duration=False)
        session.append_event(duration=4,
                             role_name="Toastmaster",
                             role_taker=MemberInfo({
                                 "English Name": "Elliot Zhang",
                                 "Chinese Name": "Xingzhi",
                                 "Speech Records": [],
                                 "Role Records": [],
                             }),
                             event="Meeting Opening & Welcome Guests  (20s/P)")

        session = Session(agenda.append_session(session).current_datetime,
                          title="Table Topic Session")
        session.append_event(duration=25,
                             role_name="Table Topic Master",
                             role_taker=MemberInfo({
                                 "English Name": "Kay",
                                 "Chinese Name": "Li Kang",
                                 "Speech Records": [],
                                 "Role Records": [],
                             }),
                             event="Theme Introduction & Table Topic Session")
        session.append_event(duration=6,
                             role_name="Table Topic Evaluator",
                             role_taker=MemberInfo({
                                 "English Name": "Raymond Lu",
                                 "Chinese Name": "Raymond",
                                 "Speech Records": [],
                                 "Role Records": [],
                             }),
                             event="Table Topic Evaluation")
        session.append_event(duration=1,
                             role_name="Toastmaster",
                             role_taker=MemberInfo({
                                 "English Name": "Elliot Zhang",
                                 "Chinese Name": "Xingzhi",
                                 "Speech Records": [],
                                 "Role Records": [],
                             }),
                             event="Return control to Toastmaster")
        agenda.append_session(session)

        agenda.dump(PathUtil().get_output_path("{}.html".format(language)))
示例#4
0
 def __init__(self, language, theme, speech_count=3):
     self._template_str = Agenda.template_localization(
         PathUtil().get_template("default.html"), language, {
             "theme": {
                 "default": theme,
             },
             "speech_count": {
                 "default": str(speech_count),
             }
         })
     self._sessions = []  # type: List[Session]
示例#5
0
    def __init__(self, month: int, day: int, is_english: bool, year=None):
        self._function_role_taker = {}  # type: Dict[str, MemberInfo]
        self._info = {}  # type: Dict[str, str]
        self._year = year if year is not None else datetime.datetime.now().year
        self._month = month
        self._day = day
        self._is_english = is_english
        self._theme = "TBD"
        self._speakers = []  # type: List[MemberInfo]
        self._new_member_count = -1
        self._skip_dict = set()  # special hacks to skip events
        self._special_events = {}  # hacks to get special events

        with open(PathUtil().get_config_path("time_dict"),
                  "r",
                  encoding="utf-8") as time_dict_file:
            self._time_dict = json.load(time_dict_file)
            time_dict_file.close()

        with open(PathUtil().get_config_path("roles"), "r",
                  encoding="utf-8") as roles_file:
            self._roles = json.load(roles_file)
            roles_file.close()
示例#6
0
    def template_localization(
            cls,
            template_path,
            language,
            additional_dict: Optional[Dict[str, Dict[str, str]]] = None):
        with open(template_path, "r", encoding="utf-8") as html_file:
            html_template = html_file.read()
            html_file.close()
        with open(PathUtil().get_config_path("localization"),
                  "r",
                  encoding="utf-8") as localization_file:
            localization_dict = json.load(
                localization_file)  # type: Dict[str, Dict[str, str]]
            localization_file.close()

        if additional_dict is not None:
            localization_dict.update(additional_dict)

        for key, v_dict in localization_dict.items():
            value = v_dict["default"] if language not in v_dict else v_dict[
                language]
            html_template = html_template.replace("{{" + key + "}}", value)
        return html_template
示例#7
0
    def __init__(self, member_info_path=None):
        self._path_util = PathUtil()

        self._member_info_path = path.join(self._path_util.current_dir, "data", "member_info.json") \
            if member_info_path is None else member_info_path

        with open(self._member_info_path, "r", encoding="utf-8") as member_info_file:
            member_info_list = json.load(member_info_file)
            self._member_info_list = []
            for member_info_json in member_info_list:
                self._member_info_list.append(MemberInfo(member_info_json))
            member_info_file.close()

            for i, member_info_json in enumerate(member_info_list):
                if "Mentor Name" in member_info_json and member_info_json["Mentor Name"] is not None:
                    self._member_info_list[i].set_mentor(member_info_json["Mentor Name"], self)

        with open(self._path_util.get_config_path("learning_path"), "r", encoding="utf-8") as in_file:
            learning_path = json.load(in_file)
            in_file.close()

        self._pathway_path = learning_path["pathway"]  # type: List[str]
        self._cc_path = learning_path["CC"]
示例#8
0
 def path_util(self):
     return PathUtil()