Delete app names
This commit is contained in:
@@ -272,11 +272,14 @@ def appids_in_data(selection=['*']):
|
|||||||
# JSON
|
# JSON
|
||||||
|
|
||||||
def try_del(index, keys):
|
def try_del(index, keys):
|
||||||
|
did_change = False
|
||||||
for x in keys:
|
for x in keys:
|
||||||
try:
|
try:
|
||||||
del(index[x])
|
del(index[x])
|
||||||
|
did_change = True
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
return did_change
|
||||||
|
|
||||||
|
|
||||||
def json_read(path):
|
def json_read(path):
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ def get_name(bundle_id, langs=['us', 'de'], fallback='< App-Name >'):
|
|||||||
return fallback # None
|
return fallback # None
|
||||||
|
|
||||||
|
|
||||||
def process(bundle_ids):
|
def process(bundle_ids, deleteOnly=False):
|
||||||
print('writing index: app names ...')
|
print('writing index: app names ...')
|
||||||
if bundle_ids == ['*']:
|
if bundle_ids == ['*']:
|
||||||
print(' full reset')
|
print(' full reset')
|
||||||
@@ -48,13 +48,22 @@ def process(bundle_ids):
|
|||||||
load_json_if_not_already()
|
load_json_if_not_already()
|
||||||
did_change = False
|
did_change = False
|
||||||
for bid in mylib.appids_in_data(bundle_ids):
|
for bid in mylib.appids_in_data(bundle_ids):
|
||||||
|
if deleteOnly:
|
||||||
|
did_change |= mylib.try_del(_bundle_name_dict, [bid])
|
||||||
|
continue
|
||||||
names = download_itunes.get_app_names(bid)
|
names = download_itunes.get_app_names(bid)
|
||||||
if not names:
|
if not names:
|
||||||
mylib.err('index-app-names', 'could not load: {}'.format(bid))
|
mylib.err('index-app-names', 'could not load: {}'.format(bid))
|
||||||
continue
|
continue
|
||||||
|
try:
|
||||||
|
if _bundle_name_dict[bid] == names:
|
||||||
|
continue
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
_bundle_name_dict[bid] = names
|
_bundle_name_dict[bid] = names
|
||||||
did_change = True
|
did_change = True
|
||||||
if did_change:
|
if did_change:
|
||||||
|
print(' writing')
|
||||||
write_json_to_disk()
|
write_json_to_disk()
|
||||||
else:
|
else:
|
||||||
print(' no change')
|
print(' no change')
|
||||||
@@ -66,5 +75,5 @@ if __name__ == '__main__':
|
|||||||
if len(args) > 0:
|
if len(args) > 0:
|
||||||
process(args)
|
process(args)
|
||||||
else:
|
else:
|
||||||
# process(['*'])
|
# process(['*'], deleteOnly=False)
|
||||||
mylib.usage(__file__, '[bundle_id] [...]')
|
mylib.usage(__file__, '[bundle_id] [...]')
|
||||||
|
|||||||
Reference in New Issue
Block a user