<commit_before>#!/usr/bin/env python
# vim: ai ts=4 sts=4 et sw=4


import time
import pygsm

from rapidsms.message import Message
from rapidsms.connection import Connection
from rapidsms.backends import Backend
import backend

class Backend(Backend):
    _title = "pyGSM"
    
    
    def configure(self, *args, **kwargs):
        self.modem = None
        self.modem_args = args
        self.modem_kwargs = kwargs
    
    
    def send(self, message):
        self.modem.send_sms(
            str(message.connection.identity),
            message.text)
    
    
    def run(self):
        self.debug("GSM RUNNING: %s" % self._running)
        # check for new messages
        while self._running:
            msg = self.modem.next_message()
        
            if msg is not None:
                # we got an sms! create RapidSMS Connection and
                # Message objects, and hand it off to the router
                c = Connection(self, msg.sender)
                m = Message(c, msg.text)
                self.router.send(m)
                
            # poll for new messages
            # every two seconds
            time.sleep(2)
    
    
    def start(self):
        self.modem = pygsm.GsmModem(
            *self.modem_args,
            **self.modem_kwargs)

        if self.modem is not None:
            backend.Backend.start(self)

    def stop(self):
        if self.modem:
            self.modem.disconnect()
        backend.Backend.stop(self)

        <commit_msg>minor is not None comparison<commit_after>#!/usr/bin/env python
# vim: ai ts=4 sts=4 et sw=4


import time
import pygsm

from rapidsms.message import Message
from rapidsms.connection import Connection
from rapidsms.backends import Backend
import backend

class Backend(Backend):
    _title = "pyGSM"
    
    
    def configure(self, *args, **kwargs):
        self.modem = None
        self.modem_args = args
        self.modem_kwargs = kwargs
    
    
    def send(self, message):
        self.modem.send_sms(
            str(message.connection.identity),
            message.text)
    
    
    def run(self):
        self.debug("GSM RUNNING: %s" % self._running)
        # check for new messages
        while self._running:
            msg = self.modem.next_message()
        
            if msg is not None:
                # we got an sms! create RapidSMS Connection and
                # Message objects, and hand it off to the router
                c = Connection(self, msg.sender)
                m = Message(c, msg.text)
                self.router.send(m)
                
            # poll for new messages
            # every two seconds
            time.sleep(2)
    
    
    def start(self):
        self.modem = pygsm.GsmModem(
            *self.modem_args,
            **self.modem_kwargs)

        if self.modem is not None:
            backend.Backend.start(self)

    def stop(self):
        if self.modem is not None:
            self.modem.disconnect()
        backend.Backend.stop(self)

        
{'fraction_non_alphanumeric': 0.08413381914541239, 'fraction_numerical': 0.002649884067572044, 'mean_word_length': 1.626086956521739, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4911019', 'n_tokens_mistral': 905, 'n_tokens_neox': 889, 'n_words': 237}