Skip to content

Commit

Permalink
cli: default to excel output, remove warning
Browse files Browse the repository at this point in the history
  • Loading branch information
zargot committed Sep 3, 2024
1 parent 279f386 commit 132eaa7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
3 changes: 2 additions & 1 deletion docs/manual/chapters/cli-reference.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ Options:

- `--outfmt=FORMAT`

output format (excel or csv), defaults to input format
output format (`excel` or `csv`), defaults to input format when input is a
file and `excel` when it's a database

- `--outdir=PATH`

Expand Down
13 changes: 3 additions & 10 deletions src/odm_sharing/tools/share.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,13 @@ def get_excel_writer(in_name: str, debug: bool, org: str, outdir: str,
return None


def infer_outfmt(path: str) -> Optional[OutFmt]:
def infer_outfmt(path: str) -> OutFmt:
'''returns None when not recognized'''
(_, ext) = os.path.splitext(path)
if ext == '.csv':
return OutFmt.CSV
elif ext == '.xlsx':
else:
return OutFmt.EXCEL
return None


def share(
Expand All @@ -175,13 +174,7 @@ def share(
in_name = Path(input).stem

if outfmt == OutFmt.AUTO:
fmt = infer_outfmt(input)
if not fmt:
logging.warning('unable to infer output format from input path, ' +
'defaulting to excel')
outfmt = OutFmt.EXCEL
else:
outfmt = fmt
outfmt = infer_outfmt(input)

logging.info(f'loading schema {qt(schema_filename)}')
try:
Expand Down

0 comments on commit 132eaa7

Please sign in to comment.