Skip to content

Instantly share code, notes, and snippets.

View Hosuke's full-sized avatar
🐢
I code slowly

Huang Geyang Hosuke

🐢
I code slowly
View GitHub Profile
import os
import re
# Get the current directory
dir_path = os.getcwd()
# Traverse all files and subdirectories in the current directory
for root, dirs, files in os.walk(dir_path):
for file_name in files:
import os
import re
# Get the current directory
dir_path = os.getcwd()
# Traverse all files and subdirectories in the current directory
for root, dirs, files in os.walk(dir_path):
for file_name in files:
@Hosuke
Hosuke / legacy_spells_mover.py
Created July 6, 2023 09:19
legacy_spells_mover
import os
import re
import shutil
# Get current dir
dir_path = os.getcwd()
for root,dirs,files in os.walk(dir_path):
for file in files:
@Hosuke
Hosuke / trino_spells_mover.py
Last active July 11, 2023 05:58
trino_spells_mover
import os
import re
import shutil
def replace_with_alias_macros(model_contents):
"""
Replace alias = 'some_alias' with alias('some_alias', legacy_model=True)
"""
pattern = r"alias\s*=\s*'([^']*)'"
# replace alias with legacy alias
import os
import re
import shutil
# Get current dir
dir_path = os.getcwd()
for root, dirs, files in os.walk(dir_path):
for file in files:
import json
def get_model_dependencies(manifest_file, model_name):
with open(manifest_file, 'r') as f:
manifest = json.load(f)
def get_dependencies(full_model_name, indent=0):
if full_model_name.startswith('model.'):
model = manifest['nodes'].get(full_model_name)
if model is None:
import json
def get_model_dependencies(manifest_file, model_name):
with open(manifest_file, 'r') as f:
manifest = json.load(f)
# Build the adjacency list
adj_list = {}
for full_model_name, model in manifest['nodes'].items():
if not full_model_name.startswith('model.'):
import os
import re
# 获取当前工作目录
directory = os.getcwd()
# 遍历目录及其所有子目录下的所有文件
for dirpath, dirnames, filenames in os.walk(directory):
for filename in filenames:
# 只处理.sql文件
import os
import re
# 获取当前工作目录
directory = os.getcwd()
# 遍历目录及其所有子目录下的所有文件
for dirpath, dirnames, filenames in os.walk(directory):
for filename in filenames:
# 只处理.sql文件
import os
import re
# 获取当前工作目录
directory = os.getcwd()
# 定义日期的正则表达式
date_pattern = r"'((19|20)\d\d[-](0[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01]))'"
# 遍历目录及其所有子目录下的所有文件