mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-08 05:24:39 +01:00
don't replace old-style format strings when "formatted" attribute == false
This commit is contained in:
parent
68f72451cd
commit
624f78af8f
1 changed files with 10 additions and 8 deletions
|
@ -120,14 +120,16 @@ def printStats( doc ):
|
||||||
|
|
||||||
def replacePcts( doc ):
|
def replacePcts( doc ):
|
||||||
pat = re.compile( '(%[sd])', re.DOTALL | re.MULTILINE )
|
pat = re.compile( '(%[sd])', re.DOTALL | re.MULTILINE )
|
||||||
for string in doc.findall('string'):
|
for typ in ['item', 'string']:
|
||||||
splits = re.split( pat, string.text )
|
for elem in doc.findall(typ):
|
||||||
nParts = len(splits)
|
if 'false' == elem.get('formatted'): continue
|
||||||
if 1 < nParts:
|
splits = re.split( pat, elem.text )
|
||||||
for ii in range(nParts):
|
nParts = len(splits)
|
||||||
part = splits[ii]
|
if 1 < nParts:
|
||||||
if re.match( pat, part ): splits[ii] = longFormFor(part)
|
for ii in range(nParts):
|
||||||
string.text = ''.join( splits )
|
part = splits[ii]
|
||||||
|
if re.match( pat, part ): splits[ii] = longFormFor(part)
|
||||||
|
elem.text = ''.join( splits )
|
||||||
|
|
||||||
# For each name in pairs, check if it's in doc. If not, find the last
|
# For each name in pairs, check if it's in doc. If not, find the last
|
||||||
# elem before it that is in doc and insert it after. Start over each
|
# elem before it that is in doc and insert it after. Start over each
|
||||||
|
|
Loading…
Reference in a new issue