How to use munch - 10 common examples

To help you get started, we’ve selected a few munch 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 Pagure / pagure / tests / test_pagure_admin.py View on Github external
"user": None,
                "token": None,
                "active": True,
                "expired": False,
                "all": False,
            }
        )
        with tests.capture_output() as output:
            pagure.cli.admin.do_list_admin_token(list_args)
        output = output.getvalue()
        self.assertNotEqual(output, "No admin tokens found\n")
        self.assertEqual(len(output.split("\n")), 2)
        self.assertIn(" -- pingou -- ", output)

        # Expire the token
        args = munch.Munch({"token": token, "all": False})
        pagure.cli.admin.do_expire_admin_token(args)

        # After
        list_args = munch.Munch(
            {
                "user": None,
                "token": None,
                "active": True,
                "expired": False,
                "all": False,
            }
        )
        with tests.capture_output() as output:
            pagure.cli.admin.do_list_admin_token(list_args)
        output = output.getvalue()
        self.assertEqual(output, "No admin tokens found\n")
github Pagure / pagure / tests / test_pagure_flask.py View on Github external
# Add group packager to project test
        project = pagure.lib.query._get_project(self.session, "test")
        msg = pagure.lib.query.add_group_to_project(
            self.session,
            project=project,
            new_group="packager",
            user="pingou",
            access="ticket",
        )
        self.session.commit()
        self.assertEqual(msg, "Group added")

        repo = pagure.lib.query._get_project(self.session, "test")

        g = munch.Munch()
        g.fas_user = tests.FakeUser(username="foo")
        g.authenticated = True
        g.session = self.session
        with mock.patch("flask.g", g):
            output = pagure.utils.is_repo_committer(repo)
            self.assertFalse(output)
github Pagure / pagure / tests / test_pagure_flask.py View on Github external
is_admin=True,
        )
        self.session.commit()
        self.assertEqual(msg, "User `foo` added to the group `packager`.")

        # Add group packager to project test
        project = pagure.lib.query._get_project(self.session, "test")
        msg = pagure.lib.query.add_group_to_project(
            self.session, project=project, new_group="packager", user="pingou"
        )
        self.session.commit()
        self.assertEqual(msg, "Group added")

        repo = pagure.lib.query._get_project(self.session, "test")

        g = munch.Munch()
        g.fas_user = tests.FakeUser(username="foo")
        g.authenticated = True
        g.session = self.session
        with mock.patch("flask.g", g):
            output = pagure.utils.is_repo_committer(repo)
            self.assertTrue(output)
github Pagure / pagure / tests / test_pagure_flask.py View on Github external
def test_is_repo_committer_external_committer_excluding_one(self):
        """ Test is_repo_committer in pagure with EXTERNAL_COMMITTER
        configured to give access to all the provenpackager but for this
        one repo
        """
        repo = pagure.lib.query._get_project(self.session, "test")

        g = munch.Munch()
        g.fas_user = tests.FakeUser()
        g.fas_user.groups.append("provenpackager")
        g.authenticated = True
        g.session = self.session
        with mock.patch("flask.g", g):
            output = pagure.utils.is_repo_committer(repo)
            self.assertFalse(output)
github aeternity / aepp-sdk-python / tests / test_transactions.py View on Github external
# meta properties
    meta_min_fee = 17740000000000


    api_spend_tx = {
        "amount":amount,
        "fee":fee,
        "nonce":nonce,
        "payload":payload,
        "recipient_id":recipient_id,
        "sender_id":sender_id,
        "type":_type,
        "version":version
    }

    api_signed_tx = Munch.fromDict({
        "block_height":181115,
        "block_hash":"mh_2essz8vfq4A8UZU98Jpm5VcB3Wt7p5CbQhzBgojjsM4AFq6z2s",
        "hash":tx_hash,
        "signatures":[
            signatures
        ],
        "tx": api_spend_tx
    })


    txbl = transactions.TxBuilder()
    txo_from_py = txbl.tx_spend(sender_id, recipient_id, amount, hashing.decode(payload), fee, ttl, nonce)
    txo_from_api = txbl.parse_node_reply(api_signed_tx).data.tx
    txo_from_str = txbl.parse_tx_string(txo_from_py.tx)

    assert txo_from_py.tx                  == txo_from_str.tx
github ceph / s3-tests / s3tests / common.py View on Github external
def read_config(fp):
    config = munch.Munch()
    g = yaml.safe_load_all(fp)
    for new in g:
        config.update(munch.Munchify(new))
    return config
