bugdantic 0.2.7__tar.gz → 0.2.8__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {bugdantic-0.2.7 → bugdantic-0.2.8}/PKG-INFO +1 -1
- {bugdantic-0.2.7 → bugdantic-0.2.8}/bugdantic/bugzilla.py +56 -12
- {bugdantic-0.2.7 → bugdantic-0.2.8}/bugdantic.egg-info/PKG-INFO +1 -1
- {bugdantic-0.2.7 → bugdantic-0.2.8}/pyproject.toml +1 -1
- {bugdantic-0.2.7 → bugdantic-0.2.8}/LICENSE +0 -0
- {bugdantic-0.2.7 → bugdantic-0.2.8}/README.md +0 -0
- {bugdantic-0.2.7 → bugdantic-0.2.8}/bugdantic/__init__.py +0 -0
- {bugdantic-0.2.7 → bugdantic-0.2.8}/bugdantic/py.typed +0 -0
- {bugdantic-0.2.7 → bugdantic-0.2.8}/bugdantic.egg-info/SOURCES.txt +0 -0
- {bugdantic-0.2.7 → bugdantic-0.2.8}/bugdantic.egg-info/dependency_links.txt +0 -0
- {bugdantic-0.2.7 → bugdantic-0.2.8}/bugdantic.egg-info/requires.txt +0 -0
- {bugdantic-0.2.7 → bugdantic-0.2.8}/bugdantic.egg-info/top_level.txt +0 -0
- {bugdantic-0.2.7 → bugdantic-0.2.8}/setup.cfg +0 -0
- {bugdantic-0.2.7 → bugdantic-0.2.8}/test/test_bugzilla.py +0 -0
|
@@ -4,11 +4,11 @@ import json
|
|
|
4
4
|
import logging
|
|
5
5
|
from dataclasses import dataclass
|
|
6
6
|
from datetime import datetime
|
|
7
|
-
from typing import Any, Mapping, MutableMapping, Optional, Sequence
|
|
7
|
+
from typing import Any, Mapping, MutableMapping, Optional, Sequence, Self
|
|
8
8
|
from urllib.parse import urljoin
|
|
9
9
|
|
|
10
10
|
import httpx
|
|
11
|
-
from pydantic import BaseModel, ConfigDict
|
|
11
|
+
from pydantic import BaseModel, ConfigDict
|
|
12
12
|
|
|
13
13
|
Json = dict[str, "Json"] | list["Json"] | str | int | float | bool | None
|
|
14
14
|
|
|
@@ -348,7 +348,7 @@ class AttachmentCreate(BaseModel):
|
|
|
348
348
|
data: str
|
|
349
349
|
file_name: str
|
|
350
350
|
summary: str
|
|
351
|
-
content_type:
|
|
351
|
+
content_type: str
|
|
352
352
|
comment: Optional[str] = None
|
|
353
353
|
is_markdown: Optional[bool] = None
|
|
354
354
|
is_patch: Optional[bool] = None
|
|
@@ -356,16 +356,60 @@ class AttachmentCreate(BaseModel):
|
|
|
356
356
|
flags: Optional[list[FlagChange]] = None
|
|
357
357
|
bug_flags: Optional[list[FlagChange]] = None
|
|
358
358
|
|
|
359
|
-
@field_validator("data", mode="before")
|
|
360
359
|
@classmethod
|
|
361
|
-
def
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
360
|
+
def from_raw_data(
|
|
361
|
+
cls,
|
|
362
|
+
data: str | bytes,
|
|
363
|
+
file_name: str,
|
|
364
|
+
summary: str,
|
|
365
|
+
content_type: str,
|
|
366
|
+
ids: Optional[list[int | str]] = None,
|
|
367
|
+
comment: Optional[str] = None,
|
|
368
|
+
is_markdown: Optional[bool] = None,
|
|
369
|
+
is_patch: Optional[bool] = None,
|
|
370
|
+
is_private: Optional[bool] = None,
|
|
371
|
+
flags: Optional[list[FlagChange]] = None,
|
|
372
|
+
bug_flags: Optional[list[FlagChange]] = None,
|
|
373
|
+
) -> Self:
|
|
374
|
+
if isinstance(data, str):
|
|
375
|
+
data = data.encode("utf8")
|
|
376
|
+
return cls(
|
|
377
|
+
ids=ids,
|
|
378
|
+
data=base64.b64encode(data).decode("ascii"),
|
|
379
|
+
file_name=file_name,
|
|
380
|
+
summary=summary,
|
|
381
|
+
content_type=content_type,
|
|
382
|
+
comment=comment,
|
|
383
|
+
is_markdown=is_markdown,
|
|
384
|
+
is_patch=is_patch,
|
|
385
|
+
is_private=is_private,
|
|
386
|
+
flags=flags,
|
|
387
|
+
bug_flags=bug_flags,
|
|
388
|
+
)
|
|
365
389
|
|
|
366
390
|
|
|
367
391
|
class AttachmentCreateResponse(BaseModel):
|
|
368
|
-
|
|
392
|
+
attacher: str
|
|
393
|
+
bug_id: int
|
|
394
|
+
content_type: str
|
|
395
|
+
creation_time: datetime
|
|
396
|
+
creator: str
|
|
397
|
+
creator_detail: User
|
|
398
|
+
data: str
|
|
399
|
+
description: str
|
|
400
|
+
file_name: str
|
|
401
|
+
flags: Optional[list[FlagChange]]
|
|
402
|
+
id: int
|
|
403
|
+
is_obsolete: bool
|
|
404
|
+
is_patch: bool
|
|
405
|
+
is_private: bool
|
|
406
|
+
last_change_time: datetime
|
|
407
|
+
size: int
|
|
408
|
+
summary: str
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
class AttachmentsCreateResponse(BaseModel):
|
|
412
|
+
attachments: Mapping[str, AttachmentCreateResponse]
|
|
369
413
|
|
|
370
414
|
|
|
371
415
|
@dataclass
|
|
@@ -573,7 +617,7 @@ class Bugzilla:
|
|
|
573
617
|
|
|
574
618
|
def create_attachment(
|
|
575
619
|
self, attachment: AttachmentCreate, bug_id: Optional[int] = None
|
|
576
|
-
) -> list[
|
|
620
|
+
) -> list[AttachmentCreateResponse]:
|
|
577
621
|
"""Add an attachment to one or more bugs"""
|
|
578
622
|
if bug_id is not None:
|
|
579
623
|
id_str = str(bug_id)
|
|
@@ -591,7 +635,7 @@ class Bugzilla:
|
|
|
591
635
|
response = self.request("POST", path, json_body=json_body)
|
|
592
636
|
|
|
593
637
|
if self.config.allow_writes:
|
|
594
|
-
create_result =
|
|
595
|
-
return create_result.
|
|
638
|
+
create_result = AttachmentsCreateResponse.model_validate(response)
|
|
639
|
+
return list(create_result.attachments.values())
|
|
596
640
|
|
|
597
641
|
return []
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|