Best Python code snippet using autotest_python
Analyzer.py
Source:Analyzer.py
1#!/usr/bin/env python2# -*- coding: windows-1251 -*-3# Copyright (C) 2005 Roman V. Kiseliov4# All rights reserved.5# 6# Redistribution and use in source and binary forms, with or without7# modification, are permitted provided that the following conditions8# are met:9# 10# 1. Redistributions of source code must retain the above copyright11# notice, this list of conditions and the following disclaimer.12# 13# 2. Redistributions in binary form must reproduce the above copyright14# notice, this list of conditions and the following disclaimer in15# the documentation and/or other materials provided with the16# distribution.17# 18# 3. All advertising materials mentioning features or use of this19# software must display the following acknowledgment:20# "This product includes software developed by21# Roman V. Kiseliov <roman@kiseliov.ru>."22# 23# 4. Redistributions of any form whatsoever must retain the following24# acknowledgment:25# "This product includes software developed by26# Roman V. Kiseliov <roman@kiseliov.ru>."27# 28# THIS SOFTWARE IS PROVIDED BY Roman V. Kiseliov ``AS IS'' AND ANY29# EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE30# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR31# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Roman V. Kiseliov OR32# ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,33# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT34# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;35# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)36# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,37# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)38# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED39# OF THE POSSIBILITY OF SUCH DAMAGE.40__rev_id__ = """$Id: Analyzer.py,v 1.4 2005/05/12 06:51:17 rvk Exp $"""41# total 258 records in database42import struct43def analyze_1904_record(data):44 # 0x002245 pass46def analyze_ADDIN_record(data):47 # 0x008748 pass49def analyze_ADDMENU_record(data):50 # 0x00C251 pass52def analyze_ARRAY_record(data):53 # 0x0021, 0x022154 pass55def analyze_AUTOFILTER_record(data):56 # 0x009E57 pass58def analyze_AUTOFILTERINFO_record(data):59 # 0x009D60 pass61def analyze_BACKUP_record(data):62 # 0x004063 pass64def analyze_BEGIN_record(data):65 # 0x103366 pass67def analyze_BITMAP_record(data):68 # 0x00E969 pass70def analyze_BLANK_record(data):71 # 0x0001, 0x020172 pass73def analyze_BOF_record(data):74 # 0x0009, 0x0209, 0x0409, 0x080975 pass76def analyze_BOOKBOOL_record(data):77 # 0x00DA78 pass79def analyze_BOOLERR_record(data):80 # 0x0005, 0x020581 pass82def analyze_BOTTOMMARGIN_record(data):83 # 0x002984 print struct.unpack('<d', data)[0]85 pass86def analyze_BOUNDSHEET_record(data):87 # 0x008588 pass89def analyze_BUILTINFMTCNT_record(data):90 # 0x005691 pass92def analyze_BUNDLEHEADER_record(data):93 # 0x008F94 pass95def analyze_BUNDLESOFFSET_record(data):96 # 0x008E97 pass98def analyze_CALCCOUNT_record(data):99 # 0x000C100 pass101def analyze_CALCMODE_record(data):102 # 0x000D103 pass104def analyze_MERGEDCELLS_record(data):105 # 0x00E5106 pass107def analyze_CF_record(data):108 # 0x01B1109 pass110def analyze_CHTRCELLCONTENT_record(data):111 # 0x013B112 pass113def analyze_CHTRHEADER_record(data):114 # 0x0196115 pass116def analyze_CHTRINFO_record(data):117 # 0x0138118 pass119def analyze_CHTRINSERT_record(data):120 # 0x0137121 pass122def analyze_CHTRINSERTTAB_record(data):123 # 0x014D124 pass125def analyze_CHTRMOVERANGE_record(data):126 # 0x0140127 pass128def analyze_CODENAME_record(data):129 # 0x01BA130 pass131def analyze_CODEPAGE_record(data):132 # 0x0042133 pass134def analyze_COLINFO_record(data):135 # 0x007D136 pass137def analyze_COLUMNDEFAULT_record(data):138 # 0x0020139 pass140def analyze_COLWIDTH_record(data):141 # 0x0024142 pass143def analyze_CONDFMT_record(data):144 # 0x01B0145 pass146def analyze_CONTINUE_record(data):147 # 0x003C148 pass149def analyze_COORDLIST_record(data):150 # 0x00A9151 pass152def analyze_COUNTRY_record(data):153 # 0x008C154 pass155def analyze_CRN_record(data):156 # 0x005A157 pass158def analyze_Chart3D_record(data):159 # 0x103A160 pass161def analyze_Chart3DDataFormat_record(data):162 # 0x105F163 pass164def analyze_ChartAI_record(data):165 # 0x1051166 pass167def analyze_ChartAlruns_record(data):168 # 0x1050169 pass170def analyze_ChartArea_record(data):171 # 0x101A172 pass173def analyze_ChartAreaformat_record(data):174 # 0x100A175 pass176def analyze_ChartAttachedlabel_record(data):177 # 0x100C178 pass179def analyze_ChartAxcext_record(data):180 # 0x1062181 pass182def analyze_ChartAxesused_record(data):183 # 0x1046184 pass185def analyze_ChartAxis_record(data):186 # 0x101D187 pass188def analyze_ChartAxislineformat_record(data):189 # 0x1021190 pass191def analyze_ChartAxisparent_record(data):192 # 0x1041193 pass194def analyze_ChartBar_record(data):195 # 0x1017196 pass197def analyze_ChartBoppcustom_record(data):198 # 0x1067199 pass200def analyze_ChartBoppop_record(data):201 # 0x1061202 pass203def analyze_ChartCatserrange_record(data):204 # 0x1020205 pass206def analyze_ChartChart_record(data):207 # 0x1002208 pass209def analyze_ChartChartformat_record(data):210 # 0x1014211 pass212def analyze_ChartChartline_record(data):213 # 0x101C214 pass215def analyze_ChartDat_record(data):216 # 0x1063217 pass218def analyze_ChartDataformat_record(data):219 # 0x1006220 pass221def analyze_ChartDefaulttext_record(data):222 # 0x1024223 pass224def analyze_ChartDropbar_record(data):225 # 0x103D226 pass227def analyze_ChartFbi_record(data):228 # 0x1060229 pass230def analyze_ChartFontx_record(data):231 # 0x1026232 pass233def analyze_ChartFormatlink_record(data):234 # 0x1022235 pass236def analyze_ChartFrame_record(data):237 # 0x1032238 pass239def analyze_ChartGelframe_record(data):240 # 0x1066241 pass242def analyze_ChartIfmt_record(data):243 # 0x104E244 pass245def analyze_ChartLegend_record(data):246 # 0x1015247 pass248def analyze_ChartLegendxn_record(data):249 # 0x1043250 pass251def analyze_ChartLine_record(data):252 # 0x1018253 pass254def analyze_ChartLineformat_record(data):255 # 0x1007256 pass257def analyze_ChartMarkerformat_record(data):258 # 0x1009259 pass260def analyze_ChartObjectLink_record(data):261 # 0x1027262 pass263def analyze_ChartPicf_record(data):264 # 0x103C265 pass266def analyze_ChartPie_record(data):267 # 0x1019268 pass269def analyze_ChartPieformat_record(data):270 # 0x100B271 pass272def analyze_ChartPlotarea_record(data):273 # 0x1035274 pass275def analyze_ChartPlotgrowth_record(data):276 # 0x1064277 pass278def analyze_ChartPos_record(data):279 # 0x104F280 pass281def analyze_ChartRadar_record(data):282 # 0x103E283 pass284def analyze_ChartRadararea_record(data):285 # 0x1040286 pass287def analyze_ChartSbaseref_record(data):288 # 0x1048289 pass290def analyze_ChartScatter_record(data):291 # 0x101B292 pass293def analyze_ChartSerauxerrbar_record(data):294 # 0x105B295 pass296def analyze_ChartSerauxtrend_record(data):297 # 0x104B298 pass299def analyze_ChartSerfmt_record(data):300 # 0x105D301 pass302def analyze_ChartSeries_record(data):303 # 0x1003304 pass305def analyze_ChartSerieslist_record(data):306 # 0x1016307 pass308def analyze_ChartSeriestext_record(data):309 # 0x100D310 pass311def analyze_ChartSerparent_record(data):312 # 0x104A313 pass314def analyze_ChartSertocrt_record(data):315 # 0x1045316 pass317def analyze_ChartShtprops_record(data):318 # 0x1044319 pass320def analyze_ChartSiindex_record(data):321 # 0x1065322 pass323def analyze_ChartSurface_record(data):324 # 0x103F325 pass326def analyze_ChartText_record(data):327 # 0x1025328 pass329def analyze_ChartTick_record(data):330 # 0x101E331 pass332def analyze_ChartValuerange_record(data):333 # 0x101F334 pass335def analyze_DBCELL_record(data):336 # 0x00D7337 pass338def analyze_DCON_record(data):339 # 0x0050340 pass341def analyze_DCONBIN_record(data):342 # 0x01B5343 pass344def analyze_DCONNAME_record(data):345 # 0x0053346 pass347def analyze_DCONREF_record(data):348 # 0x0051349 pass350def analyze_DEFAULTROWHEIGHT_record(data):351 # 0x0025, 0x0225352 pass353def analyze_DEFCOLWIDTH_record(data):354 # 0x0055355 pass356def analyze_DELMENU_record(data):357 # 0x00C3358 pass359def analyze_DELTA_record(data):360 # 0x0010361 pass362def analyze_DIMENSIONS_record(data):363 # 0x0000, 0x0200364 pass365def analyze_DOCROUTE_record(data):366 # 0x00B8367 pass368def analyze_DSF_record(data):369 # 0x0161370 pass371def analyze_DV_record(data):372 # 0x01BE373 pass374def analyze_DVAL_record(data):375 # 0x01B2376 pass377def analyze_EDG_record(data):378 # 0x0088379 pass380def analyze_EFONT_record(data):381 # 0x0045382 pass383def analyze_END_record(data):384 # 0x1034385 pass386def analyze_EOF_record(data):387 # 0x000A388 pass389def analyze_EXTERNCOUNT_record(data):390 # 0x0016391 pass392def analyze_EXTERNNAME_record(data):393 # 0x0023, 0x0223394 pass395def analyze_EXTERNSHEET_record(data):396 # 0x0017397 pass398def analyze_EXTSST_record(data):399 # 0x00FF400 pass401def analyze_FILEPASS_record(data):402 # 0x002F403 pass404def analyze_FILESHARING_record(data):405 # 0x005B406 pass407def analyze_FILTERMODE_record(data):408 # 0x009B409 pass410def analyze_FNGROUPCOUNT_record(data):411 # 0x009C412 pass413def analyze_FNGROUPNAME_record(data):414 # 0x009A415 pass416def analyze_FONT_record(data):417 # 0x0031, 0x0231418 pass419def analyze_FOOTER_record(data):420 # 0x0015421 pass422def analyze_FORMAT_record(data):423 # 0x001E, 0x041E424 fmt_idx = struct.unpack('<H', data[0:2])425 name_len = struct.unpack('<H', data[2:4])426 compressed = data[4] == '\x00'427 print 'format index : 0x%04X' % fmt_idx428 print 'format name len : 0x%04X' % name_len429 print 'compressed UNICODE:', compressed430 name = data[5:]431 if not compressed:432 name = [c for c in name if c != '\x00'] 433 name = ''.join(name)434 print 'format str :', name 435 pass436def analyze_FORMATCOUNT_record(data):437 # 0x001F438 pass439def analyze_FORMULA_record(data):440 # 0x0006, 0x0206, 0x0406441 pass442def analyze_GCW_record(data):443 # 0x00AB444 pass445def analyze_GRIDSET_record(data):446 # 0x0082447 pass448def analyze_GUTS_record(data):449 # 0x0080450 pass451def analyze_HCENTER_record(data):452 # 0x0083453 pass454def analyze_HEADER_record(data):455 # 0x0014456 pass457def analyze_HIDEOBJ_record(data):458 # 0x008D459 pass460def analyze_HLINK_record(data):461 # 0x01B8462 pass463def analyze_HORIZONTALPAGEBREAKS_record(data):464 # 0x001B465 pass466def analyze_IMDATA_record(data):467 # 0x007F468 pass469def analyze_INDEX_record(data):470 # 0x000B, 0x020B471 pass472def analyze_INTEGER_record(data):473 # 0x0002474 pass475def analyze_INTERFACEEND_record(data):476 # 0x00E2477 pass478def analyze_INTERFACEHDR_record(data):479 # 0x00E1480 pass481def analyze_ITERATION_record(data):482 # 0x0011483 pass484def analyze_IXFE_record(data):485 # 0x0044486 pass487def analyze_LABEL_record(data):488 # 0x0004, 0x0204489 pass490def analyze_LABELRANGES_record(data):491 # 0x015F492 pass493def analyze_LABELSST_record(data):494 # 0x00FD495 row, col, xf_idx, sst_idx = struct.unpack('<3HL', data)496 print 'row : 0x%000X' % row497 print 'col : 0x%000X' % col498 print 'xf idx : 0x%000X' % xf_idx499 print 'sst idx : 0x%000X' % sst_idx500 pass501def analyze_LEFTMARGIN_record(data):502 # 0x0026503 print struct.unpack('<d', data)[0]504 pass505def analyze_LHNGRAPH_record(data):506 # 0x0095507 pass508def analyze_LHRECORD_record(data):509 # 0x0094510 pass511def analyze_LPR_record(data):512 # 0x0098513 pass514def analyze_MMS_record(data):515 # 0x00C1516 pass517def analyze_MSODRAWING_record(data):518 # 0x00EC519 pass520def analyze_MSODRAWINGGROUP_record(data):521 # 0x00EB522 pass523def analyze_MSODRAWINGSELECTION_record(data):524 # 0x00ED525 pass526def analyze_MULBLANK_record(data):527 # 0x00BE528 pass529def analyze_MULRK_record(data):530 # 0x00BD531 pass532def analyze_NAME_record(data):533 # 0x0018, 0x0218534 pass535def analyze_NOTE_record(data):536 # 0x001C537 pass538def analyze_NUMBER_record(data):539 # 0x0003, 0x0203540 pass541def analyze_OBJ_record(data):542 # 0x005D543 pass544def analyze_OBJPROTECT_record(data):545 # 0x0063546 pass547def analyze_OBPROJ_record(data):548 # 0x00D3549 pass550def analyze_OLESIZE_record(data):551 # 0x00DE552 pass553def analyze_PALETTE_record(data):554 # 0x0092555 pass556def analyze_PANE_record(data):557 # 0x0041558 pass559def analyze_PASSWORD_record(data):560 # 0x0013561 pass562def analyze_PLS_record(data):563 # 0x004D564 pass565def analyze_PRECISION_record(data):566 # 0x000E567 pass568def analyze_PRINTGRIDLINES_record(data):569 # 0x002B570 pass571def analyze_PRINTHEADERS_record(data):572 # 0x002A573 pass574def analyze_PROT4REV_record(data):575 # 0x01AF576 pass577def analyze_PROT4REVPASS_record(data):578 # 0x01BC579 pass580def analyze_PROTECT_record(data):581 # 0x0012582 pass583def analyze_PUB_record(data):584 # 0x0089585 pass586def analyze_QSI_record(data):587 # 0x01AD588 pass589def analyze_RECALCID_record(data):590 # 0x01C1: 591 pass592def analyze_RECIPNAME_record(data):593 # 0x00B9594 pass595def analyze_REFMODE_record(data):596 # 0x000F597 pass598def analyze_REFRESHALL_record(data):599 # 0x01B7600 pass601def analyze_RIGHTMARGIN_record(data):602 # 0x0027603 print struct.unpack('<d', data)[0]604 pass605def analyze_RK_record(data):606 # 0x007E, 0x027E607 pass608def analyze_ROW_record(data):609 # 0x0008, 0x0208610 idx, col1, col2, height_options, not_used, not_used, options = \611 struct.unpack('<6HL', data)612 print 'row index : 0x%000X' % idx613 print 'start col : 0x%000X' % col1614 print 'last col + 1 : 0x%000X' % col2615 print 'height : 0x%000X' % (height_options & 0x7FFF)616 print 'height is custom : 0x%000X' % ((height_options & 0x8000) >> 15)617 print 'outline level : 0x%000X' % ((options & 0x00000007L) >> 0)618 print 'level collapsed : 0x%000X' % ((options & 0x00000010L) >> 4)619 print 'row is hidden : 0x%000X' % ((options & 0x00000020L) >> 5)620 print 'font height match: 0x%000X' % ((options & 0x00000040L) >> 6)621 print 'default format : 0x%000X' % ((options & 0x00000080L) >> 7)622 print 'default xf index : 0x%000X' % ((options & 0x0FFF0000L) >> 16)623 print 'add space above : 0x%000X' % ((options & 0x10000000L) >> 28)624 print 'add space below : 0x%000X' % ((options & 0x20000000L) >> 29)625def analyze_RSTRING_record(data):626 # 0x00D6627 pass628def analyze_SAFERECALC_record(data):629 # 0x005F630 pass631def analyze_SCENARIO_record(data):632 # 0x00AF633 pass634def analyze_SCENMAN_record(data):635 # 0x00AE636 pass637def analyze_SCENPROTECT_record(data):638 # 0x00DD639 pass640def analyze_SCL_record(data):641 # 0x00A0642 pass643def analyze_SCREENTIP_record(data):644 # 0x0800645 pass646def analyze_SELECTION_record(data):647 # 0x001D648 pass649def analyze_SETUP_record(data):650 # 0x00A1651 pass652def analyze_SHEETLAYOUT_record(data):653 # 0x0862654 pass655def analyze_SHEETPROTECTION_record(data):656 # 0x0867657 pass658def analyze_SHRFMLA_record(data):659 # 0x00BC, 0x04BC660 pass661def analyze_SORT_record(data):662 # 0x0090663 pass664def analyze_SOUND_record(data):665 # 0x0096666 pass667def analyze_SST_record(data):668 # 0x00FC669 pass670def analyze_STANDARDWIDTH_record(data):671 # 0x0099672 pass673def analyze_STRING_record(data):674 # 0x0007, 0x0207675 pass676def analyze_STYLE_record(data):677 # 0x0093, 0x0293678 pass679def analyze_SUB_record(data):680 # 0x0091681 pass682def analyze_SUPBOOK_record(data):683 # 0x01AE684 pass685def analyze_SXDATETIME_record(data):686 # 0x00CE687 pass688def analyze_SXDB_record(data):689 # 0x00C6690 pass691def analyze_SXDBEX_record(data):692 # 0x0122693 pass694def analyze_SXDI_record(data):695 # 0x00C5696 pass697def analyze_SXDOUBLE_record(data):698 # 0x00C9699 pass700def analyze_SXEX_record(data):701 # 0x00F1702 pass703def analyze_SXEXT_PARAMQRY_record(data):704 # 0x00DC705 pass706def analyze_SXFDBTYPE_record(data):707 # 0x01BB708 pass709def analyze_SXFIELD_record(data):710 # 0x00C7711 pass712def analyze_SXFILT_record(data):713 # 0x00F2714 pass715def analyze_SXFMLA_record(data):716 # 0x00F9717 pass718def analyze_SXFORMAT_record(data):719 # 0x00FB720 pass721def analyze_SXFORMULA_record(data):722 # 0x0103723 pass724def analyze_SXIDSTM_record(data):725 # 0x00D5726 pass727def analyze_SXINDEXLIST_record(data):728 # 0x00C8729 pass730def analyze_SXIVD_record(data):731 # 0x00B4732 pass733def analyze_SXLI_record(data):734 # 0x00B5735 pass736def analyze_SXNAME_record(data):737 # 0x00F6738 pass739def analyze_SXPAIR_record(data):740 # 0x00F8741 pass742def analyze_SXPI_record(data):743 # 0x00B6744 pass745def analyze_SXRULE_record(data):746 # 0x00F0747 pass748def analyze_SXSELECT_record(data):749 # 0x00F7750 pass751def analyze_SXSTRING_record(data):752 # 0x00CD753 pass754def analyze_SXTBL_record(data):755 # 0x00D0756 pass757def analyze_SXTBPG_record(data):758 # 0x00D2759 pass760def analyze_SXTBRGITEM_record(data):761 # 0x00D1762 pass763def analyze_SXVD_record(data):764 # 0x00B1765 pass766def analyze_SXVDEX_record(data):767 # 0x0100768 pass769def analyze_SXVI_record(data):770 # 0x00B2771 pass772def analyze_SXVIEW_record(data):773 # 0x00B0774 pass775def analyze_SXVS_record(data):776 # 0x00E3777 pass778def analyze_TABID_record(data):779 # 0x013D780 pass781def analyze_TABLE_record(data):782 # 0x0036, 0x0236783 pass784def analyze_TEMPLATE_record(data):785 # 0x0060786 pass787def analyze_TOPMARGIN_record(data):788 # 0x0028789 print struct.unpack('<d', data)[0]790 pass791def analyze_TXO_record(data):792 # 0x01B6793 pass794def analyze_UDDESC_record(data):795 # 0x00DF796 pass797def analyze_UNCALCED_record(data):798 # 0x005E799 pass800def analyze_UNITS_record(data):801 # 0x1001802 pass803def analyze_USERBVIEW_record(data):804 # 0x01A9805 pass806def analyze_USERSVIEWBEGIN_record(data):807 # 0x01AA808 pass809def analyze_USERSVIEWEND_record(data):810 # 0x01AB811 pass812def analyze_USESELFS_record(data):813 # 0x0160814 pass815def analyze_VCENTER_record(data):816 # 0x0084817 pass818def analyze_VERTICALPAGEBREAKS_record(data):819 # 0x001A820 pass821def analyze_WEBQRYSETTINGS_record(data):822 # 0x0803823 pass824def analyze_WEBQRYTABLES_record(data):825 # 0x0804826 pass827def analyze_WINDOW1_record(data):828 # 0x003D829 pass830def analyze_WINDOW2_record(data):831 # 0x003E, 0x023E832 pass833def analyze_WINDOWPROTECT_record(data):834 # 0x0019835 pass836def analyze_WRITEACCESS_record(data):837 # 0x005C838 pass839def analyze_WRITEPROT_record(data):840 # 0x0086841 pass842def analyze_WSBOOL_record(data):843 # 0x0081844 pass845def analyze_XCT_record(data):846 # 0x0059847 pass848def analyze_XF_record(data):849 # 0x0043, 0x00E0, 0x0243, 0x0443850 #fnt_idx, num_ftm_idx, \851 # cell_prot, \852 # align, rotation, txt_format, \853 # used_attrib, \854 # border0, border1, border2 = struct.unpack('<3H4B2LH', data)855 #print 'fnt idx : 0x%000X' % fnt_idx856 #print 'num fmt idx : 0x%000X' % num_ftm_idx857 #print 'cell is locked : 0x%0X ' % ((cell_prot) & 0x01)858 #print 'format is hidden : 0x%0X ' % ((cell_prot & 0x02) >> 1)859 #print 'style XF(1), cell XF(0) : 0x%0X ' % ((cell_prot & 0x03) >> 3)860 #print 'Index to parent style XF: 0x%0000X' % ((cell_prot & 0xFFF0) >> 4)861 pass862def analyze_XL5MODIFY_record(data):863 # 0x0162864 pass865def analyze_XL9FILE_record(data):866 # 0x01C0: 867 pass868all_records = {869 0x0000: ('DIMENSIONS', analyze_DIMENSIONS_record),870 0x0001: ('BLANK', analyze_BLANK_record),871 0x0002: ('INTEGER', analyze_INTEGER_record),872 0x0003: ('NUMBER', analyze_NUMBER_record),873 0x0004: ('LABEL', analyze_LABEL_record),874 0x0005: ('BOOLERR', analyze_BOOLERR_record),875 0x0006: ('FORMULA', analyze_FORMULA_record),876 0x0007: ('STRING', analyze_STRING_record),877 0x0008: ('ROW', analyze_ROW_record),878 0x0009: ('BOF', analyze_BOF_record),879 0x000A: ('EOF', analyze_EOF_record),880 0x000B: ('INDEX', analyze_INDEX_record),881 0x000C: ('CALCCOUNT', analyze_CALCCOUNT_record),882 0x000D: ('CALCMODE', analyze_CALCMODE_record),883 0x000E: ('PRECISION', analyze_PRECISION_record),884 0x000F: ('REFMODE', analyze_REFMODE_record),885 0x0010: ('DELTA', analyze_DELTA_record),886 0x0011: ('ITERATION', analyze_ITERATION_record),887 0x0012: ('PROTECT', analyze_PROTECT_record),888 0x0013: ('PASSWORD', analyze_PASSWORD_record),889 0x0014: ('HEADER', analyze_HEADER_record),890 0x0015: ('FOOTER', analyze_FOOTER_record),891 0x0016: ('EXTERNCOUNT', analyze_EXTERNCOUNT_record),892 0x0017: ('EXTERNSHEET', analyze_EXTERNSHEET_record),893 0x0018: ('NAME', analyze_NAME_record),894 0x0019: ('WINDOWPROTECT', analyze_WINDOWPROTECT_record),895 0x001A: ('VERTICALPAGEBREAKS', analyze_VERTICALPAGEBREAKS_record),896 0x001B: ('HORIZONTALPAGEBREAKS', analyze_HORIZONTALPAGEBREAKS_record),897 0x001C: ('NOTE', analyze_NOTE_record),898 0x001D: ('SELECTION', analyze_SELECTION_record),899 0x001E: ('FORMAT', analyze_FORMAT_record),900 0x001F: ('FORMATCOUNT', analyze_FORMATCOUNT_record),901 0x0020: ('COLUMNDEFAULT', analyze_COLUMNDEFAULT_record),902 0x0021: ('ARRAY', analyze_ARRAY_record),903 0x0022: ('1904', analyze_1904_record),904 0x0023: ('EXTERNNAME', analyze_EXTERNNAME_record),905 0x0024: ('COLWIDTH', analyze_COLWIDTH_record),906 0x0025: ('DEFAULTROWHEIGHT', analyze_DEFAULTROWHEIGHT_record),907 0x0026: ('LEFTMARGIN', analyze_LEFTMARGIN_record),908 0x0027: ('RIGHTMARGIN', analyze_RIGHTMARGIN_record),909 0x0028: ('TOPMARGIN', analyze_TOPMARGIN_record),910 0x0029: ('BOTTOMMARGIN', analyze_BOTTOMMARGIN_record),911 0x002A: ('PRINTHEADERS', analyze_PRINTHEADERS_record),912 0x002B: ('PRINTGRIDLINES', analyze_PRINTGRIDLINES_record),913 0x002F: ('FILEPASS', analyze_FILEPASS_record),914 0x0031: ('FONT', analyze_FONT_record),915 0x0036: ('TABLE', analyze_TABLE_record),916 0x003C: ('CONTINUE', analyze_CONTINUE_record),917 0x003D: ('WINDOW1', analyze_WINDOW1_record),918 0x003E: ('WINDOW2', analyze_WINDOW2_record),919 0x0040: ('BACKUP', analyze_BACKUP_record),920 0x0041: ('PANE', analyze_PANE_record),921 0x0042: ('CODEPAGE', analyze_CODEPAGE_record),922 0x0043: ('XF', analyze_XF_record),923 0x0044: ('IXFE', analyze_IXFE_record),924 0x0045: ('EFONT', analyze_EFONT_record),925 0x004D: ('PLS', analyze_PLS_record),926 0x0050: ('DCON', analyze_DCON_record),927 0x0051: ('DCONREF', analyze_DCONREF_record),928 0x0053: ('DCONNAME', analyze_DCONNAME_record),929 0x0055: ('DEFCOLWIDTH', analyze_DEFCOLWIDTH_record),930 0x0056: ('BUILTINFMTCNT', analyze_BUILTINFMTCNT_record),931 0x0059: ('XCT', analyze_XCT_record),932 0x005A: ('CRN', analyze_CRN_record),933 0x005B: ('FILESHARING', analyze_FILESHARING_record),934 0x005C: ('WRITEACCESS', analyze_WRITEACCESS_record),935 0x005D: ('OBJ', analyze_OBJ_record),936 0x005E: ('UNCALCED', analyze_UNCALCED_record),937 0x005F: ('SAFERECALC', analyze_SAFERECALC_record),938 0x0060: ('TEMPLATE', analyze_TEMPLATE_record),939 0x0063: ('OBJPROTECT', analyze_OBJPROTECT_record),940 0x007D: ('COLINFO', analyze_COLINFO_record),941 0x007E: ('RK', analyze_RK_record),942 0x007F: ('IMDATA', analyze_IMDATA_record),943 0x0080: ('GUTS', analyze_GUTS_record),944 0x0081: ('WSBOOL', analyze_WSBOOL_record),945 0x0082: ('GRIDSET', analyze_GRIDSET_record),946 0x0083: ('HCENTER', analyze_HCENTER_record),947 0x0084: ('VCENTER', analyze_VCENTER_record),948 0x0085: ('BOUNDSHEET', analyze_BOUNDSHEET_record),949 0x0086: ('WRITEPROT', analyze_WRITEPROT_record),950 0x0087: ('ADDIN', analyze_ADDIN_record),951 0x0088: ('EDG', analyze_EDG_record),952 0x0089: ('PUB', analyze_PUB_record),953 0x008C: ('COUNTRY', analyze_COUNTRY_record),954 0x008D: ('HIDEOBJ', analyze_HIDEOBJ_record),955 0x008E: ('BUNDLESOFFSET', analyze_BUNDLESOFFSET_record),956 0x008F: ('BUNDLEHEADER', analyze_BUNDLEHEADER_record),957 0x0090: ('SORT', analyze_SORT_record),958 0x0091: ('SUB', analyze_SUB_record),959 0x0092: ('PALETTE', analyze_PALETTE_record),960 0x0093: ('STYLE', analyze_STYLE_record),961 0x0094: ('LHRECORD', analyze_LHRECORD_record),962 0x0095: ('LHNGRAPH', analyze_LHNGRAPH_record),963 0x0096: ('SOUND', analyze_SOUND_record),964 0x0098: ('LPR', analyze_LPR_record),965 0x0099: ('STANDARDWIDTH', analyze_STANDARDWIDTH_record),966 0x009A: ('FNGROUPNAME', analyze_FNGROUPNAME_record),967 0x009B: ('FILTERMODE', analyze_FILTERMODE_record),968 0x009C: ('FNGROUPCOUNT', analyze_FNGROUPCOUNT_record),969 0x009D: ('AUTOFILTERINFO', analyze_AUTOFILTERINFO_record),970 0x009E: ('AUTOFILTER', analyze_AUTOFILTER_record),971 0x00A0: ('SCL', analyze_SCL_record),972 0x00A1: ('SETUP', analyze_SETUP_record),973 0x00A9: ('COORDLIST', analyze_COORDLIST_record),974 0x00AB: ('GCW', analyze_GCW_record),975 0x00AE: ('SCENMAN', analyze_SCENMAN_record),976 0x00AF: ('SCENARIO', analyze_SCENARIO_record),977 0x00B0: ('SXVIEW', analyze_SXVIEW_record),978 0x00B1: ('SXVD', analyze_SXVD_record),979 0x00B2: ('SXVI', analyze_SXVI_record),980 0x00B4: ('SXIVD', analyze_SXIVD_record),981 0x00B5: ('SXLI', analyze_SXLI_record),982 0x00B6: ('SXPI', analyze_SXPI_record),983 0x00B8: ('DOCROUTE', analyze_DOCROUTE_record),984 0x00B9: ('RECIPNAME', analyze_RECIPNAME_record),985 0x00BC: ('SHRFMLA', analyze_SHRFMLA_record),986 0x00BD: ('MULRK', analyze_MULRK_record),987 0x00BE: ('MULBLANK', analyze_MULBLANK_record),988 0x00C1: ('MMS', analyze_MMS_record),989 0x00C2: ('ADDMENU', analyze_ADDMENU_record),990 0x00C3: ('DELMENU', analyze_DELMENU_record),991 0x00C5: ('SXDI', analyze_SXDI_record),992 0x00C6: ('SXDB', analyze_SXDB_record),993 0x00C7: ('SXFIELD', analyze_SXFIELD_record),994 0x00C8: ('SXINDEXLIST', analyze_SXINDEXLIST_record),995 0x00C9: ('SXDOUBLE', analyze_SXDOUBLE_record),996 0x00CD: ('SXSTRING', analyze_SXSTRING_record),997 0x00CE: ('SXDATETIME', analyze_SXDATETIME_record),998 0x00D0: ('SXTBL', analyze_SXTBL_record),999 0x00D1: ('SXTBRGITEM', analyze_SXTBRGITEM_record),1000 0x00D2: ('SXTBPG', analyze_SXTBPG_record),1001 0x00D3: ('OBPROJ', analyze_OBPROJ_record),1002 0x00D5: ('SXIDSTM', analyze_SXIDSTM_record),1003 0x00D6: ('RSTRING', analyze_RSTRING_record),1004 0x00D7: ('DBCELL', analyze_DBCELL_record),1005 0x00DA: ('BOOKBOOL', analyze_BOOKBOOL_record),1006 0x00DC: ('SXEXT|PARAMQRY', analyze_SXEXT_PARAMQRY_record),1007 0x00DD: ('SCENPROTECT', analyze_SCENPROTECT_record),1008 0x00DE: ('OLESIZE', analyze_OLESIZE_record),1009 0x00DF: ('UDDESC', analyze_UDDESC_record),1010 0x00E0: ('XF', analyze_XF_record),1011 0x00E1: ('INTERFACEHDR', analyze_INTERFACEHDR_record),1012 0x00E2: ('INTERFACEEND', analyze_INTERFACEEND_record),1013 0x00E3: ('SXVS', analyze_SXVS_record),1014 0x00E5: ('MERGEDCELLS', analyze_MERGEDCELLS_record),1015 0x00E9: ('BITMAP', analyze_BITMAP_record),1016 0x00EB: ('MSODRAWINGGROUP', analyze_MSODRAWINGGROUP_record),1017 0x00EC: ('MSODRAWING', analyze_MSODRAWING_record),1018 0x00ED: ('MSODRAWINGSELECTION', analyze_MSODRAWINGSELECTION_record),1019 0x00F0: ('SXRULE', analyze_SXRULE_record),1020 0x00F1: ('SXEX', analyze_SXEX_record),1021 0x00F2: ('SXFILT', analyze_SXFILT_record),1022 0x00F6: ('SXNAME', analyze_SXNAME_record),1023 0x00F7: ('SXSELECT', analyze_SXSELECT_record),1024 0x00F8: ('SXPAIR', analyze_SXPAIR_record),1025 0x00F9: ('SXFMLA', analyze_SXFMLA_record),1026 0x00FB: ('SXFORMAT', analyze_SXFORMAT_record),1027 0x00FC: ('SST', analyze_SST_record),1028 0x00FD: ('LABELSST', analyze_LABELSST_record),1029 0x00FF: ('EXTSST', analyze_EXTSST_record),1030 0x0100: ('SXVDEX', analyze_SXVDEX_record),1031 0x0103: ('SXFORMULA', analyze_SXFORMULA_record),1032 0x0122: ('SXDBEX', analyze_SXDBEX_record),1033 0x0137: ('CHTRINSERT', analyze_CHTRINSERT_record),1034 0x0138: ('CHTRINFO', analyze_CHTRINFO_record),1035 0x013B: ('CHTRCELLCONTENT', analyze_CHTRCELLCONTENT_record),1036 0x013D: ('TABID', analyze_TABID_record),1037 0x0140: ('CHTRMOVERANGE', analyze_CHTRMOVERANGE_record),1038 0x014D: ('CHTRINSERTTAB', analyze_CHTRINSERTTAB_record),1039 0x015F: ('LABELRANGES', analyze_LABELRANGES_record),1040 0x0160: ('USESELFS', analyze_USESELFS_record),1041 0x0161: ('DSF', analyze_DSF_record),1042 0x0162: ('XL5MODIFY', analyze_XL5MODIFY_record),1043 0x0196: ('CHTRHEADER', analyze_CHTRHEADER_record),1044 0x01A9: ('USERBVIEW', analyze_USERBVIEW_record),1045 0x01AA: ('USERSVIEWBEGIN', analyze_USERSVIEWBEGIN_record),1046 0x01AB: ('USERSVIEWEND', analyze_USERSVIEWEND_record),1047 0x01AD: ('QSI', analyze_QSI_record),1048 0x01AE: ('SUPBOOK', analyze_SUPBOOK_record),1049 0x01AF: ('PROT4REV', analyze_PROT4REV_record),1050 0x01B0: ('CONDFMT', analyze_CONDFMT_record),1051 0x01B1: ('CF', analyze_CF_record),1052 0x01B2: ('DVAL', analyze_DVAL_record),1053 0x01B5: ('DCONBIN', analyze_DCONBIN_record),1054 0x01B6: ('TXO', analyze_TXO_record),1055 0x01B7: ('REFRESHALL', analyze_REFRESHALL_record),1056 0x01B8: ('HLINK', analyze_HLINK_record),1057 0x01BA: ('CODENAME', analyze_CODENAME_record),1058 0x01BB: ('SXFDBTYPE', analyze_SXFDBTYPE_record),1059 0x01BC: ('PROT4REVPASS', analyze_PROT4REVPASS_record),1060 0x01BE: ('DV', analyze_DV_record),1061 0x01C0: ('XL9FILE', analyze_XL9FILE_record),1062 0x01C1: ('RECALCID',analyze_RECALCID_record),1063 0x0200: ('DIMENSIONS', analyze_DIMENSIONS_record),1064 0x0201: ('BLANK', analyze_BLANK_record),1065 0x0203: ('NUMBER', analyze_NUMBER_record),1066 0x0204: ('LABEL', analyze_LABEL_record),1067 0x0205: ('BOOLERR', analyze_BOOLERR_record),1068 0x0206: ('FORMULA', analyze_FORMULA_record),1069 0x0207: ('STRING', analyze_STRING_record),1070 0x0208: ('ROW', analyze_ROW_record),1071 0x0209: ('BOF', analyze_BOF_record),1072 0x020B: ('INDEX', analyze_INDEX_record),1073 0x0218: ('NAME', analyze_NAME_record),1074 0x0221: ('ARRAY', analyze_ARRAY_record),1075 0x0223: ('EXTERNNAME', analyze_EXTERNNAME_record),1076 0x0225: ('DEFAULTROWHEIGHT', analyze_DEFAULTROWHEIGHT_record),1077 0x0231: ('FONT', analyze_FONT_record),1078 0x0236: ('TABLE', analyze_TABLE_record),1079 0x023E: ('WINDOW2', analyze_WINDOW2_record),1080 0x0243: ('XF', analyze_XF_record),1081 0x027E: ('RK', analyze_RK_record),1082 0x0293: ('STYLE', analyze_STYLE_record),1083 0x0406: ('FORMULA', analyze_FORMULA_record),1084 0x0409: ('BOF', analyze_BOF_record),1085 0x041E: ('FORMAT', analyze_FORMAT_record),1086 0x0443: ('XF', analyze_XF_record),1087 0x04BC: ('SHRFMLA', analyze_SHRFMLA_record),1088 0x0800: ('SCREENTIP', analyze_SCREENTIP_record),1089 0x0803: ('WEBQRYSETTINGS', analyze_WEBQRYSETTINGS_record),1090 0x0804: ('WEBQRYTABLES', analyze_WEBQRYTABLES_record),1091 0x0809: ('BOF', analyze_BOF_record),1092 0x0862: ('SHEETLAYOUT', analyze_SHEETLAYOUT_record),1093 0x0867: ('SHEETPROTECTION', analyze_SHEETPROTECTION_record),1094 0x1001: ('UNITS', analyze_UNITS_record),1095 0x1002: ('ChartChart', analyze_ChartChart_record),1096 0x1003: ('ChartSeries', analyze_ChartSeries_record),1097 0x1006: ('ChartDataformat', analyze_ChartDataformat_record),1098 0x1007: ('ChartLineformat', analyze_ChartLineformat_record),1099 0x1009: ('ChartMarkerformat', analyze_ChartMarkerformat_record),1100 0x100A: ('ChartAreaformat', analyze_ChartAreaformat_record),1101 0x100B: ('ChartPieformat', analyze_ChartPieformat_record),1102 0x100C: ('ChartAttachedlabel', analyze_ChartAttachedlabel_record),1103 0x100D: ('ChartSeriestext', analyze_ChartSeriestext_record),1104 0x1014: ('ChartChartformat', analyze_ChartChartformat_record),1105 0x1015: ('ChartLegend', analyze_ChartLegend_record),1106 0x1016: ('ChartSerieslist', analyze_ChartSerieslist_record),1107 0x1017: ('ChartBar', analyze_ChartBar_record),1108 0x1018: ('ChartLine', analyze_ChartLine_record),1109 0x1019: ('ChartPie', analyze_ChartPie_record),1110 0x101A: ('ChartArea', analyze_ChartArea_record),1111 0x101B: ('ChartScatter', analyze_ChartScatter_record),1112 0x101C: ('ChartChartline', analyze_ChartChartline_record),1113 0x101D: ('ChartAxis', analyze_ChartAxis_record),1114 0x101E: ('ChartTick', analyze_ChartTick_record),1115 0x101F: ('ChartValuerange', analyze_ChartValuerange_record),1116 0x1020: ('ChartCatserrange', analyze_ChartCatserrange_record),1117 0x1021: ('ChartAxislineformat', analyze_ChartAxislineformat_record),1118 0x1022: ('ChartFormatlink', analyze_ChartFormatlink_record),1119 0x1024: ('ChartDefaulttext', analyze_ChartDefaulttext_record),1120 0x1025: ('ChartText', analyze_ChartText_record),1121 0x1026: ('ChartFontx', analyze_ChartFontx_record),1122 0x1027: ('ChartObjectLink', analyze_ChartObjectLink_record),1123 0x1032: ('ChartFrame', analyze_ChartFrame_record),1124 0x1033: ('BEGIN', analyze_BEGIN_record),1125 0x1034: ('END', analyze_END_record),1126 0x1035: ('ChartPlotarea', analyze_ChartPlotarea_record),1127 0x103A: ('Chart3D', analyze_Chart3D_record),1128 0x103C: ('ChartPicf', analyze_ChartPicf_record),1129 0x103D: ('ChartDropbar', analyze_ChartDropbar_record),1130 0x103E: ('ChartRadar', analyze_ChartRadar_record),1131 0x103F: ('ChartSurface', analyze_ChartSurface_record),1132 0x1040: ('ChartRadararea', analyze_ChartRadararea_record),1133 0x1041: ('ChartAxisparent', analyze_ChartAxisparent_record),1134 0x1043: ('ChartLegendxn', analyze_ChartLegendxn_record),1135 0x1044: ('ChartShtprops', analyze_ChartShtprops_record),1136 0x1045: ('ChartSertocrt', analyze_ChartSertocrt_record),1137 0x1046: ('ChartAxesused', analyze_ChartAxesused_record),1138 0x1048: ('ChartSbaseref', analyze_ChartSbaseref_record),1139 0x104A: ('ChartSerparent', analyze_ChartSerparent_record),1140 0x104B: ('ChartSerauxtrend', analyze_ChartSerauxtrend_record),1141 0x104E: ('ChartIfmt', analyze_ChartIfmt_record),1142 0x104F: ('ChartPos', analyze_ChartPos_record),1143 0x1050: ('ChartAlruns', analyze_ChartAlruns_record),1144 0x1051: ('ChartAI', analyze_ChartAI_record),1145 0x105B: ('ChartSerauxerrbar', analyze_ChartSerauxerrbar_record),1146 0x105D: ('ChartSerfmt', analyze_ChartSerfmt_record),1147 0x105F: ('Chart3DDataFormat', analyze_Chart3DDataFormat_record),1148 0x1060: ('ChartFbi', analyze_ChartFbi_record),1149 0x1061: ('ChartBoppop', analyze_ChartBoppop_record),1150 0x1062: ('ChartAxcext', analyze_ChartAxcext_record),1151 0x1063: ('ChartDat', analyze_ChartDat_record),1152 0x1064: ('ChartPlotgrowth', analyze_ChartPlotgrowth_record),1153 0x1065: ('ChartSiindex', analyze_ChartSiindex_record),1154 0x1066: ('ChartGelframe', analyze_ChartGelframe_record),1155 0x1067: ('ChartBoppcustom', analyze_ChartBoppcustom_record),1156 0xFFFF: ('', None)1157}1158if __name__ == '__main__':1159 for r in all_records:1160 if all_records[r][1]:1161 all_records[r][1]('analyze it!')...
0520affd61ebbea655a021ff74c8e3d6344a42be.svn-base
Source:0520affd61ebbea655a021ff74c8e3d6344a42be.svn-base
1#!/usr/bin/env python2# -*- coding: windows-1251 -*-3# Copyright (C) 2005 Roman V. Kiseliov4# All rights reserved.5# 6# Redistribution and use in source and binary forms, with or without7# modification, are permitted provided that the following conditions8# are met:9# 10# 1. Redistributions of source code must retain the above copyright11# notice, this list of conditions and the following disclaimer.12# 13# 2. Redistributions in binary form must reproduce the above copyright14# notice, this list of conditions and the following disclaimer in15# the documentation and/or other materials provided with the16# distribution.17# 18# 3. All advertising materials mentioning features or use of this19# software must display the following acknowledgment:20# "This product includes software developed by21# Roman V. Kiseliov <roman@kiseliov.ru>."22# 23# 4. Redistributions of any form whatsoever must retain the following24# acknowledgment:25# "This product includes software developed by26# Roman V. Kiseliov <roman@kiseliov.ru>."27# 28# THIS SOFTWARE IS PROVIDED BY Roman V. Kiseliov ``AS IS'' AND ANY29# EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE30# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR31# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Roman V. Kiseliov OR32# ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,33# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT34# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;35# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)36# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,37# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)38# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED39# OF THE POSSIBILITY OF SUCH DAMAGE.40__rev_id__ = """$Id: Analyzer.py,v 1.4 2005/05/12 06:51:17 rvk Exp $"""41# total 258 records in database42import struct43def analyze_1904_record(data):44 # 0x002245 pass46def analyze_ADDIN_record(data):47 # 0x008748 pass49def analyze_ADDMENU_record(data):50 # 0x00C251 pass52def analyze_ARRAY_record(data):53 # 0x0021, 0x022154 pass55def analyze_AUTOFILTER_record(data):56 # 0x009E57 pass58def analyze_AUTOFILTERINFO_record(data):59 # 0x009D60 pass61def analyze_BACKUP_record(data):62 # 0x004063 pass64def analyze_BEGIN_record(data):65 # 0x103366 pass67def analyze_BITMAP_record(data):68 # 0x00E969 pass70def analyze_BLANK_record(data):71 # 0x0001, 0x020172 pass73def analyze_BOF_record(data):74 # 0x0009, 0x0209, 0x0409, 0x080975 pass76def analyze_BOOKBOOL_record(data):77 # 0x00DA78 pass79def analyze_BOOLERR_record(data):80 # 0x0005, 0x020581 pass82def analyze_BOTTOMMARGIN_record(data):83 # 0x002984 print struct.unpack('<d', data)[0]85 pass86def analyze_BOUNDSHEET_record(data):87 # 0x008588 pass89def analyze_BUILTINFMTCNT_record(data):90 # 0x005691 pass92def analyze_BUNDLEHEADER_record(data):93 # 0x008F94 pass95def analyze_BUNDLESOFFSET_record(data):96 # 0x008E97 pass98def analyze_CALCCOUNT_record(data):99 # 0x000C100 pass101def analyze_CALCMODE_record(data):102 # 0x000D103 pass104def analyze_MERGEDCELLS_record(data):105 # 0x00E5106 pass107def analyze_CF_record(data):108 # 0x01B1109 pass110def analyze_CHTRCELLCONTENT_record(data):111 # 0x013B112 pass113def analyze_CHTRHEADER_record(data):114 # 0x0196115 pass116def analyze_CHTRINFO_record(data):117 # 0x0138118 pass119def analyze_CHTRINSERT_record(data):120 # 0x0137121 pass122def analyze_CHTRINSERTTAB_record(data):123 # 0x014D124 pass125def analyze_CHTRMOVERANGE_record(data):126 # 0x0140127 pass128def analyze_CODENAME_record(data):129 # 0x01BA130 pass131def analyze_CODEPAGE_record(data):132 # 0x0042133 pass134def analyze_COLINFO_record(data):135 # 0x007D136 pass137def analyze_COLUMNDEFAULT_record(data):138 # 0x0020139 pass140def analyze_COLWIDTH_record(data):141 # 0x0024142 pass143def analyze_CONDFMT_record(data):144 # 0x01B0145 pass146def analyze_CONTINUE_record(data):147 # 0x003C148 pass149def analyze_COORDLIST_record(data):150 # 0x00A9151 pass152def analyze_COUNTRY_record(data):153 # 0x008C154 pass155def analyze_CRN_record(data):156 # 0x005A157 pass158def analyze_Chart3D_record(data):159 # 0x103A160 pass161def analyze_Chart3DDataFormat_record(data):162 # 0x105F163 pass164def analyze_ChartAI_record(data):165 # 0x1051166 pass167def analyze_ChartAlruns_record(data):168 # 0x1050169 pass170def analyze_ChartArea_record(data):171 # 0x101A172 pass173def analyze_ChartAreaformat_record(data):174 # 0x100A175 pass176def analyze_ChartAttachedlabel_record(data):177 # 0x100C178 pass179def analyze_ChartAxcext_record(data):180 # 0x1062181 pass182def analyze_ChartAxesused_record(data):183 # 0x1046184 pass185def analyze_ChartAxis_record(data):186 # 0x101D187 pass188def analyze_ChartAxislineformat_record(data):189 # 0x1021190 pass191def analyze_ChartAxisparent_record(data):192 # 0x1041193 pass194def analyze_ChartBar_record(data):195 # 0x1017196 pass197def analyze_ChartBoppcustom_record(data):198 # 0x1067199 pass200def analyze_ChartBoppop_record(data):201 # 0x1061202 pass203def analyze_ChartCatserrange_record(data):204 # 0x1020205 pass206def analyze_ChartChart_record(data):207 # 0x1002208 pass209def analyze_ChartChartformat_record(data):210 # 0x1014211 pass212def analyze_ChartChartline_record(data):213 # 0x101C214 pass215def analyze_ChartDat_record(data):216 # 0x1063217 pass218def analyze_ChartDataformat_record(data):219 # 0x1006220 pass221def analyze_ChartDefaulttext_record(data):222 # 0x1024223 pass224def analyze_ChartDropbar_record(data):225 # 0x103D226 pass227def analyze_ChartFbi_record(data):228 # 0x1060229 pass230def analyze_ChartFontx_record(data):231 # 0x1026232 pass233def analyze_ChartFormatlink_record(data):234 # 0x1022235 pass236def analyze_ChartFrame_record(data):237 # 0x1032238 pass239def analyze_ChartGelframe_record(data):240 # 0x1066241 pass242def analyze_ChartIfmt_record(data):243 # 0x104E244 pass245def analyze_ChartLegend_record(data):246 # 0x1015247 pass248def analyze_ChartLegendxn_record(data):249 # 0x1043250 pass251def analyze_ChartLine_record(data):252 # 0x1018253 pass254def analyze_ChartLineformat_record(data):255 # 0x1007256 pass257def analyze_ChartMarkerformat_record(data):258 # 0x1009259 pass260def analyze_ChartObjectLink_record(data):261 # 0x1027262 pass263def analyze_ChartPicf_record(data):264 # 0x103C265 pass266def analyze_ChartPie_record(data):267 # 0x1019268 pass269def analyze_ChartPieformat_record(data):270 # 0x100B271 pass272def analyze_ChartPlotarea_record(data):273 # 0x1035274 pass275def analyze_ChartPlotgrowth_record(data):276 # 0x1064277 pass278def analyze_ChartPos_record(data):279 # 0x104F280 pass281def analyze_ChartRadar_record(data):282 # 0x103E283 pass284def analyze_ChartRadararea_record(data):285 # 0x1040286 pass287def analyze_ChartSbaseref_record(data):288 # 0x1048289 pass290def analyze_ChartScatter_record(data):291 # 0x101B292 pass293def analyze_ChartSerauxerrbar_record(data):294 # 0x105B295 pass296def analyze_ChartSerauxtrend_record(data):297 # 0x104B298 pass299def analyze_ChartSerfmt_record(data):300 # 0x105D301 pass302def analyze_ChartSeries_record(data):303 # 0x1003304 pass305def analyze_ChartSerieslist_record(data):306 # 0x1016307 pass308def analyze_ChartSeriestext_record(data):309 # 0x100D310 pass311def analyze_ChartSerparent_record(data):312 # 0x104A313 pass314def analyze_ChartSertocrt_record(data):315 # 0x1045316 pass317def analyze_ChartShtprops_record(data):318 # 0x1044319 pass320def analyze_ChartSiindex_record(data):321 # 0x1065322 pass323def analyze_ChartSurface_record(data):324 # 0x103F325 pass326def analyze_ChartText_record(data):327 # 0x1025328 pass329def analyze_ChartTick_record(data):330 # 0x101E331 pass332def analyze_ChartValuerange_record(data):333 # 0x101F334 pass335def analyze_DBCELL_record(data):336 # 0x00D7337 pass338def analyze_DCON_record(data):339 # 0x0050340 pass341def analyze_DCONBIN_record(data):342 # 0x01B5343 pass344def analyze_DCONNAME_record(data):345 # 0x0053346 pass347def analyze_DCONREF_record(data):348 # 0x0051349 pass350def analyze_DEFAULTROWHEIGHT_record(data):351 # 0x0025, 0x0225352 pass353def analyze_DEFCOLWIDTH_record(data):354 # 0x0055355 pass356def analyze_DELMENU_record(data):357 # 0x00C3358 pass359def analyze_DELTA_record(data):360 # 0x0010361 pass362def analyze_DIMENSIONS_record(data):363 # 0x0000, 0x0200364 pass365def analyze_DOCROUTE_record(data):366 # 0x00B8367 pass368def analyze_DSF_record(data):369 # 0x0161370 pass371def analyze_DV_record(data):372 # 0x01BE373 pass374def analyze_DVAL_record(data):375 # 0x01B2376 pass377def analyze_EDG_record(data):378 # 0x0088379 pass380def analyze_EFONT_record(data):381 # 0x0045382 pass383def analyze_END_record(data):384 # 0x1034385 pass386def analyze_EOF_record(data):387 # 0x000A388 pass389def analyze_EXTERNCOUNT_record(data):390 # 0x0016391 pass392def analyze_EXTERNNAME_record(data):393 # 0x0023, 0x0223394 pass395def analyze_EXTERNSHEET_record(data):396 # 0x0017397 pass398def analyze_EXTSST_record(data):399 # 0x00FF400 pass401def analyze_FILEPASS_record(data):402 # 0x002F403 pass404def analyze_FILESHARING_record(data):405 # 0x005B406 pass407def analyze_FILTERMODE_record(data):408 # 0x009B409 pass410def analyze_FNGROUPCOUNT_record(data):411 # 0x009C412 pass413def analyze_FNGROUPNAME_record(data):414 # 0x009A415 pass416def analyze_FONT_record(data):417 # 0x0031, 0x0231418 pass419def analyze_FOOTER_record(data):420 # 0x0015421 pass422def analyze_FORMAT_record(data):423 # 0x001E, 0x041E424 fmt_idx = struct.unpack('<H', data[0:2])425 name_len = struct.unpack('<H', data[2:4])426 compressed = data[4] == '\x00'427 print 'format index : 0x%04X' % fmt_idx428 print 'format name len : 0x%04X' % name_len429 print 'compressed UNICODE:', compressed430 name = data[5:]431 if not compressed:432 name = [c for c in name if c != '\x00'] 433 name = ''.join(name)434 print 'format str :', name 435 pass436def analyze_FORMATCOUNT_record(data):437 # 0x001F438 pass439def analyze_FORMULA_record(data):440 # 0x0006, 0x0206, 0x0406441 pass442def analyze_GCW_record(data):443 # 0x00AB444 pass445def analyze_GRIDSET_record(data):446 # 0x0082447 pass448def analyze_GUTS_record(data):449 # 0x0080450 pass451def analyze_HCENTER_record(data):452 # 0x0083453 pass454def analyze_HEADER_record(data):455 # 0x0014456 pass457def analyze_HIDEOBJ_record(data):458 # 0x008D459 pass460def analyze_HLINK_record(data):461 # 0x01B8462 pass463def analyze_HORIZONTALPAGEBREAKS_record(data):464 # 0x001B465 pass466def analyze_IMDATA_record(data):467 # 0x007F468 pass469def analyze_INDEX_record(data):470 # 0x000B, 0x020B471 pass472def analyze_INTEGER_record(data):473 # 0x0002474 pass475def analyze_INTERFACEEND_record(data):476 # 0x00E2477 pass478def analyze_INTERFACEHDR_record(data):479 # 0x00E1480 pass481def analyze_ITERATION_record(data):482 # 0x0011483 pass484def analyze_IXFE_record(data):485 # 0x0044486 pass487def analyze_LABEL_record(data):488 # 0x0004, 0x0204489 pass490def analyze_LABELRANGES_record(data):491 # 0x015F492 pass493def analyze_LABELSST_record(data):494 # 0x00FD495 row, col, xf_idx, sst_idx = struct.unpack('<3HL', data)496 print 'row : 0x%000X' % row497 print 'col : 0x%000X' % col498 print 'xf idx : 0x%000X' % xf_idx499 print 'sst idx : 0x%000X' % sst_idx500 pass501def analyze_LEFTMARGIN_record(data):502 # 0x0026503 print struct.unpack('<d', data)[0]504 pass505def analyze_LHNGRAPH_record(data):506 # 0x0095507 pass508def analyze_LHRECORD_record(data):509 # 0x0094510 pass511def analyze_LPR_record(data):512 # 0x0098513 pass514def analyze_MMS_record(data):515 # 0x00C1516 pass517def analyze_MSODRAWING_record(data):518 # 0x00EC519 pass520def analyze_MSODRAWINGGROUP_record(data):521 # 0x00EB522 pass523def analyze_MSODRAWINGSELECTION_record(data):524 # 0x00ED525 pass526def analyze_MULBLANK_record(data):527 # 0x00BE528 pass529def analyze_MULRK_record(data):530 # 0x00BD531 pass532def analyze_NAME_record(data):533 # 0x0018, 0x0218534 pass535def analyze_NOTE_record(data):536 # 0x001C537 pass538def analyze_NUMBER_record(data):539 # 0x0003, 0x0203540 pass541def analyze_OBJ_record(data):542 # 0x005D543 pass544def analyze_OBJPROTECT_record(data):545 # 0x0063546 pass547def analyze_OBPROJ_record(data):548 # 0x00D3549 pass550def analyze_OLESIZE_record(data):551 # 0x00DE552 pass553def analyze_PALETTE_record(data):554 # 0x0092555 pass556def analyze_PANE_record(data):557 # 0x0041558 pass559def analyze_PASSWORD_record(data):560 # 0x0013561 pass562def analyze_PLS_record(data):563 # 0x004D564 pass565def analyze_PRECISION_record(data):566 # 0x000E567 pass568def analyze_PRINTGRIDLINES_record(data):569 # 0x002B570 pass571def analyze_PRINTHEADERS_record(data):572 # 0x002A573 pass574def analyze_PROT4REV_record(data):575 # 0x01AF576 pass577def analyze_PROT4REVPASS_record(data):578 # 0x01BC579 pass580def analyze_PROTECT_record(data):581 # 0x0012582 pass583def analyze_PUB_record(data):584 # 0x0089585 pass586def analyze_QSI_record(data):587 # 0x01AD588 pass589def analyze_RECALCID_record(data):590 # 0x01C1: 591 pass592def analyze_RECIPNAME_record(data):593 # 0x00B9594 pass595def analyze_REFMODE_record(data):596 # 0x000F597 pass598def analyze_REFRESHALL_record(data):599 # 0x01B7600 pass601def analyze_RIGHTMARGIN_record(data):602 # 0x0027603 print struct.unpack('<d', data)[0]604 pass605def analyze_RK_record(data):606 # 0x007E, 0x027E607 pass608def analyze_ROW_record(data):609 # 0x0008, 0x0208610 idx, col1, col2, height_options, not_used, not_used, options = \611 struct.unpack('<6HL', data)612 print 'row index : 0x%000X' % idx613 print 'start col : 0x%000X' % col1614 print 'last col + 1 : 0x%000X' % col2615 print 'height : 0x%000X' % (height_options & 0x7FFF)616 print 'height is custom : 0x%000X' % ((height_options & 0x8000) >> 15)617 print 'outline level : 0x%000X' % ((options & 0x00000007L) >> 0)618 print 'level collapsed : 0x%000X' % ((options & 0x00000010L) >> 4)619 print 'row is hidden : 0x%000X' % ((options & 0x00000020L) >> 5)620 print 'font height match: 0x%000X' % ((options & 0x00000040L) >> 6)621 print 'default format : 0x%000X' % ((options & 0x00000080L) >> 7)622 print 'default xf index : 0x%000X' % ((options & 0x0FFF0000L) >> 16)623 print 'add space above : 0x%000X' % ((options & 0x10000000L) >> 28)624 print 'add space below : 0x%000X' % ((options & 0x20000000L) >> 29)625def analyze_RSTRING_record(data):626 # 0x00D6627 pass628def analyze_SAFERECALC_record(data):629 # 0x005F630 pass631def analyze_SCENARIO_record(data):632 # 0x00AF633 pass634def analyze_SCENMAN_record(data):635 # 0x00AE636 pass637def analyze_SCENPROTECT_record(data):638 # 0x00DD639 pass640def analyze_SCL_record(data):641 # 0x00A0642 pass643def analyze_SCREENTIP_record(data):644 # 0x0800645 pass646def analyze_SELECTION_record(data):647 # 0x001D648 pass649def analyze_SETUP_record(data):650 # 0x00A1651 pass652def analyze_SHEETLAYOUT_record(data):653 # 0x0862654 pass655def analyze_SHEETPROTECTION_record(data):656 # 0x0867657 pass658def analyze_SHRFMLA_record(data):659 # 0x00BC, 0x04BC660 pass661def analyze_SORT_record(data):662 # 0x0090663 pass664def analyze_SOUND_record(data):665 # 0x0096666 pass667def analyze_SST_record(data):668 # 0x00FC669 pass670def analyze_STANDARDWIDTH_record(data):671 # 0x0099672 pass673def analyze_STRING_record(data):674 # 0x0007, 0x0207675 pass676def analyze_STYLE_record(data):677 # 0x0093, 0x0293678 pass679def analyze_SUB_record(data):680 # 0x0091681 pass682def analyze_SUPBOOK_record(data):683 # 0x01AE684 pass685def analyze_SXDATETIME_record(data):686 # 0x00CE687 pass688def analyze_SXDB_record(data):689 # 0x00C6690 pass691def analyze_SXDBEX_record(data):692 # 0x0122693 pass694def analyze_SXDI_record(data):695 # 0x00C5696 pass697def analyze_SXDOUBLE_record(data):698 # 0x00C9699 pass700def analyze_SXEX_record(data):701 # 0x00F1702 pass703def analyze_SXEXT_PARAMQRY_record(data):704 # 0x00DC705 pass706def analyze_SXFDBTYPE_record(data):707 # 0x01BB708 pass709def analyze_SXFIELD_record(data):710 # 0x00C7711 pass712def analyze_SXFILT_record(data):713 # 0x00F2714 pass715def analyze_SXFMLA_record(data):716 # 0x00F9717 pass718def analyze_SXFORMAT_record(data):719 # 0x00FB720 pass721def analyze_SXFORMULA_record(data):722 # 0x0103723 pass724def analyze_SXIDSTM_record(data):725 # 0x00D5726 pass727def analyze_SXINDEXLIST_record(data):728 # 0x00C8729 pass730def analyze_SXIVD_record(data):731 # 0x00B4732 pass733def analyze_SXLI_record(data):734 # 0x00B5735 pass736def analyze_SXNAME_record(data):737 # 0x00F6738 pass739def analyze_SXPAIR_record(data):740 # 0x00F8741 pass742def analyze_SXPI_record(data):743 # 0x00B6744 pass745def analyze_SXRULE_record(data):746 # 0x00F0747 pass748def analyze_SXSELECT_record(data):749 # 0x00F7750 pass751def analyze_SXSTRING_record(data):752 # 0x00CD753 pass754def analyze_SXTBL_record(data):755 # 0x00D0756 pass757def analyze_SXTBPG_record(data):758 # 0x00D2759 pass760def analyze_SXTBRGITEM_record(data):761 # 0x00D1762 pass763def analyze_SXVD_record(data):764 # 0x00B1765 pass766def analyze_SXVDEX_record(data):767 # 0x0100768 pass769def analyze_SXVI_record(data):770 # 0x00B2771 pass772def analyze_SXVIEW_record(data):773 # 0x00B0774 pass775def analyze_SXVS_record(data):776 # 0x00E3777 pass778def analyze_TABID_record(data):779 # 0x013D780 pass781def analyze_TABLE_record(data):782 # 0x0036, 0x0236783 pass784def analyze_TEMPLATE_record(data):785 # 0x0060786 pass787def analyze_TOPMARGIN_record(data):788 # 0x0028789 print struct.unpack('<d', data)[0]790 pass791def analyze_TXO_record(data):792 # 0x01B6793 pass794def analyze_UDDESC_record(data):795 # 0x00DF796 pass797def analyze_UNCALCED_record(data):798 # 0x005E799 pass800def analyze_UNITS_record(data):801 # 0x1001802 pass803def analyze_USERBVIEW_record(data):804 # 0x01A9805 pass806def analyze_USERSVIEWBEGIN_record(data):807 # 0x01AA808 pass809def analyze_USERSVIEWEND_record(data):810 # 0x01AB811 pass812def analyze_USESELFS_record(data):813 # 0x0160814 pass815def analyze_VCENTER_record(data):816 # 0x0084817 pass818def analyze_VERTICALPAGEBREAKS_record(data):819 # 0x001A820 pass821def analyze_WEBQRYSETTINGS_record(data):822 # 0x0803823 pass824def analyze_WEBQRYTABLES_record(data):825 # 0x0804826 pass827def analyze_WINDOW1_record(data):828 # 0x003D829 pass830def analyze_WINDOW2_record(data):831 # 0x003E, 0x023E832 pass833def analyze_WINDOWPROTECT_record(data):834 # 0x0019835 pass836def analyze_WRITEACCESS_record(data):837 # 0x005C838 pass839def analyze_WRITEPROT_record(data):840 # 0x0086841 pass842def analyze_WSBOOL_record(data):843 # 0x0081844 pass845def analyze_XCT_record(data):846 # 0x0059847 pass848def analyze_XF_record(data):849 # 0x0043, 0x00E0, 0x0243, 0x0443850 #fnt_idx, num_ftm_idx, \851 # cell_prot, \852 # align, rotation, txt_format, \853 # used_attrib, \854 # border0, border1, border2 = struct.unpack('<3H4B2LH', data)855 #print 'fnt idx : 0x%000X' % fnt_idx856 #print 'num fmt idx : 0x%000X' % num_ftm_idx857 #print 'cell is locked : 0x%0X ' % ((cell_prot) & 0x01)858 #print 'format is hidden : 0x%0X ' % ((cell_prot & 0x02) >> 1)859 #print 'style XF(1), cell XF(0) : 0x%0X ' % ((cell_prot & 0x03) >> 3)860 #print 'Index to parent style XF: 0x%0000X' % ((cell_prot & 0xFFF0) >> 4)861 pass862def analyze_XL5MODIFY_record(data):863 # 0x0162864 pass865def analyze_XL9FILE_record(data):866 # 0x01C0: 867 pass868all_records = {869 0x0000: ('DIMENSIONS', analyze_DIMENSIONS_record),870 0x0001: ('BLANK', analyze_BLANK_record),871 0x0002: ('INTEGER', analyze_INTEGER_record),872 0x0003: ('NUMBER', analyze_NUMBER_record),873 0x0004: ('LABEL', analyze_LABEL_record),874 0x0005: ('BOOLERR', analyze_BOOLERR_record),875 0x0006: ('FORMULA', analyze_FORMULA_record),876 0x0007: ('STRING', analyze_STRING_record),877 0x0008: ('ROW', analyze_ROW_record),878 0x0009: ('BOF', analyze_BOF_record),879 0x000A: ('EOF', analyze_EOF_record),880 0x000B: ('INDEX', analyze_INDEX_record),881 0x000C: ('CALCCOUNT', analyze_CALCCOUNT_record),882 0x000D: ('CALCMODE', analyze_CALCMODE_record),883 0x000E: ('PRECISION', analyze_PRECISION_record),884 0x000F: ('REFMODE', analyze_REFMODE_record),885 0x0010: ('DELTA', analyze_DELTA_record),886 0x0011: ('ITERATION', analyze_ITERATION_record),887 0x0012: ('PROTECT', analyze_PROTECT_record),888 0x0013: ('PASSWORD', analyze_PASSWORD_record),889 0x0014: ('HEADER', analyze_HEADER_record),890 0x0015: ('FOOTER', analyze_FOOTER_record),891 0x0016: ('EXTERNCOUNT', analyze_EXTERNCOUNT_record),892 0x0017: ('EXTERNSHEET', analyze_EXTERNSHEET_record),893 0x0018: ('NAME', analyze_NAME_record),894 0x0019: ('WINDOWPROTECT', analyze_WINDOWPROTECT_record),895 0x001A: ('VERTICALPAGEBREAKS', analyze_VERTICALPAGEBREAKS_record),896 0x001B: ('HORIZONTALPAGEBREAKS', analyze_HORIZONTALPAGEBREAKS_record),897 0x001C: ('NOTE', analyze_NOTE_record),898 0x001D: ('SELECTION', analyze_SELECTION_record),899 0x001E: ('FORMAT', analyze_FORMAT_record),900 0x001F: ('FORMATCOUNT', analyze_FORMATCOUNT_record),901 0x0020: ('COLUMNDEFAULT', analyze_COLUMNDEFAULT_record),902 0x0021: ('ARRAY', analyze_ARRAY_record),903 0x0022: ('1904', analyze_1904_record),904 0x0023: ('EXTERNNAME', analyze_EXTERNNAME_record),905 0x0024: ('COLWIDTH', analyze_COLWIDTH_record),906 0x0025: ('DEFAULTROWHEIGHT', analyze_DEFAULTROWHEIGHT_record),907 0x0026: ('LEFTMARGIN', analyze_LEFTMARGIN_record),908 0x0027: ('RIGHTMARGIN', analyze_RIGHTMARGIN_record),909 0x0028: ('TOPMARGIN', analyze_TOPMARGIN_record),910 0x0029: ('BOTTOMMARGIN', analyze_BOTTOMMARGIN_record),911 0x002A: ('PRINTHEADERS', analyze_PRINTHEADERS_record),912 0x002B: ('PRINTGRIDLINES', analyze_PRINTGRIDLINES_record),913 0x002F: ('FILEPASS', analyze_FILEPASS_record),914 0x0031: ('FONT', analyze_FONT_record),915 0x0036: ('TABLE', analyze_TABLE_record),916 0x003C: ('CONTINUE', analyze_CONTINUE_record),917 0x003D: ('WINDOW1', analyze_WINDOW1_record),918 0x003E: ('WINDOW2', analyze_WINDOW2_record),919 0x0040: ('BACKUP', analyze_BACKUP_record),920 0x0041: ('PANE', analyze_PANE_record),921 0x0042: ('CODEPAGE', analyze_CODEPAGE_record),922 0x0043: ('XF', analyze_XF_record),923 0x0044: ('IXFE', analyze_IXFE_record),924 0x0045: ('EFONT', analyze_EFONT_record),925 0x004D: ('PLS', analyze_PLS_record),926 0x0050: ('DCON', analyze_DCON_record),927 0x0051: ('DCONREF', analyze_DCONREF_record),928 0x0053: ('DCONNAME', analyze_DCONNAME_record),929 0x0055: ('DEFCOLWIDTH', analyze_DEFCOLWIDTH_record),930 0x0056: ('BUILTINFMTCNT', analyze_BUILTINFMTCNT_record),931 0x0059: ('XCT', analyze_XCT_record),932 0x005A: ('CRN', analyze_CRN_record),933 0x005B: ('FILESHARING', analyze_FILESHARING_record),934 0x005C: ('WRITEACCESS', analyze_WRITEACCESS_record),935 0x005D: ('OBJ', analyze_OBJ_record),936 0x005E: ('UNCALCED', analyze_UNCALCED_record),937 0x005F: ('SAFERECALC', analyze_SAFERECALC_record),938 0x0060: ('TEMPLATE', analyze_TEMPLATE_record),939 0x0063: ('OBJPROTECT', analyze_OBJPROTECT_record),940 0x007D: ('COLINFO', analyze_COLINFO_record),941 0x007E: ('RK', analyze_RK_record),942 0x007F: ('IMDATA', analyze_IMDATA_record),943 0x0080: ('GUTS', analyze_GUTS_record),944 0x0081: ('WSBOOL', analyze_WSBOOL_record),945 0x0082: ('GRIDSET', analyze_GRIDSET_record),946 0x0083: ('HCENTER', analyze_HCENTER_record),947 0x0084: ('VCENTER', analyze_VCENTER_record),948 0x0085: ('BOUNDSHEET', analyze_BOUNDSHEET_record),949 0x0086: ('WRITEPROT', analyze_WRITEPROT_record),950 0x0087: ('ADDIN', analyze_ADDIN_record),951 0x0088: ('EDG', analyze_EDG_record),952 0x0089: ('PUB', analyze_PUB_record),953 0x008C: ('COUNTRY', analyze_COUNTRY_record),954 0x008D: ('HIDEOBJ', analyze_HIDEOBJ_record),955 0x008E: ('BUNDLESOFFSET', analyze_BUNDLESOFFSET_record),956 0x008F: ('BUNDLEHEADER', analyze_BUNDLEHEADER_record),957 0x0090: ('SORT', analyze_SORT_record),958 0x0091: ('SUB', analyze_SUB_record),959 0x0092: ('PALETTE', analyze_PALETTE_record),960 0x0093: ('STYLE', analyze_STYLE_record),961 0x0094: ('LHRECORD', analyze_LHRECORD_record),962 0x0095: ('LHNGRAPH', analyze_LHNGRAPH_record),963 0x0096: ('SOUND', analyze_SOUND_record),964 0x0098: ('LPR', analyze_LPR_record),965 0x0099: ('STANDARDWIDTH', analyze_STANDARDWIDTH_record),966 0x009A: ('FNGROUPNAME', analyze_FNGROUPNAME_record),967 0x009B: ('FILTERMODE', analyze_FILTERMODE_record),968 0x009C: ('FNGROUPCOUNT', analyze_FNGROUPCOUNT_record),969 0x009D: ('AUTOFILTERINFO', analyze_AUTOFILTERINFO_record),970 0x009E: ('AUTOFILTER', analyze_AUTOFILTER_record),971 0x00A0: ('SCL', analyze_SCL_record),972 0x00A1: ('SETUP', analyze_SETUP_record),973 0x00A9: ('COORDLIST', analyze_COORDLIST_record),974 0x00AB: ('GCW', analyze_GCW_record),975 0x00AE: ('SCENMAN', analyze_SCENMAN_record),976 0x00AF: ('SCENARIO', analyze_SCENARIO_record),977 0x00B0: ('SXVIEW', analyze_SXVIEW_record),978 0x00B1: ('SXVD', analyze_SXVD_record),979 0x00B2: ('SXVI', analyze_SXVI_record),980 0x00B4: ('SXIVD', analyze_SXIVD_record),981 0x00B5: ('SXLI', analyze_SXLI_record),982 0x00B6: ('SXPI', analyze_SXPI_record),983 0x00B8: ('DOCROUTE', analyze_DOCROUTE_record),984 0x00B9: ('RECIPNAME', analyze_RECIPNAME_record),985 0x00BC: ('SHRFMLA', analyze_SHRFMLA_record),986 0x00BD: ('MULRK', analyze_MULRK_record),987 0x00BE: ('MULBLANK', analyze_MULBLANK_record),988 0x00C1: ('MMS', analyze_MMS_record),989 0x00C2: ('ADDMENU', analyze_ADDMENU_record),990 0x00C3: ('DELMENU', analyze_DELMENU_record),991 0x00C5: ('SXDI', analyze_SXDI_record),992 0x00C6: ('SXDB', analyze_SXDB_record),993 0x00C7: ('SXFIELD', analyze_SXFIELD_record),994 0x00C8: ('SXINDEXLIST', analyze_SXINDEXLIST_record),995 0x00C9: ('SXDOUBLE', analyze_SXDOUBLE_record),996 0x00CD: ('SXSTRING', analyze_SXSTRING_record),997 0x00CE: ('SXDATETIME', analyze_SXDATETIME_record),998 0x00D0: ('SXTBL', analyze_SXTBL_record),999 0x00D1: ('SXTBRGITEM', analyze_SXTBRGITEM_record),1000 0x00D2: ('SXTBPG', analyze_SXTBPG_record),1001 0x00D3: ('OBPROJ', analyze_OBPROJ_record),1002 0x00D5: ('SXIDSTM', analyze_SXIDSTM_record),1003 0x00D6: ('RSTRING', analyze_RSTRING_record),1004 0x00D7: ('DBCELL', analyze_DBCELL_record),1005 0x00DA: ('BOOKBOOL', analyze_BOOKBOOL_record),1006 0x00DC: ('SXEXT|PARAMQRY', analyze_SXEXT_PARAMQRY_record),1007 0x00DD: ('SCENPROTECT', analyze_SCENPROTECT_record),1008 0x00DE: ('OLESIZE', analyze_OLESIZE_record),1009 0x00DF: ('UDDESC', analyze_UDDESC_record),1010 0x00E0: ('XF', analyze_XF_record),1011 0x00E1: ('INTERFACEHDR', analyze_INTERFACEHDR_record),1012 0x00E2: ('INTERFACEEND', analyze_INTERFACEEND_record),1013 0x00E3: ('SXVS', analyze_SXVS_record),1014 0x00E5: ('MERGEDCELLS', analyze_MERGEDCELLS_record),1015 0x00E9: ('BITMAP', analyze_BITMAP_record),1016 0x00EB: ('MSODRAWINGGROUP', analyze_MSODRAWINGGROUP_record),1017 0x00EC: ('MSODRAWING', analyze_MSODRAWING_record),1018 0x00ED: ('MSODRAWINGSELECTION', analyze_MSODRAWINGSELECTION_record),1019 0x00F0: ('SXRULE', analyze_SXRULE_record),1020 0x00F1: ('SXEX', analyze_SXEX_record),1021 0x00F2: ('SXFILT', analyze_SXFILT_record),1022 0x00F6: ('SXNAME', analyze_SXNAME_record),1023 0x00F7: ('SXSELECT', analyze_SXSELECT_record),1024 0x00F8: ('SXPAIR', analyze_SXPAIR_record),1025 0x00F9: ('SXFMLA', analyze_SXFMLA_record),1026 0x00FB: ('SXFORMAT', analyze_SXFORMAT_record),1027 0x00FC: ('SST', analyze_SST_record),1028 0x00FD: ('LABELSST', analyze_LABELSST_record),1029 0x00FF: ('EXTSST', analyze_EXTSST_record),1030 0x0100: ('SXVDEX', analyze_SXVDEX_record),1031 0x0103: ('SXFORMULA', analyze_SXFORMULA_record),1032 0x0122: ('SXDBEX', analyze_SXDBEX_record),1033 0x0137: ('CHTRINSERT', analyze_CHTRINSERT_record),1034 0x0138: ('CHTRINFO', analyze_CHTRINFO_record),1035 0x013B: ('CHTRCELLCONTENT', analyze_CHTRCELLCONTENT_record),1036 0x013D: ('TABID', analyze_TABID_record),1037 0x0140: ('CHTRMOVERANGE', analyze_CHTRMOVERANGE_record),1038 0x014D: ('CHTRINSERTTAB', analyze_CHTRINSERTTAB_record),1039 0x015F: ('LABELRANGES', analyze_LABELRANGES_record),1040 0x0160: ('USESELFS', analyze_USESELFS_record),1041 0x0161: ('DSF', analyze_DSF_record),1042 0x0162: ('XL5MODIFY', analyze_XL5MODIFY_record),1043 0x0196: ('CHTRHEADER', analyze_CHTRHEADER_record),1044 0x01A9: ('USERBVIEW', analyze_USERBVIEW_record),1045 0x01AA: ('USERSVIEWBEGIN', analyze_USERSVIEWBEGIN_record),1046 0x01AB: ('USERSVIEWEND', analyze_USERSVIEWEND_record),1047 0x01AD: ('QSI', analyze_QSI_record),1048 0x01AE: ('SUPBOOK', analyze_SUPBOOK_record),1049 0x01AF: ('PROT4REV', analyze_PROT4REV_record),1050 0x01B0: ('CONDFMT', analyze_CONDFMT_record),1051 0x01B1: ('CF', analyze_CF_record),1052 0x01B2: ('DVAL', analyze_DVAL_record),1053 0x01B5: ('DCONBIN', analyze_DCONBIN_record),1054 0x01B6: ('TXO', analyze_TXO_record),1055 0x01B7: ('REFRESHALL', analyze_REFRESHALL_record),1056 0x01B8: ('HLINK', analyze_HLINK_record),1057 0x01BA: ('CODENAME', analyze_CODENAME_record),1058 0x01BB: ('SXFDBTYPE', analyze_SXFDBTYPE_record),1059 0x01BC: ('PROT4REVPASS', analyze_PROT4REVPASS_record),1060 0x01BE: ('DV', analyze_DV_record),1061 0x01C0: ('XL9FILE', analyze_XL9FILE_record),1062 0x01C1: ('RECALCID',analyze_RECALCID_record),1063 0x0200: ('DIMENSIONS', analyze_DIMENSIONS_record),1064 0x0201: ('BLANK', analyze_BLANK_record),1065 0x0203: ('NUMBER', analyze_NUMBER_record),1066 0x0204: ('LABEL', analyze_LABEL_record),1067 0x0205: ('BOOLERR', analyze_BOOLERR_record),1068 0x0206: ('FORMULA', analyze_FORMULA_record),1069 0x0207: ('STRING', analyze_STRING_record),1070 0x0208: ('ROW', analyze_ROW_record),1071 0x0209: ('BOF', analyze_BOF_record),1072 0x020B: ('INDEX', analyze_INDEX_record),1073 0x0218: ('NAME', analyze_NAME_record),1074 0x0221: ('ARRAY', analyze_ARRAY_record),1075 0x0223: ('EXTERNNAME', analyze_EXTERNNAME_record),1076 0x0225: ('DEFAULTROWHEIGHT', analyze_DEFAULTROWHEIGHT_record),1077 0x0231: ('FONT', analyze_FONT_record),1078 0x0236: ('TABLE', analyze_TABLE_record),1079 0x023E: ('WINDOW2', analyze_WINDOW2_record),1080 0x0243: ('XF', analyze_XF_record),1081 0x027E: ('RK', analyze_RK_record),1082 0x0293: ('STYLE', analyze_STYLE_record),1083 0x0406: ('FORMULA', analyze_FORMULA_record),1084 0x0409: ('BOF', analyze_BOF_record),1085 0x041E: ('FORMAT', analyze_FORMAT_record),1086 0x0443: ('XF', analyze_XF_record),1087 0x04BC: ('SHRFMLA', analyze_SHRFMLA_record),1088 0x0800: ('SCREENTIP', analyze_SCREENTIP_record),1089 0x0803: ('WEBQRYSETTINGS', analyze_WEBQRYSETTINGS_record),1090 0x0804: ('WEBQRYTABLES', analyze_WEBQRYTABLES_record),1091 0x0809: ('BOF', analyze_BOF_record),1092 0x0862: ('SHEETLAYOUT', analyze_SHEETLAYOUT_record),1093 0x0867: ('SHEETPROTECTION', analyze_SHEETPROTECTION_record),1094 0x1001: ('UNITS', analyze_UNITS_record),1095 0x1002: ('ChartChart', analyze_ChartChart_record),1096 0x1003: ('ChartSeries', analyze_ChartSeries_record),1097 0x1006: ('ChartDataformat', analyze_ChartDataformat_record),1098 0x1007: ('ChartLineformat', analyze_ChartLineformat_record),1099 0x1009: ('ChartMarkerformat', analyze_ChartMarkerformat_record),1100 0x100A: ('ChartAreaformat', analyze_ChartAreaformat_record),1101 0x100B: ('ChartPieformat', analyze_ChartPieformat_record),1102 0x100C: ('ChartAttachedlabel', analyze_ChartAttachedlabel_record),1103 0x100D: ('ChartSeriestext', analyze_ChartSeriestext_record),1104 0x1014: ('ChartChartformat', analyze_ChartChartformat_record),1105 0x1015: ('ChartLegend', analyze_ChartLegend_record),1106 0x1016: ('ChartSerieslist', analyze_ChartSerieslist_record),1107 0x1017: ('ChartBar', analyze_ChartBar_record),1108 0x1018: ('ChartLine', analyze_ChartLine_record),1109 0x1019: ('ChartPie', analyze_ChartPie_record),1110 0x101A: ('ChartArea', analyze_ChartArea_record),1111 0x101B: ('ChartScatter', analyze_ChartScatter_record),1112 0x101C: ('ChartChartline', analyze_ChartChartline_record),1113 0x101D: ('ChartAxis', analyze_ChartAxis_record),1114 0x101E: ('ChartTick', analyze_ChartTick_record),1115 0x101F: ('ChartValuerange', analyze_ChartValuerange_record),1116 0x1020: ('ChartCatserrange', analyze_ChartCatserrange_record),1117 0x1021: ('ChartAxislineformat', analyze_ChartAxislineformat_record),1118 0x1022: ('ChartFormatlink', analyze_ChartFormatlink_record),1119 0x1024: ('ChartDefaulttext', analyze_ChartDefaulttext_record),1120 0x1025: ('ChartText', analyze_ChartText_record),1121 0x1026: ('ChartFontx', analyze_ChartFontx_record),1122 0x1027: ('ChartObjectLink', analyze_ChartObjectLink_record),1123 0x1032: ('ChartFrame', analyze_ChartFrame_record),1124 0x1033: ('BEGIN', analyze_BEGIN_record),1125 0x1034: ('END', analyze_END_record),1126 0x1035: ('ChartPlotarea', analyze_ChartPlotarea_record),1127 0x103A: ('Chart3D', analyze_Chart3D_record),1128 0x103C: ('ChartPicf', analyze_ChartPicf_record),1129 0x103D: ('ChartDropbar', analyze_ChartDropbar_record),1130 0x103E: ('ChartRadar', analyze_ChartRadar_record),1131 0x103F: ('ChartSurface', analyze_ChartSurface_record),1132 0x1040: ('ChartRadararea', analyze_ChartRadararea_record),1133 0x1041: ('ChartAxisparent', analyze_ChartAxisparent_record),1134 0x1043: ('ChartLegendxn', analyze_ChartLegendxn_record),1135 0x1044: ('ChartShtprops', analyze_ChartShtprops_record),1136 0x1045: ('ChartSertocrt', analyze_ChartSertocrt_record),1137 0x1046: ('ChartAxesused', analyze_ChartAxesused_record),1138 0x1048: ('ChartSbaseref', analyze_ChartSbaseref_record),1139 0x104A: ('ChartSerparent', analyze_ChartSerparent_record),1140 0x104B: ('ChartSerauxtrend', analyze_ChartSerauxtrend_record),1141 0x104E: ('ChartIfmt', analyze_ChartIfmt_record),1142 0x104F: ('ChartPos', analyze_ChartPos_record),1143 0x1050: ('ChartAlruns', analyze_ChartAlruns_record),1144 0x1051: ('ChartAI', analyze_ChartAI_record),1145 0x105B: ('ChartSerauxerrbar', analyze_ChartSerauxerrbar_record),1146 0x105D: ('ChartSerfmt', analyze_ChartSerfmt_record),1147 0x105F: ('Chart3DDataFormat', analyze_Chart3DDataFormat_record),1148 0x1060: ('ChartFbi', analyze_ChartFbi_record),1149 0x1061: ('ChartBoppop', analyze_ChartBoppop_record),1150 0x1062: ('ChartAxcext', analyze_ChartAxcext_record),1151 0x1063: ('ChartDat', analyze_ChartDat_record),1152 0x1064: ('ChartPlotgrowth', analyze_ChartPlotgrowth_record),1153 0x1065: ('ChartSiindex', analyze_ChartSiindex_record),1154 0x1066: ('ChartGelframe', analyze_ChartGelframe_record),1155 0x1067: ('ChartBoppcustom', analyze_ChartBoppcustom_record),1156 0xFFFF: ('', None)1157}1158if __name__ == '__main__':1159 for r in all_records:1160 if all_records[r][1]:1161 all_records[r][1]('analyze it!')...
etgen.py
Source:etgen.py
1import clr2if clr.use35:3 clr.AddReference("Microsoft.Scripting.Core")4 import Microsoft.Scripting.Ast as Exprs5else:6 clr.AddReference("System.Core")7 import System.Linq.Expressions as Exprs8from System.Collections.Generic import IEnumerable9from System.Dynamic import CallInfo10import System11import parser12import runtime13import lexer14### AnalyzeExpr performs semantic checkind and name binding on the expression.15### It returns an Expression.16###17#def AnalyzeExpr (expr, scope):18# expr.Analyze(scope)19# dict[type(expr)](scope)20#21#def AnalyzeImportExpr (self, scope):22# pass23#parser.SymplImportExpr.Analyze = AnalyzeImportExpr24###25def AnalyzeExpr (expr, scope):26 exprtype = type(expr)27 debugprint("exprtype: ", exprtype)28 if exprtype is parser.SymplImportExpr:29 return AnalyzeImportExpr(expr, scope)30 elif exprtype is parser.SymplFunCallExpr:31 return AnalyzeFunCallExpr(expr, scope)32 elif exprtype is parser.SymplDefunExpr:33 return AnalyzeDefunExpr(expr, scope)34 elif exprtype is parser.SymplLambdaExpr:35 return AnalyzeLambdaExpr(expr, scope)36 elif exprtype is parser.SymplIdExpr:37 return AnalyzeIdExpr(expr, scope)38 elif exprtype is parser.SymplQuoteExpr:39 return AnalyzeQuoteExpr(expr, scope)40 elif exprtype is parser.SymplLiteralExpr:41 return Exprs.Expression.Constant(expr.Value)42 elif exprtype is parser.SymplAssignExpr:43 return AnalyzeAssignExpr(expr, scope)44 elif exprtype is parser.SymplLetStarExpr:45 return AnalyzeLetStarExpr(expr, scope)46 elif exprtype is parser.SymplBlockExpr:47 return AnalyzeBlockExpr(expr, scope)48 elif exprtype is parser.SymplEqExpr:49 return AnalyzeEqExpr(expr, scope)50 elif exprtype is parser.SymplConsExpr:51 return AnalyzeConsExpr(expr, scope)52 elif exprtype is parser.SymplListCallExpr:53 return AnalyzeListCallExpr(expr, scope)54 elif exprtype is parser.SymplIfExpr:55 return AnalyzeIfExpr(expr, scope)56 elif exprtype is parser.SymplDottedExpr:57 return AnalyzeDottedExpr(expr, scope)58 elif exprtype is parser.SymplLoopExpr:59 return AnalyzeLoopExpr(expr, scope)60 elif exprtype is parser.SymplBreakExpr:61 return AnalyzeBreakExpr(expr, scope)62 elif exprtype is parser.SymplEltExpr:63 return AnalyzeEltExpr(expr, scope)64 elif exprtype is parser.SymplNewExpr:65 return AnalyzeNewExpr(expr, scope)66 elif exprtype is parser.SymplBinaryExpr:67 return AnalyzeBinaryExpr(expr, scope)68 elif exprtype is parser.SymplUnaryExpr:69 return AnalyzeUnaryExpr(expr, scope)70 else:71 raise Exception("Internal: no expression to analyze -- " +72 repr(expr))73### Returns a call to the import runtime helper function.74###75def AnalyzeImportExpr (expr, scope):76 debugprint("analyze import ...")77 if type(expr) is not parser.SymplImportExpr:78 raise Exception("Internal: need import expr to analyze.")79 if not scope.IsModule():80 raise Exception("Import expression must be a top level expression.")81 return runtime.MakeSymplImportCall(scope.RuntimeExpr, scope.ModuleExpr,82 expr.NamespaceExpr, expr.MemberNames,83 expr.Renames)84def AnalyzeDefunExpr (expr, scope):85 debugprint("analyze defun ...", expr.Name.Name)86 if type(expr) is not parser.SymplDefunExpr:87 raise Exception("Internal: need defun to analyze.")88 if not scope.IsModule():89 raise Exception("Use Defmethod or Lambda when not defining " +90 "top-level function.")91 return Exprs.Expression.Dynamic(92 scope.GetRuntime().GetSetMemberBinder(expr.Name.Name), 93 object,94 [scope.ModuleExpr, 95 AnalyzeLambdaDef(expr, scope, "defun " + expr.Name.Name)])96def AnalyzeLambdaExpr (expr, scope):97 debugprint("analyze lambda ...")98 if type(expr) is not parser.SymplLambdaExpr:99 raise Exception("Internal: need lambda to analyze.")100 return AnalyzeLambdaDef(expr, scope, "lambda")101def AnalyzeLambdaDef (expr, scope, description):102 funscope = AnalysisScope(scope, description)103 funscope.IsLambda = True # needed for return support.104 paramsInOrder = []105 for p in expr.Params:106 var = Exprs.Expression.Parameter(object, p.Name)107 paramsInOrder.append(var)108 funscope.Names[p.Name.lower()] = var109 ## No need to add fun name to module scope since recursive call just looks110 ## up global name late bound. For lambdas,to get the effect of flet to111 ## support recursion, bind a variable to nil and then set it to a lambda.112 ## Then the lambda's body can refer to the let bound var in its def.113 body = []114 for e in expr.Body:115 body.append(AnalyzeExpr(e, funscope))116 return Exprs.Expression.Lambda(117 Exprs.Expression.GetFuncType(118 System.Array[System.Type](119 [object] * (len(expr.Params) + 1))),120 ## Due to .NET 4.0 co/contra-variance, IPy's binding isn't picking121 ## the overload with just IEnumerable<Expr>, so pick it explicitly.122 Exprs.Expression.Block.Overloads[IEnumerable[Exprs.Expression]](body),123 paramsInOrder)124### Returns a dynamic InvokeMember or Invoke expression, depending on the125### Function expression.126###127def AnalyzeFunCallExpr (expr, scope):128 debugprint("analyze function ...", expr.Function)129 if type(expr) is not parser.SymplFunCallExpr:130 raise Exception("Internal: need function call to analyze.")131 if type(expr.Function) is parser.SymplDottedExpr:132 if len(expr.Function.Exprs) > 1:133 objExpr = AnalyzeDottedExpr(134 parser.SymplDottedExpr(expr.Function.ObjectExpr,135 expr.Function.Exprs[:-1]),136 scope)137 else:138 objExpr = AnalyzeExpr(expr.Function.ObjectExpr, scope)139 args = [AnalyzeExpr(a, scope) for a in expr.Arguments]140 return Exprs.Expression.Dynamic(141 scope.GetRuntime().GetInvokeMemberBinder(142 runtime.InvokeMemberBinderKey(143 ## Last must be ID.144 expr.Function.Exprs[-1].IdToken.Name,145 CallInfo(len(args)))),146 object,147 [objExpr] + args)148 else:149 fun = AnalyzeExpr(expr.Function, scope)150 args = [AnalyzeExpr(a, scope) for a in expr.Arguments]151 ## Use DynExpr so that I don't always have to have a delegate to call,152 ## such as what happens with IPy interop.153 return Exprs.Expression.Dynamic(154 scope.GetRuntime().GetInvokeBinder(CallInfo(len(args))),155 object,156 [fun] + args)157### Returns a chain of GetMember and InvokeMember dynamic expressions for158### the dotted expr.159###160def AnalyzeDottedExpr (expr, scope):161 debugprint("analyze dotted ...", expr.ObjectExpr)162 if type(expr) is not parser.SymplDottedExpr:163 raise Exception("Internal: need dotted expr to analyze.")164 curExpr = AnalyzeExpr(expr.ObjectExpr, scope)165 for e in expr.Exprs:166 if type(e) is parser.SymplIdExpr:167 tmp = Exprs.Expression.Dynamic(168 scope.GetRuntime().GetGetMemberBinder(e.IdToken.Name),169 object, [curExpr])170 elif type(e) is parser.SymplFunCallExpr:171 tmp = Exprs.Expression.Dynamic(172 scope.GetRuntime().GetInvokeMemberBinder(173 runtime.InvokeMemberBinderKey(174 ## Dotted exprs must be simple invoke members,175 ## a.b.(c ...), that is, function is identifier.176 e.Function.IdToken.Name,177 CallInfo(len(e.Arguments)))),178 object,179 [curExpr] + e.Arguments)180 else:181 raise Exception("Internal: dotted must be IDs or Funs.")182 curExpr = tmp183 return curExpr184### AnalyzeAssignExpr handles IDs, indexing, and member sets. IDs are either185### lexical or dynamic exprs on the module scope (ExpandoObject). Everything186### else is dynamic.187###188def AnalyzeAssignExpr (expr, scope):189 debugprint("analyze expr ...", expr.Location)190 loctype = type(expr.Location)191 if loctype is parser.SymplIdExpr:192 lhs = AnalyzeExpr(expr.Location, scope)193 val = AnalyzeExpr(expr.Value, scope)194 param = _findIdDef(expr.Location.IdToken.Name, scope)195 if param is not None:196 return Exprs.Expression.Assign(197 lhs,198 Exprs.Expression.Convert(val, param.Type))199 else:200 tmp = Exprs.Expression.Parameter(object, "assignTmpForRes")201 return Exprs.Expression.Block([tmp], [202 Exprs.Expression.Assign(203 tmp,204 Exprs.Expression.Convert(val, object)),205 Exprs.Expression.Dynamic(206 scope.GetRuntime().GetSetMemberBinder(207 expr.Location.IdToken.Name), 208 object,209 [scope.GetModuleExpr(), tmp]),210 tmp])211 elif loctype is parser.SymplEltExpr:212 obj = AnalyzeExpr(expr.Location.ObjectExpr, scope)213 args = [AnalyzeExpr(x, scope) for x in expr.Location.Indexes]214 args.append(AnalyzeExpr(expr.Value, scope))215 return Exprs.Expression.Dynamic(216 scope.GetRuntime().GetSetIndexBinder(217 CallInfo(len(expr.Location.Indexes))), 218 object,219 [obj] + args)220 elif loctype is parser.SymplDottedExpr:221 ## For now, one dot only. Later, pick oflast dotted member222 ## access (like AnalyzeFunctionCall), and use a temp and block.223 if len(expr.Location.Exprs) > 1:224 raise Exception("Don't support assigning with more than simple " +225 "dotted expression, o.foo.")226 if not isinstance(expr.Location.Exprs[0], parser.SymplIdExpr):227 raise Exception("Only support unindexed field or property when " +228 "assigning dotted expression location.")229 return Exprs.Expression.Dynamic(230 scope.GetRuntime().GetSetMemberBinder(231 expr.Location.Exprs[0].IdToken.Name),232 object,233 [AnalyzeExpr(expr.Location.ObjectExpr, scope),234 AnalyzeExpr(expr.Value, scope)])235### Return an Expression for referencing the ID. If we find the name in the236### scope chain, then we just return the stored ParamExpr. Otherwise, the237### reference is a dynamic member lookup on the root scope, a module object.238###239def AnalyzeIdExpr (expr, scope):240 debugprint("analyze ID ...", expr.IdToken.Name)241 if type(expr) is not parser.SymplIdExpr:242 raise Exception("Internal: need ID Expr to analyze.")243 if expr.IdToken.IsKeywordToken:244 if expr.IdToken is parser.lexer.KeywordToken.Nil:245 return Exprs.Expression.Constant(None, object)246 elif expr.IdToken is parser.lexer.KeywordToken.True:247 return Exprs.Expression.Constant(True)248 elif expr.IdToken is parser.lexer.KeywordToken.False:249 return Exprs.Expression.Constant(False)250 else:251 raise Exception("Internal: unrecognized keyword literal constant.")252 else:253 param = _findIdDef(expr.IdToken.Name, scope)254 if param is not None:255 return param256 else:257 return Exprs.Expression.Dynamic(258 scope.GetRuntime().GetGetMemberBinder(expr.IdToken.Name), 259 object,260 scope.GetModuleExpr())261### _findIdDef returns the ParameterExpr for the name by searching the scopes,262### or it returns None.263###264def _findIdDef (name, scope):265 curscope = scope266 name = name.lower()267 while curscope is not None and not curscope.IsModule():268 if name in curscope.Names:269 return curscope.Names[name]270 else:271 curscope = curscope.Parent272 if curscope is None:273 raise Exception("Got bad AnalysisScope chain with no module at end.")274 return None275### AnalyzeLetStar returns a Block with vars, each initialized in the order276### they appear. Each var's init expr can refer to vars initialized before it.277### The Block's body is the Let*'s body.278###279def AnalyzeLetStarExpr (expr, scope):280 debugprint("analyze let* ...")281 if type(expr) is not parser.SymplLetStarExpr:282 raise Exception("Internal: need Let* Expr to analyze.")283 letscope = AnalysisScope(scope, "let*")284 ## Analyze bindings.285 inits = []286 varsInOrder = []287 for b in expr.Bindings:288 ## Need richer logic for mvbind289 var = Exprs.Expression.Parameter(object, b[0].Name)290 varsInOrder.append(var)291 inits.append(Exprs.Expression.Assign(292 var, 293 Exprs.Expression.Convert(AnalyzeExpr(b[1], letscope),294 var.Type)))295 ## Add var to scope after analyzing init value so that init value296 ## references to the same ID do not bind to his uninitialized var.297 letscope.Names[b[0].Name.lower()] = var298 body = []299 for e in expr.Body:300 body.append(AnalyzeExpr(e, letscope))301 ## Order of vars to BlockExpr don't matter semantically, but may as well302 ## keep them in the order the programmer specified in case they look at the303 ## Expr Trees in the debugger or for meta-programming.304 return Exprs.Expression.Block(object, varsInOrder, inits + body)305### AnalyzeBlockExpr returns a Block with the body exprs.306###307def AnalyzeBlockExpr (expr, scope):308 debugprint("analyze block ...")309 if type(expr) is not parser.SymplBlockExpr:310 raise Exception("Internal: need Block Expr to analyze.")311 body = []312 for e in expr.Body:313 body.append(AnalyzeExpr(e, scope))314 ## Due to .NET 4.0 co/contra-variance, IPy's binding isn't picking the overload315 ## with Type and IEnumerable<Expr>, so pick it explicitly.316 return Exprs.Expression.Block.Overloads[317 System.Type, IEnumerable[Exprs.Expression]](object, body)318### AnalyzeQuoteExpr converts a list, literal, or id expr to a runtime quoted319### literal and returns the Constant expression for it.320###321def AnalyzeQuoteExpr (expr, scope):322 debugprint("analyze quote ...")323 if type(expr) is not parser.SymplQuoteExpr:324 raise Exception("Internal: need Quote Expr to analyze.")325 return Exprs.Expression.Constant(326 MakeQuoteConstant(expr.Expr, scope.GetRuntime()))327def MakeQuoteConstant (expr, symplRuntime):328 if type(expr) is parser.SymplListExpr:329 exprs = []330 for e in expr.Elements:331 exprs.append(MakeQuoteConstant(e, symplRuntime))332 return runtime.Cons._List(*exprs)333 elif isinstance(expr, lexer.IdOrKeywordToken):334 return symplRuntime.MakeSymbol(expr.Name)335 elif isinstance(expr, lexer.LiteralToken):336 return expr.Value337 else:338 raise Exception("Internal: quoted list has -- " + repr(expr))339def AnalyzeEqExpr (expr, scope):340 debugprint("analyze eq ...")341 if type(expr) is not parser.SymplEqExpr:342 raise Exception("Internal: need eq expr to analyze.")343 return runtime.MakeSymplEqCall(AnalyzeExpr(expr.Left, scope),344 AnalyzeExpr(expr.Right, scope))345 346def AnalyzeConsExpr (expr, scope):347 debugprint("analyze cons ...")348 if type(expr) is not parser.SymplConsExpr:349 raise Exception("Internal: need cons expr to analyze.")350 return runtime.MakeSymplConsCall(AnalyzeExpr(expr.Left, scope),351 AnalyzeExpr(expr.Right, scope))352 353def AnalyzeListCallExpr (expr, scope):354 debugprint("analyze List call ...")355 if type(expr) is not parser.SymplListCallExpr:356 raise Exception("Internal: need import expr to analyze.")357 return runtime.MakeSymplListCall([AnalyzeExpr(x, scope)358 for x in expr.Elements])359def AnalyzeIfExpr (expr, scope):360 if type(expr) is not parser.SymplIfExpr:361 raise Exception("Internal: need IF expr to analyze.")362 if expr.Alternative is not None:363 alt = AnalyzeExpr(expr.Alternative, scope)364 else:365 alt = Exprs.Expression.Constant(False)366 return Exprs.Expression.Condition(367 WrapBooleanTest(AnalyzeExpr(expr.Test, scope)),368 Exprs.Expression.Convert(AnalyzeExpr(expr.Consequent, scope),369 object),370 Exprs.Expression.Convert(alt, object))371 372def WrapBooleanTest (expr):373 tmp = Exprs.Expression.Parameter(object, "testtmp")374 return Exprs.Expression.Block(375 [tmp],376 [Exprs.Expression.Assign(tmp, Exprs.Expression.Convert(expr, object)),377 Exprs.Expression.Condition(378 Exprs.Expression.TypeIs(tmp, bool), 379 Exprs.Expression.Convert(tmp, bool),380 Exprs.Expression.NotEqual(tmp, Exprs.Expression.Constant(None)))])381def AnalyzeLoopExpr (expr, scope):382 debugprint("analyze loop ...")383 if type(expr) is not parser.SymplLoopExpr:384 raise Exception("Internal: need loop to analyze.")385 loopscope = AnalysisScope(scope, "loop ")386 loopscope.IsLoop = True # needed for break and continue387 loopscope.LoopBreak = Exprs.Expression.Label(object, "loop break")388 body = []389 for e in expr.Body:390 body.append(AnalyzeExpr(e, loopscope))391 ## Due to .NET 4.0 co/contra-variance, IPy's binding isn't picking the overload392 ## with Type and IEnumerable<Expr>, so pick it explicitly.393 return Exprs.Expression.Loop(Exprs.Expression.Block.Overloads394 [System.Type, IEnumerable[Exprs.Expression]]395 (object, body), 396 loopscope.LoopBreak)397def AnalyzeBreakExpr (expr, scope):398 debugprint("analyze break ..." + repr(expr.Value))399 if type(expr) is not parser.SymplBreakExpr:400 raise Exception("Internal: need break to analyze.")401 loopscope = _findFirstLoop(scope)402 if loopscope is None:403 raise Exception("Call to Break not inside loop.")404 if expr.Value is None:405 value = Exprs.Expression.Constant(None, object)406 else:407 ## Ok if value jumps to break label.408 value = AnalyzeExpr(expr.Value, scope)409 ## Need final type=object arg because the Goto is in a value returning410 ## position, and the Break factory doesn't set the GotoExpr.Type property411 ## to the type of the LoopBreak label target's type.412 return Exprs.Expression.Break(loopscope.LoopBreak, value, object)413### _findFirstLoop returns the first loop AnalysisScope or None.414###415def _findFirstLoop (scope):416 curscope = scope417 while curscope is not None:418 if curscope.IsLoop:419 return curscope420 else:421 curscope = curscope.Parent422 return None423def AnalyzeNewExpr (expr, scope):424 debugprint("analyze new ...", expr.Typ)425 if type(expr) is not parser.SymplNewExpr:426 raise Exception("Internal: need New call to analyze.")427 typ = AnalyzeExpr(expr.Typ, scope)428 args = [AnalyzeExpr(a, scope) for a in expr.Arguments]429 ## Use DynExpr since we don't know type until runtime.430 return Exprs.Expression.Dynamic(431 scope.GetRuntime().GetCreateInstanceBinder(CallInfo(len(args))),432 object,433 [typ] + args)434### AnalyzeEltExpr returns and Expression for accessing an element of an435### aggregate structure. This also works for .NET objs with indexer Item436### properties. We handle analyzing Elt for assignment in AnalyzeAssignExpr.437###438def AnalyzeEltExpr (expr, scope):439 debugprint("analyze elt ...", expr.ObjectExpr)440 if type(expr) is not parser.SymplEltExpr:441 raise Exception("Internal: need Elt call to analyze.")442 obj = AnalyzeExpr(expr.ObjectExpr, scope)443 args = [AnalyzeExpr(a, scope) for a in expr.Indexes]444 ## Use DynExpr since we don't know obj until runtime.445 return Exprs.Expression.Dynamic(446 scope.GetRuntime().GetGetIndexBinder(CallInfo(len(args))),447 object,448 [obj] + args)449def AnalyzeBinaryExpr (expr, scope):450 if type(expr) is not parser.SymplBinaryExpr:451 raise Exception("Internal: need binary op to analyze.")452 if expr.Op == Exprs.ExpressionType.And:453 ## (and x y) is (if x y)454 return AnalyzeIfExpr(parser.SymplIfExpr(expr.Left, expr.Right, None),455 scope)456 elif expr.Op == Exprs.ExpressionType.Or:457 ## (or x y) is (let ((tmpx x))458 ## (if tmpx tmpx (let ((tmp2 y)) (if tmp2 tmp2))))459 ##460 ## Build inner let for y first.461 ## Real impl needs to ensure unique ID in scope chain.462 tmp2 = lexer.IdOrKeywordToken("__tmpOrLetVar2", False) #False = not kwd463 tmpExpr2 = parser.SymplIdExpr(tmp2)464 bindings2 = [(tmp2, expr.Right)]465 ifExpr2 = parser.SymplIfExpr(tmpExpr2, tmpExpr2, None)466 letExpr2 = parser.SymplLetStarExpr(bindings2, [ifExpr2])467 ## Build outer let for x.468 tmp1 = lexer.IdOrKeywordToken("__tmpOrLetVar1", False) #False = not kwd469 tmpExpr1 = parser.SymplIdExpr(tmp1)470 bindings1 = [(tmp1, expr.Left)]471 ifExpr1 = parser.SymplIfExpr(tmpExpr1, tmpExpr1, letExpr2)472 return AnalyzeLetStarExpr(473 parser.SymplLetStarExpr(bindings1, [ifExpr1]),474 scope)475 else:476 return Exprs.Expression.Dynamic(477 scope.GetRuntime().GetBinaryOperationBinder(expr.Op),478 object,479 AnalyzeExpr(expr.Left, scope),480 AnalyzeExpr(expr.Right, scope))481 482def AnalyzeUnaryExpr (expr, scope):483 if type(expr) is not parser.SymplUnaryExpr:484 raise Exception("Internal: need Unary op to analyze.")485 if expr.Op == Exprs.ExpressionType.Not:486 ## Sympl has specific semantics for what is true vs. false and would487 ## use the OnesComplement node kind if Sympl had that.488 return Exprs.Expression.Not(WrapBooleanTest(AnalyzeExpr(expr.Operand,489 scope)))490 else:491 ## Should never get here unless we add, say, unary minus.492 return Exprs.Expression.Dynamic(493 scope.GetRuntime().GetUnaryOperationBinder(expr.Op),494 object,495 AnalyzeExpr(expr.Operand, scope))496 497### AnalysisScope holds identifier information so that we can do name binding498### during analysis. It manages a map from names to ParameterExprs so ET499### definition locations and reference locations can alias the same variable.500###501### These chain from inner most BlockExprs, through LambdaExprs, to the root502### which models a file or top-level expression. The root has non-None503### ModuleExpr and RuntimeExpr, which are ParameterExprs.504###505class AnalysisScope (object):506 def __init__ (self, parent, nam = "", runtime = None, runtimeParam = None,507 moduleParam = None):508 self.ModuleExpr = moduleParam509 self.RuntimeExpr = runtimeParam510 ## Need runtime for interning Symbol constants at code gen time.511 self.Runtime = runtime512 self.Name = nam513 self.Parent = parent514 self.Names = {}515 ## Need IsLambda when support return to find tightest closing fun.516 self.IsLambda = False517 self.IsLoop = False518 self.LoopBreak = None519 self.LoopContinue = None520 521 def IsModule (self):522 return self.ModuleExpr is not None523 def GetModuleExpr (self):524 curscope = self525 while not curscope.IsModule():526 curscope = curscope.Parent527 return curscope.ModuleExpr528 def GetRuntime (self):529 curscope = self530 while curscope.Runtime is None:531 curscope = curscope.Parent532 return curscope.Runtime533##################534### Dev-time Utils535##################536_debug = False537def debugprint (*stuff):538 if _debug:539 for x in stuff:540 print x,...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!