Huan 5 年 前
コミット
8a43f3914e

BIN
CGB/__pycache__/__init__.cpython-37.pyc


BIN
DSGC/__pycache__/__init__.cpython-37.pyc


BIN
Data_Science/__pycache__/Learn.cpython-37.pyc


BIN
Data_Science/__pycache__/__init__.cpython-37.pyc


+ 224 - 0
GIT.py

@@ -0,0 +1,224 @@
+import tkinter
+import tkinter.messagebox
+from tkinter.filedialog import askopenfilename, asksaveasfilename,askdirectory,askopenfilenames
+import os
+import Git_Ctrl
+from tkinter.scrolledtext import ScrolledText
+
+Git = Git_Ctrl.git_Ctrol()#需要去掉
+
+def Main():
+    global top,Git,PATH,bg,bbg,fg,Git_List,Last_Name
+    PATH = os.getcwd()
+    Git = Git_Ctrl.git_Ctrol()
+    Git_List = []
+    top = tkinter.Tk()
+    Last_Name = None
+    bg = '#FFFAFA'  # 主颜色
+    bbg = '#FFFAFA'  # 按钮颜色
+    fg = '#000000'  # 文字颜色
+    top["bg"] = bg
+    FONT = ('黑体', 11)  # 设置字体
+    top.title('CoTan仓库管理器')
+    top.resizable(width=False, height=False)
+    top.geometry('+10+10')  # 设置所在位置
+
+    width_B = 13  # 标准宽度
+    height_B = 2
+    a_y = 0
+    a_x = 0
+
+    global clone_url
+    a_y += 1
+    tkinter.Label(top, text='克隆URL:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,row=a_y)
+    Dic_Var = tkinter.StringVar()#当前的Dic
+    clone_url = tkinter.Entry(top, width=width_B * 2, textvariable=Dic_Var)
+    clone_url.grid(column=a_x+1, row=a_y, columnspan=2, sticky=tkinter.E + tkinter.W)
+
+    a_y += 1
+    tkinter.Button(top, bg=bbg, fg=fg, text='克隆仓库', command=clone_git, font=FONT, width=width_B,
+                   height=height_B).grid(column=a_x, row=a_y, sticky=tkinter.E + tkinter.W)
+    tkinter.Button(top, bg=bbg, fg=fg, text='打开仓库', command=init_git, font=FONT, width=width_B,
+                   height=height_B).grid(column=a_x+1, row=a_y, sticky=tkinter.E + tkinter.W)
+    tkinter.Button(top, bg=bbg, fg=fg, text='查看文件', command=get_Git_Dir, font=FONT, width=width_B,
+                   height=height_B).grid(column=a_x+2, row=a_y, sticky=tkinter.E + tkinter.W)
+
+    global Git_Box,Git_Dir
+    a_y += 1
+    Git_Box = tkinter.Listbox(top, width=width_B * 3, height=height_B * 5)
+    Git_Box.grid(column=a_x, row=a_y, columnspan=3, rowspan=5, sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N)
+
+    a_y += 5
+    tkinter.Label(top, text='【仓库文件列表】', bg=bg, fg=fg, font=FONT, width=width_B * 3, height=height_B).grid(
+        column=a_x,columnspan=3,row=a_y,sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)  # 设置说明
+
+    a_y += 1
+    Git_Dir = tkinter.Listbox(top, width=width_B * 3, height=height_B * 5)
+    Git_Dir.grid(column=a_x, row=a_y, columnspan=3, rowspan=5, sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N)
+
+    a_y += 5
+    tkinter.Button(top, bg=bbg, fg=fg, text='添加暂存区文件', command=Add_File, font=FONT, width=width_B,
+                   height=height_B).grid(column=a_x, row=a_y, sticky=tkinter.E + tkinter.W)
+    tkinter.Button(top, bg=bbg, fg=fg, text='移除暂存区文件', command=init_git, font=FONT, width=width_B,
+                   height=height_B).grid(column=a_x+1, row=a_y, sticky=tkinter.E + tkinter.W)
+    tkinter.Button(top, bg=bbg, fg=fg, text='提交到git', command=Commit_File, font=FONT, width=width_B,
+                   height=height_B).grid(column=a_x+2, row=a_y, sticky=tkinter.E + tkinter.W)
+
+    global commit_m,head,master
+    a_y += 1
+    tkinter.Label(top, text='提交描述:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,row=a_y)
+    commit_m = tkinter.Entry(top, width=width_B * 2)
+    commit_m.grid(column=a_x + 1, row=a_y, columnspan=2, sticky=tkinter.E + tkinter.W)
+
+    a_y += 1
+    tkinter.Button(top, bg=bbg, fg=fg, text='查看执行日志', command=lambda :not_Args(Git.reflog), font=FONT, width=width_B,
+                   height=height_B).grid(column=a_x, row=a_y, sticky=tkinter.E + tkinter.W)
+    tkinter.Button(top, bg=bbg, fg=fg, text='查看文件日志', command=lambda :not_Args(Git.log), font=FONT, width=width_B,
+                   height=height_B).grid(column=a_x+1, row=a_y, sticky=tkinter.E + tkinter.W)
+    tkinter.Button(top, bg=bbg, fg=fg, text='查看状态', command=lambda :not_Args(Git.status), font=FONT, width=width_B,
+                   height=height_B).grid(column=a_x+2, row=a_y, sticky=tkinter.E + tkinter.W)
+
+    a_y += 1
+    tkinter.Button(top, bg=bbg, fg=fg, text='版本回退', command=Back_version, font=FONT, width=width_B,
+                   height=height_B).grid(column=a_x, row=a_y, sticky=tkinter.E + tkinter.W)
+    tkinter.Button(top, bg=bbg, fg=fg, text='文件回退', command=Back_File, font=FONT, width=width_B,
+                   height=height_B).grid(column=a_x+1, row=a_y, sticky=tkinter.E + tkinter.W)
+    tkinter.Button(top, bg=bbg, fg=fg, text='删除文件', command=rm_file, font=FONT, width=width_B,
+                   height=height_B).grid(column=a_x+2, row=a_y, sticky=tkinter.E + tkinter.W)
+
+    a_y += 1
+    tkinter.Label(top, text='diff分支:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,row=a_y)
+    master = tkinter.Entry(top, width=width_B * 2)
+    master.grid(column=a_x + 1, row=a_y, columnspan=2, sticky=tkinter.E + tkinter.W)
+
+    a_y += 1
+    tkinter.Label(top, text='回退版本号:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,row=a_y)
+    head = tkinter.Entry(top, width=width_B * 2)
+    head.grid(column=a_x + 1, row=a_y, columnspan=2, sticky=tkinter.E + tkinter.W)
+
+    top.mainloop()
+
+def rm_file():
+    global Git,head
+    dic = askopenfilenames(title=f'选择要删除的文件(取消为全选)')
+    if dic == '': return False
+    do_Sys(Git.rm,(get_Name(),dic))
+    update_Git_Dir()
+
+def Back_File():
+    global Git,head
+    dic = askopenfilenames(title=f'选择要add的文件(取消为全选)')
+    if dic == '': return False
+    do_Sys(Git.checkout_version,(get_Name(),dic))
+    update_Git_Dir()
+
+def Back_version():
+    global Git,head
+    HEAD = head.get()
+    if HEAD == '': HEAD = 'HEAD~1'
+    do_Sys(Git.back_version,(get_Name(),HEAD))
+    update_Git_Dir()
+
+def do_Sys(func,args,name='CoTan Git'):
+    p = func(*args)
+    p.wait()
+    if p.returncode != 0: print(p.returncode)
+    else:
+        print('success')
+    data = ''
+    while True:
+        i = p.stdout.readline().decode('utf-8')
+        if i == '': break
+        data += i
+    if data.replace('\n','').replace(' ','') != '':show(data,name)
+
+
+def not_Args(func):
+    global Git
+    name = get_Name()
+    do_Sys(func,(name,))
+    update_Git_Dir()
+
+def Commit_File():
+    global Git,commit_m
+    m = commit_m.get()
+    if m.replace(' ','') == '':
+        tkinter.messagebox.showinfo('警告!', '非常遗憾,我不同意你commit而不添加任何描述!\n描述是很重要的!')
+        return False
+    name = get_Name()
+    do_Sys(Git.commit_File,(name,m))
+    update_Git_Dir()
+
+def Diff_File():
+    global Git,master
+    MASTER = master.get()
+    if MASTER == '':MASTER = 'HEAD'
+    do_Sys(Git.diff_File,(get_Name(),MASTER))
+    update_Git_Dir()
+
+def Add_File():
+    global Git,Last_Name
+    dic = askopenfilenames(title=f'选择要add的文件(取消为全选)')
+    if dic == '':dic = '*'
+    do_Sys(Git.add_File,(get_Name(),dic))
+    update_Git_Dir()
+
+def update_Git_Dir():
+    global Last_Name
+    if Last_Name == None:return False
+    Git_dir(Last_Name)
+
+def get_Git_Dir():
+    name = get_Name()
+    Git_dir(name)
+
+def Git_dir(name):
+    global Git, Git_Dir,Last_Name
+    dir_list = Git.get_Dir(name)
+    Git_Dir.delete(0,tkinter.END)
+    Git_Dir.insert(tkinter.END,*dir_list)
+    Last_Name = name
+
+def clone_git():#克隆仓库
+    global clone_url
+    new_Dic = askdirectory(title = '选择仓库地址')
+    if new_Dic == '':return False
+    Git.Clone_init(new_Dic, clone_url.get())
+    Updata_GitBox()
+
+def init_git():#创建仓库
+    global Git
+    new_Dic = askdirectory(title = '选择仓库地址')
+    if new_Dic == '':return False
+    Git.Add_init(new_Dic,)
+    Updata_GitBox()
+
+def get_Name():  # 获得名字统一接口
+    global Git,Git_List,Git_Box
+    try:
+        return Git_List[Git_Box.curselection()[0]]
+    except:
+        try:
+            return Git_List[0]
+        except:
+            return None
+
+def Updata_GitBox():
+    global Git,Git_List,Git_Box
+    Git_List = list(Git.get_git_Dic().keys())
+    Git_Box.delete(0,tkinter.END)
+    Git_Box.insert(tkinter.END,*Git_List)
+
+def show(data,name):
+    global bg, ft1
+    new_top = tkinter.Toplevel(bg=bg)
+    new_top.title(name)
+    new_top.geometry('+10+10')  # 设置所在位置
+    text = ScrolledText(new_top, font=('黑体', 11), height=50)
+    text.pack(fill=tkinter.BOTH)
+    text.insert('0.0', data)
+    text.config(state=tkinter.DISABLED)
+    new_top.resizable(width=False, height=False)
+
+if __name__ == '__main__':
+    Main()

+ 133 - 0
Git_Ctrl.py

@@ -0,0 +1,133 @@
+# -*- coding: <encoding name> -*-
+from git import Repo
+from os.path import split,exists
+import os
+import subprocess
+
+sys_seeting = dict(shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
+git_path = 'git'
+
+class git_Repo:#git的基类
+    def __init__(self,Dic,name,*args,**kwargs):
+        self.Repo_Dic = Dic  # 仓库地址
+        self.url = None
+        if not exists(Dic + r'/.git'):  # 是否为git 仓库
+            subprocess.Popen(f'{git_path} init',cwd=self.Repo_Dic,**sys_seeting).wait()
+        self.repo = Repo(Dic)
+        self.name = name
+
+    def Flie_List(self,file_list,is_file=True,pat=' '):
+        if file_list == '*':
+            file = '*'
+        else:
+            file_ = []
+            for i in file_list:
+                if i[:len(self.Repo_Dic)] == self.Repo_Dic:
+                    file_.append(i[len(self.Repo_Dic) + 1:])  # +1是为了去除/
+            if not is_file:return file_
+            file = pat.join(file_)
+        return file
+
+    def dir_list(self,all=True):
+        listfile = []
+        if all:
+            listfile += [f'[当前分支] {self.repo.active_branch} 工作区{"不" if self.repo.is_dirty() else ""}干净 -> {self.name}']
+        listfile += [f'{"[配置文件]" if i == ".git" else "[未跟踪]"if i in self.repo.untracked_files else "[已跟踪]"} {i}'
+                     for i in os.listdir(self.Repo_Dic)]
+        return listfile
+
+    def Add_File(self,file_list):
+        file = self.Flie_List(file_list)
+        return subprocess.Popen(f'{git_path} add {file}',cwd=self.Repo_Dic,**sys_seeting)
+
+    def Commit_File(self,m):
+        return subprocess.Popen(f'{git_path} commit -m "{m}"',cwd=self.Repo_Dic,**sys_seeting)
+
+    def Status(self):#执行status
+        return subprocess.Popen(f'{git_path} status',cwd=self.Repo_Dic,**sys_seeting)
+
+    def Log(self):#执行log
+        return subprocess.Popen(f'{git_path} log',cwd=self.Repo_Dic,**sys_seeting)
+
+    def refLog(self):#执行reflog
+        return subprocess.Popen(f'{git_path} reflog',cwd=self.Repo_Dic,**sys_seeting)
+
+    def Diff_File(self,MASTER='HEAD'):#执行diff
+        return subprocess.Popen(f'{git_path} diff {MASTER}',cwd=self.Repo_Dic,**sys_seeting)
+
+    def reset(self,HEAD='HEAD~1'):
+        return subprocess.Popen(f'{git_path} reset --hard {HEAD}',cwd=self.Repo_Dic,**sys_seeting)
+
+    def checkout(self,file_list):
+        if len(file_list) >= 1:#多于一个文件,不用--,空格
+            file = self.Flie_List(file_list,pat=' ')
+            return subprocess.Popen(f'{git_path} checkout {file}',cwd=self.Repo_Dic,**sys_seeting)
+        elif len(file_list) == 1:
+            return subprocess.Popen(f'{git_path} checkout -- {file_list[0]}', cwd=self.Repo_Dic, **sys_seeting)
+        else:
+            return subprocess.Popen(f'{git_path} checkout *', cwd=self.Repo_Dic, **sys_seeting)
+
+    def rm(self,file_list):#删除版本库中的文件
+        file = self.Flie_List(file_list)
+        return subprocess.Popen(f'{git_path} rm {file}', cwd=self.Repo_Dic,**sys_seeting)
+
+class Clone_git(git_Repo):#Clone一个git
+    def __init__(self,Dic,url,name,*args,**kwargs):
+        super(Clone_git, self).__init__(Dic,name, *args, **kwargs)
+        self.url = url
+        Repo.clone_from(url=url,to_path=Dic)
+        self.git = self.repo.git
+        self.index = self.repo.index
+
+class git_Ctrol:
+    def __init__(self):
+        self.git_Dic = {}#名字-文件位置
+        self.gitType_Dic = {}#名字-类型
+
+    def Add_init(self,Dic,**kwargs):
+        name = split(Dic)[-1]
+        git = git_Repo(Dic,name)
+        self.git_Dic[name] = git
+        self.gitType_Dic[name] = 'init'
+
+    def Clone_init(self,Dic,url,**kwargs):
+        name = split(Dic)[-1]
+        git = Clone_git(Dic,url,name)
+        self.git_Dic[name] = git
+        self.gitType_Dic[name] = 'clone'
+
+    def get_git(self,name):
+        return self.git_Dic[name]
+
+    def get_git_Dic(self):
+        return self.git_Dic.copy()
+
+    def get_Dir(self,name):
+        return self.get_git(name).dir_list()
+
+    def add_File(self,name,dic_list):
+        return self.get_git(name).Add_File(dic_list)
+
+    def commit_File(self,name,m):
+        return self.get_git(name).Commit_File(m)
+
+    def log(self,name):
+        return self.get_git(name).Log()
+
+    def reflog(self,name):
+        return self.get_git(name).refLog()
+
+    def status(self,name):
+        return self.get_git(name).Status()
+
+    def diff_File(self,name,MASTER):
+        return self.get_git(name).Diff_File(MASTER)
+
+    def back_version(self,name,HEAD):
+        return self.get_git(name).reset(HEAD)
+
+    def checkout_version(self,name,file):
+        return self.get_git(name).checkout(file)
+
+    def rm(self,name,file):
+        return self.get_git(name).rm(file)

BIN
HSCH/__pycache__/__init__.cpython-37.pyc


BIN
Machine_learning_analysis/__pycache__/Learn_Numpy.cpython-37.pyc


BIN
Machine_learning_analysis/__pycache__/Machine_learning.cpython-37.pyc


BIN
Machine_learning_analysis/__pycache__/__init__.cpython-37.pyc


+ 14 - 25
Text.py

@@ -1,27 +1,16 @@
-# import numpy as np
+# import subprocess
 #
 #
-# Dic = r'C:\Users\宋子桓\Desktop\CSV表格'
-#
-# x=np.linspace(0,1,1400)
-# z=np.linspace(8,9,1400)
-# y=7*np.sin(2*np.pi*20*x) + 5*np.sin(2*np.pi*40*z)+3*np.sin(2*np.pi*60*z)
-#
-# # o = np.vstack(x,z)
-# np.savetxt(Dic + r"/sin_x.csv", y, delimiter=',')
-
-# from scipy.fftpack import fft, ifft
-# import numpy as np
-# x = np.arange(5)
-# a = fft(x)
-# b = ifft(a)
-# print(a)
-# print(b)
-# print(a.dtype)
-# print(b.dtype)
-
-import numpy as np
+# a = subprocess.Popen('dir;dir',shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE,
+#                      cwd=r'C:\Users\宋子桓\Desktop\Git_Test')
+# # print(a.stdout())
+# a.wait()
+# print(a.returncode)
+# while True:
+#     i = a.stdout.readline().decode('utf-8')
+#     if i == '':break
+#     print(i,end='')
 
 
-a = np.array([1,2,3,4,5])
-b = np.array([1,2,3,4,5])
-c = a + b * 1j
-print(c)
+a = '&&'
+# b = ['1','2','3']
+b = ['1']
+print(a.join(b))

BIN
__pycache__/Git_Ctrl.cpython-37.pyc


BIN
__pycache__/Learn_Numpy.cpython-37.pyc