<commit_before># No shebang line, this module is meant to be imported
#
# This file is part of PyFarm.
# Copyright (C) 2008-2012 <NAME>
#
# PyFarm is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# PyFarm is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with PyFarm.  If not, see <http://www.gnu.org/licenses/>.

import socket
from sqlalchemy import Column
from sqlalchemy.orm import validates
from sqlalchemy.types import String, Boolean, Integer

from pyfarm.net import openport
from pyfarm.logger import Logger
from pyfarm.db.tables import MAX_HOSTNAME_LENGTH, MAX_IPV4_LENGTH, \
    MIN_PORT, MAX_PORT

logger = Logger(__name__)

class NetworkHost(object):
    '''mixin which defines common attributes that all network hosts have'''
    hostname = Column(String(MAX_HOSTNAME_LENGTH), nullable=False, unique=True)
    ip = Column(String(MAX_IPV4_LENGTH), nullable=False, unique=True)
    subnet = Column(String(MAX_IPV4_LENGTH), nullable=False)
    port = Column(Integer, nullable=False)
    enabled = Column(Boolean, default=True)

    def __init__(self, hostname, ip, subnet, port, enabled=False):
        self.hostname = hostname
        self.ip = ip
        self.subnet = subnet

        # autoselect if an integer was not provided for the port
        if not isinstance(port, int):
            port = openport()
            logger.debug("port not provided, using %s" % port)<commit_msg>better description<commit_after># No shebang line, this module is meant to be imported
#
# This file is part of PyFarm.
# Copyright (C) 2008-2012 <NAME>
#
# PyFarm is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# PyFarm is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with PyFarm.  If not, see <http://www.gnu.org/licenses/>.

import socket
from sqlalchemy import Column
from sqlalchemy.orm import validates
from sqlalchemy.types import String, Boolean, Integer

from pyfarm.net import openport
from pyfarm.logger import Logger
from pyfarm.db.tables import MAX_HOSTNAME_LENGTH, MAX_IPV4_LENGTH, \
    MIN_PORT, MAX_PORT

logger = Logger(__name__)

class NetworkHost(object):
    '''mixin which defines common attributes that all network nodes have'''
    hostname = Column(String(MAX_HOSTNAME_LENGTH), nullable=False, unique=True)
    ip = Column(String(MAX_IPV4_LENGTH), nullable=False, unique=True)
    subnet = Column(String(MAX_IPV4_LENGTH), nullable=False)
    port = Column(Integer, nullable=False)
    enabled = Column(Boolean, default=True)

    def __init__(self, hostname, ip, subnet, port, enabled=False):
        self.hostname = hostname
        self.ip = ip
        self.subnet = subnet

        # autoselect if an integer was not provided for the port
        if not isinstance(port, int):
            port = openport()
            logger.debug("port not provided, using %s" % port)
{'fraction_non_alphanumeric': 0.07528905619790266, 'fraction_numerical': 0.006453347674105943, 'mean_word_length': 3.96, 'pattern_counts': {'":': 0, '<': 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': '1353787', 'n_tokens_mistral': 1063, 'n_tokens_neox': 1028, 'n_words': 434}