Skip to content

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

Open
wants to merge 3 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
8 changes: 6 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"""

import os
import sys
Copy link
Owner

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?

import runpy

from setuptools import setup
Expand All @@ -26,7 +27,9 @@ def get_version():

setup(
name="wpm",
scripts=["scripts/wpm"],
entry_points = {
"console_scripts": ['wpm = wpm.commandline:main']
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will entry_points interfere with non-Windows systems?

},
version=_VERSION,
description="Console app for measuring typing speed in words per minute (WPM)",
author="Christian Stigen Larsen",
Expand All @@ -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",
Expand Down
4 changes: 4 additions & 0 deletions wpm/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,16 @@ def wpm(self, elapsed):
"""Words per minute."""
if self.start is None:
return 0
if not elapsed:
return 0
Copy link
Owner

Choose a reason for hiding this comment

The 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:
Copy link
Owner

Choose a reason for hiding this comment

The 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
Expand Down
2 changes: 1 addition & 1 deletion wpm/screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
hicolor = os.getenv("TERM").endswith("256color") if os.getenv("TERM") else None
hicolor = os.getenv("TERM", "").endswith("256color")


if hicolor:
color = self.config.xterm256colors
Expand Down
11 changes: 7 additions & 4 deletions wpm/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Copy link
Owner

Choose a reason for hiding this comment

The 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)

Expand All @@ -254,4 +255,6 @@ def save(self, filename):
game[0] = 1 + race
writer.writerow(game)

if os.path.exists(filename):
Copy link
Owner

Choose a reason for hiding this comment

The 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)