<commit_before>from oebakery import die, err, warn, info, debug
from oelite import *
from oelite.dbutil import *
import oelite.recipe

import sys
import os
import copy
import operator

class OEliteRunQueue:


    def __init__(self, config, cookbook, rebuild=None, relax=None,
                 depth_first=True):
        self.cookbook = cookbook
        self.config = config
        # 1: --rebuild, 2: --rebuildall, 3: --reallyrebuildall
        self.rebuild = rebuild
        self.relax = relax
        self.depth_first = depth_first
        self._assume_provided = (self.config.get("ASSUME_PROVIDED")
                                or "").split()
        self.runable = []
        self.metahashable = []
        self.cookbook.db.execute("ATTACH ':memory:' AS runq")
        self.dbc = self.cookbook.db.cursor()
        self.init_db()
        return


    def init_db(self):
        self.dbc.execute(
            "CREATE TABLE IF NOT EXISTS runq.provider ( "
            "type		TEXT, "
            "item		TEXT, "
            "version		TEXT, "
            "package		INTEGER )")

        self.dbc.execute(
            "CREATE TABLE IF NOT EXISTS runq.task ( "
            "task		INTEGER, "
            "prime		INTEGER, "
            "build		INTEGER, "
            "relax		INTEGER, "
            "status		INTEGER, "
            "metahash		TEXT, "
            "mtime		REAL, "
            "tmphash		TEXT, "
            "buildhash		TEXT, "
            "UNIQUE (task) ON CONFLICT IGNORE )")

        self.dbc.execute(
            "CREATE TABLE IF NOT EXISTS runq.depend ( "
            "id			INTEGER PRIMARY KEY, "
            "task		INTEGER, " # references task.id
            "prime		INTEGER, " # boolean
            "parent_task	INTEGER, " # references task.id
            "deptype		TEXT, "
            "package		INTEGER DEFAULT -1, " # package
            "filename		TEXT, "
            "prebake		INTEGER, "
            "UNIQUE (task, parent_task, deptype, package) "
            "ON CONFLICT IGNORE )")

        self.dbc.execute(
            "CREATE TABLE IF NOT EXISTS runq.recdepend ( "
            "deptype            TEXT, "
            "package		INTEGER, "
            "parent_package	INTEGER )")

        return


    def assume_provided(self, item):
        return "%s:%s"%(item.type, item.name) in self._assume_provided


    def add_something(self, something, task_name):
        return (self.add_recipe(something, task_name) or<commit_msg>lib/oelite: Fix broken sqlite UNIQUE constraint<commit_after>from oebakery import die, err, warn, info, debug
from oelite import *
from oelite.dbutil import *
import oelite.recipe

import sys
import os
import copy
import operator

class OEliteRunQueue:


    def __init__(self, config, cookbook, rebuild=None, relax=None,
                 depth_first=True):
        self.cookbook = cookbook
        self.config = config
        # 1: --rebuild, 2: --rebuildall, 3: --reallyrebuildall
        self.rebuild = rebuild
        self.relax = relax
        self.depth_first = depth_first
        self._assume_provided = (self.config.get("ASSUME_PROVIDED")
                                or "").split()
        self.runable = []
        self.metahashable = []
        self.cookbook.db.execute("ATTACH ':memory:' AS runq")
        self.dbc = self.cookbook.db.cursor()
        self.init_db()
        return


    def init_db(self):
        self.dbc.execute(
            "CREATE TABLE IF NOT EXISTS runq.provider ( "
            "type		TEXT, "
            "item		TEXT, "
            "version		TEXT, "
            "package		INTEGER )")

        self.dbc.execute(
            "CREATE TABLE IF NOT EXISTS runq.task ( "
            "task		INTEGER, "
            "prime		INTEGER, "
            "build		INTEGER, "
            "relax		INTEGER, "
            "status		INTEGER, "
            "metahash		TEXT, "
            "mtime		REAL, "
            "tmphash		TEXT, "
            "buildhash		TEXT, "
            "UNIQUE (task) ON CONFLICT IGNORE )")

        self.dbc.execute(
            "CREATE TABLE IF NOT EXISTS runq.depend ( "
            "id			INTEGER PRIMARY KEY, "
            "task		INTEGER, " # references task.id
            "prime		INTEGER, " # boolean
            "parent_task	INTEGER, " # references task.id
            "deptype		TEXT DEFAULT '', "
            "package		INTEGER DEFAULT -1, " # package
            "filename		TEXT, "
            "prebake		INTEGER, "
            "UNIQUE (task, parent_task, deptype, package) "
            "ON CONFLICT IGNORE )")

        self.dbc.execute(
            "CREATE TABLE IF NOT EXISTS runq.recdepend ( "
            "deptype            TEXT, "
            "package		INTEGER, "
            "parent_package	INTEGER )")

        return


    def assume_provided(self, item):
        return "%s:%s"%(item.type, item.name) in self._assume_provided


    def add_something(self, something, task_name):
        return (self.add_recipe(something, task_name) or
{'fraction_non_alphanumeric': 0.09957498482088646, 'fraction_numerical': 0.0016191054442420564, 'mean_word_length': 1.6641509433962265, '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': '6229604', 'n_tokens_mistral': 1575, 'n_tokens_neox': 1511, 'n_words': 367}