Deprecated since Python 3.14: codecs.open() has been superseded by open()

This commit is contained in:
Ivan Kravets
2025-12-29 19:06:58 +02:00
parent 7540c9b3ef
commit 5f8c97fbaf
2 changed files with 4 additions and 6 deletions
+2 -3
View File
@@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import codecs
import hashlib
import os
from time import time
@@ -57,7 +56,7 @@ class ContentCache:
cache_path = self.get_cache_path(key)
if not os.path.isfile(cache_path):
return None
with codecs.open(cache_path, "rb", encoding="utf8") as fp:
with open(cache_path, "r", encoding="utf8") as fp:
return fp.read()
def set(self, key, data, valid):
@@ -78,7 +77,7 @@ class ContentCache:
if not os.path.isdir(os.path.dirname(cache_path)):
os.makedirs(os.path.dirname(cache_path))
try:
with codecs.open(cache_path, mode="wb", encoding="utf8") as fp:
with open(cache_path, mode="w", encoding="utf8") as fp:
fp.write(data)
with open(self._db_path, mode="a", encoding="utf8") as fp:
fp.write("%s=%s\n" % (str(expire_time), os.path.basename(cache_path)))
+2 -3
View File
@@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import codecs
import os
import sys
@@ -167,12 +166,12 @@ class ProjectGenerator:
@staticmethod
def _render_tpl(tpl_path, tpl_vars):
with codecs.open(tpl_path, "r", encoding="utf8") as fp:
with open(tpl_path, "r", encoding="utf8") as fp:
return bottle.template(fp.read(), **tpl_vars)
@staticmethod
def _merge_contents(dst_path, contents):
if os.path.basename(dst_path) == ".gitignore" and os.path.isfile(dst_path):
return
with codecs.open(dst_path, "w", encoding="utf8") as fp:
with open(dst_path, "w", encoding="utf8") as fp:
fp.write(contents)