Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

添加IO流函数 #80

Merged
merged 3 commits into from
Apr 6, 2023
Merged

添加IO流函数 #80

merged 3 commits into from
Apr 6, 2023

Conversation

Amber-Keter
Copy link
Contributor

具体内容见开头注释

更新IO流函数
更新IO流函数配置文件
os.mkdir("plugin/tmp/Input/input_data")
if not os.path.exists(data_path):
init_data = {}
with open(data_path,"w",encoding="utf-8") as file:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

应该将文件打开模式由"w"改成"wb",否则在读取的时候会报TypeError的错误提示

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

麻了草,我忘了改读取模式了

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

改,反正离合并还远,我正在做另一个开发

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#思考
没怎么用过pr,原项目修改后怎么更新到这个pr里

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

通常来说,只要你的pr开放,被合入的分支中任何提交都会被补充进来

with open(cache_path, "w", encoding='utf8') as f:
pickle.dump(cache_data, f, indent=4, ensure_ascii=False)
return
#新序列不合法,结束输入流,删除缓存数据
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if dealt_time > max_time: os.rename(cache_path, \
    "plugin/tmp/Input/input_data/{}_expired.pickle".format(cache_file_name))

group = str(self.data.group_id)
data_path = 'plugin/tmp/Input/{}_input_log.pickle'.format(plugin_name)
if not os.path.exists("plugin/tmp/Input"): #检验数据文件与目录是否存在
os.mkdir("plugin/tmp/Input")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

快考虑使用os.makedirs()函数,这样可以级联创建需要的目录,更加方便!!!!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

本来是有考虑的()
但是因为是在原先的代码上改,就没想改x
所以暂且就这样了

import pickle
import time
import uuid
from .. import API
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

baka!

@lunzhiPenxil lunzhiPenxil merged commit 8fc232a into OlivOS-Team:main Apr 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants