Coverage for /var/srv/projects/api.amasfac.comuna18.com/tmp/venv/lib/python3.9/site-packages/openpyxl/pivot/cache.py: 66%

599 statements  

« prev     ^ index     » next       coverage.py v6.4.4, created at 2023-07-17 14:22 -0600

1# Copyright (c) 2010-2022 openpyxl 

2 

3from openpyxl.descriptors.serialisable import Serialisable 

4from openpyxl.descriptors import ( 

5 Typed, 

6 Bool, 

7 Float, 

8 Set, 

9 NoneSet, 

10 String, 

11 Integer, 

12 DateTime, 

13 Sequence, 

14) 

15 

16from openpyxl.descriptors.excel import ( 

17 HexBinary, 

18 ExtensionList, 

19 Relation, 

20) 

21from openpyxl.descriptors.nested import NestedInteger 

22from openpyxl.descriptors.sequence import ( 

23 NestedSequence, 

24 MultiSequence, 

25 MultiSequencePart, 

26) 

27from openpyxl.xml.constants import SHEET_MAIN_NS 

28from openpyxl.xml.functions import tostring 

29from openpyxl.packaging.relationship import ( 

30 RelationshipList, 

31 Relationship, 

32 get_rels_path 

33) 

34 

35from .table import ( 

36 PivotArea, 

37 Reference, 

38) 

39from .fields import ( 

40 Boolean, 

41 Error, 

42 Missing, 

43 Number, 

44 Text, 

45 TupleList, 

46 DateTimeField, 

47) 

48 

49class MeasureDimensionMap(Serialisable): 

50 

51 tagname = "map" 

52 

53 measureGroup = Integer(allow_none=True) 

54 dimension = Integer(allow_none=True) 

55 

56 def __init__(self, 

57 measureGroup=None, 

58 dimension=None, 

59 ): 

60 self.measureGroup = measureGroup 

61 self.dimension = dimension 

62 

63 

64class MeasureGroup(Serialisable): 

65 

66 tagname = "measureGroup" 

67 

68 name = String() 

69 caption = String() 

70 

71 def __init__(self, 

72 name=None, 

73 caption=None, 

74 ): 

75 self.name = name 

76 self.caption = caption 

77 

78 

79class PivotDimension(Serialisable): 

80 

81 tagname = "dimension" 

82 

83 measure = Bool() 

84 name = String() 

85 uniqueName = String() 

86 caption = String() 

87 

88 def __init__(self, 

89 measure=None, 

90 name=None, 

91 uniqueName=None, 

92 caption=None, 

93 ): 

94 self.measure = measure 

95 self.name = name 

96 self.uniqueName = uniqueName 

97 self.caption = caption 

98 

99 

100class CalculatedMember(Serialisable): 

101 

102 tagname = "calculatedMember" 

103 

104 name = String() 

105 mdx = String() 

106 memberName = String() 

107 hierarchy = String() 

108 parent = String() 

109 solveOrder = Integer() 

110 set = Bool() 

111 extLst = Typed(expected_type=ExtensionList, allow_none=True) 

112 

113 __elements__ = () 

114 

115 def __init__(self, 

116 name=None, 

117 mdx=None, 

118 memberName=None, 

119 hierarchy=None, 

120 parent=None, 

121 solveOrder=None, 

122 set=None, 

123 extLst=None, 

124 ): 

125 self.name = name 

126 self.mdx = mdx 

127 self.memberName = memberName 

128 self.hierarchy = hierarchy 

129 self.parent = parent 

130 self.solveOrder = solveOrder 

131 self.set = set 

132 #self.extLst = extLst 

133 

134 

135class CalculatedItem(Serialisable): 

136 

137 tagname = "calculatedItem" 

138 

139 field = Integer(allow_none=True) 

140 formula = String() 

141 pivotArea = Typed(expected_type=PivotArea, ) 

142 extLst = Typed(expected_type=ExtensionList, allow_none=True) 

143 

144 __elements__ = ('pivotArea', 'extLst') 

145 

146 def __init__(self, 

147 field=None, 

148 formula=None, 

149 pivotArea=None, 

150 extLst=None, 

151 ): 

152 self.field = field 

153 self.formula = formula 

154 self.pivotArea = pivotArea 

155 self.extLst = extLst 

156 

157 

158class ServerFormat(Serialisable): 

159 

160 tagname = "serverFormat" 

161 

