deanishe Posted November 2, 2017 Author Share Posted November 2, 2017 (edited) Updated to v3.1. I've replaced the now-dead Yahoo! Finance API with openexchangerates.org. Unfortunately, this requires an API key, which you can get for free here. Edited November 2, 2017 by deanishe Point link to release Link to comment
deanishe Posted November 2, 2017 Author Share Posted November 2, 2017 (edited) Due to an excess of productivity, I've also released v3.2 today. This adds the ability to use Pint's contexts. Edited November 2, 2017 by deanishe Point link to release Link to comment
deanishe Posted November 20, 2017 Author Share Posted November 20, 2017 (edited) v3.3 also uses the decimal and thousands separators you've set to parse input. Now, you exotic Euro-types can enter 12.000,56 or 32'783,30 etc. (depending on your settings), and the workflow won't throw up on your slippers. Edited November 20, 2017 by deanishe cands 1 Link to comment
deanishe Posted January 31, 2018 Author Share Posted January 31, 2018 Moar updates. v3.5.1 now handles negative numbers and is smarter about the number of decimal places. There's a CURRENCY_DECIMAL_PLACES override to set a different number of decimal places for currency conversions (for you Bitcoin types), and DECIMAL_PLACES is now a minimum, not a hard limit (by default). If DYNAMIC_DECIMALS is on (the default), the workflow will show as many decimal places as necessary (up to 10) for the result to be non-zero. Link to comment
johseb Posted February 14, 2019 Share Posted February 14, 2019 Hi @deanishe, thanks for the great workflow. I have a request related to the significant digits of the converted quantity. The variable DECIMAL_PLACES controls not only the displayed format in Alfred bar but also the quantity copied to the clipboard on pressing Enter. E.g. `conv 2.3456 m km` will show a converted quantity `0.0023 kilometer` and copy 0.0023 on the clipboard. I would prefer to have the displayed result controlled by the mentioned variable but to retain all significant digits in the quantity copied to clipboard (in my previous example 0.0023456). Link to comment
deanishe Posted February 22, 2019 Author Share Posted February 22, 2019 On 2/14/2019 at 4:40 PM, johseb said: I would prefer Is there an objective reason why I should implement this change? I don't really see the point myself. OTOH, I don't work seriously with numbers, so I'm always open to making justifiable changes. Link to comment
khaoskosmos Posted November 16, 2019 Share Posted November 16, 2019 On 2/22/2019 at 4:44 AM, deanishe said: Is there an objective reason why I should implement this change? I don't really see the point myself. OTOH, I don't work seriously with numbers, so I'm always open to making justifiable changes. If you're doing calculation and need the correct number of significant figures, it's never a problem when a conversion has more than necessary. Otherwise, you can get rounding errors. It would be useful it you could simply type the number without a keyword, and without a space on the unit ie. 4.1mm Instead of stating that no destination or defaults set, it would be useful to list the most common conversions (ex.. in the US its very common to convert mm to inch, whereas mm to cm is rather easy for a person). Check out the default setup for Spotlight, I think it lists common conversions, with no keyword. BTW, I only critique because the workflow is very cool and useful, thanks for it. Link to comment
deanishe Posted November 16, 2019 Author Share Posted November 16, 2019 8 hours ago, khaoskosmos said: If you're doing calculation and need the correct number of significant figures The workflow only rounds the result if you tell it to. 8 hours ago, khaoskosmos said: It would be useful it you could simply type the number without a keyword That isn't really how workflows work. 8 hours ago, khaoskosmos said: without a space on the unit You don't need a space. 8 hours ago, khaoskosmos said: the most common conversions If you have any universally-useful suggestions, I'll definitely consider it. However, I'm generally against adding any presets like inches that are of no interest to most users. In a choice between requiring American users to manually add acres, pounds, Fahrenheit etc. and requiring everybody else to manually delete them, everybody else wins. Link to comment
khaoskosmos Posted November 17, 2019 Share Posted November 17, 2019 14 hours ago, deanishe said: The workflow only rounds the result if you tell it to. That isn't really how workflows work. You don't need a space. If you have any universally-useful suggestions, I'll definitely consider it. However, I'm generally against adding any presets like inches that are of no interest to most users. In a choice between requiring American users to manually add acres, pounds, Fahrenheit etc. and requiring everybody else to manually delete them, everybody else wins. Thanks. I will look into modifying it myself for my own needs. Is Alfred not aware of a user's location setting? Link to comment
deanishe Posted November 17, 2019 Author Share Posted November 17, 2019 4 hours ago, khaoskosmos said: Is Alfred not aware of a user's location setting? Alfred is (being a native application), but it doesn't share that information with workflows. You can use the command defaults read -globalDomain AppleMetricUnits to ask whether the OS is set to use metric. khaoskosmos 1 Link to comment
sebastianK Posted May 25, 2020 Share Posted May 25, 2020 I am trying to add new units like described but i get the following error: "maximum recursion depth exceeded while calling a Python object" i added in the unit definitions.txt the following: squarefoot = 0,092903 quadratmeter = sqft = ft2 = sqf quadratmeter = 10.764 squarefoot = m2 = sqm what am i doing wrong!? Link to comment
deanishe Posted May 25, 2020 Author Share Posted May 25, 2020 4 hours ago, sebastianK said: squarefoot = 0,092903 quadratmeter = sqft = ft2 = sqf quadratmeter = 10.764 squarefoot = m2 = sqm what am i doing wrong!? Your definition is recursive. You can’t define unit X in terms of unit Y and also unit Y in terms of unit X. You need to define at least one of them in terms of something the library already understands: quadratmeter = 1 m**2 = m2 = sqm squarefoot = 0.092903 quadratmeter = sqft = ft2 = sqf Link to comment
sebastianK Posted May 30, 2020 Share Posted May 30, 2020 On 5/25/2020 at 12:05 PM, deanishe said: Your definition is recursive. You can’t define unit X in terms of unit Y and also unit Y in terms of unit X. You need to define at least one of them in terms of something the library already understands Ah! thank you so much! this works! If i understand correct you define quadratmeter with m (meter) which is already understood by the library!? Link to comment
deanishe Posted May 30, 2020 Author Share Posted May 30, 2020 41 minutes ago, sebastianK said: If i understand correct you define quadratmeter with m (meter) which is already understood by the library!? Yes. Pint already understands length and area. You can define your own dimensions, too. But the relationship between unit definitions must be linear, not circular, like yours was. Link to comment
Александр Posted January 17, 2021 Share Posted January 17, 2021 Good afternoon, I still don't understand where to enter the openexchangerates.org API key and how to do it. Show by example please. I received the key after registering at openexchangerates.org. Thank you, I will wait for an answer. Link to comment
kenanmike Posted April 11, 2022 Share Posted April 11, 2022 D On 1/17/2021 at 6:05 PM, Александр said: Good afternoon, I still don't understand where to enter the openexchangerates.org API key and how to do it. Show by example please. I received the key after registering at openexchangerates.org. Thank you, I will wait for an answer. Do you still need this? Link to comment
charms Posted May 12, 2022 Share Posted May 12, 2022 LOVE this workflow. Super useful converting measurements for me. Unfortunately, it's stopped responding and I was hoping to get some help with it. Whenever I get past the "conv " and into the units, the workflow drops and I just get the "Search Google for conv XXunit unit" I've tried uninstalling and reinstalling. I'm using 3.7.1. The ONLY thing I've changed is the icon. Link to comment
Vero Posted May 12, 2022 Share Posted May 12, 2022 @charms Take a look at the Debugger, which should give you more insight into what's not working: https://www.alfredapp.com/help/workflows/advanced/debugger/ If you're using macOS Monterey 12.3+ and haven't reinstalled Python 2, then your issue is the following: https://www.alfredapp.com/blog/guides-and-tutorials/python-2-workflows-on-macos-monterey-12-3/ In short, Apple have removed the built-in Python 2 programming language from macOS 12.3 onwards. Reading the link above should get you back up and running in no time Cheers, Vero Link to comment
charms Posted May 13, 2022 Share Posted May 13, 2022 @Vero Thank you for the suggestions and links. I think this is the problem, but after going through all of the steps, it's still not working. I think it's more of just me not knowing how to link Python and Alfred up. I copied and pasted all of those lines. Am I supposed to replace {HOME} with something specific? Link to comment
vitor Posted May 13, 2022 Share Posted May 13, 2022 Welcome @charms, You’ll also need to install the fixed version of this Workflow from the table. Link to comment
charms Posted May 13, 2022 Share Posted May 13, 2022 @vitor Sweet fancy Moses! Thank you thank you thank you! And @Vero. Appreciate you both! vitor 1 Link to comment
iandol Posted October 8, 2023 Share Posted October 8, 2023 I just saw this has been forked and added to the Gallery, many many thanks to @giovanni and @vitor as this remains my favourite converter giovanni and vitor 2 Link to comment
Orxion Posted March 29 Share Posted March 29 Finally, it works again, I really missed this one .. just have one question, when entering API, is it just the code or something extra? doesn't seem to be converting currency .. or am I doing something wrong? Link to comment
iandol Posted April 1 Share Posted April 1 Hi @giovanni — I am getting this error at present: Traceback (most recent call last): File "/Users/ian/Library/CloudStorage/Dropbox/Assorted/Alfred Settings/Alfred.alfredpreferences/workflows/user.workflow.FA895A69-DD0A-4EDF-AA0A-3934D0B00C79/convert.py", line 19, in <module> from pint import UnitRegistry, UndefinedUnitError, DimensionalityError File "/Users/ian/Library/CloudStorage/Dropbox/Assorted/Alfred Settings/Alfred.alfredpreferences/workflows/user.workflow.FA895A69-DD0A-4EDF-AA0A-3934D0B00C79/pint/__init__.py", line 17, in <module> import pkg_resources File "/Users/ian/Library/CloudStorage/Dropbox/Assorted/Alfred Settings/Alfred.alfredpreferences/workflows/user.workflow.FA895A69-DD0A-4EDF-AA0A-3934D0B00C79/pkg_resources/__init__.py", line 57, in <module> from pkg_resources.extern import six ImportError: cannot import name 'six' from 'pkg_resources.extern' (/Users/ian/Library/CloudStorage/Dropbox/Assorted/Alfred Settings/Alfred.alfredpreferences/workflows/user.workflow.FA895A69-DD0A-4EDF-AA0A-3934D0B00C79/pkg_resources/extern/__init__.py) I have to admit I don't quite understand how the python dependencies are packaged in the workflow. My python is 3.12.1 (installed with pyenv) Link to comment
giovanni Posted April 1 Share Posted April 1 @iandol yes, not sure what has changed but other pythons can now take precedence over the system Python. You just need to add `/usr/bin/` before `python3` in the script filter (see also this issue). I will update this and other workflows with the same issue. iandol 1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now