Skip to content

Commit

Permalink
Update generate_licenses.py
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterK0927 committed Apr 6, 2024
1 parent ef65323 commit 1de22db
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions script/generate_licenses.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,36 +161,36 @@ def validated_data_field(data, field_name):
return field_value


# def generate_backgrounds_license(preamble, backgrounds):
# notices = ''

# for background in backgrounds:
# if notices:
# notices += '\n'

# filename = validated_data_field(background, 'wallpaperImageUrl')
# author_name = validated_data_field(background, 'author')
# # Don't validate link. it can be empty.
# author_link = background['link']
# original_url = validated_data_field(background, 'originalUrl')
# license_text = validated_data_field(background, 'license')
# if license_text != 'used with permission' \
# and license_text[0:8] != 'https://' \
# and license_text[0:7] != 'http://':
# print('Invalid license for background image ' \
# f"{background['name']}. It needs to be a URL or the " \
# 'string "used with permission".')
# sys.exit(1)

# if author_link != '':
# notices += f'File: {filename}\nAuthor: {author_name} ' \
# f'({author_link})\nURL: {original_url}\n' \
# f'License: {license_text}\n'
# else:
# notices += f'File: {filename}\nAuthor: {author_name}\n' \
# f'URL: {original_url}\nLicense: {license_text}\n'

# return f'{preamble}\n\n{notices}'
def generate_backgrounds_license(preamble, backgrounds):
notices = ''

for background in backgrounds:
if notices:
notices += '\n'

filename = validated_data_field(background, 'wallpaperImageUrl')
author_name = validated_data_field(background, 'author')
# Don't validate link. it can be empty.
author_link = background['link']
original_url = validated_data_field(background, 'originalUrl')
license_text = validated_data_field(background, 'license')
if license_text != 'used with permission' \
and license_text[0:8] != 'https://' \
and license_text[0:7] != 'http://':
print('Invalid license for background image ' \
f"{background['name']}. It needs to be a URL or the " \
'string "used with permission".')
sys.exit(1)

if author_link != '':
notices += f'File: {filename}\nAuthor: {author_name} ' \
f'({author_link})\nURL: {original_url}\n' \
f'License: {license_text}\n'
else:
notices += f'File: {filename}\nAuthor: {author_name}\n' \
f'URL: {original_url}\nLicense: {license_text}\n'

return f'{preamble}\n\n{notices}'


def main():
Expand Down

0 comments on commit 1de22db

Please sign in to comment.