<commit_before>from __future__ import print_function
import threading
import time 
import syncplay
import os
import re
from syncplay import utils

class ConsoleUI(threading.Thread):
    def __init__(self):
        self.promptMode = threading.Event()
        self.PromptResult = ""
        self.promptMode.set()
        self._syncplayClient = None
        threading.Thread.__init__(self, name="ConsoleUI")
        
    def addClient(self, client):
        self._syncplayClient = client
        
    def run(self):
        while True:
            data = raw_input()
            data = data.rstrip('\n\r')
            if(not self.promptMode.isSet()):
                self.PromptResult = data
                self.promptMode.set()
            elif(self._syncplayClient):
                self._executeCommand(data)
        
    def promptFor(self, prompt=">", message=""):
        if message <> "":
            print(message)
        self.promptMode.clear()
        print(prompt, end='')
        self.promptMode.wait()
        return self.PromptResult

    def showMessage(self, message, noTimestamp=False):
        if(os.name == "nt"):
            message = message.encode('ascii', 'replace') 
        if(noTimestamp):
            print(message)
        else:
            print(time.strftime("[%X] ", time.localtime()) + message)

    def showDebugMessage(self, message):
        print(message)
        
    def showErrorMessage(self, message):
        print("ERROR:\t" + message)            

    def _extractRegexSign(self, m):
        if(m.group(1)):
            if(m.group(1) == "-"):
                return -1
            else:
                return 1
        else:
            return None
        
    def _tryAdvancedCommands(self, data):
        o = re.match(r"^(?:o|offset)\ ([+-])?\ ?(\d+[:\.]?)+$", data)
        s = re.match(r"^(?:s|seek)?\ ?([+-])?\ ?(\d+[:\.]?)+$", data) #careful! s will match o as well
        if(o):
            sign = self._extractRegexSign(o)
            t = utils.parseTime(o.group(2))
            if(t is None):
                return
            if(sign):
                t = self._syncplayClient.getUserOffset() + sign * t 
            self._syncplayClient.setUserOffset(t)
            return True
        elif s:
            sign = self._extractRegexSign(s)
            t = utils.parseTime(s.group(2))
            if(t is None):<commit_msg>Update consoleUI.py - Fix offset pattern<commit_after>from __future__ import print_function
import threading
import time 
import syncplay
import os
import re
from syncplay import utils

class ConsoleUI(threading.Thread):
    def __init__(self):
        self.promptMode = threading.Event()
        self.PromptResult = ""
        self.promptMode.set()
        self._syncplayClient = None
        threading.Thread.__init__(self, name="ConsoleUI")
        
    def addClient(self, client):
        self._syncplayClient = client
        
    def run(self):
        while True:
            data = raw_input()
            data = data.rstrip('\n\r')
            if(not self.promptMode.isSet()):
                self.PromptResult = data
                self.promptMode.set()
            elif(self._syncplayClient):
                self._executeCommand(data)
        
    def promptFor(self, prompt=">", message=""):
        if message <> "":
            print(message)
        self.promptMode.clear()
        print(prompt, end='')
        self.promptMode.wait()
        return self.PromptResult

    def showMessage(self, message, noTimestamp=False):
        if(os.name == "nt"):
            message = message.encode('ascii', 'replace') 
        if(noTimestamp):
            print(message)
        else:
            print(time.strftime("[%X] ", time.localtime()) + message)

    def showDebugMessage(self, message):
        print(message)
        
    def showErrorMessage(self, message):
        print("ERROR:\t" + message)            

    def _extractRegexSign(self, m):
        if(m.group(1)):
            if(m.group(1) == "-"):
                return -1
            else:
                return 1
        else:
            return None
        
    def _tryAdvancedCommands(self, data):
        o = re.match(r"^(?:o|offset)\ ?(?P<sign>[+-])?(?P<time>\d+(?:[^\d\.](?:\d+)){0,2}(?:\.(?:\d+))?)$", data)
        s = re.match(r"^(?:s|seek)?\ ?([+-])?\ ?(\d+[:\.]?)+$", data) #careful! s will match o as well
        if(o):
            sign = self._extractRegexSign(o)
            t = utils.parseTime(o.group(2))
            if(t is None):
                return
            if(sign):
                t = self._syncplayClient.getUserOffset() + sign * t 
            self._syncplayClient.setUserOffset(t)
            return True
        elif s:
            sign = self._extractRegexSign(s)
            t = utils.parseTime(s.group(2))
            if(t is None):
{'fraction_non_alphanumeric': 0.1379738968303294, 'fraction_numerical': 0.00290035218562254, 'mean_word_length': 1.7731188971855256, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 9, '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': '5686090', 'n_tokens_mistral': 1447, 'n_tokens_neox': 1409, 'n_words': 291}