Skip to content

[WIP] Add Python 3.* support. #152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
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
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ language: python
python:
- "2.6"
- "2.7"
- "3.5"

before_script:
- virtualenv ../venv
Expand Down
14 changes: 8 additions & 6 deletions pyg/Pygemony.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from __future__ import print_function

from fnmatch import filter as fn_filter
from os import walk, path
import hashlib

from utils import detect_mimetype
from github import GithubAPIManager
from languages import *
from pyg.utils import detect_mimetype
from pyg.github import GithubAPIManager
from pyg.languages import *


class Pygemony(object):
Expand Down Expand Up @@ -45,7 +47,7 @@ def _sanitize_todo_line(self, lines):
@staticmethod
def hash_todo(todo_content, file_name):
m = hashlib.md5()
m.update('{}-{}'.format(todo_content, file_name))
m.update('{}-{}'.format(todo_content, file_name).encode('utf-8'))
return str(m.hexdigest())

def parse_for_todo(self, f, file_):
Expand Down Expand Up @@ -84,14 +86,14 @@ def file_handler(self):
if file_type[0].startswith("application") or file_type[0] is None:
files_found.remove(file_)
except (AttributeError, IndexError) as e:
print "Failed to open file {} with error of {}".format(file_, e)
print("Failed to open file {} with error of {}".format(file_, e))

for file_ in files_found:
try:
with open(file_, 'r') as f:
self.parse_for_todo(f, file_)
except IOError as e:
print "Failed to open file {} with error of {}".format(file_, e)
print("Failed to open file {} with error of {}".format(file_, e))

return files_found

Expand Down
6 changes: 4 additions & 2 deletions pyg/github.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import print_function

import github3
from os import path

Expand Down Expand Up @@ -30,7 +32,7 @@ def login(self):
try:
return github3.login(self.user, self.token)
except github3.models.GitHubError as e:
print "Failed to login due to {}".format(e)
print("Failed to login due to {}".format(e))
return None

def _save_submitted_todo(self, issue):
Expand Down Expand Up @@ -88,5 +90,5 @@ def _construct_issue_body(issue):
def _pprint(self, issue):
msg = "Committing to repo: {}"
msg += "\n\tFile Name: {}:{}\n\tTodo Message:{}"
print msg.format(self.repo, issue[0], issue[1], issue[2])
print(msg.format(self.repo, issue[0], issue[1], issue[2]))