Skip to content

Commit 1207916

Browse files
committed
Update for fabric3.0
1 parent d653591 commit 1207916

File tree

12 files changed

+89
-82
lines changed

12 files changed

+89
-82
lines changed

pyproject.toml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
[build-system]
2+
requires = ["setuptools"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "patchwork"
7+
version = "2.0.0"
8+
description = "Deployment/sysadmin operations, powered by Fabric"
9+
authors = [{ name = "Jeff Forcier", email = "jeff@bitprophet.org" }]
10+
maintainers = [{ name = "Jeff Forcier", email = "jeff@bitprophet.org" }]
11+
requires-python = ">=3.6.2"
12+
readme = "README.rst"
13+
license = { file = "LICENSE" }
14+
classifiers = [
15+
"Development Status :: 5 - Production/Stable",
16+
"Environment :: Console",
17+
"Intended Audience :: Developers",
18+
"Intended Audience :: System Administrators",
19+
"License :: OSI Approved :: BSD License",
20+
"Operating System :: POSIX",
21+
"Operating System :: Unix",
22+
"Operating System :: MacOS :: MacOS X",
23+
"Operating System :: Microsoft :: Windows",
24+
"Programming Language :: Python",
25+
"Programming Language :: Python :: 2",
26+
"Programming Language :: Python :: 2.7",
27+
"Programming Language :: Python :: 3",
28+
"Programming Language :: Python :: 3.4",
29+
"Programming Language :: Python :: 3.5",
30+
"Programming Language :: Python :: 3.6",
31+
"Topic :: Software Development",
32+
"Topic :: Software Development :: Build Tools",
33+
"Topic :: Software Development :: Libraries",
34+
"Topic :: Software Development :: Libraries :: Python Modules",
35+
"Topic :: System :: Software Distribution",
36+
"Topic :: System :: Systems Administration",
37+
]
38+
39+
dependencies = [
40+
"fabric>=3.0",
41+
]
42+
43+
[project.optional-dependencies]
44+
dev = [
45+
]
46+
doc = [
47+
"releases",
48+
"alabaster",
49+
"sphinx",
50+
]
51+
test = [
52+
"invocations",
53+
"pytest",
54+
"pytest-cov",
55+
"mock",
56+
]
57+
58+
[project.urls]
59+
homepage = "https://www.fabfile.org/"
60+
61+
[tool.pytest.ini_options]
62+
testpaths = ["tests"]

setup.py

Lines changed: 0 additions & 48 deletions
This file was deleted.
File renamed without changes.

src/patchwork/__init__.py

Whitespace-only changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ def have_program(c, name):
77
"""
88
Returns whether connected user has program ``name`` in their ``$PATH``.
99
"""
10-
return c.run("which {}".format(name), hide=True, warn=True)
10+
return c.run(f"which {name}", hide=True, warn=True)
Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
import re
66

7-
from invoke.vendor import six
8-
97
from .util import set_runner
108

119

@@ -25,12 +23,12 @@ def directory(c, runner, path, user=None, group=None, mode=None):
2523
:param str mode:
2624
``chmod`` compatible mode string to apply to the directory.
2725
"""
28-
runner("mkdir -p {}".format(path))
26+
runner(f"mkdir -p {path}")
2927
if user is not None:
3028
group = group or user
31-
runner("chown {}:{} {}".format(user, group, path))
29+
runner(f"chown {user}:{group} {path}")
3230
if mode is not None:
33-
runner("chmod {} {}".format(mode, path))
31+
runner(f"chmod {mode} {path}")
3432

3533

3634
@set_runner
@@ -78,8 +76,8 @@ def contains(c, runner, filename, text, exact=False, escape=True):
7876
if escape:
7977
text = _escape_for_regex(text)
8078
if exact:
81-
text = "^{}$".format(text)
82-
egrep_cmd = 'egrep "{}" "{}"'.format(text, filename)
79+
text = f"^{text}$"
80+
egrep_cmd = f'egrep "{text}" "{filename}"'
8381
return runner(egrep_cmd, hide=True, warn=True).ok
8482

8583

@@ -116,7 +114,7 @@ def append(c, runner, filename, text, partial=False, escape=True):
116114
Whether to perform regex-oriented escaping on ``text``.
117115
"""
118116
# Normalize non-list input to be a list
119-
if isinstance(text, six.string_types):
117+
if isinstance(text, str):
120118
text = [text]
121119
for line in text:
122120
regex = "^" + _escape_for_regex(line) + ("" if partial else "$")
@@ -127,7 +125,7 @@ def append(c, runner, filename, text, partial=False, escape=True):
127125
):
128126
continue
129127
line = line.replace("'", r"'\\''") if escape else line
130-
runner("echo '{}' >> {}".format(line, filename))
128+
runner(f"echo '{line}' >> {filename}")
131129

