Skip to content
Merged
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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ dev = [
"pylint == 4.0.6",
"pyrefly==1.1.1",
"pytest == 9.1.1",
"ruff == 0.15.22"
"ruff == 0.16.0"
]

[build-system]
Expand Down
1 change: 1 addition & 0 deletions test/cli_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import unittest

from trackpack import cli


Expand Down
17 changes: 11 additions & 6 deletions test/config_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@

import datetime
import unittest
from unittest.mock import patch, Mock
from trackpack import config, cli
from unittest.mock import patch

from trackpack import cli, config


class TestConfig(unittest.TestCase):
Expand All @@ -34,8 +35,10 @@ def test_extension_is_stripped_from_archivename(self) -> None:
cfg.archive_name = "stems.zip"
self.assertEqual("stems", cfg.archive_name)

@patch("trackpack.config.date", Mock(today=lambda: datetime.date(2020, 1, 1)))
def test_append_date_appends_date_to_archive_name(self) -> None:
@patch("trackpack.config.datetime")
def test_append_date_appends_date_to_archive_name(self, mock_datetime) -> None:
mock_datetime.now.return_value.date.return_value = datetime.date(2020, 1, 1)

cfg = config.Config()
cfg.archive_name = "xyz"
cfg.append_date = True
Expand All @@ -57,8 +60,10 @@ def test_load_from_yaml(self) -> None:
cfg.load_from_yaml("name: project-1\narchive_name: proj1\nappend_date: true")
self.assertTrue(cfg.append_date)

@patch("trackpack.config.date", Mock(today=lambda: datetime.date(2020, 1, 2)))
def test_load_from_cli_args(self) -> None:
@patch("trackpack.config.datetime")
def test_load_from_cli_args(self, mock_datetime) -> None:
mock_datetime.now.return_value.date.return_value = datetime.date(2020, 1, 2)

args = cli.parse_args(["pack", "--archive-name", "proj.zip", "--append-date"])
cfg = config.Config()
cfg.archive_name = "should override"
Expand Down
7 changes: 4 additions & 3 deletions test/trackpack_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import unittest
from unittest.mock import patch, call
import os
from trackpack.trackpacker import TrackPacker, MissingFileException
import unittest
from unittest.mock import call, patch

from trackpack.trackpacker import MissingFileException, TrackPacker


class TestTrackPack(unittest.TestCase):
Expand Down
1 change: 1 addition & 0 deletions trackpack/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import argparse

from trackpack.version import __version__


Expand Down
6 changes: 4 additions & 2 deletions trackpack/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from datetime import date
from datetime import datetime, timezone

import yaml


Expand All @@ -29,7 +30,8 @@ def __init__(self) -> None:
@property
def archive_name(self) -> str:
if self.append_date:
return "-".join((self._archive_name, date.today().strftime("%Y-%m-%d")))
today_date = datetime.now(timezone.utc).date()
return "-".join((self._archive_name, today_date.strftime("%Y-%m-%d")))
return self._archive_name

@archive_name.setter
Expand Down
3 changes: 1 addition & 2 deletions trackpack/trackpacker.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,5 @@ def pack_files(self, archive_name: str, files: list[str]):
archive.write(file, self.__normalize_stem_name(os.path.basename(file)))

def __normalize_stem_name(self, stem_name: str) -> str:
if stem_name.startswith(self.__project_name):
stem_name = stem_name[len(self.__project_name) :]
stem_name = stem_name.removeprefix(self.__project_name)
return stem_name.strip().replace(" ", "-")