162 culture = String(allow_none=True) 

163 format = String(allow_none=True) 

164 

165 def __init__(self, 

166 culture=None, 

167 format=None, 

168 ): 

169 self.culture = culture 

170 self.format = format 

171 

172 

173class ServerFormatList(Serialisable): 

174 

175 tagname = "serverFormats" 

176 

177 serverFormat = Sequence(expected_type=ServerFormat, allow_none=True) 

178 

179 __elements__ = ('serverFormat',) 

180 __attrs__ = ('count',) 

181 

182 def __init__(self, 

183 count=None, 

184 serverFormat=None, 

185 ): 

186 self.serverFormat = serverFormat 

187 

188 

189 @property 

190 def count(self): 

191 return len(self.serverFormat) 

192 

193 

194class Query(Serialisable): 

195 

196 tagname = "query" 

197 

198 mdx = String() 

199 tpls = Typed(expected_type=TupleList, allow_none=True) 

200 

201 __elements__ = ('tpls',) 

202 

203 def __init__(self, 

204 mdx=None, 

205 tpls=None, 

206 ): 

207 self.mdx = mdx 

208 self.tpls = tpls 

209 

210 

211class QueryCache(Serialisable): 

212 

213 tagname = "queryCache" 

214 

215 count = Integer() 

216 query = Typed(expected_type=Query, ) 

217 

218 __elements__ = ('query',) 

219 

220 def __init__(self, 

221 count=None, 

222 query=None, 

223 ): 

224 self.count = count 

225 self.query = query 

226 

227 

228class OLAPSet(Serialisable): 

229 

230 tagname = "set" 

231 

232 count = Integer() 

233 maxRank = Integer() 

234 setDefinition = String() 

235 sortType = NoneSet(values=(['ascending', 'descending', 'ascendingAlpha', 

236 'descendingAlpha', 'ascendingNatural', 'descendingNatural'])) 

237 queryFailed = Bool() 

238 tpls = Typed(expected_type=TupleList, allow_none=True) 

239 sortByTuple = Typed(expected_type=TupleList, allow_none=True) 

240 

241 __elements__ = ('tpls', 'sortByTuple') 

242 

243 def __init__(self, 

244 count=None, 

245 maxRank=None, 

246 setDefinition=None, 

247 sortType=None, 

248 queryFailed=None, 

249 tpls=None, 

250 sortByTuple=None, 

251 ): 

252 self.count = count 

253 self.maxRank = maxRank 

254 self.setDefinition = setDefinition 

255 self.sortType = sortType 

256 self.queryFailed = queryFailed 

257 self.tpls = tpls 

258 self.sortByTuple = sortByTuple 

259 

260 

261class OLAPSets(Serialisable): 

262 

263 count = Integer() 

264 set = Typed(expected_type=OLAPSet, ) 

265 

266 __elements__ = ('set',) 

267 

268 def __init__(self, 

269 count=None, 

270 set=None, 

271 ): 

272 self.count = count 

273 self.set = set 

274 

275 

276class PCDSDTCEntries(Serialisable): 

277 

278 tagname = "pCDSDTCEntries" 

279 

280 count = Integer() 

281 # some elements are choice 

282 m = Typed(expected_type=Missing, ) 

283 n = Typed(expected_type=Number, ) 

284 e = Typed(expected_type=Error, ) 

285 s = Typed(expected_type=Text) 

286 

287 __elements__ = ('m', 'n', 'e', 's') 

288 

289 def __init__(self, 

290 count=None, 

291 m=None, 

292 n=None, 

293 e=None, 

294 s=None, 

295 ): 

296 self.count = count 

297 self.m = m 

298 self.n = n 

299 self.e = e 

300 self.s = s 

301 

302 

303class TupleCache(Serialisable): 

304 

305 tagname = "tupleCache" 

306 

307 entries = Typed(expected_type=PCDSDTCEntries, allow_none=True) 

308 sets = Typed(expected_type=OLAPSets, allow_none=True) 

309 queryCache = Typed(expected_type=QueryCache, allow_none=True) 

310 serverFormats = Typed(expected_type=ServerFormatList, allow_none=True) 

311 extLst = Typed(expected_type=ExtensionList, allow_none=True) 

312 

313 __elements__ = ('entries', 'sets', 'queryCache', 'serverFormats', 'extLst') 

314 

315 def __init__(self, 

316 entries=None, 

317 sets=None, 

318 queryCache=None, 

319 serverFormats=None, 

320 extLst=None, 

321 ): 

322 self.entries = entries 

323 self.sets = sets 

324 self.queryCache = queryCache 

325 self.serverFormats = serverFormats 

326 self.extLst = extLst 

327 

328 

329class PCDKPI(Serialisable): 

330 

331 tagname = "pCDKPI" 

332 

333 uniqueName = String() 

334 caption = String(allow_none=True) 

335 displayFolder = String() 

336 measureGroup = String() 

337 parent = String() 

338 value = String() 

339 goal = String() 

340 status = String() 

341 trend = String() 

342 weight = String() 

343 time = String() 

344 

345 def __init__(self, 

346 uniqueName=None, 

347 caption=None, 

348 displayFolder=None, 

349 measureGroup=None, 

350 parent=None, 

351 value=None, 

352 goal=None, 

353 status=None, 

354 trend=None, 

355 weight=None, 

356 time=None, 

357 ): 

358 self.uniqueName = uniqueName 

359 self.caption = caption 

360 self.displayFolder = displayFolder 

361 self.measureGroup = measureGroup 

362 self.parent = parent 

363 self.value = value 

364 self.goal = goal 

365 self.status = status 

366 self.trend = trend 

367 self.weight = weight 

368 self.time = time 

369 

370 

371class GroupMember(Serialisable): 

372 

373 tagname = "groupMember" 

374 

375 uniqueName = String() 

376 group = Bool() 

377 

378 def __init__(self, 

379 uniqueName=None, 

380 group=None, 

381 ): 

382 self.uniqueName = uniqueName 

383 self.group = group 

384 

385 

386class GroupMembers(Serialisable): 

387 

388 count = Integer() 

389 groupMember = Typed(expected_type=GroupMember, ) 

390 

391 __elements__ = ('groupMember',) 

392 

393 def __init__(self, 

394 count=None, 

395 groupMember=None, 

396 ): 

397 self.count = count 

398 self.groupMember = groupMember 

399 

400 

401class LevelGroup(Serialisable): 

402 

403 tagname = "levelGroup" 

404 

405 name = String() 

406 uniqueName = String() 

407 caption = String() 

408 uniqueParent = String() 

409 id = Integer() 

410 groupMembers = Typed(expected_type=GroupMembers, ) 

411 

412 __elements__ = ('groupMembers',) 

413 

414 def __init__(self, 

415 name=None, 

416 uniqueName=None, 

417 caption=None, 

418 uniqueParent=None, 

419 id=None, 

420 groupMembers=None, 

421 ): 

422 self.name = name 

423 self.uniqueName = uniqueName 

424 self.caption = caption 

425 self.uniqueParent = uniqueParent 

426 self.id = id 

427 self.groupMembers = groupMembers 

428 

429 

430class Groups(Serialisable): 

431 

432 tagname = "groups" 

433 

434 count = Integer() 

435 group = Typed(expected_type=LevelGroup, ) 

436 

437 __elements__ = ('group',) 

438 

439 def __init__(self, 

440 count=None, 

441 group=None, 

442 ): 

443 self.count = count 

444 self.group = group 

445 

446 

447class GroupLevel(Serialisable): 

448 

449 tagname = "groupLevel" 

450 

451 uniqueName = String() 

452 caption = String() 

453 user = Bool() 

454 customRollUp = Bool() 

455 groups = Typed(expected_type=Groups, allow_none=True) 

456 extLst = Typed(expected_type=ExtensionList, allow_none=True) 

457 

458 __elements__ = ('groups', 'extLst') 

459 

460 def __init__(self, 

461 uniqueName=None, 

462 caption=None, 

463 user=None, 

464 customRollUp=None, 

465 groups=None, 

466 extLst=None, 

467 ): 

468 self.uniqueName = uniqueName 

469 self.caption = caption 

470 self.user = user 

471 self.customRollUp = customRollUp 

472 self.groups = groups 

473 self.extLst = extLst 

474 

475 

476class GroupLevels(Serialisable): 

477 

478 count = Integer() 

479 groupLevel = Typed(expected_type=GroupLevel, ) 

480 

481 __elements__ = ('groupLevel',) 

482 

483 def __init__(self, 

484 count=None, 

485 groupLevel=None, 

486 ): 

487 self.count = count 

488 self.groupLevel = groupLevel 

489 

490 

491class FieldUsage(Serialisable): 

