Esempio n. 1
0
    def get_all_user_cells(self, cell_range_list):
        """
        Searches the cells to be merged for cell ranges and extracts the individual cells from these.

        keywords:
            cell_range_list -- list of cells and ranges (list)

        return:
            cell_list -- updated list of cells (list)
        """
        range_list = [elem for elem in cell_range_list if elem.find(":") > 0]
        cell_list = [
            elem for elem in cell_range_list if elem not in range_list
        ]

        for j in range(len(range_list)):
            min_row, min_col, max_row, max_col = self.xl_range_reverse(
                range_list[j])

            for col in range(min_col, max_col + 1):
                for row in range(min_row, max_row + 1):
                    new_cell = xl_rowcol_to_cell_fast(row, col)
                    cell_list.append(new_cell)

        cell_list.sort()
        return cell_list
Esempio n. 2
0
def _get_corner(df, startcol=0, startrow=0, index=False, header=True, **kw):
    ref = {}

    if header:
        i = _index_levels(df.columns)
        ref['header'] = list(range(i))
        startrow += i

        if index and isinstance(df.columns, pd.MultiIndex):
            ref['skiprows'] = [i + 1]
            startrow += 1

    if index:
        i = _index_levels(df.index)
        ref['index_col'] = list(range(i))
        startcol += i
    landing = xl_rowcol_to_cell_fast(startrow, startcol)
    ref = '{}(L):..(DR):LURD:["df", {}]'.format(landing, json.dumps(ref))
    return startrow, startcol, ref
def report_outline_sheet(private_results, excel):
    '''
    info: 总览
    '''
    ouline_sheet = excel.add_worksheet('检测结果总览')
    # title 合并单元格
    title_style = excel.add_format({
        'bold': True,
        'align': 'center',
        'font_size': 18,
        'valign': 'vcenter',
        'fg_color': '#f05b72'
    })
    ouline_sheet.merge_range(
        'A1:L5',
        '支付平台SDK上线私有API审核报告(%s)' % time.strftime("%Y-%m-%d", time.localtime()),
        title_style)

    ########header
    header_style = excel.add_format({
        'bold': True,
        'align': 'center',
        'fg_color': '#a3cf62',
        'font_size': 12
    })
    header_style.set_border(1)  # 定义format_title对象单元格边框加粗(1像素)的格式

    # 设置列宽
    ouline_sheet.set_column('A:A', 5)
    ouline_sheet.set_column('B:B', 20)
    ouline_sheet.set_column('C:D', 15)
    ouline_sheet.set_column('E:F', 20)
    ouline_sheet.set_column('G:L', 30)
    ouline_sheet.set_column('I:I', 20)
    # header
    ouline_sheet.write(5, 0, 'ID', header_style)  # A
    ouline_sheet.write(5, 1, 'App_Name', header_style)  # B

    ouline_sheet.write(5, 2, '版本号', header_style)  # C
    ouline_sheet.write(5, 3, 'Bundle ID', header_style)  # D
    ouline_sheet.write(5, 4, 'Target os version', header_style)  # E
    ouline_sheet.write(5, 5, 'Minimum os version', header_style)  # F

    ouline_sheet.write(5, 6, '设备数量', header_style)  # G
    ouline_sheet.write_comment('G4', '具有APP安装证书的设备数量,即添加过设备的UDID')

    ouline_sheet.write(5, 7, '架构', header_style)  # H
    ouline_sheet.write_comment('H4', 'appstore 在2014年底强制要求所有的上线app都必须支持64位架构')

    ouline_sheet.write(5, 8, '证书类型', header_style)  # I
    ouline_sheet.write_comment('I4',
                               '正式上线应该为 Enterprise,测试包一般为 Ad Hoc/Developer')

    ouline_sheet.write(5, 9, 'Warnings数', header_style)  # J
    ouline_sheet.write_comment('J4', '一些配置项的警告信息,建议修改')

    ouline_sheet.write(5, 10, 'Errors数', header_style)  # K
    ouline_sheet.write_comment('K4', '一些配置项的错误信息,强烈要求修复')

    ouline_sheet.write(5, 11, '私有API', header_style)  # L
    ouline_sheet.write_comment(
        'L4',
        '私有api是平台禁止使用的一些方法集合,如果app中使用,可能会导致上线被拒,并且给苹果留下不好的印象;此项包括私有API和私有Framework'
    )

    # header

    # check_results['name'] = parse.app_name()
    # check_results['version'] = parse.version()
    # check_results['bundle_id'] = parse.bundle_identifier()
    # check_results['tar_version'] = parse.target_os_version()
    # check_results['min_version'] = parse.minimum_os_version()
    #
    # check_results['expiration'] = parse.expiration_date()
    # check_results['profile_type'] = parse.distribution_profile_type()
    # check_results['provisioned_devices'] = parse.provisioned_devices()
    #
    # # warning and error
    # check_results['warning'] = []
    # check_results['error'] = []

    # data
    #     success_format = excel.add_format(({'bold': True, 'color': '#b6d7a8'}))
    #     fail_format = excel.add_format(({'bold': True, 'color': '#cc4125'}))
    text_format = excel.add_format(({'align': 'center'}))
    url_format = excel.add_format({'font_color': 'blue', 'underline': 1})
    cnt = 6
    for result in private_results:
        ouline_sheet.write(cnt, 0, cnt - 5, text_format)  # A
        ouline_sheet.write_url(
            cnt, 1, 'internal:' + result.get('sheet_name', '') + '!' +
            xl_rowcol_to_cell_fast(0, 0), url_format, result.get('name', ''))
        ouline_sheet.write(cnt, 2, result.get('version', ''), text_format)
        ouline_sheet.write(cnt, 3, result.get('bundle_id', ''), text_format)
        ouline_sheet.write(cnt, 4, result.get('tar_version', ''), text_format)
        ouline_sheet.write(cnt, 5, result.get('min_version', ''), text_format)
        ouline_sheet.write(cnt, 6, len(result.get('provisioned_devices', [])),
                           text_format)
        ouline_sheet.write(cnt, 7, ' / '.join(result.get('arcs', '')))
        ouline_sheet.write(cnt, 8, result.get('profile_type', ''), text_format)
        ouline_sheet.write(cnt, 9, len(result.get('warning', [])), text_format)
        ouline_sheet.write(cnt, 10, len(result.get('error', [])), text_format)
        ouline_sheet.write(cnt, 11,
                           str(len(result.get('private_apis', []))) + ' / ' +
                           str(len(result.get('private_frameworks', []))),
                           text_format)  # G

        cnt = cnt + 1

    return excel
