Remove PrefixedKeyDict (unused)
This commit is contained in:
parent
1de1eaae87
commit
5eb271c684
@ -5,12 +5,11 @@ import re
|
||||
import configparser
|
||||
|
||||
from i3pystatus import IntervalModule, formatp
|
||||
from i3pystatus.core.util import PrefixedKeyDict, lchop, TimeWrapper
|
||||
from i3pystatus.core.util import lchop, TimeWrapper
|
||||
from i3pystatus.core.desktop import display_notification
|
||||
|
||||
|
||||
class UEventParser(configparser.ConfigParser):
|
||||
|
||||
@staticmethod
|
||||
def parse_file(file):
|
||||
parser = UEventParser()
|
||||
@ -29,7 +28,6 @@ class UEventParser(configparser.ConfigParser):
|
||||
|
||||
|
||||
class Battery:
|
||||
|
||||
@staticmethod
|
||||
def create(from_file):
|
||||
batinfo = UEventParser.parse_file(from_file)
|
||||
@ -58,7 +56,6 @@ class Battery:
|
||||
|
||||
|
||||
class BatteryCharge(Battery):
|
||||
|
||||
def consumption(self):
|
||||
return self.bat["VOLTAGE_NOW"] * self.bat["CURRENT_NOW"] # V * A = W
|
||||
|
||||
@ -74,7 +71,6 @@ class BatteryCharge(Battery):
|
||||
|
||||
|
||||
class BatteryEnergy(Battery):
|
||||
|
||||
def consumption(self):
|
||||
return self.bat["POWER_NOW"]
|
||||
|
||||
@ -90,7 +86,6 @@ class BatteryEnergy(Battery):
|
||||
|
||||
|
||||
class BatteryChecker(IntervalModule):
|
||||
|
||||
"""
|
||||
This class uses the /sys/class/power_supply/…/uevent interface to check for the
|
||||
battery status
|
||||
|
@ -89,22 +89,6 @@ class ModuleList(collections.UserList):
|
||||
return module
|
||||
|
||||
|
||||
class PrefixedKeyDict(collections.UserDict):
|
||||
"""
|
||||
A dict implementation adding a prefix to every key added
|
||||
|
||||
:param prefix: Prefix to prepend
|
||||
"""
|
||||
|
||||
def __init__(self, prefix):
|
||||
super().__init__()
|
||||
|
||||
self.prefix = prefix
|
||||
|
||||
def __setitem__(self, key, value):
|
||||
super().__setitem__(self.prefix + key, value)
|
||||
|
||||
|
||||
class KeyConstraintDict(collections.UserDict):
|
||||
"""
|
||||
A dict implementation with sets of valid and required keys
|
||||
|
@ -4,7 +4,6 @@ import unittest
|
||||
from unittest.mock import MagicMock
|
||||
import string
|
||||
import random
|
||||
import sys
|
||||
import types
|
||||
|
||||
from i3pystatus.core import util
|
||||
@ -187,35 +186,6 @@ class ModuleListTests(unittest.TestCase):
|
||||
cls.registered.assert_called_with(self.status_handler)
|
||||
|
||||
|
||||
class PrefixedKeyDictTests(unittest.TestCase):
|
||||
|
||||
def test_no_prefix(self):
|
||||
dict = util.PrefixedKeyDict("")
|
||||
dict["foo"] = None
|
||||
dict["bar"] = 42
|
||||
|
||||
assert dict["foo"] == None
|
||||
assert dict["bar"] == 42
|
||||
|
||||
def test_prefix(self):
|
||||
dict = util.PrefixedKeyDict("pfx_")
|
||||
dict["foo"] = None
|
||||
dict["bar"] = 42
|
||||
|
||||
assert dict["pfx_foo"] == None
|
||||
assert dict["pfx_bar"] == 42
|
||||
|
||||
def test_dict(self):
|
||||
d = util.PrefixedKeyDict("pfx_")
|
||||
d["foo"] = None
|
||||
d["bar"] = 42
|
||||
|
||||
realdict = dict(d)
|
||||
|
||||
assert realdict["pfx_foo"] == None
|
||||
assert realdict["pfx_bar"] == 42
|
||||
|
||||
|
||||
class KeyConstraintDictAdvancedTests(unittest.TestCase):
|
||||
|
||||
def test_invalid_1(self):
|
||||
|
Loading…
Reference in New Issue
Block a user