~therp-nl/anybox.recipe.openerp/jbaudoux-relative_paths_resolve_conflict

« back to all changes in this revision

Viewing changes to anybox/recipe/openerp/base.py

[MRG] Update with target branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
 
38
38
class MainSoftware(object):
39
39
    """Placeholder to represent the main software instead of an addon location.
 
40
 
 
41
    Should just have a singleton instance: :data:`main_software`,
 
42
    whose meaning depends on the concrete recipe class using it.
 
43
 
 
44
    For example, in :class:`anybox.recipe.openerp.server.ServerRecipe`,
 
45
    :data:`main_software` represents the OpenObject server or the OpenERP
 
46
    standard distribution.
40
47
    """
41
48
 
42
49
    def __str__(self):
51
58
    """Base class for other recipes.
52
59
 
53
60
    It implements notably fetching of the main software part plus addons.
54
 
    The ``sources`` attributes is a dict storing how to fetch the main software
55
 
    part and specified addons. It has the following structure:
56
 
 
57
 
        local path -> (type, location_spec, options).
58
 
 
59
 
        where local path is the ``main_software`` object for the main software
60
 
        part, and otherwise a local path to an addons container.
61
 
 
62
 
        type can be
63
 
            - 'local'
64
 
            - 'downloadable'
65
 
            - one of the supported vcs
66
 
 
67
 
        location_spec is, depending on the type, a tuple specifying how to
68
 
        fetch : (url, None), or (vcs_url, vcs_revision) or None
69
 
 
70
 
        addons options are typically used to specify that the addons directory
71
 
        is actually a subdir of the specified one.
 
61
 
 
62
    The :attr:`sources` attribute is a ``dict`` storing how to fetch the main
 
63
    software part and the specified addons, with the following structure:
 
64
 
 
65
       ``local path -> (type, location_spec, options)``, in which:
 
66
 
 
67
       :local path: is either the :data:`main_software` singleton
 
68
                    (see :class:`MainSoftware`) or a local path to an
 
69
                    addons directory.
 
70
       :type: can be either
 
71
 
 
72
              * ``'local'``
 
73
              * ``'downloadable'``
 
74
              * one of the supported vcs
 
75
 
 
76
       :location_spec: is, depending on the type, a tuple specifying how
 
77
                       fetch is to be done:
 
78
 
 
79
                       ``(url, None)``, or ``(vcs_url, vcs_revision)``
 
80
                       or ``None``
 
81
       :addons options: are typically used to specify that the addons
 
82
                        directory is actually a subdir of the specified one.
 
83
 
 
84
                        VCS support classes (see
 
85
                        :mod:`anybox.recipe.openerp.vcs`) can implemented their
 
86
                        dedicated options
72
87
 
73
88
    """
74
89
 
164
179
        self.parse_revisions(options)
165
180
 
166
181
    def parse_version(self):
167
 
        """Set the main software in ``sources`` and related attributes.
 
182
        """Set the main software in :attr:`sources` and related attributes.
168
183
        """
169
184
        self.version_wanted = self.options.get('version')
170
185
        if self.version_wanted is None:
438
453
            os.putenv('PYTHONPATH', pythonpath_bak)
439
454
 
440
455
    def parse_addons(self, options):
441
 
        """Parse the addons options into the ``sources`` attribute.
 
456
        """Parse the addons options into :attr:`sources`.
442
457
 
443
 
        See ``BaseRecipe`` docstring for details about the ``sources`` dict.
 
458
        See :class:`BaseRecipe` for the structure of :attr:`sources`.
444
459
        """
445
460
 
446
461
        for line in options.get('addons', '').split(os.linesep):
462
477
            self.sources[addons_dir] = (loc_type, location_spec, options)
463
478
 
464
479
    def parse_revisions(self, options):
465
 
        """Parse revisions options and update the ``sources`` attribute.
 
480
        """Parse revisions options and update :attr:`sources`.
466
481
 
467
 
        It is assumed that ``sources`` has already been populated, and
468
 
        notably has a main_software part.
 
482
        It is assumed that :attr:`sources` has already been populated, and
 
483
        notably has a :data:`main_software` entry.
469
484
        This allows for easy fixing of revisions in an extension buildout
 
485
 
 
486
        See :class:`BaseRecipe` for the structure of :attr:`sources`.
470
487
        """
471
488
        for line in options.get('revisions', '').split(os.linesep):
472
489
            # GR inline comment should have not gone through, but sometimes
505
522
                                        + source[2:])
506
523
 
507
524
    def retrieve_addons(self):
508
 
        """Parse the addons option line, download and return a list of paths.
 
525
        """Peform all lookup and downloads specified in :attr:`sources`.
509
526
 
510
 
        syntax: repo_type repo_url repo_dir repo_rev [options]
511
 
              or an absolute or relative path
512
 
        options are themselves in the key=value form
 
527
        See :class:`BaseRecipe` for the structure of :attr:`sources`.
513
528
        """
514
529
        self.addons_paths = []
515
530
        for local_dir, source_spec in self.sources.items():
623
638
        logger.info("No need to re-download %s", self.archive_path)
624
639
 
625
640
    def retrieve_main_software(self):
626
 
        """install server, webclient or gtkclient."""
 
641
        """Lookup or fetch the main software.
 
642
 
 
643
        See :class:`MainSoftware` and :class:`BaseRecipe` for explanations.
 
644
        """
627
645
 
628
646
        source = self.sources[main_software]
629
647
        type_spec = source[0]
751
769
    def dump_nightly_latest_version(self):
752
770
        """After download/analysis of 'nightly latest', give equivalent spec.
753
771
        """
754
 
        return ' '.join((self.nightly_series, 'nightly', self.nightly_version))
 
772
        return ' '.join(('nightly', self.nightly_series, self.nightly_version))
755
773
 
756
774
    def freeze_to(self, out_config_path):
757
775
        """Create an extension buildout freezing current revisions & versions.
1141
1159
        else:
1142
1160
            base_addons = join(self.openerp_dir, 'openerp', 'addons')
1143
1161
        if os.path.exists(base_addons):
1144
 
            self.addons_paths.append(base_addons)
 
1162
            self.addons_paths.insert(0, base_addons)
1145
1163
 
1146
1164
        if check_existence:
1147
1165
            for path in self.addons_paths: