Skip to content

Commit

Permalink
python3 support in sight, some encoding issues remain
Browse files Browse the repository at this point in the history
  • Loading branch information
yaph committed Sep 8, 2013
1 parent 28a1d23 commit 3e39def
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 33 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
language: python
python:
- "2.7"
- "3.2"
- "3.3"
# - "3.2"
# - "3.3"
# does not have headers provided, please ask https://launchpad.net/~pypy/+archive/ppa
# maintainers to fix their pypy-dev package.
- "pypy"
Expand All @@ -11,4 +11,4 @@ install:
- pip install . --use-mirrors
- pip install -r test_requirements.txt --use-mirrors
# command to run tests
script: nosetests
script: nosetests
16 changes: 14 additions & 2 deletions fabfile.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from fabric.api import local
from fabric.api import local, lcd


def release():
Expand All @@ -14,4 +14,16 @@ def git():

def reinstall():
local('pip uninstall logya')
local('python setup.py logya')
local('python setup.py install')


def test():
local('rm -rf t')
local('`which logya` create t')
with lcd('t'):
local('`which logya` gen')


def rt():
reinstall()
test()
6 changes: 5 additions & 1 deletion logya/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import datetime
import PyRSS2Gen
from operator import itemgetter
from logya.compat import execfile
from logya.config import Config
from logya.docreader import DocReader
from logya.docparser import DocParser
Expand Down Expand Up @@ -100,7 +101,10 @@ def get_dirs_from_path(self, url):
The last directory is omitted as it contains and index.html file
containing the content of the appropriate document."""

return filter(None, url.strip('/').split('/'))[:-1]
dirs = [f for f in url.strip('/').split('/') if f]
if dirs:
dirs = dirs[:-1]
return dirs

def update_index(self, doc, path):
"""Add a doc to given path index."""
Expand Down
6 changes: 5 additions & 1 deletion logya/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from SimpleHTTPServer import SimpleHTTPRequestHandler
from BaseHTTPServer import HTTPServer

execfile = execfile
str = unicode

elif (_ver[0] == 3):
Expand All @@ -30,4 +31,7 @@
from http.server import SimpleHTTPRequestHandler
from http.server import HTTPServer

str = str
str = str

def execfile(exe, args):
exec(compile(open(exe).read(), exe, 'exec'), args)
7 changes: 5 additions & 2 deletions logya/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ def test(args):

def main():
parser = argparse.ArgumentParser(
description='Logya a static Web site generator.', version=__version__)
description='Logya a static Web site generator.')
parser.add_argument(
'--version', action='version', version=__version__)
parser.add_argument(
'--verbose', action="store_true", default=False, help='print messages')

Expand Down Expand Up @@ -55,7 +57,8 @@ def main():

# process arguments
args = parser.parse_args()
args.func(args)
if getattr(args, 'func', None):
args.func(args)

if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion logya/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def serve(self):
"""Serve static files from logya deploy directory."""

os.chdir(self.logya.dir_dst)
print('Serving on http://%s:%s/' % (self.host, self.port))
print(('Serving on http://%s:%s/' % (self.host, self.port)))
self.serve_forever()


Expand Down
Empty file removed logya/sites/__init__.py
Empty file.
Empty file removed logya/sites/docs/__init__.py
Empty file.
6 changes: 3 additions & 3 deletions logya/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,6 @@ def get_source(self, environment, template):
if not os.path.exists(path):
raise TemplateNotFound(template)
mtime = os.path.getmtime(path)
with file(path) as f:
source = f.read().decode('utf-8')
return source, path, lambda: mtime == os.path.getmtime(path)
with open(path, 'r') as f:
source = f.read()
return source, path, lambda: mtime == os.path.getmtime(path)
2 changes: 1 addition & 1 deletion logya/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def getfile(self, dir_dst, path):
def write(self, file, content):
"""Write content to file and close it."""

file.write(content)
file.write(str(content))
file.close()


Expand Down
28 changes: 9 additions & 19 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,10 @@
with open('requirements.txt') as f:
required = f.read().splitlines()


def get_package_data():
"""Return a list of files in sites dir to include in package."""

dir_base = os.path.join(os.getcwd(), 'logya')
dir_sites = os.path.join(dir_base, 'sites')
sites_files = []
for root, dirs, files in os.walk(dir_sites):
sites_files.extend([os.path.join(root, f).replace(dir_base, '').lstrip('/') for f in files])
return sites_files

setup(
name='logya',
version='3.0',
description='Logya is a static Web site generator written in Python designed to be easy to use and flexible.',
version=3.0,
description='Logya: easy to use and flexible static Web site generator.',
long_description=readme,
url='http://yaph.github.com/logya/',
author='Ramiro Gómez',
Expand All @@ -35,20 +24,21 @@ def get_package_data():
maintainer_email='[email protected]',
keywords=['Website Generator'],
license=license,
packages=find_packages(),
package_data={'logya': get_package_data()},
install_requires = required,
packages=['logya'],
include_package_data=True,
exclude_package_data={'': ['*.pyc']},
install_requires=required,
classifiers=[
'Development Status :: 5 - Production/Stable',
'Development Status :: 4 - Beta',
'Environment :: Console',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python',
'Topic :: Internet :: WWW/HTTP :: Site Management'],
entry_points={
'console_scripts': [
'logya=logya.main:main'
'logya = logya.main:main'
]
}
)

0 comments on commit 3e39def

Please sign in to comment.