From 3a833923c087ce98a11ed26ab1e48d86b1e2a2b6 Mon Sep 17 00:00:00 2001 From: jonct <2807816+jonct@users.noreply.github.com> Date: Mon, 15 Jul 2024 01:54:39 -0400 Subject: [PATCH] Extract file utils --- src/jlmkr/donor/jlmkr.py | 7 +------ src/jlmkr/utils/files.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 6 deletions(-) create mode 100644 src/jlmkr/utils/files.py diff --git a/src/jlmkr/donor/jlmkr.py b/src/jlmkr/donor/jlmkr.py index bdfba90..ce3ded9 100755 --- a/src/jlmkr/donor/jlmkr.py +++ b/src/jlmkr/donor/jlmkr.py @@ -707,12 +707,7 @@ def run_lxc_download_script( return 0 -def stat_chmod(file_path, mode): - """ - Change mode if file doesn't already have this mode. - """ - if mode != stat.S_IMODE(os.stat(file_path).st_mode): - os.chmod(file_path, mode) +from utils.files import stat_chmod def get_mount_point(path): diff --git a/src/jlmkr/utils/files.py b/src/jlmkr/utils/files.py new file mode 100644 index 0000000..a328223 --- /dev/null +++ b/src/jlmkr/utils/files.py @@ -0,0 +1,14 @@ +# SPDX-FileCopyrightText: © 2024 Jip-Hop and the Jailmakers +# +# SPDX-License-Identifier: LGPL-3.0-only + +import os +import stat + + +def stat_chmod(file_path, mode): + """ + Change mode if file doesn't already have this mode. + """ + if mode != stat.S_IMODE(os.stat(file_path).st_mode): + os.chmod(file_path, mode)