import os
import re
from . import Helper

class BLSItem:
	def __init__(self, blsName, srcDir):
		if srcDir:
			self.srcDir = srcDir
			self.name = os.path.splitext(blsName.lower())[0]
			self.blsFullName = os.path.join(srcDir, blsName)
		else:
			self.srcDir = Helper.getWorkingDirForFile(blsName) + '\\SOURCE'
			self.name = os.path.splitext(os.path.basename(blsName).lower())[0]
			self.blsFullName = blsName
		self.addedToCompile = False
		self.dependence = self.__getDependence__()		

	def __getDependence__(self):
		if (self.blsFullName == ''):
			print('BSScript: __getDependence__ no fullBLSFileName.')
			return None
		blsFile = open(self.blsFullName, "rb")
		data = blsFile.read().decode("cp1251", "ignore")
		blsFile.close()
		data = re.sub(r'{[\S\s]*?}', '', data, flags = re.IGNORECASE)
		data = re.sub(r'\(\*[\S\s]*?\*\)', '', data, flags = re.IGNORECASE)
		data = re.sub(r'//.*', '', data, flags = re.IGNORECASE)
		#expr = re.compile(r'[^\']\buses\b([\s\S][^;]*);', flags = re.IGNORECASE)
		expr = re.compile(r'^(?<![\'])\buses\b([\s\S][^;]*);', flags = re.IGNORECASE | re.MULTILINE)		
		matcher = expr.search(data)
		strUses = ''
		while matcher:
			strUses = strUses + matcher.group(1) + ','
			strUses = re.sub(r'\s', '', strUses, flags = re.IGNORECASE)
			matcher = expr.search(data, matcher.end(1))
		if (strUses != ''):
			return strUses[:-1].split(',')
		else:
			return None
65a000541bcb0464374fc5e32416e3cc630c8c02
<mask token>


class BLSItem:
    <mask token>
    <mask token>

<mask token>


class BLSItem:
    <mask token>

    def __getDependence__(self):
        if self.blsFullName == '':
            print('BSScript: __getDependence__ no fullBLSFileName.')
            return None
        blsFile = open(self.blsFullName, 'rb')
        data = blsFile.read().decode('cp1251', 'ignore')
        blsFile.close()
        data = re.sub('{[\\S\\s]*?}', '', data, flags=re.IGNORECASE)
        data = re.sub('\\(\\*[\\S\\s]*?\\*\\)', '', data, flags=re.IGNORECASE)
        data = re.sub('//.*', '', data, flags=re.IGNORECASE)
        expr = re.compile("^(?<![\\'])\\buses\\b([\\s\\S][^;]*);", flags=re
            .IGNORECASE | re.MULTILINE)
        matcher = expr.search(data)
        strUses = ''
        while matcher:
            strUses = strUses + matcher.group(1) + ','
            strUses = re.sub('\\s', '', strUses, flags=re.IGNORECASE)
            matcher = expr.search(data, matcher.end(1))
        if strUses != '':
            return strUses[:-1].split(',')
        else:
            return None

<mask token>


class BLSItem:

    def __init__(self, blsName, srcDir):
        if srcDir:
            self.srcDir = srcDir
            self.name = os.path.splitext(blsName.lower())[0]
            self.blsFullName = os.path.join(srcDir, blsName)
        else:
            self.srcDir = Helper.getWorkingDirForFile(blsName) + '\\SOURCE'
            self.name = os.path.splitext(os.path.basename(blsName).lower())[0]
            self.blsFullName = blsName
        self.addedToCompile = False
        self.dependence = self.__getDependence__()

    def __getDependence__(self):
        if self.blsFullName == '':
            print('BSScript: __getDependence__ no fullBLSFileName.')
            return None
        blsFile = open(self.blsFullName, 'rb')
        data = blsFile.read().decode('cp1251', 'ignore')
        blsFile.close()
        data = re.sub('{[\\S\\s]*?}', '', data, flags=re.IGNORECASE)
        data = re.sub('\\(\\*[\\S\\s]*?\\*\\)', '', data, flags=re.IGNORECASE)
        data = re.sub('//.*', '', data, flags=re.IGNORECASE)
        expr = re.compile("^(?<![\\'])\\buses\\b([\\s\\S][^;]*);", flags=re
            .IGNORECASE | re.MULTILINE)
        matcher = expr.search(data)
        strUses = ''
        while matcher:
            strUses = strUses + matcher.group(1) + ','
            strUses = re.sub('\\s', '', strUses, flags=re.IGNORECASE)
            matcher = expr.search(data, matcher.end(1))
        if strUses != '':
            return strUses[:-1].split(',')
        else:
            return None

