pythonlib 1.0.2 → 2.0.1

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.
Files changed (133) hide show
  1. package/README.md +123 -49
  2. package/dist/base64-C_am75Sv.d.ts +165 -0
  3. package/dist/base64.d.ts +1 -0
  4. package/dist/base64.js +37 -0
  5. package/dist/chunk-2QEMKE7U.js +252 -0
  6. package/dist/chunk-2YTO24B5.js +78 -0
  7. package/dist/chunk-3HQSBCEC.js +348 -0
  8. package/dist/{chunk-7BZB2TQF.js → chunk-3M3PB4RO.js} +4 -6
  9. package/dist/chunk-5OKGPZBQ.js +1106 -0
  10. package/dist/chunk-B5LQJODJ.js +37 -0
  11. package/dist/{chunk-CUP6EPDB.js → chunk-BCMGGBWG.js} +2 -5
  12. package/dist/chunk-BCVIH2BN.js +175 -0
  13. package/dist/chunk-CANUXHVB.js +349 -0
  14. package/dist/{chunk-QURVRHY2.js → chunk-D35YI363.js} +15 -12
  15. package/dist/{chunk-RSBRI27Z.js → chunk-ETBW6XNR.js} +3 -4
  16. package/dist/chunk-HSTC277I.js +255 -0
  17. package/dist/chunk-HTCQ4OO5.js +238 -0
  18. package/dist/chunk-IANXD4D4.js +250 -0
  19. package/dist/{chunk-G6PUQTVZ.js → chunk-JAUU3HMH.js} +1 -2
  20. package/dist/chunk-JVTQM7CI.js +195 -0
  21. package/dist/chunk-KKJHGY4C.js +551 -0
  22. package/dist/chunk-LHPQS75Z.js +192 -0
  23. package/dist/{chunk-OSX7QZAW.js → chunk-LK2L2TFG.js} +5 -6
  24. package/dist/{chunk-CEZSBJJV.js → chunk-LWYBTWBZ.js} +2 -3
  25. package/dist/chunk-MEEU4SH5.js +362 -0
  26. package/dist/{chunk-TAYRRHJ3.js → chunk-MFKIEN7N.js} +1 -2
  27. package/dist/{chunk-PZ5AY32C.js → chunk-MLKGABMK.js} +0 -1
  28. package/dist/chunk-OZRS5PC4.js +312 -0
  29. package/dist/chunk-PVK4F3ME.js +194 -0
  30. package/dist/{chunk-56DGFWIJ.js → chunk-QKJBQKPY.js} +1 -2
  31. package/dist/chunk-RB6BYCIQ.js +141 -0
  32. package/dist/chunk-RRSOZXZE.js +155 -0
  33. package/dist/chunk-THMJVAK6.js +282 -0
  34. package/dist/chunk-UGZ5OY5Z.js +165 -0
  35. package/dist/chunk-WTZSAITC.js +82 -0
  36. package/dist/chunk-YONWJHJU.js +265 -0
  37. package/dist/collections.js +2 -3
  38. package/dist/copy-6ZaZ__ge.d.ts +59 -0
  39. package/dist/copy.d.ts +1 -0
  40. package/dist/copy.js +9 -0
  41. package/dist/datetime.js +2 -3
  42. package/dist/functools.js +2 -3
  43. package/dist/glob.browser-B6d_YdV5.d.ts +50 -0
  44. package/dist/glob.browser.d.ts +1 -0
  45. package/dist/glob.browser.js +15 -0
  46. package/dist/glob.node-wn5ehtyM.d.ts +80 -0
  47. package/dist/glob.node.d.ts +1 -0
  48. package/dist/glob.node.js +15 -0
  49. package/dist/hashlib-vKP511NY.d.ts +205 -0
  50. package/dist/hashlib.d.ts +1 -0
  51. package/dist/hashlib.js +39 -0
  52. package/dist/index.browser.d.ts +172 -0
  53. package/dist/index.browser.js +305 -0
  54. package/dist/index.d.ts +36 -602
  55. package/dist/index.js +138 -1073
  56. package/dist/itertools.js +2 -3
  57. package/dist/json.js +2 -3
  58. package/dist/logging.browser-Dux4L5kz.d.ts +185 -0
  59. package/dist/logging.browser.d.ts +1 -0
  60. package/dist/logging.browser.js +63 -0
  61. package/dist/logging.node-CH75bVdE.d.ts +185 -0
  62. package/dist/logging.node.d.ts +1 -0
  63. package/dist/logging.node.js +61 -0
  64. package/dist/math.js +2 -3
  65. package/dist/{os-CqGKe872.d.ts → os.browser-krjSx5kF.d.ts} +32 -55
  66. package/dist/os.browser.d.ts +2 -0
  67. package/dist/{os.js → os.browser.js} +41 -16
  68. package/dist/os.node-CQjch8Ht.d.ts +124 -0
  69. package/dist/os.node.d.ts +2 -0
  70. package/dist/os.node.js +83 -0
  71. package/dist/os.shared-C3x70nhO.d.ts +59 -0
  72. package/dist/pathlib.browser-NC7kKQYe.d.ts +91 -0
  73. package/dist/pathlib.browser.d.ts +1 -0
  74. package/dist/pathlib.browser.js +17 -0
  75. package/dist/pathlib.node-CY3yUFdT.d.ts +331 -0
  76. package/dist/pathlib.node.d.ts +2 -0
  77. package/dist/pathlib.node.js +17 -0
  78. package/dist/random.js +2 -3
  79. package/dist/re.js +2 -3
  80. package/dist/set-JQbLAq8B.d.ts +592 -0
  81. package/dist/shutil.browser-Ck5oWhnP.d.ts +113 -0
  82. package/dist/shutil.browser.d.ts +1 -0
  83. package/dist/shutil.browser.js +33 -0
  84. package/dist/shutil.node-C9kwvhAf.d.ts +160 -0
  85. package/dist/shutil.node.d.ts +2 -0
  86. package/dist/shutil.node.js +33 -0
  87. package/dist/string.js +2 -3
  88. package/dist/subprocess-CZVYzQ3V.d.ts +214 -0
  89. package/dist/subprocess.d.ts +1 -0
  90. package/dist/subprocess.js +29 -0
  91. package/dist/sys-IL8LgI_W.d.ts +212 -0
  92. package/dist/sys.d.ts +1 -0
  93. package/dist/sys.js +51 -0
  94. package/dist/tempfile.browser-DciOKfNm.d.ts +78 -0
  95. package/dist/tempfile.browser.d.ts +1 -0
  96. package/dist/tempfile.browser.js +19 -0
  97. package/dist/tempfile.node-bVMY60Cu.d.ts +195 -0
  98. package/dist/tempfile.node.d.ts +2 -0
  99. package/dist/tempfile.node.js +23 -0
  100. package/dist/time-CcYhdiSu.d.ts +245 -0
  101. package/dist/time.d.ts +1 -0
  102. package/dist/time.js +49 -0
  103. package/dist/urllib-DJtkj-0f.d.ts +198 -0
  104. package/dist/urllib.d.ts +1 -0
  105. package/dist/urllib.js +37 -0
  106. package/dist/uuid-C0ypmn56.d.ts +160 -0
  107. package/dist/uuid.d.ts +1 -0
  108. package/dist/uuid.js +23 -0
  109. package/package.json +128 -5
  110. package/dist/chunk-56DGFWIJ.js.map +0 -1
  111. package/dist/chunk-5AOJFFYN.js +0 -313
  112. package/dist/chunk-5AOJFFYN.js.map +0 -1
  113. package/dist/chunk-7BZB2TQF.js.map +0 -1
  114. package/dist/chunk-CEZSBJJV.js.map +0 -1
  115. package/dist/chunk-CUP6EPDB.js.map +0 -1
  116. package/dist/chunk-G6PUQTVZ.js.map +0 -1
  117. package/dist/chunk-OSX7QZAW.js.map +0 -1
  118. package/dist/chunk-PZ5AY32C.js.map +0 -1
  119. package/dist/chunk-QURVRHY2.js.map +0 -1
  120. package/dist/chunk-RSBRI27Z.js.map +0 -1
  121. package/dist/chunk-TAYRRHJ3.js.map +0 -1
  122. package/dist/collections.js.map +0 -1
  123. package/dist/datetime.js.map +0 -1
  124. package/dist/functools.js.map +0 -1
  125. package/dist/index.js.map +0 -1
  126. package/dist/itertools.js.map +0 -1
  127. package/dist/json.js.map +0 -1
  128. package/dist/math.js.map +0 -1
  129. package/dist/os.d.ts +0 -1
  130. package/dist/os.js.map +0 -1
  131. package/dist/random.js.map +0 -1
  132. package/dist/re.js.map +0 -1
  133. package/dist/string.js.map +0 -1
@@ -0,0 +1,250 @@
1
+ import {
2
+ __export
3
+ } from "./chunk-MLKGABMK.js";
4
+
5
+ // src/urllib.ts
6
+ var urllib_exports = {};
7
+ __export(urllib_exports, {
8
+ parse: () => parse,
9
+ parseQs: () => parseQs,
10
+ parseQsl: () => parseQsl,
11
+ quote: () => quote,
12
+ quotePlus: () => quotePlus,
13
+ splithost: () => splithost,
14
+ splitpasswd: () => splitpasswd,
15
+ splitport: () => splitport,
16
+ splittype: () => splittype,
17
+ splituser: () => splituser,
18
+ unquote: () => unquote,
19
+ unquotePlus: () => unquotePlus,
20
+ urlencode: () => urlencode,
21
+ urljoin: () => urljoin,
22
+ urlparse: () => urlparse,
23
+ urlunparse: () => urlunparse
24
+ });
25
+ function urlparse(urlstring, scheme = "", allowFragments = true) {
26
+ try {
27
+ let url;
28
+ if (!urlstring.includes("://")) {
29
+ url = new URL((scheme || "http") + "://" + urlstring);
30
+ } else {
31
+ url = new URL(urlstring);
32
+ }
33
+ let fragment = "";
34
+ if (allowFragments && url.hash) {
35
+ fragment = url.hash.slice(1);
36
+ }
37
+ let netloc = url.host;
38
+ if (url.username) {
39
+ const userinfo = url.password ? `${url.username}:${url.password}` : url.username;
40
+ netloc = `${userinfo}@${url.host}`;
41
+ }
42
+ return {
43
+ scheme: url.protocol.slice(0, -1),
44
+ netloc,
45
+ path: url.pathname,
46
+ params: "",
47
+ query: url.search ? url.search.slice(1) : "",
48
+ fragment,
49
+ username: url.username || null,
50
+ password: url.password || null,
51
+ hostname: url.hostname || null,
52
+ port: url.port ? parseInt(url.port, 10) : null
53
+ };
54
+ } catch {
55
+ return {
56
+ scheme,
57
+ netloc: "",
58
+ path: urlstring,
59
+ params: "",
60
+ query: "",
61
+ fragment: "",
62
+ username: null,
63
+ password: null,
64
+ hostname: null,
65
+ port: null
66
+ };
67
+ }
68
+ }
69
+ function urlunparse(components) {
70
+ let scheme, netloc, path, params, query, fragment;
71
+ if (Array.isArray(components)) {
72
+ ;
73
+ [scheme, netloc, path, params, query, fragment] = components;
74
+ } else {
75
+ ;
76
+ ({ scheme, netloc, path, params, query, fragment } = components);
77
+ }
78
+ let url = "";
79
+ if (scheme) {
80
+ url += scheme + "://";
81
+ }
82
+ if (netloc) {
83
+ url += netloc;
84
+ }
85
+ url += path;
86
+ if (params) {
87
+ url += ";" + params;
88
+ }
89
+ if (query) {
90
+ url += "?" + query;
91
+ }
92
+ if (fragment) {
93
+ url += "#" + fragment;
94
+ }
95
+ return url;
96
+ }
97
+ function urljoin(base, url, allowFragments = true) {
98
+ if (!base) return url;
99
+ if (!url) return base;
100
+ try {
101
+ const result = new URL(url, base);
102
+ if (!allowFragments) {
103
+ result.hash = "";
104
+ }
105
+ return result.href;
106
+ } catch {
107
+ return url;
108
+ }
109
+ }
110
+ function urlencode(query, doseq = false) {
111
+ const params = new URLSearchParams();
112
+ if (Array.isArray(query)) {
113
+ for (const [key, value] of query) {
114
+ params.append(key, value);
115
+ }
116
+ } else {
117
+ for (const [key, value] of Object.entries(query)) {
118
+ if (Array.isArray(value) && doseq) {
119
+ for (const v of value) {
120
+ params.append(key, v);
121
+ }
122
+ } else if (Array.isArray(value)) {
123
+ params.append(key, value.join(","));
124
+ } else {
125
+ params.append(key, value);
126
+ }
127
+ }
128
+ }
129
+ return params.toString();
130
+ }
131
+ function parseQs(qs, keepBlankValues = false) {
132
+ const result = {};
133
+ const params = new URLSearchParams(qs);
134
+ for (const [key, value] of params) {
135
+ if (!keepBlankValues && value === "") {
136
+ continue;
137
+ }
138
+ if (!(key in result)) {
139
+ result[key] = [];
140
+ }
141
+ result[key]?.push(value);
142
+ }
143
+ return result;
144
+ }
145
+ function parseQsl(qs, keepBlankValues = false) {
146
+ const result = [];
147
+ const params = new URLSearchParams(qs);
148
+ for (const [key, value] of params) {
149
+ if (!keepBlankValues && value === "") {
150
+ continue;
151
+ }
152
+ result.push([key, value]);
153
+ }
154
+ return result;
155
+ }
156
+ function quote(s, safe = "") {
157
+ let result = encodeURIComponent(s);
158
+ for (const char of safe) {
159
+ result = result.replace(new RegExp(encodeURIComponent(char), "g"), char);
160
+ }
161
+ return result;
162
+ }
163
+ function quotePlus(s, safe = "") {
164
+ return quote(s, safe).replace(/%20/g, "+");
165
+ }
166
+ function unquote(s) {
167
+ return decodeURIComponent(s);
168
+ }
169
+ function unquotePlus(s) {
170
+ return decodeURIComponent(s.replace(/\+/g, " "));
171
+ }
172
+ function splittype(url) {
173
+ const match = /^([a-zA-Z][a-zA-Z0-9+.-]*):(.*)$/.exec(url);
174
+ if (match) {
175
+ return [match[1] ?? "", match[2] ?? ""];
176
+ }
177
+ return ["", url];
178
+ }
179
+ function splithost(url) {
180
+ const match = /^\/\/([^/?#]*)(.*)$/.exec(url);
181
+ if (match) {
182
+ return [match[1] ?? null, match[2] ?? ""];
183
+ }
184
+ return [null, url];
185
+ }
186
+ function splituser(host) {
187
+ const match = /^([^@]*)@(.*)$/.exec(host);
188
+ if (match) {
189
+ return [match[1] ?? null, match[2] ?? ""];
190
+ }
191
+ return [null, host];
192
+ }
193
+ function splitpasswd(user) {
194
+ const match = /^([^:]*):(.*)$/.exec(user);
195
+ if (match) {
196
+ return [match[1] ?? "", match[2] ?? null];
197
+ }
198
+ return [user, null];
199
+ }
200
+ function splitport(host) {
201
+ if (host.startsWith("[")) {
202
+ const match2 = /^\[([^\]]+)\]:?(\d*)$/.exec(host);
203
+ if (match2) {
204
+ return [match2[1] ?? "", match2[2] ?? null];
205
+ }
206
+ return [host, null];
207
+ }
208
+ const match = /^(.*):(\d+)$/.exec(host);
209
+ if (match) {
210
+ return [match[1] ?? "", match[2] ?? null];
211
+ }
212
+ return [host, null];
213
+ }
214
+ var parse = {
215
+ urlparse,
216
+ urlunparse,
217
+ urljoin,
218
+ urlencode,
219
+ parseQs,
220
+ parseQsl,
221
+ quote,
222
+ quotePlus,
223
+ unquote,
224
+ unquotePlus,
225
+ splittype,
226
+ splithost,
227
+ splituser,
228
+ splitpasswd,
229
+ splitport
230
+ };
231
+
232
+ export {
233
+ urlparse,
234
+ urlunparse,
235
+ urljoin,
236
+ urlencode,
237
+ parseQs,
238
+ parseQsl,
239
+ quote,
240
+ quotePlus,
241
+ unquote,
242
+ unquotePlus,
243
+ splittype,
244
+ splithost,
245
+ splituser,
246
+ splitpasswd,
247
+ splitport,
248
+ parse,
249
+ urllib_exports
250
+ };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __export
3
- } from "./chunk-PZ5AY32C.js";
3
+ } from "./chunk-MLKGABMK.js";
4
4
 
5
5
  // src/json.ts
6
6
  var json_exports = {};
@@ -106,4 +106,3 @@ export {
106
106
  };
107
107
  /* v8 ignore start -- error handling for invalid JSON @preserve */
108
108
  /* v8 ignore start -- advanced custom parser hooks @preserve */
109
- //# sourceMappingURL=chunk-G6PUQTVZ.js.map
@@ -0,0 +1,195 @@
1
+ import {
2
+ __export
3
+ } from "./chunk-MLKGABMK.js";
4
+
5
+ // src/shutil.node.ts
6
+ var shutil_node_exports = {};
7
+ __export(shutil_node_exports, {
8
+ copy: () => copy,
9
+ copy2: () => copy2,
10
+ copyfile: () => copyfile,
11
+ copyfileobj: () => copyfileobj,
12
+ copymode: () => copymode,
13
+ copystat: () => copystat,
14
+ copytree: () => copytree,
15
+ diskUsage: () => diskUsage,
16
+ getTerminalSize: () => getTerminalSize,
17
+ makeArchive: () => makeArchive,
18
+ move: () => move,
19
+ rmtree: () => rmtree,
20
+ unpackArchive: () => unpackArchive,
21
+ which: () => which
22
+ });
23
+ import { constants } from "fs";
24
+ import {
25
+ access,
26
+ chmod,
27
+ copyFile,
28
+ lstat,
29
+ mkdir,
30
+ readdir,
31
+ readlink,
32
+ rename as fsRename,
33
+ rm,
34
+ stat,
35
+ statfs,
36
+ symlink,
37
+ unlink,
38
+ utimes
39
+ } from "fs/promises";
40
+ import { basename, delimiter, join } from "path";
41
+ async function copy(src, dst) {
42
+ let finalDst = dst;
43
+ try {
44
+ if ((await stat(dst)).isDirectory()) {
45
+ finalDst = join(dst, basename(src));
46
+ }
47
+ } catch {
48
+ }
49
+ await copyFile(src, finalDst);
50
+ return finalDst;
51
+ }
52
+ async function copy2(src, dst) {
53
+ const finalDst = await copy(src, dst);
54
+ const srcStat = await stat(src);
55
+ await utimes(finalDst, srcStat.atime, srcStat.mtime);
56
+ return finalDst;
57
+ }
58
+ async function copytree(src, dst, options) {
59
+ const copyFunc = options?.copyFunction ?? (async (s, d) => {
60
+ await copy2(s, d);
61
+ });
62
+ const ignoreFunc = options?.ignore;
63
+ await mkdir(dst, { recursive: options?.dirsExistOk });
64
+ const entries = await readdir(src);
65
+ const ignoredNames = ignoreFunc ? ignoreFunc(src, entries) : [];
66
+ for (const entry of entries) {
67
+ if (ignoredNames.includes(entry)) {
68
+ continue;
69
+ }
70
+ const srcPath = join(src, entry);
71
+ const dstPath = join(dst, entry);
72
+ const entryStat = await lstat(srcPath);
73
+ if (entryStat.isDirectory()) {
74
+ await copytree(srcPath, dstPath, options);
75
+ } else if (entryStat.isSymbolicLink() && options?.symlinkss) {
76
+ const target = await readlink(srcPath);
77
+ await symlink(target, dstPath);
78
+ } else {
79
+ await copyFunc(srcPath, dstPath);
80
+ }
81
+ }
82
+ return dst;
83
+ }
84
+ async function move(src, dst) {
85
+ let finalDst = dst;
86
+ try {
87
+ if ((await stat(dst)).isDirectory()) {
88
+ finalDst = join(dst, basename(src));
89
+ }
90
+ } catch {
91
+ }
92
+ try {
93
+ await fsRename(src, finalDst);
94
+ } catch {
95
+ const srcStat = await stat(src);
96
+ if (srcStat.isDirectory()) {
97
+ await copytree(src, finalDst);
98
+ await rmtree(src);
99
+ } else {
100
+ await copy2(src, finalDst);
101
+ await unlink(src);
102
+ }
103
+ }
104
+ return finalDst;
105
+ }
106
+ async function rmtree(path, options) {
107
+ try {
108
+ await rm(path, { recursive: true, force: options?.ignoreErrors ?? false });
109
+ } catch (err) {
110
+ if (!options?.ignoreErrors) {
111
+ throw err;
112
+ }
113
+ }
114
+ }
115
+ async function which(cmd, path) {
116
+ const pathDirs = (path ?? process.env.PATH ?? "").split(delimiter);
117
+ const extensions = process.platform === "win32" ? [".exe", ".cmd", ".bat", ".com", ""] : [""];
118
+ for (const dir of pathDirs) {
119
+ for (const ext of extensions) {
120
+ const fullPath = join(dir, cmd + ext);
121
+ try {
122
+ await access(fullPath, constants.X_OK);
123
+ return fullPath;
124
+ } catch {
125
+ }
126
+ }
127
+ }
128
+ return null;
129
+ }
130
+ async function diskUsage(path) {
131
+ if (process.platform === "win32") {
132
+ throw new Error("diskUsage is not implemented on Windows");
133
+ }
134
+ const fsStat = await statfs(path);
135
+ const total = fsStat.blocks * fsStat.bsize;
136
+ const free = fsStat.bavail * fsStat.bsize;
137
+ return { total, used: total - free, free };
138
+ }
139
+ function getTerminalSize() {
140
+ const columns = process.stdout.columns ?? 80;
141
+ const lines = process.stdout.rows ?? 24;
142
+ return { columns, lines };
143
+ }
144
+ async function copymode(src, dst) {
145
+ const srcStat = await stat(src);
146
+ await chmod(dst, srcStat.mode);
147
+ }
148
+ async function copystat(src, dst) {
149
+ const srcStat = await stat(src);
150
+ await chmod(dst, srcStat.mode);
151
+ await utimes(dst, srcStat.atime, srcStat.mtime);
152
+ }
153
+ async function copyfile(src, dst) {
154
+ await copyFile(src, dst);
155
+ }
156
+ function copyfileobj(fsrc, fdst, length) {
157
+ if (length === void 0) {
158
+ ;
159
+ fsrc.pipe(fdst);
160
+ } else {
161
+ let remaining = length;
162
+ fsrc.on("data", (chunk) => {
163
+ if (remaining <= 0) return;
164
+ const toWrite = chunk.subarray(0, Math.min(chunk.length, remaining));
165
+ fdst.write(toWrite);
166
+ remaining -= toWrite.length;
167
+ });
168
+ }
169
+ }
170
+ function makeArchive(_baseName, _format, _rootDir) {
171
+ throw new Error("makeArchive is not implemented (requires external tools)");
172
+ }
173
+ function unpackArchive(_filename, _extractDir) {
174
+ throw new Error("unpackArchive is not implemented (requires external tools)");
175
+ }
176
+
177
+ export {
178
+ copy,
179
+ copy2,
180
+ copytree,
181
+ move,
182
+ rmtree,
183
+ which,
184
+ diskUsage,
185
+ getTerminalSize,
186
+ copymode,
187
+ copystat,
188
+ copyfile,
189
+ copyfileobj,
190
+ makeArchive,
191
+ unpackArchive,
192
+ shutil_node_exports
193
+ };
194
+ /* v8 ignore next 3 -- Windows-specific check @preserve */
195
+ /* v8 ignore start -- stream operations are tested via integration @preserve */