forked from github/pelican
Sort imports and remove trailing whitespaces
This commit is contained in:
parent
821fa5460b
commit
9cced6be83
9 changed files with 93 additions and 88 deletions
|
|
@ -1,12 +1,13 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from pelican.utils import slugify, truncate_html_words
|
||||
from pelican.log import *
|
||||
from pelican.settings import _DEFAULT_CONFIG
|
||||
from datetime import datetime
|
||||
import datetime
|
||||
from os import getenv
|
||||
from sys import platform, stdin
|
||||
import locale
|
||||
|
||||
from pelican.log import *
|
||||
from pelican.settings import _DEFAULT_CONFIG
|
||||
from pelican.utils import slugify, truncate_html_words
|
||||
|
||||
class Page(object):
|
||||
"""Represents a page
|
||||
Given a content, and metadata, create an adequate object.
|
||||
|
|
@ -101,7 +102,7 @@ class Page(object):
|
|||
if not hasattr(self, 'status'):
|
||||
self.status = settings['DEFAULT_STATUS']
|
||||
if not settings['WITH_FUTURE_DATES']:
|
||||
if hasattr(self, 'date') and self.date > datetime.now():
|
||||
if hasattr(self, 'date') and self.date > datetime.datetime.now():
|
||||
self.status = 'draft'
|
||||
|
||||
# set summary
|
||||
|
|
@ -130,11 +131,10 @@ class Page(object):
|
|||
"""Dummy function"""
|
||||
pass
|
||||
|
||||
summary = property(_get_summary, _set_summary, \
|
||||
summary = property(_get_summary, _set_summary,
|
||||
"Summary of the article. Based on the content. Can't be set")
|
||||
|
||||
|
||||
|
||||
class Article(Page):
|
||||
mandatory_properties = ('title', 'date', 'category')
|
||||
|
||||
|
|
|
|||
|
|
@ -1,22 +1,23 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from operator import attrgetter, itemgetter
|
||||
from itertools import chain
|
||||
from functools import partial
|
||||
from datetime import datetime
|
||||
from collections import defaultdict
|
||||
import os
|
||||
import datetime
|
||||
import math
|
||||
import random
|
||||
import urlparse
|
||||
|
||||
from collections import defaultdict
|
||||
from functools import partial
|
||||
from itertools import chain
|
||||
from operator import attrgetter, itemgetter
|
||||
|
||||
from jinja2 import Environment, FileSystemLoader, PrefixLoader, ChoiceLoader
|
||||
from jinja2.exceptions import TemplateNotFound
|
||||
|
||||
from pelican.contents import Article, Page, is_valid_content
|
||||
from pelican.log import *
|
||||
from pelican.readers import read_file
|
||||
from pelican.utils import copy, process_translations, open
|
||||
from pelican.utils import slugify
|
||||
from pelican.contents import Article, Page, is_valid_content
|
||||
from pelican.readers import read_file
|
||||
from pelican.log import *
|
||||
|
||||
|
||||
class Generator(object):
|
||||
|
|
@ -231,7 +232,7 @@ class ArticlesGenerator(Generator):
|
|||
|
||||
if 'date' not in metadata.keys()\
|
||||
and self.settings['FALLBACK_ON_FS_DATE']:
|
||||
metadata['date'] = datetime.fromtimestamp(os.stat(f).st_ctime)
|
||||
metadata['date'] = datetime.datetime.fromtimestamp(os.stat(f).st_ctime)
|
||||
|
||||
article = Article(content, metadata, settings=self.settings,
|
||||
filename=f)
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import os
|
||||
import sys
|
||||
from logging import CRITICAL, ERROR, WARN, INFO, DEBUG
|
||||
from logging import critical, error, info, warning, warn, debug
|
||||
from logging import Formatter, getLogger, StreamHandler
|
||||
import sys
|
||||
import os
|
||||
|
||||
global ANSI
|
||||
ANSI = {
|
||||
|
|
@ -62,7 +62,8 @@ class TextFormatter(Formatter):
|
|||
class DummyFormatter(object):
|
||||
"""
|
||||
A dummy class.
|
||||
Return an instance of the appropriate formatter (ANSIFormatter if sys.stdout.isatty() is True, else TextFormatter)
|
||||
Return an instance of the appropriate formatter (ANSIFormatter if
|
||||
sys.stdout.isatty() is True, else TextFormatter)
|
||||
"""
|
||||
|
||||
def __new__(cls, *args, **kwargs):
|
||||
|
|
@ -73,9 +74,6 @@ class DummyFormatter(object):
|
|||
return TextFormatter( *args, **kwargs)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def init(level=None, logger=getLogger(), handler=StreamHandler()):
|
||||
fmt = DummyFormatter()
|
||||
handler.setFormatter(fmt)
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import os
|
||||
import shutil
|
||||
import pytz
|
||||
from datetime import datetime
|
||||
import re
|
||||
import shutil
|
||||
|
||||
from codecs import open as _open
|
||||
from datetime import datetime
|
||||
from itertools import groupby
|
||||
from operator import attrgetter
|
||||
from pelican.log import warning, info
|
||||
|
|
@ -80,6 +81,7 @@ def copy(path, source, destination, destination_path=None, overwrite=False):
|
|||
shutil.copy(source_, destination_)
|
||||
info('copying %s to %s' % (source_, destination_))
|
||||
|
||||
|
||||
def clean_output_dir(path):
|
||||
"""Remove all the files from the output directory"""
|
||||
|
||||
|
|
@ -228,6 +230,7 @@ def files_changed(path, extensions):
|
|||
return True
|
||||
return False
|
||||
|
||||
|
||||
def set_date_tzinfo(d, tz_name=None):
|
||||
""" Date without tzinfo shoudbe utc.
|
||||
This function set the right tz to date that aren't utc and don't have tzinfo
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import with_statement
|
||||
import os
|
||||
import re
|
||||
from codecs import open
|
||||
from functools import partial
|
||||
import locale
|
||||
import re
|
||||
|
||||
from feedgenerator import Atom1Feed, Rss201rev2Feed
|
||||
from pelican.utils import get_relative_path, set_date_tzinfo
|
||||
from pelican.paginator import Paginator
|
||||
from pelican.log import *
|
||||
from pelican.utils import get_relative_path, set_date_tzinfo
|
||||
|
||||
|
||||
class Writer(object):
|
||||
|
|
|
|||
|
|
@ -4,8 +4,9 @@ try:
|
|||
except ImportError, e:
|
||||
import unittest as unittest2
|
||||
|
||||
import os
|
||||
import datetime
|
||||
import os
|
||||
|
||||
from pelican import readers
|
||||
|
||||
CUR_DIR = os.path.dirname(__file__)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
#! /usr/bin/env python
|
||||
|
||||
from pelican.utils import slugify
|
||||
import argparse
|
||||
import os
|
||||
import time
|
||||
|
||||
from codecs import open
|
||||
import os
|
||||
import argparse
|
||||
import time
|
||||
|
||||
from pelican.utils import slugify
|
||||
|
||||
|
||||
def wp2fields(xml):
|
||||
|
|
|
|||
|
|
@ -205,7 +205,6 @@ def main():
|
|||
|
||||
args = parser.parse_args()
|
||||
|
||||
|
||||
print('''Welcome to pelican-quickstart v{v}.
|
||||
|
||||
This script will help you creating a new Pelican based website.
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os, sys, shutil
|
||||
import argparse
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
try:
|
||||
import pelican
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue