當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。