Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

json str issue #24

Open
wanghaisheng opened this issue Sep 20, 2023 · 20 comments
Open

json str issue #24

wanghaisheng opened this issue Sep 20, 2023 · 20 comments

Comments

@wanghaisheng
Copy link

==1== <class 'UltraDict.UltraDict.UltraDict'>
==2== {'1': {'video_local_path': '/Users/wenke/github/tiktoka-studio-uploader-app/tests/videos/1.mp4', 'video_filename': '1.mp4', 'video_title': '1', 'heading': '', 'subheading': '', 'extraheading': '', 'video_description': '', 'thumbnail_bg_image_path': '/Users/wenke/github/tiktoka-studio-uploader-app/tests/videos/1/sp/1-003.jpg', 'thumbnail_local_path': [], 'release_date': '', 'release_date_hour': '10:15', 'is_not_for_kid': True, 'categories': '', 'comments_ratings_policy': 1, 'is_age_restriction': False, 'is_paid_promotion': False, 'is_automatic_chapters': True, 'is_featured_place': True, 'video_language': '', 'captions_certification': 0, 'video_film_date': '', 'video_film_location': '', 'license_type': 0, 'is_allow_embedding': True, 'is_publish_to_subscriptions_feed_notify': True, 'shorts_remixing_type': 0, 'is_show_howmany_likes': True, 'is_monetization_allowed': True, 'first_comment': '', 'subtitles': '', 'tags': ''}}
==3== <class 'dict'>
==4== {'1': {'captions_certification': 0, 'categories': '', 'comments_ratings_policy': 1, 'extraheading': '', 'first_comment': '', 'heading': '3333', 'is_age_restriction': False, 'is_allow_embedding': True, 'is_automatic_chapters': True, 'is_featured_place': True, 'is_monetization_allowed': True, 'is_not_for_kid': True, 'is_paid_promotion': False, 'is_publish_to_subscriptions_feed_notify': True, 'is_show_howmany_likes': True, 'license_type': 0, 'release_date': '', 'release_date_hour': '10:15', 'shorts_remixing_type': 0, 'subheading': '2222', 'subtitles': '', 'tags': '', 'thumbnail_bg_image_path': '', 'thumbnail_local_path': [], 'video_description': '', 'video_filename': '1.mp4', 'video_film_date': '', 'video_film_location': '', 'video_language': '', 'video_local_path': '/Users/wenke/github/tiktoka-studio-uploader-app/tests/videos/1.mp4', 'video_title': '1'}}
wohhha data
```


code is 
```
                                    print('==1==',type(ultra[folder]['videos']))
                                    print('==2==',ultra[folder]['videos'])


                                    print('==3==',type(json.loads(df.to_json())))
                                    print('==4==',json.loads(df.to_json()))
                                    try:
                                        ultra[folder]['videos']=json.loads(df.to_json())
                                    except Exception as e:
                                        print(f'wohhha {e}')
```
@wanghaisheng
Copy link
Author

@ronny-rentner

@wanghaisheng
Copy link
Author

wanghaisheng commented Sep 20, 2023

                                new=UltraDict()
                                for key in json.loads(df.to_json()).keys():
                                    new[key]  =json.loads(df.to_json())[key]                             

this one works but what if this one is a nested dict, i dont know how to do

@wanghaisheng
Copy link
Author

new=UltraDict()
new=json.loads(df.to_json())

this one wont work either

@ronny-rentner
Copy link
Owner

@wanghaisheng Please share the exception details including stack trace, exception message, etc.

@wanghaisheng
Copy link
Author

with my code showing above,
what all i get is
wohhha data

@ronny-rentner
Copy link
Owner

Well, your code above is not enough to debug the problem as you are catching the exception. What happens if you don't catch the exception?

Can you send a full example that I can run myself? I don't have your json string.

@wanghaisheng
Copy link
Author

this code is exact code

json str is here. at first I am not aware of ultradict and dict is not the same type .since I print two object and it look like the same

==4== {'1': {'captions_certification': 0, 'categories': '', 'comments_ratings_policy': 1, 'extraheading': '', 'first_comment': '', 'heading': '3333', 'is_age_restriction': False, 'is_allow_embedding': True, 'is_automatic_chapters': True, 'is_featured_place': True, 'is_monetization_allowed': True, 'is_not_for_kid': True, 'is_paid_promotion': False, 'is_publish_to_subscriptions_feed_notify': True, 'is_show_howmany_likes': True, 'license_type': 0, 'release_date': '', 'release_date_hour': '10:15', 'shorts_remixing_type': 0, 'subheading': '2222', 'subtitles': '', 'tags': '', 'thumbnail_bg_image_path': '', 'thumbnail_local_path': [], 'video_description': '', 'video_filename': '1.mp4', 'video_film_date': '', 'video_film_location': '', 'video_language': '', 'video_local_path': '/Users/wenke/github/tiktoka-studio-uploader-app/tests/videos/1.mp4', 'video_title': '1'}}

you can ignore ==2 and set it as you like

@ronny-rentner
Copy link
Owner

I've tried it and it works for me:

Python 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from UltraDict import UltraDict
>>> ultra = UltraDict()
>>> d = dict({'1': {'captions_certification': 0, 'categories': '', 'comments_ratings_policy': 1, 'extraheading': '', 'first_comment': '', 'heading': '3333', 'is_age_restriction': False, 'is_allow_embedding': True, 'is_automatic_chapters': True, 'is_featured_place': True, 'is_monetization_allowed': True, 'is_not_for_kid': True, 'is_paid_promotion': False, 'is_publish_to_subscriptions_feed_notify': True, 'is_show_howmany_likes': True, 'license_type': 0, 'release_date': '', 'release_date_hour': '10:15', 'shorts_remixing_type': 0, 'subheading': '2222', 'subtitles': '', 'tags': '', 'thumbnail_bg_image_path': '', 'thumbnail_local_path': [], 'video_description': '', 'video_filename': '1.mp4', 'video_film_date': '', 'video_film_location': '', 'video_language': '', 'video_local_path': '/Users/wenke/github/tiktoka-studio-uploader-app/tests/videos/1.mp4', 'video_title': '1'}})
>>> ultra['d'] = d
>>> ultra
{'d': {'1': {'captions_certification': 0, 'categories': '', 'comments_ratings_policy': 1, 'extraheading': '', 'first_comment': '', 'heading': '3333', 'is_age_restriction': False, 'is_allow_embedding': True, 'is_automatic_chapters': True, 'is_featured_place': True, 'is_monetization_allowed': True, 'is_not_for_kid': True, 'is_paid_promotion': False, 'is_publish_to_subscriptions_feed_notify': True, 'is_show_howmany_likes': True, 'license_type': 0, 'release_date': '', 'release_date_hour': '10:15', 'shorts_remixing_type': 0, 'subheading': '2222', 'subtitles': '', 'tags': '', 'thumbnail_bg_image_path': '', 'thumbnail_local_path': [], 'video_description': '', 'video_filename': '1.mp4', 'video_film_date': '', 'video_film_location': '', 'video_language': '', 'video_local_path': '/Users/wenke/github/tiktoka-studio-uploader-app/tests/videos/1.mp4', 'video_title': '1'}}}

@wanghaisheng
Copy link
Author

as you see in my code
ultra[folder]['videos']=json.loads(df.to_json())

json.loads(df.to_json()) is
{'1': {'captions_certification': 0, 'categories': '', 'comments_ratings_policy': 1, 'extraheading': '', 'first_comment': '', 'heading': '3333', 'is_age_restriction': False, 'is_allow_embedding': True, 'is_automatic_chapters': True, 'is_featured_place': True, 'is_monetization_allowed': True, 'is_not_for_kid': True, 'is_paid_promotion': False, 'is_publish_to_subscriptions_feed_notify': True, 'is_show_howmany_likes': True, 'license_type': 0, 'release_date': '', 'release_date_hour': '10:15', 'shorts_remixing_type': 0, 'subheading': '2222', 'subtitles': '', 'tags': '', 'thumbnail_bg_image_path': '', 'thumbnail_local_path': [], 'video_description': '', 'video_filename': '1.mp4', 'video_film_date': '', 'video_film_location': '', 'video_language': '', 'video_local_path': '/Users/wenke/github/tiktoka-studio-uploader-app/tests/videos/1.mp4', 'video_title': '1'}}

not your

dict({'1': {'captions_certification': 0, 'categories': '', 'comments_ratings_policy': 1, 'extraheading': '', 'first_comment': '', 'heading': '3333', 'is_age_restriction': False, 'is_allow_embedding': True, 'is_automatic_chapters': True, 'is_featured_place': True, 'is_monetization_allowed': True, 'is_not_for_kid': True, 'is_paid_promotion': False, 'is_publish_to_subscriptions_feed_notify': True, 'is_show_howmany_likes': True, 'license_type': 0, 'release_date': '', 'release_date_hour': '10:15', 'shorts_remixing_type': 0, 'subheading': '2222', 'subtitles': '', 'tags': '', 'thumbnail_bg_image_path': '', 'thumbnail_local_path': [], 'video_description': '', 'video_filename': '1.mp4', 'video_film_date': '', 'video_film_location': '', 'video_language': '', 'video_local_path': '/Users/wenke/github/tiktoka-studio-uploader-app/tests/videos/1.mp4', 'video_title': '1'}})

@ronny-rentner
Copy link
Owner

Well, as far as I know, json.loads() returns a dict, so those are the same.

You've shown this in your own example:

print('==3==',type(json.loads(df.to_json())))

==3== <class 'dict'>

@wanghaisheng
Copy link
Author

I will try to provide a minimal example for you

@wanghaisheng
Copy link
Author

wanghaisheng commented Oct 10, 2023

@ronny-rentner

Well, as far as I know, json.loads() returns a dict, so those are the same.

You've shown this in your own example:

print('==3==',type(json.loads(df.to_json())))

==3== <class 'dict'>

here is the minimal code you can run,you will see the error

Traceback (most recent call last):
  File "D:\Programs\anaconda\lib\site-packages\UltraDict\UltraDict.py", line 841, in __setitem__
    item = UltraDict(item,
  File "D:\Programs\anaconda\lib\site-packages\UltraDict\UltraDict.py", line 488, in __init__
    super().__init__(*args, **kwargs)
  File "D:\Programs\anaconda\lib\collections\__init__.py", line 1046, in __init__
    self.update(dict)
  File "D:\Programs\anaconda\lib\site-packages\UltraDict\UltraDict.py", line 815, in update
    self[k] = v
  File "D:\Programs\anaconda\lib\site-packages\UltraDict\UltraDict.py", line 849, in __setitem__
    if item.name not in self.recurse_register.data:
AttributeError: data
from UltraDict import UltraDict
ultra = UltraDict(shared_lock=True,recurse=True)
ultra['videos']={'1': {'video_local_path': 'D:/Download/audio-visual/saas/tiktoka/tiktoka-studio-uploader-genius/tests/videos/vertical\\1.mp4', 'video_filename': '1.mp4', 'video_title': 1, 'heading': None, 'subheading': None, 'extraheading': None, 'video_description': None, 'thumbnail_bg_image_path': None, 'thumbnail_local_path': '[]', 'release_date': None, 'release_date_hour': '10:15', 'is_not_for_kid': True, 'categories': None, 'comments_ratings_policy': 1, 'is_age_restriction': False, 'is_paid_promotion': False, 'is_automatic_chapters': True, 'is_featured_place': True, 'video_language': None, 'captions_certification': 0, 'video_film_date': None, 'video_film_location': None, 'license_type': 0, 'is_allow_embedding': True, 'is_publish_to_subscriptions_feed_notify': True, 'shorts_remixing_type': 0, 'is_show_howmany_likes': True, 'is_monetization_allowed': True, 'first_comment': None, 'subtitles': None, 'tags': None}}
new2={'2': {'video_local_path': 'D:/Download/audio-visual/saas/tiktoka/tiktoka-studio-uploader-genius/tests/videos/vertical\\1.mp4', 'video_filename': '1.mp4', 'video_title': 222, 'heading': None, 'subheading': None, 'extraheading': None, 'video_description': None, 'thumbnail_bg_image_path': None, 'thumbnail_local_path': '[]', 'release_date': None, 'release_date_hour': '10:15', 'is_not_for_kid': True, 'categories': None, 'comments_ratings_policy': 1, 'is_age_restriction': False, 'is_paid_promotion': False, 'is_automatic_chapters': True, 'is_featured_place': True, 'video_language': None, 'captions_certification': 0, 'video_film_date': None, 'video_film_location': None, 'license_type': 0, 'is_allow_embedding': True, 'is_publish_to_subscriptions_feed_notify': True, 'shorts_remixing_type': 0, 'is_show_howmany_likes': True, 'is_monetization_allowed': True, 'first_comment': None, 'subtitles': None, 'tags': 'xxxxxx'}}
ultra['videos']=new2
print(ultra['videos'])
new3={'3': {'video_local_path': 'D:/Download/audio-visual/saas/tiktoka/tiktoka-studio-uploader-genius/tests/videos/vertical\\1.mp4', 'video_filename': '1.mp4', 'video_title': 222, 'heading': None, 'subheading': None, 'extraheading': None, 'video_description': None, 'thumbnail_bg_image_path': None, 'thumbnail_local_path': '[]', 'release_date': None, 'release_date_hour': '10:15', 'is_not_for_kid': True, 'categories': None, 'comments_ratings_policy': 1, 'is_age_restriction': False, 'is_paid_promotion': False, 'is_automatic_chapters': True, 'is_featured_place': True, 'video_language': None, 'captions_certification': 0, 'video_film_date': None, 'video_film_location': None, 'license_type': 0, 'is_allow_embedding': True, 'is_publish_to_subscriptions_feed_notify': True, 'shorts_remixing_type': 0, 'is_show_howmany_likes': True, 'is_monetization_allowed': True, 'first_comment': None, 'subtitles': None, 'tags': 'xxxxxx'}}

method=1
if method==1:
    ultra['videos']=new3
    print(ultra['videos'])    
else:
    for filename,video in new3.items():
        #     print('debug',filename,video)
        ultra['videos'][filename]= video
        print(ultra['videos'])

@wanghaisheng
Copy link
Author

wanghaisheng commented Oct 10, 2023

from UltraDict import UltraDict
ultra = UltraDict(shared_lock=True,recurse=True)
ultra['empty']={}
new={'1': {'video_local_path': 'D:/Download/audio-visual/saas/tiktoka/tiktoka-studio-uploader-genius/tests/videos/vertical\\1.mp4', 'video_filename': '1.mp4', 'video_title': 1, 'heading': None, 'subheading': None, 'extraheading': None, 'video_description': None, 'thumbnail_bg_image_path': None, 'thumbnail_local_path': '[]', 'release_date': None, 'release_date_hour': '10:15', 'is_not_for_kid': True, 'categories': None, 'comments_ratings_policy': 1, 'is_age_restriction': False, 'is_paid_promotion': False, 'is_automatic_chapters': True, 'is_featured_place': True, 'video_language': None, 'captions_certification': 0, 'video_film_date': None, 'video_film_location': None, 'license_type': 0, 'is_allow_embedding': True, 'is_publish_to_subscriptions_feed_notify': True, 'shorts_remixing_type': 0, 'is_show_howmany_likes': True, 'is_monetization_allowed': True, 'first_comment': None, 'subtitles': None, 'tags': None}}

new2={'2': {'video_local_path': 'D:/Download/audio-visual/saas/tiktoka/tiktoka-studio-uploader-genius/tests/videos/vertical\\1.mp4', 'video_filename': '1.mp4', 'video_title': 222, 'heading': None, 'subheading': None, 'extraheading': None, 'video_description': None, 'thumbnail_bg_image_path': None, 'thumbnail_local_path': '[]', 'release_date': None, 'release_date_hour': '10:15', 'is_not_for_kid': True, 'categories': None, 'comments_ratings_policy': 1, 'is_age_restriction': False, 'is_paid_promotion': False, 'is_automatic_chapters': True, 'is_featured_place': True, 'video_language': None, 'captions_certification': 0, 'video_film_date': None, 'video_film_location': None, 'license_type': 0, 'is_allow_embedding': True, 'is_publish_to_subscriptions_feed_notify': True, 'shorts_remixing_type': 0, 'is_show_howmany_likes': True, 'is_monetization_allowed': True, 'first_comment': None, 'subtitles': None, 'tags': 'xxxxxx'}}
new3={'3': {'video_local_path': 'D:/Download/audio-visual/saas/tiktoka/tiktoka-studio-uploader-genius/tests/videos/vertical\\1.mp4', 'video_filename': '1.mp4', 'video_title': 222, 'heading': None, 'subheading': None, 'extraheading': None, 'video_description': None, 'thumbnail_bg_image_path': None, 'thumbnail_local_path': '[]', 'release_date': None, 'release_date_hour': '10:15', 'is_not_for_kid': True, 'categories': None, 'comments_ratings_policy': 1, 'is_age_restriction': False, 'is_paid_promotion': False, 'is_automatic_chapters': True, 'is_featured_place': True, 'video_language': None, 'captions_certification': 0, 'video_film_date': None, 'video_film_location': None, 'license_type': 0, 'is_allow_embedding': True, 'is_publish_to_subscriptions_feed_notify': True, 'shorts_remixing_type': 0, 'is_show_howmany_likes': True, 'is_monetization_allowed': True, 'first_comment': None, 'subtitles': None, 'tags': 'xxxxxx'}}


ultra['new']=new
def t0(key):
#overwrite with same dict
    ultra[key]=new


def t1(key):
        #overwrite with same key diff field
        ultra[key]={'1': {'video_local_path': 'C:/Download/audio-visual/saas/tiktoka/tiktoka-studio-uploader-genius/tests/videos/vertical\\1.mp4', 'video_filename': '1.mp4', 'video_title': 1, 'heading': None, 'subheading': None, 'extraheading': None, 'video_description': None, 'thumbnail_bg_image_path': None, 'thumbnail_local_path': '[]', 'release_date': None, 'release_date_hour': '10:15', 'is_not_for_kid': True, 'categories': None, 'comments_ratings_policy': 1, 'is_age_restriction': False, 'is_paid_promotion': False, 'is_automatic_chapters': True, 'is_featured_place': True, 'video_language': None, 'captions_certification': 0, 'video_film_date': None, 'video_film_location': None, 'license_type': 0, 'is_allow_embedding': True, 'is_publish_to_subscriptions_feed_notify': True, 'shorts_remixing_type': 0, 'is_show_howmany_likes': True, 'is_monetization_allowed': True, 'first_comment': None, 'subtitles': None, 'tags': None}}
        print('same key diff field',ultra[key])
def t11(key):
        #overwrite with same key diff field
        ultra[key]={'1': {'video_local_path': 'C:/Download/audio-visual/saas/tiktoka/tiktoka-studio-uploader-genius/tests/videos/vertical\\1.mp4', 'video_filename': '1.mp4', 'video_title': 1, 'heading': None, 'subheading': None, 'extraheading': None, 'video_description': None, 'thumbnail_bg_image_path': None, 'thumbnail_local_path': '[]', 'release_date': None, 'release_date_hour': '10:15', 'is_not_for_kid': True, 'categories': None, 'comments_ratings_policy': 1, 'is_age_restriction': False, 'is_paid_promotion': False, 'is_automatic_chapters': True, 'is_featured_place': True, 'video_language': None, 'captions_certification': 0, 'video_film_date': None, 'video_film_location': None, 'license_type': 0, 'is_allow_embedding': True, 'is_publish_to_subscriptions_feed_notify': True, 'shorts_remixing_type': 0, 'is_show_howmany_likes': True, 'is_monetization_allowed': True, 'first_comment': None, 'subtitles': None, 'tags': None}}
        print('same key diff field',ultra[key])
def t12(key):
        # make it a  empty one at first
        ultra[key]=dict({})
        #overwrite with same key diff field

        ultra[key]={'1': {'video_local_path': 'C:/Download/audio-visual/saas/tiktoka/tiktoka-studio-uploader-genius/tests/videos/vertical\\1.mp4', 'video_filename': '1.mp4', 'video_title': 1, 'heading': None, 'subheading': None, 'extraheading': None, 'video_description': None, 'thumbnail_bg_image_path': None, 'thumbnail_local_path': '[]', 'release_date': None, 'release_date_hour': '10:15', 'is_not_for_kid': True, 'categories': None, 'comments_ratings_policy': 1, 'is_age_restriction': False, 'is_paid_promotion': False, 'is_automatic_chapters': True, 'is_featured_place': True, 'video_language': None, 'captions_certification': 0, 'video_film_date': None, 'video_film_location': None, 'license_type': 0, 'is_allow_embedding': True, 'is_publish_to_subscriptions_feed_notify': True, 'shorts_remixing_type': 0, 'is_show_howmany_likes': True, 'is_monetization_allowed': True, 'first_comment': None, 'subtitles': None, 'tags': None}}
        print('same key diff field',ultra[key])
def t2(key):
#overwrite with diff key 

        ultra[key]=new2
        print(ultra[key])

def method1(key):
    ultra[key]=new3
    print(ultra[key])    

def method2(key):
    for filename,video in new3.items(key):
        #     print('debug',filename,video)
        ultra[key][filename]= video
        print(ultra[key])
    print('m2 pass')
for key in ['empty','new']:
    print(f'start to deal {key}')
    for func in [t0,t1,t11,t12,t2,method1,method2]:
        try:
            func(key)
            print(f'{func} ok')

        except :
            print(f'{func} failed')




@ronny-rentner
Copy link
Owner

Thanks, I can reproduce the issue now and will provide a bug fix.

@wanghaisheng
Copy link
Author

make a little update for your reproduce

@wanghaisheng
Copy link
Author

@ronny-rentner anything update

@ronny-rentner
Copy link
Owner

ronny-rentner commented Oct 12, 2023

I've committed a fix now. Please try if it works for you.

You've changed your example a couple of times. In your last example you're doing:

        except :
            print(f'{func} failed')

This is bad because it hides the error. You should better do:

import traceback

...

        except :
            print(f'{func} failed')
            traceback.print_exc()

This will print something like:

  File "/home/ronny/Projects/py/UltraDict/./error2.py", line 44, in method2
    for filename,video in new3.items(key):
                          ^^^^^^^^^^^^^^^
TypeError: dict.items() takes no arguments (1 given)

So in this case, the problem is that you've provided an argument to the items() function which does not accept one.

@wanghaisheng
Copy link
Author

thanks for teaching me .
learned a great trick

@wanghaisheng
Copy link
Author

start to deal empty
<function t0 at 0x7f88859acaf0> ok
<function t1 at 0x7f88859acb80> ok
<function t11 at 0x7f88859acc10> ok
<function t12 at 0x7f88859acca0> ok
<function t2 at 0x7f88859acd30> ok
<function method1 at 0x7f88859acdc0> ok
<function method2 at 0x7f88859ace50> ok
start to deal new
<function t0 at 0x7f88859acaf0> ok
<function t1 at 0x7f88859acb80> ok
<function t11 at 0x7f88859acc10> ok
<function t12 at 0x7f88859acca0> ok
<function t2 at 0x7f88859acd30> ok
<function method1 at 0x7f88859acdc0> ok
<function method2 at 0x7f88859ace50> ok

it do works now

from UltraDict import UltraDict
import traceback,platform

ultra = UltraDict(recurse=True)

if platform.system()=='Windows':

    ultra = UltraDict(shared_lock=True,recurse=True)
ultra['empty']={}
new={'1': {'video_local_path': 'D:/Download/audio-visual/saas/tiktoka/tiktoka-studio-uploader-genius/tests/videos/vertical\\1.mp4', 'video_filename': '1.mp4', 'video_title': 1, 'heading': None, 'subheading': None, 'extraheading': None, 'video_description': None, 'thumbnail_bg_image_path': None, 'thumbnail_local_path': '[]', 'release_date': None, 'release_date_hour': '10:15', 'is_not_for_kid': True, 'categories': None, 'comments_ratings_policy': 1, 'is_age_restriction': False, 'is_paid_promotion': False, 'is_automatic_chapters': True, 'is_featured_place': True, 'video_language': None, 'captions_certification': 0, 'video_film_date': None, 'video_film_location': None, 'license_type': 0, 'is_allow_embedding': True, 'is_publish_to_subscriptions_feed_notify': True, 'shorts_remixing_type': 0, 'is_show_howmany_likes': True, 'is_monetization_allowed': True, 'first_comment': None, 'subtitles': None, 'tags': None}}

new2={'2': {'video_local_path': 'D:/Download/audio-visual/saas/tiktoka/tiktoka-studio-uploader-genius/tests/videos/vertical\\1.mp4', 'video_filename': '1.mp4', 'video_title': 222, 'heading': None, 'subheading': None, 'extraheading': None, 'video_description': None, 'thumbnail_bg_image_path': None, 'thumbnail_local_path': '[]', 'release_date': None, 'release_date_hour': '10:15', 'is_not_for_kid': True, 'categories': None, 'comments_ratings_policy': 1, 'is_age_restriction': False, 'is_paid_promotion': False, 'is_automatic_chapters': True, 'is_featured_place': True, 'video_language': None, 'captions_certification': 0, 'video_film_date': None, 'video_film_location': None, 'license_type': 0, 'is_allow_embedding': True, 'is_publish_to_subscriptions_feed_notify': True, 'shorts_remixing_type': 0, 'is_show_howmany_likes': True, 'is_monetization_allowed': True, 'first_comment': None, 'subtitles': None, 'tags': 'xxxxxx'}}
new3={'3': {'video_local_path': 'D:/Download/audio-visual/saas/tiktoka/tiktoka-studio-uploader-genius/tests/videos/vertical\\1.mp4', 'video_filename': '1.mp4', 'video_title': 222, 'heading': None, 'subheading': None, 'extraheading': None, 'video_description': None, 'thumbnail_bg_image_path': None, 'thumbnail_local_path': '[]', 'release_date': None, 'release_date_hour': '10:15', 'is_not_for_kid': True, 'categories': None, 'comments_ratings_policy': 1, 'is_age_restriction': False, 'is_paid_promotion': False, 'is_automatic_chapters': True, 'is_featured_place': True, 'video_language': None, 'captions_certification': 0, 'video_film_date': None, 'video_film_location': None, 'license_type': 0, 'is_allow_embedding': True, 'is_publish_to_subscriptions_feed_notify': True, 'shorts_remixing_type': 0, 'is_show_howmany_likes': True, 'is_monetization_allowed': True, 'first_comment': None, 'subtitles': None, 'tags': 'xxxxxx'}}


ultra['new']=new
def t0(key):
#overwrite with same dict
    ultra[key]=new


def t1(key):
        #overwrite with same key diff field
        ultra[key]={'1': {'video_local_path': 'C:/Download/audio-visual/saas/tiktoka/tiktoka-studio-uploader-genius/tests/videos/vertical\\1.mp4', 'video_filename': '1.mp4', 'video_title': 1, 'heading': None, 'subheading': None, 'extraheading': None, 'video_description': None, 'thumbnail_bg_image_path': None, 'thumbnail_local_path': '[]', 'release_date': None, 'release_date_hour': '10:15', 'is_not_for_kid': True, 'categories': None, 'comments_ratings_policy': 1, 'is_age_restriction': False, 'is_paid_promotion': False, 'is_automatic_chapters': True, 'is_featured_place': True, 'video_language': None, 'captions_certification': 0, 'video_film_date': None, 'video_film_location': None, 'license_type': 0, 'is_allow_embedding': True, 'is_publish_to_subscriptions_feed_notify': True, 'shorts_remixing_type': 0, 'is_show_howmany_likes': True, 'is_monetization_allowed': True, 'first_comment': None, 'subtitles': None, 'tags': None}}
        # print('same key diff field',ultra[key])
def t11(key):
        #overwrite with same key diff field
        ultra[key]={'1': {'video_local_path': 'C:/Download/audio-visual/saas/tiktoka/tiktoka-studio-uploader-genius/tests/videos/vertical\\1.mp4', 'video_filename': '1.mp4', 'video_title': 1, 'heading': None, 'subheading': None, 'extraheading': None, 'video_description': None, 'thumbnail_bg_image_path': None, 'thumbnail_local_path': '[]', 'release_date': None, 'release_date_hour': '10:15', 'is_not_for_kid': True, 'categories': None, 'comments_ratings_policy': 1, 'is_age_restriction': False, 'is_paid_promotion': False, 'is_automatic_chapters': True, 'is_featured_place': True, 'video_language': None, 'captions_certification': 0, 'video_film_date': None, 'video_film_location': None, 'license_type': 0, 'is_allow_embedding': True, 'is_publish_to_subscriptions_feed_notify': True, 'shorts_remixing_type': 0, 'is_show_howmany_likes': True, 'is_monetization_allowed': True, 'first_comment': None, 'subtitles': None, 'tags': None}}
        # print('same key diff field',ultra[key])
def t12(key):
        # make it a  empty one at first
        ultra[key]=dict({})
        #overwrite with same key diff field

        ultra[key]={'1': {'video_local_path': 'C:/Download/audio-visual/saas/tiktoka/tiktoka-studio-uploader-genius/tests/videos/vertical\\1.mp4', 'video_filename': '1.mp4', 'video_title': 1, 'heading': None, 'subheading': None, 'extraheading': None, 'video_description': None, 'thumbnail_bg_image_path': None, 'thumbnail_local_path': '[]', 'release_date': None, 'release_date_hour': '10:15', 'is_not_for_kid': True, 'categories': None, 'comments_ratings_policy': 1, 'is_age_restriction': False, 'is_paid_promotion': False, 'is_automatic_chapters': True, 'is_featured_place': True, 'video_language': None, 'captions_certification': 0, 'video_film_date': None, 'video_film_location': None, 'license_type': 0, 'is_allow_embedding': True, 'is_publish_to_subscriptions_feed_notify': True, 'shorts_remixing_type': 0, 'is_show_howmany_likes': True, 'is_monetization_allowed': True, 'first_comment': None, 'subtitles': None, 'tags': None}}
        # print('same key diff field',ultra[key])
def t2(key):
#overwrite with diff key 

        ultra[key]=new2
        # print(ultra[key])

def method1(key):
    ultra[key]=new3
    # print(ultra[key])    

def method2(key):
    for filename,video in new3.items():
        #     print('debug',filename,video)
        ultra[key][filename]= video
        # print(ultra[key])
    # print('m2 pass')
for key in ['empty','new']:
    print(f'start to deal {key}')
    for func in [t0,t1,t11,t12,t2,method1,method2]:
        try:
            func(key)
            print(f'{func} ok')

        except :
            print(f'{func} failed')
            traceback.print_exc()




@wanghaisheng
Copy link
Author

@ronny-rentner can you pack a new release to pypi

wanghaisheng added a commit to wanghaisheng/json-dict-in-memory that referenced this issue Dec 12, 2023
Fix for issue ronny-rentner#24, cleanup of recurse_register was too aggressive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants