Skip to content

Commit

Permalink
Merge pull request #46 from bigladder/fix-string-patterns
Browse files Browse the repository at this point in the history
Fix string patterns
  • Loading branch information
nealkruis authored May 29, 2024
2 parents e01ba42 + 5a5e79b commit 36f1d7c
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 120 deletions.
11 changes: 7 additions & 4 deletions lattice/docs/mkdocs_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import shutil
from urllib.parse import urlparse
from typing import List
from datetime import datetime

import pygit2
from jinja2 import Environment, FileSystemLoader
Expand Down Expand Up @@ -74,6 +75,7 @@ def __init__(self, lattice):
self.specification_counter = 1
self.specification_templates: List[DocumentFile] = []
self.navigation = []
self.timestamp = datetime.now()

def setup_build_directory_structure(self): # pylint: disable=missing-function-docstring
self.content_directory_path = make_dir(Path(self.build_directory, "docs"))
Expand All @@ -100,9 +102,7 @@ def get_git_info(self): # pylint: disable=missing-function-docstring
self.git_ref_name = "main"
else:
self.git_ref_name = self.git_repo.head.name
self.git_remote_url = (
rf"https://{self.git_repo_owner}.{self.git_repo_host}.com/{self.git_repo_owner}/{self.git_repo_name}"
)
self.git_remote_url = rf"https://{self.git_repo_host}.com/{self.git_repo_owner}/{self.git_repo_name}"
self.base_url = rf"https://{self.git_repo_owner}.{self.git_repo_host}.io/{self.git_repo_name}/"

# pylint: disable-next=missing-function-docstring, too-many-branches, too-many-statements
Expand All @@ -121,11 +121,12 @@ def make_config(self): # pylint: disable=missing-function-docstring
"site_url": self.base_url,
"site_author": self.author,
"site_description": self.description,
"copyright": f"&copy {self.timestamp.year} {self.author} All rights reserved",
"theme": {"name": "material", "favicon": favicon, "logo": logo, "palette": self.colors},
"repo_name": self.git_repo_name,
"repo_url": self.git_remote_url,
"nav": self.navigation,
"markdown_extensions": ["markdown_grid_tables"],
"markdown_extensions": ["markdown_grid_tables", "pymdownx.smartsymbols"],
}

def make_pages(self):
Expand Down Expand Up @@ -308,6 +309,7 @@ def make_main_menu_page(
):
front_matter = {
"title": title,
"build_date_utc": self.timestamp,
}

if content_type is not None:
Expand Down Expand Up @@ -350,6 +352,7 @@ def make_specification_page(
# Append front matter
front_matter = {
"title": title,
"build_date_utc": self.timestamp,
}

self.specification_counter += 1
Expand Down
14 changes: 7 additions & 7 deletions lattice/lattice.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import warnings
from fnmatch import fnmatch
from pathlib import Path
from typing import List
from typing import List, Union
from jsonschema.exceptions import RefResolutionError

from lattice.docs.process_template import process_template
Expand All @@ -20,7 +20,7 @@
class SchemaFile: # pylint:disable=R0902
"""Parse the components of a schema file."""

def __init__(self, path) -> None:
def __init__(self, path: Path) -> None:
"""Open and parse source schema"""

self.path = Path(path).absolute()
Expand Down Expand Up @@ -126,11 +126,11 @@ class Lattice: # pylint:disable=R0902

def __init__(
self,
root_directory=Path.cwd(),
build_directory: Path = None,
build_output_directory_name=".lattice",
build_validation=True,
):
root_directory: Path = Path.cwd(),
build_directory: Union[Path, None] = None,
build_output_directory_name: Path = Path(".lattice"),
build_validation: bool = True,
) -> None:
"""Set up file structure"""

# Check if directories exists
Expand Down
11 changes: 7 additions & 4 deletions lattice/schema.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from __future__ import (
annotations,
) # Needed for type hinting classes that are not yet fully defined
from typing import List
import pathlib
import re

from .file_io import load, get_file_basename

core_schema_path = pathlib.Path(pathlib.Path(__file__).parent, "core.schema.yaml")
Expand Down Expand Up @@ -160,7 +162,7 @@ class ArrayLengthLimitsConstraint(Constraint):
pattern = RegularExpressionPattern(r"\[(\d*)\.\.(\d*)\]")


_constraint_list = [
_constraint_list: List[Constraint] = [
RangeConstraint,
MultipleConstraint,
SetConstraint,
Expand All @@ -171,7 +173,7 @@ class ArrayLengthLimitsConstraint(Constraint):
]


def _constraint_factory(input: str, parent_data_element: DataElement):
def _constraint_factory(input: str, parent_data_element: DataElement) -> Constraint:
number_of_matches = 0
match_type = None
for constraint in _constraint_list:
Expand Down Expand Up @@ -263,7 +265,7 @@ def init_method(self, text, parent_data_element):


class DataGroup:
def __init__(self, name, data_group_dictionary, parent_schema: Schema):
def __init__(self, name: str, data_group_dictionary, parent_schema: Schema):
self.name = name
self.dictionary = data_group_dictionary
self.parent_schema = parent_schema
Expand Down Expand Up @@ -368,7 +370,8 @@ def __init__(self, schema=None):
f"({sets})|"
f"({self.data_element_value_constraint})|"
f"({reference_scope})|"
f"({self.selector_constraint})"
f"({self.selector_constraint})|"
f"({StringPatternConstraint.pattern})"
)

# Conditional Requirements
Expand Down
Loading

0 comments on commit 36f1d7c

Please sign in to comment.