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

import os
import sys

from proc_stat import ProcStat
from proc_swaps import ProcSwaps
from proc_uptime import ProcUptime
from proc_version import ProcVersion


def print_stats():
    '''
    Parses details from the /proc/stat file.
    Gathered information is then printed to stdout.
    '''
    stat = ProcStat()
    stat.dump()


def print_uptime():
    '''
    Parses details from the /proc/uptime file.
    Gathered information is then printed to stdout.
    '''
    uptime = ProcUptime()
    uptime.dump()


def print_version():
    '''
    Parses details from the /proc/version file.
    Gathered information is then printed to stdout.
    '''
    version = ProcVersion()
    version.dump()


def print_swaps():
    '''
    Parses details from the /proc/swaps file.
    Gathered information is then printed to stdout.
    '''
    swaps = ProcSwaps()
    swaps.dump()


if __name__ == '__main__':

    if os.name != 'posix':
        print('pyProc only supports UNIX systems, exiting')
        sys.exit()

    print_stats()
    print_uptime()
    print_version()
    print_swaps()<commit_msg>create class to handle printing to stdout<commit_after>#!/usr/bin/env python3

import os
import sys

from proc_stat import ProcStat
from proc_swaps import ProcSwaps
from proc_uptime import ProcUptime
from proc_version import ProcVersion


class PrintManager:
    '''
    Class manages the list of supported /proc
    sub-files we have classes for.

    As well as printing the information contained in
    them to stdout.
    '''

    def __init__(self):
        '''
        Creates an instance of all the classes derived
        from ProcBase. Representing abstractions of
        the supported sub-files.
        '''
        self.file_wrappers = [ProcStat(),
                              ProcSwaps(),
                              ProcUptime(),
                              ProcVersion()]

    def dump_all(self):
        '''
        Iterates over all files and prints their details to
        stdout using overridden procBase dump() function.
        '''
        for _file in self.file_wrappers:
            _file.dump()  # Implemented in base class


if __name__ == '__main__':

    if os.name != 'posix':
        print('pyProc only supports UNIX systems, exiting')
        sys.exit()

    # Print all details
    printer = PrintManager()
    printer.dump_all()
{'fraction_non_alphanumeric': 0.08368026644462948, 'fraction_numerical': 0.0008326394671107411, 'mean_word_length': 2.3797468354430378, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '3155493', 'n_tokens_mistral': 716, 'n_tokens_neox': 678, 'n_words': 231}