-
Notifications
You must be signed in to change notification settings - Fork 47
Add Windows support + bugs fixes #47
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ | |
""" | ||
|
||
import os | ||
import sys | ||
import runpy | ||
|
||
from setuptools import setup | ||
|
@@ -26,7 +27,9 @@ def get_version(): | |
|
||
setup( | ||
name="wpm", | ||
scripts=["scripts/wpm"], | ||
entry_points = { | ||
"console_scripts": ['wpm = wpm.commandline:main'] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will |
||
}, | ||
version=_VERSION, | ||
description="Console app for measuring typing speed in words per minute (WPM)", | ||
author="Christian Stigen Larsen", | ||
|
@@ -35,14 +38,15 @@ def get_version(): | |
package_dir={"wpm": "wpm"}, | ||
package_data={"wpm": ["data/examples.json.gz"]}, | ||
include_package_data=True, | ||
install_requires=(["windows-curses"] if sys.platform.startswith("win") else []), | ||
url="https://github.com/cslarsen/wpm", | ||
download_url="https://github.com/cslarsen/wpm/tarball/v%s" % _VERSION, | ||
license="https://www.gnu.org/licenses/agpl-3.0.html", | ||
long_description=open("README.rst").read(), | ||
zip_safe=True, | ||
test_suite="tests", | ||
keywords=["wpm", "typing", "typist"], | ||
platforms=["unix", "linux", "osx", "cygwin"], | ||
platforms=["unix", "linux", "osx", "cygwin", "win32"], | ||
classifiers=[ | ||
"Development Status :: 3 - Alpha", | ||
"Environment :: Console", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -125,12 +125,16 @@ def wpm(self, elapsed): | |
"""Words per minute.""" | ||
if self.start is None: | ||
return 0 | ||
if not elapsed: | ||
return 0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please put in another PR, this is unrelated to windows support. |
||
return min((60.0 * self.position / 5.0) / elapsed, 999) | ||
|
||
def cps(self, elapsed): | ||
"""Characters per second.""" | ||
if self.start is None: | ||
return 0 | ||
if not elapsed: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see why you do this, but I'd prefer to have it in a separate PR. |
||
return 0 | ||
return min(float(self.position) / elapsed, 99) | ||
|
||
@property | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -150,7 +150,7 @@ def lines(self): | |||||
|
||||||
def set_colors(self): | ||||||
"""Sets up curses color pairs.""" | ||||||
hicolor = os.getenv("TERM").endswith("256color") | ||||||
hicolor = os.getenv("TERM").endswith("256color") if os.getenv("TERM") else None | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
if hicolor: | ||||||
color = self.config.xterm256colors | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -224,10 +224,11 @@ def parse(row): | |
reader = csv.reader(file_obj) | ||
|
||
for row in reader: | ||
result = parse(row) | ||
tag = result[-1] | ||
games[tag].append(result[:-1]) | ||
current_tag = tag | ||
if len(row) == 9: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's going on here? |
||
result = parse(row) | ||
tag = result[-1] | ||
games[tag].append(result[:-1]) | ||
current_tag = tag | ||
|
||
return Stats(current_tag, games) | ||
|
||
|
@@ -254,4 +255,6 @@ def save(self, filename): | |
game[0] = 1 + race | ||
writer.writerow(game) | ||
|
||
if os.path.exists(filename): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove this or put into another PR |
||
os.remove(filename) | ||
os.rename(filename + ".tmp", filename) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this used in the file?