mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 11:30:18 +00:00
up
This commit is contained in:
parent
064356682f
commit
e737c33b85
@ -1,6 +1,7 @@
|
|||||||
## 0.5.1+1
|
## 0.5.1+2
|
||||||
|
|
||||||
+ Fix a bug of parsing large `list/dict/set`
|
+ Fix a bug of parsing large `list/dict/set`
|
||||||
|
+ Add `os.path.join`
|
||||||
|
|
||||||
## 0.5.0+7
|
## 0.5.0+7
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
name: pocketpy
|
name: pocketpy
|
||||||
description: A lightweight Python interpreter for game engines.
|
description: A lightweight Python interpreter for game engines.
|
||||||
version: 0.5.1+1
|
version: 0.5.1+2
|
||||||
homepage: https://pocketpy.dev
|
homepage: https://pocketpy.dev
|
||||||
repository: https://github.com/blueloveth/pocketpy
|
repository: https://github.com/blueloveth/pocketpy
|
||||||
|
|
||||||
|
@ -2664,17 +2664,17 @@ class FileIO:
|
|||||||
def __init__(self, path, mode):
|
def __init__(self, path, mode):
|
||||||
assert type(path) is str
|
assert type(path) is str
|
||||||
assert type(mode) is str
|
assert type(mode) is str
|
||||||
assert mode in ['r', 'w']
|
assert mode in ['r', 'w', 'rt', 'wt']
|
||||||
self.path = path
|
self.path = path
|
||||||
self.mode = mode
|
self.mode = mode
|
||||||
self.fp = jsonrpc('fopen', [path, mode])
|
self.fp = jsonrpc('fopen', [path, mode])
|
||||||
|
|
||||||
def read(self):
|
def read(self):
|
||||||
assert self.mode == 'r'
|
assert self.mode in ['r', 'rt']
|
||||||
return jsonrpc('fread', [self.fp])
|
return jsonrpc('fread', [self.fp])
|
||||||
|
|
||||||
def write(self, s):
|
def write(self, s):
|
||||||
assert self.mode == 'w'
|
assert self.mode in ['w', 'wt']
|
||||||
assert type(s) is str
|
assert type(s) is str
|
||||||
jsonrpc('fwrite', [self.fp, s])
|
jsonrpc('fwrite', [self.fp, s])
|
||||||
|
|
||||||
@ -2812,6 +2812,16 @@ def __path4exists(path):
|
|||||||
return jsonrpc("os.path.exists", [path])
|
return jsonrpc("os.path.exists", [path])
|
||||||
path.exists = __path4exists
|
path.exists = __path4exists
|
||||||
del __path4exists
|
del __path4exists
|
||||||
|
|
||||||
|
def __path4join(*paths):
|
||||||
|
s = '/'.join(paths)
|
||||||
|
s = s.replace('\\', '/')
|
||||||
|
s = s.replace('//', '/')
|
||||||
|
s = s.replace('//', '/')
|
||||||
|
return s
|
||||||
|
|
||||||
|
path.join = __path4join
|
||||||
|
del __path4join
|
||||||
)";
|
)";
|
||||||
|
|
||||||
const char* __RANDOM_CODE = R"(
|
const char* __RANDOM_CODE = R"(
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 8d72bddf3e80119e0f095aea14cf669024a8bee0
|
Subproject commit be3b15ee0aa6a3f56a83e130035c7eb82d753d42
|
@ -291,17 +291,17 @@ class FileIO:
|
|||||||
def __init__(self, path, mode):
|
def __init__(self, path, mode):
|
||||||
assert type(path) is str
|
assert type(path) is str
|
||||||
assert type(mode) is str
|
assert type(mode) is str
|
||||||
assert mode in ['r', 'w']
|
assert mode in ['r', 'w', 'rt', 'wt']
|
||||||
self.path = path
|
self.path = path
|
||||||
self.mode = mode
|
self.mode = mode
|
||||||
self.fp = jsonrpc('fopen', [path, mode])
|
self.fp = jsonrpc('fopen', [path, mode])
|
||||||
|
|
||||||
def read(self):
|
def read(self):
|
||||||
assert self.mode == 'r'
|
assert self.mode in ['r', 'rt']
|
||||||
return jsonrpc('fread', [self.fp])
|
return jsonrpc('fread', [self.fp])
|
||||||
|
|
||||||
def write(self, s):
|
def write(self, s):
|
||||||
assert self.mode == 'w'
|
assert self.mode in ['w', 'wt']
|
||||||
assert type(s) is str
|
assert type(s) is str
|
||||||
jsonrpc('fwrite', [self.fp, s])
|
jsonrpc('fwrite', [self.fp, s])
|
||||||
|
|
||||||
@ -439,6 +439,16 @@ def __path4exists(path):
|
|||||||
return jsonrpc("os.path.exists", [path])
|
return jsonrpc("os.path.exists", [path])
|
||||||
path.exists = __path4exists
|
path.exists = __path4exists
|
||||||
del __path4exists
|
del __path4exists
|
||||||
|
|
||||||
|
def __path4join(*paths):
|
||||||
|
s = '/'.join(paths)
|
||||||
|
s = s.replace('\\', '/')
|
||||||
|
s = s.replace('//', '/')
|
||||||
|
s = s.replace('//', '/')
|
||||||
|
return s
|
||||||
|
|
||||||
|
path.join = __path4join
|
||||||
|
del __path4join
|
||||||
)";
|
)";
|
||||||
|
|
||||||
const char* __RANDOM_CODE = R"(
|
const char* __RANDOM_CODE = R"(
|
||||||
|
12
tests/_os_path.py
Normal file
12
tests/_os_path.py
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
# test os.path.join
|
||||||
|
|
||||||
|
f = os.path.join
|
||||||
|
|
||||||
|
assert f('/', 'a') == '/a'
|
||||||
|
assert f('/', 'a/', 'b/') == '/a/b/'
|
||||||
|
assert f('c', 'd') == 'c/d'
|
||||||
|
assert f('C:\\', 'a') == 'C:/a'
|
||||||
|
assert f('C:\\', 'a\\', 'b\\') == 'C:/a/b/'
|
||||||
|
assert f('c\\', 'd/') == 'c/d/'
|
Loading…
x
Reference in New Issue
Block a user