KApiDox

doxyfilewriter.py
1 # -*- coding: utf-8 -*-
2 #
3 # SPDX-FileCopyrightText: 2014 Aurélien Gâteau <[email protected]>
4 # SPDX-FileCopyrightText: 2014 Alex Merry <[email protected]>
5 # SPDX-FileCopyrightText: 2014 Alex Turbov <[email protected]>
6 #
7 # SPDX-License-Identifier: BSD-2-Clause
8 
9 def _quote(txt):
10  return '"' + txt + '"'
11 
12 class DoxyfileWriter(object):
13  """Makes it easy to write entries in a Doxyfile, correctly handling quoting
14  """
15  def __init__(self, fl):
16  self.fl = fl
17 
18  def write_entry(self, key, value):
19  """Write an entry
20 
21  Args:
22  key: the key part of the entry
23  value: the value part of the entry. Can be a string, a list, a
24  tuple or a boolean
25  """
26  if isinstance(value, (list, tuple)):
27  txt = ' '.join([_quote(x) for x in value])
28  elif isinstance(value, bool):
29  txt = ['NO', 'YES'][value]
30  else:
31  txt = _quote(str(value))
32  self.fl.write(key + ' = ' + txt + '\n')
33 
34  def write_entries(self, **kwargs):
35  """ Call write_entry for all arguments passed"""
36  for key, value in kwargs.items():
37  self.write_entry(key, value)
def write_entry(self, key, value)
Write an entry.
def write_entries(self, kwargs)
Call write_entry for all arguments passed.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Nov 30 2020 22:54:36 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.