github ceph / s3-tests / s3tests_boto3 / common.py View on Github external
def read_config(fp):
    config = munch.Munch()
    g = yaml.safe_load_all(fp)
    for new in g:
        config.update(munch.Munchify(new))
    return config
github retorquere / zotero-better-bibtex / setup / item.py View on Github external
from munch import Munch, DefaultMunch
import copy

root = os.path.join(os.path.dirname(__file__), '..')

def load(url):
  with urllib.request.urlopen(url) as f:
    return json.loads(f.read().decode())

data = DefaultMunch.fromDict({
  'zotero': load('https://api.zotero.org/schema'),
  'jurism': load('https://raw.githubusercontent.com/Juris-M/zotero-schema/master/schema-jurism.json')
}, None)

print('Generating item field metadata...')
ValidFields = DefaultMunch(None, {})
ValidTypes = {}
Alias = {}
Itemfields = set()
for client in data.keys():
  for spec in data[client].itemTypes:
    if spec.itemType in ValidTypes:
      ValidTypes[spec.itemType] = 'true'
    else:
      ValidTypes[spec.itemType] = client

    if not ValidFields[spec.itemType]:
      if spec.itemType == 'note':
        ValidFields[spec.itemType] = DefaultMunch(None, {field: 'true' for field in 'itemType tags note id itemID dateAdded dateModified'.split(' ')})
      elif spec.itemType == 'attachment':
        ValidFields[spec.itemType] = DefaultMunch(None, {field: 'true' for field in 'itemType tags id itemID dateAdded dateModified'.split(' ')})
      else:
github retorquere / zotero-better-bibtex / setup / item.py View on Github external
print('Generating item field metadata...')
ValidFields = DefaultMunch(None, {})
ValidTypes = {}
Alias = {}
Itemfields = set()
for client in data.keys():
  for spec in data[client].itemTypes:
    if spec.itemType in ValidTypes:
      ValidTypes[spec.itemType] = 'true'
    else:
      ValidTypes[spec.itemType] = client

    if not ValidFields[spec.itemType]:
      if spec.itemType == 'note':
        ValidFields[spec.itemType] = DefaultMunch(None, {field: 'true' for field in 'itemType tags note id itemID dateAdded dateModified'.split(' ')})
      elif spec.itemType == 'attachment':
        ValidFields[spec.itemType] = DefaultMunch(None, {field: 'true' for field in 'itemType tags id itemID dateAdded dateModified'.split(' ')})
      else:
        ValidFields[spec.itemType] = DefaultMunch(None, {field: 'true' for field in 'itemType creators tags attachments notes seeAlso id itemID dateAdded dateModified multi'.split(' ')})

    for field in spec.fields:
      if field.baseField:
        if not field.baseField in Alias: Alias[field.baseField] = Munch(zotero=set(), jurism=set())
        Alias[field.baseField][client].add(field.field)

        fieldName = field.baseField
      else:
        fieldName = field.field

      if spec.itemType not in ['note', 'attachment']: Itemfields.add(fieldName)
github retorquere / zotero-better-bibtex / setup / item.py View on Github external
Alias = {}
Itemfields = set()
for client in data.keys():
  for spec in data[client].itemTypes:
    if spec.itemType in ValidTypes:
      ValidTypes[spec.itemType] = 'true'
    else:
      ValidTypes[spec.itemType] = client

    if not ValidFields[spec.itemType]:
      if spec.itemType == 'note':
        ValidFields[spec.itemType] = DefaultMunch(None, {field: 'true' for field in 'itemType tags note id itemID dateAdded dateModified'.split(' ')})
      elif spec.itemType == 'attachment':
        ValidFields[spec.itemType] = DefaultMunch(None, {field: 'true' for field in 'itemType tags id itemID dateAdded dateModified'.split(' ')})
      else:
        ValidFields[spec.itemType] = DefaultMunch(None, {field: 'true' for field in 'itemType creators tags attachments notes seeAlso id itemID dateAdded dateModified multi'.split(' ')})

    for field in spec.fields:
      if field.baseField:
        if not field.baseField in Alias: Alias[field.baseField] = Munch(zotero=set(), jurism=set())
        Alias[field.baseField][client].add(field.field)

        fieldName = field.baseField
      else:
        fieldName = field.field

      if spec.itemType not in ['note', 'attachment']: Itemfields.add(fieldName)

      if ValidFields[spec.itemType][fieldName]:
        ValidFields[spec.itemType][fieldName] = 'true'
      else:
        ValidFields[spec.itemType][fieldName] = client