<commit_before>#!/usr/bin/env python3

import os
from flask import Flask, render_template
app = Flask(__name__)

class VolumeInfo:
    def __init__(self, volume):
        #TODO: Verify volume is valid
        self.volume = volume.strip()
        self._stat = os.statvfs(self.volume)

    @property
    def free_space(self):
        return self._stat.f_bavail * self._stat.f_frsize

@app.route("/")
def hello():
    display_list_file = open("displaylist", 'r')
    render_items = []
    for line in display_list_file:
        info = VolumeInfo(line)
        render_items.append(info)

    return render_template('index.html', render_items=render_items)

if __name__ == "__main__":
    app.debug = True
    app.run(host='0.0.0.0')<commit_msg>Display list parsing moved into a class<commit_after>#!/usr/bin/env python3

import os
from flask import Flask, render_template
app = Flask(__name__)

class VolumeInfo:
    def __init__(self, volume):
        #TODO: Verify volume is valid
        self.volume = volume.strip()
        self._stat = os.statvfs(self.volume)

    @property
    def free_space(self):
        return self._stat.f_bavail * self._stat.f_frsize

    @property
    def total_size(self):
        return self._stat.f_blocks * self._stat.f_frsize

class DisplayList(list):
    def __init__(self, display_list_path):
        list.__init__(self)

        self._parse_display_list(display_list_path)

    def _parse_display_list(self, display_list_path):
        list_file = open(display_list_path, 'r')
        for line in list_file:
            self.append(VolumeInfo(line))

@app.route("/")
def hello():
    display_list = DisplayList("displaylist")

    return render_template('index.html', render_items=display_list)

if __name__ == "__main__":
    app.debug = True
    app.run(host='0.0.0.0')
{'fraction_non_alphanumeric': 0.11357340720221606, 'fraction_numerical': 0.00554016620498615, 'mean_word_length': 3.269503546099291, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2386540', 'n_tokens_mistral': 599, 'n_tokens_neox': 588, 'n_words': 128}