<commit_before>import logging
from functools import partial

import tornado.process
from tornado.ioloop import IOLoop

import os.path as _path

logger = logging.getLogger(__name__)
_self_path = _path.dirname(_path.abspath(__file__))
_cmd_prefix=['/bin/bash', _path.join(_self_path, 'vcs.sh')]

PROT_VER = 1

def _parse_oldver(oldver):
    if oldver is None:
        return (PROT_VER, 0, '')
    try:
        prot_ver, count, ver = oldver.split('.', maxsplit=2)
        prot_ver = int(prot_ver)
        count = int(count)
    except:
        return (PROT_VER, 0, '')
    if prot_ver != PROT_VER:
        return (PROT_VER, 0, ver)
    return (PROT_VER, count, ver)

def get_version(name, conf, callback):
  vcs = conf['vcs']
  oldver = conf['oldver']
  cmd = _cmd_prefix + [name, vcs]
  p = tornado.process.Subprocess(cmd, io_loop=IOLoop.instance(),
                                 stdout=tornado.process.Subprocess.STREAM)
  p.set_exit_callback(partial(_command_done, name, oldver, callback, p))

def _command_done(name, oldver, callback, process, status):
  if status != 0:
    logger.error('%s: command exited with %d.', name, status)<commit_msg>fix coding style for vcs.py<commit_after>import logging
from functools import partial

import tornado.process
from tornado.ioloop import IOLoop

import os.path as _path

logger = logging.getLogger(__name__)
_self_path = _path.dirname(_path.abspath(__file__))
_cmd_prefix = ['/bin/bash', _path.join(_self_path, 'vcs.sh')]

PROT_VER = 1

def _parse_oldver(oldver):
    if oldver is None:
        return PROT_VER, 0, ''
    try:
        prot_ver, count, ver = oldver.split('.', maxsplit=2)
        prot_ver = int(prot_ver)
        count = int(count)
    except:
        return PROT_VER, 0, ''
    if prot_ver != PROT_VER:
        return PROT_VER, 0, ver
    return PROT_VER, count, ver

def get_version(name, conf, callback):
  vcs = conf['vcs']
  oldver = conf['oldver']
  cmd = _cmd_prefix + [name, vcs]
  p = tornado.process.Subprocess(cmd, io_loop=IOLoop.instance(),
                                 stdout=tornado.process.Subprocess.STREAM)
  p.set_exit_callback(partial(_command_done, name, oldver, callback, p))

def _command_done(name, oldver, callback, process, status):
  if status != 0:
    logger.error('%s: command exited with %d.', name, status)
{'fraction_non_alphanumeric': 0.12196180555555555, 'fraction_numerical': 0.005208333333333333, 'mean_word_length': 3.4498069498069497, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4857220', 'n_tokens_mistral': 820, 'n_tokens_neox': 788, 'n_words': 196}