Skip to content

Commit

Permalink
feat: support for empty file names mcbeet#419
Browse files Browse the repository at this point in the history
  • Loading branch information
edayot committed Apr 4, 2024
1 parent 728859b commit 008e8c8
Show file tree
Hide file tree
Showing 17 changed files with 28 additions and 3 deletions.
2 changes: 0 additions & 2 deletions beet/library/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,8 +679,6 @@ class NamespaceProxy(

def split_key(self, key: str) -> Tuple[str, str]:
namespace, _, file_path = key.partition(":")
if not file_path:
raise KeyError(key)
return namespace, file_path

def join_key(self, key1: str, key2: str) -> str:
Expand Down
9 changes: 8 additions & 1 deletion beet/library/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,17 @@ def list_origin_folders(prefix: str, origin: FileOrigin) -> Dict[str, List[PureP

return folders

def modified_suffixes(path: PurePath) -> List[str]:
name = path.name
if name.endswith('.'):
return []
name = name.lstrip('.')
return ['.' + suffix for suffix in name.split('.')]


def list_extensions(path: PurePath) -> List[str]:
extensions: List[str] = list(
accumulate(reversed(path.suffixes), lambda a, b: b + a) # type: ignore
accumulate(reversed(modified_suffixes(path)), lambda a, b: b + a) # type: ignore
)
extensions.reverse()
extensions.append("")
Expand Down
10 changes: 10 additions & 0 deletions examples/code_void/add_header.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@


from beet import Context, Function



def beet_default(ctx: Context):
for f in ctx.data.functions.keys():
ctx.data.functions[f]=Function(f"say {f}")

10 changes: 10 additions & 0 deletions examples/code_void/beet.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
data_pack:
load: [.]
resource_pack:
load: [.]

output: build


pipeline:
- add_header
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.

0 comments on commit 008e8c8

Please sign in to comment.