Skip to content

Commit

Permalink
When text and textclass are used as arguments (the FQL library passes…
Browse files Browse the repository at this point in the history
… this), then textclass is interpreted as settextclass. (proycon/flat#173)
  • Loading branch information
proycon committed Jul 1, 2021
1 parent 8dff344 commit 2014b35
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions folia/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,20 @@ def parsecommonarguments(self, doc, **kwargs):
else:
self.auth = self.__class__.AUTH


if 'textclass' in kwargs:
if 'text' in kwargs:
#we are editing a text and providing a textclass,
#then what we want is settextclass rather than textclass
#(which is for provenance). This may be needed for the FQL library:
kwargs['settextclass'] = kwargs['textclass']
elif not Attrib.TEXTCLASS in supported:
raise ValueError("Textclass is not supported for " + self.__class__.__name__)
else:
self.textclass = kwargs['textclass']
del kwargs['textclass']
else:
if Attrib.TEXTCLASS in supported:
self.textclass = "current"

if 'text' in kwargs:
if kwargs['text']:
Expand All @@ -986,14 +999,6 @@ def parsecommonarguments(self, doc, **kwargs):
self.setphon(kwargs['phon'])
del kwargs['phon']

if 'textclass' in kwargs:
if not Attrib.TEXTCLASS in supported:
raise ValueError("Textclass is not supported for " + self.__class__.__name__)
self.textclass = kwargs['textclass']
del kwargs['textclass']
else:
if Attrib.TEXTCLASS in supported:
self.textclass = "current"

if 'tag' in kwargs:
if kwargs['tag']:
Expand Down Expand Up @@ -4454,8 +4459,9 @@ def text(self, normalize_spaces=False, trim_spaces=True):
"""Obtain the text (unicode instance)"""
return super(TextContent,self).text(normalize_spaces=normalize_spaces, trim_spaces=trim_spaces) #AbstractElement will handle it now, merely overridden to get rid of parameters that dont make sense in this context

def settext(self, text):
def settext(self, text, cls=None):
self.data = [text]
if cls is not None: self.cls = cls
if not self.data:
raise ValueError("Empty text content elements are not allowed")
#if isstring(self.data[0]) and (self.data[0] != self.data[0].translate(ILLEGAL_UNICODE_CONTROL_CHARACTERS)):
Expand Down

0 comments on commit 2014b35

Please sign in to comment.