calc: on editing invalidation of view with different zoom is wrong
[LibreOffice.git] / bin / update / uncompress_mar.py
blob14726dd96178b28958ae3f85d2938612894428d6
1 #!/usr/bin/env python3
2 # -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
4 # This file is part of the LibreOffice project.
6 # This Source Code Form is subject to the terms of the Mozilla Public
7 # License, v. 2.0. If a copy of the MPL was not distributed with this
8 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 # Extract a mar file and uncompress the content
13 import os
14 import re
15 import sys
16 import subprocess
17 from path import convert_to_native
20 def uncompress_content(file_path):
21 bzip2 = os.environ.get('BZIP2', 'bzip2')
22 file_path_compressed = file_path + ".bz2"
23 os.rename(file_path, file_path_compressed)
24 subprocess.check_call([bzip2, "-d", convert_to_native(file_path_compressed)])
27 def extract_mar(mar_file, target_dir):
28 mar = os.environ.get('MAR', 'mar')
29 subprocess.check_call([mar, "-C", convert_to_native(target_dir), "-x", convert_to_native(mar_file)])
30 file_info = subprocess.check_output([mar, "-t", convert_to_native(mar_file)])
31 lines = file_info.splitlines()
32 prog = re.compile(r"\d+\s+\d+\s+(.+)")
33 for line in lines:
34 match = prog.match(line.decode("utf-8", "strict"))
35 if match is None:
36 continue
37 info = match.groups()[0]
38 # ignore header line
39 if info == b'NAME':
40 continue
42 uncompress_content(os.path.join(target_dir, info))
45 def main():
46 if len(sys.argv) != 3:
47 print("Help: This program takes exactly two arguments pointing to a mar file and a target location")
48 sys.exit(1)
50 mar_file = sys.argv[1]
51 target_dir = sys.argv[2]
52 extract_mar(mar_file, target_dir)
55 if __name__ == "__main__":
56 main()
58 # vim: set shiftwidth=4 softtabstop=4 expandtab: