Projet

Général

Profil

tiramisu.patch

Lionel Morin, 05/01/2017 16:46

Télécharger (3,04 ko)

Voir les différences:

tiramisu/config.py
436 436

  
437 437
    def make_dict(self, flatten=False, _currpath=None, withoption=None,
438 438
                  withvalue=undefined, force_permissive=False,
439
                  setting_properties=undefined):
439
                  setting_properties=undefined, fullpath=False):
440 440
        """exports the whole config into a `dict`, for example:
441 441

  
442 442
        >>> print cfg.make_dict()
......
506 506
                        path = path[len(tmypath):]
507 507
                self._make_sub_dict(opt, path, pathsvalues, _currpath, flatten,
508 508
                                    force_permissive=force_permissive,
509
                                    setting_properties=setting_properties)
509
                                    setting_properties=setting_properties,
510
                                    fullpath=fullpath)
510 511
        #withoption can be set to None below !
511 512
        if withoption is None:
512 513
            for opt in self.cfgimpl_get_description().impl_getchildren():
513 514
                path = opt.impl_getname()
514 515
                self._make_sub_dict(opt, path, pathsvalues, _currpath, flatten,
515 516
                                    force_permissive=force_permissive,
516
                                    setting_properties=setting_properties)
517
                                    setting_properties=setting_properties,
518
                                    fullpath=fullpath)
517 519
        if _currpath == []:
518 520
            options = dict(pathsvalues)
519 521
            return options
520 522
        return pathsvalues
521 523

  
522 524
    def _make_sub_dict(self, opt, path, pathsvalues, _currpath, flatten,
523
                       setting_properties, force_permissive=False):
525
                       setting_properties, force_permissive=False, fullpath=False):
524 526
        value = self.getattr(path,
525 527
                             force_permissive=force_permissive,
526 528
                             _setting_properties=setting_properties,
......
533 535
                    pathsvalues += value.make_dict(flatten,
534 536
                                                   _currpath + path.split('.'),
535 537
                                                   force_permissive=force_permissive,
536
                                                   setting_properties=setting_properties)
538
                                                   setting_properties=setting_properties,
539
                                                   fullpath=fullpath)
537 540
            else:
538 541
                if flatten:
539 542
                    name = opt.impl_getname()
540 543
                else:
541
                    name = '.'.join(_currpath + [opt.impl_getname()])
544
                    if fullpath:
545
                        name = '.'.join([self._impl_path,  opt.impl_getname()])
546
                    else:
547
                        name = '.'.join(_currpath + [opt.impl_getname()])
542 548
                pathsvalues.append((name, value))
543 549

  
544 550
    def cfgimpl_get_path(self, dyn=True):