Compare commits

...

3 Commits

Author SHA1 Message Date
7bab8a9436 Added rudimentary VSCode launch for development
All checks were successful
ydeng/renamebycsv/pipeline/head This commit looks good
2023-04-25 09:17:27 -05:00
f31b1b2705 Added check for non-existing keys in CSV dictionary 2023-04-25 09:15:26 -05:00
7b7f6438d4 Test installation now forces reinstall
All checks were successful
ydeng/renamebycsv/pipeline/head This commit looks good
2023-04-24 12:25:55 -05:00
12 changed files with 47 additions and 3 deletions

23
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,23 @@
{
// 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") {
steps {
sh "pip install dist/*.whl"
sh "pip install dist/*.whl --force-reinstall"
sh "renamebycsv -h"
}
}

View File

@ -50,10 +50,17 @@ def rename(
raise Exception("Duplicate current key.")
replacement_dict[row[current_col_ind]] = row[become_col_ind]
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
objective = os.path.join(
os.path.dirname(subitem_path),
re.sub(match.re, replacement_dict[match.group(1)], subitem),
re.sub(match.re, replacement_dict[match.group(1)], subitem.strip()),
)
if keep_extension:
objective += os.path.splitext(subitem_path)[1]

View File

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

View File

@ -0,0 +1 @@
Text

View File

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

View File

@ -0,0 +1 @@
Text

View File

@ -0,0 +1 @@
Text

View File

@ -0,0 +1 @@
Text

View File

@ -0,0 +1 @@
Text

View File

@ -0,0 +1 @@
Text

View File

@ -0,0 +1,6 @@
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