Skip to content

Commit

Permalink
Replace spaces with dots in SourceFile.name
Browse files Browse the repository at this point in the history
  • Loading branch information
s-t-e-v-e-n-k committed Aug 25, 2024
1 parent 53ff873 commit d073067
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 3 additions & 2 deletions sinking/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ class SourceFile:
@property
def name(self) -> str:
o = Options()
name = self.path.name
if o.rename and self.needs_rename:
return f"{self.path.parts[-2]}{self.path.suffix}"
return self.path.name
name = f"{self.path.parts[-2]}{self.path.suffix}"
return name.replace(" ", ".")

@property
def pattern(self) -> str:
Expand Down
6 changes: 6 additions & 0 deletions tests/test_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ def test_name_with_rename_false(self):
s = SourceFile(pathlib.Path("/foo/bar/baz/bar"))
self.assertEqual(s.name, "bar")

def test_name_with_spaces(self):
p = pathlib.Path("/foo/bar/FooBarBaz.S03E05/FooBarBaz S03E05")
s = SourceFile(p)
self.assertFalse(s.needs_rename)
self.assertEqual(s.name, "FooBarBaz.S03E05")

def test_needs_rename(self):
s = SourceFile(pathlib.Path("/foo/bar/baz/foo"))
self.assertEqual(s.name, "baz")
Expand Down

0 comments on commit d073067

Please sign in to comment.