Skip to content

Commit

Permalink
rafactor - try to fix 'snapbtrex not a package'
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshtec committed Oct 5, 2024
1 parent 3c511b7 commit 5de18e4
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 26 deletions.
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[build-system]
requires = [
"setuptools>=42",
"wheel"
]
build-backend = "setuptools.build_meta"
9 changes: 5 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import setuptools

VERSION = "2.0.7"
VERSION = "2.0.9"

with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read()
Expand All @@ -17,11 +17,12 @@
url="https://github.com/yoshtec/snapbtrex",
entry_points={
"console_scripts": [
"snapbtrex = snapbtrex.cli:main",
"snapbtrex.py = snapbtrex.cli:main",
"snapbtrex=snapbtrex.cli:main",
"snapbtrex.py=snapbtrex.cli:main",
]
},
packages=setuptools.find_packages(),
#packages=setuptools.find_packages(exclude=["tests", "tests.*"]),
packages=['snapbtrex'],
classifiers=[
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python :: 3",
Expand Down
8 changes: 8 additions & 0 deletions snapbtrex/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# -*- coding: utf-8 -*-
# SPDX-License-Identifier: BSD

# __init__.py for the package

# Importing submodules
#from .operations import Operations, FakeOperations, DryOperations
#from .cli import main
3 changes: 2 additions & 1 deletion snapbtrex/__main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from .cli import main
import sys

if __name__ == "__main__":
main()
main(sys.argv)
27 changes: 7 additions & 20 deletions snapbtrex/cli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import sys
import time
from .snapbtrex import (
import sys, time
from .operations import (
FakeOperations,
Operations,
DryOperations,
Expand All @@ -9,19 +8,6 @@
)


def log_trace(fmt, *args, **kwargs):
try:
tt = time.strftime(DATE_FORMAT, time.gmtime(None)) + ": "
if args:
print(tt + (fmt % args))
elif kwargs:
print(tt + (fmt % kwargs))
else:
print(tt + fmt)
except (Exception,):
print(fmt)


def default_trace(fmt, *args, **kwargs):
try:
if args:
Expand All @@ -34,6 +20,11 @@ def default_trace(fmt, *args, **kwargs):
print(fmt)


def log_trace(fmt, *args, **kwargs):
tt = time.strftime(DATE_FORMAT, time.gmtime(None)) + ": " + fmt
default_trace(tt, *args, **kwargs)


def null_trace(fmt, *args, **kwargs):
pass

Expand Down Expand Up @@ -400,7 +391,3 @@ def parse_ageoffset_to_timestamp(age_str):
operations.log_local(
"no options for cleaning were passed -> keeping all snapshots"
)


if "__main__" == __name__:
sys.exit(main(sys.argv))
5 changes: 4 additions & 1 deletion snapbtrex/snapbtrex.py → snapbtrex/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,8 +610,11 @@ def sync_cleandir(self, target_dir, sync_keep):
self.unsnapx(os.path.join(target_dir, del_dir))


# Allows to Simulate operations
class DryOperations(Operations):
"""
DryOperations is a subclass of Operations that simulates operations without making changes
"""

def __init__(self, path, trace=None):
Operations.__init__(self, path=path, trace=trace)
self.dirs = None
Expand Down

0 comments on commit 5de18e4

Please sign in to comment.