Merge pull request #230 from AndreaCrotti/master

refactor the scripts
This commit is contained in:
Alexis Metaireau 2012-03-07 03:59:15 -08:00
commit 1405667692
14 changed files with 781 additions and 797 deletions

View file

@ -1,3 +0,0 @@
#!/usr/bin/env python
from pelican import main
main()

View file

@ -1 +0,0 @@
@python "%~dpn0" %*

View file

@ -158,7 +158,3 @@ def main():
raise
else:
sys.exit(getattr(e, 'exitcode', 1))
if __name__ == '__main__':
main()

View file

@ -1,21 +1,23 @@
#!/usr/bin/env python
from setuptools import setup
import sys
import platform
VERSION = "3.0" # find a better way to do so.
requires = ['feedgenerator', 'jinja2', 'pygments', 'docutils', 'pytz']
if sys.version_info < (2,7):
try:
import argparse
except ImportError:
requires.append('argparse')
scripts = ['bin/pelican', 'tools/pelican-themes', 'tools/pelican-import', 'tools/pelican-quickstart']
if sys.platform.startswith('win'):
scripts += [
'bin/pelican.bat', 'tools/pelican-themes.bat',
'tools/pelican-import.bat', 'tools/pelican-quickstart.bat'
]
entry_points = {
'console_scripts': [
'pelican = pelican:main',
'pelican-import = tools.pelican_import:main',
'pelican-quickstart = tools.pelican_quickstart:main',
'pelican-themes = tools.pelican_themes:main'
]
}
setup(
name = "pelican",
@ -28,7 +30,7 @@ setup(
packages = ['pelican'],
include_package_data = True,
install_requires = requires,
scripts = scripts,
entry_points = entry_points,
classifiers = ['Development Status :: 5 - Production/Stable',
'Environment :: Console',
'License :: OSI Approved :: GNU Affero General Public License v3',

0
tools/__init__.py Normal file
View file

View file

@ -1 +0,0 @@
@python "%~dpn0" %*

View file

@ -1 +0,0 @@
@python "%~dpn0" %*

View file

@ -1 +0,0 @@
@python "%~dpn0" %*

View file

@ -231,18 +231,7 @@ def fields2pelican(fields, out_markup, output_path, dircat=False):
fs.write(header + content)
def main(input_type, input, out_markup, output_path, dircat=False):
if input_type == 'wordpress':
fields = wp2fields(input)
elif input_type == 'dotclear':
fields = dc2fields(input)
elif input_type == 'feed':
fields = feed2fields(input)
fields2pelican(fields, out_markup, output_path, dircat=dircat)
if __name__ == '__main__':
def main():
parser = argparse.ArgumentParser(
description="Transform feed, Wordpress or Dotclear files to rst files."
"Be sure to have pandoc installed")
@ -280,4 +269,14 @@ if __name__ == '__main__':
error("Couldn't create the output folder: " + args.output)
exit()
main(input_type, args.input, args.markup, args.output, dircat=args.dircat)
# TODO: refactor this long assignment
input_type, input, out_markup, output_path, dircat=False = input_type, args.input, args.markup, args.output, args.dircat
if input_type == 'wordpress':
fields = wp2fields(input)
elif input_type == 'dotclear':
fields = dc2fields(input)
elif input_type == 'feed':
fields = feed2fields(input)
fields2pelican(fields, out_markup, output_path, dircat=dircat)

View file

@ -270,6 +270,3 @@ Please answer the following questions so this script can generate the files need
print('Error: {0}'.format(e))
print('Done. Your new project is available at %s' % CONF['basedir'])
if __name__ == '__main__':
main()

View file

@ -212,6 +212,3 @@ def clean(v=False):
c+=1
print("\nRemoved {0} broken links".format(c))
if __name__ == '__main__':
main()