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

Have only one point for system fallback behaviour. #70

Open
elbenfreund opened this issue Apr 15, 2016 · 0 comments
Open

Have only one point for system fallback behaviour. #70

elbenfreund opened this issue Apr 15, 2016 · 0 comments

Comments

@elbenfreund
Copy link

What we do right now is as part of assigning system we fall back to assigning linux2 if we do not recognize the system.
Most of our functions however, apply the same fallback strategy anew if they encounter none of the recognized strings, but now they dont check againsts sys.platform but our own system global.
To me it seems sensible to have only one point where a system (propably better named strategy) is determined and have all functions just act accordingly.
If a function ends up with going though all supported system string values without a hit, it should throw an error as it means that for whatever reason system has been assigned a value that we do not support.
A line of code is propably worth more then words:

elif system == 'darwin':
        path = os.path.expanduser('/Library/Application Support')
        if appname:
            path = os.path.join(path, appname)
else:
        # XDG default for $XDG_DATA_DIRS
        # only first, if multipath is False](url)

should be:

elif system == 'darwin':
        path = os.path.expanduser('/Library/Application Support')
        if appname:
            path = os.path.join(path, appname)
elif system== 'linux2':
        # XDG default for $XDG_DATA_DIRS
        # only first, if multipath is False](url)
else:
    raise ValueError("Unrecognized system string.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant