diff options
author | workfork <workfork@yandex-team.ru> | 2022-02-10 16:46:43 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:43 +0300 |
commit | 89db6fe2fe2c32d2a832ddfeb04e8d078e301084 (patch) | |
tree | 49e222ea1c5804306084bb3ae065bb702625360f /build/scripts/generate_mf.py | |
parent | c3745173272d1cf5b0642debb40d019e7ae71094 (diff) | |
download | ydb-89db6fe2fe2c32d2a832ddfeb04e8d078e301084.tar.gz |
Restoring authorship annotation for <workfork@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'build/scripts/generate_mf.py')
-rw-r--r-- | build/scripts/generate_mf.py | 96 |
1 files changed, 48 insertions, 48 deletions
diff --git a/build/scripts/generate_mf.py b/build/scripts/generate_mf.py index 76997020cc4..a44a9699801 100644 --- a/build/scripts/generate_mf.py +++ b/build/scripts/generate_mf.py @@ -1,20 +1,20 @@ -import json -import logging -import optparse -import os -import sys +import json +import logging +import optparse +import os +import sys import io - + import process_command_files as pcf - -class BadMfError(Exception): - pass - - -class GplNotAllowed(Exception): - pass - - + +class BadMfError(Exception): + pass + + +class GplNotAllowed(Exception): + pass + + def process_quotes(s): for quote_char in '\'"': if s.startswith(quote_char) and s.endswith(quote_char): @@ -22,40 +22,40 @@ def process_quotes(s): return s -def parse_args(): +def parse_args(): args = pcf.get_args(sys.argv[1:]) lics, peers, free_args, credits = [], [], [], [] - current_list = free_args - for a in args: - if a == '-Ya,lics': - current_list = lics - elif a == '-Ya,peers': - current_list = peers + current_list = free_args + for a in args: + if a == '-Ya,lics': + current_list = lics + elif a == '-Ya,peers': + current_list = peers elif a == '-Ya,credits': current_list = credits - elif a and a.startswith('-'): - current_list = free_args - current_list.append(a) - else: - current_list.append(a) - - parser = optparse.OptionParser() - parser.add_option('--build-root') - parser.add_option('--module-name') - parser.add_option('-o', '--output') + elif a and a.startswith('-'): + current_list = free_args + current_list.append(a) + else: + current_list.append(a) + + parser = optparse.OptionParser() + parser.add_option('--build-root') + parser.add_option('--module-name') + parser.add_option('-o', '--output') parser.add_option('-c', '--credits-output') - parser.add_option('-t', '--type') - opts, _ = parser.parse_args(free_args) + parser.add_option('-t', '--type') + opts, _ = parser.parse_args(free_args) return lics, peers, credits, opts, - - + + def generate_header(meta): return '-' * 20 + meta.get('path', 'Unknown module') + '-' * 20 -def generate_mf(): +def generate_mf(): lics, peers, credits, options = parse_args() - + meta = { 'module_name': options.module_name, 'path': os.path.dirname(options.output), @@ -63,16 +63,16 @@ def generate_mf(): 'dependencies': [], 'license_texts': '' } - - build_root = options.build_root - file_name = os.path.join(build_root, options.output) - + + build_root = options.build_root + file_name = os.path.join(build_root, options.output) + if options.type != 'LIBRARY': for rel_filename in peers: with open(os.path.join(build_root, rel_filename + '.mf')) as peer_file: peer_meta = json.load(peer_file) meta['dependencies'].append(peer_meta) - + if credits: union_texts = [] for texts_file in credits: @@ -101,11 +101,11 @@ def generate_mf(): data = data.decode('utf-8') f.write(data) - with open(file_name, 'w') as mf_file: - json.dump(meta, mf_file, indent=4) - - -if __name__ == '__main__': + with open(file_name, 'w') as mf_file: + json.dump(meta, mf_file, indent=4) + + +if __name__ == '__main__': try: generate_mf() except Exception as e: |