mirror of https://gitlab.com/bashrc2/epicyon
Tidying
parent
139cffa0d5
commit
c5815a2564
42
posts.py
42
posts.py
|
@ -852,6 +852,30 @@ def _addAutoCW(baseDir: str, nickname: str, domain: str,
|
||||||
return newSubject
|
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,
|
def _createPostBase(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
toUrl: str, ccUrl: str, httpPrefix: str, content: str,
|
toUrl: str, ccUrl: str, httpPrefix: str, content: str,
|
||||||
followersOnly: bool, saveToFile: bool,
|
followersOnly: bool, saveToFile: bool,
|
||||||
|
@ -952,21 +976,9 @@ def _createPostBase(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
_updateHashtagsIndex(baseDir, tag, newPostId)
|
_updateHashtagsIndex(baseDir, tag, newPostId)
|
||||||
# print('Content tags: ' + str(tags))
|
# print('Content tags: ' + str(tags))
|
||||||
|
|
||||||
if inReplyTo and not sensitive:
|
sensitive, summary = \
|
||||||
# locate the post which this is a reply to and check if
|
_createPostCWFromReply(baseDir, nickname, domain,
|
||||||
# it has a content warning. If it does then reproduce
|
inReplyTo, sensitive, summary)
|
||||||
# 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']
|
|
||||||
|
|
||||||
# get the ending date and time
|
# get the ending date and time
|
||||||
endDateStr = None
|
endDateStr = None
|
||||||
|
|
14
tests.py
14
tests.py
|
@ -3016,6 +3016,7 @@ def _testFunctions():
|
||||||
if not line.strip().startswith('def '):
|
if not line.strip().startswith('def '):
|
||||||
if lineCount > 0:
|
if lineCount > 0:
|
||||||
lineCount += 1
|
lineCount += 1
|
||||||
|
# add LOC count for this function
|
||||||
if len(prevLine.strip()) == 0 and \
|
if len(prevLine.strip()) == 0 and \
|
||||||
len(line.strip()) == 0 and \
|
len(line.strip()) == 0 and \
|
||||||
lineCount > 2:
|
lineCount > 2:
|
||||||
|
@ -3051,6 +3052,19 @@ def _testFunctions():
|
||||||
"module": modName,
|
"module": modName,
|
||||||
"calledInModule": []
|
"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
|
break
|
||||||
|
|
||||||
print('LOC counts:')
|
print('LOC counts:')
|
||||||
|
|
Loading…
Reference in New Issue