Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'munch' in functional components in Python. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.
"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")
# 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)
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)
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)
# 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
def read_config(fp):
config = munch.Munch()
g = yaml.safe_load_all(fp)
for new in g:
config.update(munch.Munchify(new))
return config
def read_config(fp):
config = munch.Munch()
g = yaml.safe_load_all(fp)
for new in g:
config.update(munch.Munchify(new))
return config
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:
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)
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