mirror of
https://github.com/evennia/evennia.git
synced 2026-03-19 14:26:30 +01:00
Move to python3 style division.
All of these are currently integer division in python2.
This commit is contained in:
parent
c8fbd2860d
commit
cbe1eefcf0
12 changed files with 18 additions and 9 deletions
|
|
@ -5,6 +5,7 @@ replacing cmdparser function. The replacement parser must accept the
|
|||
same inputs as the default one.
|
||||
|
||||
"""
|
||||
from __future__ import division
|
||||
|
||||
import re
|
||||
from django.conf import settings
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
System commands
|
||||
|
||||
"""
|
||||
from __future__ import division
|
||||
|
||||
import traceback
|
||||
import os
|
||||
|
|
@ -690,7 +691,7 @@ class CmdServerLoad(MuxCommand):
|
|||
if has_psutil:
|
||||
loadavg = psutil.cpu_percent()
|
||||
_mem = psutil.virtual_memory()
|
||||
rmem = _mem.used / (1000 * 1000)
|
||||
rmem = _mem.used / (1000.0 * 1000)
|
||||
pmem = _mem.percent
|
||||
|
||||
if "mem" in self.switches:
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ Installation/testing:
|
|||
3) Use `@desc` and `@detail` to customize the room, then play around!
|
||||
|
||||
"""
|
||||
from __future__ import division
|
||||
|
||||
import re
|
||||
from django.conf import settings
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
Sessionhandler for portal sessions
|
||||
"""
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
|
||||
from time import time
|
||||
from collections import deque
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ for instructions on how to define this module.
|
|||
|
||||
"""
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
|
||||
import sys
|
||||
import time
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ the script will append to this file if it already exists.
|
|||
|
||||
Call this module directly to plot the log (requires matplotlib and numpy).
|
||||
"""
|
||||
from __future__ import division
|
||||
import os, sys
|
||||
import time
|
||||
#TODO!
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ class ANSIParser(object):
|
|||
|
||||
if convert:
|
||||
colval = 16 + (red * 36) + (green * 6) + blue
|
||||
return "\033[%s8;5;%s%s%sm" % (3 + int(background), colval/100, (colval % 100)/10, colval%10)
|
||||
return "\033[%s8;5;%s%s%sm" % (3 + int(background), colval // 100, (colval % 100) // 10, colval%10)
|
||||
else:
|
||||
# xterm256 not supported, convert the rgb value to ansi instead
|
||||
if red == green and red == blue and red < 2:
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ It also supplies some useful methods to convert between
|
|||
in-mud time and real-world time as well allows to get the
|
||||
total runtime of the server and the current uptime.
|
||||
"""
|
||||
from __future__ import division
|
||||
|
||||
from time import time
|
||||
from django.conf import settings
|
||||
|
|
@ -56,7 +57,7 @@ def _format(seconds, *divisors) :
|
|||
results = []
|
||||
seconds = int(seconds)
|
||||
for divisor in divisors:
|
||||
results.append(seconds / divisor)
|
||||
results.append(seconds // divisor)
|
||||
seconds %= divisor
|
||||
results.append(seconds)
|
||||
return tuple(results)
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ leave caching unexpectedly (no use of WeakRefs).
|
|||
Also adds `cache_size()` for monitoring the size of the cache.
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
|
||||
import os, threading, gc, time
|
||||
#from twisted.internet import reactor
|
||||
|
|
|
|||
|
|
@ -1145,7 +1145,7 @@ class PrettyTable(object):
|
|||
dHeight = row_height - len(lines)
|
||||
if dHeight:
|
||||
if valign == "m":
|
||||
lines = [""] * int(dHeight / 2) + lines + [""] * (dHeight - int(dHeight / 2))
|
||||
lines = [""] * (dHeight // 2) + lines + [""] * (dHeight - (dHeight // 2))
|
||||
elif valign == "b":
|
||||
lines = [""] * dHeight + lines
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -130,8 +130,8 @@ def complete_hybi00(headers, challenge):
|
|||
key1 = headers["Sec-WebSocket-Key1"]
|
||||
key2 = headers["Sec-WebSocket-Key2"]
|
||||
|
||||
first = int("".join(i for i in key1 if i in digits)) / key1.count(" ")
|
||||
second = int("".join(i for i in key2 if i in digits)) / key2.count(" ")
|
||||
first = int("".join(i for i in key1 if i in digits)) // key1.count(" ")
|
||||
second = int("".join(i for i in key2 if i in digits)) // key2.count(" ")
|
||||
|
||||
nonce = pack(">II8s", first, second, challenge)
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ They provide some useful string and conversion methods that might
|
|||
be of use when designing your own game.
|
||||
|
||||
"""
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
|
|
@ -265,11 +266,11 @@ def time_format(seconds, style=0):
|
|||
# We'll just use integer math, no need for decimal precision.
|
||||
seconds = int(seconds)
|
||||
|
||||
days = seconds / 86400
|
||||
days = seconds // 86400
|
||||
seconds -= days * 86400
|
||||
hours = seconds / 3600
|
||||
hours = seconds // 3600
|
||||
seconds -= hours * 3600
|
||||
minutes = seconds / 60
|
||||
minutes = seconds // 60
|
||||
seconds -= minutes * 60
|
||||
|
||||
if style is 0:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue