<commit_before>
import os
import subprocess
from flask import render_template, request, current_app
from emonitor.extensions import classes, db
from emonitor.modules.printers.printerutils import PrintLayout


def getAdminContent(self, **params):
    """
    Deliver admin content of module printers

    :param params: use given parameters of request
    :return: rendered template as string
    """
    module = request.view_args['module'].split('/')

    if len(module) == 2:
        if module[1] == 'settings':  # printer settings
            if request.method == 'POST':
                if request.form.get('action') == 'savereprintersparams':
                    classes.get('settings').set('printer.callstring', request.form.get('printers_callstring'))

            _p = dict()
            _p['callstring'] = classes.get('settings').get('printer.callstring')
            params.update({'params': _p})
            return render_template('admin.printers.settings.html', **params)
    else:

        def _printernames(callstring):
            printernames = ['<default>']
            if len(callstring.split()) > 0:
                callstring = '{} -printer "xxx"'.format(callstring.split()[0])
            try:
                subprocess.check_output(callstring, stderr=subprocess.STDOUT, shell=True)
            except subprocess.CalledProcessError as e:
                for l in e.output.split('\r\n'):
                    if l.startswith('  "'):
                        printernames.append(l[3:-1].strip())
            return printernames

        #def _callstring():  # get callstring and replace variables
        #    callstring = classes.get('settings').get('printer.callstring')
        #    callstring = callstring.replace('[basepath]', current_app.config.get('PROJECT_ROOT'))
        #    return callstring

        def _templates():  # get all printer templates
            templates = {}
            for root, dirs, files in os.walk("{}/emonitor/modules/".format(current_app.config.get('PROJECT_ROOT'))):
                mod = root.replace("{}/emonitor/modules/".format(current_app.config.get('PROJECT_ROOT'), '').replace('\\templates', ''))
                for f in files:
                    if f.endswith('.html') and f.startswith('print.'):<commit_msg>fixed replace statement<commit_after>
import os
import subprocess
from flask import render_template, request, current_app
from emonitor.extensions import classes, db
from emonitor.modules.printers.printerutils import PrintLayout


def getAdminContent(self, **params):
    """
    Deliver admin content of module printers

    :param params: use given parameters of request
    :return: rendered template as string
    """
    module = request.view_args['module'].split('/')

    if len(module) == 2:
        if module[1] == 'settings':  # printer settings
            if request.method == 'POST':
                if request.form.get('action') == 'savereprintersparams':
                    classes.get('settings').set('printer.callstring', request.form.get('printers_callstring'))

            _p = dict()
            _p['callstring'] = classes.get('settings').get('printer.callstring')
            params.update({'params': _p})
            return render_template('admin.printers.settings.html', **params)
    else:

        def _printernames(callstring):
            printernames = ['<default>']
            if len(callstring.split()) > 0:
                callstring = '{} -printer "xxx"'.format(callstring.split()[0])
            try:
                subprocess.check_output(callstring, stderr=subprocess.STDOUT, shell=True)
            except subprocess.CalledProcessError as e:
                for l in e.output.split('\r\n'):
                    if l.startswith('  "'):
                        printernames.append(l[3:-1].strip())
            return printernames

        #def _callstring():  # get callstring and replace variables
        #    callstring = classes.get('settings').get('printer.callstring')
        #    callstring = callstring.replace('[basepath]', current_app.config.get('PROJECT_ROOT'))
        #    return callstring

        def _templates():  # get all printer templates
            templates = {}
            for root, dirs, files in os.walk("{}/emonitor/modules/".format(current_app.config.get('PROJECT_ROOT'))):
                mod = root.replace("{}/emonitor/modules/".format(current_app.config.get('PROJECT_ROOT')), '').replace('\\templates', '')
                for f in files:
                    if f.endswith('.html') and f.startswith('print.'):
{'fraction_non_alphanumeric': 0.1339481774264383, 'fraction_numerical': 0.002635046113306983, 'mean_word_length': 2.463878326996198, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '7237813', 'n_tokens_mistral': 1273, 'n_tokens_neox': 1228, 'n_words': 269}