Last active
April 5, 2020 18:03
-
-
Save Ehsanul-Hoque/fd53e56e11f9f09d1f3c54928a674418 to your computer and use it in GitHub Desktop.
Python code for generating release apk automatically (Part 2)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fileinput | |
# ... | |
# Function for overwriting gradle.properties file | |
def overwriteGradleProperties(source_item_dict): | |
global input_company_id | |
global app_properties_keys | |
print('\nOVERWRITING gradle.properties file...') | |
# Iterate over every line of the gradle.properties file | |
for line in fileinput.input(constants.GRADLE_PROPERTIES_FILE, inplace=True): | |
# Check if this line contains keystore filename | |
if line.startswith(constants.GRADLE_KEY_KEYSTORE_INFO_FILE): | |
print((constants.GRADLE_KEY_KEYSTORE_INFO_FILE | |
+ '=' | |
+ constants.KEYSTORE_FOLDER + input_key_filename + constants.KEYSTORE_PROPERTIES_FILE_NAME_SUFFIX)) | |
else: | |
replaced = False | |
# Iterate over the list of keys to check if the current line contains any key. | |
# If it does contain a key, replace the line with the given value from JSON | |
for key_dictionary in app_properties_keys: | |
if line.startswith(key_dictionary['gradle_key']): | |
print(key_dictionary['gradle_key'] + '=' + source_item_dict[key_dictionary['json_key']]) | |
replaced = True; | |
# If the line doesn't contain any gradle key, don't change anything in that line | |
if not replaced: | |
print(line, end='') | |
print('gradle.properties file overwritten for company with id = ' + str(input_company_id)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment