omdev 0.0.0.dev74__py3-none-any.whl → 0.0.0.dev76__py3-none-any.whl
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.
Potentially problematic release.
This version of omdev might be problematic. Click here for more details.
- omdev/.manifests.json +12 -0
- omdev/imgur.py +135 -0
- omdev/tools/dockertools.py +5 -5
- {omdev-0.0.0.dev74.dist-info → omdev-0.0.0.dev76.dist-info}/METADATA +2 -2
- {omdev-0.0.0.dev74.dist-info → omdev-0.0.0.dev76.dist-info}/RECORD +9 -8
- {omdev-0.0.0.dev74.dist-info → omdev-0.0.0.dev76.dist-info}/LICENSE +0 -0
- {omdev-0.0.0.dev74.dist-info → omdev-0.0.0.dev76.dist-info}/WHEEL +0 -0
- {omdev-0.0.0.dev74.dist-info → omdev-0.0.0.dev76.dist-info}/entry_points.txt +0 -0
- {omdev-0.0.0.dev74.dist-info → omdev-0.0.0.dev76.dist-info}/top_level.txt +0 -0
omdev/.manifests.json
CHANGED
|
@@ -47,6 +47,18 @@
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
},
|
|
50
|
+
{
|
|
51
|
+
"module": ".imgur",
|
|
52
|
+
"attr": "_FOO_CLI_MODULE",
|
|
53
|
+
"file": "omdev/imgur.py",
|
|
54
|
+
"line": 130,
|
|
55
|
+
"value": {
|
|
56
|
+
"$.cli.types.CliModule": {
|
|
57
|
+
"cmd_name": "imgur",
|
|
58
|
+
"mod_name": "omdev.imgur"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
},
|
|
50
62
|
{
|
|
51
63
|
"module": ".interp.__main__",
|
|
52
64
|
"attr": "_CLI_MODULE",
|
omdev/imgur.py
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"""
|
|
2
|
+
TODO:
|
|
3
|
+
- auth cmd
|
|
4
|
+
|
|
5
|
+
==
|
|
6
|
+
|
|
7
|
+
https://planspace.org/2013/01/13/upload-images-to-your-imgur-account/
|
|
8
|
+
|
|
9
|
+
https://api.imgur.com/oauth2/authorize?client_id=YOUR_CLIENT_ID&response_type=pin
|
|
10
|
+
|
|
11
|
+
curl \
|
|
12
|
+
-X POST \
|
|
13
|
+
-F "client_id=YOUR_CLIENT_ID" \
|
|
14
|
+
-F "client_secret=YOUR_CLIENT_SECRET" \
|
|
15
|
+
-F "grant_type=pin" \
|
|
16
|
+
-F "pin=YOUR_PIN" \
|
|
17
|
+
https://api.imgur.com/oauth2/token
|
|
18
|
+
|
|
19
|
+
curl \
|
|
20
|
+
-X POST \
|
|
21
|
+
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
|
|
22
|
+
-F "image=@PATH_TO_YOUR_IMAGE_FILE" \
|
|
23
|
+
https://api.imgur.com/3/upload
|
|
24
|
+
"""
|
|
25
|
+
import dataclasses as dc
|
|
26
|
+
import os.path
|
|
27
|
+
import typing as ta
|
|
28
|
+
|
|
29
|
+
from omlish import check
|
|
30
|
+
from omlish import http as hu
|
|
31
|
+
from omlish import marshal as msh
|
|
32
|
+
from omlish.formats import json
|
|
33
|
+
from omlish.secrets import Secret
|
|
34
|
+
|
|
35
|
+
from .cli import CliModule
|
|
36
|
+
from .secrets import load_secrets
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
@dc.dataclass(frozen=True)
|
|
40
|
+
@msh.update_object_metadata(unknown_field='x')
|
|
41
|
+
class ImageUploadData:
|
|
42
|
+
id: str
|
|
43
|
+
deletehash: str # noqa
|
|
44
|
+
account_id: int
|
|
45
|
+
account_url: str
|
|
46
|
+
title: str
|
|
47
|
+
description: str
|
|
48
|
+
name: str
|
|
49
|
+
type: str
|
|
50
|
+
width: int
|
|
51
|
+
height: int
|
|
52
|
+
size: int
|
|
53
|
+
views: int
|
|
54
|
+
animated: bool
|
|
55
|
+
has_sound: bool
|
|
56
|
+
link: str
|
|
57
|
+
tags: ta.Sequence[str]
|
|
58
|
+
datetime: int
|
|
59
|
+
mp4: str
|
|
60
|
+
hls: str
|
|
61
|
+
|
|
62
|
+
x: ta.Mapping[str, ta.Any] | None = None
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
@dc.dataclass(frozen=True)
|
|
66
|
+
class ImageUploadResponse:
|
|
67
|
+
status: int
|
|
68
|
+
success: bool
|
|
69
|
+
data: ImageUploadData
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
DEFAULT_UPLOAD_IMAGE_URL = 'https://api.imgur.com/3/upload'
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def upload_image(
|
|
76
|
+
file_name: str,
|
|
77
|
+
file_data: bytes,
|
|
78
|
+
auth_key: Secret | str,
|
|
79
|
+
*,
|
|
80
|
+
url: str = DEFAULT_UPLOAD_IMAGE_URL,
|
|
81
|
+
client: hu.HttpClient | None = None,
|
|
82
|
+
) -> ImageUploadResponse:
|
|
83
|
+
me = hu.MultipartEncoder([
|
|
84
|
+
hu.MultipartField(
|
|
85
|
+
file_data,
|
|
86
|
+
b'image',
|
|
87
|
+
file_name.encode(),
|
|
88
|
+
headers=[(hu.consts.HEADER_CONTENT_TYPE, hu.consts.CONTENT_TYPE_BYTES)],
|
|
89
|
+
),
|
|
90
|
+
])
|
|
91
|
+
|
|
92
|
+
resp = hu.request(
|
|
93
|
+
url,
|
|
94
|
+
headers={
|
|
95
|
+
hu.consts.HEADER_AUTH: hu.consts.format_bearer_auth_header(Secret.of(auth_key).reveal()),
|
|
96
|
+
hu.consts.HEADER_CONTENT_TYPE: me.content_type().decode(),
|
|
97
|
+
},
|
|
98
|
+
data=me.content(),
|
|
99
|
+
check=True,
|
|
100
|
+
client=client,
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
return msh.unmarshal(json.loads(check.not_none(resp.data).decode('utf-8')), ImageUploadResponse)
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def _main() -> None:
|
|
107
|
+
from omlish import argparse as ap
|
|
108
|
+
|
|
109
|
+
class Cli(ap.Cli):
|
|
110
|
+
@ap.command(
|
|
111
|
+
ap.arg('file'),
|
|
112
|
+
)
|
|
113
|
+
def upload(self) -> None:
|
|
114
|
+
file = self.args.file
|
|
115
|
+
file_name = os.path.basename(file)
|
|
116
|
+
with open(file, 'rb') as f:
|
|
117
|
+
file_data = f.read()
|
|
118
|
+
|
|
119
|
+
resp = upload_image(
|
|
120
|
+
file_name,
|
|
121
|
+
file_data,
|
|
122
|
+
load_secrets().get('imgur_client_access_token'),
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
print(resp.data.link)
|
|
126
|
+
|
|
127
|
+
Cli().call_and_exit()
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
# @omlish-manifest
|
|
131
|
+
_FOO_CLI_MODULE = CliModule('imgur', __name__)
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
if __name__ == '__main__':
|
|
135
|
+
_main()
|
omdev/tools/dockertools.py
CHANGED
|
@@ -123,17 +123,17 @@ class Cli(ap.Cli):
|
|
|
123
123
|
|
|
124
124
|
services = check.isinstance(
|
|
125
125
|
check.single(
|
|
126
|
-
v.value
|
|
126
|
+
v.value
|
|
127
127
|
for k, v in root.items()
|
|
128
|
-
if k.value == 'services'
|
|
128
|
+
if k.value == 'services'
|
|
129
129
|
),
|
|
130
130
|
ta.Mapping,
|
|
131
131
|
)
|
|
132
132
|
for name_w, cfg_w in services.items():
|
|
133
|
-
name = check.isinstance(name_w.value, str)
|
|
134
|
-
cfg = check.isinstance(cfg_w.value, ta.Mapping)
|
|
133
|
+
name = check.isinstance(name_w.value, str)
|
|
134
|
+
cfg = check.isinstance(cfg_w.value, ta.Mapping)
|
|
135
135
|
|
|
136
|
-
ports = check.opt_single(v.value for k, v in cfg.items() if k.value == 'ports')
|
|
136
|
+
ports = check.opt_single(v.value for k, v in cfg.items() if k.value == 'ports')
|
|
137
137
|
if not ports:
|
|
138
138
|
continue
|
|
139
139
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: omdev
|
|
3
|
-
Version: 0.0.0.
|
|
3
|
+
Version: 0.0.0.dev76
|
|
4
4
|
Summary: omdev
|
|
5
5
|
Author: wrmsr
|
|
6
6
|
License: BSD-3-Clause
|
|
@@ -12,7 +12,7 @@ Classifier: Operating System :: OS Independent
|
|
|
12
12
|
Classifier: Operating System :: POSIX
|
|
13
13
|
Requires-Python: ~=3.12
|
|
14
14
|
License-File: LICENSE
|
|
15
|
-
Requires-Dist: omlish ==0.0.0.
|
|
15
|
+
Requires-Dist: omlish ==0.0.0.dev76
|
|
16
16
|
Provides-Extra: all
|
|
17
17
|
Requires-Dist: black ~=24.10 ; extra == 'all'
|
|
18
18
|
Requires-Dist: pycparser ~=2.22 ; extra == 'all'
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
omdev/.manifests.json,sha256=
|
|
1
|
+
omdev/.manifests.json,sha256=qqGdjl5ipGAzn3N24XuhpvfczMlYD__3pV1gFHXw4AY,5228
|
|
2
2
|
omdev/__about__.py,sha256=bwCUKH9MgCgKZ4s7JedVN9_ESOv-1CziylwJJCgiaE4,1131
|
|
3
3
|
omdev/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
4
|
omdev/bracepy.py,sha256=HwBK5XmlOsF_juTel25fRLJK9vHSJCWXuCc-OZlevRQ,2619
|
|
@@ -7,6 +7,7 @@ omdev/cmake.py,sha256=Diy2ry65806dQP125DAstD3w46z_wszMH7PwC2-6iik,4578
|
|
|
7
7
|
omdev/findimports.py,sha256=P8v4I1tm6g-PEWJiNwAKxErvWwL-Nop83vAuwq1kR5A,2246
|
|
8
8
|
omdev/findmagic.py,sha256=DhBYHHP_dzwM5pIh21xnQPnkZ2YmAXCjithsr7X0ScU,2357
|
|
9
9
|
omdev/git.py,sha256=riM2KqSpQPC3N89uipd7Vm3kVgv4EYYDBU9tV1Z8juM,2208
|
|
10
|
+
omdev/imgur.py,sha256=il12R3t19tALolteYCZywvcdQUEOcgvPyUYgWtKiqt4,2993
|
|
10
11
|
omdev/revisions.py,sha256=U657hf4zeEN32y3g4CzqCAodx_HlfkHj2cIIKALNFDo,5009
|
|
11
12
|
omdev/secrets.py,sha256=MBCTWMxZbKS3FmvUYT9I3Yd_TfIBx5qXIJHprrNKKyo,437
|
|
12
13
|
omdev/tokens.py,sha256=GusxQ1Cd_eiScuR8XTTtc9QFhOgYviYGBZmFnn3Hj7s,756
|
|
@@ -111,7 +112,7 @@ omdev/toml/__init__.py,sha256=Y3l4WY4JRi2uLG6kgbGp93fuGfkxkKwZDvhsa0Rwgtk,15
|
|
|
111
112
|
omdev/toml/parser.py,sha256=84bn09uhYHwQGyfww6Rw6y1RxPAE_HDltODOSakcqDM,29186
|
|
112
113
|
omdev/toml/writer.py,sha256=lk3on3YXVbWuLJa-xsOzOhs1bBAT1vXqw4mBbluZl_w,3040
|
|
113
114
|
omdev/tools/__init__.py,sha256=iVJAOQ0viGTQOm0DLX4uZLro-9jOioYJGLg9s0kDx1A,78
|
|
114
|
-
omdev/tools/dockertools.py,sha256=
|
|
115
|
+
omdev/tools/dockertools.py,sha256=k2BrVvFYwyGov064CPHd_HWo9aqR1zHc2UeEsVwPth4,6827
|
|
115
116
|
omdev/tools/gittools.py,sha256=1Oa2AgdZIJZ2eusso9yFzkd9zLWH3d4lTiVFzwg0uDM,3808
|
|
116
117
|
omdev/tools/importscan.py,sha256=vxOMdAABShqt5-G3n6DGHopCZ5uGgciThY0MCa5W0mA,4066
|
|
117
118
|
omdev/tools/mkrelimp.py,sha256=fwt4GWzenuLNVtzdK2uaJJTSuJbUVJZquF5adwAwlPg,4051
|
|
@@ -120,9 +121,9 @@ omdev/tools/piptools.py,sha256=-jR5q3w4sHqntxCLExFCBNIARB788FUsAbJ62PK2sBU,2774
|
|
|
120
121
|
omdev/tools/proftools.py,sha256=8ZU9x_Dq8eT2ZFwU9sJpDIvxcIn9qBc8y2ELKPb5e5M,1382
|
|
121
122
|
omdev/tools/rsttool.py,sha256=suwsfseUf8GH8rYmYygTUdif-Jk_bX1g9fYRLXaKkmM,1340
|
|
122
123
|
omdev/tools/sqlrepl.py,sha256=tmFZh80-xsGM62dyQ7_UGLebChrj7IHbIPYBWDJMgVk,5741
|
|
123
|
-
omdev-0.0.0.
|
|
124
|
-
omdev-0.0.0.
|
|
125
|
-
omdev-0.0.0.
|
|
126
|
-
omdev-0.0.0.
|
|
127
|
-
omdev-0.0.0.
|
|
128
|
-
omdev-0.0.0.
|
|
124
|
+
omdev-0.0.0.dev76.dist-info/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
|
|
125
|
+
omdev-0.0.0.dev76.dist-info/METADATA,sha256=xXP15jgk8-HYT7LFgJmDrzHDcplqIzbMM2D8M7CBzss,1492
|
|
126
|
+
omdev-0.0.0.dev76.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
|
|
127
|
+
omdev-0.0.0.dev76.dist-info/entry_points.txt,sha256=dHLXFmq5D9B8qUyhRtFqTGWGxlbx3t5ejedjrnXNYLU,33
|
|
128
|
+
omdev-0.0.0.dev76.dist-info/top_level.txt,sha256=1nr7j30fEWgLYHW3lGR9pkdHkb7knv1U1ES1XRNVQ6k,6
|
|
129
|
+
omdev-0.0.0.dev76.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|