Skip to content

Commit af7d5b9

Browse files
committed
docs(pypi-package): add utils/retrying
1 parent 87fa493 commit af7d5b9

File tree

6 files changed

+583
-479
lines changed

6 files changed

+583
-479
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# jsonpath - 通过表达式解析 JSON
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# retrying - 重试任务
2+
3+
[[TOC]]
4+
5+
## 1. 项目简介
6+
7+
`retrying` 是一个 Python 重试任务的工具包。
8+
9+
```python
10+
import random
11+
from retrying import retry
12+
13+
@retry
14+
def do_something_unreliable():
15+
if random.randint(0, 10) > 1:
16+
raise IOError("Broken sauce, everything is hosed!!!111one")
17+
else:
18+
return "Awesome sauce!"
19+
20+
print(do_something_unreliable())
21+
```
22+
23+
还可以包含参数:
24+
25+
```python
26+
@retry(stop_max_attempt_number=7)
27+
def stop_after_7_attempts():
28+
print("Stopping after 7 attempts")
29+
```
30+
31+
可用参数:
32+
33+
- `stop_max_attempt_number`:最大重试次数
34+
- `stop_max_delay`:重试指定在指定时间内完成
35+
- `wait_fixed`:固定的重试等待时间
36+
- `wait_random_min`:最小随机等待时间(毫秒)
37+
- `wait_random_max`:最大随机等待时间(毫秒)
38+
- `wait_exponential_multiplier`:指数等待时间的基数(毫秒)
39+
- `wait_exponential_max`:指数等待时间的最大值(毫秒)
40+
- `retry_on_exception`:传入判断异常是否重试的函数
41+
- `wrap_exception`:抛出错误的异常类型
42+
- `retry_on_result`:在结果为指定条件时重试

docs/pypi-package/utils/six.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# six - 兼容 Python 2 和 Python 3 的工具包
2+
3+
[[TOC]]
4+
5+
## 1. 项目简介
6+
7+
`six` 是一个兼容 Python 2 和 Python 3 的工具包。
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Python 获取系统桌面
2+
3+
## 1. Windows 系统
4+
5+
通过注册表:
6+
7+
```python
8+
import winreg
9+
10+
def get_desktop_path() -> str:
11+
key = winreg.OpenKey(
12+
winreg.HKEY_CURRENT_USER,
13+
"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders",
14+
)
15+
path = winreg.QueryValueEx(key, "Desktop")[0]
16+
return path
17+
```
18+
19+
通过 Windows API `SHGetFolderPathW`
20+
21+
```python
22+
import ctypes
23+
24+
def get_desktop_path() -> str:
25+
CSIDL_DESKTOPDIRECTORY = 0x0010
26+
buf = ctypes.create_unicode_buffer(260)
27+
ctypes.windll.shell32.SHGetFolderPathW(
28+
None,
29+
CSIDL_DESKTOPDIRECTORY,
30+
None,
31+
0,
32+
buf,
33+
)
34+
desktop_path = buf.value
35+
return desktop_path
36+
```

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
"author": "Alex",
2121
"license": "ISC",
2222
"devDependencies": {
23-
"@vuepress/client": "2.0.0-beta.63",
24-
"@vuepress/plugin-shiki": "2.0.0-beta.63",
25-
"@vuepress/utils": "2.0.0-beta.63",
23+
"@vuepress/client": "2.0.0-beta.66",
24+
"@vuepress/plugin-shiki": "2.0.0-beta.66",
25+
"@vuepress/utils": "2.0.0-beta.66",
2626
"vue": "^3.3.4",
27-
"vuepress": "2.0.0-beta.63",
28-
"vuepress-plugin-auto-catalog": "2.0.0-beta.226",
29-
"vuepress-plugin-copy-code2": "2.0.0-beta.226",
30-
"vuepress-plugin-md-enhance": "2.0.0-beta.226",
31-
"vuepress-plugin-search-pro": "2.0.0-beta.226"
27+
"vuepress": "2.0.0-beta.66",
28+
"vuepress-plugin-auto-catalog": "2.0.0-beta.233",
29+
"vuepress-plugin-copy-code2": "2.0.0-beta.233",
30+
"vuepress-plugin-md-enhance": "2.0.0-beta.233",
31+
"vuepress-plugin-search-pro": "2.0.0-beta.233"
3232
}
3333
}

0 commit comments

Comments
 (0)