How to use the pystachio.naming.Ref.from_address function in pystachio

To help you get started, we’ve selected a few pystachio examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wickman / pystachio / tests / test_parsing.py View on Github external
bar = "bar derp",
                   baz = "baz blerp")

  joined, unbound = MustacheParser.join(MustacheParser.split("{{foo}}"), oe)
  assert joined == "foo herp"
  assert unbound == []

  splits = MustacheParser.split('blech {{foo}} {{bar}} bonk {{&baz}} bling')
  joined, unbound = MustacheParser.join(splits, oe)
  assert joined == 'blech foo herp bar derp bonk {{baz}} bling'
  assert unbound == []

  splits = MustacheParser.split('{{foo}} {{bar}} {{unbound}}')
  joined, unbound = MustacheParser.join(splits, oe)
  assert joined == 'foo herp bar derp {{unbound}}'
  assert unbound == [Ref.from_address('unbound')]
github wickman / pystachio / tests / test_base.py View on Github external
def ref(address):
  return Ref.from_address(address)
github wickman / pystachio / tests / test_composite_types.py View on Github external
def ref(address):
  return Ref.from_address(address)
github wickman / pystachio / tests / test_naming.py View on Github external
def ref(address):
  return Ref.from_address(address)
github wickman / pystachio / tests / test_base.py View on Github external
def dtd(d):
  return dict((Ref.from_address(key), str(val)) for key, val in d.items())
github wickman / pystachio / tests / test_container_types.py View on Github external
def ref(address):
  return Ref.from_address(address)
github wickman / pystachio / pystachio / parsing.py View on Github external
def split(cls, string, keep_aliases=False):
    splits = cls._MUSTACHE_RE.split(string)
    first_split = splits.pop(0)
    outsplits = [first_split] if first_split else []
    assert len(splits) % 3 == 0
    for k in range(0, len(splits), 3):
      if splits[k] == cls._ADDRESS_DELIMITER:
        outsplits.append('{{%s%s}}' % (
            cls._ADDRESS_DELIMITER if keep_aliases else '',
            splits[k + 1]))
      elif splits[k] is None:
        outsplits.append(Ref.from_address(splits[k + 1]))
      else:
        raise Exception("Unexpected parsing error in Mustache: splits[%s] = '%s'" % (
          k, splits[k]))
      if splits[k + 2]:
        outsplits.append(splits[k + 2])
    return outsplits