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

Validation against certain rules including strict checking of casing as an option #51

Merged
merged 77 commits into from
Jan 10, 2025
Merged
Changes from 1 commit
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
bb40e7e
Removing 2.7 support and switching everything to new practices
xiancg May 7, 2023
270e3cf
New package setup
xiancg Aug 3, 2024
f9dc598
Update logger
xiancg Aug 3, 2024
29228ad
Logger update and removed six calls
xiancg Aug 3, 2024
3944c62
Updating format and removing eval statements
xiancg Aug 4, 2024
0e74614
Adding pathlib and making sure TokenNumber and Token are taken in loa…
xiancg Aug 4, 2024
721f128
Working on typing hints to improve readability
xiancg Aug 4, 2024
1c143f6
Typing hints
xiancg Aug 4, 2024
78eced5
Parameterize explicit solve test
xiancg Aug 4, 2024
72316fc
Parameterize defaults tests
xiancg Aug 4, 2024
02aebeb
Parameterize implicit solving test
xiancg Aug 4, 2024
4ef373d
Parameterize parsing tests
xiancg Aug 4, 2024
ab7ad6d
Parameterize repeated tokens
xiancg Aug 4, 2024
c828ed0
Parameterize repeating tokens
xiancg Aug 4, 2024
2a38c90
Parameterization of anchor tests
xiancg Aug 4, 2024
ba8372d
More parameterization on naming tests
xiancg Aug 4, 2024
db14be8
Remove comment
xiancg Aug 4, 2024
f535ba3
WIP rules tests parameterization
xiancg Aug 4, 2024
aa898fc
Validate basic rule creation parameters
xiancg Aug 5, 2024
638c895
Rules tests parametrization
xiancg Aug 5, 2024
584c456
Wip token tests parametrization
xiancg Aug 6, 2024
3ded37b
Tokens tests parametrization finished
xiancg Aug 6, 2024
870da79
Update docs
xiancg Aug 6, 2024
7cf4ddf
Fixing outdated tox
xiancg Aug 6, 2024
df05641
Merge branch 'master' into refactor
xiancg Aug 7, 2024
ef92972
Remove old travis
xiancg Aug 7, 2024
34f456d
Merge branch 'master' into refactor
xiancg Aug 7, 2024
cb57fb5
Setup shell before invoking ruff
xiancg Aug 7, 2024
4906430
Using pipenv run
xiancg Aug 7, 2024
ebdcf82
Badges
xiancg Aug 7, 2024
4bdded2
Fixing docs buils
xiancg Aug 7, 2024
0794381
docs requirements
xiancg Aug 7, 2024
4930a59
Update yml with requirements
xiancg Aug 7, 2024
8e01a76
Merge branch 'master' into refactor
xiancg Aug 7, 2024
93611b4
Update badges in docs
xiancg Aug 7, 2024
96dfd41
Merge branch 'master' into refactor
xiancg Aug 7, 2024
879181d
Update coverage
xiancg Aug 10, 2024
a06c8a4
Adds coverage badge
xiancg Aug 10, 2024
8fce812
Testing environment
xiancg Aug 10, 2024
583e488
Add lcov report
xiancg Aug 10, 2024
057036f
wrong token placement
xiancg Aug 10, 2024
9122ca7
Merge branch 'master' into refactor
xiancg Aug 10, 2024
50c3fbe
Update get_repo logic and adds validation functions
xiancg Aug 11, 2024
60dc4ec
Adds tokens and rules validations. Refactor save_session
xiancg Aug 11, 2024
be5a88c
Update load function conf naming
xiancg Aug 11, 2024
f0c10d6
Not templates, rules
xiancg Aug 11, 2024
bb8d379
Limit to pull requests
xiancg Aug 11, 2024
e4aa558
Adding referenced rules
xiancg Aug 11, 2024
55ad519
Working on new referenced functionality an tests
xiancg Aug 11, 2024
a243b9d
Adds validation function and test
xiancg Dec 23, 2024
1b31d15
All tests passing
xiancg Dec 23, 2024
aba19d4
Validations for token numbers
xiancg Dec 23, 2024
4fd1bd2
Padding validation and more docs for it
xiancg Dec 23, 2024
5f3b565
Version up
xiancg Dec 23, 2024
023de7d
Merge branch 'master' into refactor
xiancg Dec 23, 2024
52126a3
Version up
xiancg Dec 23, 2024
36305df
Ignore flake8 for now
xiancg Dec 23, 2024
7d54804
Fix .conf file naming in logs
xiancg Dec 23, 2024
61ceac2
Merge branch 'master' into refactor
xiancg Dec 23, 2024
6c60b27
Missing log info in raise statement
xiancg Jan 6, 2025
b027a75
Merge branch 'master' into refactor
xiancg Jan 6, 2025
98f45dc
Let the user know about casing mismatches
xiancg Jan 6, 2025
24c8be4
Merge branch 'master' into refactor
xiancg Jan 6, 2025
dfb9dda
Improve error info if casing is the problem
xiancg Jan 7, 2025
c0049f4
Implements validation against data passed by the user
xiancg Jan 7, 2025
e4156af
Version up
xiancg Jan 7, 2025
7026449
Merge branch 'master' into refactor
xiancg Jan 7, 2025
64a0c65
Implements fallback value for required tokens
xiancg Jan 8, 2025
74c110a
Make sure we only enforce this on Token and not TokenNumber
xiancg Jan 8, 2025
6af78cb
Update docs to include new fallback attribute of Token
xiancg Jan 8, 2025
9c4c69f
Version up
xiancg Jan 8, 2025
8e9613d
Merge branch 'master' into refactor
xiancg Jan 8, 2025
bd159e7
WIP picking rules
xiancg Jan 8, 2025
f18ec2c
WIP validate many rules
xiancg Jan 10, 2025
bf5f13b
Merge branch 'master' into refactor
xiancg Jan 10, 2025
9d0b0fd
Validate against certain rules. Validation now returns a list of vali…
xiancg Jan 10, 2025
82861dd
Update docs
xiancg Jan 10, 2025
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
Prev Previous commit
Next Next commit
Validations for token numbers
  • Loading branch information
