src/tools/Package-All.py [53:109]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    return imports, codes


def write_merged_code(code, merged_file_full_path):
    with open(merged_file_full_path, 'a+') as py_file:
        py_file.write(code)


def insert_copyright_notice(merged_file_full_path, merged_file_name):
    notice = '# --------------------------------------------------------------------------------------------------------------------\n'
    notice += '# <copyright file="' + merged_file_name + '" company="Microsoft">\n'
    notice += '#   Copyright 2020 Microsoft Corporation\n' \
              '#\n' \
              '#   Licensed under the Apache License, Version 2.0 (the "License");\n' \
              '#   you may not use this file except in compliance with the License.\n' \
              '#   You may obtain a copy of the License at\n' \
              '#\n' \
              '#     http://www.apache.org/licenses/LICENSE-2.0\n' \
              '#\n' \
              '#   Unless required by applicable law or agreed to in writing, software\n' \
              '#   distributed under the License is distributed on an "AS IS" BASIS,\n' \
              '#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n' \
              '#   See the License for the specific language governing permissions and\n' \
              '#   limitations under the License.\n' \
              '#\n' \
              '#   Requires Python 2.7+\n'
    notice += '# </copyright>\n'
    notice += '# --------------------------------------------------------------------------------------------------------------------\n\n'
    prepend_content_to_file(notice, merged_file_full_path)


# noinspection PyPep8
def replace_text_in_file(file_path, old_text, new_text):
    with open(file_path, 'rb') as file_handle: text = file_handle.read()
    text = text.replace(old_text.encode(encoding='UTF-8'), new_text.encode(encoding='UTF-8'))
    with open(file_path, 'wb') as file_handle: file_handle.write(text)


def insert_imports(imports, merged_file_name):
    imports_str = ''.join(imports)
    prepend_content_to_file(imports_str, merged_file_name)


def prepend_content_to_file(content, file_name):
    temp_file = os.path.join(os.path.dirname(file_name), "temp_.py")
    with open(file_name, 'r') as file1:
        with open(temp_file, 'w+') as file2:
            file2.write(content)
            file2.write(file1.read())
    if os.name.lower() == 'nt':
        os.unlink(file_name)
    os.rename(temp_file, file_name)


def generate_compiled_script(source_code_path, merged_file_full_path, merged_file_name, environment):
    try:
        print('\n\n=============================== GENERATING ' + merged_file_name + '... =============================================================\n')
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



src/tools/Package-Core.py [56:112]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    return imports, codes


def write_merged_code(code, merged_file_full_path):
    with open(merged_file_full_path, 'a+') as py_file:
        py_file.write(code)


def insert_copyright_notice(merged_file_full_path, merged_file_name):
    notice = '# --------------------------------------------------------------------------------------------------------------------\n'
    notice += '# <copyright file="' + merged_file_name + '" company="Microsoft">\n'
    notice += '#   Copyright 2020 Microsoft Corporation\n' \
              '#\n' \
              '#   Licensed under the Apache License, Version 2.0 (the "License");\n' \
              '#   you may not use this file except in compliance with the License.\n' \
              '#   You may obtain a copy of the License at\n' \
              '#\n' \
              '#     http://www.apache.org/licenses/LICENSE-2.0\n' \
              '#\n' \
              '#   Unless required by applicable law or agreed to in writing, software\n' \
              '#   distributed under the License is distributed on an "AS IS" BASIS,\n' \
              '#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n' \
              '#   See the License for the specific language governing permissions and\n' \
              '#   limitations under the License.\n' \
              '#\n' \
              '#   Requires Python 2.7+\n'
    notice += '# </copyright>\n'
    notice += '# --------------------------------------------------------------------------------------------------------------------\n\n'
    prepend_content_to_file(notice, merged_file_full_path)


# noinspection PyPep8
def replace_text_in_file(file_path, old_text, new_text):
    with open(file_path, 'rb') as file_handle: text = file_handle.read()
    text = text.replace(old_text.encode(encoding='UTF-8'), new_text.encode(encoding='UTF-8'))
    with open(file_path, 'wb') as file_handle: file_handle.write(text)


def insert_imports(imports, merged_file_name):
    imports_str = ''.join(imports)
    prepend_content_to_file(imports_str, merged_file_name)


def prepend_content_to_file(content, file_name):
    temp_file = os.path.join(os.path.dirname(file_name), "temp_.py")
    with open(file_name, 'r') as file1:
        with open(temp_file, 'w+') as file2:
            file2.write(content)
            file2.write(file1.read())
    if os.name.lower() == 'nt':
        os.unlink(file_name)
    os.rename(temp_file, file_name)


def generate_compiled_script(source_code_path, merged_file_full_path, merged_file_name, environment):
    try:
        print('\n\n=============================== GENERATING ' + merged_file_name + '... =============================================================\n')
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



