Skip to content

Commit 31765e4

Browse files
Add fixes from code review
1 parent 2f79422 commit 31765e4

File tree

2 files changed

+7
-16
lines changed

2 files changed

+7
-16
lines changed

plugins/modules/file_remove.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/python
2-
# -*- coding: utf-8 -*-
32

43
# Copyright (c) 2025, Shahar Golshani (@shahargolshani)
54
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
@@ -15,21 +14,22 @@
1514
1615
description:
1716
- This module removes files from a specified directory that match a given pattern.
18-
- The pattern can include wildcards and regular expressions.
17+
The pattern can include wildcards and regular expressions.
1918
- By default, only files in the specified directory are removed (non-recursive).
20-
- Use the O(recursive) option to search and remove files in subdirectories.
19+
Use the O(recursive) option to search and remove files in subdirectories.
2120
2221
version_added: "12.1.0"
2322
2423
author:
2524
- Shahar Golshani (@shahargolshani)
2625
26+
extends_documentation_fragment:
27+
- community.general.attributes
28+
2729
attributes:
2830
check_mode:
29-
description: Can run in check_mode and return changed status without modifying the target.
3031
support: full
3132
diff_mode:
32-
description: Will return details on what has changed (or possibly needs changing in check_mode).
3333
support: full
3434
3535
options:
@@ -43,7 +43,7 @@
4343
pattern:
4444
description:
4545
- Pattern to match files for removal.
46-
- Supports wildcards (*, ?, [seq], [!seq]) for glob-style matching.
46+
- Supports wildcards (V(*), V(?), V([seq]), V([!seq])) for glob-style matching.
4747
- Use O(use_regex=true) to interpret this as a regular expression instead.
4848
type: str
4949
required: true
@@ -64,7 +64,6 @@
6464
6565
file_type:
6666
description:
67-
- Type of files to remove.
6867
- V(file) - remove only regular files.
6968
- V(link) - remove only symbolic links.
7069
- V(any) - remove both files and symbolic links.
@@ -123,12 +122,6 @@
123122
returned: always
124123
sample: 2
125124
126-
msg:
127-
description: Status message.
128-
type: str
129-
returned: always
130-
sample: "Removed 2 files matching pattern '*.log'"
131-
132125
path:
133126
description: The directory path that was searched.
134127
type: str
@@ -252,7 +245,7 @@ def main():
252245
try:
253246
re.compile(pattern)
254247
except re.error as e:
255-
module.fail_json(msg=f"Invalid regular expression pattern: {to_native(e)}")
248+
module.fail_json(msg=f"Invalid regular expression pattern: {e}")
256249

257250
# Find matching files
258251
try:

tests/integration/targets/file_remove/aliases

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,3 @@
33
# SPDX-License-Identifier: GPL-3.0-or-later
44

55
azp/posix/3
6-
destructive
7-

0 commit comments

Comments
 (0)