From af80925d70c7ec9a2f3a8042f7e473b3a3a97189 Mon Sep 17 00:00:00 2001 From: "Martin A. Brown" Date: Sat, 2 Apr 2016 11:58:19 -0700 Subject: [PATCH] remove references to unused statinfo stuff --- tests/test_utils.py | 13 +++++++------ tldp/utils.py | 36 +----------------------------------- 2 files changed, 8 insertions(+), 41 deletions(-) diff --git a/tests/test_utils.py b/tests/test_utils.py index 39d7859..bf88c24 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -19,6 +19,7 @@ from tldp.utils import statfile, statfiles, stem_and_ext from tldp.utils import arg_isexecutable, isexecutable from tldp.utils import arg_isreadablefile, isreadablefile from tldp.utils import arg_isdirectory, arg_isloglevel +from tldp.utils import arg_isstr from tldp.utils import swapdirs @@ -54,6 +55,12 @@ class Test_isreadablefile_and_friends(unittest.TestCase): self.assertIsNone(arg_isreadablefile(f.name)) +class Test_arg_isstr(unittest.TestCase): + + def test_arg_isstr(self): + self.assertEqual('s', arg_isstr('s')) + self.assertEqual(None, arg_isstr(7)) + class Test_arg_isloglevel(unittest.TestCase): def test_arg_isloglevel_integer(self): @@ -247,11 +254,5 @@ class Test_swapdirs(TestToolsFilesystem): self.assertTrue(os.path.exists(b)) self.assertTrue(os.path.exists(bfile)) - -class Test_att_statinfo(unittest.TestCase): - - def test_max_mtime(self): - pass - # # -- end of file diff --git a/tldp/utils.py b/tldp/utils.py index 9f35dd1..6340a05 100644 --- a/tldp/utils.py +++ b/tldp/utils.py @@ -229,7 +229,7 @@ def isstr(s): unicode stringy = (str, unicode) except NameError: - stringy = (str,) + stringy = (str,) # -- python3 return isinstance(s, stringy) @@ -349,39 +349,5 @@ def fileinfo(name, relative=None, func=statfile): del info[relpath] return info - -def att_statinfo(statinfo, attr='st_mtime', func=max): - if statinfo: - return func([getattr(v, attr) for v in statinfo.values()]) - else: - return 0 - - -max_size = functools.partial(att_statinfo, attr='st_size', func=max) -min_size = functools.partial(att_statinfo, attr='st_size', func=min) - -max_mtime = functools.partial(att_statinfo, attr='st_mtime', func=max) -min_mtime = functools.partial(att_statinfo, attr='st_mtime', func=min) - -max_ctime = functools.partial(att_statinfo, attr='st_ctime', func=max) -min_ctime = functools.partial(att_statinfo, attr='st_ctime', func=min) - -max_atime = functools.partial(att_statinfo, attr='st_atime', func=max) -min_atime = functools.partial(att_statinfo, attr='st_atime', func=min) - - -def sieve(operand, statinfo, attr='st_mtime', func=operator.gt): - result = set() - for fname, stbuf in statinfo.items(): - if func(getattr(stbuf, attr), operand): - result.add(fname) - return result - -mtime_gt = functools.partial(sieve, attr='st_mtime', func=operator.gt) -mtime_lt = functools.partial(sieve, attr='st_mtime', func=operator.lt) - -size_gt = functools.partial(sieve, attr='st_size', func=operator.gt) -size_lt = functools.partial(sieve, attr='st_size', func=operator.lt) - # # -- end of file