Skip to content

Hua work common - #104

Merged
zaihuaji merged 7 commits into
mainfrom
hua-work-common
May 15, 2026
Merged

zaihuaji merged 7 commits into
mainfrom
hua-work-common

Conversation

@zaihuaji

Copy link
Copy Markdown
Collaborator

No description provided.

zaihuaji and others added 3 commits May 14, 2026 17:08
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>
Copilot AI review requested due to automatic review settings May 15, 2026 15:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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__.py to 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 to 2.1.8, and added hvac as 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.

Comment thread src/rda_python_common/pgpassword.py Outdated
Comment thread README.md Outdated
zaihuaji and others added 4 commits May 15, 2026 11:04
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>
@zaihuaji
zaihuaji merged commit 09cc4cf into main May 15, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants