File indexing completed on 2024-04-21 03:52:27
0001 # -*- coding: utf-8 -*- 0002 # 0003 # SPDX-FileCopyrightText: 2014 Aurélien Gâteau <agateau@kde.org> 0004 # SPDX-FileCopyrightText: 2014 Alex Merry <alex.merry@kdemail.net> 0005 # SPDX-FileCopyrightText: 2014 Alex Turbov <i.zaufi@gmail.com> 0006 # 0007 # SPDX-License-Identifier: BSD-2-Clause 0008 0009 def _quote(txt): 0010 return '"' + txt + '"' 0011 0012 0013 class DoxyfileWriter(object): 0014 """Makes it easy to write entries in a Doxyfile, correctly handling quoting 0015 """ 0016 def __init__(self, fl): 0017 self.fl = fl 0018 0019 def write_entry(self, key, value): 0020 """Write an entry 0021 0022 Args: 0023 key: the key part of the entry 0024 value: the value part of the entry. Can be a string, a list, a 0025 tuple or a boolean 0026 """ 0027 if isinstance(value, (list, tuple)): 0028 txt = ' '.join([_quote(x) for x in value]) 0029 elif isinstance(value, bool): 0030 txt = ['NO', 'YES'][value] 0031 else: 0032 txt = _quote(str(value)) 0033 self.fl.write(key + ' = ' + txt + '\n') 0034 0035 def write_entries(self, **kwargs): 0036 """ Call write_entry for all arguments passed""" 0037 for key, value in kwargs.items(): 0038 self.write_entry(key, value)