Comments (3)
#4
(bytes) I can probably remove that code and use utils.convert_size_to_int()
now.
#5
(remove quotes) can probably be added to utils
as a function.
#6
(normalize keys) can probably be added to utils
as a function.
The dict mapper idea is not a bad one, but probably not at the top of my priority list at the moment.
from jc.
I have made some initial attempts as a personal exploration:
I currently have a draft version, but I am not entirely satisfied with it :(
You can find the code here:
- Implementation: dict_mapper.py
- Test cases: test_dict_mapper.py
The issue I am facing is that I initially examine item_mappings
and then move on to key_mappings
. However, the resulting changes are not as predictable for the end user.
I believe implementing changes in a pipeline would be more effective, allowing users to define the order themselves:
mapper_options = Pipeline([
# find matches and add results to the dict
UpdateMapper({'http-update': matcher}),
KeyMapper({
'version' : 'HTTP-Version',
'status_code': 'Status-Code',
'status_reason': 'Status-Reason'
}),
KeyMapper('replace_this_key', 'replaced_key'),
KeyMapper({'.+_change$': lambda x: x.lower()}),
ValueMapper({'*': lambda x: x.upper()})
])
- KeyMapper = update a key
key = change(key)
- ValueMapper = update the value
value = change(value)
- UpdateMapper = add key:values to the data
dict = change(key, value)
- ItemMapper = change the value, the function signature is
value = change(key,value)
from jc.
... can probably be added to
utils
as a function.
yes the idea was to map helper functions (maybe all placed in utils.converter
) to some dict values identified by keys.
The dict mapper idea is not a bad one, but probably not at the top of my priority list at the moment.
yes - you are right - the mapper would be out of scope of jc
While I think more about it: it is better to have it KISS than a bunch of additional code to just replace one-liners
I will close this issue, maybe reopen it when I have better and leaner implementation available
from jc.
Related Issues (20)
- /proc/pid/state parser add missing state 'I' HOT 2
- jc --rsync, it should be able to parse the summary of rsync, but doesn't work HOT 5
- New parser: php-fpm8.2 -tt HOT 2
- PostgreSQL INI files HOT 2
- xrandr fails to parse disconnected output, that is still enabled HOT 3
- iptables fails to parse -x (expand numbers) option because "pkts" header has more than one leading blank HOT 5
- Add `--locale` option to specify fallback encoding to decode `data_in` with HOT 1
- `lspci` parser PhySlot issue HOT 4
- Fix documentation for apt-get-sqq parser HOT 3
- New Parser - NUT-upsc command HOT 1
- [parsers /pci_ids.py] Only last [subvendor][subdevice] got loaded into result when multiple subdevices having the same subvendor id HOT 3
- Bug: Traceroute ignored IPs when multiple IPs on hop HOT 3
- "ss" Parser not working correctly: Entries Missing HOT 5
- .netrc support HOT 1
- Problem with --pip-show parser for a module with nothing on the License: line but which has following lines HOT 4
- lspci strips trailing digit on bus ID HOT 3
- `--zpool-status` fails to handle the `spares` section of `zpool status` HOT 3
- New parser request: pacman -Si HOT 2
- 1.25.3: pytest fails in nits which are comparing time HOT 2
- Python 3.12 test regression: `tests.test_ip_address.MyTests.test_ip_address_ipv6_6to4` HOT 4
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 jc.