Comments (5)
Because I don’t have any experience in programming, I hope you can explain in detail how I can operate or modify your workflow if you can help me.
Thanks again!
from alfred-converter.
There are 2 ways to add new units to the system.
- By editing this bit of code: https://github.com/WoLpH/alfred-converter/blob/master/converter/extra_units.py
- By editing the units XML file: https://github.com/WoLpH/alfred-converter/blob/master/poscUnits22.xml
When editing the extra_units.py
file I think you would need something like this as part of the register_post
function:
convert.Unit(
id='dollar',
name='Dollar',
annotations=['$', 'dollar'],
conversion_params=('0', '0', '1', '0'),
).register(units)
convert.Unit(
id='paypal-fee',
name='PayPal fee',
base_unit='dollar',
conversion_params=('0.3', '0.044', '1', '0'),
Note: the conversion params work like this: (a + b * value) / (c + d * value)
Perhaps I'll add something in the future to make this easier, but for now that's the only option. You're the first to ask for a custom unit :)
from alfred-converter.
I compared your new code formats and put them in this section of the extra_units.py file.
But I still don’t seem to add them correctly, because PP-fee is not available in the Alfred 4
Is this because I put the code in the wrong place or is it just that Alfred made a mistake about using the PP hotkey?
Sorry for taking your time again.
from alfred-converter.
It seems I somehow missed your reply... sorry about that
In any case, it looks like my example was a bit too limited to work. I've tried a little more and I've come up with this code:
params = dict(
units=units,
quantity_types=['money'],
base_unit='dollar',
)
add = 0.3
fee = 4.4
multiplier = fee * 0.0105
convert.Unit(
id='dollar',
name='Dollar',
annotations=['$', 'dollar'],
conversion_params=('0', '1', '1', '0'),
**params
).register(units)
convert.Unit(
id='paypal-fee',
name='PayPal fee',
annotations=['pp', 'paypal'],
conversion_params=('-%s' % add, '1', str(multiplier), '0'),
**params
).register(units)
convert.Unit(
id='paypal-total',
name='PayPal Total',
annotations=['pt'],
conversion_params=('-%s' % add, '1', str(1 + multiplier), '0'),
**params
).register(units)
If needed you can easily change the 4.4% and +0.3. Note that after editing the code you will have to delete the units.pickle
file which caches the calculations.
This is how it looks right now:
from alfred-converter.
from alfred-converter.
Related Issues (20)
- Bug: safemath functions not working [with fix] HOT 2
- Subtraction of floating point numbers doesn't work without spaces HOT 5
- Farad derivatives support? HOT 8
- Feet and inches conversion HOT 1
- Some HEX numbers are not recognized HOT 2
- Timezones would be a nice addition HOT 2
- Option to change decimal separator HOT 4
- Doesn't work with negative values of temperature HOT 4
- 1024mb should be equal to 1.000gb HOT 3
- Python 2 removed in macOS 8.3 beta HOT 7
- Add variable to enable or disable fractional units HOT 7
- Not working since Python2 removed by MacOS 12.3+ HOT 4
- main function references nonexistent location for logfile HOT 1
- Would be nice to be able to do simple math HOT 2
- `/usr/bin/python` is not a thing on the recent mac versions HOT 2
- Blacklist variable input mismatch HOT 4
- Environment Variables not working HOT 4
- TypeError on conversion HOT 3
- can't get it to start HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from alfred-converter.