@@ -1,11 +1,12 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright 2014-2025 Mike Fährmann
|
# Copyright 2014-2026 Mike Fährmann
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License version 2 as
|
# it under the terms of the GNU General Public License version 2 as
|
||||||
# published by the Free Software Foundation.
|
# published by the Free Software Foundation.
|
||||||
|
|
||||||
|
import os
|
||||||
import sys
|
import sys
|
||||||
import logging
|
import logging
|
||||||
from . import version, config, option, output, extractor, job, util, exception
|
from . import version, config, option, output, extractor, job, util, exception
|
||||||
@@ -542,11 +543,14 @@ class InputManager():
|
|||||||
|
|
||||||
def _rewrite(self):
|
def _rewrite(self):
|
||||||
url, path, action, indicies = self._item
|
url, path, action, indicies = self._item
|
||||||
|
path_tmp = path + ".tmp"
|
||||||
lines = self.files[path]
|
lines = self.files[path]
|
||||||
action(lines, indicies)
|
action(lines, indicies)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open(path, "w", encoding="utf-8") as fp:
|
with open(path_tmp, "w", encoding="utf-8") as fp:
|
||||||
fp.writelines(lines)
|
fp.writelines(lines)
|
||||||
|
os.replace(path_tmp, path)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
self.log.warning(
|
self.log.warning(
|
||||||
"Unable to update '%s' (%s: %s)",
|
"Unable to update '%s' (%s: %s)",
|
||||||
|
|||||||
Reference in New Issue
Block a user