Skip to content

Commit

Permalink
change set_config to init in regexes.py (jaybaird#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
FelipeAdachi authored May 16, 2023
1 parent 43ff7f9 commit 9ff8696
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
9 changes: 5 additions & 4 deletions langkit/regexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ def has_patterns(text: str) -> Optional[str]:
return group["name"]
return patterns_info


def set_config(config: LangKitConfig):
pattern_loader.set_config(config)
pattern_loader.update_patterns()
def init(pattern_file_path: Optional[str]=None):
if pattern_file_path:
lang_config.pattern_file_path = pattern_file_path
pattern_loader.set_config(lang_config)
pattern_loader.update_patterns()
4 changes: 1 addition & 3 deletions langkit/tests/test_patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ def test_ptt(ptt_df, user_defined_json):
json_path = os.path.join(temp_dir, json_filename)
with open(json_path, "w") as file:
file.write(user_json)
regexes.set_config(
LangKitConfig(pattern_file_path=os.path.join(temp_dir, json_filename))
)
regexes.init(pattern_file_path=os.path.join(temp_dir, json_filename))

schema = DeclarativeSchema(generate_udf_schema())
result = why.log(ptt_df, schema=schema)
Expand Down

0 comments on commit 9ff8696

Please sign in to comment.