diff --git a/bin/pelican b/bin/pelican deleted file mode 100755 index 3fe2ee57..00000000 --- a/bin/pelican +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env python -from pelican import main -main() diff --git a/bin/pelican.bat b/bin/pelican.bat deleted file mode 100755 index 674e1fd7..00000000 --- a/bin/pelican.bat +++ /dev/null @@ -1 +0,0 @@ -@python "%~dpn0" %* diff --git a/pelican/__init__.py b/pelican/__init__.py index 710c9ff1..a0b5704c 100644 --- a/pelican/__init__.py +++ b/pelican/__init__.py @@ -158,7 +158,3 @@ def main(): raise else: sys.exit(getattr(e, 'exitcode', 1)) - - -if __name__ == '__main__': - main() diff --git a/setup.py b/setup.py index 9b299085..910499de 100755 --- a/setup.py +++ b/setup.py @@ -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', diff --git a/tools/__init__.py b/tools/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tools/pelican-import.bat b/tools/pelican-import.bat deleted file mode 100755 index 674e1fd7..00000000 --- a/tools/pelican-import.bat +++ /dev/null @@ -1 +0,0 @@ -@python "%~dpn0" %* diff --git a/tools/pelican-quickstart.bat b/tools/pelican-quickstart.bat deleted file mode 100755 index 674e1fd7..00000000 --- a/tools/pelican-quickstart.bat +++ /dev/null @@ -1 +0,0 @@ -@python "%~dpn0" %* diff --git a/tools/pelican-themes.bat b/tools/pelican-themes.bat deleted file mode 100755 index 674e1fd7..00000000 --- a/tools/pelican-themes.bat +++ /dev/null @@ -1 +0,0 @@ -@python "%~dpn0" %* diff --git a/tools/pelican-import b/tools/pelican_import.py similarity index 98% rename from tools/pelican-import rename to tools/pelican_import.py index 3a931afd..e7f8e051 100755 --- a/tools/pelican-import +++ b/tools/pelican_import.py @@ -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) diff --git a/tools/pelican-quickstart b/tools/pelican_quickstart.py similarity index 99% rename from tools/pelican-quickstart rename to tools/pelican_quickstart.py index 4048c2bf..56c22f10 100755 --- a/tools/pelican-quickstart +++ b/tools/pelican_quickstart.py @@ -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() diff --git a/tools/pelican-themes b/tools/pelican_themes.py similarity index 99% rename from tools/pelican-themes rename to tools/pelican_themes.py index 78df4a48..3d35bb5d 100755 --- a/tools/pelican-themes +++ b/tools/pelican_themes.py @@ -212,6 +212,3 @@ def clean(v=False): c+=1 print("\nRemoved {0} broken links".format(c)) - -if __name__ == '__main__': - main()