Skip to content

Commit

Permalink
Prevent potential filename error.
Browse files Browse the repository at this point in the history
  • Loading branch information
xkww3n committed Dec 1, 2023
1 parent 4119016 commit 1599bee
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions Utils/ruleset.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,19 +142,20 @@ def custom_convert(src: Path) -> RuleSet:


def dump(src: RuleSet, target: str, dst: Path, filename: str) -> None:
try:
if target == "yaml":
match target:
case "yaml":
filename = filename + ".yaml"
elif target == "geosite":
case "geosite":
filename = filename
elif target == "sing-ruleset":
case "sing-ruleset":
filename = filename + ".json"
else:
case _:
filename = filename + ".txt"
try:
dist = open(dst/filename, mode="w", encoding="utf-8")
except FileNotFoundError:
dst.mkdir(parents=True)
dist = open(dst/filename, mode="w")
dist = open(dst/filename, mode="w", encoding="utf-8")
match target:
case "text":
for rule in src:
Expand Down

0 comments on commit 1599bee

Please sign in to comment.