def test_drop_with_predicate(self):
     not_alpha = lambda x: not x.isalpha()
     self.assertEqualAsLists(U.drop_while(not_alpha, ''), '')
     self.assertEqualAsLists(U.drop_while(not_alpha, 'abc'), 'abc')
     self.assertEqualAsLists(U.drop_while(not_alpha, '123abc456'), 'abc456')
     self.assertEqualAsLists(U.drop_while(not_alpha, '   abc   '), 'abc   ')
     self.assertEqualAsLists(U.drop_while(not_alpha, '   '), '')
Esempio n. 2
0
def get_body(lines):
    """
    Extracts only the body of the "net use" table. The body is everything between the column
    headers and the end of the output.
    `lines` is a list of strings from the output of `NET USE`.
    """
    bottom = drop_while(not_(is_line_separator), lines)
    is_last_line = lambda x: x and x != LAST_TABLE_LINE
    return take_while(is_last_line, bottom[1:]) if len(bottom) > 1 else []
def get_body(lines):
    """
    Extracts only the body of the "net use" table. The body is everything between the column
    headers and the end of the output.
    `lines` is a list of strings from the output of `NET USE`.
    """
    bottom = drop_while(not_(is_line_separator), lines)
    is_last_line = lambda x: x and x != LAST_TABLE_LINE
    return (take_while(is_last_line, bottom[1:]) if len(bottom) > 1 else [])
 def test_drop_everything(self):
     self.assertEqualAsLists(U.drop_while(always, ''), '')
     self.assertEqualAsLists(U.drop_while(always, 'a'), '')
     self.assertEqualAsLists(U.drop_while(always, 'abc'), '')
 def test_drop_nothing(self):
     self.assertEqualAsLists(U.drop_while(never, ''), '')
     self.assertEqualAsLists(U.drop_while(never, 'a'), 'a')
     self.assertEqualAsLists(U.drop_while(never, 'abc'), 'abc')