<commit_before>#!/usr/bin/env python
import codecs
import logging
import os
import sys
from decimal import *

import synctools

__all__ = ['adjustoffset']

def adjustoffset(simfile):
    log = logging.getLogger('synctools')
    cfg = synctools.get_config()
    synctools.backup(simfile)
    with codecs.open(simfile.filename, 'w', 'utf-8') as output:
        for param in simfile.params:
            if param[0].upper() == 'OFFSET':
                # Process offset
                offset = Decimal(param[1])
                offset2 = offset + Decimal(cfg['adjustoffset']['amount'])
                log.info('%s -> %s' % (str(offset), str(offset2)))
                # Rewrite parameter
                param[1] = str(offset2)
            output.write(unicode(param) + '\n')


if __name__ == '__main__':
    os.chdir(os.path.dirname(os.path.abspath(sys.argv[0])))
    synctools.main_iterator(adjustoffset, sys.argv[1:])<commit_msg>Reworked adjustoffset to use new Simfile methods<commit_after>#!/usr/bin/env python
import codecs
import logging
import os
import sys
from decimal import *

import synctools

__all__ = ['adjustoffset']

def adjustoffset(simfile):
    log = logging.getLogger('synctools')
    cfg = synctools.get_config()
    synctools.backup(simfile)
    offset_param = simfile.get('OFFSET')
    # Process offset
    offset = Decimal(offset_param[1])
    offset2 = offset + Decimal(cfg['adjustoffset']['amount'])
    log.info('%s -> %s' % (str(offset), str(offset2)))
    # Rewrite parameter
    offset_param[1] = str(offset2)
    simfile.save()


if __name__ == '__main__':
    os.chdir(os.path.dirname(os.path.abspath(sys.argv[0])))
    synctools.main_iterator(adjustoffset, sys.argv[1:])
{'fraction_non_alphanumeric': 0.13975337639459776, 'fraction_numerical': 0.009395184967704051, 'mean_word_length': 3.292191435768262, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1404324', 'n_tokens_mistral': 568, 'n_tokens_neox': 553, 'n_words': 113}