init
This commit is contained in:
commit
386a9066c0
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
bin
|
||||||
|
include
|
||||||
|
lib
|
||||||
|
share
|
||||||
|
pyvenv.cfg
|
||||||
|
lib64
|
4
README.md
Normal file
4
README.md
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
## 工作生活中脚本
|
||||||
|
|
||||||
|
1. 指定目录下生成excel `file.py`
|
||||||
|
2. 根据票号生成回复信息 `commit_message.py`
|
19
commit_message.py
Normal file
19
commit_message.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import sys,datetime
|
||||||
|
|
||||||
|
from rich.console import Console
|
||||||
|
|
||||||
|
console = Console()
|
||||||
|
|
||||||
|
today = datetime.date.today().strftime("%Y%m%d")
|
||||||
|
|
||||||
|
try:
|
||||||
|
args = sys.argv[1]
|
||||||
|
message = """
|
||||||
|
対応完了しました。
|
||||||
|
エビデンス⇒\[attachment:#{args}_確認エビデンス({date}).xlsx]
|
||||||
|
ご確認お願い致します。
|
||||||
|
""".format(args=args,date=today)
|
||||||
|
|
||||||
|
console.print(message)
|
||||||
|
except IndexError as err:
|
||||||
|
console.log("输入票号",log_locals=True, style="red")
|
38
file.py
Normal file
38
file.py
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
import datetime,xlwt,os
|
||||||
|
import logging
|
||||||
|
from rich.logging import RichHandler
|
||||||
|
|
||||||
|
FORMAT = "%(message)s"
|
||||||
|
logging.basicConfig(
|
||||||
|
level="NOTSET", format=FORMAT, datefmt="[%X]", handlers=[RichHandler()]
|
||||||
|
)
|
||||||
|
|
||||||
|
log = logging.getLogger("rich")
|
||||||
|
today = datetime.date.today()
|
||||||
|
format = today.strftime("%Y%m%d")
|
||||||
|
|
||||||
|
path = "/home/wjf/2023测试excel/"
|
||||||
|
|
||||||
|
full_path = path + format
|
||||||
|
|
||||||
|
try:
|
||||||
|
if not os.path.exists(full_path) :
|
||||||
|
os.makedirs(full_path)
|
||||||
|
logging.info("创建目录:" + full_path)
|
||||||
|
else:
|
||||||
|
logging.info("目录已存在:" + full_path)
|
||||||
|
|
||||||
|
for item in range(4):
|
||||||
|
workbook = xlwt.Workbook('utf-8')
|
||||||
|
worksheet = workbook.add_sheet("sheet %s" %item)
|
||||||
|
|
||||||
|
worksheet.write(0,0, '修正前')
|
||||||
|
worksheet.write(0,1,'修正後')
|
||||||
|
filename = "{item}_確認エビデンス({date}).xlsx".format(date=format, item=item)
|
||||||
|
if os.path.exists(full_path + "/" + filename):
|
||||||
|
logging.info("\[[red]跳过创建[/]] " +"文件已存在:" + filename, extra={"markup": True})
|
||||||
|
else:
|
||||||
|
workbook.save(full_path + "/" + filename)
|
||||||
|
logging.info("\[[green]创建成功[/]] " +"创建文件:" + filename, extra={"markup": True})
|
||||||
|
except Exception as e:
|
||||||
|
logging.exception(e)
|
Loading…
Reference in New Issue
Block a user