output_list = []
for module_info in module_infos:
- if module_info.ts_checked:
- date_checked = datetime.datetime.fromtimestamp(
- module_info.ts_checked, self.tz).strftime('%Y-%m-%d %H:%M:%S %Z')
- else:
- date_checked = None
- data = {
- 'name': module_info.name,
- 'vendor': module_info.vendor,
- 'full_name': module_info.full_name,
- 'forge_version': module_info.forge_version,
- 'forge_avail': module_info.forge_avail,
- 'forge_homepage_url': module_info.forge_homepage_url,
- 'repo': module_info.repo,
- 'ts_checked': module_info.ts_checked,
- 'date_checked': date_checked,
- 'version_development': module_info.local_version_output('development'),
- 'version_test': module_info.local_version_output('test'),
- 'version_production': module_info.local_version_output('production'),
- }
- output_list.append(data)
-
- self.print_out(json.dumps(output_list))
+ output_data = self.get_output_data(module_info)
+ output_list.append(output_data)
+
+ indent = None
+ if self.verbose:
+ indent = 4
+
+ self.print_out(json.dumps(output_list, indent=indent, sort_keys=True))
+
+ # -------------------------------------------------------------------------
+ def get_output_data(self, module_info):
+
+ if module_info.ts_checked:
+ date_checked = datetime.datetime.fromtimestamp(
+ module_info.ts_checked, self.tz).strftime('%Y-%m-%d %H:%M:%S %Z')
+ else:
+ date_checked = None
+
+ output_data = {
+ 'name': module_info.name,
+ 'vendor': module_info.vendor,
+ 'full_name': module_info.full_name,
+ 'forge_version': module_info.forge_version,
+ 'forge_avail': module_info.forge_avail,
+ 'forge_homepage_url': module_info.forge_homepage_url,
+ 'repo': module_info.repo,
+ 'ts_checked': module_info.ts_checked,
+ 'date_checked': date_checked,
+ 'version_development': module_info.local_version_output('development'),
+ 'version_test': module_info.local_version_output('test'),
+ 'version_production': module_info.local_version_output('production'),
+ }
+ return output_data
# -------------------------------------------------------------------------
def read_cache_file(self):