本文整理汇总了Python中conans.model.values.Values.copy方法的典型用法代码示例。如果您正苦于以下问题:Python Values.copy方法的具体用法?Python Values.copy怎么用?Python Values.copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类conans.model.values.Values
的用法示例。
在下文中一共展示了Values.copy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: OptionsValues
# 需要导入模块: from conans.model.values import Values [as 别名]
# 或者: from conans.model.values.Values import copy [as 别名]
class OptionsValues(object):
""" static= True,
Boost.static = False,
Poco.optimized = True
"""
def __init__(self):
self._options = Values()
self._reqs_options = {} # {name("Boost": Values}
def __getitem__(self, item):
return self._reqs_options.setdefault(item, Values())
def pop(self, item):
return self._reqs_options.pop(item, None)
def __repr__(self):
return self.dumps()
def __getattr__(self, attr):
return getattr(self._options, attr)
def copy(self):
result = OptionsValues()
result._options = self._options.copy()
for k, v in self._reqs_options.items():
result._reqs_options[k] = v.copy()
return result
def __setattr__(self, attr, value):
if attr[0] == "_":
return super(OptionsValues, self).__setattr__(attr, value)
return setattr(self._options, attr, value)
def clear_indirect(self):
for v in self._reqs_options.values():
v.clear()
def as_list(self):
result = []
options_list = self._options.as_list()
if options_list:
result.extend(options_list)
for key in sorted(self._reqs_options.keys()):
for line in self._reqs_options[key].as_list():
line_key, line_value = line
result.append(("%s:%s" % (key, line_key), line_value))
return result
@staticmethod
def from_list(data):
result = OptionsValues()
by_package = defaultdict(list)
for k, v in data:
tokens = k.split(":")
if len(tokens) == 2:
package, option = tokens
by_package[package.strip()].append((option, v))
else:
by_package[None].append((k, v))
result._options = Values.from_list(by_package[None])
for k, v in by_package.items():
if k is not None:
result._reqs_options[k] = Values.from_list(v)
return result
def dumps(self):
result = []
for key, value in self.as_list():
result.append("%s=%s" % (key, value))
return "\n".join(result)
@staticmethod
def loads(text):
result = OptionsValues()
for line in text.splitlines():
line = line.strip()
if not line:
continue
tokens = line.split(":")
if len(tokens) == 2:
package, option = tokens
current = result._reqs_options.setdefault(package.strip(), Values())
else:
option = tokens[0].strip()
current = result._options
current.add(option)
return result
@property
def sha(self):
result = []
result.append(self._options.sha)
for key in sorted(list(self._reqs_options.keys())):
result.append(self._reqs_options[key].sha)
return sha1('\n'.join(result).encode())
def serialize(self):
ret = {}
ret["options"] = self._options.serialize()
ret["req_options"] = {}
#.........这里部分代码省略.........