Skip to content

Commit

Permalink
fix the last of the test asserts and clean up extra code
Browse files Browse the repository at this point in the history
  • Loading branch information
pnadolny13 committed Jul 27, 2023
1 parent 729cbb2 commit 039171f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 47 deletions.
45 changes: 1 addition & 44 deletions hub_utils/meltano_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ def _capitalize(cleaned_sentence):
for elem in capital_list:
sentence_list = elem.split()
last_elem = MeltanoUtil._last_element(clean_capital_list)
if sentence_list[0][0].isupper() or last_elem.endswith('e.g') or last_elem.endswith('i.e'):
if sentence_list[0][0].isupper() or sentence_list[0][0] == "'" or last_elem.endswith('e.g') or last_elem.endswith('i.e'):
clean_capital_list.append(" ".join(sentence_list))
else:
sentence_list[0] = sentence_list[0].capitalize()
Expand All @@ -416,46 +416,3 @@ def _clean_description(description):
cleaned_sentence = MeltanoUtil._split_sentence_endings(desc_list)
cleaned_description = MeltanoUtil._capitalize(cleaned_sentence)
return cleaned_description

# desc_list_clean = [elem for elem in ]
description = description.replace(".", ". ")



# Upper case the first letter of the description in each sentence
description = MeltanoUtil._upper_case_first_letter(description)




# Split the description by periods and commas, and preserve them in the result
split_description = description.split()
split_description = [
elem.replace(".", ". ").replace(",", ", ")
if not any(keyword in elem for keyword in ("http", "ssh", "ssl", "e.g."))
else elem
for elem in split_description
]
split_description = " ".join(split_description).split()

# Capitalize the first word of each sentence
for i in range(len(split_description)):
if i == 0 or (
i > 0
and (
split_description[i - 1].endswith(".")
)
):
if not split_description[i][0].isupper():
split_description[i] = split_description[i].capitalize()

# Join the cleaned description back into a single string
cleaned_description = " ".join(split_description)

return cleaned_description


if __name__ == "__main__":
MeltanoUtil()._clean_description("By providing a path-like prefix (e.g. myFolder/thisTable/) under which all the relevant files sit, we.")
# MeltanoUtil()._clean_description("a sentence.with bad punctuation.Starts here. with another sentence. Being poorly written. checkout this link <a href=\"https://json-schema.org/understanding-json-schema/reference/type.html\" target=\"_blank\">JSON Schema datatypes</a>.")
# MeltanoUtil()._clean_description("Optionally provide a schema to enforce, as a valid JSON string. Ensure this is a mapping of <strong>{ \"column\" : \"type\" }</strong>, where types are valid <a href=\"https://json-schema.org/understanding-json-schema/reference/type.html\" target=\"_blank\">JSON Schema datatypes</a>. Leave as {} to auto-infer the schema.")
8 changes: 5 additions & 3 deletions tests/test_meltano_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,15 @@ def test_sdk_about_parsing_airbyte():
"name": "connector_config.provider.path_prefix",
"label": "Connector Config Provider Path Prefix",
"description": "By providing a path-like prefix (e.g. myFolder/thisTable/) under which all the relevant files sit, we can optimize finding these in S3. This is optional but recommended if your bucket contains many folders/files which you don't need to replicate.",
"kind": "password"
"kind": "password",
"value": ""
},
{
"name": "connector_config.provider.endpoint",
"label": "Connector Config Provider Endpoint",
"description": "Endpoint to an S3 compatible service. Leave empty to use AWS.",
"kind": "password"
"kind": "password",
"value": ""
},
{
"name": "stream_maps",
Expand Down Expand Up @@ -243,7 +245,7 @@ def test_sdk_about_parsing_airbyte():
}
]
for i, setting in enumerate(settings):
assert setting == expected_settings[i]
assert setting == expected_settings[i], setting
assert set(settings_group_validation[0]) == set(
[
"airbyte_spec.image",
Expand Down

0 comments on commit 039171f

Please sign in to comment.