ronny-rentner / UltraDict

Sychronized, streaming Python dictionary that uses shared memory as a backend
Apache License 2.0
266 stars 25 forks source link

json str issue #24

Open wanghaisheng opened 11 months ago

wanghaisheng commented 11 months ago
==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 commented 11 months ago

@ronny-rentner

wanghaisheng commented 11 months ago
                                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 commented 11 months ago

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

this one wont work either

ronny-rentner commented 11 months ago

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

wanghaisheng commented 11 months ago

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

ronny-rentner commented 11 months ago

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 commented 11 months ago

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 commented 11 months ago

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 commented 11 months ago

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 commented 11 months ago

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 commented 11 months ago

I will try to provide a minimal example for you

wanghaisheng commented 11 months ago

@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 commented 11 months ago
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 commented 11 months ago

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

wanghaisheng commented 11 months ago

make a little update for your reproduce

wanghaisheng commented 11 months ago

@ronny-rentner anything update

ronny-rentner commented 11 months ago

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 commented 11 months ago

thanks for teaching me . learned a great trick

wanghaisheng commented 11 months ago

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 commented 11 months ago

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