openlp/tests/utils/osdinteraction.py

41 lines
1.9 KiB
Python
Raw Normal View History

# -*- coding: utf-8 -*-
2019-04-13 13:00:22 +00:00
##########################################################################
# OpenLP - Open Source Lyrics Projection #
# ---------------------------------------------------------------------- #
2022-02-06 09:10:17 +00:00
# Copyright (c) 2008-2022 OpenLP Developers #
2019-04-13 13:00:22 +00:00
# ---------------------------------------------------------------------- #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
##########################################################################
"""
The :mod:`osdinteraction` provides miscellaneous functions for interacting with
OSD files.
"""
import json
2017-12-28 08:22:55 +00:00
import os
from tests.utils.constants import TEST_RESOURCES_PATH
def read_service_from_file(file_name):
"""
Reads an OSD file and returns the first service item found therein.
@param file_name: File name of an OSD file residing in the tests/resources folder.
@return: The service contained in the file.
"""
service_file = os.path.join(TEST_RESOURCES_PATH, 'service', file_name)
2013-08-31 18:17:38 +00:00
with open(service_file, 'r') as open_file:
service = json.load(open_file)
return service