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

Commit

Permalink
pep8
Browse files Browse the repository at this point in the history
  • Loading branch information
irmen committed Jul 5, 2017
1 parent 27e818b commit a582be9
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion stories/demo/story.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def init_player(self, player: Player) -> None:
Hint("unlocked_enddoor", None, "Step out through the door into the freedom!")
])

def create_account_dialog(self, playerconnection: PlayerConnection, playernaming:PlayerNaming) -> Generator:
def create_account_dialog(self, playerconnection: PlayerConnection, playernaming: PlayerNaming) -> Generator:
"""
Override to add extra dialog options to the character creation process.
Because there's no actual player yet, you receive PlayerConnection and PlayerNaming arguments.
Expand Down
4 changes: 2 additions & 2 deletions tale/charbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Copyright by Irmen de Jong (irmen@razorvine.net)
"""

from typing import Generator, Set
from typing import Generator, Set, Dict, Any

from . import lang
from . import mud_context
Expand All @@ -23,7 +23,7 @@ def __init__(self) -> None:
self.wizard = False
self.password = None
self.email = None
self.story_data = {}
self.story_data = {} # type: Dict[Any, Any]

def apply_to(self, player: Player) -> None:
assert self._name
Expand Down
34 changes: 17 additions & 17 deletions tale/lang.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,54 +66,54 @@ def a(noun_phrase: str) -> str:
if not noun_phrase:
return ""
if noun_phrase.lower() in {"a", "an"}:
return "an "+noun_phrase
return "an " + noun_phrase
m = re.search('\w+', noun_phrase)
if m:
word = m.group(0)
if word.lower() in {"a", "an"}:
return noun_phrase
else:
return 'an '+noun_phrase
return 'an ' + noun_phrase

wordi = word.lower()
if wordi.startswith(('euler', 'heir', 'honest', 'hono')):
return 'an '+noun_phrase
return 'an ' + noun_phrase

if wordi.startswith('hour') and not wordi.startswith('houri'):
return 'an '+noun_phrase
return 'an ' + noun_phrase

if len(word) == 1:
if wordi in 'aefhilmnorsx':
return 'an '+noun_phrase
return 'an ' + noun_phrase
else:
return 'a '+noun_phrase
return 'a ' + noun_phrase

if re.match(r'(?!FJO|[HLMNS]Y.|RY[EO]|SQU|'
r'(F[LR]?|[HL]|MN?|N|RH?|S[CHKLMNPTVW]?|X(YL)?)[AEIOU])'
r'[FHLMNRSX][A-Z]', word):
return 'an '+noun_phrase
r'(F[LR]?|[HL]|MN?|N|RH?|S[CHKLMNPTVW]?|X(YL)?)[AEIOU])'
r'[FHLMNRSX][A-Z]', word):
return 'an ' + noun_phrase

for regex in (r'^e[uw]', r'^onc?e\b',
r'^uni([^nmd]|mo)','^u[bcfhjkqrst][aeiou]'):
r'^uni([^nmd]|mo)', '^u[bcfhjkqrst][aeiou]'):
if re.match(regex, wordi):
return 'a '+noun_phrase
return 'a ' + noun_phrase

# original regex was /^U[NK][AIEO]?/ but that matches UK, UN, etc.
if re.match('^U[NK][AIEO]', word):
return 'a '+noun_phrase
return 'a ' + noun_phrase
elif word == word.upper():
if wordi[0] in 'aefhilmnorsx':
return 'an '+noun_phrase
return 'an ' + noun_phrase
else:
return 'a '+noun_phrase
return 'a ' + noun_phrase

if wordi[0] in 'aeiou':
return 'an '+noun_phrase
return 'an ' + noun_phrase

if re.match(r'^y(b[lor]|cl[ea]|fere|gg|p[ios]|rou|tt)', wordi):
return 'an '+noun_phrase
return 'an ' + noun_phrase
else:
return 'a '+noun_phrase
return 'a ' + noun_phrase


def A(word: str) -> str:
Expand Down
2 changes: 1 addition & 1 deletion tale/tio/if_browser_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def wsgi_handle_story(self, environ: Dict[str, Any], parameters: Dict[str, str],
return [txt.encode("utf-8")]

def wsgi_handle_eventsource(self, environ: Dict[str, Any], parameters: Dict[str, str],
start_response: WsgiStartResponseType) -> Iterable[bytes]:
start_response: WsgiStartResponseType) -> Iterable[bytes]:
session = environ["wsgi.session"]
conn = session.get("player_connection")
if not conn:
Expand Down
2 changes: 1 addition & 1 deletion tale/tio/mud_browser_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def wsgi_handle_story(self, environ: Dict[str, Any], parameters: Dict[str, str],
return super().wsgi_handle_story(environ, parameters, start_response)

def wsgi_handle_eventsource(self, environ: Dict[str, Any], parameters: Dict[str, str],
start_response: WsgiStartResponseType) -> Iterable[bytes]:
start_response: WsgiStartResponseType) -> Iterable[bytes]:
session = environ["wsgi.session"]
conn = session.get("player_connection")
if not conn:
Expand Down

0 comments on commit a582be9

Please sign in to comment.