summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
ee766d1)
* lib/mudpy/__init__.py
* lib/mudpy/data.py
* lib/mudpy/misc.py
* lib/mudpy/telnet.py: Limit lines to <80 characters and adjust
hanging/visual indents for clarity and consistency.
- u"""Import/reload some modules (be careful, as this can result in loops)."""
+ u"""Import/reload some modules (be careful, as this can result in
+ loops)."""
# pick up the modules list from this package
global modules
# pick up the modules list from this package
global modules
relative=self.filename,
universe=self.universe
)
relative=self.filename,
universe=self.universe
)
- if include_file not in self.universe.files or not self.universe.files[
- include_file
- ].is_writeable():
+ if (include_file not in self.universe.files or not
+ self.universe.files[include_file].is_writeable()):
DataFile(include_file, self.universe)
def save(self):
DataFile(include_file, self.universe)
def save(self):
else:
self.category = u"other"
self.subkey = self.key
else:
self.category = u"other"
self.subkey = self.key
- if not self.category in self.universe.categories:
+ if self.category not in self.universe.categories:
self.category = u"other"
self.subkey = self.key
self.category = u"other"
self.subkey = self.key
filename = os.path.abspath(filename)
# add the file if it doesn't exist yet
filename = os.path.abspath(filename)
# add the file if it doesn't exist yet
- if not filename in self.universe.files:
+ if filename not in self.universe.files:
data.DataFile(filename, self.universe)
# record or reset a pointer to the origin file
data.DataFile(filename, self.universe)
# record or reset a pointer to the origin file
def authenticate(self):
u"""Flag the user as authenticated and disconnect duplicates."""
def authenticate(self):
u"""Flag the user as authenticated and disconnect duplicates."""
- if not self.state is u"authenticated":
+ if self.state is not u"authenticated":
log(u"User " + self.account.get(u"name") + u" logged in.", 2)
self.authenticated = True
if self.account.subkey in universe.categories[
log(u"User " + self.account.get(u"name") + u" logged in.", 2)
self.authenticated = True
if self.account.subkey in universe.categories[
account = self.account.get(u"name")
else:
account = u"an unknown user"
account = self.account.get(u"name")
else:
account = u"an unknown user"
- log(
- u"Sending to %s raised an exception (broken pipe?)." % account,
- 7
- )
+ log(u"Sending to %s raised an exception (broken pipe?)."
+ % account, 7)
pass
def enqueue_input(self):
pass
def enqueue_input(self):
# iterate over every line in the message
full_message = u""
for line in lines:
# iterate over every line in the message
full_message = u""
for line in lines:
- full_message += u"$(bld)$(red)" + timestamp + u" " + line.replace(
- u"$(", u"$_("
- ) + u"$(nrm)$(eol)"
+ full_message += (
+ u"$(bld)$(red)" + timestamp + u" "
+ + line.replace(u"$(", u"$_(") + u"$(nrm)$(eol)")
user.send(full_message, flush=True)
# add to the recent log list
user.send(full_message, flush=True)
# add to the recent log list
# the current position in the entire text string, including all
# characters, printable or otherwise
# the current position in the entire text string, including all
# characters, printable or otherwise
# the current text position relative to the begining of the line,
# ignoring color escape sequences
# the current text position relative to the begining of the line,
# ignoring color escape sequences
# the absolute position of the most recent whitespace character
last_whitespace = 0
# the absolute position of the most recent whitespace character
last_whitespace = 0
# the current character is a newline, so reset the relative
# position (start a new line)
elif each_character == u"\n":
# the current character is a newline, so reset the relative
# position (start a new line)
elif each_character == u"\n":
- relative_position = 0
- last_whitespace = absolute_position
+ rel_pos = 0
+ last_whitespace = abs_pos
# the current character meets the requested maximum line width,
# so we need to backtrack and find a space at which to wrap;
# special care is taken to avoid an off-by-one in case the
# current character is a double-width glyph
elif each_character != u"\r" and (
# the current character meets the requested maximum line width,
# so we need to backtrack and find a space at which to wrap;
# special care is taken to avoid an off-by-one in case the
# current character is a double-width glyph
elif each_character != u"\r" and (
- relative_position >= width or (
- relative_position >= width - 1 and glyph_columns(
+ rel_pos >= width or (
+ rel_pos >= width - 1 and glyph_columns(
# it's always possible we landed on whitespace
if unicodedata.category(each_character) in (u"Cc", u"Zs"):
# it's always possible we landed on whitespace
if unicodedata.category(each_character) in (u"Cc", u"Zs"):
- last_whitespace = absolute_position
+ last_whitespace = abs_pos
# insert an eol in place of the space
text = text[:last_whitespace] + \
# insert an eol in place of the space
text = text[:last_whitespace] + \
# increase the absolute position because an eol is two
# characters but the space it replaced was only one
# increase the absolute position because an eol is two
# characters but the space it replaced was only one
# now we're at the begining of a new line, plus the
# number of characters wrapped from the previous line
# now we're at the begining of a new line, plus the
# number of characters wrapped from the previous line
- relative_position = 0
- for remaining_characters in text[last_whitespace:absolute_position]:
- relative_position += glyph_columns(remaining_characters)
+ rel_pos = 0
+ for remaining_characters in text[last_whitespace:abs_pos]:
+ rel_pos += glyph_columns(remaining_characters)
# as long as the character is not a carriage return and the
# other above conditions haven't been met, count it as a
# printable character
elif each_character != u"\r":
# as long as the character is not a carriage return and the
# other above conditions haven't been met, count it as a
# printable character
elif each_character != u"\r":
- relative_position += glyph_columns(each_character)
+ rel_pos += glyph_columns(each_character)
if unicodedata.category(each_character) in (u"Cc", u"Zs"):
if unicodedata.category(each_character) in (u"Cc", u"Zs"):
- last_whitespace = absolute_position
+ last_whitespace = abs_pos
# increase the absolute position for every character
# increase the absolute position for every character
# return the newly-wrapped text
return text
# return the newly-wrapped text
return text
user.pulse()
# add an element for counters if it doesn't exist
user.pulse()
# add an element for counters if it doesn't exist
- if not u"counters" in universe.categories[u"internal"]:
+ if u"counters" not in universe.categories[u"internal"]:
universe.categories[u"internal"][u"counters"] = Element(
u"internal:counters", universe
)
universe.categories[u"internal"][u"counters"] = Element(
u"internal:counters", universe
)
actions = universe.categories[u"internal"][u"language"].getdict(
u"actions"
)
actions = universe.categories[u"internal"][u"language"].getdict(
u"actions"
)
- default_punctuation = universe.categories[u"internal"][u"language"].get(
- u"default_punctuation"
- )
+ default_punctuation = (
+ universe.categories[u"internal"][u"language"].get(
+ u"default_punctuation"))
action = u""
for mark in actions.keys():
if not literal and message.endswith(mark):
action = u""
for mark in actions.keys():
if not literal and message.endswith(mark):
else:
start = 10
if len(arguments) >= 2:
else:
start = 10
if len(arguments) >= 2:
- if re.match(u"^\d+$", arguments[1]) and 0 <= int(arguments[1]) <= 9:
+ if (re.match(u"^\d+$", arguments[1])
+ and 0 <= int(arguments[1]) <= 9):
level = int(arguments[1])
else:
level = -1
level = int(arguments[1])
else:
level = -1
- """This contains functions to be performed when shutting down the engine."""
+ """This contains functions to be performed when shutting down the
+ engine."""
# the loop has terminated, so save persistent data
universe.save()
# the loop has terminated, so save persistent data
universe.save()
def is_enabled(user, telopt, party, state=YES):
def is_enabled(user, telopt, party, state=YES):
- u"""Returns True if the indicated Telnet option is enabled, False if not."""
+ u"""Returns True if the indicated Telnet option is enabled, False if
+ not."""
if (telopt, party) in user.telopts and user.telopts[
(telopt, party)
] is state:
if (telopt, party) in user.telopts and user.telopts[
(telopt, party)
] is state:
def disable(user, telopt, party):
def disable(user, telopt, party):
- u"""Negotiates disabling a Telnet option for the indicated user's socket."""
+ u"""Negotiates disabling a Telnet option for the indicated user's
+ socket."""
if party is HIM:
txneg = DONT
else:
if party is HIM:
txneg = DONT
else: