Skip to content

Commit a8484cf

Browse files
committed
style(optional): apply ruff against latest
1 parent d03851f commit a8484cf

5 files changed

Lines changed: 52 additions & 98 deletions

File tree

code/planet/cache.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,6 @@ def get_as_null(self, key):
238238
if not self.has_key(key):
239239
raise KeyError(key)
240240

241-
242241
def del_key(self, key):
243242
"""Delete the given key."""
244243
key = key.replace(" ", "_")

code/planet/compat_logging/__init__.py

Lines changed: 34 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,7 @@ def _acquireLock():
165165

166166

167167
def _releaseLock():
168-
"""Release the module-level lock acquired by calling _acquireLock().
169-
"""
168+
"""Release the module-level lock acquired by calling _acquireLock()."""
170169
if _lock:
171170
_lock.release()
172171

@@ -189,8 +188,7 @@ class LogRecord:
189188
"""
190189

191190
def __init__(self, name, level, pathname, lineno, msg, args, exc_info):
192-
"""Initialize a logging record with interesting information.
193-
"""
191+
"""Initialize a logging record with interesting information."""
194192
ct = time.time()
195193
self.name = name
196194
self.msg = msg
@@ -380,8 +378,7 @@ def format(self, record):
380378

381379

382380
class BufferingFormatter:
383-
"""A formatter suitable for formatting a number of records.
384-
"""
381+
"""A formatter suitable for formatting a number of records."""
385382

386383
def __init__(self, linefmt=None):
387384
"""Optionally specify a formatter which will be used to format each
@@ -393,18 +390,15 @@ def __init__(self, linefmt=None):
393390
self.linefmt = _defaultFormatter
394391

395392
def formatHeader(self, records):
396-
"""Return the header string for the specified records.
397-
"""
393+
"""Return the header string for the specified records."""
398394
return ""
399395

400396
def formatFooter(self, records):
401-
"""Return the footer string for the specified records.
402-
"""
397+
"""Return the footer string for the specified records."""
403398
return ""
404399

405400
def format(self, records):
406-
"""Format the specified records and return the result as a string.
407-
"""
401+
"""Format the specified records and return the result as a string."""
408402
rv = ""
409403
if len(records) > 0:
410404
rv = rv + self.formatHeader(records)
@@ -459,19 +453,16 @@ class Filterer:
459453
"""
460454

461455
def __init__(self):
462-
"""Initialize the list of filters to be an empty list.
463-
"""
456+
"""Initialize the list of filters to be an empty list."""
464457
self.filters = []
465458

466459
def addFilter(self, filter):
467-
"""Add the specified filter to this handler.
468-
"""
460+
"""Add the specified filter to this handler."""
469461
if filter not in self.filters:
470462
self.filters.append(filter)
471463

472464
def removeFilter(self, filter):
473-
"""Remove the specified filter from this handler.
474-
"""
465+
"""Remove the specified filter from this handler."""
475466
if filter in self.filters:
476467
self.filters.remove(filter)
477468

@@ -522,28 +513,24 @@ def __init__(self, level=NOTSET):
522513
self.createLock()
523514

524515
def createLock(self):
525-
"""Acquire a thread lock for serializing access to the underlying I/O.
526-
"""
516+
"""Acquire a thread lock for serializing access to the underlying I/O."""
527517
if thread:
528518
self.lock = thread.allocate_lock()
529519
else:
530520
self.lock = None
531521

532522
def acquire(self):
533-
"""Acquire the I/O thread lock.
534-
"""
523+
"""Acquire the I/O thread lock."""
535524
if self.lock:
536525
self.lock.acquire()
537526

538527
def release(self):
539-
"""Release the I/O thread lock.
540-
"""
528+
"""Release the I/O thread lock."""
541529
if self.lock:
542530
self.lock.release()
543531

544532
def setLevel(self, level):
545-
"""Set the logging level of this handler.
546-
"""
533+
"""Set the logging level of this handler."""
547534
self.level = level
548535

549536
def format(self, record):
@@ -584,8 +571,7 @@ def handle(self, record):
584571
return rv
585572

586573
def setFormatter(self, fmt):
587-
"""Set the formatter for this handler.
588-
"""
574+
"""Set the formatter for this handler."""
589575
self.formatter = fmt
590576

591577
def flush(self):
@@ -639,8 +625,7 @@ def __init__(self, strm=None):
639625
self.formatter = None
640626

641627
def flush(self):
642-
"""Flushes the stream.
643-
"""
628+
"""Flushes the stream."""
644629
self.stream.flush()
645630

646631
def emit(self, record):
@@ -667,19 +652,16 @@ def emit(self, record):
667652

668653

669654
class FileHandler(StreamHandler):
670-
"""A handler class which writes formatted logging records to disk files.
671-
"""
655+
"""A handler class which writes formatted logging records to disk files."""
672656

673657
def __init__(self, filename, mode="a"):
674-
"""Open the specified file and use it as the stream for logging.
675-
"""
658+
"""Open the specified file and use it as the stream for logging."""
676659
StreamHandler.__init__(self, open(filename, mode))
677660
self.baseFilename = filename
678661
self.mode = mode
679662

680663
def close(self):
681-
"""Closes the stream.
682-
"""
664+
"""Closes the stream."""
683665
self.stream.close()
684666

685667

@@ -695,13 +677,11 @@ class PlaceHolder:
695677
"""
696678

697679
def __init__(self, alogger):
698-
"""Initialize with the specified logger being a child of this placeholder.
699-
"""
680+
"""Initialize with the specified logger being a child of this placeholder."""
700681
self.loggers = [alogger]
701682

702683
def append(self, alogger):
703-
"""Add the specified logger as a child of this placeholder.
704-
"""
684+
"""Add the specified logger as a child of this placeholder."""
705685
if alogger not in self.loggers:
706686
self.loggers.append(alogger)
707687

@@ -730,8 +710,7 @@ class Manager:
730710
"""
731711

732712
def __init__(self, rootnode):
733-
"""Initialize the manager with the root node of the logger hierarchy.
734-
"""
713+
"""Initialize the manager with the root node of the logger hierarchy."""
735714
self.root = rootnode
736715
self.disable = 0
737716
self.emittedNoHandlerWarning = 0
@@ -821,8 +800,7 @@ class Logger(Filterer):
821800
"""
822801

823802
def __init__(self, name, level=NOTSET):
824-
"""Initialize the logger with a name and an optional level.
825-
"""
803+
"""Initialize the logger with a name and an optional level."""
826804
Filterer.__init__(self)
827805
self.name = name
828806
self.level = level
@@ -832,8 +810,7 @@ def __init__(self, name, level=NOTSET):
832810
self.disabled = 0
833811

834812
def setLevel(self, level):
835-
"""Set the logging level of this logger.
836-
"""
813+
"""Set the logging level of this logger."""
837814
self.level = level
838815

839816
# def getRoot(self):
@@ -897,8 +874,7 @@ def error(self, msg, *args, **kwargs):
897874
self._log(ERROR, msg, args, **kwargs)
898875

899876
def exception(self, msg, *args):
900-
"""Convenience method for logging an ERROR with exception information.
901-
"""
877+
"""Convenience method for logging an ERROR with exception information."""
902878
self.error(msg, *args, exc_info=True)
903879

904880
def critical(self, msg, *args, **kwargs):
@@ -971,14 +947,12 @@ def handle(self, record):
971947
self.callHandlers(record)
972948

973949
def addHandler(self, hdlr):
974-
"""Add the specified handler to this logger.
975-
"""
950+
"""Add the specified handler to this logger."""
976951
if hdlr not in self.handlers:
977952
self.handlers.append(hdlr)
978953

979954
def removeHandler(self, hdlr):
980-
"""Remove the specified handler from this logger.
981-
"""
955+
"""Remove the specified handler from this logger."""
982956
if hdlr in self.handlers:
983957
# hdlr.close()
984958
self.handlers.remove(hdlr)
@@ -1021,8 +995,7 @@ def getEffectiveLevel(self):
1021995
return NOTSET
1022996

1023997
def isEnabledFor(self, level):
1024-
"""Is this logger enabled for level 'level'?
1025-
"""
998+
"""Is this logger enabled for level 'level'?"""
1026999
if self.manager.disable >= level:
10271000
return 0
10281001
return level >= self.getEffectiveLevel()
@@ -1035,8 +1008,7 @@ class RootLogger(Logger):
10351008
"""
10361009

10371010
def __init__(self, level):
1038-
"""Initialize the logger with the name "root".
1039-
"""
1011+
"""Initialize the logger with the name "root"."""
10401012
Logger.__init__(self, "root", level)
10411013

10421014

@@ -1093,8 +1065,7 @@ def getLogger(name=None):
10931065

10941066

10951067
def critical(msg, *args, **kwargs):
1096-
"""Log a message with severity 'CRITICAL' on the root logger.
1097-
"""
1068+
"""Log a message with severity 'CRITICAL' on the root logger."""
10981069
if len(root.handlers) == 0:
10991070
basicConfig()
11001071
root.critical(msg, *args, **kwargs)
@@ -1104,8 +1075,7 @@ def critical(msg, *args, **kwargs):
11041075

11051076

11061077
def error(msg, *args, **kwargs):
1107-
"""Log a message with severity 'ERROR' on the root logger.
1108-
"""
1078+
"""Log a message with severity 'ERROR' on the root logger."""
11091079
if len(root.handlers) == 0:
11101080
basicConfig()
11111081
root.error(msg, *args, **kwargs)
@@ -1119,8 +1089,7 @@ def exception(msg, *args):
11191089

11201090

11211091
def warning(msg, *args, **kwargs):
1122-
"""Log a message with severity 'WARNING' on the root logger.
1123-
"""
1092+
"""Log a message with severity 'WARNING' on the root logger."""
11241093
if len(root.handlers) == 0:
11251094
basicConfig()
11261095
root.warning(msg, *args, **kwargs)
@@ -1130,24 +1099,21 @@ def warning(msg, *args, **kwargs):
11301099

11311100

11321101
def info(msg, *args, **kwargs):
1133-
"""Log a message with severity 'INFO' on the root logger.
1134-
"""
1102+
"""Log a message with severity 'INFO' on the root logger."""
11351103
if len(root.handlers) == 0:
11361104
basicConfig()
11371105
root.info(msg, *args, **kwargs)
11381106

11391107

11401108
def debug(msg, *args, **kwargs):
1141-
"""Log a message with severity 'DEBUG' on the root logger.
1142-
"""
1109+
"""Log a message with severity 'DEBUG' on the root logger."""
11431110
if len(root.handlers) == 0:
11441111
basicConfig()
11451112
root.debug(msg, *args, **kwargs)
11461113

11471114

11481115
def disable(level):
1149-
"""Disable all logging calls less severe than 'level'.
1150-
"""
1116+
"""Disable all logging calls less severe than 'level'."""
11511117
root.manager.disable = level
11521118

11531119

code/planet/compat_logging/config.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,7 @@ def handle(self):
252252
raise
253253

254254
class ConfigSocketReceiver(ThreadingTCPServer):
255-
"""A simple TCP socket-based logging config receiver.
256-
"""
255+
"""A simple TCP socket-based logging config receiver."""
257256

258257
allow_reuse_address = 1
259258

@@ -288,8 +287,7 @@ def serve(rcvr, hdlr, port):
288287

289288

290289
def stopListening():
291-
"""Stop the listening server which was created with a call to listen().
292-
"""
290+
"""Stop the listening server which was created with a call to listen()."""
293291
global _listener
294292
if _listener:
295293
logging._acquireLock()

0 commit comments

Comments
 (0)