Skip to content

Commit

Permalink
fix: reformat code with black
Browse files Browse the repository at this point in the history
Signed-off-by: tra371 <[email protected]>
  • Loading branch information
tra371 committed Feb 28, 2024
1 parent dcb3b0d commit 9a31bff
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 27 deletions.
12 changes: 9 additions & 3 deletions aries_cloudagent/anoncreds/issuer.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,9 @@ async def create_credential_offer(self, credential_definition_id: str) -> str:
CATEGORY_CRED_DEF_KEY_PROOF, credential_definition_id
)
except AskarError as err:
raise AnonCredsIssuerError("Error retrieving credential definition") from err
raise AnonCredsIssuerError(
"Error retrieving credential definition"
) from err
if not cred_def or not key_proof:
raise AnonCredsIssuerError(
"Credential definition not found for credential offer"
Expand Down Expand Up @@ -592,7 +594,9 @@ async def create_credential(
CATEGORY_CRED_DEF_PRIVATE, cred_def_id
)
except AskarError as err:
raise AnonCredsIssuerError("Error retrieving credential definition") from err
raise AnonCredsIssuerError(
"Error retrieving credential definition"
) from err

if not cred_def or not cred_def_private:
raise AnonCredsIssuerError(
Expand Down Expand Up @@ -649,7 +653,9 @@ async def create_credential_vc_di(
CATEGORY_CRED_DEF_PRIVATE, cred_def_id
)
except AskarError as err:
raise AnonCredsIssuerError("Error retrieving credential definition") from err
raise AnonCredsIssuerError(
"Error retrieving credential definition"
) from err

if not cred_def or not cred_def_private:
raise AnonCredsIssuerError(
Expand Down
4 changes: 3 additions & 1 deletion aries_cloudagent/indy/models/cred_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,9 @@ class Meta:
model_class = DidcommSignedAttachment
unknown = EXCLUDE

attachment_id = fields.Str(required=True, metadata={"description": "", "example": ""})
attachment_id = fields.Str(
required=True, metadata={"description": "", "example": ""}
)


class BindingProof(BaseModel):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,9 @@ async def create_request(
)

nonce = cred_offer["binding_method"]["anoncreds_link_secret"]["nonce"]
cred_def_id = cred_offer["binding_method"]["anoncreds_link_secret"]["cred_def_id"]
cred_def_id = cred_offer["binding_method"]["anoncreds_link_secret"][
"cred_def_id"
]

async def _create():
anoncreds_registry = self.profile.inject(AnonCredsRegistry)
Expand Down
34 changes: 26 additions & 8 deletions demo/runners/agent_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,9 @@ async def handle_issue_credential(self, message):
cred_attrs = self.cred_attrs[message["credential_definition_id"]]
cred_preview = {
"@type": CRED_PREVIEW_TYPE,
"attributes": [{"name": n, "value": v} for (n, v) in cred_attrs.items()],
"attributes": [
{"name": n, "value": v} for (n, v) in cred_attrs.items()
],
}
try:
cred_ex_rec = await self.admin_POST(
Expand Down Expand Up @@ -422,7 +424,9 @@ async def handle_present_proof_v2_0(self, message):
pres_request_indy = (
message["by_format"].get("pres_request", {}).get("indy")
)
pres_request_dif = message["by_format"].get("pres_request", {}).get("dif")
pres_request_dif = (
message["by_format"].get("pres_request", {}).get("dif")
)
request = {}

if not pres_request_dif and not pres_request_indy:
Expand Down Expand Up @@ -599,7 +603,9 @@ async def generate_invitation(
self._connection_ready = asyncio.Future()
with log_timer("Generate invitation duration:"):
# Generate an invitation
log_status("#7 Create a connection to alice and print out the invite details")
log_status(
"#7 Create a connection to alice and print out the invite details"
)
invi_rec = await self.get_invite(
use_did_exchange,
auto_accept=auto_accept,
Expand Down Expand Up @@ -811,7 +817,9 @@ async def initialize(
raise Exception("Endorser agent returns None :-(")

# set the endorser invite so the agent can auto-connect
self.agent.endorser_invite = self.endorser_agent.endorser_multi_invitation_url
self.agent.endorser_invite = (
self.endorser_agent.endorser_multi_invitation_url
)
self.agent.endorser_did = self.endorser_agent.endorser_public_did
else:
self.endorser_agent = None
Expand Down Expand Up @@ -847,17 +855,25 @@ async def initialize(
if self.mediation:
# we need to pre-connect the agent to its mediator
self.agent.log("Connect wallet to mediator ...")
if not await connect_wallet_to_mediator(self.agent, self.mediator_agent):
if not await connect_wallet_to_mediator(
self.agent, self.mediator_agent
):
raise Exception("Mediation setup FAILED :-(")
if self.endorser_agent:
self.agent.log("Connect wallet to endorser ...")
if not await connect_wallet_to_endorser(self.agent, self.endorser_agent):
if not await connect_wallet_to_endorser(
self.agent, self.endorser_agent
):
raise Exception("Endorser setup FAILED :-(")
if self.taa_accept:
await self.agent.taa_accept()

# if we are an author, create our public DID here ...
if self.endorser_role and self.endorser_role == "author" and self.endorser_agent:
if (
self.endorser_role
and self.endorser_role == "author"
and self.endorser_agent
):
if self.public_did and self.cred_type != CRED_FORMAT_JSON_LD:
new_did = await self.agent.admin_POST("/wallet/did/create")
self.agent.did = new_did["result"]["did"]
Expand Down Expand Up @@ -1302,7 +1318,9 @@ def arg_parser(ident: str = None, port: int = 8020):
metavar=("<api>"),
help="API level (10 or 20 (default))",
)
parser.add_argument("--timing", action="store_true", help="Enable timing information")
parser.add_argument(
"--timing", action="store_true", help="Enable timing information"
)
parser.add_argument(
"--multitenant", action="store_true", help="Enable multitenancy options"
)
Expand Down
56 changes: 42 additions & 14 deletions demo/runners/support/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,9 @@ async def register_schema_and_creddef_indy(
log_msg("Schema ID:", schema_id)

# Create a cred def for the schema
cred_def_tag = tag if tag else (self.ident + "." + schema_name).replace(" ", "_")
cred_def_tag = (
tag if tag else (self.ident + "." + schema_name).replace(" ", "_")
)
credential_definition_body = {
"schema_id": schema_id,
"support_revocation": support_revocation,
Expand Down Expand Up @@ -400,7 +402,9 @@ async def register_schema_and_creddef_indy(
credential_definition_response = await self.admin_GET(
"/credential-definitions/created"
)
if 0 == len(credential_definition_response["credential_definition_ids"]):
if 0 == len(
credential_definition_response["credential_definition_ids"]
):
await asyncio.sleep(1.0)
attempts = attempts - 1
credential_definition_id = credential_definition_response[
Expand Down Expand Up @@ -447,7 +451,9 @@ async def register_schema_and_creddef_anoncreds(
log_msg("Schema ID:", schema_id)

# Create a cred def for the schema
cred_def_tag = tag if tag else (self.ident + "." + schema_name).replace(" ", "_")
cred_def_tag = (
tag if tag else (self.ident + "." + schema_name).replace(" ", "_")
)
max_cred_num = revocation_registry_size if revocation_registry_size else 0
credential_definition_body = {
"credential_definition": {
Expand Down Expand Up @@ -483,7 +489,9 @@ async def register_schema_and_creddef_anoncreds(
credential_definition_response = await self.admin_GET(
"/anoncreds/credential-definitions"
)
if 0 == len(credential_definition_response["credential_definition_ids"]):
if 0 == len(
credential_definition_response["credential_definition_ids"]
):
await asyncio.sleep(1.0)
attempts = attempts - 1
credential_definition_id = credential_definition_response[
Expand Down Expand Up @@ -698,7 +706,9 @@ async def register_did(
nym_info = data
else:
log_msg("using ledger: " + ledger_url + "/register")
resp = await self.client_session.post(ledger_url + "/register", json=data)
resp = await self.client_session.post(
ledger_url + "/register", json=data
)
if resp.status != 200:
raise Exception(
f"Error registering DID {data}, response code {resp.status}"
Expand Down Expand Up @@ -895,7 +905,9 @@ def _process(self, args, env, loop):

def get_process_args(self):
return list(
flatten(([PYTHON, "-m", "aries_cloudagent", "start"], self.get_agent_args()))
flatten(
([PYTHON, "-m", "aries_cloudagent", "start"], self.get_agent_args())
)
)

async def start_process(self, python_path: str = None, wait: bool = True):
Expand Down Expand Up @@ -1111,7 +1123,9 @@ async def admin_GET(
if self.multitenant:
if not headers:
headers = {}
headers["Authorization"] = "Bearer " + self.managed_wallet_params["token"]
headers["Authorization"] = (
"Bearer " + self.managed_wallet_params["token"]
)
response = await self.admin_request(
"GET", path, None, text, params, headers=headers
)
Expand Down Expand Up @@ -1163,7 +1177,9 @@ async def admin_POST(
if self.multitenant:
if not headers:
headers = {}
headers["Authorization"] = "Bearer " + self.managed_wallet_params["token"]
headers["Authorization"] = (
"Bearer " + self.managed_wallet_params["token"]
)
response = await self.admin_request(
"POST", path, data, text, params, headers=headers
)
Expand All @@ -1184,7 +1200,9 @@ async def admin_PATCH(
if self.multitenant:
if not headers:
headers = {}
headers["Authorization"] = "Bearer " + self.managed_wallet_params["token"]
headers["Authorization"] = (
"Bearer " + self.managed_wallet_params["token"]
)
return await self.admin_request(
"PATCH", path, data, text, params, headers=headers
)
Expand All @@ -1199,7 +1217,9 @@ async def admin_PUT(
if self.multitenant:
if not headers:
headers = {}
headers["Authorization"] = "Bearer " + self.managed_wallet_params["token"]
headers["Authorization"] = (
"Bearer " + self.managed_wallet_params["token"]
)
return await self.admin_request(
"PUT", path, data, text, params, headers=headers
)
Expand All @@ -1219,7 +1239,9 @@ async def admin_DELETE(
if self.multitenant:
if not headers:
headers = {}
headers["Authorization"] = "Bearer " + self.managed_wallet_params["token"]
headers["Authorization"] = (
"Bearer " + self.managed_wallet_params["token"]
)
response = await self.admin_request(
"DELETE", path, data, text, params, headers=headers
)
Expand All @@ -1238,7 +1260,9 @@ async def admin_GET_FILE(self, path, params=None, headers=None) -> bytes:
if self.multitenant:
if not headers:
headers = {}
headers["Authorization"] = "Bearer " + self.managed_wallet_params["token"]
headers["Authorization"] = (
"Bearer " + self.managed_wallet_params["token"]
)
params = {k: v for (k, v) in (params or {}).items() if v is not None}
resp = await self.client_session.request(
"GET", self.admin_url + path, params=params, headers=headers
Expand All @@ -1254,7 +1278,9 @@ async def admin_PUT_FILE(self, files, url, params=None, headers=None) -> bytes:
if self.multitenant:
if not headers:
headers = {}
headers["Authorization"] = "Bearer " + self.managed_wallet_params["token"]
headers["Authorization"] = (
"Bearer " + self.managed_wallet_params["token"]
)
params = {k: v for (k, v) in (params or {}).items() if v is not None}
resp = await self.client_session.request(
"PUT", url, params=params, data=files, headers=headers
Expand Down Expand Up @@ -1626,7 +1652,9 @@ async def handle_connections(self, message):
# setup endorser meta-data on our connection
log_msg("Setup endorser agent meta-data ...")
await self.admin_POST(
"/transactions/" + self.endorser_connection_id + "/set-endorser-role",
"/transactions/"
+ self.endorser_connection_id
+ "/set-endorser-role",
params={"transaction_my_job": "TRANSACTION_ENDORSER"},
)

Expand Down

0 comments on commit 9a31bff

Please sign in to comment.