本文整理汇总了Python中pex.variables.Variables类的典型用法代码示例。如果您正苦于以下问题:Python Variables类的具体用法?Python Variables怎么用?Python Variables使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Variables类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: assert_pex_vars_hermetic
def assert_pex_vars_hermetic():
v = Variables()
assert os.environ == v.copy()
existing = os.environ.get('TEST')
expected = (existing or '') + 'different'
assert expected != existing
with environment_as(TEST=expected):
assert expected != v.copy().get('TEST')
示例2: test_pex_vars_set
def test_pex_vars_set():
v = Variables(environ={})
v.set('HELLO', '42')
assert v._get_int('HELLO') == 42
v.delete('HELLO')
assert v._get_int('HELLO') is None
assert {} == v.copy()
示例3: test_pex_vars_defaults_stripped
def test_pex_vars_defaults_stripped():
v = Variables(environ={})
stripped = v.strip_defaults()
# bool
assert v.PEX_ALWAYS_CACHE is not None
assert stripped.PEX_ALWAYS_CACHE is None
# string
assert v.PEX_PATH is not None
assert stripped.PEX_PATH is None
# int
assert v.PEX_VERBOSE is not None
assert stripped.PEX_VERBOSE is None
示例4: test_process_pydoc
def test_process_pydoc():
def thing():
# no pydoc
pass
assert Variables.process_pydoc(thing.__doc__) == ('Unknown', 'Unknown')
def other_thing():
"""Type
Properly
formatted
text.
"""
assert Variables.process_pydoc(other_thing.__doc__) == (
'Type', 'Properly formatted text.')
示例5: test_process_pydoc
def test_process_pydoc():
def thing():
# no pydoc
pass
assert Variables.process_pydoc(thing.__doc__) == ("Unknown", "Unknown")
def other_thing():
"""Type
Properly
formatted
text.
"""
assert Variables.process_pydoc(other_thing.__doc__) == ("Type", "Properly formatted text.")
示例6: get_pex_python_paths
def get_pex_python_paths():
"""Returns a list of paths to Python interpreters as defined in a pexrc file.
These are provided by a PEX_PYTHON_PATH in either of '/etc/pexrc', '~/.pexrc'.
PEX_PYTHON_PATH defines a colon-separated list of paths to interpreters
that a pex can be built and run against.
"""
ppp = Variables.from_rc().get('PEX_PYTHON_PATH')
if ppp:
return ppp.split(os.pathsep)
else:
return []
示例7: pex_python_paths
def pex_python_paths(cls):
"""A list of paths to Python interpreter binaries as defined by a
PEX_PYTHON_PATH defined in either in '/etc/pexrc', '~/.pexrc'.
PEX_PYTHON_PATH defines a colon-seperated list of paths to interpreters
that a pex can be built and ran against.
:return: paths to interpreters as specified by PEX_PYTHON_PATH
:rtype: list
"""
ppp = Variables.from_rc().get('PEX_PYTHON_PATH')
if ppp:
return ppp.split(os.pathsep)
else:
return []
示例8: test_pexrc_precedence
def test_pexrc_precedence():
with named_temporary_file(mode='w') as pexrc:
pexrc.write('HELLO=FORTYTWO')
pexrc.flush()
v = Variables(rc=pexrc.name, environ={'HELLO': 42})
assert v._get_int('HELLO') == 42
示例9: test_pex_from_rc
def test_pex_from_rc():
with named_temporary_file(mode='w') as pexrc:
pexrc.write('HELLO=42')
pexrc.flush()
v = Variables(rc=pexrc.name)
assert v._get_int('HELLO') == 42
示例10: test_iter_help
def test_iter_help():
for variable_name, variable_type, variable_text in Variables.iter_help():
assert variable_name.startswith("PEX_")
assert "\n" not in variable_type
assert "\n" not in variable_text
示例11: test_iter_help
def test_iter_help():
for variable_name, variable_type, variable_text in Variables.iter_help():
assert variable_name.startswith('PEX_')
assert '\n' not in variable_type
assert '\n' not in variable_text
示例12: test_pex_get_kv
def test_pex_get_kv():
v = Variables(environ={})
assert v._get_kv('HELLO') is None
assert v._get_kv('=42') is None
assert v._get_kv('TOO=MANY=COOKS') is None
assert v._get_kv('THIS=WORKS') == ['THIS', 'WORKS']
示例13: print_variable_help
def print_variable_help(option, option_str, option_value, parser):
for variable_name, variable_type, variable_help in Variables.iter_help():
print('\n%s: %s\n' % (variable_name, variable_type))
for line in TextWrapper(initial_indent=' ' * 4, subsequent_indent=' ' * 4).wrap(variable_help):
print(line)
sys.exit(0)
示例14: test_pex_vars_set
def test_pex_vars_set():
v = Variables(environ={})
v.set("HELLO", "42")
assert v._get_int("HELLO") == 42
v.delete("HELLO")
assert v._get_int("HELLO") is None
示例15: test_pex_get_kv
def test_pex_get_kv():
v = Variables(environ={})
assert v._get_kv("HELLO") is None
assert v._get_kv("=42") is None
assert v._get_kv("TOO=MANY=COOKS") is None
assert v._get_kv("THIS=WORKS") == ["THIS", "WORKS"]