492 

493 tagname = "fieldUsage" 

494 

495 x = Integer() 

496 

497 def __init__(self, 

498 x=None, 

499 ): 

500 self.x = x 

501 

502 

503class FieldsUsage(Serialisable): 

504 

505 count = Integer() 

506 fieldUsage = Typed(expected_type=FieldUsage, allow_none=True) 

507 

508 __elements__ = ('fieldUsage',) 

509 

510 def __init__(self, 

511 count=None, 

512 fieldUsage=None, 

513 ): 

514 self.count = count 

515 self.fieldUsage = fieldUsage 

516 

517 

518class CacheHierarchy(Serialisable): 

519 

520 tagname = "cacheHierarchy" 

521 

522 uniqueName = String() 

523 caption = String(allow_none=True) 

524 measure = Bool() 

525 set = Bool() 

526 parentSet = Integer(allow_none=True) 

527 iconSet = Integer() 

528 attribute = Bool() 

529 time = Bool() 

530 keyAttribute = Bool() 

531 defaultMemberUniqueName = String(allow_none=True) 

532 allUniqueName = String(allow_none=True) 

533 allCaption = String(allow_none=True) 

534 dimensionUniqueName = String(allow_none=True) 

535 displayFolder = String(allow_none=True) 

536 measureGroup = String(allow_none=True) 

537 measures = Bool() 

538 count = Integer() 

539 oneField = Bool() 

540 memberValueDatatype = Integer(allow_none=True) 

541 unbalanced = Bool(allow_none=True) 

542 unbalancedGroup = Bool(allow_none=True) 

543 hidden = Bool() 

544 fieldsUsage = Typed(expected_type=FieldsUsage, allow_none=True) 

545 groupLevels = Typed(expected_type=GroupLevels, allow_none=True) 

546 extLst = Typed(expected_type=ExtensionList, allow_none=True) 

547 

548 __elements__ = ('fieldsUsage', 'groupLevels') 

549 

550 def __init__(self, 

551 uniqueName="", 

552 caption=None, 

553 measure=None, 

554 set=None, 

555 parentSet=None, 

556 iconSet=0, 

557 attribute=None, 

558 time=None, 

559 keyAttribute=None, 

560 defaultMemberUniqueName=None, 

561 allUniqueName=None, 

562 allCaption=None, 

563 dimensionUniqueName=None, 

564 displayFolder=None, 

565 measureGroup=None, 

566 measures=None, 

567 count=None, 

568 oneField=None, 

569 memberValueDatatype=None, 

570 unbalanced=None, 

571 unbalancedGroup=None, 

572 hidden=None, 

573 fieldsUsage=None, 

574 groupLevels=None, 

575 extLst=None, 

576 ): 

577 self.uniqueName = uniqueName 

578 self.caption = caption 

579 self.measure = measure 

580 self.set = set 

581 self.parentSet = parentSet 

582 self.iconSet = iconSet 

583 self.attribute = attribute 

584 self.time = time 

585 self.keyAttribute = keyAttribute 

586 self.defaultMemberUniqueName = defaultMemberUniqueName 

587 self.allUniqueName = allUniqueName 

588 self.allCaption = allCaption 

589 self.dimensionUniqueName = dimensionUniqueName 

590 self.displayFolder = displayFolder 

591 self.measureGroup = measureGroup 

592 self.measures = measures 

593 self.count = count 

594 self.oneField = oneField 

595 self.memberValueDatatype = memberValueDatatype 

596 self.unbalanced = unbalanced 

597 self.unbalancedGroup = unbalancedGroup 

598 self.hidden = hidden 

599 self.fieldsUsage = fieldsUsage 

600 self.groupLevels = groupLevels 

601 self.extLst = extLst 

602 

603 

604class GroupItems(Serialisable): 

605 

606 tagname = "groupItems" 

607 

608 m = Sequence(expected_type=Missing) 

609 n = Sequence(expected_type=Number) 

610 b = Sequence(expected_type=Boolean) 

611 e = Sequence(expected_type=Error) 

612 s = Sequence(expected_type=Text) 

613 d = Sequence(expected_type=DateTimeField,) 

614 

615 __elements__ = ('m', 'n', 'b', 'e', 's', 'd') 

616 __attrs__ = ("count", ) 

617 

618 def __init__(self, 

619 count=None, 

620 m=(), 

621 n=(), 

622 b=(), 

623 e=(), 

624 s=(), 

625 d=(), 

626 ): 

627 self.m = m 

628 self.n = n 

629 self.b = b 

630 self.e = e 

631 self.s = s 

632 self.d = d 

633 

634 

635 @property 

636 def count(self): 

637 return len(self.m + self.n + self.b + self.e + self.s + self.d) 

638 

639 

640class DiscretePr(Serialisable): 

641 

642 tagname = "discretePr" 

643 

644 count = Integer() 

645 x = NestedInteger(allow_none=True) 

646 

647 __elements__ = ('x',) 

648 

649 def __init__(self, 

650 count=None, 

651 x=None, 

652 ): 

653 self.count = count 

654 self.x = x 

655 

656 

657class RangePr(Serialisable): 

658 

659 tagname = "rangePr" 

660 

661 autoStart = Bool(allow_none=True) 

662 autoEnd = Bool(allow_none=True) 

663 groupBy = Set(values=(['range', 'seconds', 'minutes', 'hours', 'days', 

664 'months', 'quarters', 'years'])) 

665 startNum = Float(allow_none=True) 

666 endNum = Float(allow_none=True) 

667 startDate = DateTime(allow_none=True) 

668 endDate = DateTime(allow_none=True) 

669 groupInterval = Float(allow_none=True) 

670 

671 def __init__(self, 

672 autoStart=True, 

673 autoEnd=True, 

674 groupBy="range", 

675 startNum=None, 

676 endNum=None, 

677 startDate=None, 

678 endDate=None, 

679 groupInterval=1, 

680 ): 

681 self.autoStart = autoStart 

682 self.autoEnd = autoEnd 

683 self.groupBy = groupBy 

684 self.startNum = startNum 

685 self.endNum = endNum 

686 self.startDate = startDate 

687 self.endDate = endDate 

688 self.groupInterval = groupInterval 

689 

690 

691class FieldGroup(Serialisable): 

692 

693 tagname = "fieldGroup" 

694 

695 par = Integer(allow_none=True) 

696 base = Integer(allow_none=True) 

697 rangePr = Typed(expected_type=RangePr, allow_none=True) 

698 discretePr = Typed(expected_type=DiscretePr, allow_none=True) 

699 groupItems = Typed(expected_type=GroupItems, allow_none=True) 

700 

701 __elements__ = ('rangePr', 'discretePr', 'groupItems') 

702 

703 def __init__(self, 

704 par=None, 

705 base=None, 

706 rangePr=None, 

707 discretePr=None, 

708 groupItems=None, 

709 ): 

710 self.par = par 

711 self.base = base 

712 self.rangePr = rangePr 

713 self.discretePr = discretePr 

714 self.groupItems = groupItems 

715 

716 

717class SharedItems(Serialisable): 

718 

719 tagname = "sharedItems" 

720 

721 _fields = MultiSequence() 

722 m = MultiSequencePart(expected_type=Missing, store="_fields") 

723 n = MultiSequencePart(expected_type=Number, store="_fields") 

724 b = MultiSequencePart(expected_type=Boolean, store="_fields") 

725 e = MultiSequencePart(expected_type=Error, store="_fields") 

726 s = MultiSequencePart(expected_type=Text, store="_fields") 

727 d = MultiSequencePart(expected_type=DateTimeField, store="_fields") 

728 # attributes are optional and must be derived from associated cache records 

729 containsSemiMixedTypes = Bool(allow_none=True) 

730 containsNonDate = Bool(allow_none=True) 

731 containsDate = Bool(allow_none=True) 

732 containsString = Bool(allow_none=True) 

733 containsBlank = Bool(allow_none=True) 

734 containsMixedTypes = Bool(allow_none=True) 

735 containsNumber = Bool(allow_none=True) 

736 containsInteger = Bool(allow_none=True) 

737 minValue = Float(allow_none=True) 

738 maxValue = Float(allow_none=True) 

739 minDate = DateTime(allow_none=True) 

740 maxDate = DateTime(allow_none=True) 

741 longText = Bool(allow_none=True) 

742 

743 __attrs__ = ('count', 'containsBlank', 'containsDate', 'containsInteger', 

744 'containsMixedTypes', 'containsNonDate', 'containsNumber', 

745 'containsSemiMixedTypes', 'containsString', 'minValue', 'maxValue', 

746 'minDate', 'maxDate', 'longText') 

747 

