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

migrate to python3, pyproject.toml #72

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
language: python
python:
- 2.7
- 3.6
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're going for Python 3, should we also go for a non-deprecated 3 version? Or are you planning to tackle that in a follow-on PR?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea I agree, just wasn't sure if CI is still running (or honestly if the project is still being maintained)

Would it make sense to just migrate to github actions? Can do that here or in a separate PR (whichever you prefer)

install:
- pip install nose
- ./setup.py develop
- pip install -e .
script:
- nosetests tests
notifications:
Expand Down
5 changes: 0 additions & 5 deletions MANIFEST.in

This file was deleted.

26 changes: 26 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[project]
name = "tarsnapper"
version = "0.5.0"
description = "Manages tarsnap backups"
readme = "README.md"
authors = [{ name = "Michael Elsdoerfer", email = "[email protected]" }]
classifiers = [
"License :: OSI Approved :: BSD License",
"Programming Language :: Python :: 3",
]
dependencies = ["pexpect>=3.1", "python-dateutil>=2.4.0", "pyyaml>=3.09"]
license = { text = "BSD" }
requires-python = ">=3.6"

[project.scripts]
tarsnapper = "tarsnapper.script:run"

[project.urls]
Homepage = "http://github.com/miracle2k/tarsnapper"

[tool.flit.sdist]
include = ["simulate.py", "tests/"]

[build-system]
requires = ["flit_core >=3.2,<4"]
build-backend = "flit_core.buildapi"
3 changes: 0 additions & 3 deletions scripts/tarsnapper

This file was deleted.

50 changes: 0 additions & 50 deletions setup.py

This file was deleted.

5 changes: 2 additions & 3 deletions tarsnapper/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
source: /important-2/
delta: important
"""
from __future__ import print_function

from datetime import timedelta
import glob
Expand All @@ -55,7 +54,7 @@ class ConfigError(Exception):
pass


class Job(object):
class Job:
"""Represent a single backup job."""

def __init__(self, **initial):
Expand Down Expand Up @@ -205,7 +204,7 @@ def load_job(job_name, job_dict):
# can only be used for selected commands, then.
require_placeholders(new_job.target, ['date'], '%s: target')
if job_dict:
raise ConfigError('%s has unsupported configuration values: %s' % (
raise ConfigError('{} has unsupported configuration values: {}'.format(
job_name, ", ".join(job_dict.keys())))
return new_job

Expand Down
2 changes: 1 addition & 1 deletion tarsnapper/expire.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def expire(backups, deltas):

# Always keep the most recent backup
most_recent_backup = backups[0][1]
to_keep = set([backups[0][0]])
to_keep = {backups[0][0]}

# Then, for each delta/generation, determine which backup to keep
last_delta = deltas.pop()
Expand Down
16 changes: 7 additions & 9 deletions tarsnapper/script.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import print_function

import argparse
from datetime import datetime
import getpass
Expand Down Expand Up @@ -28,7 +26,7 @@ class TarsnapError(Exception):
pass


class TarsnapBackend(object):
class TarsnapBackend:
"""
The code that calls the tarsnap executable.

Expand Down Expand Up @@ -61,7 +59,7 @@ def call(self, *arguments):
for option in self.options:
key = option[0]
pre = "-" if len(key) == 1 else "--"
call_with.append("%s%s" % (pre, key))
call_with.append("{}{}".format(pre, key))
for value in option[1:]:
call_with.append(value)
call_with.extend(arguments)
Expand All @@ -77,15 +75,15 @@ def _exec_tarsnap(self, args):
child.logfile = sys.stdout

# look for the passphrase prompt
has_prompt = (child.expect([u'Please enter passphrase for keyfile .*?:', pexpect.EOF]) == 0)
has_prompt = (child.expect(['Please enter passphrase for keyfile .*?:', pexpect.EOF]) == 0)
if has_prompt:
child.sendline(self._get_key_passphrase())
child.expect(pexpect.EOF)
out = child.before
child.close()

if child.exitstatus != 0:
raise TarsnapError("tarsnap failed with status {0}:{1}{2}".format(
raise TarsnapError("tarsnap failed with status {}:{}{}".format(
child.exitstatus, os.linesep, out))
return out

Expand All @@ -100,7 +98,7 @@ def _exec_util(self, cmdline, shell=False):
p = subprocess.Popen(cmdline, shell=True)
p.communicate()
if p.returncode:
raise RuntimeError('%s failed with exit code %s' % (
raise RuntimeError('{} failed with exit code {}'.format(
cmdline, p.returncode))

def _add_known_archive(self, name):
Expand Down Expand Up @@ -263,7 +261,7 @@ def timedelta_string(value):
raise argparse.ArgumentTypeError('invalid delta value: %r (suffix d, s allowed)' % e)


class Command(object):
class Command:

BackendClass = TarsnapBackend

Expand Down Expand Up @@ -536,7 +534,7 @@ def main(argv):
if unknown:
log.error('Error: not defined in the config file: %s', ", ".join(unknown))
return 1
jobs_to_run = dict([(n, j) for n, j in jobs.items() if n in args.jobs])
jobs_to_run = {n: j for n, j in jobs.items() if n in args.jobs}
else:
jobs_to_run = jobs

Expand Down
2 changes: 1 addition & 1 deletion tarsnapper/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
__all__ = ('BackupSimulator',)


class BackupSimulator(object):
class BackupSimulator:
"""Helper to simulate making backups, and expire old ones, at
various points in time.
"""
Expand Down
4 changes: 2 additions & 2 deletions tests/test_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(self, *a, **kw):
def _exec_tarsnap(self, args):
self.calls.append(args[1:]) # 0 is "tarsnap"
if '--list-archives' in args:
return u"\n".join(self.fake_archives)
return "\n".join(self.fake_archives)

def _exec_util(self, cmdline):
self.calls.append(cmdline)
Expand All @@ -44,7 +44,7 @@ def match(self, expect_calls):
return True


class BaseTest(object):
class BaseTest:

def setup(self):
self.log = logging.getLogger("test_script")
Expand Down