From 64204b561db738fb006c5b549b620cb6aceb2fd6 Mon Sep 17 00:00:00 2001 From: Harrison Date: Fri, 21 Apr 2023 15:20:59 -0500 Subject: [PATCH 1/2] Added some information about usage in README.md --- README.md | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 232d46d..ceed2c3 100644 --- a/README.md +++ b/README.md @@ -6,4 +6,26 @@ A simple program that renames files by using a spreadsheet in CSV format as a di - Rename files recursively within a directory to a desired string - Desired string is set by a CSV where one column is the original string, and another column is the string to replace the original string with - - Uses a REGEX capture group to select file and the portion of the filename to rename \ No newline at end of file + - Uses a REGEX capture group to select file and the portion of the filename to rename + +## Installing using `pip` + +1. Run `pip install --index-url https://git.reslate.systems/api/packages/ydeng/pypi/simple renamebycsv` in any `python3` enabled terminal. + +2. Run `renamebycsv -h` to see the help and confirm installation was successful. + + +## Advanced Usage: What is REGEX? + +This program makes heavy use of REGEX, also known as Regular Expression to give users the flexibility to choose which portion of any given filename should be the portion used by the program to look up in the CSV. It is therefore critical for users of this script to understand how REGEX works. Here are some key pointers to get you started: + + - REGEX works by matching one string to another, this is just like if you used any in-text search function. + - Where it differs is the ability to use one REGEX string to match many strings. + - i.e, the REGEX "`abc\d+`" will match with "`abc1`", "`abc2`", "`abc12`", but not "`ac12`" or "`abc`". + - Many characters can be used as normal and will match a string literally (character for character), but some will be treated as special characters (such as the previously used `\`, which indicates that the letter afterwards should be treated specially, such as a token) + - Common tokens to be aware of: `.` for any character, `\d` for single digits, `\w` for word characters, `\s` for space characters (tabs, spaces, linebreaks, etc.). Tokens can be repeated by using `+`, indicating "one or more", `*` indicating "none or more". + - A capture group is a way of "selecting" a part of a text and is formed by using `(` and `)` around the REGEX that should be selected. + + Now for a few examples: + +Let's say we have files `run325-a-1.vcf`, `run326-b-2.vcf`, and `run327-b-3.vcf`. If we know that all that matters is the `1` after the `run[numbers]-[character]-`, we can write `run\d+-\w-(\d).vcf` which will match with all 3 of the above examples, and select the last digit. The program can then use a given CSV to look up the selected digits and replace the name with what is given by the CSV. \ No newline at end of file From 286ca0b5a54d42b45a8a7a624422e1c6b00eb5e1 Mon Sep 17 00:00:00 2001 From: Harrison Date: Sat, 22 Apr 2023 16:37:03 -0500 Subject: [PATCH 2/2] Added step to test installation --- Jenkinsfile | 1 + renamebycsv/{renamebycsv.py => cli.py} | 0 setup.cfg | 2 +- 3 files changed, 2 insertions(+), 1 deletion(-) rename renamebycsv/{renamebycsv.py => cli.py} (100%) diff --git a/Jenkinsfile b/Jenkinsfile index 1460814..dd10be4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -20,6 +20,7 @@ pipeline { stage("test") { steps { sh "pip install dist/*.whl" + sh "renamebycsv -h" } } stage("archive") { diff --git a/renamebycsv/renamebycsv.py b/renamebycsv/cli.py similarity index 100% rename from renamebycsv/renamebycsv.py rename to renamebycsv/cli.py diff --git a/setup.cfg b/setup.cfg index ca39691..35b0cf0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -7,4 +7,4 @@ packages = renamebycsv [options.entry_points] console_scripts = - renamebycsv = renamebycsv.renamebycsv:main \ No newline at end of file + renamebycsv = renamebycsv.cli:main \ No newline at end of file