Compare commits
9 Commits
867686fe98
...
9ed70b317d
Author | SHA1 | Date | |
---|---|---|---|
9ed70b317d | |||
739ac17b02 | |||
cc6c9bd0db | |||
edec2cb929 | |||
1fea13d053 | |||
b867f333a1 | |||
1e508eeace | |||
7ce680b112 | |||
81f4bd8d41 |
26
Jenkinsfile
vendored
Normal file
26
Jenkinsfile
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
pipeline {
|
||||
agent any
|
||||
stages {
|
||||
stage("install") {
|
||||
steps {
|
||||
sh 'conda env update --file environment.yml'
|
||||
sh 'echo "conda activate renamebycsv" >> ~/.bashrc'
|
||||
}
|
||||
}
|
||||
stage("build") {
|
||||
steps {
|
||||
sh "python -m build"
|
||||
}
|
||||
}
|
||||
stage("publish") {
|
||||
when {
|
||||
branch '**/master'
|
||||
}
|
||||
steps {
|
||||
withCredentials([usernamePassword(credentialsId: 'rs-git-package-registry-ydeng', passwordVariable: 'PASS', usernameVariable: 'USER')]) {
|
||||
sh "python -m twine upload --repository-url https://git.reslate.systems/api/packages/${USER}/pypi -u ${USER} -p ${PASS} --non-interactive --disable-progress-bar --verbose dist/*"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
21
LICENSE
Normal file
21
LICENSE
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) [year] [fullname]
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
11
environment.yml
Normal file
11
environment.yml
Normal file
@ -0,0 +1,11 @@
|
||||
name: renamebycsv
|
||||
channels:
|
||||
- anaconda
|
||||
- conda-forge
|
||||
dependencies:
|
||||
- build=0.7.0
|
||||
- pytest=7.2.2
|
||||
- python=3.11.3
|
||||
- setuptools=67.6.1
|
||||
- twine=4.0.2
|
||||
- cryptography=38.0.4
|
3
pyproject.toml
Normal file
3
pyproject.toml
Normal file
@ -0,0 +1,3 @@
|
||||
[build-system]
|
||||
build-backend = "setuptools.build_meta"
|
||||
requires = ["setuptools", "wheel"]
|
@ -31,6 +31,7 @@ def rename(
|
||||
current: str,
|
||||
become: str,
|
||||
dry: bool,
|
||||
keep_extension: bool,
|
||||
):
|
||||
replacement_dict = {}
|
||||
with open(csv_path, "r") as csv_fd:
|
||||
@ -54,6 +55,8 @@ def rename(
|
||||
os.path.dirname(subitem_path),
|
||||
re.sub(match.re, replacement_dict[match.group(1)], subitem),
|
||||
)
|
||||
if keep_extension:
|
||||
objective += os.path.splitext(subitem_path)[1]
|
||||
logging.info(f'Will rename "{original}" to "{os.path.basename(objective)}"')
|
||||
if os.path.exists(objective):
|
||||
logging.error(
|
||||
@ -119,6 +122,13 @@ def main():
|
||||
type=str,
|
||||
default="INFO",
|
||||
)
|
||||
argparser.add_argument(
|
||||
"-k",
|
||||
"--keep-extension",
|
||||
help="Keeps the original file's extension by appending it to the end of the "
|
||||
"name defined by the CSV.",
|
||||
action="store_true",
|
||||
)
|
||||
|
||||
args = argparser.parse_args()
|
||||
logging.basicConfig(
|
||||
@ -126,7 +136,9 @@ def main():
|
||||
level=args.verbosity.upper(),
|
||||
)
|
||||
candidates = find_all_candidates(args.input_dir, args.regex, args.recursive)
|
||||
rename(args.csv, candidates, args.current, args.become, args.dry)
|
||||
rename(
|
||||
args.csv, candidates, args.current, args.become, args.dry, args.keep_extension
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
10
setup.cfg
Normal file
10
setup.cfg
Normal file
@ -0,0 +1,10 @@
|
||||
[metadata]
|
||||
name = renamebycsv
|
||||
version = 0.0.1
|
||||
|
||||
[options]
|
||||
packages = renamebycsv
|
||||
|
||||
[options.entry_points]
|
||||
console_scripts =
|
||||
renamebycsv = renamebycsv.renamebycsv:main
|
Loading…
Reference in New Issue
Block a user