Skip to content

Commit

Permalink
minor updates based on pr-294
Browse files Browse the repository at this point in the history
  • Loading branch information
dmichaels-harvard committed Dec 11, 2023
1 parent 9939474 commit 367a51b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions dcicutils/data_readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import csv
import openpyxl
from typing import Any, Generator, Iterator, List, Optional, Type, Tuple, Union
from dcicutils.misc_utils import create_object, right_trim
from dcicutils.misc_utils import create_dict, right_trim

# Forward type references for type hints.
Excel = Type["Excel"]
Expand Down Expand Up @@ -59,11 +59,11 @@ def file(self) -> Optional[str]:
def warnings(self) -> List[str]:
warnings = []
if self._warning_empty_headers:
warnings.append({"src": create_object(file=self.file),
warnings.append({"src": create_dict(file=self.file),
"warning": "Empty header column encountered; ignoring it and all subsequent columns."})
if self._warning_extra_values:
for row_number in self._warning_extra_values:
warnings.append({"src": create_object(file=self.file, row=row_number),
warnings.append({"src": create_dict(file=self.file, row=row_number),
"warning": f"Extra row column values."})
return warnings

Expand Down
2 changes: 1 addition & 1 deletion dcicutils/misc_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1501,7 +1501,7 @@ def right_trim(list_or_tuple: Union[List[Any], Tuple[Any]],
return list_or_tuple[:i + 1]


def create_object(**kwargs) -> dict:
def create_dict(**kwargs) -> dict:
result = {}
for name in kwargs:
if kwargs[name]:
Expand Down
8 changes: 4 additions & 4 deletions dcicutils/structured_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from webtest.app import TestApp
from dcicutils.common import OrchestratedApp
from dcicutils.data_readers import CsvReader, Excel, RowReader
from dcicutils.misc_utils import (create_object, load_json_if, merge_objects, remove_empty_properties, right_trim,
from dcicutils.misc_utils import (create_dict, load_json_if, merge_objects, remove_empty_properties, right_trim,
split_string, to_boolean, to_enum, to_float, to_integer, VirtualApp)
from dcicutils.portal_utils import Portal as PortalBase
from dcicutils.zip_utils import unpack_gz_file_to_temporary_file, unpack_files
Expand Down Expand Up @@ -71,7 +71,7 @@ def validate(self, force: bool = False) -> None:
row_number += 1
if (validation_errors := schema.validate(data)) is not None:
for validation_error in validation_errors:
self._note_error({"src": create_object(type=schema.name, row=row_number),
self._note_error({"src": create_dict(type=schema.name, row=row_number),
"error": validation_error}, "validation")

@property
Expand Down Expand Up @@ -204,8 +204,8 @@ def create_row(self) -> dict:

def set_value(self, data: dict, column_name: str, value: str, file: Optional[str], row_number: int = -1) -> None:
if (set_value_function := self._set_value_functions.get(column_name)):
src = create_object(type=self._schema.name if self._schema else None,
column=column_name, file=file, row=row_number)
src = create_dict(type=self._schema.name if self._schema else None,
column=column_name, file=file, row=row_number)
set_value_function(data, value, src)

def _create_row_template(self, column_names: List[str]) -> dict: # Surprisingly tricky code here.
Expand Down

0 comments on commit 367a51b

Please sign in to comment.