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

Add a shortcut to take automatically use the proper MSS class #5

Closed
sametmax opened this issue Apr 14, 2015 · 1 comment
Closed

Add a shortcut to take automatically use the proper MSS class #5

sametmax opened this issue Apr 14, 2015 · 1 comment
Assignees

Comments

@sametmax
Copy link

Something like:

from platform import system

def mss(*args, **kwargs):
    """ Factory returning a proper MSS class instance 

        It detects the plateform we are running on 
        and choose the most adapted mss_class to take
        screenshots.

        It then proxies its arguments to the class for 
        instanciation.
    """

    mss_class = {
        'Darwin': MSSMac,
        'Linux': MSSLinux,
        'Windows': MSSWindows
    }[system()]

    return mss_class(*args, **kwargs)

So so mss can be used as simply as:

from mss import mss

screenshotter = mss()
for f in screenshotter.save():
    print(f)

This avoid to write the same boiler plate over and over fow the most common use case.

@BoboTiG
Copy link
Owner

BoboTiG commented Apr 15, 2015

Yes, it is a good idea. Thank you 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants