Skip to content

Commit

Permalink
Merge pull request #3115 from mart-e/import-config-file
Browse files Browse the repository at this point in the history
  • Loading branch information
justinmayer committed Jun 4, 2023
2 parents 1b360ac + ef844db commit 23c50ea
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions pelican/tools/pelican_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

# because logging.setLoggerClass has to be called before logging.getLogger
from pelican.log import init
from pelican.settings import read_settings
from pelican.settings import DEFAULT_CONFIG
from pelican.utils import SafeDatetime, slugify


Expand Down Expand Up @@ -285,8 +285,7 @@ def dc2fields(file):

print("%i posts read." % len(posts))

settings = read_settings()
subs = settings['SLUG_REGEX_SUBSTITUTIONS']
subs = DEFAULT_CONFIG['SLUG_REGEX_SUBSTITUTIONS']
for post in posts:
fields = post.split('","')

Expand Down Expand Up @@ -404,8 +403,7 @@ def get_posterous_posts(api_token, email, password, page=1):

page = 1
posts = get_posterous_posts(api_token, email, password, page)
settings = read_settings()
subs = settings['SLUG_REGEX_SUBSTITUTIONS']
subs = DEFAULT_CONFIG['SLUG_REGEX_SUBSTITUTIONS']
while len(posts) > 0:
posts = get_posterous_posts(api_token, email, password, page)
page += 1
Expand Down Expand Up @@ -446,8 +444,7 @@ def get_tumblr_posts(api_key, blogname, offset=0):

offset = 0
posts = get_tumblr_posts(api_key, blogname, offset)
settings = read_settings()
subs = settings['SLUG_REGEX_SUBSTITUTIONS']
subs = DEFAULT_CONFIG['SLUG_REGEX_SUBSTITUTIONS']
while len(posts) > 0:
for post in posts:
title = \
Expand Down Expand Up @@ -531,8 +528,7 @@ def feed2fields(file):
"""Read a feed and yield pelican fields"""
import feedparser
d = feedparser.parse(file)
settings = read_settings()
subs = settings['SLUG_REGEX_SUBSTITUTIONS']
subs = DEFAULT_CONFIG['SLUG_REGEX_SUBSTITUTIONS']
for entry in d.entries:
date = (time.strftime('%Y-%m-%d %H:%M', entry.updated_parsed)
if hasattr(entry, 'updated_parsed') else None)
Expand Down Expand Up @@ -778,8 +774,7 @@ def fields2pelican(
pandoc_version = get_pandoc_version()
posts_require_pandoc = []

settings = read_settings()
slug_subs = settings['SLUG_REGEX_SUBSTITUTIONS']
slug_subs = DEFAULT_CONFIG['SLUG_REGEX_SUBSTITUTIONS']

for (title, content, filename, date, author, categories, tags, status,
kind, in_markup) in fields:
Expand Down

0 comments on commit 23c50ea

Please sign in to comment.