Ran black on code

This commit is contained in:
Griatch 2020-01-29 23:18:22 +01:00
parent ff16eb1bfe
commit c3cf3f99ab
4 changed files with 36 additions and 31 deletions

View file

@ -213,8 +213,10 @@ application = service.Application("Portal")
if "--nodaemon" not in sys.argv: if "--nodaemon" not in sys.argv:
logfile = logger.WeeklyLogFile( logfile = logger.WeeklyLogFile(
os.path.basename(settings.PORTAL_LOG_FILE), os.path.dirname(settings.PORTAL_LOG_FILE), os.path.basename(settings.PORTAL_LOG_FILE),
day_rotation=settings.PORTAL_LOG_DAY_ROTATION, max_size=settings.PORTAL_LOG_MAX_SIZE os.path.dirname(settings.PORTAL_LOG_FILE),
day_rotation=settings.PORTAL_LOG_DAY_ROTATION,
max_size=settings.PORTAL_LOG_MAX_SIZE,
) )
application.setComponent(ILogObserver, logger.PortalLogObserver(logfile).emit) application.setComponent(ILogObserver, logger.PortalLogObserver(logfile).emit)

View file

@ -55,9 +55,9 @@ class TestAMPServer(TwistedTestCase):
if pickle.HIGHEST_PROTOCOL == 5: if pickle.HIGHEST_PROTOCOL == 5:
# Python 3.8+ # Python 3.8+
byte_out = ( byte_out = (
b'\x00\x04_ask\x00\x011\x00\x08_command\x00\x10MsgServer2Portal\x00\x0b' b"\x00\x04_ask\x00\x011\x00\x08_command\x00\x10MsgServer2Portal\x00\x0b"
b'packed_data\x00 x\xdak`\x9d*\xc8\x00\x01\xde\x8c\xb5SzXJR' b"packed_data\x00 x\xdak`\x9d*\xc8\x00\x01\xde\x8c\xb5SzXJR"
b'\x8bK\xa6x3\x15\xb7M\xd1\x03\x00VU\x07u\x00\x00' b"\x8bK\xa6x3\x15\xb7M\xd1\x03\x00VU\x07u\x00\x00"
) )
elif pickle.HIGHEST_PROTOCOL == 4: elif pickle.HIGHEST_PROTOCOL == 4:
# Python 3.7 # Python 3.7
@ -78,9 +78,9 @@ class TestAMPServer(TwistedTestCase):
if pickle.HIGHEST_PROTOCOL == 5: if pickle.HIGHEST_PROTOCOL == 5:
# Python 3.8+ # Python 3.8+
byte_out = ( byte_out = (
b'\x00\x04_ask\x00\x011\x00\x08_command\x00\x10MsgPortal2Server\x00\x0b' b"\x00\x04_ask\x00\x011\x00\x08_command\x00\x10MsgPortal2Server\x00\x0b"
b'packed_data\x00 x\xdak`\x9d*\xc8\x00\x01\xde\x8c\xb5SzXJR' b"packed_data\x00 x\xdak`\x9d*\xc8\x00\x01\xde\x8c\xb5SzXJR"
b'\x8bK\xa6x3\x15\xb7M\xd1\x03\x00VU\x07u\x00\x00' b"\x8bK\xa6x3\x15\xb7M\xd1\x03\x00VU\x07u\x00\x00"
) )
elif pickle.HIGHEST_PROTOCOL == 4: elif pickle.HIGHEST_PROTOCOL == 4:
# Python 3.7 # Python 3.7
@ -105,22 +105,22 @@ class TestAMPServer(TwistedTestCase):
if pickle.HIGHEST_PROTOCOL == 5: if pickle.HIGHEST_PROTOCOL == 5:
# Python 3.8+ # Python 3.8+
self.transport.write.assert_called_with( self.transport.write.assert_called_with(
b'\x00\x04_ask\x00\x011\x00\x08_command\x00\x10MsgServer2Portal\x00\x0bpacked_data' b"\x00\x04_ask\x00\x011\x00\x08_command\x00\x10MsgServer2Portal\x00\x0bpacked_data"
b'\x00wx\xda\xed\xc6\xc1\t\x80 \x00@Q#=5Z\x0b\xb8\x80\x13\xe85h\x80\x8e\xbam`Dc\xf4><\xf8g' b"\x00wx\xda\xed\xc6\xc1\t\x80 \x00@Q#=5Z\x0b\xb8\x80\x13\xe85h\x80\x8e\xbam`Dc\xf4><\xf8g"
b'\x1a[\xf8\xda\x97\xa3_\xb1\x95\xdaz\xbe\xe7\x1a\xde\x03\x00\x00\x00\x00\x00\x00\x00' b"\x1a[\xf8\xda\x97\xa3_\xb1\x95\xdaz\xbe\xe7\x1a\xde\x03\x00\x00\x00\x00\x00\x00\x00"
b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xe0\x1f\x1eP\x1d\x02\r\x00\rpacked_data.2' b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xe0\x1f\x1eP\x1d\x02\r\x00\rpacked_data.2"
b'\x00Zx\xda\xed\xc3\x01\r\x00\x00\x08\xc0\xa0\xb4&\xf0\xfdg\x10a\xa3' b"\x00Zx\xda\xed\xc3\x01\r\x00\x00\x08\xc0\xa0\xb4&\xf0\xfdg\x10a\xa3"
b'\xd9RUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU\xf5\xfb\x03m\xe0\x06' b"\xd9RUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU\xf5\xfb\x03m\xe0\x06"
b'\x1d\x00\rpacked_data.3\x00Zx\xda\xed\xc3\x01\r\x00\x00\x08\xc0\xa0\xb4&\xf0\xfdg\x10a' b"\x1d\x00\rpacked_data.3\x00Zx\xda\xed\xc3\x01\r\x00\x00\x08\xc0\xa0\xb4&\xf0\xfdg\x10a"
b'\xa3fSUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU\xf5\xfb\x03n\x1c' b"\xa3fSUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU\xf5\xfb\x03n\x1c"
b'\x06\x1e\x00\rpacked_data.4\x00Zx\xda\xed\xc3\x01\t\x00\x00\x0c\x03\xa0\xb4O\xb0\xf5gA' b"\x06\x1e\x00\rpacked_data.4\x00Zx\xda\xed\xc3\x01\t\x00\x00\x0c\x03\xa0\xb4O\xb0\xf5gA"
b'\xae`\xda\x8b\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa' b"\xae`\xda\x8b\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
b'\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa' b"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
b'\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa' b"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
b'\xaa\xaa\xaa\xdf\x0fnI\x06,\x00\rpacked_data.5\x00\x18x\xdaK-.)I\xc5\x8e\xa7\xb22@\xc0' b"\xaa\xaa\xaa\xdf\x0fnI\x06,\x00\rpacked_data.5\x00\x18x\xdaK-.)I\xc5\x8e\xa7\xb22@\xc0"
b'\x94\xe2\xb6)z\x00Z\x1e\x0e\xb6\x00\x00' b"\x94\xe2\xb6)z\x00Z\x1e\x0e\xb6\x00\x00"
) )
elif pickle.HIGHEST_PROTOCOL == 4: elif pickle.HIGHEST_PROTOCOL == 4:
# Python 3.7 # Python 3.7

View file

@ -616,8 +616,10 @@ application = service.Application("Evennia")
if "--nodaemon" not in sys.argv: if "--nodaemon" not in sys.argv:
# custom logging, but only if we are not running in interactive mode # custom logging, but only if we are not running in interactive mode
logfile = logger.WeeklyLogFile( logfile = logger.WeeklyLogFile(
os.path.basename(settings.SERVER_LOG_FILE), os.path.dirname(settings.SERVER_LOG_FILE), os.path.basename(settings.SERVER_LOG_FILE),
day_rotation=settings.SERVER_LOG_DAY_ROTATION, max_size=settings.SERVER_LOG_MAX_SIZE os.path.dirname(settings.SERVER_LOG_FILE),
day_rotation=settings.SERVER_LOG_DAY_ROTATION,
max_size=settings.SERVER_LOG_MAX_SIZE,
) )
application.setComponent(ILogObserver, logger.ServerLogObserver(logfile).emit) application.setComponent(ILogObserver, logger.ServerLogObserver(logfile).emit)

View file

@ -107,10 +107,12 @@ class WeeklyLogFile(logfile.DailyLogFile):
# all dates here are tuples (year, month, day) # all dates here are tuples (year, month, day)
now = self.toDate() now = self.toDate()
then = self.lastDate then = self.lastDate
return (now[0] > then[0] or return (
now[1] > then[1] or now[0] > then[0]
now[2] > (then[2] + self.day_rotation) or or now[1] > then[1]
self.size >= self.max_size) or now[2] > (then[2] + self.day_rotation)
or self.size >= self.max_size
)
def suffix(self, tupledate): def suffix(self, tupledate):
"""Return the suffix given a (year, month, day) tuple or unixtime. """Return the suffix given a (year, month, day) tuple or unixtime.
@ -143,7 +145,6 @@ class WeeklyLogFile(logfile.DailyLogFile):
break break
return suffix return suffix
def write(self, data): def write(self, data):
"Write data to log file" "Write data to log file"
logfile.BaseLogFile.write(self, data) logfile.BaseLogFile.write(self, data)