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


Python variables.Variables类代码示例

本文整理汇总了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')
开发者ID:jsirois,项目名称:pex,代码行数:10,代码来源:test_variables.py

示例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()
开发者ID:jsirois,项目名称:pex,代码行数:7,代码来源:test_variables.py

示例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
开发者ID:pfmoore,项目名称:pex,代码行数:15,代码来源:test_variables.py

示例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.')
开发者ID:pfmoore,项目名称:pex,代码行数:16,代码来源:test_variables.py

示例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.")
开发者ID:sdjsngs,项目名称:pex,代码行数:16,代码来源:test_variables.py

示例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 []
开发者ID:jsirois,项目名称:pants,代码行数:12,代码来源:python_setup.py

示例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 []
开发者ID:baroquebobcat,项目名称:pants,代码行数:14,代码来源:interpreter_cache.py

示例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
开发者ID:pfmoore,项目名称:pex,代码行数:6,代码来源:test_variables.py

示例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
开发者ID:pfmoore,项目名称:pex,代码行数:6,代码来源:test_variables.py

示例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
开发者ID:sdjsngs,项目名称:pex,代码行数:5,代码来源:test_variables.py

示例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
开发者ID:pfmoore,项目名称:pex,代码行数:5,代码来源:test_variables.py

示例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']
开发者ID:pfmoore,项目名称:pex,代码行数:6,代码来源:test_variables.py

示例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)
开发者ID:Houzz,项目名称:pex,代码行数:6,代码来源:pex.py

示例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
开发者ID:sdjsngs,项目名称:pex,代码行数:6,代码来源:test_variables.py

示例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"]
开发者ID:sdjsngs,项目名称:pex,代码行数:6,代码来源:test_variables.py


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