X-Git-Url: https://wagner.pp.ru/gitweb/?a=blobdiff_plain;f=convertdump.py;h=0f59e8282d6dc9e2e9fa481a1312201b6468c2bf;hb=HEAD;hp=937403b43bf1b137fa8ecca42e795298613efd2f;hpb=8819fec092bba922675ce35ee5248c0d52a482ae;p=oss%2Fljdump.git diff --git a/convertdump.py b/convertdump.py index 937403b..0f59e82 100755 --- a/convertdump.py +++ b/convertdump.py @@ -175,11 +175,39 @@ def addCommentsForId(outDoc, entry, username, id): if(parentId != ""): appendTextNode(outDoc, outComment, "parent_itemid", parentId) + +# regular expressions used in replaceLJTags() +# (global for later reuse - suggestion by jparise) + +userRE = re.compile('', re.IGNORECASE) +commRE = re.compile('', re.IGNORECASE) +namedCutRE = re.compile('', + re.IGNORECASE|re.DOTALL) +cutRE = re.compile('', re.IGNORECASE) +cutRE = re.compile('', re.IGNORECASE) +embedRE = re.compile('', re.IGNORECASE) + def replaceLJTags(entry): - # regex to replace tags - fixedUserTags = re.sub("", "\\1", entry) + rv = entry + + # replace lj user tags + rv = re.sub(userRE, '\\1', rv) + + # replace lj comm tags + rv = re.sub(commRE, '\\1', rv) + + # replace lj-cut tags + rv = re.sub(namedCutRE, '', rv) + rv = re.sub(cutRE, '', rv) + rv = re.sub(cutRE, '', rv) + + # replace lj-embed tags + # this doesn't actually work. LJ doesn't include the embedded content + # when ljdump calls 'getevents', but instead includes an lj-embed tag + # with an id and nothing else. + #rv = re.sub(embedRE, '', rv) - return fixedUserTags + return rv def usage():