Skip to content

Commit

Permalink
Fade to black
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Jul 20, 2019
1 parent 5430110 commit 8247643
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 42 deletions.
6 changes: 3 additions & 3 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
platform_names = 'Linux', 'Darwin', 'Windows'

collect_ignore = [
'jaraco/clipboard/{name}.py'.format(**locals())
for name in platform_names
if platform.system() != name
'jaraco/clipboard/{name}.py'.format(**locals())
for name in platform_names
if platform.system() != name
]
12 changes: 3 additions & 9 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

extensions = [
'sphinx.ext.autodoc',
'jaraco.packaging.sphinx',
'rst.linker',
]
extensions = ['sphinx.ext.autodoc', 'jaraco.packaging.sphinx', 'rst.linker']

master_doc = "index"

link_files = {
'../CHANGES.rst': dict(
using=dict(
GH='https://github.com',
),
using=dict(GH='https://github.com'),
replace=[
dict(
pattern=r'(Issue #|\B#)(?P<issue>\d+)',
Expand All @@ -28,5 +22,5 @@
url='https://www.python.org/dev/peps/pep-{pep_number:0>4}/',
),
],
),
)
}
9 changes: 4 additions & 5 deletions jaraco/clipboard/Linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
copy_text, paste_text = pyperclip.determine_clipboard()

unavailable = any(
isinstance(func, object)
and type(func).__name__ == 'ClipboardUnavailable'
for func in locals().values()
isinstance(func, object) and type(func).__name__ == 'ClipboardUnavailable'
for func in locals().values()
)

if unavailable:
del copy_text
del paste_text
del copy_text
del paste_text
2 changes: 1 addition & 1 deletion jaraco/clipboard/Windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


def paste_html():
return wclip.get_html().html
return wclip.get_html().html


paste_image = wclip.get_image
30 changes: 15 additions & 15 deletions jaraco/clipboard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,31 @@


def _not_implemented(*args, **kwargs):
raise NotImplementedError("format not supported")
raise NotImplementedError("format not supported")


def _init():
_platform_mod_name = '.' + platform.system()
_platform_mod = importlib.import_module(
_platform_mod_name, 'jaraco.clipboard')
_platform_mod_name = '.' + platform.system()
_platform_mod = importlib.import_module(_platform_mod_name, 'jaraco.clipboard')

# support copy and paste of text, html, and image.
_modes = 'copy', 'paste'
_formats = 'text', 'html', 'image'
_methods = map('_'.join, itertools.product(_modes, _formats))
# support copy and paste of text, html, and image.
_modes = 'copy', 'paste'
_formats = 'text', 'html', 'image'
_methods = map('_'.join, itertools.product(_modes, _formats))

for name in _methods:
func = getattr(_platform_mod, name, _not_implemented)
globals().update({name: func})
for name in _methods:
func = getattr(_platform_mod, name, _not_implemented)
globals().update({name: func})

globals().update(copy=globals()['copy_text'])
globals().update(paste=globals()['paste_text'])
globals().update(copy=globals()['copy_text'])
globals().update(paste=globals()['paste_text'])


_init()


__all__ = [
name for name, func in globals().items()
if callable(func) and not name.startswith('_')
name
for name, func in globals().items()
if callable(func) and not name.startswith('_')
]
18 changes: 9 additions & 9 deletions test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@


def needs_command(name):
cmd = vars(clipboard)[name]
cmd = vars(clipboard)[name]

return pytest.mark.xfail(
cmd is clipboard._not_implemented,
reason="{name} not implemented on this platform",
)
return pytest.mark.xfail(
cmd is clipboard._not_implemented,
reason="{name} not implemented on this platform",
)


@needs_command("copy_text")
def test_copy_text():
clipboard.copy_text("foo")
clipboard.copy_text("foo")


@needs_command("paste_text")
def test_paste_text():
# first ensure there's something on the clipboard:
clipboard.copy_text('test for paste')
assert clipboard.paste_text() == 'test for paste'
# first ensure there's something on the clipboard:
clipboard.copy_text('test for paste')
assert clipboard.paste_text() == 'test for paste'

0 comments on commit 8247643

Please sign in to comment.