<commit_before>__author__ = 'rixx'

import logging
import time
from sqlalchemy import Column, Integer, String
from sqlalchemy.orm import relationship
from .base import Base
from .tag import Tag
from .entry import Entry


class Project(Base):
    __tablename__ = "projects"
    logger = logging.getLogger(__name__)
    id = Column(Integer, primary_key=True)
    name = Column(String(30), unique=True)

    tags = relationship("Tag", secondary=Base.projects_tags, backref="projects")
    entries = relationship("Entry", back_populates="project")

    def __init__(self, name):
        self.name = name

    def insert(self, session):
        try:
            session.add(self)
            session.commit()
        except:
            print("Sorry, the new project could not be added … are you sure it doesn't exist already?")

    def init_tags(self, session):
        tag_list = Tag.get_list(session)

        if tag_list:
            print("The following tags exist: " + tag_list)
        else:
            print("No tags exist")

        user_tag_list = input("Please enter the tags for this project separated by commas: ").split(',')

        for tag in user_tag_list:
            if len(tag) > 0:
                new_tag = Tag.get_by_name(tag, session)

                if new_tag:
                    self.tags.append(new_tag)
                else:
                    print("Tag " + tag + " not found, skipping.")


    def status(self, session):
        pass

    def start(self):
        entry = Entry(int(time.time()))
        self.entries.append(entry)

    def stop(self):
        entry = self.entries[-1]

        if not entry.end:
            entry.end = int(time.time())
        else:
            print("Project wasn't running!")

    @staticmethod
    def get_latest(session):
        try:
            latest_project = session.query(Project).join(Entry).order_by(Entry.start.desc()).first()
            return latest_project
        except:
            return None

    @staticmethod
    def get_list(session):
        query = session.query(Project.name).all()
        return_string = ''

        for project in query:
            return_string += project.name + " "

        return return_string

    @staticmethod
    def get_by_name(name, session):
        try:
            project = session.query(Project).filter(Project.name == name).one()
            return project
        except:
            None<commit_msg>removed PAUSE project from listing output<commit_after>__author__ = 'rixx'

import logging
import time
from sqlalchemy import Column, Integer, String
from sqlalchemy.orm import relationship
from .base import Base
from .tag import Tag
from .entry import Entry


class Project(Base):
    __tablename__ = "projects"
    logger = logging.getLogger(__name__)
    id = Column(Integer, primary_key=True)
    name = Column(String(30), unique=True)

    tags = relationship("Tag", secondary=Base.projects_tags, backref="projects")
    entries = relationship("Entry", back_populates="project")

    def __init__(self, name):
        self.name = name

    def insert(self, session):
        try:
            session.add(self)
            session.commit()
        except:
            print("Sorry, the new project could not be added … are you sure it doesn't exist already?")

    def init_tags(self, session):
        tag_list = Tag.get_list(session)

        if tag_list:
            print("The following tags exist: " + tag_list)
        else:
            print("No tags exist")

        user_tag_list = input("Please enter the tags for this project separated by commas: ").split(',')

        for tag in user_tag_list:
            if len(tag) > 0:
                new_tag = Tag.get_by_name(tag, session)

                if new_tag:
                    self.tags.append(new_tag)
                else:
                    print("Tag " + tag + " not found, skipping.")


    def status(self, session):
        pass

    def start(self):
        entry = Entry(int(time.time()))
        self.entries.append(entry)

    def stop(self):
        entry = self.entries[-1]

        if not entry.end:
            entry.end = int(time.time())
        else:
            print("Project wasn't running!")

    @staticmethod
    def get_latest(session):
        try:
            latest_project = session.query(Project).join(Entry).order_by(Entry.start.desc()).first()
            return latest_project
        except:
            return None

    @staticmethod
    def get_list(session):
        query = session.query(Project.name).all()
        return_string = ''

        for project in query:
            if project.name != "PAUSE":
                return_string += project.name + " "

        return return_string

    @staticmethod
    def get_by_name(name, session):
        try:
            project = session.query(Project).filter(Project.name == name).one()
            return project
        except:
            None
{'fraction_non_alphanumeric': 0.10137875101378752, 'fraction_numerical': 0.0016220600162206002, 'mean_word_length': 2.0889167188478397, 'pattern_counts': {'":': 1, '<': 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': '2529838', 'n_tokens_mistral': 1391, 'n_tokens_neox': 1328, 'n_words': 369}