<commit_before>#!/usr/bin/python
############################################################
# <bsn.cl fy=2013 v=onl>
# 
#        Copyright 2013, 2014 Big Switch Networks, Inc.       
# 
# Licensed under the Eclipse Public License, Version 1.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.eclipse.org/legal/epl-v10.html
# 
# 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.
# 
# </bsn.cl>
############################################################
#
# Open Network Linux Build Package Manager
#
############################################################
import sys
import os
import argparse
import shutil
import re
from debian import deb822
import logging
import subprocess
import fcntl


#
# Hack
# Disabled and/or deprecated packages
#
disabled_packages = [
];

def package_enabled(p):
    for dp in disabled_packages:
        if dp in p:
            return False
    return True

def find_file_or_dir(basedir, filename=None, dirname=None):
    """Find and return the path to a given file or directory below the given root"""
    for root, dirs, files in os.walk(basedir):
        for file_ in files:
            if file_ == filename:
                print "%s/%s" % (root, file_)
                sys.exit(0)
        if dirname and os.path.basename(root) == dirname and root != basedir:
            print "%s" % (root)
            sys.exit(0)

def find_component_dir(basedir, package_name):
    """Find the local component directory that builds the given package."""
    for root, dirs, files in os.walk(basedir):
        for file_ in files:
            if file_ == "Makefile" or file_ == "makefile":
                with open("%s/%s" % (root,file_), "r") as f:
                    data = f.read()
                    if "Package:%s" % package_name in data:
                        # By convention - this is the component directory.
                        return os.path.abspath(root)
            if file_ == "control":
                with open("%s/%s" % (root,file_), "r") as f:
                    control = f.read()
                    if "Package: %s " % package_name in control or "Package: %s\n" % package_name in control:
                        # By convention - find the parent directory
                        # That has a 'debian' directory in it.
                        logger.info("found at %s", root)
                        while not 'Makefile.comp' in os.listdir(root):<commit_msg>Fixed pkg depency bug in onlpkg<commit_after>#!/usr/bin/python
############################################################
# <bsn.cl fy=2013 v=onl>
# 
#        Copyright 2013, 2014 Big Switch Networks, Inc.       
# 
# Licensed under the Eclipse Public License, Version 1.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.eclipse.org/legal/epl-v10.html
# 
# 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.
# 
# </bsn.cl>
############################################################
#
# Open Network Linux Build Package Manager
#
############################################################
import sys
import os
import argparse
import shutil
import re
from debian import deb822
import logging
import subprocess
import fcntl


#
# Hack
# Disabled and/or deprecated packages
#
disabled_packages = [
];

def package_enabled(p):
    for dp in disabled_packages:
        if dp in p:
            return False
    return True

def find_file_or_dir(basedir, filename=None, dirname=None):
    """Find and return the path to a given file or directory below the given root"""
    for root, dirs, files in os.walk(basedir):
        for file_ in files:
            if file_ == filename:
                print "%s/%s" % (root, file_)
                sys.exit(0)
        if dirname and os.path.basename(root) == dirname and root != basedir:
            print "%s" % (root)
            sys.exit(0)

def find_component_dir(basedir, package_name):
    """Find the local component directory that builds the given package."""
    for root, dirs, files in os.walk(basedir):
        for file_ in files:
            if file_ == "Makefile" or file_ == "makefile":
                with open("%s/%s" % (root,file_), "r") as f:
                    data = f.read()
                    packages = re.findall("Package:(.*)", data)
                    if package_name in packages:
                        # By convention - this is the component directory.
                        return os.path.abspath(root)
            if file_ == "control":
                with open("%s/%s" % (root,file_), "r") as f:
                    control = f.read()
                    if "Package: %s " % package_name in control or "Package: %s\n" % package_name in control:
                        # By convention - find the parent directory
                        # That has a 'debian' directory in it.
                        logger.info("found at %s", root)
                        while not 'Makefile.comp' in os.listdir(root):
{'fraction_non_alphanumeric': 0.15295789660685735, 'fraction_numerical': 0.0074613608100906025, 'mean_word_length': 2.3632019115890084, 'pattern_counts': {'":': 4, '<': 7, '<?xml version=': 0, '>': 7, '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': '6765739', 'n_tokens_mistral': 1550, 'n_tokens_neox': 1468, 'n_words': 570}