Giter VIP home page Giter VIP logo

dictor's People

Contributors

jdan735 avatar mostafa avatar mreiderqb avatar perfecto25 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

dictor's Issues

How can i buy you a beer?

I have to work with deeply nested JIRA Api Response and your package is a LIFESAVER, especially the default values if part of the "path" isn't found.
How can i buy you a beer?

Enhancement Request

Love this project.

Just small requests. I'll try to put in a Pull Request

  1. Add pathseparator. So if '. ' can possibly be in the keys, then someone can use "/" as separator
  2. Add support for regex or wildcard match on keys so that one does not need full key name.

lookup fails if key has ":"

key lookup fails if key has : character

from dictor import dictor

data = { "my:key": 
               { 
                   "names": ["joe", "frank", "mary"] 
               }
}

key = "my:key"

print(dictor(data, f"{key}.names"))
None

returns None, should return list of names

Release binary's to Pypi

Not sure of the terminology, but versions 0.1.1 and 0.1.2 both could be pulled with the --only-binary flag. 0.1.3 & 0.1.4 cannot.

Anyway this can be done?

upper key in path matches a deeper one

dictor({'lastname': 'Doe'}, 'foo.lastname')

returns "Doe" instead of None

It seems that if there is an upper key in the path that match the last level, it returns a match

add automatic conversion of dot values in data, to remove "pathsep"

data comes in with unexpected chars,

ie

data = {"/tmp/file": "true", "file.conf": true"}

this data has to be parsed with pathsep="some separator", as dot and / wont work, both "/" and "." are in the lookup path

makes using pathsep impractical because any character used as pathsep can actually be in the data string

add auotmatic splitting to insert some unique separator that wont ever come up in actual data , ie "dictor_sep" or something similar, that way users wont ever need to use pathsep flag

add CheckVal flag to remove any value thats blank, False or None

from dictor import dictor

d = {
    "age": "",
    "name": "joe",
    "somekey": None,
    "status": False
}

print(dictor(d, pretty=True))

>>>
{
    "age": "",
    "name": "joe",
    "somekey": null,
    "status": false
}

this will print out contents of Age. Somekey and Status, even though tho values are empty

add option to skip any values that are None, False, ""

Avoid using eval()

Hi,

Really enjoy this project, great idea !
But using eval() to get return value (re)formatted lookup syntax is a no go for me. This is prone to malicious code execution and a major security concern.

Would be nice to rework this part and using solutions discussed here: https://stackoverflow.com/a/52260663

This is just my opinion and a suggestion, no criticism from me.
Again, dictor is a simple but great idea !

defaultValue suddenly not working anymore

Python 3.9
Dictor 0.12

This suddenly starts to appear after working perfectly for a year. i have no clue why. The return type of the dictor call is NoneType while it should be an empty string.

Code:

            if dictor(details, "Hinweis1.values.0", ""):
                newDescription += "Hinweis 1: " + details["Hinweis1"].values[0] + lf

Error:

  File "//./app.py", line 1255, in updateTicketsWithKissData
    if dictor(details, "Hinweis1.values.0", ""):
       │      └      Kurkan  ... LizenzAnzahl
       │        2753  LANDL  ...           12
       │        
       │        [1 rows x 12 columns]
       └ <function dictor at 0x7f5124ba0d30>
  File "/usr/local/lib/python3.9/site-packages/dictor/__init__.py", line 147, in dictor
    val = _findval(data, path, pathsep, ignorecase, default)
          │        │     │     │        │           └ ''
          │        │     │     │        └ False
          │        │     │     └ '.'
          │        │     └ 'Hinweis1.values.0'
          │        └      Kurkan  ... LizenzAnzahl
          │          2753  LANDL  ...           12
          │          
          │          [1 rows x 12 columns]
          └ <function _findval at 0x7f5124c54dc0>
  File "/usr/local/lib/python3.9/site-packages/dictor/__init__.py", line 34, in _findval
    if data and key in data:
       │        │      └      Kurkan  ... LizenzAnzahl
       │        │        2753  LANDL  ...           12
       │        │        
       │        │        [1 rows x 12 columns]
       │        └ 'Hinweis1'
       └      Kurkan  ... LizenzAnzahl
         2753  LANDL  ...           12
�
 
         [1 rows x 12 columns]
  File "/usr/local/lib/python3.9/site-packages/pandas/core/generic.py", line 1527, in __nonzero__
    raise ValueError(
ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

Conda package

Hello,

we currently use your code in one of our tool whose development is in progress. We plan to integrate it in our tools suite (rptools) which is a conda package but your tool is not present on anaconda.org.

Have you planned to create a conda package of your tool?

Best regards,
Joan

Numeric keys handling

Hello,

I noticed that dictor does not seem to support cases when dictionary keys are strings composed only of numbers, e.g. :

{
      "1200": "banana",
      "2000": "apple"
}

Am I doing something wrong ?

Thanks in advance.

Empty string value treated as missing value

dictor()'s current implementation treats both empty values and missing values as situations where the default value is returned. This can be seen from the following lines:

    if val is None or val == "":
        return default

I don't believe this is a reasonable default behavior, as an object may have a key with an empty string for a value, which may be a distinct desired state from either a missing key or even a value of None.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.