Skip to content

Commit c598d9c

Browse files
Created frontend for repository_finder (formerly mining_repo_with_java)
1 parent 55cb62c commit c598d9c

6 files changed

Lines changed: 173 additions & 391 deletions

File tree

README.md

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ Its role is to mine repositories (from the Apache Software Project) to see how m
66
## Table of Contents
77
- [Installing](#installing)
88
- [Run Analysis](#run-analysis)
9-
- [Parameters](#parameters)
10-
- [Help](#help)
9+
- [Parameters](#analysis-parameters)
10+
- [Help](#analysis-help)
11+
- [Run Repo Finder](#run-repo-finder)
12+
- [Parameters](#repo-finder-parameters)
13+
- [Help](#finder-help)
1114
- [Run Tests](#run-tests)
1215

1316
## Installing
@@ -31,7 +34,8 @@ python tdd_analysis.py [--date DATE] [--language LANGUAGE] [--languages LANGUAG
3134
[--verbose]
3235
```
3336

34-
### Parameters
37+
### Analysis Parameters
38+
3539
- `--date DATE (optional)`: The date for the experiment in YYYY-MM-DD format. Defaults to a specific date in `tdd_analysis.py`.
3640

3741
- `--language LANGUAGE (optional)`: Single programming language to analyse. Defaults to `Java`.
@@ -52,13 +56,38 @@ python tdd_analysis.py [--date DATE] [--language LANGUAGE] [--languages LANGUAG
5256

5357
- `--verbose (optional)`: Enable verbose output for debugging or detailed logs.
5458

55-
### Help
59+
60+
### Analysis Help
5661
To display a help message with detailed usage instructions, run:
5762

5863
```bash
5964
python tdd_analysis.py --help
6065
```
6166

67+
## Run Repo Finder
68+
To execute the repo finder, use the command-line interface:
69+
```bash
70+
python find_repos.py [--github_token TOKEN] [--organisation ORGANISATION] [--language LANGUAGE] [--pagination PAGINATION] [--maximum MAXIMUM]
71+
```
72+
73+
### Repo Finder Parameters
74+
- `--github_token GITHUB_TOKEN`: Personal GitHub token. For information on how to create one, visit: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-fine-grained-personal-access-token
75+
76+
- `--language LANGUAGE`: Programming language to find repositories for.
77+
78+
- `--organisation --org ORGANISATION (optional)`: Organisation to find repositories for. (default: Apache)
79+
80+
- `--pagination PAGINATION (optional)`: Pagination for searching GitHub. Defaults to 100.
81+
82+
- `--maximum --max MAXIMUM (optional)`: Maximum number of repositories to find.
83+
84+
### Finder Help
85+
To display a help message with detailed usage instructions, run:
86+
87+
```bash
88+
python find_repos.py --help
89+
```
90+
6291
## Run Tests
6392
To run the unit tests, simply call:
6493
```bash

find_repos.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/usr/bin/env python
2+
3+
import argparse
4+
import asyncio
5+
import logging
6+
import sys
7+
from src.mining.repository_finder import RepositoryFinder
8+
9+
def _get_parameters():
10+
parser = argparse.ArgumentParser(
11+
description="Find repositories on GitHub.",
12+
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
13+
)
14+
15+
parser.add_argument(
16+
"--github_token",
17+
required=True,
18+
type=str,
19+
help="Personal GitHub token. For information on how to create one, visit: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-fine-grained-personal-access-token"
20+
)
21+
parser.add_argument(
22+
"--language",
23+
required=True,
24+
type=str,
25+
help="Programming language to find repositories for.",
26+
)
27+
parser.add_argument(
28+
"--organisation",
29+
"--org",
30+
type=str,
31+
default=RepositoryFinder.APACHE_ORGANISATION,
32+
help="Organisation to find repositories for."
33+
)
34+
parser.add_argument(
35+
"--pagination",
36+
type=int,
37+
default = 100,
38+
help="Pagination for retrieving repositories."
39+
)
40+
parser.add_argument(
41+
"--maximum",
42+
"--max",
43+
type=int,
44+
help="Maximum number of repositories to find."
45+
)
46+
47+
args = parser.parse_args()
48+
49+
if args.pagination < 1:
50+
raise argparse.ArgumentError(None, "--pagination cannot be lower than 1.")
51+
if args.maximum is not None and args.maximum < 1:
52+
raise argparse.ArgumentError(None, "--maximum cannot be lower than 1.")
53+
54+
return args
55+
56+
async def main():
57+
try:
58+
args = _get_parameters()
59+
60+
repository_finder = RepositoryFinder(args.github_token)
61+
repository_finder.extract_repositories(args.organisation.lower(), args.pagination, args.language.lower(), args.maximum)
62+
63+
print("Repository find complete.")
64+
65+
except Exception as e:
66+
logging.exception(e)
67+
print(f"Error: {e}", file=sys.stderr)
68+
sys.exit(1)
69+
70+
if __name__ == "__main__":
71+
asyncio.run(main())

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ pytest-asyncio
44
matplotlib~=3.9.4
55
tqdm
66
requests
7-
numpy
7+
numpy

src/mining/mining_repo_with_java.py

Lines changed: 0 additions & 67 deletions
This file was deleted.

0 commit comments

Comments
 (0)