mirror of
https://github.com/karma-riuk/crab.git
synced 2025-07-05 05:28:13 +02:00
extracted function to utils
This commit is contained in:
@ -1,28 +1,15 @@
|
|||||||
import os, logging
|
import os
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
from github import Github
|
from github import Github
|
||||||
from utils import has_only_1_round_of_comments, has_only_1_comment
|
from utils import has_only_1_round_of_comments, has_only_1_comment, move_github_logging_to_file
|
||||||
|
|
||||||
tqdm.pandas()
|
tqdm.pandas()
|
||||||
|
|
||||||
# Initialize GitHub API client
|
# Initialize GitHub API client
|
||||||
g = Github(os.environ["GITHUB_AUTH_TOKEN_CRAB"])
|
g = Github(os.environ["GITHUB_AUTH_TOKEN_CRAB"])
|
||||||
|
|
||||||
def move_github_logging_to_file():
|
|
||||||
github_logger = logging.getLogger("github")
|
|
||||||
|
|
||||||
# Remove existing handlers to prevent duplicate logging
|
|
||||||
for handler in github_logger.handlers[:]:
|
|
||||||
github_logger.removeHandler(handler)
|
|
||||||
|
|
||||||
file_handler = logging.FileHandler("github_api.log") # Log to file
|
|
||||||
formatter = logging.Formatter("%(asctime)s - %(levelname)s - %(message)s")
|
|
||||||
file_handler.setFormatter(formatter)
|
|
||||||
github_logger.addHandler(file_handler)
|
|
||||||
github_logger.propagate = False # Prevent logging to standard output
|
|
||||||
|
|
||||||
def process_pull(repo, pull):
|
def process_pull(repo, pull):
|
||||||
commits = pull.get_commits()
|
commits = pull.get_commits()
|
||||||
comments = pull.get_review_comments()
|
comments = pull.get_review_comments()
|
||||||
|
14
utils.py
14
utils.py
@ -3,6 +3,20 @@ from github.Commit import Commit
|
|||||||
from github.PaginatedList import PaginatedList
|
from github.PaginatedList import PaginatedList
|
||||||
from github.PullRequestComment import PullRequestComment
|
from github.PullRequestComment import PullRequestComment
|
||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
|
import logging
|
||||||
|
|
||||||
|
def move_github_logging_to_file():
|
||||||
|
github_logger = logging.getLogger("github")
|
||||||
|
|
||||||
|
# Remove existing handlers to prevent duplicate logging
|
||||||
|
for handler in github_logger.handlers[:]:
|
||||||
|
github_logger.removeHandler(handler)
|
||||||
|
|
||||||
|
file_handler = logging.FileHandler("github_api.log") # Log to file
|
||||||
|
formatter = logging.Formatter("%(asctime)s - %(levelname)s - %(message)s")
|
||||||
|
file_handler.setFormatter(formatter)
|
||||||
|
github_logger.addHandler(file_handler)
|
||||||
|
github_logger.propagate = False # Prevent logging to standard output
|
||||||
|
|
||||||
def parse_date(date: str) -> datetime:
|
def parse_date(date: str) -> datetime:
|
||||||
return datetime.strptime(date, "%Y-%m-%dT%H:%M:%SZ")
|
return datetime.strptime(date, "%Y-%m-%dT%H:%M:%SZ")
|
||||||
|
Reference in New Issue
Block a user