748 def __init__(self, 

749 _fields=(), 

750 containsSemiMixedTypes=None, 

751 containsNonDate=None, 

752 containsDate=None, 

753 containsString=None, 

754 containsBlank=None, 

755 containsMixedTypes=None, 

756 containsNumber=None, 

757 containsInteger=None, 

758 minValue=None, 

759 maxValue=None, 

760 minDate=None, 

761 maxDate=None, 

762 count=None, 

763 longText=None, 

764 ): 

765 self._fields = _fields 

766 self.containsBlank = containsBlank 

767 self.containsDate = containsDate 

768 self.containsNonDate = containsNonDate 

769 self.containsString = containsString 

770 self.containsMixedTypes = containsMixedTypes 

771 self.containsSemiMixedTypes = containsSemiMixedTypes 

772 self.containsNumber = containsNumber 

773 self.containsInteger = containsInteger 

774 self.minValue = minValue 

775 self.maxValue = maxValue 

776 self.minDate = minDate 

777 self.maxDate = maxDate 

778 self.longText = longText 

779 

780 

781 @property 

782 def count(self): 

783 return len(self._fields) 

784 

785 

786class CacheField(Serialisable): 

787 

788 tagname = "cacheField" 

789 

790 sharedItems = Typed(expected_type=SharedItems, allow_none=True) 

791 fieldGroup = Typed(expected_type=FieldGroup, allow_none=True) 

792 mpMap = NestedInteger(allow_none=True, attribute="v") 

793 extLst = Typed(expected_type=ExtensionList, allow_none=True) 

794 name = String() 

795 caption = String(allow_none=True) 

796 propertyName = String(allow_none=True) 

797 serverField = Bool(allow_none=True) 

798 uniqueList = Bool(allow_none=True) 

799 numFmtId = Integer(allow_none=True) 

800 formula = String(allow_none=True) 

801 sqlType = Integer(allow_none=True) 

802 hierarchy = Integer(allow_none=True) 

803 level = Integer(allow_none=True) 

804 databaseField = Bool(allow_none=True) 

805 mappingCount = Integer(allow_none=True) 

806 memberPropertyField = Bool(allow_none=True) 

807 

808 __elements__ = ('sharedItems', 'fieldGroup', 'mpMap') 

809 

810 def __init__(self, 

811 sharedItems=None, 

812 fieldGroup=None, 

813 mpMap=None, 

814 extLst=None, 

815 name=None, 

816 caption=None, 

817 propertyName=None, 

818 serverField=None, 

819 uniqueList=True, 

820 numFmtId=None, 

821 formula=None, 

822 sqlType=0, 

823 hierarchy=0, 

824 level=0, 

825 databaseField=True, 

826 mappingCount=None, 

827 memberPropertyField=None, 

828 ): 

829 self.sharedItems = sharedItems 

830 self.fieldGroup = fieldGroup 

831 self.mpMap = mpMap 

832 self.extLst = extLst 

833 self.name = name 

834 self.caption = caption 

835 self.propertyName = propertyName 

836 self.serverField = serverField 

837 self.uniqueList = uniqueList 

838 self.numFmtId = numFmtId 

839 self.formula = formula 

840 self.sqlType = sqlType 

841 self.hierarchy = hierarchy 

842 self.level = level 

843 self.databaseField = databaseField 

844 self.mappingCount = mappingCount 

845 self.memberPropertyField = memberPropertyField 

846 

847 

848class RangeSet(Serialisable): 

849 

850 tagname = "rangeSet" 

851 

852 i1 = Integer(allow_none=True) 

853 i2 = Integer(allow_none=True) 

854 i3 = Integer(allow_none=True) 

855 i4 = Integer(allow_none=True) 

856 ref = String() 

857 name = String(allow_none=True) 

858 sheet = String(allow_none=True) 

859 

860 def __init__(self, 

861 i1=None, 

862 i2=None, 

863 i3=None, 

864 i4=None, 

865 ref=None, 

866 name=None, 

867 sheet=None, 

868 ): 

869 self.i1 = i1 

870 self.i2 = i2 

871 self.i3 = i3 

872 self.i4 = i4 

873 self.ref = ref 

874 self.name = name 

875 self.sheet = sheet 

876 

877 

878class PageItem(Serialisable): 

879 

880 tagname = "pageItem" 

881 

882 name = String() 

883 

884 def __init__(self, 

885 name=None, 

886 ): 

887 self.name = name 

888 

889 

890class Page(Serialisable): 

891 

892 # PCDSCPage 

893 tagname = "PCDSCPage" 

894 

895 pageItem = Sequence(expected_type=PageItem) 

896 

897 __elements__ = ('pageItem',) 

898 

899 def __init__(self, 

900 count=None, 

901 pageItem=None, 

902 ): 

903 self.pageItem = pageItem 

904 

905 

906 @property 

907 def count(self): 

908 return len(self.pageItem) 

909 

910 

911class Consolidation(Serialisable): 

912 

913 tagname = "consolidation" 

914 

915 autoPage = Bool(allow_none=True) 

916 pages = NestedSequence(expected_type=Page, count=True) 

917 rangeSets = NestedSequence(expected_type=RangeSet, count=True) 

918 

919 __elements__ = ('pages', 'rangeSets') 

920 

921 def __init__(self, 

922 autoPage=None, 

923 pages=(), 

924 rangeSets=(), 

925 ): 

926 self.autoPage = autoPage 

927 self.pages = pages 

928 self.rangeSets = rangeSets 

929 

930 

931class WorksheetSource(Serialisable): 

932 

933 tagname = "worksheetSource" 

934 

935 ref = String(allow_none=True) 

936 name = String(allow_none=True) 

937 sheet = String(allow_none=True) 

938 

939 def __init__(self, 

940 ref=None, 

941 name=None, 

942 sheet=None, 

943 ): 

944 self.ref = ref 

945 self.name = name 

946 self.sheet = sheet 

947 

948 

949class CacheSource(Serialisable): 

950 

951 tagname = "cacheSource" 

952 

953 type = Set(values=(['worksheet', 'external', 'consolidation', 'scenario'])) 

954 connectionId = Integer(allow_none=True) 

955 # some elements are choice 

956 worksheetSource = Typed(expected_type=WorksheetSource, allow_none=True) 

957 consolidation = Typed(expected_type=Consolidation, allow_none=True) 

958 extLst = Typed(expected_type=ExtensionList, allow_none=True) 

959 

960 __elements__ = ('worksheetSource', 'consolidation',) 

961 

962 def __init__(self, 

963 type=None, 

964 connectionId=None, 

965 worksheetSource=None, 

966 consolidation=None, 

967 extLst=None, 

968 ): 

969 self.type = type 

970 self.connectionId = connectionId 

971 self.worksheetSource = worksheetSource 

972 self.consolidation = consolidation 

973 

974 

975class CacheDefinition(Serialisable): 

976 

977 mime_type = "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml" 

978 rel_type = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition" 

979 _id = 1 

980 _path = "/xl/pivotCache/pivotCacheDefinition{0}.xml" 

981 records = None 

982 

983 tagname = "pivotCacheDefinition" 

984 

985 invalid = Bool(allow_none=True) 

986 saveData = Bool(allow_none=True) 

987 refreshOnLoad = Bool(allow_none=True) 

988 optimizeMemory = Bool(allow_none=True) 

989 enableRefresh = Bool(allow_none=True) 

990 refreshedBy = String(allow_none=True) 

991 refreshedDate = Float(allow_none=True) 

992 refreshedDateIso = DateTime(allow_none=True) 

993 backgroundQuery = Bool(allow_none=True) 

994 missingItemsLimit = Integer(allow_none=True) 

995 createdVersion = Integer(allow_none=True) 

996 refreshedVersion = Integer(allow_none=True) 

997 minRefreshableVersion = Integer(allow_none=True) 

998 recordCount = Integer(allow_none=True) 

999 upgradeOnRefresh = Bool(allow_none=True) 

1000 tupleCache = Bool(allow_none=True) 

1001 supportSubquery = Bool(allow_none=True) 

1002 supportAdvancedDrill = Bool(allow_none=True) 

1003 cacheSource = Typed(expected_type=CacheSource) 

1004 cacheFields = NestedSequence(expected_type=CacheField, count=True) 

1005 cacheHierarchies = NestedSequence(expected_type=CacheHierarchy, allow_none=True) 

1006 kpis = NestedSequence(expected_type=PCDKPI, allow_none=True) 

1007 tupleCache = Typed(expected_type=TupleCache, allow_none=True) 

1008 calculatedItems = NestedSequence(expected_type=CalculatedItem, count=True) 

1009 calculatedMembers = NestedSequence(expected_type=CalculatedMember, count=True) 

