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

from lxml import etree
import sys
import os


def manipulate_xml(input_filename, output_filename, string_to_find,
                   target_value):
    """It gets a configuration (.xml in our case) file, defined by the
    input_filename parameter and changes its contents defied by the
    string_to_find parameter. The new values are defined in the target_value
    parameter. The result is saved in a new file defined by the output_file.

    :param input_filename: The configuration filepath we want to change.
    :param output_filename: The new configuration file, after changing the
    original one.
    :param string_to_find: The string we want to change in the configuration
    file.
    :param target_value: The new value to replace the string_to_find
    :type input_filename: str
    :type output_filename: str
    :type string_to_find: str
    :type target_value: str
    """

    doc = etree.parse(input_filename)
    #go inside snapshot
    for  elt in doc.getiterator():
        if string_to_find in elt.tag:
            elt.text = target_value
    outFile = open(output_filename, 'w')
    doc.write(outFile)

def change_stats_period_main():
    """Takes as command line argument the new interval of statistics period we
    want to set in the configuration file of the controller and writes it in
    this file.
    """

    string_to_find = 'min-request-net-monitor-interval'
    input_file = os.path.dirname(os.path.realpath(__file__)) + \
        '/distribution-karaf-0.3.0-SNAPSHOT/etc/opendaylight/karaf/30-statistics-manager.xml'
    manipulate_xml(input_file,input_file,string_to_find,
                   str(int(sys.argv[1])))

if __name__ == '__main__':
    change_stats_period_main()<commit_msg>Fix on manipulate_xml() for change_stats_period on beryllium<commit_after>#! /usr/bin/env python3.4

from lxml import etree
import sys
import os


def manipulate_xml(input_filename, output_filename,
                   string_to_find, target_value):
    """It gets a configuration (.xml in our case) file, defined by the
    input_filename parameter and changes its contents defied by the
    string_to_find parameter. The new values are defined in the target_value
    parameter. The result is saved in a new file defined by the output_file.

    :param input_filename: The configuration filepath we want to change.
    :param output_filename: The new configuration file, after changing the
    original one.
    :param string_to_find: The string we want to change in the configuration
    file.
    :param target_value: The new value to replace the string_to_find
    :type input_filename: str
    :type output_filename: str
    :type string_to_find: str
    :type target_value: str
    """

    doc = etree.parse(input_filename)
    #go inside snapshot
    for  elt in doc.getiterator():
        if string_to_find in elt.tag:
            elt.text = target_value
    outFile = open(output_filename, 'wb')
    doc.write(outFile)

def change_stats_period_main():
    """Takes as command line argument the new interval of statistics period we
    want to set in the configuration file of the controller and writes it in
    this file.
    """

    string_to_find = 'min-request-net-monitor-interval'
    input_file = os.path.dirname(os.path.realpath(__file__)) + \
        '/distribution-karaf-0.4.0-Beryllium-RC2/etc/opendaylight/karaf/30-statistics-manager.xml'
    manipulate_xml(input_file,input_file,string_to_find,
                   str(int(sys.argv[1])))

if __name__ == '__main__':
    change_stats_period_main()
{'fraction_non_alphanumeric': 0.07447698744769875, 'fraction_numerical': 0.004741980474198048, 'mean_word_length': 3.3414043583535107, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 11}, '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': '3830417', 'n_tokens_mistral': 1077, 'n_tokens_neox': 1054, 'n_words': 351}