import os
import re
from . import Helper


class BLSItem:

    def __init__(self, blsName, srcDir):
        if srcDir:
            self.srcDir = srcDir
            self.name = os.path.splitext(blsName.lower())[0]
            self.blsFullName = os.path.join(srcDir, blsName)
        else:
            self.srcDir = Helper.getWorkingDirForFile(blsName) + '\\SOURCE'
            self.name = os.path.splitext(os.path.basename(blsName).lower())[0]
            self.blsFullName = blsName
        self.addedToCompile = False
        self.dependence = self.__getDependence__()

    def __getDependence__(self):
        if self.blsFullName == '':
            print('BSScript: __getDependence__ no fullBLSFileName.')
            return None
        blsFile = open(self.blsFullName, 'rb')
        data = blsFile.read().decode('cp1251', 'ignore')
        blsFile.close()
        data = re.sub('{[\\S\\s]*?}', '', data, flags=re.IGNORECASE)
        data = re.sub('\\(\\*[\\S\\s]*?\\*\\)', '', data, flags=re.IGNORECASE)
        data = re.sub('//.*', '', data, flags=re.IGNORECASE)
        expr = re.compile("^(?<![\\'])\\buses\\b([\\s\\S][^;]*);", flags=re
            .IGNORECASE | re.MULTILINE)
        matcher = expr.search(data)
        strUses = ''
        while matcher:
            strUses = strUses + matcher.group(1) + ','
            strUses = re.sub('\\s', '', strUses, flags=re.IGNORECASE)
            matcher = expr.search(data, matcher.end(1))
        if strUses != '':
            return strUses[:-1].split(',')
        else:
            return None

import os
import re
from . import Helper

class BLSItem:
	def __init__(self, blsName, srcDir):
		if srcDir:
			self.srcDir = srcDir
			self.name = os.path.splitext(blsName.lower())[0]
			self.blsFullName = os.path.join(srcDir, blsName)
		else:
			self.srcDir = Helper.getWorkingDirForFile(blsName) + '\\SOURCE'
			self.name = os.path.splitext(os.path.basename(blsName).lower())[0]
			self.blsFullName = blsName
		self.addedToCompile = False
		self.dependence = self.__getDependence__()		

	def __getDependence__(self):
		if (self.blsFullName == ''):
			print('BSScript: __getDependence__ no fullBLSFileName.')
			return None
		blsFile = open(self.blsFullName, "rb")
		data = blsFile.read().decode("cp1251", "ignore")
		blsFile.close()
		data = re.sub(r'{[\S\s]*?}', '', data, flags = re.IGNORECASE)
		data = re.sub(r'\(\*[\S\s]*?\*\)', '', data, flags = re.IGNORECASE)
		data = re.sub(r'//.*', '', data, flags = re.IGNORECASE)
		#expr = re.compile(r'[^\']\buses\b([\s\S][^;]*);', flags = re.IGNORECASE)
		expr = re.compile(r'^(?<![\'])\buses\b([\s\S][^;]*);', flags = re.IGNORECASE | re.MULTILINE)		
		matcher = expr.search(data)
		strUses = ''
		while matcher:
			strUses = strUses + matcher.group(1) + ','
			strUses = re.sub(r'\s', '', strUses, flags = re.IGNORECASE)
			matcher = expr.search(data, matcher.end(1))
		if (strUses != ''):
			return strUses[:-1].split(',')
		else:
			return None