Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
EugeneTorap committed Nov 14, 2022
1 parent 6a5c2ff commit 653f818
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 12 deletions.
3 changes: 2 additions & 1 deletion superset/charts/commands/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
from superset.datasets.commands.export import ExportDatasetsCommand
from superset.commands.export.models import ExportModelsCommand
from superset.models.slice import Slice
from superset.utils.dict_import_export import EXPORT_VERSION, get_filename
from superset.utils.dict_import_export import EXPORT_VERSION
from superset.utils.file import get_filename

logger = logging.getLogger(__name__)

Expand Down
3 changes: 2 additions & 1 deletion superset/dashboards/commands/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
from superset.datasets.dao import DatasetDAO
from superset.models.dashboard import Dashboard
from superset.models.slice import Slice
from superset.utils.dict_import_export import EXPORT_VERSION, get_filename
from superset.utils.dict_import_export import EXPORT_VERSION
from superset.utils.file import get_filename

logger = logging.getLogger(__name__)

Expand Down
3 changes: 2 additions & 1 deletion superset/databases/commands/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
from superset.databases.dao import DatabaseDAO
from superset.commands.export.models import ExportModelsCommand
from superset.models.core import Database
from superset.utils.dict_import_export import EXPORT_VERSION, get_filename
from superset.utils.dict_import_export import EXPORT_VERSION
from superset.utils.file import get_filename

logger = logging.getLogger(__name__)

Expand Down
3 changes: 2 additions & 1 deletion superset/datasets/commands/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
from superset.connectors.sqla.models import SqlaTable
from superset.datasets.commands.exceptions import DatasetNotFoundError
from superset.datasets.dao import DatasetDAO
from superset.utils.dict_import_export import EXPORT_VERSION, get_filename
from superset.utils.dict_import_export import EXPORT_VERSION
from superset.utils.file import get_filename

logger = logging.getLogger(__name__)

Expand Down
7 changes: 0 additions & 7 deletions superset/utils/dict_import_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from typing import Any, Dict

from sqlalchemy.orm import Session
from werkzeug.utils import secure_filename

from superset.models.core import Database

Expand All @@ -27,12 +26,6 @@
logger = logging.getLogger(__name__)


def get_filename(model_name: str, model_id: int, skip_id: bool = False) -> str:
slug = secure_filename(model_name)
filename = slug if skip_id else f"{slug}_{model_id}"
return filename if slug else str(model_id)


def export_schema_to_dict(back_references: bool) -> Dict[str, Any]:
"""Exports the supported import/export schema to a dictionary"""
databases = [
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# under the License.
import pytest

from superset.utils.import_export import get_filename
from superset.utils.file import get_filename


@pytest.mark.parametrize(
Expand All @@ -29,8 +29,12 @@
("D:\\Charts\\Energy Sankey", 132, True, "DChartsEnergy_Sankey"),
("🥴🥴🥴", 4751, False, "4751"),
("🥴🥴🥴", 4751, True, "4751"),
("Energy Sankey 🥴🥴🥴", 4751, False, "Energy_Sankey_4751"),
("Energy Sankey 🥴🥴🥴", 4751, True, "Energy_Sankey"),
("你好", 475, False, "475"),
("你好", 475, True, "475"),
("Energy Sankey 你好", 475, False, "Energy_Sankey_475"),
("Energy Sankey 你好", 475, True, "Energy_Sankey"),
],
)
def test_get_filename(
Expand Down

0 comments on commit 653f818

Please sign in to comment.