Compare commits

...

9 Commits

Author SHA1 Message Date
9ed70b317d Jenkins pipeline now only publishes when on main branch
Some checks failed
ydeng/renamebycsv/pipeline/head There was a failure building this commit
2023-04-08 13:14:45 -05:00
739ac17b02 Fixed pipeline publishing stage
Some checks failed
ydeng/renamebycsv/pipeline/head There was a failure building this commit
2023-04-08 12:51:38 -05:00
cc6c9bd0db Downgraded environment cryptography package
Some checks failed
ydeng/renamebycsv/pipeline/head There was a failure building this commit
2023-04-08 05:55:09 -05:00
edec2cb929 Fixed Jenkinsfile
Some checks failed
ydeng/renamebycsv/pipeline/head There was a failure building this commit
2023-04-08 05:45:31 -05:00
1fea13d053 Change image to debian
Some checks failed
ydeng/renamebycsv/pipeline/head There was a failure building this commit
2023-04-08 05:38:47 -05:00
b867f333a1 Changed to using mamba environment 2023-04-08 05:36:11 -05:00
1e508eeace Added package configurations and Woodpecker CI pipeline
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2023-04-06 00:52:05 -05:00
7ce680b112 Added option to retain original file extensions 2023-04-06 00:40:28 -05:00
81f4bd8d41 Added a license and restructured folders 2023-04-05 16:19:32 -05:00
7 changed files with 86 additions and 1 deletions

26
Jenkinsfile vendored Normal file
View 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
View 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
View 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
View File

@ -0,0 +1,3 @@
[build-system]
build-backend = "setuptools.build_meta"
requires = ["setuptools", "wheel"]

View File

@ -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
View File

@ -0,0 +1,10 @@
[metadata]
name = renamebycsv
version = 0.0.1
[options]
packages = renamebycsv
[options.entry_points]
console_scripts =
renamebycsv = renamebycsv.renamebycsv:main

2
setup.py Normal file
View File

@ -0,0 +1,2 @@
from setuptools import setup
setup()