<commit_before># -*- coding: utf-8 -*-
# http://google-styleguide.googlecode.com/svn/trunk/pyguide.html

from datetime import datetime
from sqlalchemy.dialects import mysql
from sqlalchemy.sql.expression import text
from sqlalchemy.ext.declarative import AbstractConcreteBase
from smsgw.extensions import db
from smsgw.lib.utils import generate_uuid
from smsgw.models import BaseModel, DateMixin


class Phone(BaseModel):
    """ Phone model """

    id = db.Column(mysql.INTEGER(10, unsigned=True), primary_key=True)
    uuid = db.Column(mysql.CHAR(36), unique=True, nullable=False,
                     default=generate_uuid)
    hostname = db.Column(db.String(64))
    imei = db.Column(db.String(35), nullable=False)
    netCode = db.Column(db.String(10))
    netName = db.Column(db.String(35))
    battery = db.Column(mysql.INTEGER)
    signal = db.Column(mysql.INTEGER)
    client = db.Column(mysql.TEXT)

    sent = db.Column(mysql.INTEGER, nullable=False, server_default='0')
    received = db.Column(mysql.INTEGER, nullable=False, server_default='0')
    send = db.Column(db.Enum("yes", "no"), default='no', nullable=False)
    receive = db.Column(db.Enum("yes", "no"), default='no', nullable=False)
    timeout = db.Column(db.TIMESTAMP)

    created = db.Column(
        db.TIMESTAMP, default=datetime.utcnow,
        server_default=text('CURRENT_TIMESTAMP')
    )
    updated = db.Column(
        db.TIMESTAMP, default=datetime.utcnow,
        onupdate=datetime.utcnow
    )


    def to_dict(self, properties=None):
        """
        To dictionary
        :param properties: {list} of required properties
        :return: {dict}
        """
        dict = {
            'id': self.id,
            'hostname': self.hostname,
            'imei': self.imei,
            'netCode': self.netCode,
            'netName': self.netName,
            'battery': self.battery,
            'signal': self.signal,
            'client': self.client,
            'sent': self.sent,
            'received': self.received,
            'sendEnabled': True if self.send == 'yes' else False,
            'receiveEnabled': True if self.receive == 'yes' else False,
            'lastActivity': self.timeout.isoformat(sep=' ') if self.timeout \
                                                            else None,
            'created': self.created.isoformat(sep=' ') if self.created \
                                                       else None,
            'updated': self.updated.isoformat(sep=' ') if self.updated \
                                                       else None<commit_msg>PhoneModel: added uuid as part of output of to_dict method<commit_after># -*- coding: utf-8 -*-
# http://google-styleguide.googlecode.com/svn/trunk/pyguide.html

from datetime import datetime
from sqlalchemy.dialects import mysql
from sqlalchemy.sql.expression import text
from sqlalchemy.ext.declarative import AbstractConcreteBase
from smsgw.extensions import db
from smsgw.lib.utils import generate_uuid
from smsgw.models import BaseModel, DateMixin


class Phone(BaseModel):
    """ Phone model """

    id = db.Column(mysql.INTEGER(10, unsigned=True), primary_key=True)
    uuid = db.Column(mysql.CHAR(36), unique=True, nullable=False,
                     default=generate_uuid)
    hostname = db.Column(db.String(64))
    imei = db.Column(db.String(35), nullable=False)
    netCode = db.Column(db.String(10))
    netName = db.Column(db.String(35))
    battery = db.Column(mysql.INTEGER)
    signal = db.Column(mysql.INTEGER)
    client = db.Column(mysql.TEXT)

    sent = db.Column(mysql.INTEGER, nullable=False, server_default='0')
    received = db.Column(mysql.INTEGER, nullable=False, server_default='0')
    send = db.Column(db.Enum("yes", "no"), default='no', nullable=False)
    receive = db.Column(db.Enum("yes", "no"), default='no', nullable=False)
    timeout = db.Column(db.TIMESTAMP)

    created = db.Column(
        db.TIMESTAMP, default=datetime.utcnow,
        server_default=text('CURRENT_TIMESTAMP')
    )
    updated = db.Column(
        db.TIMESTAMP, default=datetime.utcnow,
        onupdate=datetime.utcnow
    )


    def to_dict(self, properties=None):
        """
        To dictionary
        :param properties: {list} of required properties
        :return: {dict}
        """
        dict = {
            'id': self.id,
            'uuid': self.uuid,
            'hostname': self.hostname,
            'imei': self.imei,
            'netCode': self.netCode,
            'netName': self.netName,
            'battery': self.battery,
            'signal': self.signal,
            'client': self.client,
            'sent': self.sent,
            'received': self.received,
            'sendEnabled': True if self.send == 'yes' else False,
            'receiveEnabled': True if self.receive == 'yes' else False,
            'lastActivity': self.timeout.isoformat(sep=' ') if self.timeout \
                                                            else None,
            'created': self.created.isoformat(sep=' ') if self.created \
                                                       else None,
            'updated': self.updated.isoformat(sep=' ') if self.updated \
                                                       else None
{'fraction_non_alphanumeric': 0.125, 'fraction_numerical': 0.0056990881458966565, 'mean_word_length': 2.192844147968466, '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': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6305522', 'n_tokens_mistral': 1547, 'n_tokens_neox': 1513, 'n_words': 324}