Added docstrings for the ease of modification

This commit is contained in:
Ali Parlakci
2018-08-06 08:13:07 +03:00
parent be7508540d
commit 20b9747330
2 changed files with 25 additions and 3 deletions

View File

@@ -455,6 +455,9 @@ def isPostExists(POST):
possibleExtensions = [".jpg",".png",".mp4",".gif",".webm",".md"] possibleExtensions = [".jpg",".png",".mp4",".gif",".webm",".md"]
"""If you change the filenames, don't forget to add them here.
Please don't remove existing ones
"""
for extension in possibleExtensions: for extension in possibleExtensions:
OLD_FILE_PATH = PATH / ( OLD_FILE_PATH = PATH / (
@@ -481,6 +484,8 @@ def isPostExists(POST):
return False return False
def downloadPost(SUBMISSION): def downloadPost(SUBMISSION):
"""Download directory is declared here for each file"""
directory = GLOBAL.directory / SUBMISSION['postSubreddit'] directory = GLOBAL.directory / SUBMISSION['postSubreddit']
global lastRequestTime global lastRequestTime

View File

@@ -102,6 +102,8 @@ class Erome:
extension = getExtension(IMAGES[0]) extension = getExtension(IMAGES[0])
"""Filenames are declared here"""
title = nameCorrector(post['postTitle']) title = nameCorrector(post['postTitle'])
print(post["postSubmitter"]+"_"+title+"_"+post['postId']+extension) print(post["postSubmitter"]+"_"+title+"_"+post['postId']+extension)
@@ -237,8 +239,11 @@ class Imgur:
post['mediaURL'] = content['object'].link post['mediaURL'] = content['object'].link
post['postExt'] = getExtension(post['mediaURL']) post['postExt'] = getExtension(post['mediaURL'])
title = nameCorrector(post['postTitle']) title = nameCorrector(post['postTitle'])
"""Filenames are declared here"""
print(post["postSubmitter"]+"_"+title+"_"+post['postId']+post['postExt']) print(post["postSubmitter"]+"_"+title+"_"+post['postId']+post['postExt'])
fileDir = directory / ( fileDir = directory / (
@@ -297,6 +302,8 @@ class Imgur:
+ "_" + "_"
+ images[i]['id']) + images[i]['id'])
"""Filenames are declared here"""
fileDir = folderDir / (fileName + images[i]['Ext']) fileDir = folderDir / (fileName + images[i]['Ext'])
tempDir = folderDir / (fileName + ".tmp") tempDir = folderDir / (fileName + ".tmp")
@@ -396,9 +403,12 @@ class Gfycat:
raise NotADownloadableLinkError("Could not read the page source") raise NotADownloadableLinkError("Could not read the page source")
POST['postExt'] = getExtension(POST['mediaURL']) POST['postExt'] = getExtension(POST['mediaURL'])
if not os.path.exists(directory): os.makedirs(directory) if not os.path.exists(directory): os.makedirs(directory)
title = nameCorrector(POST['postTitle']) title = nameCorrector(POST['postTitle'])
"""Filenames are declared here"""
print(POST["postSubmitter"]+"_"+title+"_"+POST['postId']+POST['postExt']) print(POST["postSubmitter"]+"_"+title+"_"+POST['postId']+POST['postExt'])
fileDir = directory / ( fileDir = directory / (
@@ -453,6 +463,9 @@ class Direct:
POST['postExt'] = getExtension(POST['postURL']) POST['postExt'] = getExtension(POST['postURL'])
if not os.path.exists(directory): os.makedirs(directory) if not os.path.exists(directory): os.makedirs(directory)
title = nameCorrector(POST['postTitle']) title = nameCorrector(POST['postTitle'])
"""Filenames are declared here"""
print(POST["postSubmitter"]+"_"+title+"_"+POST['postId']+POST['postExt']) print(POST["postSubmitter"]+"_"+title+"_"+POST['postId']+POST['postExt'])
fileDir = directory / ( fileDir = directory / (
@@ -475,6 +488,9 @@ class Self:
if not os.path.exists(directory): os.makedirs(directory) if not os.path.exists(directory): os.makedirs(directory)
title = nameCorrector(post['postTitle']) title = nameCorrector(post['postTitle'])
"""Filenames are declared here"""
print(post["postSubmitter"]+"_"+title+"_"+post['postId']+".md") print(post["postSubmitter"]+"_"+title+"_"+post['postId']+".md")
fileDir = directory / ( fileDir = directory / (
@@ -494,7 +510,8 @@ class Self:
@staticmethod @staticmethod
def writeToFile(directory,post): def writeToFile(directory,post):
"""Self posts are formatted here"""
content = ("## [" content = ("## ["
+ post["postTitle"] + post["postTitle"]
+ "](" + "]("