From 7440c978d04c08235bea5f038da1387e94b2338f Mon Sep 17 00:00:00 2001 From: LandGrey Date: Sun, 14 Mar 2021 16:28:28 +0800 Subject: [PATCH] fix bug 1. fix issues/24 bug -tool combiner UnicodeDecodeError 2. fix issues/26 bug --repeat python3 TypeError: 'dict_keys' object is not subscriptable --- README.md | 2 +- README_CN.md | 2 +- lib/data/data.py | 2 +- lib/fun/filter.py | 6 +++--- tools/combiner.py | 7 ++++--- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index d3195b2..d9b2854 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # pydictor -[![build](https://img.shields.io/badge/build-passing-brightgreen.svg)](https://www.github.com/landgrey/pydictor) [![Python 2.7&3.4](https://img.shields.io/badge/python-2.7&3.4-yellow.svg)](https://www.python.org/) ![release](https://img.shields.io/badge/version-2.1.5.2-orange.svg) ![License](https://img.shields.io/badge/license-GPLv3-red.svg) +[![build](https://img.shields.io/badge/build-passing-brightgreen.svg)](https://www.github.com/landgrey/pydictor) [![Python 2.7&3.4](https://img.shields.io/badge/python-2.7&3.4-yellow.svg)](https://www.python.org/) ![release](https://img.shields.io/badge/version-2.1.5.3-orange.svg) ![License](https://img.shields.io/badge/license-GPLv3-red.svg) **README.md [中文版](README_CN.md)** diff --git a/README_CN.md b/README_CN.md index d07898a..92f1baf 100644 --- a/README_CN.md +++ b/README_CN.md @@ -1,5 +1,5 @@ # pydictor -[![build](https://img.shields.io/badge/build-passing-brightgreen.svg)](https://www.github.com/landgrey/pydictor) [![Python 2.7&3.4](https://img.shields.io/badge/python-2.7&3.4-yellow.svg)](https://www.python.org/) ![release](https://img.shields.io/badge/version-2.1.5.2-orange.svg) ![License](https://img.shields.io/badge/license-GPLv3-red.svg) +[![build](https://img.shields.io/badge/build-passing-brightgreen.svg)](https://www.github.com/landgrey/pydictor) [![Python 2.7&3.4](https://img.shields.io/badge/python-2.7&3.4-yellow.svg)](https://www.python.org/) ![release](https://img.shields.io/badge/version-2.1.5.3-orange.svg) ![License](https://img.shields.io/badge/license-GPLv3-red.svg) **README.md [English](README.md)** diff --git a/lib/data/data.py b/lib/data/data.py index 8b5ce4d..4a4187d 100644 --- a/lib/data/data.py +++ b/lib/data/data.py @@ -56,7 +56,7 @@ def init_pystrs(): # start time pystrs.startime = time.time() - pystrs.version = '2.1.5.2#dev' + pystrs.version = '2.1.5.3#dev' # build configuration file element description pystrs.conf_head = "head" diff --git a/lib/fun/filter.py b/lib/fun/filter.py index baea12a..91e1b76 100644 --- a/lib/fun/filter.py +++ b/lib/fun/filter.py @@ -2,7 +2,7 @@ # coding:utf-8 # """ -Copyright (c) 2016-2019 LandGrey (https://github.com/LandGrey/pydictor) +Copyright (c) 2016-2021 LandGrey (https://github.com/LandGrey/pydictor) License: GNU GENERAL PUBLIC LICENSE Version 3 """ @@ -148,8 +148,8 @@ def repeat_filter(item, letter_repeat=pyoptions.letter_repeat, digital_repeat=py groups = groupby(item) repeat_dict = [{label: sum(1 for _ in group)} for label, group in groups] for r in repeat_dict: - key = r.keys()[0] - value = r.values()[0] + key = list(r.keys())[0] + value = list(r.values())[0] if key in string.ascii_letters: l_repeat = max(l_repeat, value) elif key in string.digits: diff --git a/tools/combiner.py b/tools/combiner.py index dedea08..04593ae 100644 --- a/tools/combiner.py +++ b/tools/combiner.py @@ -2,12 +2,13 @@ # coding:utf-8 # author: LandGrey """ -Copyright (c) 2016-2017 LandGrey (https://github.com/LandGrey/pydictor) +Copyright (c) 2016-2021 LandGrey (https://github.com/LandGrey/pydictor) License: GNU GENERAL PUBLIC LICENSE Version 3 """ from __future__ import unicode_literals import os +import codecs import mimetypes import traceback from lib.data.data import pyoptions @@ -35,9 +36,9 @@ def combiner_magic(*args): if mimetypes.guess_type(_)[0] == 'text/plain': combine_list.append(_) try: - with open(storepath, "a") as f: + with codecs.open(storepath, 'a', encoding="utf-8") as f: for onefile in combine_list: - with open(onefile, 'r') as tf: + with codecs.open(onefile, 'r', encoding="utf-8") as tf: f.write(tf.read()) finishprinter(storepath)