Skip to content
This repository has been archived by the owner on Oct 24, 2022. It is now read-only.

Port to python3 #18

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# serve to show the default.

import sys, os
import six

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
Expand Down Expand Up @@ -41,8 +42,8 @@
master_doc = 'index'

# General information about the project.
project = u'pygithub3'
copyright = u'2012, David Medina'
project = six.u('pygithub3')
copyright = six.u('2012, David Medina')

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -189,8 +190,8 @@
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'pygithub3.tex', u'pygithub3 Documentation',
u'David Medina', 'manual'),
('index', 'pygithub3.tex', six.u('pygithub3 Documentation'),
six.u('David Medina'), 'manual'),
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down Expand Up @@ -219,8 +220,8 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'pygithub3', u'pygithub3 Documentation',
[u'David Medina'], 1)
('index', 'pygithub3', six.u('pygithub3 Documentation'),
[six.u('David Medina')], 1)
]

# If true, show URL addresses after external links.
Expand All @@ -233,8 +234,8 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'pygithub3', u'pygithub3 Documentation',
u'David Medina', 'pygithub3', 'One line description of project.',
('index', 'pygithub3', six.u('pygithub3 Documentation'),
six.u('David Medina'), 'pygithub3', 'One line description of project.',
'Miscellaneous'),
]

Expand Down
2 changes: 1 addition & 1 deletion pygithub3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
__license__ = 'ISC'
__copyright__ = 'Copyright 2012 David Medina'

from github import Github
from .github import Github
3 changes: 2 additions & 1 deletion pygithub3/core/result/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# -*- encoding: utf-8 -*-

import functools
import six


class Method(object):
Expand Down Expand Up @@ -72,7 +73,7 @@ def wrapper(self):
@get_content
def __next__(self):
try:
return self.iterable.next()
return six.advance_iterator(self.iterable)
except StopIteration:
self.iterable = iter(self.getter(self.page))
raise StopIteration
Expand Down
7 changes: 6 additions & 1 deletion pygithub3/core/result/link.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
#!/usr/bin/env python
# -*- encoding: utf-8 -*-

from urlparse import urlparse, parse_qs
try:
# Python 3
from urllib.parse import urlparse, parse_qs
except ImportError:
from urlparse import urlparse, parse_qs


from pygithub3.core.third_libs.link_header import parse_link_value

Expand Down
2 changes: 1 addition & 1 deletion pygithub3/core/result/smart.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,6 @@ def get_page(self, page):

:param int page: Page number
"""
if page in xrange(1, self.pages + 1):
if page in range(1, self.pages + 1):
return base.Page(self.getter, page)
return None
3 changes: 2 additions & 1 deletion pygithub3/core/third_libs/link_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

Simple routines to parse and manipulate Link headers.
"""
from __future__ import print_function

__license__ = """
Copyright (c) 2009 Mark Nottingham
Expand Down Expand Up @@ -86,4 +87,4 @@ def parse_link_value(instr):
if __name__ == '__main__':
import sys
if len(sys.argv) > 1:
print parse_link_value(sys.argv[1])
print(parse_link_value(sys.argv[1]))
2 changes: 2 additions & 0 deletions pygithub3/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import json

from collections import MutableMapping
from six.moves import map
from six.moves import zip


def _import_module(module_uri):
Expand Down
2 changes: 1 addition & 1 deletion pygithub3/requests/users/emails.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def is_email(email):
raise ValidationError("'%s' request needs emails"
% (self.__class__.__name__))

return filter(is_email, self.body)
return tuple([ele for ele in self.body if is_email(ele)])


class Delete(Request):
Expand Down
2 changes: 1 addition & 1 deletion pygithub3/services/gists/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- encoding: utf-8 -*-

from pygithub3.services.base import Service
from comments import Comments
from .comments import Comments


class Gist(Service):
Expand Down
2 changes: 2 additions & 0 deletions pygithub3/services/issues/labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# -*- encoding: utf-8 -*-

from pygithub3.services.base import Service
from six.moves import map
from six.moves import zip


class Labels(Service):
Expand Down
5 changes: 3 additions & 2 deletions pygithub3/tests/core/test_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from pygithub3.tests.utils.core import (mock_paginate_github_in_GET, request,
mock_no_paginate_github_in_GET,
MockPaginate)
import six


class ResultInitMixin(object):
Expand Down Expand Up @@ -38,7 +39,7 @@ def test_iteration_CALLS(self):

def test_consumed_are_Pages(self):
pages_that_are_Pages = len(
filter(lambda page: isinstance(page, base.Page), list(self.r)))
[page for page in self.r if isinstance(page, base.Page)])
self.assertEqual(pages_that_are_Pages, 3, 'There are not 3 Pages objs')

def test_all_iteration_CALLS(self):
Expand Down Expand Up @@ -66,7 +67,7 @@ def mock(self):
return mock_no_paginate_github_in_GET

def test_iteration_stop_at_1(self):
self.r.next()
six.advance_iterator(self.r)
self.assertRaises(StopIteration, self.r.next)

def test_get_only_1page(self):
Expand Down
4 changes: 2 additions & 2 deletions pygithub3/tests/resources/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ def test_MAPS(self):
self.assertEqual(self.r.simple.type, 'simple')

def test_LIST_collection_map(self):
has_simple_objects = filter(lambda x: isinstance(x, HasSimple),
self.r.list_collection)
has_simple_objects = [obj for obj in self.r.list_collection
if isinstance(obj, HasSimple)]
self.assertEqual(len(has_simple_objects), 2)
self.assertEqual(self.r.list_collection[0].type, 'has_simple')
self.assertEqual(self.r.list_collection[0].simple.type, 'simple')
Expand Down
1 change: 1 addition & 0 deletions requirements/base.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
requests >= 0.12.1
six
6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,16 @@
'nose',
'mock',
],
install_requires=map(str.strip, open(join('requirements', 'base.txt'))),
install_requires=[
s.strip() for s in open(join('requirements', 'base.txt'))],
include_package_data=True,
classifiers=(
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.2',
'License :: OSI Approved :: ISC License (ISCL)',
'Operating System :: OS Independent',
'Development Status :: 2 - Pre-Alpha',
Expand Down