Skip to content
This repository was archived by the owner on Oct 17, 2024. It is now read-only.

Do not remove space before .ext #61

Merged
merged 3 commits into from
Oct 14, 2024
Merged
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
31 changes: 17 additions & 14 deletions rust/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pub fn fix(
return;
}
let table = &mut table_element.unwrap().first().unwrap().borrow_mut();
let re = Regex::new(r" \.(\W)").unwrap();
expand_entry_points_inline_tables(table);
for_entries(table, &mut |key, entry| match key.split('.').next().unwrap() {
"name" => {
Expand All @@ -36,18 +37,20 @@ pub fn fix(
}
"description" => {
update_content(entry, |s| {
s.trim()
.lines()
.map(|part| {
part.trim()
.split(char::is_whitespace)
.filter(|part| !part.trim().is_empty())
.collect::<Vec<&str>>()
.join(" ")
.replace(" .", ".")
})
.collect::<Vec<String>>()
.join(" ")
re.replace_all(
&s.trim()
.lines()
.map(|part| {
part.split_whitespace()
.filter(|part| !part.trim().is_empty())
.collect::<Vec<&str>>()
.join(" ")
})
.collect::<Vec<String>>()
.join(" "),
".$1",
)
.to_string()
});
}
"requires-python" => {
Expand Down Expand Up @@ -659,10 +662,10 @@ mod tests {
(3, 13),
)]
#[case::project_description_whitespace(
"[project]\ndescription = ' A magic stuff \t is great\t\t.\r\n Like really .\t\'\nrequires-python = '==3.12'",
"[project]\ndescription = ' A magic stuff \t is great\t\t.\r\n Like really . Works on .rst and .NET :)\t\'\nrequires-python = '==3.12'",
indoc ! {r#"
[project]
description = "A magic stuff is great. Like really."
description = "A magic stuff is great. Like really. Works on .rst and .NET :)"
requires-python = "==3.12"
classifiers = [
"Programming Language :: Python :: 3 :: Only",
Expand Down