cleanups and minor bugfixes

This commit is contained in:
Peter Molnar 2017-09-20 11:16:45 +00:00
parent 812d7fa0c3
commit 8cbb86e5f8
3 changed files with 27 additions and 15 deletions

34
nasg.py
View file

@ -16,14 +16,15 @@ import math
import asyncio import asyncio
import csv import csv
import getpass import getpass
import quopri #import quopri
import base64 #import base64
import mimetypes #import mimetypes
import copy
import magic import magic
import arrow import arrow
import wand.image import wand.image
import similar_text #import similar_text
import frontmatter import frontmatter
from slugify import slugify from slugify import slugify
import langdetect import langdetect
@ -35,9 +36,10 @@ import urllib.parse
from webmentiontools.send import WebmentionSend from webmentiontools.send import WebmentionSend
import bleach import bleach
from emoji import UNICODE_EMOJI from emoji import UNICODE_EMOJI
from bs4 import BeautifulSoup #from bs4 import BeautifulSoup
from readability.readability import Document #from readability.readability import Document
import shared import shared
#import oauth
def splitpath(path): def splitpath(path):
parts = [] parts = []
@ -899,6 +901,8 @@ class Taxonomy(BaseIter):
p = shared.config.get('target', 'builddir') p = shared.config.get('target', 'builddir')
if self.taxonomy: if self.taxonomy:
p = os.path.join(p, self.taxonomy) p = os.path.join(p, self.taxonomy)
if not os.path.isdir(p):
os.mkdir(p)
return p return p
@ -906,18 +910,25 @@ class Taxonomy(BaseIter):
def myp(self): def myp(self):
p = self.basep p = self.basep
if self.slug: if self.slug:
return os.path.join(p,self.slug) p = os.path.join(p,self.slug)
if not os.path.isdir(p):
os.mkdir(p)
return p return p
@property @property
def feedp(self): def feedp(self):
return os.path.join(self.myp, 'feed') p = os.path.join(self.myp, 'feed')
if not os.path.isdir(p):
os.mkdir(p)
return p
@property @property
def pagep(self): def pagep(self):
return os.path.join(self.myp, 'page') p = os.path.join(self.myp, 'page')
if not os.path.isdir(p):
os.mkdir(p)
return p
@property @property
@ -1492,19 +1503,16 @@ class Singular(BaseRenderable):
l = { l = {
'url': 'https://creativecommons.org/licenses/by/4.0/', 'url': 'https://creativecommons.org/licenses/by/4.0/',
'text': 'CC BY 4.0', 'text': 'CC BY 4.0',
'description': 'Licensed under <a href="https://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International</a>. You are free to share or republish, even if modified, if you link back here and indicate the modifications, even for commercial use.'
} }
elif 'journal' == self.category: elif 'journal' == self.category:
l = { l = {
'url': 'https://creativecommons.org/licenses/by-nc/4.0/', 'url': 'https://creativecommons.org/licenses/by-nc/4.0/',
'text': 'CC BY-NC 4.0', 'text': 'CC BY-NC 4.0',
'description': 'Licensed under <a href="https://creativecommons.org/licenses/by-nc/4.0/">Creative Commons Attribution-NonCommercial 4.0 International</a>. You are free to share or republish, even if modified, if you link back here and indicate the modifications, for non commercial use. For commercial use please contact the author.'
} }
else: else:
l = { l = {
'url': 'https://creativecommons.org/licenses/by-nc-nd/4.0/', 'url': 'https://creativecommons.org/licenses/by-nc-nd/4.0/',
'text': 'CC BY-NC-ND 4.0', 'text': 'CC BY-NC-ND 4.0',
'description': 'Licensed under <a href="https://creativecommons.org/licenses/by-nc-nd/4.0/">Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International</a>. You are free to share if you link back here for non commercial use, but you can\'t publish any altered versions of it. For commercial use please contact the author.'
} }
self._licence = l self._licence = l

View file

@ -37,3 +37,7 @@ for fname, fm in bm.items():
trueurl = shared.find_archiveorgurl(url) trueurl = shared.find_archiveorgurl(url)
w = shared.wget(trueurl, dirname=f) w = shared.wget(trueurl, dirname=f)
w.archive() w.archive()
# this is to skip the failed ones next time
if not os.path.isdir(p):
os.mkdir(p)

View file

@ -681,8 +681,8 @@ if __name__ == '__main__':
flickr = FlickrFavs() flickr = FlickrFavs()
flickr.run() flickr.run()
hn = HNBookmarks() #hn = HNBookmarks()
hn.run() #hn.run()
fivehpx = FivehpxFavs() fivehpx = FivehpxFavs()
fivehpx.run() fivehpx.run()