xiancg committed Dec 23, 2024
commit aba19d449fab2e5f6260ded72994772598e4f6bf
7 changes: 7 additions & 0 deletions docs/source/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Changelog
================================

1.3.1-beta
---------------------------------------

**Improvements:**
- Adds validate functionality to rules.


1.3.0-beta
---------------------------------------

4 changes: 3 additions & 1 deletion docs/source/roadmap.rst
Original file line number Diff line number Diff line change
@@ -3,4 +3,6 @@ Roadmap

- Implement referenced Tokens

- GUI for creating and editing VFXNaming repos
- GUI for creating and editing VFXNaming repos

- Improve registry capabilities
10 changes: 10 additions & 0 deletions docs/source/usage/validating.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Validating
=====================

Many times the only thing we need is to know if a name is valid or not for a given rule. Each Rule validates the name according to next criteria:

- The name must have the same number of tokens as the rule.
- The tokens must be in the same order as the rule.
- The number of expected separators must match with the rule.
- If tokens have options, the given name must use one of those options.
- If token is a number, validates suffix, prefix and padding.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "vfxnaming"
version = "1.3.0-beta"
version = "1.3.1-beta"
authors = [
{ name="Chris Granados", email="info@chrisgranados.com" },
]
29 changes: 28 additions & 1 deletion src/vfxnaming/rules.py
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
from typing import Dict, AnyStr, Union, Tuple

from vfxnaming.serialize import Serializable
from vfxnaming.tokens import get_token
from vfxnaming.tokens import get_token, TokenNumber
from vfxnaming.logger import logger
from vfxnaming.error import ParsingError, SolvingError, RuleError

@@ -213,6 +213,7 @@ def validate(self, name: AnyStr) -> bool:
repeated_fields[each] = 1
if repeated_fields:
logger.debug(f"Repeated tokens: {', '.join(repeated_fields.keys())}")

matching_options = True
for key, value in name_parts:
# Strip number that was added to make group name unique
@@ -225,6 +226,32 @@ def validate(self, name: AnyStr) -> bool:
):
logger.debug(f"Token {token_name} has no option {value}")
matching_options = False
if isinstance(token, TokenNumber):
if len(token.suffix):
if not value.endswith(token.suffix):
logger.debug(
f"Token {token_name}: {value} must end with {token.suffix}"
)
matching_options = False
if len(token.prefix):
if not value.startswith(token.prefix):
logger.debug(
f"Token {token_name}: {value} must end with {token.prefix}"
)
matching_options = False
digits = value[len(token.prefix) : len(token.suffix) * -1]
if not digits.isdigit():
logger.debug(
f"Token {token_name}: {value} must be digits with "
f"prefix '{token.prefix}' and suffix '{token.suffix}'"
)
matching_options = False
if len(digits) != token.padding:
logger.debug(
f"Token {token_name}: {value} must have {token.padding} digits"
)
matching_options = False

return matching_options

def __build_regex(self) -> re.Pattern: