add_func: support yaml

This commit is contained in:
fengbohan 2023-08-17 09:53:08 +08:00
parent ab7c038d79
commit c9436a4a1d
2 changed files with 9 additions and 2 deletions

1
config.yaml Normal file
View File

@ -0,0 +1 @@
user_name: 冯博涵

View File

@ -8,20 +8,26 @@ import win32com
from win32com.client import Dispatch, constants
import os
import sys
import ruamel.yaml as yaml
class WEEK_REPORT:
file_name = ""
pre_file_name = ""
pre_str = ""
str = ""
user_name = ""
__word = ""
__doc = ""
def __init__(self):
with open("config.yaml", "r", encoding="UTF-8") as f1:
data = yaml.safe_load(f1)
print("config.yaml: {}".format(data))
self.user_name = data["user_name"]
self.get_name()
def get_name(self):
self.file_name = "{}WW{}周工作报告_冯博涵.doc".format(time.strftime('%Y'), time.strftime('%W'))
self.pre_file_name = "{}WW{}周工作报告_冯博涵.doc".format(time.strftime('%Y'), str(int(time.strftime('%W'))-1))
self.file_name = "{}WW{}周工作报告_{}.doc".format(time.strftime('%Y'), time.strftime('%W'), self.user_name)
self.pre_file_name = "{}WW{}周工作报告_{}.doc".format(time.strftime('%Y'), str(int(time.strftime('%W'))-1), self.user_name)
print("pre file name: {}; \nnew file name: {};".format(self.pre_file_name, self.file_name))
if(os.path.isfile(self.file_name)==True):
print("{} is already exist.".format(self.file_name))