def prune_processes(args=[]): procs = [] for p in text_lines(list_processes(args)): p = split(' +', p) if p[7:]: procs.append('kill -9 %-10s # %s' % (p[1], ' '.join(p[7:])[:20])) return '\n'.join(procs)
def unc_student_test(): output = ['Sensei Users: ', list_users()] for course in unc_courses(): # import_test_students() students = list_students(course) output.append(students) return '%s Student Records' % len(text_lines(text_join(output)))
def render_sections(markdown_text): output = [] sections = markdown_text.split("\n## ") for text in sections: body = fix_images(text, '../images') title = text_lines(text)[0] settings = create_slide_section(title, body) output.append(settings) return output
def source(): print('source code:') source_text = source_code() print('%s files, %s lines of source code' % (len(code_files()), len(text_lines(source_text))))
def count_lines(text, min, max): x = len(text_lines(text)) if x > max or x < min: return '%d Lines in output (should be between %s and %s)' % (x, min, max) else: return 'Lines in output (is between %s and %s)' % (min, max)
def code_source_test(): files = len(code_files()) source = len(text_lines(source_code())) functions = len(text_lines(list_functions())) return '%s files, %s functions, %s lines of source code' % (files, functions, source)
def code_files(path='.'): exclude = ['env', '.venv'] files = shell_file_list(path, 'py', exclude) files = delete_lines(files, '.DS_Store') return text_lines(files)
def html_files(): exclude = ['env', '.venv'] files = text_lines(shell_file_list('.', 'html', exclude)) files += text_lines(shell_file_list('.', 'css', exclude)) return files
def doc_files(): exclude = ['.git', 'env', '.venv'] files = shell_file_list('Documents', '', exclude) files = delete_lines(files, '.DS_Store') files = delete_lines(files, 'dktht') return text_lines(files)
def no_blank_lines(text): text = text_lines(text) text = [x for x in text if x.strip() != ''] text = text_join(text) return text