Beispiel #1
0
def autofill_input_data(request):
    """Process an AJAX request to autofill the data textareas."""
    content = UploadedFile(request.FILES['file']).read().decode('utf-8')
    lines = content.splitlines()
    for i_line, line in enumerate(lines):
        if re.match(r'\s*#', line) or not line or line == '\r':
            del lines[i_line]
    return HttpResponse('\n'.join(lines))
Beispiel #2
0
def extract_k_from_control_in(request):
    """Extract the k-point path from the provided control.in."""
    content = UploadedFile(request.FILES['file']).read().decode('utf-8')
    k_labels = []
    for line in content.splitlines():
        if re.match(r' *output\b\s* band', line):
            words = line.split()
            k_labels.append(f'{words[-2]} {words[-1]}')
    return HttpResponse('\n'.join(k_labels))