132130

133131
def _escape_for_regex(text):
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def distro_name(c):
2929
}
3030
for name, sentinels in sentinel_files.items():
3131
for sentinel in sentinels:
32-
if exists(c, "/etc/{}".format(sentinel)):
32+
if exists(c, f"/etc/{sentinel}"):
3333
return name
3434
return "other"
3535

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# apt/deb, rpm/yum/dnf, arch/pacman, etc etc etc.
77

88

9-
from patchwork.info import distro_family
9+
from ..info import distro_family
1010

1111

1212
def package(c, *packages):
@@ -29,4 +29,4 @@ def rubygem(c, gem):
2929
"""
3030
Install a Ruby gem.
3131
"""
32-
return c.sudo("gem install -b --no-rdoc --no-ri {}".format(gem))
32+
return c.sudo(f"gem install -b --no-rdoc --no-ri {gem}")
Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
File transfer functionality above and beyond basic ``put``/``get``.
33
"""
44

5-
from invoke.vendor import six
6-
75

86
def rsync(
97
c,
@@ -79,7 +77,7 @@ def rsync(
7977
(rsync's ``--rsh`` flag.)
8078
"""
8179
# Turn single-string exclude into a one-item list for consistency
82-
if isinstance(exclude, six.string_types):
80+
if isinstance(exclude, str):
8381
exclude = [exclude]
8482
# Create --exclude options from exclude list
8583
exclude_opts = ' --exclude "{}"' * len(exclude)
@@ -97,30 +95,30 @@ def rsync(
9795
# always-a-list, always-up-to-date-from-all-sources attribute to save us
9896
# from having to do this sort of thing. (may want to wait for Paramiko auth
9997
# overhaul tho!)
100-
if isinstance(keys, six.string_types):
98+
if isinstance(keys, str):
10199
keys = [keys]
102100
if keys:
103101
key_string = "-i " + " -i ".join(keys)
104102
# Get base cxn params
105103
user, host, port = c.user, c.host, c.port
106-
port_string = "-p {}".format(port)
104+
port_string = f"-p {port}"
107105
# Remote shell (SSH) options
108106
rsh_string = ""
109107
# Strict host key checking
110108
disable_keys = "-o StrictHostKeyChecking=no"
111109
if not strict_host_keys and disable_keys not in ssh_opts:
112-
ssh_opts += " {}".format(disable_keys)
110+
ssh_opts += f" {disable_keys}"
113111
rsh_parts = [key_string, port_string, ssh_opts]
114112
if any(rsh_parts):
115-
rsh_string = "--rsh='ssh {}'".format(" ".join(rsh_parts))
113+
rsh_string = f"--rsh='ssh {' '.join(rsh_parts)}'"
116114
# Set up options part of string
117115
options_map = {
118116
"delete": "--delete" if delete else "",
119117
"exclude": exclude_opts.format(*exclusions),
120118
"rsh": rsh_string,
121119
"extra": rsync_opts,
122120
}
123-
options = "{delete}{exclude} -pthrvz {extra} {rsh}".format(**options_map)
121+
options = f"{options_map['delete']}{options_map['exclude']} -pthrvz {options_map['extra']} {options_map['rsh']}"
124122
# Create and run final command string
125123
# TODO: richer host object exposing stuff like .address_is_ipv6 or whatever
126124
if host.count(":") > 1:

0 commit comments

Comments
 (0)