Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions gitmetrics/summarize.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import pandas as pd

from gitmetrics.constants import ECOSYSTEM_COLUMN_NAME
from gitmetrics.drive import _get_drive_client, is_drive_path, split_drive_path
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't this is_drive_path be shadowed by the one below?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see other reference for is_drive_path other than line 9 and 128.

from gitmetrics.output import create_spreadsheet, load_spreadsheet
from gitmetrics.time_utils import get_current_year, get_dt_now_spelled_out, get_min_max_dt_in_year

Expand Down Expand Up @@ -118,11 +119,26 @@ def summarize_metrics(
for sheet_name, df in sheets.items():
LOGGER.info(f'Sheet Name: {sheet_name}')
LOGGER.info(df.to_string())

if not dry_run:
# Write to local directory
output_path = os.path.join(dir_path, OUTPUT_FILENAME)
create_spreadsheet(output_path=output_path, sheets=sheets)

if is_drive_path(input_folder):
drive = _get_drive_client()
gdrive_folder = input_folder.rstrip('/') + '/'
folder_id, _ = split_drive_path(gdrive_folder)

folder = drive.CreateFile({'id': folder_id})
folder.FetchMetadata(fields='parents')

parents = folder.get('parents') or []
parent_id = parents[0].get('id')

output_path = f'gdrive://{parent_id}/{OUTPUT_FILENAME}'
create_spreadsheet(output_path=output_path, sheets=sheets)


def _create_df():
columns = [ECOSYSTEM_COLUMN_NAME, TOTAL_COLUMN_NAME]
Expand Down
Loading