示例#1
0
def list_dir(dir_path, file_filter = None):
    file_list = []
    if string_utils.is_not_empty(dir_path):
        if os.path.isdir(dir_path):
            filename_list = os.listdir(dir_path)
            for filename in filename_list:
                if file_filter and isinstance(file_filter, FileFilter):
                    if file_filter.filter(filename):
                        file_list.append(os.path.join(dir_path, filename))
                else:
                    file_list.append(os.path.join(dir_path, filename))
    else:
        file_list = None
        
    return file_list
示例#2
0
def list_dir(dir_path, file_filter=None):
    file_list = []
    if string_utils.is_not_empty(dir_path):
        if os.path.isdir(dir_path):
            filename_list = os.listdir(dir_path)
            for filename in filename_list:
                if file_filter and isinstance(file_filter, FileFilter):
                    if file_filter.filter(filename):
                        file_list.append(os.path.join(dir_path, filename))
                else:
                    file_list.append(os.path.join(dir_path, filename))
    else:
        file_list = None

    return file_list
示例#3
0
def main(argv):
    sub_cmd = argv[1]
    if str_utils.is_not_empty(sub_cmd):
        if sub_cmd == 'sed':
            sed.exec_cmd(argv)
        elif sub_cmd == 'grep':
            grep.exec_cmd(argv)
        elif sub_cmd == 'awk':
            awk.exec_cmd(argv)
        elif sub_cmd == 'edit':
            edit.exec_cmd(argv)
        elif sub_cmd == 'help':
            show_help()
        else:
            show_help()
示例#4
0
 def match_line(line):
     if string_utils.is_not_empty(line):
         return len(string_utils.split(line, ';')) == 5
     return False
示例#5
0
 def test_is_not_empty(self):
     self.assertEqual(string_utils.is_not_empty(None), False)
     self.assertEqual(string_utils.is_not_empty(' '), False)
     self.assertEqual(string_utils.is_not_empty('word'), True)
     self.assertEqual(string_utils.is_not_empty(True), True)
     self.assertEqual(string_utils.is_not_empty(21), True)
示例#6
0
 def print_user(line):
     if len(line) == 7:
         if string_utils.is_not_empty(line[6]) and line[
                 6] != '/usr/sbin/nologin' and line[6] != '/bin/false':
             return [line[0], line[5], line[6]]
     return None
示例#7
0
 def print_user(line):
     if len(line) == 7:
         if string_utils.is_not_empty(line[6]) and line[6] != '/usr/sbin/nologin' and line[6] != '/bin/false':
             return [line[0], line[5], line[6]]
     return None
示例#8
0
 def match_line(line):
     if string_utils.is_not_empty(line):
         return len(string_utils.split(line, ';')) == 5
     return False