Removing html formatting from patch

main
Bob Mottram 2020-05-02 17:06:13 +00:00
parent b5053a9155
commit 03f88377dd
2 changed files with 15 additions and 10 deletions

16
git.py
View File

@ -9,6 +9,17 @@ __status__ = "Production"
import os import os
def gitFormatContent(content) -> str:
""" replace html formatting, so that it's more
like the original patch file
"""
contentStr = content.replace('<br>', '\n').replace('<br \>', '\n')
contentStr = contentStr.replace('<p>', '').replace('</p>', '\n')
if 'From ' in contentStr:
contentStr = contentStr.split('From ', 1)[1]
return contentStr
def getGitProjectName(baseDir: str, nickname: str, domain: str, def getGitProjectName(baseDir: str, nickname: str, domain: str,
subject: str) -> str: subject: str) -> str:
"""Returns the project name for a git patch """Returns the project name for a git patch
@ -76,10 +87,7 @@ def receiveGitPatch(baseDir: str, nickname: str, domain: str,
subject, content): subject, content):
return False return False
# replace html formatting, so that it's more contentStr = gitFormatContent(content)
# like the original patch file
contentStr = content.replace('<br>', '\n').replace('<br />', '\n')
contentStr = contentStr.replace('<p>', '').replace('</p>', '\n')
patchLines = contentStr.split('\n') patchLines = contentStr.split('\n')
patchFilename = None patchFilename = None

View File

@ -60,7 +60,7 @@ from question import questionUpdateVotes
from media import replaceYouTube from media import replaceYouTube
from git import isGitPatch from git import isGitPatch
from git import receiveGitPatch from git import receiveGitPatch
from git import gitFormatContent
def storeHashTags(baseDir: str, nickname: str, postJsonObject: {}) -> None: def storeHashTags(baseDir: str, nickname: str, postJsonObject: {}) -> None:
"""Extracts hashtags from an incoming post and updates the """Extracts hashtags from an incoming post and updates the
@ -1708,12 +1708,9 @@ def gitPatchNotify(baseDir: str, handle: str,
patchFile = accountDir + '/.newPatch' patchFile = accountDir + '/.newPatch'
with open(patchFile, 'w') as fp: with open(patchFile, 'w') as fp:
fp.write(subject) fp.write(subject)
contentStr = content.replace('<br>', '\n').replace('<br \>', '\n')
contentStr = contentStr.replace('<p>', '').replace('</p>', '\n')
if 'From ' in contentStr:
contentStr = contentStr.split('From ', 1)[1]
with open(patchFile + 'Content', 'w') as fp: with open(patchFile + 'Content', 'w') as fp:
fp.write(contentStr) fp.write(gitFormatContent(content))
def groupHandle(baseDir: str, handle: str) -> bool: def groupHandle(baseDir: str, handle: str) -> bool: