Skip to content

Commit

Permalink
fix for_file helper without lnk_name
Browse files Browse the repository at this point in the history
  • Loading branch information
strayge committed Jun 24, 2024
1 parent 891629b commit e2d3d1d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
8 changes: 1 addition & 7 deletions pylnk3/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@ def parse(lnk: str) -> Lnk:
return Lnk.from_file(lnk)


def create(f: Optional[str] = None) -> Lnk:
if f is None:
return Lnk.from_file(f)
return Lnk()


def for_file(
target_file: str,
lnk_name: Optional[str] = None,
Expand All @@ -58,7 +52,7 @@ def for_file(
window_mode: Optional[str] = None,
is_file: Optional[bool] = None,
) -> Lnk:
lnk = create(lnk_name)
lnk = Lnk()
lnk.link_flags.IsUnicode = True
lnk.link_info = None
if target_file.startswith('\\\\'):
Expand Down
10 changes: 10 additions & 0 deletions tests/test_helpers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from pylnk3 import Lnk, for_file


def test_helpers_for_file(temp_filename: str) -> None:
path = 'C:\\folder\\file.txt'
lnk = for_file(path)
assert lnk.path == path
lnk.save(temp_filename)
lnk2 = Lnk.from_file(temp_filename)
assert lnk2.path == path

0 comments on commit e2d3d1d

Please sign in to comment.