示例#1
0
def get_ssr_conf(ssr_conf_path: str) -> Dict:
    _ssr_conf: Dict = utils.parse_json(ssr_conf_path)

    if not _ssr_conf:
        exit.error('Require ssr-config.')

    # -- check params --
    port = _ssr_conf.get('server_port')
    if port is None:
        exit.error('Require \'server_port\'.')
    if type(port) != int or port <= 0:
        exit.error('Illegal \'server_port\'.')

    password = _ssr_conf.get('password')
    if common.is_blank(password):
        exit.error('Require \'password\'.')

    method = _ssr_conf.get('method')
    if common.is_blank(method):
        exit.error('Require \'method\'.')
    if not encrypt.is_supported(method):
        exit.error(f'Not supported method [{method}]')

    protocol = _ssr_conf.get('protocol')
    if common.is_blank(protocol):
        exit.error('Require \'protocol\'.')

    obfs = _ssr_conf.get('obfs')
    if common.is_blank(obfs):
        exit.error('Require \'obfs\'.')

    # -- default params --
    _ssr_conf['server'] = '::'
    _ssr_conf['password'] = common.to_bytes(_ssr_conf['password'])
    _ssr_conf['protocol_param'] = _ssr_conf.get('protocol_param', '')
    _ssr_conf['obfs_param'] = _ssr_conf.get('obfs_param', '')

    # process default data
    try:
        _ssr_conf['forbidden_ip'] = \
            common.IPNetwork(_ssr_conf.get('forbidden_ip', '127.0.0.0/8,::1/128'))
    except Exception as e:
        exit.error('error configuration \'forbidden_ip\'.')
    try:
        _ssr_conf['forbidden_port'] = common.PortRange(
            _ssr_conf.get('forbidden_port', ''))
    except Exception as e:
        exit.error('error configuration \'forbidden_port\'.')
    try:
        _ssr_conf['ignore_bind'] = \
            common.IPNetwork(_ssr_conf.get('ignore_bind', '127.0.0.0/8,::1/128,10.0.0.0/8,192.168.0.0/16'))
    except Exception as e:
        exit.error('error configuration \'ignore_bind\'.')

    return _ssr_conf
def load_workbook(wb):
    global sheet_dict, company_type
    sheet = wb.sheet_by_index(SHEET_NUMBER)
    nrows = sheet.nrows
    for i in range(STARTING_ROW, nrows):
        if company_type != "" and (not common.is_blank(sheet.cell(
                i, 0))) and (not is_bold(sheet.cell(i, 1)) and
                             (not common.is_blank(sheet.cell(i, 1)))):
            for k in fields_dictionary.keys():
                sheet_dict[fields_dictionary[k]].append(
                    sheet.cell(i,
                               int(k) - 1).value)
            sheet_dict['company_type'].append(company_type)
        elif is_bold(sheet.cell(
                i, 1)) or ("господарські" in sheet.cell(i, 1).value
                           and "товариства" in sheet.cell(i, 1).value) or (
                               "державн" in sheet.cell(i, 1).value
                               and "підприємств" in sheet.cell(i, 1).value):
            company_type = common.refine_company_type(sheet.cell(i, 1).value)
def load_workbook(wb):
    global sheet_dict, company_type
    sheet = wb.sheet_by_index(SHEET_NUMBER)
    nrows = sheet.nrows
    for i in range(STARTING_ROW, nrows):
        if (not is_bold(sheet.cell(i, 1)) and (not common.is_blank(sheet.cell(i, 1)))) and (not common.is_blank(sheet.cell(i,0))):
            for k in fields_dictionary.keys():
                sheet_dict[fields_dictionary[k]].append(sheet.cell(i, int(k) - 1).value)
            sheet_dict['final_assessment'].append(final_mark([sheet.cell(i,30).value, sheet.cell(i,31).value, sheet.cell(i,32).value]))
            sheet_dict['company_type'].append(company_type)
        elif is_bold(sheet.cell(i, 1)) or ("господарські" in sheet.cell(i,1).value and  "товариства" in sheet.cell(i,1).value):
            company_type = common.refine_company_type(sheet.cell(i, 1).value)
示例#4
0
def is_company_type(cell):
    if common.is_blank(cell):
        return False
    elif isinstance(cell.value, str) and "." in cell.value:
        return False
    elif isinstance(cell.value, str) and not ("." in cell.value):
        return True
    elif isinstance(cell.value, float) and int(cell.value) == cell.value:
        return True
    elif isinstance(cell.value, float) and int(cell.value) != cell.value:
        return False
    elif isinstance(cell.value, int):
        return True
示例#5
0
def load_workbook(wb):
    global sheet_dict, company_type
    sheet = wb.sheet_by_index(SHEET_NUMBER)
    nrows = sheet.nrows
    for i in range(STARTING_ROW, nrows):
        if (not (common.is_blank(sheet.cell(i, 0)))) and (not is_company_type(
                sheet.cell(i, 0))):
            for k in fields_dictionary.keys():
                sheet_dict[fields_dictionary[k]].append(
                    sheet.cell(i,
                               int(k) - 1).value)
            sheet_dict['company_type'].append(company_type)
        elif is_company_type(sheet.cell(i, 0)):
            company_type = common.refine_company_type(sheet.cell(i, 1).value)
def load_workbook(wb):
    global sheet_dict
    sheet = wb.sheet_by_index(SHEET_NUMBER)
    nrows = sheet.nrows
    lessor = ''
    for i in range(STARTING_ROW, nrows):
        if not (common.is_blank(sheet.cell(i, 0))):
            if int(float(sheet.cell(i, 0).value)) != float(
                    sheet.cell(i, 0).value):
                for k in fields_dictionary.keys():
                    sheet_dict[fields_dictionary[k]].append(
                        remove_x(sheet.cell(i,
                                            int(k) - 1).value))
                sheet_dict["lessor"].append(lessor)
            else:
                lessor = get_lessor(sheet.cell(i, 1).value)
示例#7
0
def check_file_path(file: str):
    if is_blank(file):
        exit.error(f'Blank file path. [arg -> {file}]')

    if not os.path.exists(file):
        exit.error('Not found file.')
示例#8
0
文件: lexer.py 项目: foones/lenguajes
 def ignore_whitespace(self):
     while not self._scanner.eof() and common.is_blank(self.peek()):
         if self.peek() == '\t':
             self.fail('no-tabs-allowed')
         self.next()