Skip to content
This repository has been archived by the owner on Mar 7, 2020. It is now read-only.

Commit

Permalink
python 3.5 support
Browse files Browse the repository at this point in the history
  • Loading branch information
everettjf committed Jul 7, 2016
1 parent 6537734 commit 9d1f061
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ Classify (.h) header files into a text (.txt) report according to the first 2 le
$ pip install supotato
```
#### Compatibility
* Python 2.7 / Python 3.x
* Linux / OSX / Windows

Tested 2.7.10/3.5.0 on macOS

## Usage

Expand All @@ -34,6 +33,9 @@ Then you got result below :
[Here](https://github.com/everettjf/supotato/blob/master/example/result.txt)


PS: Another result sample [Here](https://github.com/everettjf/supotato/blob/master/example/lots.txt).


##Options

```
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name="supotato",
version="1.0.0",
version="1.0.1",
description="Classify the header (.h) files in to a txt report.",
url="http://github.com/everettjf/supotato",
author="everettjf",
Expand Down
15 changes: 11 additions & 4 deletions supotato/supotato.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ def classify(input=None, output=None, sortby="prefix", asc=True, prefix_length=2
files = mapper[prefix]
counter[prefix] = len(files)

ordered = sorted(counter.iteritems(), key=lambda d:d[sortindex], reverse=not asc)
if six.PY2:
ordered = sorted(counter.iteritems(), key=lambda d:d[sortindex], reverse=not asc)
else:
ordered = sorted(counter.items(), key=lambda d:d[sortindex], reverse=not asc)


# console output
total_file_count = 0
Expand Down Expand Up @@ -103,7 +107,10 @@ def classify(input=None, output=None, sortby="prefix", asc=True, prefix_length=2
f.write("%s (%d)\n" %(prefix, len(files)))

for file in files:
line = file.encode('utf-8')
if six.PY2:
line = file.encode('utf-8')
else:
line = file
f.write(" " + line + "\n")
f.write("--- Total %d files ---"% total_file_count)

Expand Down Expand Up @@ -137,5 +144,5 @@ def main():
sys.exit()


# if __name__ == '__main__':
# main()
if __name__ == '__main__':
main()

0 comments on commit 9d1f061

Please sign in to comment.