コード例 #1
0
    def test_not_(self):
        false_ = lambda: False
        true_ = lambda: True
        id_ = lambda x: x

        self.assertEqual(U.not_(false_)(), True)
        self.assertEqual(U.not_(id_)(False), True)

        self.assertEqual(U.not_(true_)(), False)
        self.assertEqual(U.not_(id_)(True), False)
コード例 #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 []
コード例 #3
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 [])
コード例 #4
0
def get_columns(lines):
    """
    Parses the column headers from a "net use" table into a list of `NetUseColumn` objects.
    `lines` is a list of strings from the output of `NET USE`.
    """
    header_iter = take_while(not_(is_line_separator), lines)
    headings = rfirst(lambda x: x and x[0].isalpha(), header_iter)

    names = headings.split()
    starts = [headings.index(name) for name in names]
    ends = [right - 1 for right in starts[1:]] + [None]

    return [NetUseColumn(name, start, end) for name, start, end in zip(names, starts, ends)]
コード例 #5
0
def get_columns(lines):
    """
    Parses the column headers from a "net use" table into a list of `NetUseColumn` objects.
    `lines` is a list of strings from the output of `NET USE`.
    """
    header_iter = take_while(not_(is_line_separator), lines)
    headings = rfirst(lambda x: x and x[0].isalpha(), header_iter)

    names = headings.split()
    starts = [headings.index(name) for name in names]
    ends = [right - 1 for right in starts[1:]] + [None]

    return [
        NetUseColumn(name, start, end)
        for name, start, end in zip(names, starts, ends)
    ]