Пример #1
0
 def remove_bullet_points():
     file = open('random_bullet_points.json', 'r', encoding='utf-8').read()
     file = json.loads(file)
     which_product = index_rbp_json(file)
     print(f'删除{file[which_product]}')
     del file[which_product]
     save_json_file(file)
     pasu.back_to_main_menu()
Пример #2
0
 def _again():
     again = input('是否再次生成?(y/n):')
     if again == 'y':
         mk_random_bulletpoints()
     elif again == 'n':
         pasu.back_to_main_menu()
     else:
         '请输入y或n'
         _again()
Пример #3
0
 def get_html_etree(self):
     if '<html' not in pyperclip.paste():
         print('没有在剪贴板中找到html标签,请确保复制了整个html页面的文本')
         pasu.back_to_main_menu(enter_quit=True)
     with open(self.HTML_etree, 'w', encoding='utf-8') as f:
         f.write(pyperclip.paste())
     src = open(self.HTML_etree, 'r', encoding='utf-8').read()
     html = etree.HTML(src, etree.HTMLParser())
     return html
Пример #4
0
 def save_all(self):
     self.file_directory = pasu.index_files()[-1]
     if type(self.file_directory) is list:
         input('只能输入一个文件路径,请确保只选择了一个文件(回车返回主菜单)')
         pasu.back_to_main_menu()
     content_dict = self.load_sheet(self.file_directory)
     for key, value in content_dict.items():
         save_this_content = self.get_all_column(self.sheet, value)
         self.save_as_html(
             f'所有内容_{datetime.datetime.now().strftime("%Y_%m_%d_%H_%M")}',
             save_this_content)
     pasu.back_to_main_menu()
Пример #5
0
def rename():
    indexed_kw_types = KWu.show_current_kw_types()
    _ui = str(input("选择需要重命名的关键词(-1退出):"))
    if _ui == '-1':
        menu()
    else:
        _uo = str(input("输入新的词汇:"))
        content = open(KWu.PATH_DATA_BASE, 'r', encoding='utf-8').read()
        content = content.replace(indexed_kw_types[int(_ui)], _uo)
        with open(KWu.PATH_DATA_BASE, 'w', encoding='utf-8') as f:
            f.write(content)
        pas_utility.back_to_main_menu()
Пример #6
0
 def find_all_txt_file(self) -> list:
     self.directory = input('输入 <翻译好的txt文件> 所在的路径:')
     files = []
     if self.directory == '-1':
         pasu.back_to_main_menu()
     elif not os.path.isdir(self.directory):
         print('请输入一个文件夹路径')
         self.find_all_txt_file()
     for folder, subfolder, file in os.walk(self.directory):
         for each_file in file:
             if each_file.split('.')[-1] == 'txt':
                 files.append(folder + '\\' + each_file)
     return files
Пример #7
0
def new_del_sheet_by_sku(
):  # P1c0pb53f-11683870895082338686 P1c0jk98b-2237820982760922098
    # D:\小米ERP相关数据\上传产品表格\20200619_充气游泳池
    _ui = input('输入sku/ean:')
    folder, which_file = pasu.index_files()
    if type(which_file) is str:
        print('处理(' + which_file + ')...')
        opsh.write_sku_delete_file(folder, which_file, _ui)
    elif type(which_file) is list:
        for each_file in which_file:
            print('处理(' + each_file + ')...')
            opsh.write_sku_delete_file(folder, each_file, _ui)
    input('处理完成')
    pasu.back_to_main_menu()
Пример #8
0
def delete_kw():
    indexed_kw = KWu.show_current_kw_types()
    content = open(KWu.PATH_DATA_BASE, 'r', encoding='utf-8').read()
    _ui = str(input("选择需要删除的关键词:"))
    _make_sure = input(f'确认删除({indexed_kw[int(_ui)]})?(y/n)')
    _del_pattern = re.compile(
        f'{indexed_kw[int(_ui)]}[::]' + '{.+}' + f'{indexed_kw[int(_ui)]}',
        re.DOTALL)
    if _make_sure == 'y':
        content = re.sub(_del_pattern, '', content)
        with open(KWu.PATH_DATA_BASE, 'w', encoding='utf-8') as f:
            f.write(content)
    else:
        print("取消删除操作,退回主菜单...")
        pas_utility.back_to_main_menu()
    pas_utility.back_to_main_menu()
Пример #9
0
    def add_bullet_points():
        file = open('random_bullet_points.json', 'r', encoding='utf-8').read()
        file = json.loads(file)

        which_product = input('请输入需要添加的内容名称:')
        if which_product not in file.keys():
            print('没有此名称,添加新的内容...')
            file[which_product] = add_bp([])
            save_json_file(file)
        else:
            file = open('random_bullet_points.json', 'r',
                        encoding='utf-8').read()
            file = json.loads(file)
            print('已有名称,添加更多...')
            file[which_product] = add_bp(file[which_product])
            save_json_file(file)
        pasu.back_to_main_menu()
Пример #10
0
def create_new_kw():
    temp = '格式示例,如果没有这些国家可以删掉\n\n\n'\
           'EN:这里写上英文的关键词\n\n'\
           'FR:这里写上法语的关键词\n\n'\
           'DE:这里写上德语的关键词\n\n'\
           'IT:这里写上意大利语的关键词\n\n'\
           'ES:这里写上西班牙语的关键词'
    with open('new_kw_temp.txt', 'w', encoding='utf-8') as t:
        t.write(temp)
    print("在打开的文件中按照对应格式添加关键词")
    os.startfile('new_kw_temp.txt')
    ui = input("是否添加完成(y/n):")
    if ui == 'y':
        KWu.process_new_kw()
        pas_utility.back_to_main_menu()
    else:
        print('取消操作,退回主菜单')
        pas_utility.back_to_main_menu()
Пример #11
0
 def index_rbp_json(json_content: dict):
     _index = 0
     _menu = {}
     for k, v in json_content.items():
         _menu[(_index, k)] = v
         print(_index, end='\t')
         print(k)
         _index += 1
     _which_product = input('请选择:')
     for k, v in _menu.items():
         _index, key = k
         if _which_product == str(_index):
             print(f'已选择:{key}')
             if v:
                 return '\n'.join(sample(v, 5))
             else:
                 input('内容为空值,请先添加内容,回车返回主菜单')
                 pasu.back_to_main_menu()
Пример #12
0
    def main(self):
        files = self.find_all_txt_file()
        self.get_langs_and_langs_dict(files)
        oc_file = pasu.index_files(ui_msg='输入 <表格文件> 所在的路径:',
                                   which_file_msg='请选择原始表格文件:')[-1]
        original_wb = openpyxl.load_workbook(str(oc_file))
        original_sheet = original_wb.get_sheet_by_name('sheet1')

        # 获取价格和节点的成员函数
        def get_node_price_list():
            _new_wb = openpyxl.load_workbook(str(oc_file))
            _new_sheet = _new_wb.get_sheet_by_name('sheet1')
            _node_list = get_content_list(_new_sheet,
                                          'recommended_browse_nodes')
            _price_list = get_content_list(_new_sheet, 'standard_price')
            _price_list = [
                each_cell for each_cell in _price_list if each_cell.value != ''
            ]
            return _node_list, _price_list, _new_wb, _new_sheet

        if check_if_the_same_day(get_time_stamp()):
            excr_node = {}
            excr_node_result = asking_for_excr_node_input()
            excr_node_result = excr_node_result.split('\n')
            excr_node_result = [
                each_line for each_line in excr_node_result
                if each_line != '' or each_line != ':'
            ]
            for each_line in excr_node_result:
                excr_node[each_line.split(':')[0].strip()] = \
                    EXCHANGE_RATE_NODE[0]+str(each_line.split(':')[-1].strip())+EXCHANGE_RATE_NODE[1]
            with open('excr_node.py', 'w', encoding='utf-8') as t:
                t.write('excr_node = ' + str(excr_node))
            with open('_time_stamp_for_excr_node.py', 'w',
                      encoding='utf-8') as t:
                t.write(
                    'time_stamp = ' +
                    f'"{datetime.datetime.strftime(datetime.datetime.now(), "%Y, %m, %d, %I, %M, %S")}"'
                )

        # 处理文本文件
        for lang, file_list in self.langs_dict.items():
            import excr_node
            template = {
                key: value
                for key, value in excr_node.excr_node.items() if key != ''
            }
            for each_file in file_list:
                out_file_name = self.directory + '\\' + lang + '_' + str(
                    oc_file).split('\\')[-1]
                print(f'正在处理  {out_file_name}')
                if excr_node.excr_node is not None:
                    for lang_excr_node, _excr_node in template.items():
                        if lang_excr_node in each_file.split('\\')[-1]:
                            line_prepender(each_file, _excr_node)

                content = open(each_file, encoding='utf-8').read()
                content_list = content.split('\n')
                content_list = [
                    each_line for each_line in content_list if each_line != ''
                ]
                content_list = [
                    each_line for each_line in content_list
                    if SEPARATOR in each_line
                ]
                for each_content in content_list:
                    try:
                        if len(each_content.split(SEPARATOR)[0]) > 9:
                            continue
                        each_content = str(each_content).split(SEPARATOR)
                        row = int(each_content[0].strip()[1:-1].replace(
                            '、', ',').split(',')[0])
                        col = int(each_content[0].strip()[1:-1].replace(
                            '、', ',').split(',')[1])
                        original_sheet.cell(row, col).value = each_content[-1].strip().replace(BR_PATTERN, ' <br> ')\
                            .replace('$$ $', ' <br> ').replace('$ $$', ' <br> ')
                    except Exception as e:
                        print(f'{each_file} 中的内容: {each_content} 发生了错误 {e}')
                        continue

                if EXCHANGE_RATE_NODE[0] not in content:
                    input(f'\n文本文件: ({each_file}) 当中没有标明汇率和节点,请检查文件(回车继续)')
                    continue
                elif EXCHANGE_RATE_NODE[0] in content:
                    search_result = re.search(
                        re.compile(r'(?<=!!\[).+(?=]!!)'), content)
                    if search_result is None:
                        continue
                    exchange_rate, node = str(
                        re.search(re.compile(r'(?<=!!\[).+(?=]!!)'),
                                  content)[0]).split(',')
                    node_list, price_list, new_wb, new_sheet = get_node_price_list(
                    )
                    for each_node in node_list:
                        row, col = pasu.get_coordinate(each_node)
                        original_sheet.cell(
                            int(row), int(col)).value = str(node).strip()
                    for each_price in price_list:
                        row, col = pasu.get_coordinate(each_price)
                        original_sheet.cell(int(row), int(col)).value = \
                            self.calculate_time_exchange_rate(each_price, exchange_rate)
                    print(f'\n当前的语言: {lang}')
                    print(f'当前使用的节点:{node}')
                    print(f'当前使用的汇率:{exchange_rate}')
                else:

                    class NoExchangeNodeError(Exception):
                        pass

                    raise NoExchangeNodeError('No exchange rate and node')
                original_wb.save(out_file_name)
        pasu.back_to_main_menu(enter_quit=True)
Пример #13
0
def main():
    kw = RandKeyWord()
    kw.kw_generator_main()
    pas_utility.back_to_main_menu()
Пример #14
0
def main():
    _i = Invoice()
    _i.main()
    pasu.back_to_main_menu()