main
Bob Mottram 2021-06-26 22:29:49 +01:00
parent 139cffa0d5
commit c5815a2564
2 changed files with 41 additions and 15 deletions

View File

@ -852,6 +852,30 @@ def _addAutoCW(baseDir: str, nickname: str, domain: str,
return newSubject
def _createPostCWFromReply(baseDir: str, nickname: str, domain: str,
inReplyTo: str,
sensitive: bool, summary: str) -> (bool, str):
"""If this is a reply and the original post has a CW
then use the same CW
"""
if inReplyTo and not sensitive:
# locate the post which this is a reply to and check if
# it has a content warning. If it does then reproduce
# the same warning
replyPostFilename = \
locatePost(baseDir, nickname, domain, inReplyTo)
if replyPostFilename:
replyToJson = loadJson(replyPostFilename)
if replyToJson:
if replyToJson.get('object'):
if replyToJson['object'].get('sensitive'):
if replyToJson['object']['sensitive']:
sensitive = True
if replyToJson['object'].get('summary'):
summary = replyToJson['object']['summary']
return sensitive, summary
def _createPostBase(baseDir: str, nickname: str, domain: str, port: int,
toUrl: str, ccUrl: str, httpPrefix: str, content: str,
followersOnly: bool, saveToFile: bool,
@ -952,21 +976,9 @@ def _createPostBase(baseDir: str, nickname: str, domain: str, port: int,
_updateHashtagsIndex(baseDir, tag, newPostId)
# print('Content tags: ' + str(tags))
if inReplyTo and not sensitive:
# locate the post which this is a reply to and check if
# it has a content warning. If it does then reproduce
# the same warning
replyPostFilename = \
locatePost(baseDir, nickname, domain, inReplyTo)
if replyPostFilename:
replyToJson = loadJson(replyPostFilename)
if replyToJson:
if replyToJson.get('object'):
if replyToJson['object'].get('sensitive'):
if replyToJson['object']['sensitive']:
sensitive = True
if replyToJson['object'].get('summary'):
summary = replyToJson['object']['summary']
sensitive, summary = \
_createPostCWFromReply(baseDir, nickname, domain,
inReplyTo, sensitive, summary)
# get the ending date and time
endDateStr = None

View File

@ -3016,6 +3016,7 @@ def _testFunctions():
if not line.strip().startswith('def '):
if lineCount > 0:
lineCount += 1
# add LOC count for this function
if len(prevLine.strip()) == 0 and \
len(line.strip()) == 0 and \
lineCount > 2:
@ -3051,6 +3052,19 @@ def _testFunctions():
"module": modName,
"calledInModule": []
}
# LOC count for the last function
if lineCount > 2:
lineCount -= 2
if lineCount > 80:
locStr = str(lineCount) + ';' + methodName
if lineCount < 1000:
locStr = '0' + locStr
if lineCount < 100:
locStr = '0' + locStr
if lineCount < 10:
locStr = '0' + locStr
if locStr not in methodLOC:
methodLOC.append(locStr)
break
print('LOC counts:')