-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add
newlineFormatOS()
to handle newline for Windows & macOS
- Loading branch information
1 parent
5978982
commit 9d56847
Showing
4 changed files
with
102 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,23 @@ | ||
import os | ||
|
||
def bool_yesno(x: bool) -> str: | ||
return "Yes" if x else "No" | ||
|
||
def dash_if_blank(x: str) -> str: | ||
return "-" if x == "" else x | ||
return "-" if x == "" else x | ||
|
||
|
||
def newlineFormatOS(text): | ||
""" | ||
Adjusts the newline characters in the given text to match the operating system's format. | ||
Parameters: | ||
text (str): The input text with newlines. | ||
Returns: | ||
str: The text with adjusted newline characters. | ||
""" | ||
if os.name == 'nt': # Windows | ||
return text.replace('\n', '\r\n') | ||
else: # macOS and other Unix-based systems | ||
return text.replace('\r\n', '\n') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters