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()
30 def convert_to_native(path
):
31 if platform
== "cygwin":
32 return subprocess
.check_output(["cygpath", "-m", path
]).decode("utf-8", "strict").rstrip()
36 class UpdaterPath(object):
38 def __init__(self
, workdir
):
39 self
._workdir
= convert_to_unix(workdir
)
41 def get_workdir(self
):
44 def get_update_dir(self
):
45 return os
.path
.join(self
._workdir
, "update-info")
47 def get_current_build_dir(self
):
48 return os
.path
.join(self
._workdir
, "mar", "current-build")
50 def get_mar_dir(self
):
51 return os
.path
.join(self
._workdir
, "mar")
53 def get_previous_build_dir(self
):
54 return os
.path
.join(self
._workdir
, "mar", "previous-build")
56 def get_language_dir(self
):
57 return os
.path
.join(self
.get_mar_dir(), "language")
59 def get_workdir(self
):
62 def ensure_dir_exist(self
):
63 mkdir_p(self
.get_update_dir())
64 mkdir_p(self
.get_current_build_dir())
65 mkdir_p(self
.get_mar_dir())
66 mkdir_p(self
.get_previous_build_dir())
67 mkdir_p(self
.get_language_dir())
69 # vim: set shiftwidth=4 softtabstop=4 expandtab: