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