当前位置: 首页>>代码示例>>Python>>正文


Python options.OptionsValues类代码示例

本文整理汇总了Python中conans.model.options.OptionsValues的典型用法代码示例。如果您正苦于以下问题:Python OptionsValues类的具体用法?Python OptionsValues怎么用?Python OptionsValues使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了OptionsValues类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: deserialize

 def deserialize(data):
     res = ConanInfo()
     res.settings = Values.deserialize(data["settings"])
     res.full_settings = Values.deserialize(data["full_settings"])
     res.options = OptionsValues.deserialize(data["options"])
     res.full_options = OptionsValues.deserialize(data["full_options"])
     res.requires = RequirementsInfo.deserialize(data["requires"])
     res.full_requires = RequirementsList.deserialize(data["full_requires"])
     return res
开发者ID:,项目名称:,代码行数:9,代码来源:

示例2: basic_test

    def basic_test(self):
        options = OptionsValues.loads("""other_option=True
        optimized_var=3
        Poco:deps_bundled=True
        Boost:static=False
        Boost:thread=True
        Boost:thread.multi=off
        Hello1:static=False
        Hello1:optimized=4
        """)
        down_ref = ConanFileReference.loads("Hello0/[email protected]/testing")
        own_ref = ConanFileReference.loads("Hello1/[email protected]/testing")
        output = TestBufferConanOutput()
        self.sut.propagate_upstream(options, down_ref, own_ref, output)
        self.assertEqual(self.sut.values.as_list(), [("optimized", "4"),
                                                     ("path", "NOTDEF"),
                                                     ("static", "False"),
                                                     ("Boost:static", "False"),
                                                     ("Boost:thread", "True"),
                                                     ("Boost:thread.multi", "off"),
                                                     ("Poco:deps_bundled", "True")])

        options2 = OptionsValues.loads("""other_option=True
        optimized_var=3
        Poco:deps_bundled=What
        Boost:static=2
        Boost:thread=Any
        Boost:thread.multi=on
        Hello1:static=True
        Hello1:optimized=2
        """)
        down_ref = ConanFileReference.loads("Hello2/[email protected]/testing")
        self.sut.propagate_upstream(options2, down_ref, own_ref, output)
        self.assertIn("""WARN: Hello2/[email protected]/testing tried to change Hello1/[email protected]/testing option optimized to 2
but it was already assigned to 4 by Hello0/[email protected]/testing
WARN: Hello2/[email protected]/testing tried to change Hello1/[email protected]/testing option static to True
but it was already assigned to False by Hello0/[email protected]/testing
WARN: Hello2/[email protected]/testing tried to change Hello1/[email protected]/testing option Boost:static to 2
but it was already assigned to False by Hello0/[email protected]/testing
WARN: Hello2/[email protected]/testing tried to change Hello1/[email protected]/testing option Boost:thread to Any
but it was already assigned to True by Hello0/[email protected]/testing
WARN: Hello2/[email protected]/testing tried to change Hello1/[email protected]/testing option Boost:thread.multi to on
but it was already assigned to off by Hello0/[email protected]/testing
WARN: Hello2/[email protected]/testing tried to change Hello1/[email protected]/testing option Poco:deps_bundled to What
but it was already assigned to True by Hello0/[email protected]/testing""", str(output))
        self.assertEqual(self.sut.values.dumps(),
                         """optimized=4
path=NOTDEF
static=False
Boost:static=False
Boost:thread=True
Boost:thread.multi=off
Poco:deps_bundled=True""")
开发者ID:JustgeekDE,项目名称:conan,代码行数:53,代码来源:options_test.py

示例3: loads

    def loads(text):
        parser = ConfigParser(text, ["settings", "full_settings", "options", "full_options",
                                     "requires", "full_requires"])

        result = ConanInfo()
        result.settings = Values.loads(parser.settings)
        result.full_settings = Values.loads(parser.full_settings)
        result.options = OptionsValues.loads(parser.options)
        result.full_options = OptionsValues.loads(parser.full_options)
        result.full_requires = RequirementsList.loads(parser.full_requires)
        result.requires = RequirementsInfo(result.full_requires)
        # TODO: Missing handling paring of requires, but not necessary now
        return result
开发者ID:KindDragon,项目名称:conan,代码行数:13,代码来源:info.py

示例4: __init__

 def __init__(self):
     # Sections
     self.settings = OrderedDict()
     self.package_settings = defaultdict(OrderedDict)
     self.env_values = EnvValues()
     self.options = OptionsValues()
     self.build_requires = OrderedDict()  # conan_ref Pattern: list of conan_ref
开发者ID:19317362,项目名称:conan,代码行数:7,代码来源:profile.py

示例5: loads

    def loads(text):
        parser = ConfigParser(text, ["settings", "full_settings", "options", "full_options",
                                     "requires", "full_requires", "scope", "recipe_hash",
                                     "env"], raise_unexpected_field=False)
        result = ConanInfo()
        result.settings = Values.loads(parser.settings)
        result.full_settings = Values.loads(parser.full_settings)
        result.options = OptionsValues.loads(parser.options)
        result.full_options = OptionsValues.loads(parser.full_options)
        result.full_requires = RequirementsList.loads(parser.full_requires)
        result.requires = RequirementsInfo(result.full_requires)
        result.recipe_hash = parser.recipe_hash or None

        # TODO: Missing handling paring of requires, but not necessary now
        result.env_values = EnvValues.loads(parser.env)
        return result
开发者ID:19317362,项目名称:conan,代码行数:16,代码来源:info.py

示例6: _parse_conan_txt

    def _parse_conan_txt(self, contents, path, output):
        conanfile = ConanFile(output, self._runner, Settings())
        # It is necessary to copy the settings, because the above is only a constraint of
        # conanfile settings, and a txt doesn't define settings. Necessary for generators,
        # as cmake_multi, that check build_type.
        conanfile.settings = self._settings.copy_values()

        try:
            parser = ConanFileTextLoader(contents)
        except Exception as e:
            raise ConanException("%s:\n%s" % (path, str(e)))
        for requirement_text in parser.requirements:
            ConanFileReference.loads(requirement_text)  # Raise if invalid
            conanfile.requires.add(requirement_text)
        for build_requirement_text in parser.build_requirements:
            ConanFileReference.loads(build_requirement_text)
            if not hasattr(conanfile, "build_requires"):
                conanfile.build_requires = []
            conanfile.build_requires.append(build_requirement_text)

        conanfile.generators = parser.generators

        options = OptionsValues.loads(parser.options)
        conanfile.options.values = options
        conanfile.options.initialize_upstream(self._user_options)

        # imports method
        conanfile.imports = parser.imports_method(conanfile)
        conanfile._env_values.update(self._env_values)
        return conanfile
开发者ID:19317362,项目名称:conan,代码行数:30,代码来源:loader.py

示例7: load_conan_txt

    def load_conan_txt(self, conan_requirements_path, output):

        if not os.path.exists(conan_requirements_path):
            raise NotFoundException("Conanfile not found!")

        conanfile = ConanFile(output, self._runner, self._settings.copy(),
                              os.path.dirname(conan_requirements_path))

        try:
            parser = ConanFileTextLoader(load(conan_requirements_path))
        except Exception as e:
            raise ConanException("%s:\n%s" % (conan_requirements_path, str(e)))
        for requirement_text in parser.requirements:
            ConanFileReference.loads(requirement_text)  # Raise if invalid
            conanfile.requires.add(requirement_text)

        conanfile.generators = parser.generators

        options = OptionsValues.loads(parser.options)
        conanfile.options.values = options
        conanfile.options.initialize_upstream(self._options)

        # imports method
        conanfile.imports = ConanFileTextLoader.imports_method(conanfile,
                                                               parser.import_parameters)
        conanfile.scope = self._scopes.package_scope()
        return conanfile
开发者ID:WimK,项目名称:conan,代码行数:27,代码来源:loader.py

示例8: _loader

    def _loader(self, current_path=None, user_settings_values=None, user_options_values=None,
                scopes=None):
        # The disk settings definition, already including the default disk values
        settings = self._paths.settings
        options = OptionsValues()
        conaninfo_scopes = Scopes()

        if current_path:
            conan_info_path = os.path.join(current_path, CONANINFO)
            if os.path.exists(conan_info_path):
                existing_info = ConanInfo.load_file(conan_info_path)
                settings.values = existing_info.full_settings
                options = existing_info.full_options  # Take existing options from conaninfo.txt
                conaninfo_scopes = existing_info.scope

        if user_settings_values:
            aux_values = Values.from_list(user_settings_values)
            settings.values = aux_values

        if user_options_values is not None:  # Install will pass an empty list []
            # Install OVERWRITES options, existing options in CONANINFO are not taken
            # into account, just those from CONANFILE + user command line
            options = OptionsValues.from_list(user_options_values)

        if scopes:
            conaninfo_scopes.update_scope(scopes)

        self._current_scopes = conaninfo_scopes
        return ConanFileLoader(self._runner, settings, options=options, scopes=conaninfo_scopes)
开发者ID:JustgeekDE,项目名称:conan,代码行数:29,代码来源:manager.py

示例9: test_replace_in_file

    def test_replace_in_file(self):
        file_content = '''
from conans import ConanFile
from conans.tools import download, unzip, replace_in_file
import os

class ConanFileToolsTest(ConanFile):
    name = "test"
    version = "1.9.10"
    settings = []

    def source(self):
        pass

    def build(self):
        replace_in_file("otherfile.txt", "ONE TWO THREE", "FOUR FIVE SIX")

'''
        tmp_dir = temp_folder()
        file_path = os.path.join(tmp_dir, "conanfile.py")
        other_file = os.path.join(tmp_dir, "otherfile.txt")
        save(file_path, file_content)
        save(other_file, "ONE TWO THREE")
        loader = ConanFileLoader(None, None, Settings(), OptionsValues.loads(""))
        ret = loader.load_conan(file_path)
        curdir = os.path.abspath(os.curdir)
        os.chdir(tmp_dir)
        try:
            ret.build()
        finally:
            os.chdir(curdir)

        content = load(other_file)
        self.assertEquals(content, "FOUR FIVE SIX")
开发者ID:zaitrarrio,项目名称:conan,代码行数:34,代码来源:conanfile_tools_test.py

示例10: setUp

 def setUp(self):
     self.sut = OptionsValues.loads("""static=True
     optimized=3
     Poco:deps_bundled=True
     Boost:static=False
     Boost:thread=True
     Boost:thread.multi=off
     """)
开发者ID:JustgeekDE,项目名称:conan,代码行数:8,代码来源:options_test.py

示例11: create_options

def create_options(conanfile):
    try:
        package_options = PackageOptions(getattr(conanfile, "options", None))
        options = Options(package_options)

        default_options = getattr(conanfile, "default_options", None)
        if default_options:
            if isinstance(default_options, tuple):
                default_values = OptionsValues.loads("\n".join(default_options))
            elif isinstance(default_options, list):
                default_values = OptionsValues.from_list(default_options)
            elif isinstance(default_options, basestring):
                default_values = OptionsValues.loads(default_options)
            else:
                raise ConanException("Please define your default_options as list or " "multiline string")
            options.values = default_values
        return options
    except Exception as e:
        raise ConanException("Error while initializing options. %s" % str(e))
开发者ID:zaitrarrio,项目名称:conan,代码行数:19,代码来源:conan_file.py

示例12: _build_and_check

    def _build_and_check(self, tmp_dir, file_path, text_file, msg):
        loader = ConanFileLoader(None, Settings(), None, OptionsValues.loads(""), Scopes(),
                                 None, None)
        ret = loader.load_conan(file_path, None)
        curdir = os.path.abspath(os.curdir)
        os.chdir(tmp_dir)
        try:
            ret.build()
        finally:
            os.chdir(curdir)

        content = load(text_file)
        self.assertEquals(content, msg)
开发者ID:conan-io,项目名称:conan,代码行数:13,代码来源:conanfile_tools_test.py

示例13: test_package_settings

    def test_package_settings(self):
        # CREATE A CONANFILE TO LOAD
        tmp_dir = temp_folder()
        conanfile_path = os.path.join(tmp_dir, "conanfile.py")
        conanfile = """from conans import ConanFile
class MyTest(ConanFile):
    requires = {}
    name = "MyPackage"
    version = "1.0"
    settings = "os"
"""
        save(conanfile_path, conanfile)

        # Apply windows for MyPackage
        package_settings = {"MyPackage": [("os", "Windows")]}
        loader = ConanFileLoader(None, Settings({"os": ["Windows", "Linux"]}),
                                 package_settings, OptionsValues.loads(""), Scopes(),
                                 None, None)

        recipe = loader.load_conan(conanfile_path, None)
        self.assertEquals(recipe.settings.os, "Windows")

        # Apply Linux for MyPackage
        package_settings = {"MyPackage": [("os", "Linux")]}
        loader = ConanFileLoader(None, Settings({"os": ["Windows", "Linux"]}),
                                 package_settings, OptionsValues.loads(""), Scopes(),
                                 None, None)

        recipe = loader.load_conan(conanfile_path, None)
        self.assertEquals(recipe.settings.os, "Linux")

        # If the package name is different from the conanfile one, it wont apply
        package_settings = {"OtherPACKAGE": [("os", "Linux")]}
        loader = ConanFileLoader(None, Settings({"os": ["Windows", "Linux"]}),
                                 package_settings, OptionsValues.loads(""), Scopes(),
                                 None, None)

        recipe = loader.load_conan(conanfile_path, None)
        self.assertIsNone(recipe.settings.os.value)
开发者ID:conan-io,项目名称:conan,代码行数:39,代码来源:conanfile_loader_test.py

示例14: _apply_inner_profile

def _apply_inner_profile(doc, base_profile):
    """

    :param doc: ConfigParser object from the current profile (excluding includes and vars, and with values already replaced)
    :param base_profile: Profile inherited, it's used as a base profile to modify it.
    :return: None
    """

    def get_package_name_value(item):
        """Parse items like package:name=value or name=value"""
        package_name = None
        if ":" in item:
            tmp = item.split(":", 1)
            package_name, item = tmp

        name, value = item.split("=", 1)
        name = name.strip()
        value = unquote(value)
        return package_name, name, value

    for setting in doc.settings.splitlines():
        setting = setting.strip()
        if setting and not setting.startswith("#"):
            if "=" not in setting:
                raise ConanException("Invalid setting line '%s'" % setting)
            package_name, name, value = get_package_name_value(setting)
            if package_name:
                base_profile.package_settings[package_name][name] = value
            else:
                base_profile.settings[name] = value

    if doc.build_requires:
        # FIXME CHECKS OF DUPLICATED?
        for req in doc.build_requires.splitlines():
            tokens = req.split(":", 1)
            if len(tokens) == 1:
                pattern, req_list = "*", req
            else:
                pattern, req_list = tokens
            req_list = [ConanFileReference.loads(r.strip()) for r in req_list.split(",")]
            base_profile.build_requires.setdefault(pattern, []).extend(req_list)

    if doc.scopes:
        base_profile.update_scopes(Scopes.from_list(doc.scopes.splitlines()))

    if doc.options:
        base_profile.options.update(OptionsValues.loads(doc.options))

    base_profile.env_values.update(EnvValues.loads(doc.env))
开发者ID:nesono,项目名称:conan,代码行数:49,代码来源:profile_loader.py

示例15: requires_init_test

    def requires_init_test(self):
        loader = ConanFileLoader(None, Settings(), None, OptionsValues.loads(""), Scopes(),
                                 None, None)
        tmp_dir = temp_folder()
        conanfile_path = os.path.join(tmp_dir, "conanfile.py")
        conanfile = """from conans import ConanFile
class MyTest(ConanFile):
    requires = {}
    def requirements(self):
        self.requires("MyPkg/[email protected]/channel")
"""
        for requires in ("''", "[]", "()", "None"):
            save(conanfile_path, conanfile.format(requires))
            result = loader.load_conan(conanfile_path, output=None, consumer=True)
            result.requirements()
            self.assertEqual("MyPkg/[email protected]/channel", str(result.requires))
开发者ID:conan-io,项目名称:conan,代码行数:16,代码来源:conanfile_loader_test.py


注:本文中的conans.model.options.OptionsValues类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。