1
0
Fork 0
mirror of https://github.com/hb9fxq/gr-digitalhf synced 2024-11-18 10:47:46 +00:00
gr-digitalhf/docs/doxygen/doxyxml/text.py

47 lines
1.3 KiB
Python
Raw Normal View History

2018-10-24 18:17:58 +00:00
#
# Copyright 2010 Free Software Foundation, Inc.
#
# This file was generated by gr_modtool, a tool from the GNU Radio framework
# This file is a part of gr-digitalhf
#
2020-02-19 13:11:45 +00:00
# SPDX-License-Identifier: GPL-3.0-or-later
2018-10-24 18:17:58 +00:00
#
#
"""
Utilities for extracting text from generated classes.
"""
2020-02-19 13:11:45 +00:00
from __future__ import unicode_literals
2018-10-24 18:17:58 +00:00
def is_string(txt):
if isinstance(txt, str):
return True
try:
2020-02-19 13:11:45 +00:00
if isinstance(txt, str):
2018-10-24 18:17:58 +00:00
return True
except NameError:
pass
return False
def description(obj):
if obj is None:
return None
return description_bit(obj).strip()
def description_bit(obj):
if hasattr(obj, 'content'):
contents = [description_bit(item) for item in obj.content]
result = ''.join(contents)
elif hasattr(obj, 'content_'):
contents = [description_bit(item) for item in obj.content_]
result = ''.join(contents)
elif hasattr(obj, 'value'):
result = description_bit(obj.value)
elif is_string(obj):
return obj
else:
2020-02-19 13:11:45 +00:00
raise Exception('Expecting a string or something with content, content_ or value attribute')
2018-10-24 18:17:58 +00:00
# If this bit is a paragraph then add one some line breaks.
if hasattr(obj, 'name') and obj.name == 'para':
result += "\n\n"
return result