Remove some unused code
This commit is contained in:
parent
6b2c635cfa
commit
126e7ac531
21
hy/util.py
21
hy/util.py
@ -19,7 +19,6 @@
|
|||||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
# DEALINGS IN THE SOFTWARE.
|
# DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
import contextlib
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
@ -27,23 +26,3 @@ if sys.version_info[0] >= 3:
|
|||||||
str_type = str
|
str_type = str
|
||||||
else:
|
else:
|
||||||
str_type = unicode
|
str_type = unicode
|
||||||
|
|
||||||
|
|
||||||
@contextlib.contextmanager
|
|
||||||
def temporary_attribute_value(obj, attribute, value):
|
|
||||||
"""Temporarily switch an object attribute value to another value."""
|
|
||||||
original_value = getattr(obj, attribute)
|
|
||||||
setattr(obj, attribute, value)
|
|
||||||
try:
|
|
||||||
yield
|
|
||||||
finally:
|
|
||||||
setattr(obj, attribute, original_value)
|
|
||||||
|
|
||||||
|
|
||||||
def flatten_literal_list(entry):
|
|
||||||
for e in entry:
|
|
||||||
if type(e) == list:
|
|
||||||
for x in flatten_literal_list(e):
|
|
||||||
yield x # needs more yield-from
|
|
||||||
else:
|
|
||||||
yield e
|
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
from hy import util
|
|
||||||
|
|
||||||
|
|
||||||
def test_temporary_attribute_value():
|
|
||||||
class O(object):
|
|
||||||
def __init__(self):
|
|
||||||
self.foobar = 0
|
|
||||||
|
|
||||||
o = O()
|
|
||||||
|
|
||||||
with util.temporary_attribute_value(o, "foobar", 42):
|
|
||||||
assert o.foobar == 42
|
|
||||||
assert o.foobar == 0
|
|
Loading…
x
Reference in New Issue
Block a user