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 @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "python_tabular"
version = "0.3.2"
version = "0.3.3"
authors = [
{ name="Curtis Stallings", email="curtisrstallings@gmail.com" },
]
Expand Down
23 changes: 13 additions & 10 deletions pytabular/culture.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
import logging
from object import PyObject, PyObjects
from typing import List

logger = logging.getLogger("PyTabular")

Expand All @@ -19,7 +20,7 @@ def __init__(self, object, model) -> None:
self._display.add_row("Culture Name", self._object.Name)
self.ObjectTranslations = self.set_translation()

def set_translation(self) -> list[dict]:
def set_translation(self) -> List[dict]:
"""
Based on the culture, it creates a list of dicts
with all the available translations in the file.
Expand All @@ -42,16 +43,18 @@ def get_translation(
By default it will search for the "Caption" object type, due to fact that a
Display folder and Description can also have translations.
"""
if translations := [
d
for d in self.ObjectTranslations
if d["object_name"] == object_name
and d["object_type"] == object_type
and d["object_parent_name"] == object_parent_name
]:
try:
# Removed walrus operator so it can be compatible with with python versions before 3.8
translations = [
d
for d in self.ObjectTranslations
if d["object_name"] == object_name
and d["object_type"] == object_type
and d["object_parent_name"] == object_parent_name
]
return translations[0]

return {"object_not_found": "Not Available"}
except Exception:
return {"object_not_found": "Not Available"}


class PyCultures(PyObjects):
Expand Down
14 changes: 7 additions & 7 deletions pytabular/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,17 +332,17 @@ def create_markdown_for_table(self, object: PyTable) -> str:
"\\n", ""
)

partition_type = ''
partition_source = ''
partition_type = ""
partition_source = ""

if str(object.Partitions[0].SourceType) == 'Calculated':
partition_type = 'dax'
if str(object.Partitions[0].SourceType) == "Calculated":
partition_type = "dax"
partition_source = object.Partitions[0].Source.Expression
elif str(object.Partitions[0].SourceType) == 'M':
partition_type = 'powerquery'
elif str(object.Partitions[0].SourceType) == "M":
partition_type = "powerquery"
partition_source = object.Partitions[0].Source.Expression
else:
partition_type = 'sql'
partition_type = "sql"
partition_source = object.Partitions[0].Source.Query

return f"""
Expand Down
2 changes: 1 addition & 1 deletion pytabular/logic_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def get_value_to_df(Query: AdomdDataReader, index: int):
return Query.GetValue(index)


def dataframe_to_dict(df: pd.DataFrame) -> list[dict]:
def dataframe_to_dict(df: pd.DataFrame) -> List[dict]:
"""Convert to Dataframe to dictionary and alter columns names with;
- Underscores (_) to spaces
- All Strings are converted to Title Case.
Expand Down
1 change: 1 addition & 0 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

class testing_storage:
query_trace = None
documentation_class = None


def pytest_report_header(config):
Expand Down
26 changes: 26 additions & 0 deletions test/test_11document.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""Tests to cover the document.py file
"""
from test.config import testing_parameters
import pytest
import pytabular as p
import os
from pytabular import logic_utils
from test.conftest import testing_storage


@pytest.mark.parametrize("model", testing_parameters)
def test_basic_document_funcionality(model):
try:
docs = p.ModelDocumenter(model=model)
docs.generate_documentation_pages()
docs.save_documentation()
testing_storage.documentation_class = docs
except Exception:
pytest.fail("Unsuccessful documentation generation..")


def test_basic_documentation_removed():
docs_class = testing_storage.documentation_class
remove = f"{docs_class.save_location}/{docs_class.friendly_name}"
logic_utils.remove_folder_and_contents(remove)
assert os.path.exists(remove) is False