Skip to content

Commit

Permalink
fix: debug messages and worng path finding (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
eieste authored Dec 19, 2024
2 parents 67c984f + ecae3bf commit 609072e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 20 deletions.
11 changes: 5 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ repos:
args: [ '--quiet' ]

- repo: https://github.com/asottile/pyupgrade
rev: v2.31.0
rev: v3.19.1
hooks:
- id: pyupgrade

- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.1.10
rev: v1.5.5
hooks:
- id: remove-tabs

- repo: https://github.com/commitizen-tools/commitizen
rev: v2.20.4
rev: v4.1.0
hooks:
- id: commitizen
stages: [ commit-msg ]
Expand All @@ -38,9 +38,8 @@ repos:
- id: end-of-file-fixer
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: fix-encoding-pragma
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.9.0 # Use the ref you want to point at
rev: v1.10.0 # Use the ref you want to point at
hooks:
- id: rst-backticks
- id: rst-directive-colons
Expand All @@ -51,7 +50,7 @@ repos:
- id: rst-linter
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.7.2
rev: v0.8.3
hooks:
# Run the linter.
- id: ruff
Expand Down
7 changes: 1 addition & 6 deletions src/tfutility/controllers/blockdate.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import sys
from datetime import datetime, timedelta

Expand Down Expand Up @@ -54,14 +53,10 @@ def new_block(self, options, block):

if not options.expire_after:
if dec.parameter("expire"):
print("HIII")

dec_date_expire = datetime.strptime(
dec.parameter("expire"), "%d-%m-%Y"
)
if now > dec_date_expire:
print("FOOOHIII")

self._error = True
self.get_logger().error(
"{} Block expired in file: {}:{}".format(
Expand All @@ -79,7 +74,7 @@ def new_block(self, options, block):

def handle(self, options):
self._error = False
results = super(BlockDateHandler, self).handle(options)
results = super().handle(options)

tf_files = self.get_file_list(options.paths)

Expand Down
7 changes: 2 additions & 5 deletions src/tfutility/core/tffile.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import pathlib
import re
from collections import namedtuple
Expand Down Expand Up @@ -200,7 +199,6 @@ def has_decorator(self, name: str) -> bool:
:return: True if the block has a decorator with the given name, False otherwise
:rtype: bool
"""
print("blubl" * 10)
if self._decorators is None:
self._decorators = self._find_decorators()
for dec in self._decorators:
Expand All @@ -215,11 +213,9 @@ def _find_decorators(self):
:return: A list of decorators found above this block
:rtype: list[TfUtilDecorator]
"""
print("hiii" * 100)
line_nr = self._start_line - 2
decorator_list = []
while self.tffile.lines[line_nr].strip().startswith("# @"):
print(self.tffile.lines[line_nr])
found_decorator = self.tffile.lines[line_nr].strip()
result = TfBlock.DECORATOR_REGEX.fullmatch(found_decorator)
decorator_list.append(
Expand All @@ -234,6 +230,7 @@ class TfFile:
def __init__(self, path: pathlib.Path, autoparse=True):
self.path = path
self._blocks = None
print(path)
self._tf_file = self.read_tf(path)
if autoparse:
self.parse()
Expand Down Expand Up @@ -285,7 +282,7 @@ def _extract_blocks(self, blockdata: dict, name: str):
):
elem_names = [key for key in blockdata.keys() if not key.startswith("__")]

if len(elem_names) > 1:
if len(elem_names) < 1:
new_name = ""
else:
new_name = elem_names[0]
Expand Down
9 changes: 6 additions & 3 deletions src/tfutility/core/tfpaths.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import argparse
import pathlib

Expand All @@ -19,7 +18,7 @@ def add_arguments(self, parser: argparse.ArgumentParser) -> argparse.ArgumentPar
:return: Tthe argument parser enriched with arguments
:rtype: argparse.ArgumentParser
"""
parser = super(TfPaths, self).add_arguments(parser)
parser = super().add_arguments(parser)
parser.add_argument(
"paths",
nargs="+",
Expand Down Expand Up @@ -54,7 +53,11 @@ def get_file_list(self, paths: list[pathlib.Path]) -> list[pathlib.Path]:
"""
file_list = []
for p in paths:
file_list += self._get_files_from_path(p)
file_list += [
f
for f in self._get_files_from_path(p)
if "/." not in f.absolute().as_posix()
]

if len(file_list) <= 0:
self.get_logger().warning(
Expand Down

0 comments on commit 609072e

Please sign in to comment.