Limit print statement by using logging module

python3 Gramps.py -d "gui.uimanager"
This commit is contained in:
romjerome 2021-04-05 09:29:42 +02:00 committed by Nick Hall
parent d4d9e302f8
commit 001941ede3

View File

@ -173,10 +173,10 @@ class UIManager():
if((len(child) == 1 and child.tag == "submenu") or if((len(child) == 1 and child.tag == "submenu") or
(len(child) == 0 and child.tag == "section")): (len(child) == 0 and child.tag == "section")):
# remove empty submenus and sections # remove empty submenus and sections
# print('del', child.tag, child.attrib) LOG.debug(('del', child.tag, child.attrib))
del parents[indx] del parents[indx]
continue continue
# print(child.attrib) LOG.debug((child.attrib))
groups = child.get('groups') groups = child.get('groups')
if not groups: if not groups:
indx += 1 indx += 1
@ -187,8 +187,8 @@ class UIManager():
indx += 1 indx += 1
break break
else: else:
#print('del', child.tag, child.attrib, parents.tag, LOG.debug(('del', child.tag, child.attrib, parents.tag,
# parents.attrib) parents.attrib))
del parents[indx] del parents[indx]
break break
# The following looks for 'placeholder' elements and if found, # The following looks for 'placeholder' elements and if found,
@ -198,8 +198,8 @@ class UIManager():
while indx < len(parents): while indx < len(parents):
if parents[indx].tag == "placeholder": if parents[indx].tag == "placeholder":
subtree = parents[indx] subtree = parents[indx]
#print('placholder del', parents[indx].tag, LOG.debug(('placholder del', parents[indx].tag,
# parents[indx].attrib, parents.tag, parents.attrib) parents[indx].attrib, parents.tag, parents.attrib))
del parents[indx] del parents[indx]
for child in subtree: for child in subtree:
parents.insert(indx, child) parents.insert(indx, child)
@ -223,7 +223,7 @@ class UIManager():
# file.write(xml_str) # file.write(xml_str)
# with open('try.xml', encoding='utf8') as file: # with open('try.xml', encoding='utf8') as file:
# xml_str = file.read() # xml_str = file.read()
# print(xml_str) #LOG.info(xml_str)
self.builder = Gtk.Builder() self.builder = Gtk.Builder()
self.builder.set_translation_domain(glocale.get_localedomain()) self.builder.set_translation_domain(glocale.get_localedomain())
self.builder.add_from_string(xml_str) self.builder.add_from_string(xml_str)
@ -251,7 +251,7 @@ class UIManager():
toolbar.show_all() toolbar.show_all()
else: else:
toolbar.hide() toolbar.hide()
#print('*** Update ui') LOG.info('*** Update ui')
def add_ui_from_string(self, changexml): def add_ui_from_string(self, changexml):
""" This performs a merge operation on the xml elements that have """ This performs a merge operation on the xml elements that have
@ -284,14 +284,14 @@ class UIManager():
# This allow addition of popups etc. # This allow addition of popups etc.
self.et_xml.append(update) self.et_xml.append(update)
#results = ET.tostring(self.et_xml, encoding="unicode") #results = ET.tostring(self.et_xml, encoding="unicode")
#print(results) #LOG.info(results)
#print ('*** Add ui') LOG.info('*** Add ui')
return changexml return changexml
except: except:
# the following is only here to assist debug # the following is only here to assist debug
print('*****', sys.exc_info()) LOG.debug('*****', sys.exc_info())
print(xml) LOG.debug(xml)
print(changexml) LOG.debug(changexml)
assert False assert False
def remove_ui(self, change_xml): def remove_ui(self, change_xml):
@ -317,8 +317,8 @@ class UIManager():
for dummy in range(len(element)): for dummy in range(len(element)):
del element[0] del element[0]
#results = ET.tostring(self.et_xml, encoding="unicode") #results = ET.tostring(self.et_xml, encoding="unicode")
#print(results) #LOG.info(results)
#print ('*** Remove ui') LOG.info('*** Remove ui')
return return
def get_widget(self, obj): def get_widget(self, obj):
@ -411,7 +411,7 @@ class UIManager():
self.set_actions_sensitive(group, False) self.set_actions_sensitive(group, False)
except: except:
# the following is only to assist in debug # the following is only to assist in debug
print(group.name, item) LOG.debug(group.name, item)
assert False assert False
def remove_action_group(self, group): def remove_action_group(self, group):