Jump to content

Offline Unit Conversion Workflow


Recommended Posts

  • 3 weeks later...
  • 2 months later...

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
  • 1 year later...

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
  • 8 months later...
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
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
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
  • 6 months later...

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
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
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
  • 7 months later...
  • 1 year later...

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.

2016432789_2021-01-1718_03_08.png.5002ba10c83d48d4cdd2b3f59918aa5b.png

Do you still need this?

Link to comment
  • 1 month later...

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

@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

@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?

Screen Shot 2022-05-12 at 3.02.34 PM.png

Link to comment
  • 1 year later...
  • 5 months later...

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?

 

 

Snímek obrazovky 2024-03-29 v 9.26.50.jpg

Link to comment

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...