Hua work common - #104
Merged
Merged
Hua work common#104
Conversation
Bug fixes:
- pgpassword.py: call get_pgpassword() (was get_pg_pass() which does not exist)
- pg_log.py: replace two bare except: with KeyError / OSError
- pg_lock.py, pg_split.py: correct header date typos
- pgpassword.py: tighten arg regex so negative numbers are not parsed as flags
Packaging:
- pyproject.toml: declare hvac as a dependency (used by pg_dbi.py / pgpassword)
API cleanup:
- pg_dbi.py: drop meaningless lambda fn=self defaults on the fmt* helpers
Efficiency (~30 sites across pg_util/pg_dbi/pg_log/pg_sig/pg_file/pg_opt):
- re.match(r'^literal', x) -> x.startswith('literal')
- re.match(r'^\d+$', s) -> s.isdigit()
- re.search(r'\n$', s) -> s.endswith('\n')
- re.match(r'^X', fmt, re.I) chain -> precomputed fmt[:1].upper()
- chained range comparisons (a > 0 and a < N) -> 0 < a < N
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Eagerly imports the legacy capitalized submodules so that ``from rda_python_common import PgLOG`` continues to return the module object that existing callers depend on. Documents both the legacy module-based API and the preferred class-based API. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request modernizes and documents the rda_python_common package while aligning the password/credential helpers with the class-based API and OpenBao support.
Changes:
- Added a package-level
__init__.pyto expose legacy (capitalized) modules and a__version__, and expanded README documentation with module hierarchy and usage examples. - Refactored a number of regex-based string checks to simpler
startswith()/endswith()/isdigit()logic across utilities and helpers. - Updated PgSplit to also inherit
PgDBI, bumped the project version to2.1.8, and addedhvacas a dependency.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/rda_python_common/pgpassword.py | Adjusts option parsing regex and switches password fallback to get_pgpassword() |
| src/rda_python_common/pg_util.py | Replaces several regex checks with string methods in date/time utilities |
| src/rda_python_common/pg_split.py | Fixes header date and updates inheritance to include PgDBI |
| src/rda_python_common/pg_sig.py | Replaces re.match('^Job') with startswith('Job') |
| src/rda_python_common/pg_opt.py | Uses isdigit() for numeric option coercion |
| src/rda_python_common/pg_log.py | Uses endswith() for newline checks; narrows exception handling; replaces some regex checks with startswith() |
| src/rda_python_common/pg_lock.py | Fixes header date typo |
| src/rda_python_common/pg_file.py | Uses isdigit() for numeric parsing in a couple of places |
| src/rda_python_common/pg_dbi.py | Fixes SQL format lambdas to accept a field/expression argument; simplifies a lock-code check |
| src/rda_python_common/init.py | Introduces package initializer exposing legacy modules + __version__ |
| README.md | Adds detailed module hierarchy and usage documentation |
| pyproject.toml | Bumps version to 2.1.8 and adds hvac dependency |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Moves the inline usage prints out of read_parameters() into a pgpassword.usg file displayed by show_usage(), matching the pattern used by other RDA console scripts. Also adds module, class, and method docstrings to pgpassword.py. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Documents the effective defaults inherited from PgDBI/PgLOG for the -l, -d, -c, -u, -h, and -p options so users know what they get when each option is omitted. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.