Skip to content

Commit

Permalink
Merge pull request #44 from keyhr/master
Browse files Browse the repository at this point in the history
Merge updates.
  • Loading branch information
cacharle committed Jan 2, 2023
2 parents bbcf19a + de86f3c commit 234bb61
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-package-develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-11]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ docs/build/
/.venv
/debug
/.vimspector.json

.vscode
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ It's just for convenience.

## Installation

Requires Python 3.6+ (3.7, 3.8, 3.9, 3.10)
Requires Python3.7+ (3.8, 3.9, 3.10, 3.11)

### From PyPI

Expand Down Expand Up @@ -54,7 +54,7 @@ positional arguments:

optional arguments:
-h, --help show this help message and exit
-c, --confirm Ask confirmation before overwritting any file
-c, --confirm Ask confirmation before overwriting any file
```

## Plugins / Extensions
Expand Down
4 changes: 2 additions & 2 deletions c_formatter_42/__main__.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def main():
"-c",
"--confirm",
action="store_true",
help="Ask confirmation before overwritting any file",
help="Ask confirmation before overwriting any file",
)
arg_parser.add_argument(
"filepaths",
Expand All @@ -52,7 +52,7 @@ def main():
)
if result != "y":
continue
print("Writting to {}".format(filepath))
print("Writing to {}".format(filepath))
with open(filepath, "w") as file:
file.write(run_all(content))
except OSError as e:
Expand Down
9 changes: 9 additions & 0 deletions c_formatter_42/formatters/preprocessor_directive.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,13 @@ def preprocessor_directive(content: str) -> str:
indent += 1
if directive_name == "endif":
indent -= 1

# if newline doesn't follows preprocessor part, insert one
lastline_index = idented[-1][0]
try:
if lines[lastline_index + 1] != "":
lines.insert(lastline_index + 1, "")
except IndexError:
pass

return "\n".join(lines)
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ url = https://github.com/dawnbeen/c_formatter_42
project_urls =
Tracker = https://github.com/dawnbeen/c_formatter_42/issues
classifiers =
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: C
Intended Audience :: Developers
Environment :: Console
Expand All @@ -22,7 +22,7 @@ classifiers =
[options]
packages = find:
python_requires = >=3.6
python_requires = >=3.7
[options.package_data]
* =
Expand Down
14 changes: 14 additions & 0 deletions tests/formatters/test_preprocessor_directive.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,17 @@ def test_preprocessor_directive_nested_10():
#endif
"""
assert output == preprocessor_directive(input)


def test_preprocessor_1():
input = """
#include "libft.h"
void *ft_function(char c)
"""
output = """
#include "libft.h"
void *ft_function(char c)
"""
assert output == preprocessor_directive(input)
assert output == preprocessor_directive(preprocessor_directive(input))
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = python3.6,python3.7,python3.8,python3.9,python3.10
envlist = python3.7,python3.8,python3.9,python3.10,python3.11
distshare = {env:XDG_CACHE_HOME}/tox/distshare

[testenv]
Expand Down

0 comments on commit 234bb61

Please sign in to comment.