1010 dimensions = NestedSequence(expected_type=PivotDimension, allow_none=True) 

1011 measureGroups = NestedSequence(expected_type=MeasureGroup, count=True) 

1012 maps = NestedSequence(expected_type=MeasureDimensionMap, count=True) 

1013 extLst = Typed(expected_type=ExtensionList, allow_none=True) 

1014 id = Relation() 

1015 

1016 __elements__ = ('cacheSource', 'cacheFields', 'cacheHierarchies', 'kpis', 

1017 'tupleCache', 'calculatedItems', 'calculatedMembers', 'dimensions', 

1018 'measureGroups', 'maps',) 

1019 

1020 def __init__(self, 

1021 invalid=None, 

1022 saveData=None, 

1023 refreshOnLoad=None, 

1024 optimizeMemory=None, 

1025 enableRefresh=None, 

1026 refreshedBy=None, 

1027 refreshedDate=None, 

1028 refreshedDateIso=None, 

1029 backgroundQuery=None, 

1030 missingItemsLimit=None, 

1031 createdVersion=None, 

1032 refreshedVersion=None, 

1033 minRefreshableVersion=None, 

1034 recordCount=None, 

1035 upgradeOnRefresh=None, 

1036 tupleCache=None, 

1037 supportSubquery=None, 

1038 supportAdvancedDrill=None, 

1039 cacheSource=None, 

1040 cacheFields=(), 

1041 cacheHierarchies=(), 

1042 kpis=(), 

1043 calculatedItems=(), 

1044 calculatedMembers=(), 

1045 dimensions=(), 

1046 measureGroups=(), 

1047 maps=(), 

1048 extLst=None, 

1049 id = None, 

1050 ): 

1051 self.invalid = invalid 

1052 self.saveData = saveData 

1053 self.refreshOnLoad = refreshOnLoad 

1054 self.optimizeMemory = optimizeMemory 

1055 self.enableRefresh = enableRefresh 

1056 self.refreshedBy = refreshedBy 

1057 self.refreshedDate = refreshedDate 

1058 self.refreshedDateIso = refreshedDateIso 

1059 self.backgroundQuery = backgroundQuery 

1060 self.missingItemsLimit = missingItemsLimit 

1061 self.createdVersion = createdVersion 

1062 self.refreshedVersion = refreshedVersion 

1063 self.minRefreshableVersion = minRefreshableVersion 

1064 self.recordCount = recordCount 

1065 self.upgradeOnRefresh = upgradeOnRefresh 

1066 self.tupleCache = tupleCache 

1067 self.supportSubquery = supportSubquery 

1068 self.supportAdvancedDrill = supportAdvancedDrill 

1069 self.cacheSource = cacheSource 

1070 self.cacheFields = cacheFields 

1071 self.cacheHierarchies = cacheHierarchies 

1072 self.kpis = kpis 

1073 self.tupleCache = tupleCache 

1074 self.calculatedItems = calculatedItems 

1075 self.calculatedMembers = calculatedMembers 

1076 self.dimensions = dimensions 

1077 self.measureGroups = measureGroups 

1078 self.maps = maps 

1079 self.id = id 

1080 

1081 

1082 def to_tree(self): 

1083 node = super(CacheDefinition, self).to_tree() 

1084 node.set("xmlns", SHEET_MAIN_NS) 

1085 return node 

1086 

1087 

1088 @property 

1089 def path(self): 

1090 return self._path.format(self._id) 

1091 

1092 

1093 def _write(self, archive, manifest): 

1094 """ 

1095 Add to zipfile and update manifest 

1096 """ 

1097 self._write_rels(archive, manifest) 

1098 xml = tostring(self.to_tree()) 

1099 archive.writestr(self.path[1:], xml) 

1100 manifest.append(self) 

1101 

1102 

1103 def _write_rels(self, archive, manifest): 

1104 """ 

1105 Write the relevant child objects and add links 

1106 """ 

1107 if self.records is None: 

1108 return 

1109 

1110 rels = RelationshipList() 

1111 r = Relationship(Type=self.records.rel_type, Target=self.records.path) 

1112 rels.append(r) 

1113 self.id = r.id 

1114 self.records._id = self._id 

1115 self.records._write(archive, manifest) 

1116 

1117 path = get_rels_path(self.path) 

1118 xml = tostring(rels.to_tree()) 

1119 archive.writestr(path[1:], xml)