[O] Default to indent none to save space

This commit is contained in:
Hykilpikonna
2021-11-22 15:22:09 -05:00
parent 1c6629e504
commit d9a78baa3d
4 changed files with 10 additions and 4 deletions
+6
View File
@@ -41,3 +41,9 @@ if __name__ == '__main__':
# Data processing - Step P2
# (After step C2) Process the downloaded tweets, determine whether they are covid-related
process_tweets()
# Who posted the most covid tweets? (covid vs non-covid ratio)
# - Graph histogram of this ratio
# Who has the most covid tweet popularity (popularity of covid vs non-covid tweets ratio)
# - Graph histogram of this ratio
+2 -2
View File
@@ -49,7 +49,7 @@ def process_users_popularity(user_dir: str = './data/twitter/user/') -> None:
users.sort(key=lambda x: x.popularity, reverse=True)
# Save data
write(f'{user_dir}/processed/popularity.json', json_stringify(users, indent=None))
write(f'{user_dir}/processed/popularity.json', json_stringify(users))
def load_users_popularity(user_dir: str = './data/twitter/user/') -> list[UserPopularity]:
@@ -110,7 +110,7 @@ def process_tweets(tweets_dir: str = './data/twitter/user-tweets/') -> None:
for t in tweets]
# Save data
write(f'{tweets_dir}/processed/{filename}', json_stringify(p, indent=None))
write(f'{tweets_dir}/processed/{filename}', json_stringify(p))
debug(f'Processed: {filename}')
+1 -1
View File
@@ -283,7 +283,7 @@ def download_users_execute(api: API, n: float, base_dir: str,
# Update meta info so that downloading can be continued
meta = {'downloaded': downloaded, 'done_set': done_set,
'current_set': current_set, 'next_set': next_set, 'n': n}
write(f'{base_dir}/meta/meta.json', json_stringify(meta, indent=None))
write(f'{base_dir}/meta/meta.json', json_stringify(meta))
debug(f'Finished saving friends of {screen_name}')
debug(f'============= Total {len(downloaded)} saved =============')
+1 -1
View File
@@ -140,7 +140,7 @@ class EnhancedJSONEncoder(json.JSONEncoder):
return super().default(o)
def json_stringify(obj, indent: Union[int, None] = 1) -> str:
def json_stringify(obj, indent: Union[int, None] = None) -> str:
"""
Serialize json string with support for dataclasses and datetime and sets and with custom
configuration.