Skip to content

Commit

Permalink
Merge branch 'master' into pathlib-like
Browse files Browse the repository at this point in the history
  • Loading branch information
henryiii committed May 25, 2017
2 parents 4d347d7 + dc76427 commit f27adea
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 9 deletions.
1 change: 1 addition & 0 deletions appveyor.yml → .appveyor.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ environment:
- PYTHON: "C:\\Python33"
- PYTHON: "C:\\Python34"
- PYTHON: "C:\\Python35"
- PYTHON: "C:\\Python36"

install:
- set PATH=%PYTHON%;%PYTHON%\Scripts;%PATH%
Expand Down
10 changes: 5 additions & 5 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
1.6.3
-----
* Python 3.6 is now supported, critical bug fixed (`#302 <https://github.com/tomerfiliba/plumbum/issues/302>`)
* Python 3.6 is now supported, critical bug fixed (`#302 <https://github.com/tomerfiliba/plumbum/issues/302>`_)
* Commands: Better handling of return codes for pipelines (`#288 <https://github.com/tomerfiliba/plumbum/pull/288>`_)
* Paths: Return split support (regression) (`#286 <https://github.com/tomerfiliba/plumbum/issues/286>`) - also supports dummy args for better ``str`` compatibility
* Paths: Return split support (regression) (`#286 <https://github.com/tomerfiliba/plumbum/issues/286>`_) - also supports dummy args for better ``str`` compatibility
* Paths: Added support for Python 3.6 path protocol
* Paths: Support Python's ``in`` syntax
* CLI: Added Config parser (provisional) (`#304 <https://github.com/tomerfiliba/plumbum/pull/304>`)
* Color: image plots with `python -m plumbum.cli.image` (`#304 <https://github.com/tomerfiliba/plumbum/pull/304>`)
* SSH: No longer hangs for ``timeout`` seconds on failure (`#306 <https://github.com/tomerfiliba/plumbum/issues/306>`)
* CLI: Added Config parser (provisional) (`#304 <https://github.com/tomerfiliba/plumbum/pull/304>`_)
* Color: image plots with `python -m plumbum.cli.image` (`#304 <https://github.com/tomerfiliba/plumbum/pull/304>`_)
* SSH: No longer hangs for ``timeout`` seconds on failure (`#306 <https://github.com/tomerfiliba/plumbum/issues/306>`_)
* Test improvements, especially on non-linux systems

1.6.2
Expand Down
1 change: 1 addition & 0 deletions docs/colors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -280,5 +280,6 @@ See Also
========

* `colored <https://pypi.python.org/pypi/colored>`_ Another library with 256 color support
* `colorful <https://github.com/timofurrer/colorful>`_ A fairly new libary with a similar feature set
* `colorama <https://pypi.python.org/pypi/colorama>`_ A library that supports colored text on Windows,
can be combined with Plumbum.colors (if you force ``use_color``, doesn't support all extended colors)
7 changes: 3 additions & 4 deletions plumbum/cli/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,8 @@ def _handle_argument(val, argtype, name):
return argtype(val)
except (TypeError, ValueError):
ex = sys.exc_info()[1] # compat
raise WrongArgumentType("Argument of %s expected to be %r, not %r:\n %r" % (
name, argtype, val, ex))
raise WrongArgumentType("Argument of {name} expected to be {argtype}, not {val!r}:\n {ex!r}".format(
name=name, argtype=argtype, val=val, ex=ex))
else:
return NotImplemented

Expand Down Expand Up @@ -627,7 +627,7 @@ def switchs(by_groups, show_groups):
swnames = ", ".join(("-" if len(n) == 1 else "--") + n for n in si.names
if n in self._switches_by_name and self._switches_by_name[n] == si)
if si.argtype:
if isinstance(si.argtype, type):
if hasattr(si.argtype, '__name__'):
typename = si.argtype.__name__
else:
typename = str(si.argtype)
Expand Down Expand Up @@ -711,4 +711,3 @@ def version(self):
ver = self._get_prog_version()
ver_name = ver if ver is not None else "(version not set)"
print('{0} {1}'.format(self.PROGNAME, ver_name))

10 changes: 10 additions & 0 deletions plumbum/cli/switches.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,16 @@ def ExistingDirectory(val):
raise ValueError("%r is not a directory" % (val,))
return p


@Predicate
def MakeDirectory(val):
p = local.path(val)
if p.is_file():
raise ValueError('%r is a file, should be nonexistent, or a directory' % (val,))
elif not p.exists():
p.mkdir()
return p

@Predicate
def ExistingFile(val):
"""A switch-type validator that ensures that the given argument is an existing file"""
Expand Down

0 comments on commit f27adea

Please sign in to comment.