media/mtransport/third_party/import.py

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/media/mtransport/third_party/import.py	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,40 @@
     1.4 +#!/usr/bin/env python
     1.5 +# This Source Code Form is subject to the terms of the Mozilla Public
     1.6 +# License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 +# file, You can obtain one at http://mozilla.org/MPL/2.0/.
     1.8 +#
     1.9 +# Execute as: /import.py <source-distribution> <target-dir>
    1.10 +# <target-dir> must have 'IMPORT_FILES' in it
    1.11 +
    1.12 +import sys
    1.13 +import re
    1.14 +import os
    1.15 +import shutil
    1.16 +
    1.17 +def die(msg):
    1.18 +    sys.stderr.write('ERROR:' + msg + '\n')
    1.19 +    sys.exit(1)
    1.20 +    
    1.21 +DISTRO = sys.argv[1]
    1.22 +IMPORT_DIR = sys.argv[2]
    1.23 +FILES = []
    1.24 +
    1.25 +f = open("%s/IMPORT_FILES" % IMPORT_DIR)
    1.26 +for l in f:
    1.27 +    l = l.strip()
    1.28 +    l = l.strip("'")
    1.29 +    if l.startswith("#"):
    1.30 +        continue
    1.31 +    if not l:
    1.32 +        continue
    1.33 +    FILES.append(l)
    1.34 +
    1.35 +for f in FILES:
    1.36 +    print f
    1.37 +    SOURCE_PATH = "%s/%s"%(DISTRO,f)
    1.38 +    DEST_PATH = "%s/%s"%(IMPORT_DIR,f)
    1.39 +    if not os.path.exists(SOURCE_PATH):
    1.40 +        die("%s does not exist"%SOURCE_PATH)
    1.41 +    if not os.path.exists(os.path.dirname(DEST_PATH)):
    1.42 +        os.makedirs(os.path.dirname(DEST_PATH))
    1.43 +    shutil.copyfile(SOURCE_PATH, DEST_PATH)

mercurial