index
int64
repo_name
string
branch_name
string
path
string
content
string
import_graph
string
58,005
klgentle/lc_python
refs/heads/master
/vs_code/copy_create_table.py
" add drop table in the head " import os path = "/mnt/e/yx_walk/report_develop/sky/TABLE" path2 = "/mnt/e/yx_walk/report_develop/sky/TABLE2" for folderName, subfolders, filenames in os.walk(path): for file_name in filenames: #print(f"file_name:{file_name}") file_name2 = os.path.join(path2, file_name) # if file_name != 'cbs_fh00_aa_account_det000.sql': # continue #print(f"file_name2:{file_name2}") f2 = open(file_name2, "w") with open(os.path.join(path, file_name), encoding="utf-8-sig") as f: head = f"drop table ODSUSER_DM.{file_name.split('.')[0].upper()}; \n" f2.write(head) for data in f.readlines(): f2.write(data) f2.close() print("Done")
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,006
klgentle/lc_python
refs/heads/master
/base_practice/birthday.py
keepgoing="y" while keepgoing=="y": birthyear=int(input("Enter year of birth:")) while birthyear<1900 or birthyear>2018: print("You need to enter a year before 2019 and after 1899.\n") birthyear=int(input("Enter another value:")) else: money=100/(1+0.025)**(2018-birthyear) print("$100 in 2018 was worth $",format(money,'.2f'),"in",birthyear,"\n") keepgoing=input("Do you want to enter another year(y for yes)?")
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,007
klgentle/lc_python
refs/heads/master
/decorator_test/logging_decorator.py
""" TODO write a decorator for logging out put """ import logging logging.basicConfig( level=logging.INFO, format="%(asctime)s - %(levelname)s: %(message)s" ) def logging_begin_end(fn): def wrapper(*args,**kwargs): logging.info("{0} begin ---------- ".format(fn.__name__)) fn(*args,**kwargs) logging.info("{0} end ----------".format(fn.__name__)) return wrapper @logging_begin_end def test_logging_begin_end(i:int): print(111111111111) print(f"-----------{i}-----------") print(999999999999) def test_logging_begin_end2(): print(222222222222) test_logging_begin_end() print(88888888888) if __name__ == "__main__": test_logging_begin_end(100) #test_logging_begin_end2()
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,008
klgentle/lc_python
refs/heads/master
/code_in_books/clean_code/PrimeGenerator.py
""" This class Generates prime numbers up to a user specified maximum. The algorithm used is the Sieve of Eratosthenes. Given an array of integers starting at 2: Find the first uncrossed integer, and cross out all its multiples. Repeat until there are no more multiples in the array. """ import math class PrimeGenerator(object): def generatePrimes(self, maxValue: int) -> list: if maxValue < 2: return None else: self.__uncrossIntegersUpTo(maxValue) self.__crossOutMultiples() self.__putUncrossedIntegersIntoResult() return self.__result def __uncrossIntegersUpTo(self, maxValue: int): self.__crossedOut = [True, True] for i in range(2, maxValue+1): self.__crossedOut.append(False) #print(self.__crossedOut) def __crossOutMultiples(self): limit = self.__determineIterationLimit() for i in range(2, limit + 1): if self.__notCrossed(i): self.__crossOutMultiplesOf(i) def __determineIterationLimit(self): # Every multiple in the array has a prime factor that # is less than or equal to the root of the array size, # so we don't have to cross out multiples of numbers # larger than that root. iterationLimit = math.sqrt(len(self.__crossedOut)) return int(iterationLimit) def __crossOutMultiplesOf(self, i: int): multiple = 2 * i while multiple < len(self.__crossedOut): self.__crossedOut[multiple] = True multiple += i def __notCrossed(self, i: int): return self.__crossedOut[i] == False def __putUncrossedIntegersIntoResult(self): self.__result = [] for i in range(2, len(self.__crossedOut)): if self.__notCrossed(i): self.__result.append(i) def __numberOfUncrossedIntegers(self): count = 0 for i in range(2, len(self.__crossedOut)): if self.__notCrossed(i): count += 1 return count if __name__ == "__main__": a = PrimeGenerator() expect = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89] assert(a.generatePrimes(90) == expect) print(a.generatePrimes(90))
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,009
klgentle/lc_python
refs/heads/master
/vs_code/copy_upload.py
import shutil, os import openpyxl import pprint import csv # copy upload register and upload file def copyRegister(date_str: str): """ copy register """ code_home = "E:\\svn" dir_name = os.path.join(code_home, "1300_编码\\发布登记表") code_bate_path = "E:\\yx_walk\\report_develop\\sky" target_path = os.path.join(code_bate_path, date_str + "bate") os.makedirs(target_path, exist_ok=True) csvFile = open( target_path + "\\登记表" + date_str + ".csv", "w", newline="", encoding="utf-8-sig" ) csvWriter = csv.writer(csvFile, delimiter=",", lineterminator="\n") csvWriter.writerow( [ "所属模块", "类型(接口\报表)", "程序名称", "程序类型(pro\java\\rpt\sql\shell)", "SVN存储目录 ", "开发负责人", "BA负责人", "发布日期", "mantis id", "remarks", ] ) for folderName, subfolders, filenames in os.walk(dir_name): for filename in filenames: # print('FILE INSIDE ' + folderName + ': '+ filename) if filename.find(date_str) > -1: print(f"filename: {filename} --------------------------") whole_filename = os.path.join(folderName, filename) # copy excel file content wb = openpyxl.load_workbook(whole_filename) sheet = wb.active countyData = {} for row in range(2, sheet.max_row + 1): name = sheet["C" + str(row)].value if not name: continue file_type = sheet["D" + str(row)].value path = sheet["E" + str(row)].value data_list = [ sheet[chr(i + ord("A")) + str(row)].value for i in range(0, 10) ] # print(f'date_list:{data_list}') csvWriter.writerow(data_list) ind = path.find("1300_编码") if ind > -1: new_path = os.path.join(code_home, path[ind:]) new_file = os.path.join( code_home, path[ind:], name + "." + file_type.lower() ) # print(f"new_file:{new_file}") targetName = path[ind:].split("\\")[1].split("_")[1] # print(f"targetName:{targetName}") target_path2 = os.path.join(target_path, targetName) os.makedirs(target_path2, exist_ok=True) try: shutil.copy(new_file, target_path2) except FileNotFoundError: print(f"error! No such file: {new_file}") csvFile.close() if __name__ == "__main__": copyRegister("20190427")
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,010
klgentle/lc_python
refs/heads/master
/base_practice/test_private.py
class TestPrivate(object): def __init__(self, name): self.__name = name def get_value(self): return self.__name #a = TestPrivate("Cklll") #print(a.get_value()) class pub(): _name = 'protected类型的变量' __info = '私有类型的变量' def _func(self): print("这是一个protected类型的方法") def __func2(self): print('这是一个私有类型的方法') def get(self): return(self.__info) a = pub() print(a.get())
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,011
klgentle/lc_python
refs/heads/master
/leet_code/top_interview_questions/Medium_Case/P0046_Permutations.py
from pysnooper import snoop class Solution: @snoop() def permute(self, nums): """ :type nums: List[int] :rtype: List[List[int]] """ if len(nums) == 1: return [nums] results = [] for index in range(len(nums)): for item in self.permute(nums[:index] + nums[index+1:]): results.append([nums[index]] + item) return results if __name__ == '__main__': a = Solution() a.permute([1,2,3])
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,012
klgentle/lc_python
refs/heads/master
/base_practice/read_number.py
f=open('numbers.txt','r') line=f.readline().strip() sum = 0 while line != '': num=int(line) sum+=num line=f.readline() f.close()
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,013
klgentle/lc_python
refs/heads/master
/svn_operate/backupToZip.py
#! python3 # Copies an entire foleder and its contents into a ZIP file # whose filename increments import zipfile, os import shutil def backupToZip(folder: str): # change path dirname = os.path.dirname(folder) os.chdir(dirname) # Backup the entire contents of "folder" into a ZIP file. folder = os.path.abspath(folder) zipFilename = os.path.basename(folder) + ".zip" if os.path.exists(zipFilename): os.remove(zipFilename) # create the ZIP file print(f"Creating {zipFilename}..") backupZip = zipfile.ZipFile(zipFilename, "w") # walk the entire folder tree and compress the files in each folder base_folder = os.path.basename(folder) for foldername, subfolders, filenames in os.walk(folder): # backupZip.write(foldername) short_foldername = foldername[len(dirname) :] backupZip.write(foldername, short_foldername) # 重命名(去掉文件名前面的绝对路径) # Add all the files in this folder to the ZIP file. for filename in filenames: newBase = base_folder + "_" if filename.startswith(newBase) and filename.endswith(".zip"): continue # skip backup ZIP files # backupZip.write(os.path.join(foldername, filename)) short_filename = os.path.join(short_foldername, filename) backupZip.write(os.path.join(foldername, filename), short_filename) backupZip.close() print("Create zip done.") if __name__ == "__main__": folder = "/mnt/e/yx_walk/report_develop/sky/20190505beta" backupToZip(folder)
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,014
klgentle/lc_python
refs/heads/master
/vs_code/CopyPicture.py
#! python3 import os import shutil import time from pathlib import Path # def readHistory(file_name:str)->list: # l = [] # with open(file_name) as f: # for i in f.readlines(): # l.append(i.strip('\n')) # return l def CopyPicture(): username = "klgentle" target_path = r"D:\picture\win10_save\tmp" hist_file = Path(target_path) / "list.txt" path = r"C:\Users\{}\AppData\Local\Packages\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\LocalState\Assets".format( username ) # os.path.dirname(path) # hist_list = readHistory(hist_file) date_str = time.strftime("%Y%m%d", time.localtime()) # 20180610 modle = "a" if date_str[6:8] == "15": modle = "w" # delete all file shutil.rmtree(target_path) os.makedirs(target_path) f = open(hist_file, modle) for filename in os.listdir(path): # 拼接路径与文件名 path_file = os.path.join(path, filename) # short_name = str(filename)[:12] short_name = str(filename) # if short_name in hist_list: # continue # 判断文件大小 if os.path.getsize(path_file) > 169 * 1024: # 复制并重新命名文件 print(f"copy file {short_name}") shutil.copy(path_file, os.path.join(target_path, short_name + ".jpg")) f.write(short_name + "\t" + date_str + "\n") f.close() if __name__ == "__main__": CopyPicture()
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,015
klgentle/lc_python
refs/heads/master
/leet_code/hard_case/p0037_Sudoku_Solver_2.py
from collections import defaultdict from collections import deque class Solution: def solveSudoku(self, board) -> None: rows, cols, blocks, toVisits = defaultdict(set), defaultdict(set), defaultdict(set), deque() for r in range(9): for c in range(9): if board[r][c] != '.': rows[r].add(board[r][c]) cols[c].add(board[r][c]) t = (r//3, c//3) blocks[t].add(board[r][c]) else: toVisits.append((r, c)) def dfs(): if not toVisits: return True r, c = toVisits[0] t = (r//3, c//3) for v in {"1", "2", "3", "4", "5", "6", "7", "8", "9"}: if v not in rows[r] and v not in cols[c] and v not in blocks[t]: toVisits.popleft() board[r][c] = v rows[r].add(v) cols[c].add(v) blocks[t].add(v) if dfs(): return True else: toVisits.appendleft((r, c)) board[r][c] = "." rows[r].discard(v) cols[c].discard(v) blocks[t].discard(v) return False dfs()
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,016
klgentle/lc_python
refs/heads/master
/Intermediate_Python/generators_fibon.py
import time def fibon(n): """ 计算斐波那契数列的生成器 用这种方式,我们不用担心它会使用大量资源 no return, no list """ a = b = 1 for i in range(n): yield a a, b = b, a + b def fibon_list(n): a = b = 1 result = [] for i in range(n): result.append(a) a, b = b, a + b return result if __name__ == "__main__": #start = time.time() #for x in fibon_list(100000): # #print(x) # pass #print(time.time() - start) start2 = time.time() for x in fibon(100000): print(x) print(time.time() - start2)
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,017
klgentle/lc_python
refs/heads/master
/decorator_test/fib_with_cache.py
""" 利用缓存解斐波那契数例 """ import sys from functools import wraps sys.setrecursionlimit(1000000) # 解决maximum recursion depth exceeded def memoization(fn): cache = {} miss = object() @wraps(fn) def wrapper(*args): result = cache.get(args, miss) if result is miss: result = fn(*args) cache[args] = result return result return wrapper @memoization def fib(n): if n < 2: return n return fib(n - 1) + fib(n - 2) if __name__ == "__main__": result = fib(500) print(result)
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,018
klgentle/lc_python
refs/heads/master
/leet_code/easy_case/merge.py
class Solution: def merge(self, nums1: List[int], m: int, nums2: List[int], n: int) -> None: """ Do not return anything, modify nums1 in-place instead. """ l1 = len(nums1) l2 = len(nums2) if nums2[-1] <= nums1[0]: nums1 = nusm2 + nums1 else if num2[0] >= nums1[-1]: nums1 = nums1.extend(nusm2) for i in range(0,m+n):
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,019
klgentle/lc_python
refs/heads/master
/leet_code/medium_case/0162_Find_Peak_Element.py
class Solution: def findPeakElement(self, nums: list) -> int: # TODO logarithmic complexity. l = len(nums) if l == 1: return 0 elif l == 2: return 0 if nums[0] > nums[1] else 1 elif l == 0: return None else: if nums[0] > nums[1]: return 0 elif nums[l-2] < nums[l-1]: return l-1 for i in range(1,l-1): if nums[i] > nums[i-1] and nums[i] > nums[i+1]: return i
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,020
klgentle/lc_python
refs/heads/master
/base_practice/polygon_sides_dict.py
n_polygons = {} #polygon_sides = {"third": 3, "four":4} for key, value in polygon_sides.items(): n_polygons[value] = key print(n_polygons)
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,021
klgentle/lc_python
refs/heads/master
/tests/TestReleaseRegistrationForm.py
import openpyxl import unittest from ReleaseRegistrationForm import ReleaseRegistrationForm class TestReleaseRegistrationForm(unittest.TestCase): def setUp(self): self.reg = ReleaseRegistrationForm('20200609','','cif') self.__registration_file = r'/mnt/e/svn/ODS程序版本发布登记表cif-test-20200609.xlsx' def test_1__getRowNumOfData(self): wb = openpyxl.load_workbook(self.__registration_file) sheet = wb.active num = self.reg._ReleaseRegistrationForm__getRowNumOfData(sheet) assert(num == 225) def test_2__deleteSheetBlankRow(self): wb = openpyxl.load_workbook(self.__registration_file) sheet = wb.active self.reg._ReleaseRegistrationForm__deleteSheetBlankRow(sheet) def tearDown(self): pass if __name__ == '__main__': unittest.main()
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,022
klgentle/lc_python
refs/heads/master
/svn_operate/create_date.py
import datetime def getBetweenDay(begin_date,end_date): date_list = [] begin_date = datetime.datetime.strptime(begin_date, "%Y%m%d") #print(f"begin_date:{begin_date}") end_date = datetime.datetime.strptime(end_date, "%Y%m%d") #print(f"end_date:{end_date}") while begin_date <= end_date: date_str = begin_date.strftime("%Y%m%d") date_list.append(date_str) begin_date += datetime.timedelta(days=1) #print(f"date_list:{date_list}") return date_list if __name__ == '__main__': getBetweenDay('20190725','20190730')
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,023
klgentle/lc_python
refs/heads/master
/leet_code/labuladong/array/p0167_Two_Sum_II_-_Input_array_is_sorted.py
""" 167. Two Sum II - Input array is sorted Easy Given an array of integers numbers that is already sorted in ascending order, find two numbers such that they add up to a specific target number. Return the indices of the two numbers (1-indexed) as an integer array answer of size 2, where 1 <= answer[0] < answer[1] <= numbers.length. You may assume that each input would have exactly one solution and you may not use the same element twice. """ class Solution: def twoSum(self, numbers: List[int], target: int) -> List[int]: left, right = 0, len(numbers) - 1 while left < right: if numbers[left] + numbers[right] == target: return [left+1, right+1] elif numbers[left] + numbers[right] < target: left += 1 elif numbers[left] + numbers[right] > target: right -= 1 return [-1, -1]
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,024
klgentle/lc_python
refs/heads/master
/svn_operate/send_mail_demo.py
#!/usr/bin/python3 import traceback import time import os import smtplib from email.mime.text import MIMEText from email.utils import formataddr from email.mime.multipart import MIMEMultipart from sys import argv sender = "klgentle4@outlook.com" mail_to = [sender] def mail(date_str=None): time_str = time.strftime("%H:%M:%S", time.localtime()) try: message = MIMEMultipart() message["From"] = formataddr(["Florian", sender]) message["To"] = formataddr(["Dear", ",".join(mail_to)]) message["Subject"] = f"UAT {date_str}beta update {time_str}" message.attach( MIMEText( f"Dear all,\n\n\tSIT, UAT program update {date_str}.\n\nBest Regards\nDong Jian", "plain", "utf-8", ) ) server = smtplib.SMTP("outlook.office365.com", 587) # 发件人邮箱中的SMTP服务器,一般端口是25 server.starttls() password = input("Passwd: ") server.login(sender, password) server.sendmail(sender, mail_to, message.as_string()) server.quit() # 关闭连接 print("邮件发送成功") except Exception as e: traceback.print_exc() print("邮件发送失败") if __name__ == "__main__": date_str = time.strftime("%Y%m%d", time.localtime()) mail(date_str)
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,025
klgentle/lc_python
refs/heads/master
/leet_code/top_interview_questions/Hard_Case/0042_Trapping_Rain_Water.py
class Solution: def trap(self, height: List[int]) -> int: if not height: return 0 sum_water = 0 height_len = len(height) left_max = [height[0]] * height_len right_max = [height[-1]] * height_len for i in range(1, height_len): left_max[i] = max(left_max[i-1], height[i]) for i in range(height_len -2, -1, -1): right_max[i] = max(right_max[i+1], height[i]) # init large index first sum_water += min(left_max[i], right_max[i]) - height[i] sum_water += min(right_max[-1], right_max[-1]) - height[-1] return sum_water
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,026
klgentle/lc_python
refs/heads/master
/leet_code/easy_case/P0938_Range_Sum_of_BST.py
""" Given the root node of a binary search tree, return the sum of values of all nodes with value between L and R (inclusive). The binary search tree is guaranteed to have unique values. """ # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def rangeSumBST(self, root: TreeNode, L: int, R: int) -> int: if not root: return 0 return ( self.rangeSumBST(root.left, L, R) + self.rangeSumBST(root.right, L, R) + (root.val if L <= root.val <= R else 0) )
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,027
klgentle/lc_python
refs/heads/master
/base_practice/chw_buy.py
all_goods_and_deliver = 4866.02 au_goods_and_deliver = 998.45 au_deliver = 66.81 print(f"CHW营养品总价及运费(第一次):¥ {all_goods_and_deliver}, 澳元原价: {au_goods_and_deliver}") rmb_deliver2 = 74.33 * 4 + 87.45 print(f"澳州转运费:¥ {rmb_deliver2}") all_fee = all_goods_and_deliver + rmb_deliver2 rate = all_goods_and_deliver / au_goods_and_deliver print(f"利率:{rate}") dha_price = 28.99 black_price = 29.99 vd_price = 13.99 print(f"DHA单价(AU):{dha_price}, black单价(AU): {black_price}, VD单价(AU): {vd_price}") ryq_good = [10, 2, 2] xz_good = [10, 6, 6] print(f"饶奕钦营养品数量:DHA * {ryq_good[0]}, black * {ryq_good[1]}, VD * {ryq_good[2]}") print(f"肖珍营养品数量:DHA * {xz_good[0]}, black * {xz_good[1]}, VD * {xz_good[2]}") ryq_good_au_value = ryq_good[0] * dha_price + ryq_good[1] * black_price + ryq_good[2] * vd_price xz_good_au_value = xz_good[0] * dha_price + xz_good[1] * black_price + xz_good[2] * vd_price ryq_good_rmb_value = ryq_good_au_value * rate xz_good_rmb_value = xz_good_au_value * rate print(f"饶奕钦营养品价值:¥{ryq_good_rmb_value:.2f}, 澳元价值:{ryq_good_au_value}") print(f"肖珍营养品价值:¥{xz_good_rmb_value:.2f}, 澳元价值:{xz_good_au_value}") ryq_deliver = au_deliver * rate / 2 + 74.33 + 87.45 xz_deliver = au_deliver * rate / 2 + 74.33 * 3 print(f"饶奕钦运费:¥{ryq_deliver:.2f}") print(f"肖珍运费:¥{xz_deliver:.2f}") ryq_good_add_fee = ryq_good_rmb_value + ryq_deliver xz_good_add_fee = xz_good_rmb_value + xz_deliver print(f"饶奕钦营养品加运费:¥{ryq_good_add_fee:.2f}") print(f"肖珍营养品加运费:¥{xz_good_add_fee:.2f}") assert( all_fee == ryq_good_add_fee + xz_good_add_fee)
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,028
klgentle/lc_python
refs/heads/master
/tests/test_map.py
def test_register_data_normalize(data_list): file_name_path_list = map(lambda data_row: data_row[2:5], data_list) return file_name_path_list def test_normalize2(data_list): print("data_list:", data_list) file_name_path_list = map(lambda data: (data[0].upper(), data[1].lower(), data[2].strip()), data_list) print("file_name_path_list:", list(file_name_path_list)) def test_lambda(data): func = lambda data: (data[0].upper(), data[1].lower(), data[2].strip()) print(func(data)) if __name__ == "__main__": data_list = [ ['1','2','3','4','5','6'], ['wr','kdks','kkkds','jdsfls','sDLSDF', 'DKLDFS,DKFKS'] ] print("data_list:", data_list) data_list = test_register_data_normalize(data_list) test_normalize2(data_list) #test_lambda(['jdsfls','sDLSDF', 'DKL DFS,DKFKS'])
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,029
klgentle/lc_python
refs/heads/master
/stock_pandas/pandas_read.py
import pandas as pd loan=pd.read_csv('loan.csv') loan50=loan[(loan['Bo_Age']>50)] print(loan50['Cust_ID'].groupby(loan50['OUTCOME']).count(),'\n\n\n') print(loan50.groupby(loan50['OUTCOME']).mean()) #loan1=loan[(loan['Bo_Age']>50) & (loan['OUTCOME']=='default')] #print(loan1.head()) #loan2=loan[(loan['Bo_Age']>50) & (loan['OUTCOME']=='non-default')] #print(loan2.head())
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,030
klgentle/lc_python
refs/heads/master
/base_practice/handle_kindle_clippings.py
""" file sample: 万历十五年 (黄仁宇) - 您在位置 #135-135的标注 | 添加于 2016年9月23日星期五 上午5:59:19 嫡母隆庆的皇后陈氏 ========== 万历十五年 (黄仁宇) - 您在位置 #145-145的标注 | 添加于 2016年9月23日星期五 上午6:01:40 后来居上,实在是本末颠倒。 ========== """ import os.path import re # from pprint import pprint # my_clippings_file = r"D:\文本\kindle电子书\My Clippings-test.txt" my_clippings_file = r"D:\文本\kindle电子书\My Clippings.txt" target_note_path = r"D:\文本\kindle电子书\notes" def read_and_split_notes(): with open(my_clippings_file, "r", encoding='utf-8-sig') as note_file: all_notes = note_file.read() return all_notes.split("==========\n") def move_notes_according_to_book_name(): all_notes_list = read_and_split_notes() # 去掉最后一个无效的 Note if not all_notes_list[-1]: all_notes_list.pop() book_note_dict = {} for note in all_notes_list: note_line_list = note.split("\n") book_name = note_line_list[0].replace("\ufeff", "") book_name = re.sub(r'[,. -!?:/]', '_', book_name) page_info = note_line_list[1].split(" | ")[0].replace("- 您在位置 ", "").replace("的标注", "") note_content_with_page = " ".join([page_info, note_line_list[3]]) if book_name in book_note_dict.keys(): book_note_dict[book_name].append(note_content_with_page) else: book_note_dict[book_name] = [note_content_with_page] # pprint(book_note_dict) return book_note_dict def write_note_to_files(): for book_name, content in move_notes_according_to_book_name().items(): if not os.path.exists(target_note_path): os.makedirs(target_note_path) # print(f"Book name:{book_name}") try: with open(os.path.join(target_note_path, book_name[0:60] + '.txt'), "a", encoding="utf-8") as note_file: note_file.write("\n".join(content)) except OSError: print(f"Error found with content:", '\n'.join(content)) print("Write complete. Please check note files.") if __name__ == "__main__": write_note_to_files()
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,031
klgentle/lc_python
refs/heads/master
/leet_code/labuladong/array/p0283_Move_Zeroes.py
""" 283. Move Zeroes Easy Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements. Example: Input: [0,1,0,3,12] Output: [1,3,12,0,0] """ class Solution: def moveZeroes(self, nums: List[int]) -> None: """ Do not return anything, modify nums in-place instead. """ fast, slow = 0, 0 while fast < len(nums): if nums[fast] != 0: nums[slow] = nums[fast] slow += 1 fast += 1 while slow < len(nums): nums[slow] = 0 slow += 1
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,032
klgentle/lc_python
refs/heads/master
/stock_pandas/get_stock.py
import matplotlib.pyplot as plt import pandas as pd import requests def get_stock(): # 选择要获取的时间段 periods = "3600" # 通过Http抓取btc历史价格数据 resp = requests.get( "https://api.cryptowat.ch/markets/gemini/btcusd/ohlc", params={"periods": periods}, ) data = resp.json() # 转换成pandas data frame df = pd.DataFrame( data["result"][periods], columns=["CloseTime", "OpenPrice", "HighPrice", "LowPrice", "ClosePrice", "Volume", "NA"], ) # 输出DataFrame的头部几行 print(df.head()) print("to show plot ------------------") # 绘制btc价格曲线 df["ClosePrice"].plot(figsize=(14, 7)) # plt.show() not work on WSL plt.show() if __name__ == "__main__": get_stock()
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,033
klgentle/lc_python
refs/heads/master
/leet_code/medium_case/0017_Letter_Combinatioins_of_a_Phone_Number.py
class Solution: def letterComb(self, ret: list, digits: str) -> List[str]: # 递归 每次取第一个数字代入,返回其余数字,进行递归。 #print(f'ret:{ret}, digits:{digits}') if len(digits) == 0: return ret ret1 = [] for i in ret: for k in self.dic.get(digits[0]): ret1.append(i+k) return self.letterComb(ret1,digits[1:]) def letterCombinations(self, digits: str) -> List[str]: self.dic = {'2':['a','b','c'], '3':['d','e','f'], '4':['g','h','i'], '5':['j','k','l'], '6':['m','n','o'], '7':['p','q','r','s'], '8':['t','u','v'], '9':['w','x','y','z']} ret1 = [] ret2 = [] ret = [] l = len(digits) if l == 0: return [] elif l == 1: return self.dic.get(digits) elif l == 2: for i in self.dic.get(digits[0]): for j in self.dic.get(digits[1]): ret.append(i+j) return ret else: for i in self.dic.get(digits[0]): for j in self.dic.get(digits[1]): ret.append(i+j) return self.letterComb(ret,digits[2:])
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,034
klgentle/lc_python
refs/heads/master
/leet_code/medium_case/findNumberOfLIS_673_v11.py
#! python3 from collections import Counter from pprint import pprint class Solution: def findNumberOfLIS(self, nums) -> int: # 给定一个未排序的整数数组,找到最长递增子序列的个数。 """ to looking for increase sub set, conside each point of the list, for each point create one increase list, if one element is large than it append it at end, if min than it then add it before. """ # questoins: # how to put element in the first position of one list? [1] + [2,3] = [1,2,3](lst = nums[i] + lst) # special cases1 (equal) [2,2,2]: nums_len = len(nums) if nums_len == 0: return 0 elif nums_len == 1: return 1 if len(set(nums)) == 1: return nums_len # special case2 (decrease) [5,4,3,2,1] TODO num2 = [] # num2 like [[],[],...,[]] # initialize for i in range(0, nums_len): num2.append([]) # TODO num2 store index instead of value for j in range(0, nums_len): n2j = num2[j] n2j.append([]) n2j[0].append(nums[j]) # print('j: ', j) for k in range(0, len(n2j)): # TODO the value of k should change! n2jk = num2[j][k] for i in range(0, nums_len): if nums[i] < nums[j] and nums[i] < nums[n2jk[0]]: n2jk = [i] + n2jk elif nums[i] > nums[j] and nums[i] > nums[n2jk[-1]]: n2jk.append(i) elif nums[i] == nums[j]: # copy the last element n2jk.pop() n2j.append(n2jk) n2j[-1].append(j) print("n2j[-1]: ===========", n2j[-1]) print("len(n2j): ===========", len(n2j)) print("n2jk:{0}, j:{1}, k:{2} ______:".format(n2jk, j, k)) print("n2j ______:", n2j) print("num2 _________________:") pprint(num2) # TODO mesure the least len, add one more for cycle target_len_list = [] for item in num2: for i in item: target_len_list.append(len(i)) max_len = max(target_len_list) print("max_len: ", max_len) target_list_long = [] for item in num2: for i in item: if len(i) != max_len: continue # if i not in target_list_long: target_list_long.append(i) print("target_list_long: ", target_list_long) print("ret: ", len(target_list_long)) return len(target_list_long) if __name__ == "__main__": a = Solution() l = [1, 1, 1, 2, 2, 2, 3, 3, 3] l1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 1, 1, 1, 1] a.findNumberOfLIS(l)
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,035
klgentle/lc_python
refs/heads/master
/leet_code/easy_case/convertToTitle_168.py
# leetcode 168 class Solution: def convertToTitle(self, n: int) -> str: ret = "" while n > 0: n -= 1 # why ? print(f"n:{n}") ret = chr(n % 26 + ord("A")) + ret print(f"ret:{ret}") n //= 26 print(f"ret: {ret}") return ret if __name__ == "__main__": a = Solution() a.convertToTitle(52) # print("next------------------\n") # a.convertToTitle(701) # print("next------------------\n") # a.convertToTitle(27)
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,036
klgentle/lc_python
refs/heads/master
/leet_code/labuladong/sliding_window/p0424_Longest_Repeating_Character_Replacement.py
""" 424. Longest Repeating Character Replacement Medium Given a string s that consists of only uppercase English letters, you can perform at most k operations on that string. In one operation, you can choose any character of the string and change it to any other uppercase English character. Find the length of the longest sub-string containing all repeating letters you can get after performing the above operations. Note: Both the string's length and k will not exceed 104. Example 1: Input: s = "ABAB", k = 2 Output: 4 Explanation: Replace the two 'A's with two 'B's or vice versa. """ class Solution: def characterReplacement(self, s: str, k: int) -> int: windFreq = defaultdict(int) start, end = 0, 0 maxWindFreq, maxLen = 0, 0 while end < len(s): c = s[end] windFreq[c] += 1 maxWindFreq = max(maxWindFreq, windFreq[c]) # 比较区间长度跟区间最大词频的差异 if (end - start + 1) - maxWindFreq > k: windFreq[s[start]] -= 1 start += 1 else: maxLen = max(maxLen, end - start + 1) end += 1 return maxLen
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,037
klgentle/lc_python
refs/heads/master
/leet_code/labuladong/tree/P0114_Flatten_Binary_Tree_to_Linked_List.py
""" Given the root of a binary tree, flatten the tree into a "linked list": The "linked list" should use the same TreeNode class where the right child pointer points to the next node in the list and the left child pointer is always null. The "linked list" should be in the same order as a pre-order traversal of the binary tree. """ # Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def flatten(self, root: TreeNode) -> None: if root is None: return # 拉平左右子树 self.flatten(root.left) self.flatten(root.right) left = root.left # flatten 没有返回值,不能用函数赋值 right = root.right # 把链表挂在右边 root.left = None root.right = left # 把右链表挂在右子树 point = root while point.right is not None: point = point.right point.right = right
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,038
klgentle/lc_python
refs/heads/master
/svn_operate/CommitRegister.py
import datetime import platform import time import sys from sys import argv from date_add import date_add from PlatformOperation import PlatformOperation from SvnOperate import SvnOperate from CheckProcedure import CheckProcedure from ReleaseRegistrationForm import ReleaseRegistrationForm SVN_DIR = "/mnt/e/svn/1300_编码/" if platform.uname().system == "Windows": SVN_DIR = "E:\\svn\\1300_编码\\" class CommitRegister(object): """ read log to write excel for install """ def __init__(self, date_str, mantis, module_type): self.__mantis = mantis self.__registration = ReleaseRegistrationForm(date_str, mantis, module_type) @staticmethod def checkProcedureAndExit(): # 检查存储过程 cp = CheckProcedure() if not cp.isAllProcedureCorrect(): sys.exit(1) def __getCommitMessage(self): commitMessage = "" if self.__mantis: commitMessage = f"mantis: {self.__mantis}" return commitMessage def svn_add_commit(self): self.svn = SvnOperate(SVN_DIR) self.svn.svn_add() self.svn.svn_delete() self.svn.svn_commit_code(message=self.__getCommitMessage()) self.svn.update_svn() #try: #except Exception as e: # print("Svn Operate Error:", e.__doc__) def commit_register(self): try: self.svn.svn_add() self.svn.svn_commit() except Exception as e: print("svn error:", e.__doc__) def SvnLogRegist(self): self.__registration.logRead() self.__registration.logRegister() self.__registration.logClean() def CreateSvnLog(self): self.checkProcedureAndExit() self.svn_add_commit() def readLogAndCommit(self): self.SvnLogRegist() self.commit_register() def SvnLogRegistAndCommit(self): self.CreateSvnLog() self.readLogAndCommit() if __name__ == "__main__": today = time.strftime("%Y%m%d", time.localtime()) date_str = time.strftime("%Y%m%d", time.localtime()) time_str = time.strftime("%H:%M", time.localtime()) if time_str > "16:10": # today add one day date_str = date_add(1) mantis = "" module_type = "cif" if len(argv) == 2 and len(argv[1]) == 8: date_str = argv[1] elif len(argv) == 3: date_str, mantis = argv[1], argv[2] elif len(argv) == 4: date_str, mantis, module_type = argv[1], argv[2], argv[3] if not argv[3]: module_type = "cif" elif len(argv) > 4: print("usage: python3 commit_register.py '20190501' mantis_id, module_type") sys.exit(1) if len(argv) > 1 and argv[1].find("d+") > -1: # get days from d+days days = int(argv[1][2:]) date_str = date_add(days) if date_str < today: print(f"date_str:{date_str} is wrong!") sys.exit(1) print(f"argv:{argv} ---------- ") print(f"date_str:{date_str} ---------- ") a = CommitRegister(date_str, mantis, module_type) a.SvnLogRegistAndCommit() print(f"time:{time_str}")
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,039
klgentle/lc_python
refs/heads/master
/data_structure/maze_rec.py
def passable(maze, pos): return maze(pos[0], pos[1]) == 0 def mark(maze, pos): maze(pos[0], pos[1]) = 2 def find_path(maze, pos, end): mark(maze, pos) if start == end: print(pos, end=" ") return dirs = ([0, 1], [1, 0], [-1, 0], [0, -1]) for i in range(0, 4): nextp = (pos[0]+dirs[i][0], pos[1]+dirs[i][1]) if passable(maze, nextp): if find_path(maze, nextp, end): print(pos, end=" ") return True return False
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,040
klgentle/lc_python
refs/heads/master
/leet_code/labuladong/tree/P0094_Binary_Tree_Inorder_Traversal.py
""" Given the root of a binary tree, return the inorder traversal of its nodes' values. Input: root = [1,null,2,3] Output: [1,3,2] Example 2: Input: root = [] Output: [] Example 3: Input: root = [1] Output: [1] """ # Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def inorderTraversal(self, root: TreeNode) -> List[int]: # 根据..序,返回正序 if root is None: return [] left_out = self.inorderTraversal(root.left) right_out = self.inorderTraversal(root.right) return left_out + [root.val] + right_out
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,041
klgentle/lc_python
refs/heads/master
/leet_code/labuladong/LRU/p0146_LRU_Cache.py
""" 146. LRU Cache Medium Design a data structure that follows the constraints of a Least Recently Used (LRU) cache. Implement the LRUCache class: LRUCache(int capacity) Initialize the LRU cache with positive size capacity. int get(int key) Return the value of the key if the key exists, otherwise return -1. void put(int key, int value) Update the value of the key if the key exists. Otherwise, add the key-value pair to the cache. If the number of keys exceeds the capacity from this operation, evict the least recently used key. Follow up: Could you do get and put in O(1) time complexity? """ from collections import OrderedDict class LRUCache: def __init__(self, capacity: int): self._capacity = capacity self._cache = OrderedDict() def get(self, key: int) -> int: if key not in self._cache: return -1 val = self._cache[key] # move to the end self._cache.move_to_end(key) return val def put(self, key: int, value: int) -> None: if key in self._cache: del self._cache[key] self._cache[key] = value if len(self._cache) > self._capacity: # pop the first item self._cache.popitem(last=False) # Your LRUCache object will be instantiated and called as such: # obj = LRUCache(capacity) # param_1 = obj.get(key) # obj.put(key,value)
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,042
klgentle/lc_python
refs/heads/master
/automatic_office/py7zunzip.py
#!/usr/bin/env python """ @Author :Rattenking @Date :2021/06/02 15:42 @CSDN :https://blog.csdn.net/m0_38082783 """ import time import subprocess def get_current_time_stamp(): times = time.time() time_stamp = int(round(times * 1000)) return time_stamp def verify_password(pwd): cmd = f'7z t -p{pwd} ./test.zip' status = subprocess.call(cmd) return status def unzip_file_other_folder(pwd): print(f'正确的密码是:{pwd}') cmd = f'7z x -p{pwd} ./test.zip -y -aos -o"./all/"' subprocess.call(cmd) def get_all_possible_password(): for i in range(1000000): pwd = str(("%06d"%i)) status = verify_password(pwd) if status == 0: unzip_file_other_folder(pwd) break if __name__ == "__main__": start = get_current_time_stamp() get_all_possible_password() end = get_current_time_stamp() print(f"解压压缩包用时:{end - start}ms")
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,043
klgentle/lc_python
refs/heads/master
/leet_code/medium_case/0082_Remove_Duplicates_from_Sorted_List_II.py
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def deleteDuplicates0(self, head: ListNode) -> ListNode: """find duplicate value, and add this value in duplicate set if node.val in duplicate set then skip this node """ value_set = set() dupl_set = set() node = head while node: if node.val not in value_set: value_set.add(node.val) else: dupl_set.add(node.val) node = node.next dummy = ListNode(None) dummy.next = head node = dummy while node.next: if node.next.val in dupl_set: # skip node node.next = node.next.next else: node = node.next return dummy.next def deleteDuplicates(self, head: ListNode) -> ListNode: """ construct a dummy list node: dummy, the head is pre, value is 0. find the distinct element, and let pre point to it at last return the node list except head (pre) """ dummy = pre = ListNode(0) dummy.next = head while head and head.next: if head.val == head.next.val: while head and head.next and head.val == head.next.val: head = head.next head = head.next pre.next = head ### core is here else: pre = pre.next head = head.next return dummy.next
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,044
klgentle/lc_python
refs/heads/master
/leet_code/labuladong/tree/P0102_Binary_Tree_Level_Order_Traversal.py
""" Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example: Given binary tree [3,9,20,null,null,15,7], 3 / \ 9 20 / \ 15 7 return its level order traversal as: [ [3], [9,20], [15,7] ] """ from collections import deque class Solution: def levelOrder(self, root: TreeNode) -> List[List[int]]: q, result = deque(), [] if root: q.append(root) while q: level = [] for _ in range(len(q)): x = q.popleft() level.append(x.val) if x.left: q.append(x.left) if x.right: q.append(x.right) result.append(level) return result
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,045
klgentle/lc_python
refs/heads/master
/leet_code/labuladong/array/p0080_Remove_Duplicates_from_Sorted_Array_II.py
""" 80. Remove Duplicates from Sorted Array II Medium Given a sorted array nums, remove the duplicates in-place such that duplicates appeared at most twice and return the new length. Do not allocate extra space for another array; you must do this by modifying the input array in-place with O(1) extra memory. """ from collections import Counter class Solution: def removeDuplicates(self, nums: List[int]) -> int: count = Counter(nums) # delete from then end for v in nums[::-1]: #print(f"v:{v}, count[v]:{count[v]}") if count[v] > 2: nums.remove(v) count[v] -= 1 return len(nums)
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,046
klgentle/lc_python
refs/heads/master
/shell_test/send_table_mail/sqlite3_demo.py
import sqlite3 def demo(): # 若不存在则创建 con = sqlite3.connect("test.db") # 游标对象 cur = con.cursor() # 新建表 cur.execute( "create table if not exists ifrs9_data \ (site_name text primary key not null, ind int, file_info text, path_name text, record_count int)" ) # insert data cur.execute( "INSERT INTO ifrs9_data(site_name, ind, file_info, path_name, record_count) VALUES(?,?,?,?,?)", ("AMH", 1, "12312 Oct 22 22:22", "name.sf", 123), ) cur.execute( "INSERT INTO ifrs9_data(site_name, ind, file_info, path_name, record_count) VALUES(?,?,?,?,?)", ("HSCN", 1, "21312 Oct 22 22:22", "name.sf", 213), ) cur.execute("select * from ifrs9_data") print(cur.fetchall()) con.commit() con.close() pass if __name__ == "__main__": demo()
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,047
klgentle/lc_python
refs/heads/master
/leet_code/top_interview_questions/Medium_Case/P0139_Word_Break.py
class Solution: def wordBreak(self, s, words): # ok[i] tells whether s[:i] can be built. ok = [True] for i in range(1, len(s)+1): ok += any(ok[j] and s[j:i] in words for j in range(i)), #print(ok) return ok[-1]
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,048
klgentle/lc_python
refs/heads/master
/leet_code/easy_case/isUgly.py
class Solution: def isUgly(self, num: int) -> bool: if num <= 0: return False for i in (2,3,5): while num % i == 0: num //= i #print(True if num == 1 else False) return True if num == 1 else False if __name__ == '__main__': a = Solution() a.isUgly(937351770)
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,049
klgentle/lc_python
refs/heads/master
/data_structure/josephus.py
def josephus_a(total_num, start, target_num): """ 假设有n个人围坐一圈,现要求从第 k 个人开始报数,报到第 m 个数的人退出 """ people = list(range(1, total_num + 1)) index = start - 1 for times in range(total_num): count = 0 while count < target_num: if people[index] > 0: count += 1 if count == target_num: print(people[index], end="") people[index] = 0 index = (index + 1) % total_num if times < total_num - 1: print(", ", end="") else: print("") return def josephus_l(n, k, m): people = list(range(1, n + 1)) i = k - 1 for num in range(n, 0, -1): i = (i + m - 1) % num print(people.pop(i), end=(", " if num > 1 else "\n")) return if __name__ == "__main__": print("a:") josephus_a(5, 2, 2) print("l:") josephus_l(5, 2, 2)
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,050
klgentle/lc_python
refs/heads/master
/leet_code/labuladong/tree/P0652_Find_Duplicate_Subtrees.py
""" Given the root of a binary tree, return all duplicate subtrees. For each kind of duplicate subtrees, you only need to return the root node of any one of them. Two trees are duplicate if they have the same structure with the same node values. Example 1: Input: root = [1,2,3,4,null,2,4,null,null,4] Output: [[2,4],[4]] """ class Solution: def __init__(self): self.memo = {} self.res = [] def findDuplicateSubtrees(self, root: TreeNode) -> List[TreeNode]: self.TreeNodeSerialization(root) return self.res def TreeNodeSerialization(self, root: TreeNode): if not root: return "#" left = self.TreeNodeSerialization(root.left) right = self.TreeNodeSerialization(root.right) subTree = f"{left},{right},{root.val}" if subTree in self.memo: self.memo[subTree] += 1 # 无法用in list判断root是不是已经在self.res中,毕竟这个结构比较复杂 if self.memo[subTree] == 2: self.res.append(root) else: self.memo[subTree] = 1 return subTree
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,051
klgentle/lc_python
refs/heads/master
/leet_code/top_interview_questions/Medium_Case/P0050_Powx_n.py
class Solution: def myPow(self, x: float, n: int) -> float: out = 1 flag = '+' if n < 0: flag = '-' n = abs(n) while n > 0: out *= x n -= 1 return out if flag =='+' else 1/out
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,052
klgentle/lc_python
refs/heads/master
/leet_code/easy_case/climStairs.py
import math class Solution: def climbStairs(self, n: int) -> int: print("n:", n) ret = 0 for i in range(0, n + 1): for j in range(0, n + 1): if i + 2 * j != n: continue print("i:{0},j:{1}".format(i, j)) y = 0 if i == 0 or j == 0: y = 1 else: y = math.factorial(i + j) / (math.factorial(j) * math.factorial(i)) ret += int(y) print("y:", y) print("ret:", ret) return ret if __name__ == "__main__": a = Solution() a.climbStairs(4)
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,053
klgentle/lc_python
refs/heads/master
/leet_code/easy_case/buddyString.py
class Solution: def buddyStrings(self, A: str, B: str) -> bool: duplicate = False la = len(A) if la != len(B) or set(A) != set(B): return False if len(set(A)) < la: duplicate = True if duplicate and A == B: return True diff_list = [] for i in range(0, la): if A[i] != B[i]: diff_list.append(i) if len(diff_list) != 2: return False j, k = diff_list[0], diff_list[1] return A[j] == B[k] and A[k] == B[j]
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,054
klgentle/lc_python
refs/heads/master
/data_structure/ackerman.py
def ack(m, n): if m == 0: return n+1 if n == 0: return ack(m-1, 1) return ack(m-1, ack(m, n-1)) print(ack(3, 4)) """ ack(0,0) = -1 ack(0,1) = -1 ack(1,0) = ack(0,1) = -1 ack(1,1) = ack(0,ack(1,0)) = ack(0,-1) = -1 ack(1,2) = ack(0,ack(1,1)) = -1 ack(2,0) = ack(1,0) = -1 ack(2,1) = ack(1,ack(2,0)) = ack(1,-1) = ack(0,..) = -1 ack(2,2) = ack(1,ack(2,1)) """
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,055
klgentle/lc_python
refs/heads/master
/leet_code/medium_case/generateMatrix.py
class Solution: def generateMatrix(self, n: int): #def generateMatrix(self, n: int) -> List[List[int]]: # TODO 递归 # list.insert(index, obj) l = [[] for i in n] l[1] = list(range(1,n+1)) l[-1] = list(range(3n-2,-1,2n-2)) for i in range(n+1,2n-1): #ind = i-n l[i-n].insert(-1,i) for i in range(3n-2,4n-4+1): l[4n-3-i].insert(0,i) return [1] if n == 1 else return self.recursionMatrxi(n-1) def recursionMatrxi(self, n:int, lst): pass
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,056
klgentle/lc_python
refs/heads/master
/tests/test_re.py
import re def test_re_search(): # search_obj = re.search(pattern, string, flags=re.IGNORECASE) view_pattern = r"V_\w*_ALL" string1 = "V_DEAL_DATE,'FH00',T1.CCY,T1.OD_ALL" string2 = "V_ACCOUNT_M_ALL" if re.search(view_pattern, string1, flags=re.IGNORECASE) : print(f"{string1} fond") else: print(f"{string1} not find") if re.search(view_pattern, string2, flags=re.IGNORECASE) : print(f"{string2} fond") else: print(f"{string2} not find") if __name__ == "__main__": test_re_search()
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,057
klgentle/lc_python
refs/heads/master
/leet_code/medium_case/P0338_Counting_Bits.py
from typing import List class Solution(object): """ 二进制数可以分成两部分: 一部分是最后一位 (i&1), 另一部分是除最后一位的其他部分 (i >> 1) 1 = 1 2 = 10 3 = 11 4 = 100 5 = 101 6 = 110 7 = 111 8 = 1000 """ def countBits(self, num: List[int]) -> List[int]: res = [0] for i in range(1, num + 1): res += (res[i >> 1] + (i & 1),) return res if __name__ == "__main__": print(Solution().countBits(4))
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,058
klgentle/lc_python
refs/heads/master
/leet_code/medium_case/0378_Kth_Smallest_Element_in_a_Sorted_Matrix.py
import heapq class Solution: def kthSmallest(self, matrix: list, k: int) -> int: length = len(matrix) counter = 0 ref = [] for i in range(length): for j in range(length): ref.append(matrix[i][j]) heapq.heapify(ref) for i in range(k): result = heapq.heappop(ref) print(result) return result if __name__ == '__main__': a = Solution() mat =[[1,5,9],[10,11,13],[12,13,15]] k =8 a.kthSmallest(mat,k)
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,059
klgentle/lc_python
refs/heads/master
/svn_operate/SvnOperate.py
import os import platform import sys import requests class SvnOperate(object): def __init__(self, path): os.chdir(path) if not self.is_system_windows(): raise TypeError("not windows OS svn operate is not safe") self.checkSvnConnect() @staticmethod def checkSvnConnect(): # SSLError(SSLCertVerif svn_url = "https://10.120.107.200/svn/HK-ODS" r = requests.get(svn_url, verify=False) @staticmethod def update_svn(): try: print("Call svn up ......") os.system("svn up") except Exception as e: print("SVN UP ERROR: ", e.__doc__) def update_windows_svn(self): if self.is_system_windows(): # BE CAREFUL HERE ############### self.update_svn() @staticmethod def is_system_windows(): is_system_windows = False if platform.uname().system == "Windows": is_system_windows = True return is_system_windows @staticmethod def svn_add(): try: # 检查是否是新增的文件 # TODO svn how to add file with blank? if os.popen("svn st").read().find("?") > -1: svn_st_list = os.popen("svn st").read().strip("\n").split("\n") svn_st_filter = filter(lambda x: x.startswith("? "), svn_st_list) svn_st_list = list(map(lambda x: x.strip("? "), svn_st_filter)) # print(list(svn_st_list)) for filename in svn_st_list: print("call svn add {}".format(filename)) os.system("svn add {}".format(filename)) except Exception as e: print("SVN ADD ERROR: ", e.__doc__) @staticmethod def svn_commit(message="", redirect=None): try: # TODO 解决重复提交的问题 if len(os.popen("svn st").read()) < 2: # print("no need to commit") return if redirect: print(f'call svn commit -m "{message}" * >{redirect}') os.system(f'svn commit -m "{message}" * >{redirect}') else: print(f'call svn commit -m "{message}" *') os.system(f'svn commit -m "{message}" *') except Exception as e: print("SVN COMMIT ERROR: ", e.__doc__) def svn_commit_code(self, message="", redirect="../commit.log"): return self.svn_commit(message, redirect) @staticmethod def svn_delete(): try: if os.popen("svn st").read().find("!") > -1: svn_st_list = os.popen("svn st").read().strip("\n").split("\n") svn_st_filter = filter(lambda x: x.startswith("! "), svn_st_list) svn_st_list = list(map(lambda x: x.strip("! "), svn_st_filter)) # print(list(svn_st_list)) for filename in svn_st_list: print("call svn delete {}".format(filename)) os.system("svn delete {}".format(filename)) except Exception as e: print("SVN DELETE ERROR: ", e.__doc__)
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,060
klgentle/lc_python
refs/heads/master
/tests/test_svn.py
import os import sys from os.path import dirname # 项目根目录 BASE_DIR = dirname(dirname(os.path.abspath(__file__))) # 添加系统环境变量 sys.path.append(BASE_DIR) from vs_code.SvnOperate import SvnOperate SVN_DIR = r"E:\svn\1300_编码" def test_svn_add(): SvnOperate(SVN_DIR).svn_add() def test_svn_commit(): SvnOperate(SVN_DIR).svn_commit() def test_svn_commit_code(): SvnOperate(SVN_DIR).svn_commit_code() if __name__ == "__main__": test_svn_commit()
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,061
klgentle/lc_python
refs/heads/master
/leet_code/labuladong/tree/p0199_Binary_Tree_Right_Side_View.py
""" 199. Binary Tree Right Side View Medium Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom. Example: Input: [1,2,3,null,5,null,4] Output: [1, 3, 4] Explanation: 1 <--- / \ 2 3 <--- \ \ 5 4 <--- """ from collections import deque class Solution: """ 此解法的模板可以解决很多个题目,只要是分层查看就可以使用 """ def rightSideView(self, root: TreeNode) -> List[int]: ans = [] q = deque() if root: q.append(root) while q: level = [] for _ in range(len(q)): x = q.popleft() level.append(x.val) if x.left: q.append(x.left) if x.right: q.append(x.right) ans.append(level[-1]) return ans
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,062
klgentle/lc_python
refs/heads/master
/data_structure/c9_2_select_sort.py
def select_sort(lst): for i in range(len(lst) - 1): # 只需循环 len(lst) -1 次 k = i for j in range(i, len(lst)): # k 是已知最小元素的位置 if lst[j].key < lst[k].key: k = j if i != k: # lst[k] 是确定的最小元素,检查是否需要交换 lst[i], lst[k] = lst[k], lst[i]
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,063
klgentle/lc_python
refs/heads/master
/string_code/StringFunctions.py
class StringFunctions(str): def __init__(self, string: str): self = string def find_the_second_position(self, target_str: str) -> int: target_str_ind = self.find(target_str) if target_str_ind == -1: return -1 target_str_ind_and_len = target_str_ind+len(target_str) str_last = self[target_str_ind_and_len:] if str_last.find(target_str) == -1: return -1 return target_str_ind_and_len + str_last.find(target_str) def str_insert(self, position: int, add_str: str) -> str: "insert in assign point" return self[0:position] + add_str + self[position:] if __name__ == '__main__': a = StringFunctions('AND a =b AND c=d') postion = a.find_the_second_position('AND') print(postion) print(a.str_insert(postion, '\n'))
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,064
klgentle/lc_python
refs/heads/master
/base_practice/data_to_html.py
import sys data = "" with open("star_data.txt","r") as f: data = f.readlines() for row in map(lambda x: x.rstrip().split(":"), data): #print("<tr><td>" + "</td><td>".join(row) + "</td></tr>") print("<tr><td>" + "</td><td>".join([i.rstrip() for i in row]) + "</td></tr>")
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,065
klgentle/lc_python
refs/heads/master
/base_practice/mix_color.py
colors = input("Enter primary color:") colors2 = input("Enter primary color:") primary_colors = [colors, colors2] if "red" in primary_colors and "blue" in primary_colors: print(f"When you mix {colors} and {colors2}, you get purple.") elif "red" in primary_colors and "yellow" in primary_colors: print(f"When you mix {colors} and {colors2}, you get orange.") elif "blue" in primary_colors and "yellow" in primary_colors: print(f"When you mix {colors} and {colors2}, you get green.") else: print("You didn't input two primary colors.")
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,066
klgentle/lc_python
refs/heads/master
/base_practice/str_upper.py
#str = input("Enter sentence to be capitalized:") str = "Enter sentence to be capitalized. kllsk. lsldk. kklsdl. kkk Ull." str_list = str.split('. ') for i in range(0,len(str_list)): a=str_list[i] str_list[i]=a[0].upper()+a[1:] str2='. '.join(str_list) print(str2)
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,067
klgentle/lc_python
refs/heads/master
/database/sqlFormat.py
import sqlparse def sqlFormat(sql: str) -> str: return sqlparse.format(sql, reindent=True, keyword_case='upper') if __name__ == "__main__": sql = """WITH TMP_CUSTOMER_NAME AS ( SELECT T61.ID ,T61.NAME_1||' '||T61.NAME_2 AS CUST_NAME FROM ODSUSER.CBS_FH00_CUSTOMER_M T61 --CUSTOMER INFO WHERE T61.M = '1' AND T61.S = '1' AND T61.DATA_DATE = date'2019-12-31' ) SELECT DISTINCT date'2019-12-31' AS DATA_DATE --,T1.DATA_DATE ,REPLACE(SUBSTR(TO_CHAR(T2.LGAC_ACCOUNT_NO, '99999,99,999999,9'),4),',', '-') AS LG_A_C_NO ,REPLACE(T61.CUST_NAME||CHR(10)||NVL(T62.CUST_NAME,' ')||CHR(10)||NVL(T63.CUST_NAME,' ') ||CHR(10)||NVL(T64.CUST_NAME,' ')||CHR(10)||NVL(T65.CUST_NAME,' '),CHR(10)||' ',NULL) AS CUST_NAME1 -- write 5 lines in one field, and delete blank line dongjian 20190918 --,T1.LGI_AMT-T1.LGI_REDEEM_AMT AS BALANCE_HKE ,NVL(T11.BALANCE_HKE,0) AS BALANCE_HKE -- DONGJIAN 20190919 ,NVL(RPTUSER.F_EX_OTH_TO_HKD(T3.LIMIT_CURRENCY,T3.LIMIT_AMOUNT,T1.DATA_DATE),0) AS LG_LIMIT_HKE ,CASE WHEN T9.COLLATERAL_TYPE IN ('10','11') THEN RPTUSER.FUC_FORMAT_AC_NO(T5.ACCOUNT_NO) ELSE T10.DESCRIPTION END AS COLLATERAL_TYPE ,CASE WHEN T9.COLLATERAL_TYPE IN ('10','11') THEN NVL(RPTUSER.F_EX_OTH_TO_HKD(T9.CURRENCY,T9.NOMINAL_VALUE,T1.DATA_DATE),0) ELSE NULL END AS F_D_AMOUNT_HKE ,CASE WHEN NVL(T9.COLLATERAL_TYPE, 'NULL') NOT IN ('10','11') AND T9.COLLATERAL_CODE = '70' THEN NVL(RPTUSER.F_EX_OTH_TO_HKD(T9.CURRENCY,T9.NOMINAL_VALUE,T1.DATA_DATE),0) -- DONGJIAN 20191126 MAINIS#13496 WHEN NVL(T9.COLLATERAL_TYPE, 'NULL') NOT IN ('10','11') THEN NVL(RPTUSER.F_EX_OTH_TO_HKD(T9.CURRENCY,T9.NOMINAL_VALUE,T1.DATA_DATE),0) -- [GENE 20200216], fixing collateral value ELSE NULL END AS VALUATION_HKE ,0 AS TTL_F_D --BO DO IT ,0 AS TTL --BO DO IT ,CASE WHEN T9.COLLATERAL_TYPE IN ('10','11') THEN 1 ELSE 0 END AS IS_COLL_TYPE_10_11 FROM ODSUSER.LGR_LG_ISSUES T1 LEFT JOIN ODSUSER.LGR_LG_ACCOUNTS T2 --LG INFO -- CHANGE LEFT JOIN TO INNER JOIN DONGJIAN 20190917 ON T2.DATA_DATE = T1.DATA_DATE AND T1.LGAC_ACCOUNT_NO = T2.LGAC_ACCOUNT_NO LEFT JOIN ( SELECT T.LGAC_ACCOUNT_NO AS LGAC_ACCOUNT_NO ,SUM(NVL(RPTUSER.F_EX_OTH_TO_HKD(T.LGI_CURRENCY_CODE, T.LGI_AMT, T.DATA_DATE), 0)) AS BALANCE_HKE FROM ODSUSER.LGR_LG_ISSUES T WHERE T.LGI_ISSUE_DATE <= date'2019-12-31' -- DONGJIAN 20190918 according to RFS AND T.DATA_DATE = date'2019-12-31' GROUP BY T.LGAC_ACCOUNT_NO ) T11 ON T2.LGAC_ACCOUNT_NO = T11.LGAC_ACCOUNT_NO --BALANCE_HKE 要SUM起来 LEFT JOIN ( SELECT DISTINCT -- DUPLICATE DATAS FIX DONGJIAN 20190918 LIMIT_CURRENCY ,LIMIT_AMOUNT ,LIMIT_ID ,AVAILABLE_MARKER FROM RPTUSER.RPT_LIMIT_MID WHERE DATA_DATE = date'2019-12-31' ) T3 ON T2.LGAC_LIMIT_ID = T3.LIMIT_ID --LIMIT INFO /* LEFT JOIN RPTUSER.RPT_COLLATERAL_MID T4 --COLLATERAL INFO ON T4.DATA_DATE = date'2019-12-31' AND T3.LIMIT_ID = T4.LIMIT_REFERENCE */ LEFT JOIN TMP_CUSTOMER_NAME T61 ON T2.LGAC_CUSTOMER_ID1 = T61.ID -- DONGJIAN 20190917 LEFT JOIN TMP_CUSTOMER_NAME T62 ON T2.LGAC_CUSTOMER_ID2 = T62.ID -- DONGJIAN 20190917 LEFT JOIN TMP_CUSTOMER_NAME T63 ON T2.LGAC_CUSTOMER_ID3 = T63.ID -- DONGJIAN 20190917 LEFT JOIN TMP_CUSTOMER_NAME T64 ON T2.LGAC_CUSTOMER_ID4 = T64.ID -- DONGJIAN 20190917 LEFT JOIN TMP_CUSTOMER_NAME T65 ON T2.LGAC_CUSTOMER_ID5 = T65.ID -- DONGJIAN 20190917 LEFT JOIN ( SELECT DISTINCT T7.ID ,T7.LIMIT_REFERENCE --DONGJIAN 20190918 FROM ODSUSER.CBS_FH00_COLLATERAL_RIGHT_M T7 --COLLATERAL RIGHT LEFT JOIN ODSUSER.CBS_FH00_COLLATERAL_RIGHT T8 --COLLATERAL RIGHT ON T8.ID = T7.ID AND T8.DATA_DATE = date'2019-12-31' WHERE (TO_DATE(T8.EXPIRY_DATE,'YYYY-MM-DD') >= date'2019-12-31' OR T8.EXPIRY_DATE IS NULL) /*AND T7.M = '1' AND T7.S = '1'*/ -- DONGJIAN 20190918 AND T7.LIMIT_REFERENCE IS NOT NULL -- NULL VALUE CAN'T JOIN DONGJIAN 20190919 AND T7.DATA_DATE = date'2019-12-31' ) T7 ON T7.LIMIT_REFERENCE = T2.LGAC_LIMIT_ID LEFT JOIN ODSUSER.CBS_FH00_COLLATERAL T9 ON T9.ID = T7.ID || '.1' AND (TO_DATE(T9.EXPIRY_DATE,'YYYY-MM-DD') >= date'2019-12-31' OR T9.EXPIRY_DATE IS NULL) -- DONGJIAN 20190918 AND T9.DATA_DATE = date'2019-12-31' LEFT JOIN RPTUSER.RPT_AA_ARRANGEMENT_TD_MID T5 --FIX DEPOSIT INFO ON T5.ARRANGEMENT = T9.APPLICATION_ID -- DONGJIAN 20190917 AND T5.DATA_DATE = date'2019-12-31' LEFT JOIN ODSUSER.CBS_FH00_COLLATERAL_TYPE_M T10 ON T9.COLLATERAL_TYPE = T10.ID AND M = '1' AND S = '1' AND T10.DATA_DATE = date'2019-12-31' WHERE (T3.LIMIT_ID IS NULL OR T3.AVAILABLE_MARKER = 'Y') -- DONGJIAN 20190917 AND T1.LGI_STATUS = 'O' --AND T1.LGI_DUE_DATE > date'2019-12-31' --- LGI_DUE_DATE 不能限制,不然会过滤数据 --AND TRUNC(T1.DATA_DATE,'MM') = TRUNC(date'2019-12-31','MM') AND T2.LGAC_ACCOUNT_NO = '49259490006119' ;""" print(sqlFormat(sql))
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,068
klgentle/lc_python
refs/heads/master
/automatic_office/word2pdf.py
from subprocess import call import shutil # Convert using Libre Office def convert_file(output_dir, input_file): call('libreoffice --headless --convert-to pdf --outdir %s %s ' % (output_dir, input_file), shell=True) if __name__ == "__main__": input_file = r'E:\yx_walk\report_develop\uat修复\201908\pcl021_requirement.docx' output_dir = r"E:\yx_walk\report_develop\uat修复\201908" convert_file(output_dir, input_file)
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,069
klgentle/lc_python
refs/heads/master
/svn_operate/ReleaseRegistrationForm.py
import os import openpyxl import platform import pprint import shutil, os import sys import re import time from sys import argv from PlatformOperation import PlatformOperation from skip_table_structure_change import skip_table_structure_change SVN_DIR = "/mnt/e/svn/1300_编码/" SVN_LOG = "/mnt/e/svn/commit.log" if platform.uname().system == "Windows": SVN_DIR = "E:\\svn\\1300_编码\\" SVN_LOG = "E:\\svn\\commit.log" class ReleaseRegistrationForm(object): def __init__(self, date_str, mantis, module_type): self.__date_str = date_str self.__module_type = module_type self.__createRegistrationFile() self.__comit_list = [] self.__commit_list_end = ["Dongjian", "Gene", self.__date_str, mantis, "", ""] def __createRegistrationFile(self): self.regi_dir = os.path.join(SVN_DIR, "发布登记表", self.__module_type) template_file = os.path.join( self.regi_dir, f"ODS程序版本发布登记表({self.__module_type})-template.xlsx" ) self.__registration_file = os.path.join( self.regi_dir, f"ODS程序版本发布登记表({self.__module_type})-{self.__date_str}.xlsx" ) if not os.path.exists(self.__registration_file): shutil.copy(template_file, self.__registration_file) @staticmethod def __getEncoding(): if platform.uname().system == "Windows": return "gb2312" else: # deal with \ufeff return "utf-8-sig" @staticmethod def __isCodeLine(line): if ( line.startswith("Sending") or line.startswith("Adding") or line.startswith("Modified") or line.startswith("Modify") ): return True return False @staticmethod def __isFolderLine(line): # 如果为目录则返回true if line.startswith("Adding") and line.split('/')[-1].find(".") == -1: return True return False @staticmethod def __isRegistrationLine(line): if line.find("ODS程序版本发布登记表") > -1: return True return False @staticmethod def __getModule(file_name:str) -> str: modu = re.split("RPT_|ITF_", file_name.upper()) module = "" if len(modu) > 1: module = modu[1][:3] return module or "CIF" @staticmethod def __svnLineClean(line): line = line.split(" ")[-1] line = line.replace("\n","") if line.find("application/octet-stream") > -1: line = line.replace("application/octet-stream", "").strip() return line def __getPathAndFileFrom(self, line): line = self.__svnLineClean(line) if line.find("1300_编码") > -1: pathAndFile = line[line.find("1300_编码") :] else: pathAndFile = os.path.join("1300_编码", line) pathAndFile = os.path.join("1000_编辑区", pathAndFile) pathAndFile = PlatformOperation.change_path_sep(pathAndFile) return pathAndFile def logReadOneLine(self, line): pathAndFile = self.__getPathAndFileFrom(line) filePath = os.path.dirname(pathAndFile) filenameAndType = os.path.basename(pathAndFile) filename = filenameAndType.split(".")[0] filetype = filenameAndType.split(".")[-1] # 兼容 windows filePath = filePath.replace(os.sep, "\\") module = self.__getModule(filename) row = [module, "报表"] + [filename, filetype, filePath] + self.__commit_list_end self.__comit_list.append(row) def logRead(self): with open(SVN_LOG, encoding=self.__getEncoding()) as svn_log: for line in svn_log.readlines(): line = line.strip() if self.__isCodeLine(line) and not self.__isRegistrationLine(line) and not self.__isFolderLine(line): self.logReadOneLine(line) @staticmethod def printComitList(comit_list): print("records are as bellow:") for registrationRow in comit_list: print(registrationRow) def logRegister(self): wb = openpyxl.load_workbook(self.__registration_file) sheet = wb.active regist_list = skip_table_structure_change(self.__comit_list) self.printComitList(regist_list) for i in regist_list: sheet.append(i) wb.save(filename=self.__registration_file) print("excel write down!") def logClean(self): with open(SVN_LOG, "w") as svn_log: pass if __name__ == "__main__": date_str = time.strftime("%Y%m%d", time.localtime()) if argv[1]: date_str = argv[1] mantis = "" if len(argv) >2: mantis = argv[2] reg = ReleaseRegistrationForm(date_str, mantis, "cif") #reg.logRead() #reg.logRegister() reg.logClean()
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,070
klgentle/lc_python
refs/heads/master
/leet_code/labuladong/tree/p0101_Symmetric_Tree.py
""" 101. Symmetric Tree Easy Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree [1,2,2,3,4,4,3] is symmetric: 1 / \ 2 2 / \ / \ 3 4 4 3 But the following [1,2,2,null,3,null,3] is not: 1 / \ 2 2 \ \ 3 3 Follow up: Solve it both recursively and iteratively. """ # Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def isSymmetric(self, root: TreeNode) -> bool: if not root: return True treelist = [] def tree2list(root: TreeNode) -> list: # 中序遍历(左根右) if not root: treelist.append(-1) return tree2list(root.left) treelist.append(root.val) tree2list(root.right) return treelist treelist = tree2list(root) print(f"treelist:{treelist}") r = root l = root straight_left = [] straight_right = [] while r.right: straight_left.append(r.right.val) r = r.right while l.left: straight_right.append(l.left.val) l = l.left return treelist == treelist[::-1] and straight_left == straight_right
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,071
klgentle/lc_python
refs/heads/master
/scrapy_test/send_mail_no_attacth.py
#!/usr/bin/python3 import traceback import time import os import smtplib from email.mime.text import MIMEText from email.utils import formataddr from email.mime.multipart import MIMEMultipart # from pysnooper import snoop # from getpass import getpass from sys import argv # password = '' # 发件人邮箱密码 sender = "klgentle@sina.com" # 收件人邮箱 addressed_eamil2 = ["jian.dong2@pactera.com", "1063237864@qq.com"] # 收件人邮箱 # @snoop() def mail(): """ 作者:梦忆安凉 原文:https://blog.csdn.net/a54288447/article/details/81113934 """ # home_path = "/home/kl" try: # 创建一个带附件的实例 message = MIMEMultipart() message["From"] = formataddr(["jdong", sender]) # 括号里的对应发件人邮箱昵称、发件人邮箱账号 # send to multi people, 1.message to should join by comma, 2.sending to should be list message["To"] = formataddr( ["Dear", ",".join(addressed_eamil2)] ) # 括号里的对应收件人邮箱昵称、收件人邮箱账号 message["Subject"] = "入户审批已公示!" # 邮件的主题,也可以说是标题 # 邮件正文内容 message.attach( MIMEText( "入户审批已公示,请登陆网址查看\nhttp://gzrsj.hrssgz.gov.cn/vsgzpiapp01/GZPI/Gateway/PersonIntroducePublicity.aspx", "plain", "utf-8", ) ) server = smtplib.SMTP_SSL("smtp.sina.com", 465) # 发件人邮箱中的SMTP服务器,一般端口是25 server.starttls() # to get passwd #password = getpass(f"{sender}'s password: ") cmd = "awk 'FS=\"=\" {if ($0~/^sina_passwd/) print $2}' $HOME/.passwd.txt" password = "" with os.popen(cmd) as p: password = p.read().strip() #print(f"test [{password}]") server.login(sender, password) # 括号中对应的是发件人邮箱账号、邮箱密码 # multi people shoud be list server.sendmail( sender, addressed_eamil2, message.as_string() ) # 括号中对应的是发件人邮箱账号、收件人邮箱账号、发送邮件 server.quit() # 关闭连接 print("邮件发送成功") except Exception as e: traceback.print_exc() print("邮件发送失败") if __name__ == "__main__": mail()
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,072
klgentle/lc_python
refs/heads/master
/tests/test_logging.py
import logging logging.basicConfig(level=logging.DEBUG, format='%(levelname)s: %(message)s') logging.info("Start print log") logging.debug("Do something") logging.warning("Something maybe fail.") logging.info("Finish")
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,073
klgentle/lc_python
refs/heads/master
/leet_code/easy_case/rob_ans.py
# coding:utf8 import pysnooper class Solution(object): # debug here # @pysnooper.snoop('/home/kl/log/leet_code/1.log') @pysnooper.snoop() def rob(self, nums: list) -> int: """ :type nums: List[int] """ last = 0 now = 0 for i in nums: # 这是一个动态规划问题 last, now = now, max(last + i, now) return now if __name__ == "__main__": a = Solution() lst1 = [1, 2, 3, 1] lst2 = [2, 1, 1, 2] a.rob(lst1) # a.rob(lst2)
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,074
klgentle/lc_python
refs/heads/master
/leet_code/easy_case/containsDuplicate.py
class Solution: def containsDuplicate(self, nums): l_set = len(set(nums)) l_nums = len(nums) """ if l_nums > l_set: return True else: return False """ return True if l_nums > l_set else False
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,075
klgentle/lc_python
refs/heads/master
/scrapy_test/jksj_yhs.py
import requests url = 'https://movie.douban.com/top250?start=0&filter=' # 把 user-agent 伪装成浏览器 user_agent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36' # 构造请求头部的 user-agent header = {} header['user-agent'] = user_agent response = requests.get(url, headers=header) print(response) # 返回200 print(response.text) # 返回请求的网页内容
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,076
klgentle/lc_python
refs/heads/master
/picture/removebg_test.py
import os from removebg import RemoveBg rmbg = RemoveBg("psCaKrA5rUMXJ6A12H8Kirup", "error.log") # 引号内是你获取的API #rmbg.remove_background_from_img_file("/mnt/d/picture/微信图片_20190801200023.jpg") # 图片地址 rmbg.remove_background_from_img_file("test.jpg") # 图片地址 #path = "/mnt/d/picture/cqb/anan" #for pic in os.listdir(path): # path_name = os.path.join(path, pic) # rmbg.remove_background_from_img_file(path_name) # 图片地址
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,077
klgentle/lc_python
refs/heads/master
/database/delete_view_fm00.py
import os view_path = "/home/kl/svn/1300_编码/1301_ODSDB/RPTUSER/03Views" new_path = "/home/kl/yx_walk/new_views" #for folderName, subfolders, filenames in os.walk(path): for file_name in os.listdir(view_path): one_file = os.path.join(view_path,file_name) content = "" with open(one_file) as f: content = f.read().upper() # test #if content.find('V_CHB_H_BLACKLIST_CUSTOMER_ALL') == -1: # continue content = content.replace(';','').strip() # skip no FM00 views if content.find("'FM00'") == -1: continue # data deal select_ind = content.find('SELECT') head = content[:select_ind] # UNION ALL may be not stand selects = content[select_ind:].split('UNION ALL') if content.find("UNION ALL") == -1: selects = content[select_ind:].split('UNION') medium = "" if selects[0].find("'FH00'") > 0: medium = selects[0] else: medium = selects[1] # wirte file new_view = os.path.join(new_path,file_name) new_f = open(new_view,'w') new_f.write(head) new_f.write(''.join([medium,';\n'])) new_f.close
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,078
klgentle/lc_python
refs/heads/master
/leet_code/labuladong/tree/p0701_Insert_into_a_Binary_Search_Tree.py
""" 701. Insert into a Binary Search Tree Medium You are given the root node of a binary search tree (BST) and a value to insert into the tree. Return the root node of the BST after the insertion. It is guaranteed that the new value does not exist in the original BST. Notice that there may exist multiple valid ways for the insertion, as long as the tree remains a BST after insertion. You can return any of them. Example 1: Input: root = [4,2,7,1,3], val = 5 Output: [4,2,7,1,3,5] Explanation: Another accepted tree is: Example 2: Input: root = [40,20,60,10,30,50,70], val = 25 Output: [40,20,60,10,30,50,70,null,null,25] """ class Solution: def insertIntoBST(self, root: TreeNode, val: int) -> TreeNode: # if root: # print(f"root.val: {root.val}") if not root: return TreeNode(val) # All the values Node.val are unique. if val < root.val: root.left = self.insertIntoBST(root.left, val) elif val > root.val: root.right = self.insertIntoBST(root.right, val) return root
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,079
klgentle/lc_python
refs/heads/master
/leet_code/medium_case/p807_Max_InCrease_to_Keep_City_Skyline.py
class Solution: @staticmethod def changeGridToColumn(grid: List[List[int]]) -> List[List[int]]: colList = [] # colList初始化 for i in range(len(grid[0])): colList.append([]) for i, row in enumerate(grid): for j in range(len(row)): colList[j].append(row[j]) #print(colList) return colList def maxIncreaseKeepingSkyline(self, grid: List[List[int]]) -> int: """ 修改后的 g[ij] = min(行最大值 max(g[i][]), 列最大值max(g[][j])) """ rowMax = [] for row in grid: rowMax.append(max(row)) #print(rowMax) colMax = [] for col in self.changeGridToColumn(grid): colMax.append(max(col)) #print(colMax) sum_increas = 0 for i, row in enumerate(grid): for j, height in enumerate(row): sum_increas += min(rowMax[i], colMax[j]) - height return sum_increas
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,080
klgentle/lc_python
refs/heads/master
/vs_code/hello.py
print(""" #!/bin/bash for test in Nevada New Hampshire New Mexico New York North Carolina do echo "Now going to $test" done """)
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,081
klgentle/lc_python
refs/heads/master
/leet_code/labuladong/math/p0319_Bulb_Switcher.py
""" 319. Bulb Switcher Medium There are n bulbs that are initially off. You first turn on all the bulbs, then you turn off every second bulb. On the third round, you toggle every third bulb (turning on if it's off or turning off if it's on). For the ith round, you toggle every i bulb. For the nth round, you only toggle the last bulb. Return the number of bulbs that are on after n rounds. """ class Solution: def bulbSwitch(self, n: int) -> int: """ 假设现在总共有 16 盏灯,我们求 16 的平方根,等于 4,这就说明最后会有 4 盏灯亮着,它们分别是第 1*1=1 盏、第 2*2=4 盏、第 3*3=9 盏和第 4*4=16 盏。就算有的 n 平方根结果是小数,强转成 int 型,也相当于一个最大整数上界,比这个上界小的所有整数,平方后的索引都是最后亮着的灯的索引。 """ return int(math.sqrt(n))
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,082
klgentle/lc_python
refs/heads/master
/leet_code/labuladong/tree/p0897_Increasing_Order_Search_Tree.py
""" 897. Increasing Order Search Tree Easy Given the root of a binary search tree, rearrange the tree in in-order so that the leftmost node in the tree is now the root of the tree, and every node has no left child and only one right child. Example 1: Input: root = [5,3,6,2,4,null,8,1,null,null,null,7,9] Output: [1,null,2,null,3,null,4,null,5,null,6,null,7,null,8,null,9] Example 2: Input: root = [5,1,7] Output: [1,null,5,null,7] """ # Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def increasingBST(self, root: TreeNode) -> TreeNode: # get value in list # constract tree from list vl = [] def getValueList(root): if not root: return getValueList(root.left) vl.append(root.val) getValueList(root.right) return vl def constractTree(vl) -> TreeNode: if not vl: return root = TreeNode(vl.pop(0)) root.right = constractTree(vl) return root vl = getValueList(root) #print(f"vl:{vl}") return constractTree(vl)
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,083
klgentle/lc_python
refs/heads/master
/vs_code/create_batch_sql.py
import os import shutil def listDir(path: str): pass # todo check exists
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,084
klgentle/lc_python
refs/heads/master
/leet_code/top_interview_questions/Hard_Case/0041_First_Missing_Positive.py
from pysnooper import snoop class Solution: #@snoop() def firstMissingPositive(self, nums: list) -> int: if 1 not in nums: return 1 l = len(nums) max_num = max(nums) min_num = min(nums) if min_num < 0: min_num = 1 # if missing one find it for i in range(min_num+1, max_num+2): #print(f"test i:{i}") if i not in nums: return i if __name__ == "__main__": a = Solution() nums = [1,3,3] b = a.firstMissingPositive(nums) print(b)
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,085
klgentle/lc_python
refs/heads/master
/leet_code/labuladong/array/p0875_Koko_Eating_Bananas.py
""" 875. Koko Eating Bananas Medium Koko loves to eat bananas. There are N piles of bananas, the i-th pile has piles[i] bananas. The guards have gone and will come back in H hours. Koko can decide her bananas-per-hour eating speed of K. Each hour, she chooses some pile of bananas, and eats K bananas from that pile. If the pile has less than K bananas, she eats all of them instead, and won't eat any more bananas during this hour. Koko likes to eat slowly, but still wants to finish eating all the bananas before the guards come back. Return the minimum integer K such that she can eat all the bananas within H hours. Example 1: Input: piles = [3,6,7,11], H = 8 Output: 4 Example 2: Input: piles = [30,11,23,4,20], H = 5 Output: 30 Example 3: Input: piles = [30,11,23,4,20], H = 6 Output: 23 """ class Solution: def minEatingSpeed(self, piles: List[int], H: int) -> int: maxSpeed = max(piles) # 用二分法进行优化 left = 1 while left < maxSpeed: v_mid = int((left+maxSpeed)/2) if self.canFinish(piles, H, v_mid): maxSpeed = v_mid else: left = v_mid + 1 return left def canFinish(self, piles, H, v): time = 0 for pile in piles: time += math.ceil(pile / v) #print(f"time:{time}") return time <= H
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,086
klgentle/lc_python
refs/heads/master
/vs_code/cutPicture2.py
#coding=utf-8 from PIL import Image #需要pillow库 import os #import cv2 class SplitPicture(object): """ 剪切手机图片,主要是剪掉图片头部跟图片下方的答案 """ def __init__(self): self.path = "/mnt/f/for_wife" def splitPicture(self): #for filename in os.listdir(self.path): for folderName, subfolders, filenames in os.walk(self.path): for filename in filenames: if isinstance(filename,list): #print(f"filename:{filename} list ") continue if not filename.endswith('png'): continue #if filename != '2019-05-13 163927.png': # continue #print(f"filename:{filename}") file_whole_name = os.path.join(self.path,folderName,filename) img = Image.open(file_whole_name) w,h = img.size h = 850 print(f"w,h:{w},{h}") box1 = (0,120,w,h) image1 = img.crop(box1) percent = 2.2 image1 = image1.resize((int(w/percent), int((h-60)/percent))) image1.save(file_whole_name) if __name__ == "__main__": a = SplitPicture() a.splitPicture()
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,087
klgentle/lc_python
refs/heads/master
/leet_code/medium_case/0073_Set_Matrix_Zeroes.py
class Solution: def setZeroes(self, matrix: List[List[int]]) -> None: """ step 1 find all zero position, step 2 set its entire row and column to 0 """ # TODO A simple improvement uses O(m + n) space, but still not the best solution. Could you devise a constant space solution? #zero_row = [] zero_col = [] for row, lst in enumerate(matrix): if 0 not in lst: continue for col, v in enumerate(lst): if v == 0: #zero_row.append(row) zero_col.append(col) matrix[row] = [0] * len(lst) for ind, lst in enumerate(matrix): # set col to 0 for col in zero_col: lst[col] = 0
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,088
klgentle/lc_python
refs/heads/master
/leet_code/labuladong/array/p0556_Next_Greater_Element_III2.py
""" 556. Next Greater Element III Medium Given a positive integer n, find the smallest integer which has exactly the same digits existing in the integer n and is greater in value than n. If no such positive integer exists, return -1. Note that the returned integer should fit in 32-bit integer, if there is a valid answer but it does not fit in 32-bit integer, return -1. Example 1: Input: n = 12 Output: 21 Example 2: Input: n = 21 Output: -1 """ class Solution: def nextGreaterElement(self, n): """ example: 234157641 index: 012345678 i=5, v=7 j=5 5 7641 6 7541 """ digits = list(str(n)) i = len(digits) - 1 # find the position to modify i-1 (Turning point) while i-1 >= 0 and digits[i] <= digits[i-1]: i -= 1 if i == 0: return -1 j = i # find the smallest value large than digits[i-1] while j+1 < len(digits) and digits[j+1] > digits[i-1]: j += 1 # swap smallest value with turning point digits[i-1], digits[j] = digits[j], digits[i-1] # reverse the value, to make in order digits[i:] = digits[i:][::-1] ret = int(''.join(digits)) return ret if ret < 1<<31 else -1
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,089
klgentle/lc_python
refs/heads/master
/leet_code/medium_case/0011_Container_With_Most_Water.py
# import pysnooper class Solution: """ 双指针 Double pointer """ #@pysnooper.snoop() def maxArea(self, height: "list[int]") -> int: res = 0 l = 0 r = len(height) - 1 while l < r: res = max(res, (r - l) * min(height[l], height[r])) if height[l] < height[r]: # KEEP THE MAX HEIGHT l += 1 else: r -= 1 print(res) return res
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,090
klgentle/lc_python
refs/heads/master
/scrapy_test/nsfwpicx/html_download_picture.py
import requests import os import re import random import sys import urllib.request import time import pprint import subprocess from bs4 import BeautifulSoup from urllib.parse import quote_plus, unquote_plus class GetNsfwPicture(object): def __init__(self): self.kv = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36" } self.root = "/mnt/d/code_test/game_test/nsf" @staticmethod def get_read_number(input_str) -> int: # 删除非数字(-)的字符串 return int(re.sub(r"\D", "", input_str)) def get_picure_addrs(self, url): """ 获取单个页面中的全部图片地址 """ pageNumber = url.replace(".html", "").split("/")[-1] print(f"test pageNumber: {pageNumber}") picList = [] title = "_" r = requests.get(url, headers=self.kv) r.raise_for_status() r.encoding = r.apparent_encoding soup = BeautifulSoup(r.text, "html.parser") title = soup.title.text.replace(" - Nsfwpicx", "") # 精确定位地址集 imgs = soup.select("img[data-src]") try: tempList = [] for img in imgs: # p = re.compile("http.*#vwid") imgAddrs = str(img).split('data-src="')[1] tempList.append(imgAddrs.split("#vwid")[0]) except Exception as e: print(e.__doc__) for addr in tempList: picList.append(addr) if len(picList) > 0: print("保存图片链接成功", pageNumber) else: print("保存图片链接失败", pageNumber) pprint.pprint(r.text) uniqueList = sorted(list(set(picList))) for i, v in enumerate(uniqueList): print(i, v) #pprint.pprint(uniqueList) print("Picture number is:", len(uniqueList)) return (title, pageNumber, uniqueList) def GetFolderRoot(self, title, pageNumber): # root 保存目录 root2 = os.path.join(self.root, str(pageNumber) + "_" + title.replace(" ", "_")) return root2 def download_picture(self, title_picList): title, pageNumber, picList = title_picList root2 = self.GetFolderRoot(title, pageNumber) if not os.path.exists(root2): os.mkdir(root2) print("保存目录为:", root2) for i, addr in enumerate(picList): filename = self.createFilename(pageNumber, i, addr) file_path = os.path.join(root2, filename) # 多进程下载图片 self.callCurlThroughSubprocess(file_path, addr) time.sleep(10) self.checkAndRedownload(root2, pageNumber, picList) @staticmethod def createFilename(pageNumber, index, addr): # 解决 windows 不区分大小写的问题 return "".join([pageNumber, "_", str(index), "_", addr.split("/")[-1]]) @staticmethod def callCurlThroughSubprocess(file_path: str, addr: str): # 感觉curl,比wget快一点 process = subprocess.Popen( ["curl", "-C", "-", "-S", "-s", "-o", file_path, addr] ) return process @staticmethod def callWgetThroughSubprocess(file_path: str, addr: str): process = subprocess.Popen( ["wget", "-O", file_path, "-q", "-o", "/tmp/wget-log", addr] ) return process def checkAndRedownload(self, root2, pageNumber, picList): for i, addr in enumerate(picList): filename = self.createFilename(pageNumber, i, addr) file_path = os.path.join(root2, filename) # 如果下载不成功,需要换方法 if not os.path.exists(file_path): print("file to check:", filename) #self.callWgetThroughSubprocess(file_path, addr) self.SaveOnePictureFrom(addr, file_path) def SaveOnePictureFrom(self, url:str, file_path:str): response = requests.get(url,headers=self.kv) with open(file_path,"wb") as f: f.write(response.content) def download_one_html(self, url): pic_list = self.get_picure_addrs(url) self.download_picture(pic_list) def download_all_pictures(self, from_number, end_number): for i in range(from_number, end_number - 1, -1): print("Deal with page index:", i) self.download_one_html(i) # 休息,防止被封, 等并行的下载完成 sleep_second = 20 print("---------Sleep {} second start--------- ...".format(sleep_second)) time.sleep(sleep_second) print("---------Sleep {} second end---------\n".format(sleep_second)) def download_list_pictures(self, index_list): for i in index_list: print("Deal with page index:", i) self.download_one_html(i) # 休息,防止被封, 等并行的下载完成 sleep_second = 20 print("---------Sleep {} second start--------- ...".format(sleep_second)) time.sleep(sleep_second) print("---------Sleep {} second end---------\n".format(sleep_second)) if __name__ == "__main__": if len(sys.argv) < 2: print("Please input Url!") g = GetNsfwPicture() # url = "http://nsfwpicx.com/2020/05/01/1435.html" g.download_one_html(sys.argv[1])
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,091
klgentle/lc_python
refs/heads/master
/leet_code/easy_case/convertToTitle_ans.py
class Solution: def convertToTitle(self, n: int) -> str: ans = "" while n > 0: n -= 1 ans += chr(n % 26 + ord("A")) n //= 26 print(ans[::-1]) return ans[::-1] if __name__ == "__main__": a = Solution() a.convertToTitle(52)
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,092
klgentle/lc_python
refs/heads/master
/leet_code/labuladong/heap/p0295_Find_Median_from_Data_Stream.py
""" 295. Find Median from Data Stream Hard Median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two middle value. For example, [2,3,4], the median is 3 [2,3], the median is (2 + 3) / 2 = 2.5 Design a data structure that supports the following two operations: void addNum(int num) - Add a integer number from the data stream to the data structure. double findMedian() - Return the median of all elements so far. Example: addNum(1) addNum(2) findMedian() -> 1.5 addNum(3) findMedian() -> 2 """ from heapq import * class MedianFinder: def __init__(self): """ initialize your data structure here. """ self.heaps = [], [] def addNum(self, num: int) -> None: small, large = self.heaps heappush(small, -heappushpop(large, num)) if len(small) > len(large): heappush(large, -heappop(small)) def findMedian(self) -> float: small, large = self.heaps if len(large) > len(small): return float(large[0]) return (large[0] - small[0]) / 2.0 # Your MedianFinder object will be instantiated and called as such: # obj = MedianFinder() # obj.addNum(num) # param_2 = obj.findMedian()
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,093
klgentle/lc_python
refs/heads/master
/scrapy_test/check_result_send_email.py
#!/usr/bin/python3 from crawler01 import check_result from send_mail_no_attacth import mail if __name__ == "__main__": if check_result(): mail() else: print("No result, please wait!")
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,094
klgentle/lc_python
refs/heads/master
/Intermediate_Python/set_find_duplicate.py
some_list = ['a', 'b', 'c', 'b'] duplicates = set([x for x in some_list if some_list.count(x) > 1]) print(duplicates) # {'b'}
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,095
klgentle/lc_python
refs/heads/master
/database/ProcedureLogModify.py
""" 存储过程日志修改 1. 添加主日志 2. job_step 写死的,改为变量 3. 添加 bat_report_log 登记 4. 日志编号在最后统一重写 """ import os import re import sys import time import logging # 绝对路径的import sys.path.append(os.path.dirname(os.path.abspath(__file__)) + "/../") from database.Procedure import Procedure logging.basicConfig(level=logging.DEBUG, format="%(levelname)s: %(message)s") class ProcedureLogModify(object): """ agr:proc_name """ def __init__(self, proc_name: str): self.__procedure = Procedure(proc_name) self.is_log_modified = False @staticmethod def declare_variable(variable_name: str, variable_type: str) -> str: """根据名称与类型,申明变量 """ return " {0}\t\t{1};\n".format(variable_name, variable_type) def declare_job_step(self, proc_cont: str) -> str: "add declare before BEGIN" job_step_variable = self.declare_variable("V_JOB_STEP", "NUMBER") # return proc_cont.replace("BEGIN", job_step_variable + "BEGIN") return re.sub( r"BEGIN", job_step_variable + "BEGIN", proc_cont, flags=re.IGNORECASE ) @staticmethod def set_job_step_value_and_modify_insert(proc_cont): """ . 设置v_job_step的值 . 将写死的job_step,改为变量 """ error_bat_log_pattern = r"V_DEAL_DATE,\n?\s*'?(-?\d+)'?,\n?\s*V_JOB_NAME" match = re.search(error_bat_log_pattern, proc_cont, flags=re.IGNORECASE) try: job_step = match.group(1) except: logging.error("proc_cont: %s" % proc_cont) return proc_cont if match and job_step == "-1": proc_cont = re.sub( r"V_DEAL_DATE\s*,\n?\s*'?-1'?", "V_DEAL_DATE,V_JOB_STEP", proc_cont, flags=re.IGNORECASE, ) else: # add line of v_job_step v_job_step_line = "V_JOB_STEP:={};\n".format(job_step) batch_insert_pattern = r"INSERT\s+INTO\s+BAT_REPORT_LOG" proc_cont = re.sub( batch_insert_pattern, v_job_step_line + r"INSERT INTO BAT_REPORT_LOG", proc_cont, flags=re.IGNORECASE, ) # replace hard code value with v_job_step bat_log_value = r"V_DEAL_DATE,\n?\s*'?{}'?".format(job_step) proc_cont = re.sub( bat_log_value, "V_DEAL_DATE,V_JOB_STEP", proc_cont, flags=re.IGNORECASE ) return proc_cont @staticmethod def spend_time_value_adjust(proc_cont: str) -> str: """查找是否spend time已经减一了,如果有就修正""" pattern = r"V_ST_TIME\s*-\s*1" if re.search(pattern, proc_cont, flags=re.IGNORECASE): proc_cont = re.sub(pattern, "V_ST_TIME", proc_cont, flags=re.IGNORECASE) return proc_cont def modify_report_log(self, proc_cont: str) -> str: """修改 bat_report_log 登记 """ if self.is_log_exists_and_need_modify(proc_cont): logging.info("修改 bat_report_log 登记") self.is_log_modified = True proc_cont = self.set_job_step_value_and_modify_insert(proc_cont) proc_cont = self.spend_time_value_adjust(proc_cont) return proc_cont @staticmethod def is_log_exists_and_need_modify(proc_cont_between_log) -> bool: proc_cont_list = proc_cont_between_log.split("BAT_SERIAL_NO.NEXTVAL,") # 如果存在VALUES(BAT_SERIAL_NO.NEXTVAL,则list长度会大于一 if len(proc_cont_list) > 1 and not proc_cont_list[1].upper().replace( "\n", "" ).replace(" ", "").strip().startswith("V_DEAL_DATE,V_JOB_STEP,V_JOB_NAME"): return True return False def modify_procedure_header(self, proc_cont: str) -> str: """修改存储过程头部部分 """ proc_cont = self.__procedure.add_header_log(proc_cont) # not find then add if not re.search("V_JOB_STEP", proc_cont, flags=re.IGNORECASE): proc_cont = self.declare_job_step(proc_cont) return proc_cont @staticmethod def bat_log_template(): bat_report_log = """COMMIT; V_END_TIME:=CURRENT_TIMESTAMP ; --处理结束时间 V_SPEND_TIME:=ROUND(TO_NUMBER(TO_DATE(TO_CHAR(V_END_TIME,'YYYY-MM-DD HH24:MI:SS') ,'YYYY-MM-DD HH24:MI:SS') -TO_DATE(TO_CHAR(V_ST_TIME,'YYYY-MM-DD HH24:MI:SS') ,'YYYY-MM-DD HH24:MI:SS')) * 24 * 60 * 60);----执行时间 V_JOB_STEP:=1; INSERT INTO BAT_REPORT_LOG(DEAL_SERIAL_NO,DEAL_DATE,JOB_STEP,JOB_NAME,SPEND_TIME,REMARK,JOB_ID,JOB_STATE) VALUES(BAT_SERIAL_NO.NEXTVAL, V_DEAL_DATE,V_JOB_STEP,V_JOB_NAME,V_SPEND_TIME,V_ERR_MSG,V_JOB_ID,V_JOB_STEP||'结束...'); COMMIT;\n """ return bat_report_log def add_report_log(self, content: str) -> str: target_str = "INSERT INTO" content_list = content.split(target_str) # content_list =['开始处理...', 'RPT_CIF032_D_1...', 'RPT_CIF032_D_2...', 'BAT_REPORT_LOG'] # 从第二个至倒数第二都要加日志 keep_list = content_list[0:1] to_add_log_list = content_list[1:] # the last one no need log_content_list = [" "] * len(to_add_log_list) logging.info("add report log") for i in range(0, len(to_add_log_list) - 2): sql = "".join([to_add_log_list[i], self.bat_log_template()]) log_content_list[i] = sql # last one is bat log, no need to modify log_content_list[-2:] = to_add_log_list[-2:] keep_list.extend(log_content_list) return target_str.join(keep_list) def modify_log_register(self, proc_cont: str): """修改存储过程两个report_log之间的部分 """ proc_cont = self.modify_report_log(proc_cont) # TODO test if proc_cont.count("INSERT INTO") > 2: self.is_log_modified = True proc_cont = self.add_report_log(proc_cont) return proc_cont def reset_job_step_value(self): """modify all job_step value after log add and modify """ procedure = self.__procedure proc_cont = procedure.read_proc_cont() pattern = r"V_JOB_STEP\s*:=\s*\d+;" job_step_value_list = re.findall(pattern, proc_cont) job_step_num = len(job_step_value_list) standard_job_value_list = [ "V_JOB_STEP:={};".format(i) for i in range(job_step_num) ] if job_step_value_list != standard_job_value_list: logging.info("job_step value reset") proc_cont_list = re.split(pattern, proc_cont) # from the second to the end, add split pattern for i in range(1, len(proc_cont_list)): proc_cont_list[i] = "\n".join( [standard_job_value_list[i - 1], proc_cont_list[i]] ) # write procedure file procedure.write_procedure("".join(proc_cont_list)) def main(self): """主入口 """ # read proc_cont procedure = self.__procedure proc_cont = procedure.read_proc_cont() proc_cont_head, proc_cont_main = re.split( r"IF\s+I_RUN_DATE\s+IS\s+NULL", proc_cont, flags=re.IGNORECASE ) main_split_str = r"V_JOB_ID" proc_cont_main_list = re.split( main_split_str, proc_cont_main, flags=re.IGNORECASE ) for ind in range(0, len(proc_cont_main_list)): proc_cont_main_list[ind] = self.modify_log_register( proc_cont_main_list[ind] ) if self.is_log_modified: proc_cont_head = self.modify_procedure_header(proc_cont_head) # write procedure file procedure.write_procedure( proc_cont_head + "IF I_RUN_DATE IS NULL" + main_split_str.join(proc_cont_main_list) ) self.reset_job_step_value() logging.info("日志修改完成!") if __name__ == "__main__": obj = ProcedureLogModify("p_rpt_cif033") obj.main()
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,096
klgentle/lc_python
refs/heads/master
/leet_code/top_interview_questions/Medium_Case/P0227_Basic_Calculator_II.py
from pysnooper import snoop class Solution: #@snoop() def calculate(self, s: str) -> int: s += '+0' stack, num, preOp = [], 0, "+" print(f"s:{s}") for i in range(len(s)): print(f"num:{num}") print(f"preOp:{preOp}") if s[i].isdigit(): num = num * 10 + int(s[i]) elif not s[i].isspace(): if preOp == "-": stack.append(-num) elif preOp == "+": stack.append(num) elif preOp == "*": stack.append(stack.pop() * num) else: stack.append(int(stack.pop() / num)) preOp, num = s[i], 0 return sum(stack) if __name__ == "__main__": a = Solution() s = '1+2*3/4+6/6*8/9' a.calculate(s)
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,097
klgentle/lc_python
refs/heads/master
/tests/test_string.py
from __future__ import absolute_import, division, print_function, unicode_literals from os.path import dirname import os import sys # 项目根目录 BASE_DIR = dirname(dirname(os.path.abspath(__file__))) # 添加系统环境变量 sys.path.append(BASE_DIR) print(BASE_DIR) sys.path.append('../') # 导入模块 from string_code.StringFunctions import StringFunctions import unittest class TestString(unittest.TestCase): def test_find_the_second_position(self): a = StringFunctions("AND a =b AND c=d") except_out = 9 self.assertEqual(except_out, a.find_the_second_position("AND")) if __name__ == "__main__": unittest.main()
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,098
klgentle/lc_python
refs/heads/master
/leet_code/labuladong/tree/P0124_Binary_Tree_Maximum_Path_Sum.py
""" 124. Binary Tree Maximum Path Sum Hard Given a non-empty binary tree, find the maximum path sum. For this problem, a path is defined as any node sequence from some starting node to any node in the tree along the parent-child connections. The path must contain at least one node and does not need to go through the root. """ # Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def __init__(self): self.ans = -99999999999999999 def onePathSum(self, root): # root.left == None 无效 if root is None: return 0 left = max(0, self.onePathSum(root.left)) right = max(0, self.onePathSum(root.right)) self.ans = max(self.ans, left + right + root.val) return max(left, right) + root.val # 为什么是max(left, right) 因为是求max,不是求和 def maxPathSum(self, root: TreeNode) -> int: self.onePathSum(root) return self.ans
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,099
klgentle/lc_python
refs/heads/master
/algorithm_code/recursive_sum.py
def recusive_sum(arr): if len(arr) == 1: return arr[-1] else: return arr.pop() + recusive_sum(arr) if __name__ == "__main__": # li = [1, 2, 3, 4] li = [2, 4, 6] print(recusive_sum(li))
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,100
klgentle/lc_python
refs/heads/master
/code_in_books/lp3thw/ex16_reading_and_writing_file.py
# seek(0): Moves the read/write location to the beginning of the file
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,101
klgentle/lc_python
refs/heads/master
/leet_code/labuladong/backtracking/P0111_Minimum_Depth_of_Binary_Tree.py
""" 111. Minimum Depth of Binary Tree Easy Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. Note: A leaf is a node with no children. Example 1: Input: root = [3,9,20,null,null,15,7] Output: 2 Example 2: Input: root = [2,null,3,null,4,null,5,null,6] Output: 5 """ class Solution: def minDepth(self, root: TreeNode) -> int: if (not root): return 0; q = list() q.append(root); depth = 1 while (q): sz = len(q); for i in range(sz): cur = q.pop(0); if (not cur.left and not cur.right): return depth if (cur.left): q.append(cur.left); if (cur.right): q.append(cur.right); depth += 1 return depth
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,102
klgentle/lc_python
refs/heads/master
/database/__init__.py
import os import sys # 项目根目录 BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # 添加系统环境变量 sys.path.append(BASE_DIR)
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,103
klgentle/lc_python
refs/heads/master
/stock_pandas/get_convertible_bond.py
#convertible_bond import pandas as pd import requests def get_convertible_bond(): resp = requests.get( "http://data.10jqka.com.cn/ipo/bond/" ) print(resp.text) #data = resp.json() #print(data) if __name__ == "__main__": get_convertible_bond()
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}
58,104
klgentle/lc_python
refs/heads/master
/frequency_model/deque.py
from collections import deque q = deque(['a', 'b', 'c']) q.append('x') q.appendleft('y') print(q) q.pop() print(q) #deque(['y', 'a', 'b', 'c', 'x'])
{"/tests/testCreateWeekReport.py": ["/automatic_office/CreateWeekReport.py"], "/tests/re_test.py": ["/database/Procedure.py"], "/tests/test_procedure.py": ["/database/Procedure.py"], "/tests/test_proc_log_modify.py": ["/database/ProcedureLogModify.py"], "/database/batch_replace.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"], "/database/Procedure.py": ["/string_code/StringFunctions.py", "/decorator_test/logging_decorator.py"], "/tests/testDealInterval.py": ["/automatic_office/DealInterval.py"], "/automatic_office/CreateWeekReport.py": ["/automatic_office/CheckInForm.py", "/automatic_office/DealInterval.py"], "/database/AutoViewReplace.py": ["/database/Procedure.py", "/database/FindViewOriginalTable.py"], "/automatic_office/CheckInForm.py": ["/automatic_office/Holiday.py"], "/database/ProcedureLogModify.py": ["/database/Procedure.py"], "/tests/test_string.py": ["/string_code/StringFunctions.py"], "/database/replace_view_and_log.py": ["/database/ProcedureLogModify.py", "/database/AutoViewReplace.py"]}