Esempio n. 4
0
def benchmark_xlsx(rows, cols, optimise, memory_check):

    # Set up testing data (do not benchmark).
    # todo: Cache for later use (better benchmark perf).

    chars = (string.ascii_uppercase + string.digits + ' '
             + string.ascii_lowercase)

    strs = [''.join(random.choice(chars)
                    for _ in range(STR_LEN))
            for _ in range(rows * cols)]

    ints = [bool(random.randint(-MAX_INT, MAX_INT))
            for _ in xrange(rows*cols)]

    floats = [random.randrange(-float(MAX_INT), float(MAX_INT))
              for _ in xrange(rows*cols)]

    bools = [bool(random.randint(-1, 1))
             for x in xrange(rows*cols)]

    data_types = [strs, ints, floats, bools]

    # todo: Add more data types?

    len_data_types = len(data_types)
    locations = []
    for i in range(len_data_types):
        for x in range(rows):
            if len(locations) < x + 1:
                locations.append([])
            for y in range(cols):
                y_index = cols * i + y
                locations[x].append(xl_rowcol_to_cell_fast(x, y_index))

    # todo: Test urls.

    start_time = clock()

    # Start of program being tested.
    workbook = xlsxwriter.Workbook('xlsxw_perf_%s_%s.xlsx' % (rows, cols),
                                   {'constant_memory': optimise})
    worksheet = workbook.add_worksheet()

    formats = []
    for _ in xrange(MAX_FORMATS):
        properties = {}
        for i in xrange(MAX_FORMAT_PROPS):
            prop = random.choice(FORMAT_PROPERTIES)
            properties[prop[0]] = prop[1]
        formats.append(workbook.add_format(properties))

    # Create the actual spreadsheet.
    for i, data_type in enumerate(data_types):
        for row in range(rows):
            for col in range(cols):
                y_index = col + len_data_types * i
                # todo: Test comments.
                worksheet.write(locations[x][y_index],
                                data_type[row * cols + col],
                                random.choice(formats))

    # Get total memory size for workbook object before closing it.
    if memory_check:
        total_size = asizeof(workbook)
    else:
        total_size = 0

    workbook.close()

    # Get the elapsed time.
    elapsed = clock() - start_time

    # Print a simple CSV output for reporting.
    print("%10s %10s %10s %10s" % (rows, cols, elapsed, total_size))

    return elapsed, total_size
Esempio n. 5
0
 def get_cell(self, row=None, column=None):
     row = row or self.row
     column = column or self.column
     return xl_rowcol_to_cell_fast(row, column)
Esempio n. 6
0
 def get_cell(self, row=None, column=None):
     row = row or self.row
     column = column or self.column
     return xl_rowcol_to_cell_fast(row, column)