Skip to content
This repository has been archived by the owner on Aug 30, 2019. It is now read-only.

list currencies #24

Open
teto opened this issue Oct 8, 2017 · 3 comments
Open

list currencies #24

teto opened this issue Oct 8, 2017 · 3 comments
Projects
Milestone

Comments

@teto
Copy link

teto commented Oct 8, 2017

Hi,

It's sometimes tough to guess the currency names, would it be possible to have a flag, for instance -l, to list currencies andtheir country ? it could be loaded from hardcoded json for offline support too.

Nb: I am currently packaging this for nixos.org

@anshulxyz
Copy link
Owner

Hi Matthieu,

Yes, that's a needed feature. It'll be done in two days.

@anshulxyz anshulxyz added this to the v1.0 milestone Oct 8, 2017
@anshulxyz anshulxyz added this to To Do in exch Oct 8, 2017
@anshulxyz anshulxyz moved this from To Do to In Progress in exch Nov 30, 2017
@anshulxyz anshulxyz reopened this Nov 30, 2017
anshulxyz added a commit that referenced this issue Dec 21, 2017
@anshulxyz
Copy link
Owner

@teto Hi, I added the feature and some other stuff. Give it a spin and let me know.

@teto
Copy link
Author

teto commented Dec 22, 2017

thanks for taking care of this.
My first remark is that exch -h didn't work even though in the source, it seems to support both --help and -h. I don't know click so I am unsure why.

[2] teto@jedha> exch --help                                                                                      ~
Usage: exch [OPTIONS] COMMAND [ARGS]...

  Get the latetst currency exchange rates from:

      - fixer.io

Options:
  -b, --base TEXT     Currency you are converting from.  [default: PHP]
  -t, --target TEXT   Currency you're converting to.  [default: CAD]
  -a, --amount FLOAT  Amount to convert.  [default: 1.0]
  -sb, --set_base     Set new default base.
  -st, --set_target   Set new default target.
  --help              Show this message and exit.

Commands:
  currencies  prints the list of currencies available
  sync        download the latest rates
teto@jedha> exch -h                                                                                              ~
Error: no such option: -h

exch ~
Traceback (most recent call last):
File "/nix/store/km1qj36j3aa5p7pbr3jjy8s4a29ycn16-exch-0.2/lib/python3.6/site-packages/exch/helpers.py", line 16, in fixer
with open(file_path) as json_file:
FileNotFoundError: [Errno 2] No such file or directory: '/nix/store/km1qj36j3aa5p7pbr3jjy8s4a29ycn16-exch-0.2/lib/python3.6/site-packages/exch/data/fixer_rates.json'

During handling of the above exception, another exception occurred:
Secondly on nixos, package folders are read only so exch fails saving the rates. Even so, I believe in general it would be best to save them in $XDG_CACHE_HOME on linux or be able to set an alternate path.

Traceback (most recent call last):
  File "/nix/store/km1qj36j3aa5p7pbr3jjy8s4a29ycn16-exch-0.2/bin/.exch-wrapped", line 12, in <module>
    sys.exit(cli())
  File "/nix/store/k3c2jkrpfrvfv9z2hcxpgqzm2jlvq9zf-python3.6-click-6.7/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/nix/store/k3c2jkrpfrvfv9z2hcxpgqzm2jlvq9zf-python3.6-click-6.7/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/nix/store/k3c2jkrpfrvfv9z2hcxpgqzm2jlvq9zf-python3.6-click-6.7/lib/python3.6/site-packages/click/core.py", line 1043, in invoke
    return Command.invoke(self, ctx)
  File "/nix/store/k3c2jkrpfrvfv9z2hcxpgqzm2jlvq9zf-python3.6-click-6.7/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/nix/store/k3c2jkrpfrvfv9z2hcxpgqzm2jlvq9zf-python3.6-click-6.7/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/nix/store/k3c2jkrpfrvfv9z2hcxpgqzm2jlvq9zf-python3.6-click-6.7/lib/python3.6/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/nix/store/km1qj36j3aa5p7pbr3jjy8s4a29ycn16-exch-0.2/lib/python3.6/site-packages/exch/cli.py", line 46, in cli
    output = fixer(base, target, amount, RATES_FIXER_JSON_FILE)
  File "/nix/store/km1qj36j3aa5p7pbr3jjy8s4a29ycn16-exch-0.2/lib/python3.6/site-packages/exch/helpers.py", line 23, in fixer
    if fixer_sync(file_path) in range(200, 300):
  File "/nix/store/km1qj36j3aa5p7pbr3jjy8s4a29ycn16-exch-0.2/lib/python3.6/site-packages/exch/helpers.py", line 50, in fixer_sync
    with open(file_path, 'wb') as json_file:
PermissionError: [Errno 13] Permission denied: '/nix/store/km1qj36j3aa5p7pbr3jjy8s4a29ycn16-exch-0.2/lib/python3.6/site-packages/exch/data/fixer_rates.json'

@anshulxyz anshulxyz reopened this Dec 22, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
exch
In Progress
Development

No branches or pull requests

2 participants