Bump version to 24.04.3.4
[LibreOffice.git] / bin / update / path.py
blob5acaafcace539dc8b42902d56536e73efda4eadc
1 # -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 import os
11 import subprocess
12 from sys import platform
14 def convert_to_unix(path):
15 if platform == "cygwin":
16 return subprocess.check_output(["cygpath", "-u", path]).decode("utf-8", "strict").rstrip()
17 else:
18 return path
21 def convert_to_native(path):
22 if platform == "cygwin":
23 return subprocess.check_output(["cygpath", "-m", path]).decode("utf-8", "strict").rstrip()
24 else:
25 return path
28 class UpdaterPath(object):
30 def __init__(self, workdir):
31 self._workdir = convert_to_unix(workdir)
33 def get_workdir(self):
34 return self._workdir
36 def get_update_dir(self):
37 return os.path.join(self._workdir, "update-info")
39 def get_current_build_dir(self):
40 return os.path.join(self._workdir, "mar", "current-build")
42 def get_mar_dir(self):
43 return os.path.join(self._workdir, "mar")
45 def get_previous_build_dir(self):
46 return os.path.join(self._workdir, "mar", "previous-build")
48 def get_language_dir(self):
49 return os.path.join(self.get_mar_dir(), "language")
51 def ensure_dir_exist(self):
52 os.makedirs(self.get_update_dir(), exist_ok=True)
53 os.makedirs(self.get_current_build_dir(), exist_ok=True)
54 os.makedirs(self.get_mar_dir(), exist_ok=True)
55 os.makedirs(self.get_previous_build_dir(), exist_ok=True)
56 os.makedirs(self.get_language_dir(), exist_ok=True)
58 # vim: set shiftwidth=4 softtabstop=4 expandtab: