whitespace-format 0.0.4__py3-none-any.whl → 0.0.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: whitespace-format
3
- Version: 0.0.4
3
+ Version: 0.0.5
4
4
  Summary: Linter and formatter for source code files and text files
5
5
  Home-page: https://github.com/DavidPal/whitespace-format
6
6
  License: MIT
@@ -14,6 +14,7 @@ Classifier: Programming Language :: Python :: 3.8
14
14
  Classifier: Programming Language :: Python :: 3.9
15
15
  Classifier: Programming Language :: Python :: 3.10
16
16
  Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
17
18
  Project-URL: Repository, https://github.com/DavidPal/whitespace-format
18
19
  Description-Content-Type: text/markdown
19
20
 
@@ -61,17 +62,18 @@ whitespace-format \
61
62
  --normalize-new-line-markers \
62
63
  foo.txt my_project/
63
64
  ```
64
- The command above formats `foo.txt` and all files contained `my_project/` and
65
- its subdirectories. Files that contain `.git/` or `.idea/` in their (relative)
66
- path are excluded. For example, files in `my_project/.git/` and files in
67
- `my_project/.idea/` are excluded. Likewise, files ending with `*.pyc` are
68
- excluded.
69
-
70
- If you want only know if any changes **would be** made, add `--check-only` option:
65
+ The command above formats `foo.txt` and all files contained in `my_project/`
66
+ directory and its subdirectories. Files that contain `.git/` or `.idea/` in
67
+ their (relative) path are excluded. For example, files in `my_project/.git/`
68
+ and files in `my_project/.idea/` are excluded. Likewise, files ending with
69
+ `*.pyc` are excluded.
70
+
71
+ If you want to know only if any changes **would be** made, add `--check-only`
72
+ option:
71
73
  ```shell
72
74
  whitespace-format \
73
- --exclude ".git/|.idea/|.pyc$" \
74
75
  --check-only \
76
+ --exclude ".git/|.idea/|.pyc$" \
75
77
  --new-line-marker linux \
76
78
  --normalize-new-line-markers \
77
79
  foo.txt my_project/
@@ -96,7 +98,7 @@ The regular expression is evaluated on the path of each file.
96
98
  This option is ignored when `--add-new-line-marker-at-end-of-file` is used.
97
99
  Empty lines at the end of the file are removed.
98
100
  * `--normalize-new-line-markers` -- Make new line markers consistent in each file
99
- by replacing `\\r\\n`, `\\n`, and `\r` with a consistent new line marker.
101
+ by replacing `\r\n`, `\n`, and `\r` with a consistent new line marker.
100
102
  * `--remove-trailing-whitespace` -- Remove whitespace at the end of each line.
101
103
  * `--remove-trailing-empty-lines` -- Remove empty lines at the end of each file.
102
104
  * `--new-line-marker=MARKER` -- This option specifies what new line marker to use.
@@ -104,9 +106,9 @@ by replacing `\\r\\n`, `\\n`, and `\r` with a consistent new line marker.
104
106
  * `auto` -- Use new line marker that is the most common in each individual file.
105
107
  If no new line marker is present in the file, Linux `\n` is used.
106
108
  This is the default option.
107
- * `linux` -- Use Linux new line marker `\\n`.
108
- * `mac` -- Use Mac new line marker `\\r`.
109
- * `windows` -- Use Windows new line marker `\\r\\n`.
109
+ * `linux` -- Use Linux new line marker `\n`.
110
+ * `mac` -- Use Mac new line marker `\r`.
111
+ * `windows` -- Use Windows new line marker `\r\n`.
110
112
  * `--encoding` -- Text encoding for both reading and writing files. Default encoding is `utf-8`.
111
113
  List of supported encodings can be found at
112
114
  https://docs.python.org/3/library/codecs.html#standard-encodings
@@ -161,7 +163,7 @@ Default value is `-1`.
161
163
 
162
164
  * `--normalize-non-standard-whitespace=MODE` -- Replace or remove
163
165
  non-standard whitespace characters (`\v` and `\f`). `MODE` must be one of the following:
164
- * `ignore` -- Leave `\v` and `f` as is. This is the default option.
166
+ * `ignore` -- Leave `\v` and `\f` as is. This is the default option.
165
167
  * `replace` -- Replace any occurrence of `\v` or `\f` with a single space.
166
168
  * `remove` -- Remove all occurrences of `\v` and `\f`
167
169
 
@@ -181,13 +183,7 @@ MIT
181
183
  brew install poetry
182
184
  ```
183
185
 
184
- 3) Create Python virtual environment with the correct Python version:
185
- ```shell
186
- make install-python
187
- make create-environment
188
- ```
189
-
190
- 4) Add the following lines to `.zshrc` or `.bash_profile` and restart the terminal:
186
+ 3) Add the following lines to `.zshrc` or `.bash_profile` and restart the terminal:
191
187
  ```shell
192
188
  # Pyenv settings
193
189
  export PYENV_ROOT="$HOME/.pyenv"
@@ -196,6 +192,12 @@ MIT
196
192
  eval "$(pyenv virtualenv-init -)"
197
193
  ```
198
194
 
195
+ 4) Create Python virtual environment with the correct Python version:
196
+ ```shell
197
+ make install-python
198
+ make create-environment
199
+ ```
200
+
199
201
  5) Install all dependencies
200
202
  ```shell
201
203
  make install-dependecies
@@ -0,0 +1,6 @@
1
+ whitespace_format.py,sha256=uqu0SZ76nyFGEDX6gMIyLZpmVv_rtJRx0IjcEC601Cs,26016
2
+ whitespace_format-0.0.5.dist-info/LICENSE,sha256=rT6UNfWDYFQc-eo65FioDJRMAyVOndtF95wNCUhkK74,1076
3
+ whitespace_format-0.0.5.dist-info/METADATA,sha256=Pq-GTLKbXw9u6uj7CGwItBpi15yDrOdjSyTXVzdnuVU,10233
4
+ whitespace_format-0.0.5.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
5
+ whitespace_format-0.0.5.dist-info/entry_points.txt,sha256=LbXoevzUZAF5MVbI2foNC9xeDjKS_Woz7VbA1ZNF5CY,60
6
+ whitespace_format-0.0.5.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 1.7.0
2
+ Generator: poetry-core 1.9.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
whitespace_format.py CHANGED
@@ -22,7 +22,7 @@ from typing import Callable
22
22
  from typing import Dict
23
23
  from typing import List
24
24
 
25
- VERSION = "0.0.4"
25
+ VERSION = "0.0.5"
26
26
 
27
27
  # Regular expression that does NOT match any string.
28
28
  UNMATCHABLE_REGEX = "$."
@@ -72,6 +72,14 @@ def color_print(message: str, parsed_arguments: argparse.Namespace):
72
72
  print(message)
73
73
 
74
74
 
75
+ def string_to_hex(text: str) -> str:
76
+ """Converts a string into a human-readable hexadecimal representation.
77
+
78
+ This function is for debugging purposes only. It is used only during development.
79
+ """
80
+ return ":".join(f"{ord(character):02x}" for character in text)
81
+
82
+
75
83
  def die(error_code: int, message: str = ""):
76
84
  """Exits the script."""
77
85
  if message:
@@ -82,7 +90,7 @@ def die(error_code: int, message: str = ""):
82
90
  def read_file_content(file_name: str, encoding: str) -> str:
83
91
  """Reads content of a file."""
84
92
  try:
85
- with open(file_name, "r", encoding=encoding) as file:
93
+ with open(file_name, "r", encoding=encoding, newline="") as file:
86
94
  return file.read()
87
95
  except IOError as exception:
88
96
  die(2, f"Cannot read file '{file_name}': {exception}")
@@ -123,6 +131,13 @@ class Line:
123
131
  return Line(line[: -len(end_of_line_marker)], end_of_line_marker)
124
132
  return Line(line, "")
125
133
 
134
+ def to_hex(self):
135
+ """Returns a human-readable hexadecimal representation of the line.
136
+
137
+ This function is for debugging purposes only. It is used only during development.
138
+ """
139
+ return f"({string_to_hex(self.content)}, {string_to_hex(self.end_of_line_marker)})"
140
+
126
141
 
127
142
  def split_lines(text: str) -> List[Line]:
128
143
  """Splits a string into lines."""
@@ -1,6 +0,0 @@
1
- whitespace_format.py,sha256=cSM_YnzCNsJjPGz-b9HVINv3TT8YK8C51m5RePwPNCk,25434
2
- whitespace_format-0.0.4.dist-info/LICENSE,sha256=rT6UNfWDYFQc-eo65FioDJRMAyVOndtF95wNCUhkK74,1076
3
- whitespace_format-0.0.4.dist-info/METADATA,sha256=Dk2GpHPm2ll_EvKpMxFCP86MCyU49rkYr43wBkZ7D7Q,10172
4
- whitespace_format-0.0.4.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
5
- whitespace_format-0.0.4.dist-info/entry_points.txt,sha256=LbXoevzUZAF5MVbI2foNC9xeDjKS_Woz7VbA1ZNF5CY,60
6
- whitespace_format-0.0.4.dist-info/RECORD,,