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/.
13 from sys
import platform
18 except OSError as exc
: # Python >2.5
19 if exc
.errno
== errno
.EEXIST
and os
.path
.isdir(path
):
24 def convert_to_unix(path
):
25 if platform
== "cygwin":
26 return subprocess
.check_output(["cygpath", "-u", path
]).decode("utf-8", "strict").rstrip()
31 def convert_to_native(path
):
32 if platform
== "cygwin":
33 return subprocess
.check_output(["cygpath", "-m", path
]).decode("utf-8", "strict").rstrip()
38 class UpdaterPath(object):
40 def __init__(self
, workdir
):
41 self
._workdir
= convert_to_unix(workdir
)
43 def get_workdir(self
):
46 def get_update_dir(self
):
47 return os
.path
.join(self
._workdir
, "update-info")
49 def get_current_build_dir(self
):
50 return os
.path
.join(self
._workdir
, "mar", "current-build")
52 def get_mar_dir(self
):
53 return os
.path
.join(self
._workdir
, "mar")
55 def get_previous_build_dir(self
):
56 return os
.path
.join(self
._workdir
, "mar", "previous-build")
58 def get_language_dir(self
):
59 return os
.path
.join(self
.get_mar_dir(), "language")
61 def ensure_dir_exist(self
):
62 os
.makedirs(self
.get_update_dir(), exist_ok
=True)
63 os
.makedirs(self
.get_current_build_dir(), exist_ok
=True)
64 os
.makedirs(self
.get_mar_dir(), exist_ok
=True)
65 os
.makedirs(self
.get_previous_build_dir(), exist_ok
=True)
66 os
.makedirs(self
.get_language_dir(), exist_ok
=True)
68 # vim: set shiftwidth=4 softtabstop=4 expandtab: