Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable glob #1581

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions mackup/applications/traktor.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[application]
name = Traktor

[options]
enable_glob = true

[configuration_files]
Documents/Native Instruments/Traktor *.*.*/Traktor Settings.tsi
13 changes: 11 additions & 2 deletions mackup/appsdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
The Applications Database provides an easy to use interface to load application
data from the Mackup Database (files).
"""
import glob
import os

try:
Expand Down Expand Up @@ -52,7 +53,7 @@ def __init__(self):
raise ValueError(
"Unsupported absolute path: {}".format(path)
)
self.apps[app_name]["configuration_files"].add(path)
self._add_path(app_name, path, config)

# Add the XDG configuration files to sync
home = os.path.expanduser("~/")
Expand All @@ -72,7 +73,7 @@ def __init__(self):
)
path = os.path.join(xdg_config_home, path)
path = path.replace(home, "")
(self.apps[app_name]["configuration_files"].add(path))
self._add_path(app_name, path, config)

@staticmethod
def get_config_files():
Expand Down Expand Up @@ -168,3 +169,11 @@ def get_pretty_app_names(self):
pretty_app_names.add(self.get_name(app_name))

return pretty_app_names

def _add_path(self, app_name, path, config):
if config.getboolean("options", "enable_glob", fallback=False):
expanded_paths = glob.glob(path)
else:
expanded_paths = [path]
for expanded_path in expanded_paths:
self.apps[app_name]["configuration_files"].add(expanded_path)