<commit_before># Copyright (c) 2014 Canonical ltd
# All Rights Reserved.
#
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

import grp
import getpass
import pwd
import os


from oslo.config import cfg

from nova.openstack.common import log as logging
from nova import context as nova_context
from nova import objects
from nova import utils

LOG = logging.getLogger(__name__)


CONF = cfg.CONF


def write_lxc_usernet(instance, bridge, user=None, count=1):
    if user is None:
        user = getpass.getuser()
    utils.execute('lxc-usernet-manage', 'set', user, bridge, str(count),
                  run_as_root=True, check_exit_code=[0])

def parse_subfile(name, fname):
    line = None
    with open(fname, "r") as fp:
        for cline in fp:
            if cline.startswith(name + ":"):
                line = cline
                break
            if line is None:
                raise ValueError("%s not found in %s" % (name, fname))
            toks = line.split(":")
    return (toks[1], toks[2])

def get_container_config(instance):
    return os.path.join(CONF.lxd.lxd_root_dir, instance['uuid'], 'config')


def get_container_rootfs(instance):
    return os.path.join(CONF.lxd.lxd_root_dir,instance['uuid'], 'rootfs')<commit_msg>Fix formatting<commit_after># Copyright (c) 2014 Canonical ltd
# All Rights Reserved.
#
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

import grp
import getpass
import pwd
import os


from oslo.config import cfg
from nova.i18n import _

from nova.openstack.common import log as logging
from nova import context as nova_context
from nova import objects
from nova import utils

LOG = logging.getLogger(__name__)


CONF = cfg.CONF


def write_lxc_usernet(instance, bridge, user=None, count=1):
    if user is None:
        user = getpass.getuser()
    utils.execute('lxc-usernet-manage', 'set', user, bridge, str(count),
                  run_as_root=True, check_exit_code=[0])

def parse_subfile(name, fname):
    line = None
    with open(fname, "r") as fp:
        for cline in fp:
            if cline.startswith(name + ":"):
                line = cline
                break
        if line is None:
            raise ValueError("%s not found in %s" % (name, fname))
        toks = line.split(":")
    return (toks[1], toks[2])

def get_container_config(instance):
    return os.path.join(CONF.lxd.lxd_root_dir, instance['uuid'], 'config')


def get_container_rootfs(instance):
    return os.path.join(CONF.lxd.lxd_root_dir,instance['uuid'], 'rootfs')
{'fraction_non_alphanumeric': 0.09444601071327882, 'fraction_numerical': 0.007330138144911192, 'mean_word_length': 3.130384167636787, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5974534', 'n_tokens_mistral': 1085, 'n_tokens_neox': 1067, 'n_words': 379}