<commit_before>#!/usr/bin/env python
# gets/set system configuration variables on NETIO4
# run as python system.py <address> <username> <password> get <variable> [<variable> ...]
#     or python system.py <address> <username> <password> set <variable>=<value> [<variable>=<value> ...]
from __future__ import print_function

from xml.etree import ElementTree
from xml.sax.saxutils import escape
import httplib, sys

class BaseRequest(object):
    inner = None # inner XML
    def wrapped(self, sessionId=None):
        attrs = ' sessionID="%s"' % sessionId if sessionId != None else ''
        return '<request%s>%s</request>' % (attrs, self.inner)

class RequestError(Exception):
    pass

class Login(BaseRequest):
    def __init__(self, username, password):
        self.inner = ('<session action="login"><credentials><username>%s</username>' \
            + '<password>%s</password></credentials></session>') % (username, password)

class Logout(BaseRequest):
    inner = '<session action="logout"/>'

class GetVariables(BaseRequest):
    def __init__(self, variables):
        """ get values of variables given in the list """
        self.inner = '<system action="get">%s</device>' % ''.join(['<%s/>' % v for v in variables])
    
class SetVariables(BaseRequest):
    def __init__(self, newValues):
        """ set values of variables given in the list """
        self.inner = '<system action="set">%s</device>' % ''.join(['<%s>%s</%s>' % (k, escape(v), k) for k, v in newValues.items()])
<commit_msg>fix XML tags<commit_after>#!/usr/bin/env python
# gets/set system configuration variables on NETIO4
# run as python system.py <address> <username> <password> get <variable> [<variable> ...]
#     or python system.py <address> <username> <password> set <variable>=<value> [<variable>=<value> ...]
from __future__ import print_function

from xml.etree import ElementTree
from xml.sax.saxutils import escape
import httplib, sys

class BaseRequest(object):
    inner = None # inner XML
    def wrapped(self, sessionId=None):
        attrs = ' sessionID="%s"' % sessionId if sessionId != None else ''
        return '<request%s>%s</request>' % (attrs, self.inner)

class RequestError(Exception):
    pass

class Login(BaseRequest):
    def __init__(self, username, password):
        self.inner = ('<session action="login"><credentials><username>%s</username>' \
            + '<password>%s</password></credentials></session>') % (username, password)

class Logout(BaseRequest):
    inner = '<session action="logout"/>'

class GetVariables(BaseRequest):
    def __init__(self, variables):
        """ get values of variables given in the list """
        self.inner = '<system action="get">%s</system>' % ''.join(['<%s/>' % v for v in variables])
    
class SetVariables(BaseRequest):
    def __init__(self, newValues):
        """ set values of variables given in the list """
        self.inner = '<system action="set">%s</system>' % ''.join(['<%s>%s</%s>' % (k, escape(v), k) for k, v in newValues.items()])

{'fraction_non_alphanumeric': 0.16461998008629272, 'fraction_numerical': 0.0006637902422834385, 'mean_word_length': 3.981818181818182, 'pattern_counts': {'":': 0, '<': 63, '<?xml version=': 0, '>': 63, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '4591697', 'n_tokens_mistral': 893, 'n_tokens_neox': 888, 'n_words': 260}