Compare commits

..

No commits in common. "7bab8a9436341467ffacd175159e0b7a0abe9de4" and "4bea0eb15e01ec0139c64426e2f40966987a9273" have entirely different histories.

12 changed files with 3 additions and 47 deletions

23
.vscode/launch.json vendored
View File

@ -1,23 +0,0 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Module",
"type": "python",
"request": "launch",
"module": "renamebycsv.cli",
"args": [
"${workspaceFolder}/tests/resources/files",
"group\\d+-\\w-(\\d+)\\.txt",
"${workspaceFolder}/tests/resources/groups.csv",
"target",
"replaced",
"-d"
],
"justMyCode": true
}
]
}

2
Jenkinsfile vendored
View File

@ -19,7 +19,7 @@ pipeline {
} }
stage("test") { stage("test") {
steps { steps {
sh "pip install dist/*.whl --force-reinstall" sh "pip install dist/*.whl"
sh "renamebycsv -h" sh "renamebycsv -h"
} }
} }

View File

@ -50,17 +50,10 @@ def rename(
raise Exception("Duplicate current key.") raise Exception("Duplicate current key.")
replacement_dict[row[current_col_ind]] = row[become_col_ind] replacement_dict[row[current_col_ind]] = row[become_col_ind]
for subitem_path, subitem, match in candidates: for subitem_path, subitem, match in candidates:
if match.group(1) not in replacement_dict:
logging.warning(
'Group "%s" was not matched to any row in the provided CSV. '
"Skipping...",
match.group(1)
)
continue
original = subitem_path original = subitem_path
objective = os.path.join( objective = os.path.join(
os.path.dirname(subitem_path), os.path.dirname(subitem_path),
re.sub(match.re, replacement_dict[match.group(1)], subitem.strip()), re.sub(match.re, replacement_dict[match.group(1)], subitem),
) )
if keep_extension: if keep_extension:
objective += os.path.splitext(subitem_path)[1] objective += os.path.splitext(subitem_path)[1]

View File

@ -1,6 +1,6 @@
[metadata] [metadata]
name = renamebycsv name = renamebycsv
version = 0.0.4 version = 0.0.3
[options] [options]
packages = renamebycsv packages = renamebycsv

View File

@ -1 +0,0 @@
Text

View File

@ -1,2 +0,0 @@
Text

View File

@ -1 +0,0 @@
Text

View File

@ -1 +0,0 @@
Text

View File

@ -1 +0,0 @@
Text

View File

@ -1 +0,0 @@
Text

View File

@ -1 +0,0 @@
Text

View File

@ -1,6 +0,0 @@
target,replaced
9,a
10,b
11,c
12,d
13,e
1 target replaced
2 9 a
3 10 b
4 11 c
5 12 d
6 13 e