<commit_before>#! /usr/bin/env python
"""Performs (incremental) backups of activities for a given Garmin Connect
account.
The activities are stored in a local directory on the user's computer.
The backups are incremental, meaning that only activities that aren't already
stored in the backup directory will be downloaded.
"""
import argparse
import getpass
from garminexport.garminclient import GarminClient
import garminexport.util
import logging
import os
import re
import sys
import traceback

logging.basicConfig(
    level=logging.INFO, format="%(asctime)-15s [%(levelname)s] %(message)s")
log = logging.getLogger(__name__)

LOG_LEVELS = {
    "DEBUG": logging.DEBUG,
    "INFO": logging.INFO,
    "WARNING": logging.WARNING,
    "ERROR": logging.ERROR
}
"""Command-line (string-based) log-level mapping to logging module levels."""

def get_backed_up_ids(backup_dir):
    """Return all activitiy ids that have been backed up in the
    given backup directory.

    :rtype: list of int
    """
    # backed up activities follow this pattern
    activity_file_pattern = r'[0-9]+\-[0-9]+_([0-9]+)_summary\.json'
    
    backed_up_ids = []
    dir_entries = os.listdir(backup_dir)
    for entry in dir_entries:
        activity_match = re.search(activity_file_pattern, entry)
        if activity_match:
            backed_up_id = int(activity_match.group(1))
            backed_up_ids.append(backed_up_id)
    return backed_up_ids           
    

if __name__ == "__main__":
    parser = argparse.ArgumentParser(
        description=(
            "Performs incremental backups of activities for a "
            "given Garmin Connect account. Only activities that "<commit_msg>fixed bug in incremental backup<commit_after>#! /usr/bin/env python
"""Performs (incremental) backups of activities for a given Garmin Connect
account.
The activities are stored in a local directory on the user's computer.
The backups are incremental, meaning that only activities that aren't already
stored in the backup directory will be downloaded.
"""
import argparse
import getpass
from garminexport.garminclient import GarminClient
import garminexport.util
import logging
import os
import re
import sys
import traceback

logging.basicConfig(
    level=logging.INFO, format="%(asctime)-15s [%(levelname)s] %(message)s")
log = logging.getLogger(__name__)

LOG_LEVELS = {
    "DEBUG": logging.DEBUG,
    "INFO": logging.INFO,
    "WARNING": logging.WARNING,
    "ERROR": logging.ERROR
}
"""Command-line (string-based) log-level mapping to logging module levels."""

def get_backed_up_ids(backup_dir):
    """Return all activitiy ids that have been backed up in the
    given backup directory.

    :rtype: list of int
    """
    # backed up activities follow this pattern: <ISO8601>_<id>_summary.json
    activity_file_pattern = r'[\d:T\+\-]+_([0-9]+)_summary\.json'
    
    backed_up_ids = []
    dir_entries = os.listdir(backup_dir)
    for entry in dir_entries:
        activity_match = re.search(activity_file_pattern, entry)
        if activity_match:
            backed_up_id = int(activity_match.group(1))
            backed_up_ids.append(backed_up_id)
    return backed_up_ids           
    

if __name__ == "__main__":
    parser = argparse.ArgumentParser(
        description=(
            "Performs incremental backups of activities for a "
            "given Garmin Connect account. Only activities that "
{'fraction_non_alphanumeric': 0.09259259259259259, 'fraction_numerical': 0.005291005291005291, 'mean_word_length': 3.604871447902571, 'pattern_counts': {'":': 10, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6161670', 'n_tokens_mistral': 1019, 'n_tokens_neox': 988, 'n_words': 313}