-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from inus/fb5-test
Add argparse handling in case called from a module
- Loading branch information
Showing
9 changed files
with
62 additions
and
60 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -121,7 +121,7 @@ celerybeat.pid | |
|
||
# Environments | ||
.env | ||
.venv | ||
.venv* | ||
env/ | ||
venv/ | ||
ENV/ | ||
|
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Change Log | ||
|
||
## [0.2.0] - 2024-05-16 | ||
### Added: | ||
Make it an importable unit. Add CHANGELOG.md. Remove shell script fb_export and replace with | ||
python script. | ||
|
||
## [0.1.0] - 2024-05-10 | ||
### Initial upload | ||
|
||
Working with Firebird 2.5 and also via Github Actions runner on ubuntu-latest. | ||
|
||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,12 +3,12 @@ requires = ["setuptools",] | |
build-backend = "setuptools.build_meta" | ||
|
||
[project] | ||
name = "firebird-export" | ||
name = "fb_export" | ||
authors = [ | ||
{name = "Inus Scheepers", email = "[email protected]"} | ||
] | ||
description = "Export Firebird database to CSV, JSON or other pandas format from dataframe" | ||
version = "0.1.0" | ||
dynamic = ["version"] | ||
readme = "README.md" | ||
requires-python = ">=3.9" | ||
dependencies = [ | ||
|
@@ -49,15 +49,11 @@ classifiers = [ | |
"Topic :: File Formats", | ||
] | ||
|
||
[project.scripts] | ||
firebird-export = "fb_export" | ||
|
||
[project.urls] | ||
Homepage = "https://github.com/inus/firebird-export" | ||
#Documentation = "https://readthedocs.org" | ||
#Repository = "https://github.com/me/spam.git" | ||
#Issues = "https://github.com/me/spam/issues" | ||
#Changelog = "https://github.com/me/spam/blob/master/CHANGELOG.md" | ||
Repository = "https://github.com/inus/firebird-export.git" | ||
Issues = "https://github.com/inus/firebird-export/issues" | ||
Changelog = "https://github.com/inus/firebird-export/CHANGELOG.md" | ||
|
||
[tool.pytest.ini_options] | ||
testpaths = "test" | ||
|
@@ -70,3 +66,11 @@ log_date_format = "%Y-%m-%d %H:%M:%S" | |
#filterwarnings = "ignore" | ||
#norecursedirs = docs build | ||
|
||
[project.scripts] | ||
fb_export = "fb_export.fb_export:main" | ||
|
||
[tool.setuptools] | ||
package-dir = {"fb_export" = "src"} | ||
|
||
[tool.setuptools.dynamic] | ||
version = {attr = "fb_export.about.VERSION"} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# about.py | ||
VERSION = "0.0.1" | ||
DATE = '2024-05-10' | ||
VERSION = "0.2.0" | ||
DATE = '2024-05-16' |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,38 @@ | ||
# Firebird export arguments | ||
from about import VERSION | ||
|
||
import argparse | ||
|
||
|
||
def get_args(): | ||
def get_args(*fbe_args): | ||
|
||
parser = argparse.ArgumentParser(description="Firebird export") | ||
|
||
parser.add_argument( 'path_to_db', type=str, | ||
help="Firebird server alias or database name \ | ||
(eg. employee) or path to database file, eg ./employee.fdb") | ||
|
||
parser.add_argument('--version', action='version', version='%(prog)s version ' + VERSION) | ||
parser.add_argument("-e", "--export", action='store_true', default=False, help="Export data") | ||
parser.add_argument('-b', '--brief', action='store_true', default=False,) | ||
parser.add_argument('-b', '--brief', action='store_true', default=False,help="Shorter info") | ||
parser.add_argument('-l', '--limit', action='store_true', default=False, | ||
help="Limit tables and fields to those in customselect.py") | ||
parser.add_argument('-m', '--maxrows', help="Max number of rows returned in export") | ||
|
||
#fixme - numsamples to be conditional on sampledata | ||
help="Limit tables and fields to those in limit_sql.py") | ||
parser.add_argument('-m', '--maxrows', help="Max number of rows to export") | ||
parser.add_argument('-s', '--sampledata', action='store_true', default=False, | ||
help="Also show sample record") | ||
help="Also show sample data records") | ||
parser.add_argument('-n', '--numsamples', default=3, help="number of sample rows") | ||
|
||
parser.add_argument('-c', '--combine', action='store_true', default=False, | ||
help="Combine output into a single file") | ||
parser.add_argument('-j', '--join', action='store_true', default=False, | ||
help="Join output files") | ||
format = [ 'csv', 'json',] # 'excel', 'sql', 'hdf', 'pickle', 'html' ....]? | ||
parser.add_argument("-F", "--format", choices=format, default='csv', help="Export output format, default .CSV") | ||
parser.add_argument("-o", "--outdir", type=str, dest='outdir', default='Export', help="Output directory") | ||
parser.add_argument("-u", "--user", type=str, default='SYSDBA', help="Firebird DB username") | ||
parser.add_argument("-p", "--password", type=str, default='masterkey', help="Firebird DB password") | ||
|
||
parser.add_argument("-d", "--database", dest='path_to_db', type=str, required=True, | ||
default="tests/employee.fdb", | ||
help="Firebird server alias or database name (eg. employee) or full path if file, eg ./employee.fdb") | ||
|
||
args = parser.parse_args() | ||
if len(fbe_args) == 0: # Command line | ||
args = parser.parse_args() | ||
else: # From module | ||
args = parser.parse_args( fbe_args[0]) | ||
|
||
return args |
This file contains 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