Skip to content

Commit 2b8f58f

Browse files
committed
Changed get_problems_list to get_problems_count
1 parent 5ec9059 commit 2b8f58f

File tree

5 files changed

+68
-177
lines changed

5 files changed

+68
-177
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ The format is based on [Keep a Changelog][Keep a Changelog], and this project ad
2424

2525
- Updated `eslint.workingDirectories` in settings.
2626
- VSCode launch.json `mainClass` for one configuration.
27+
- Changed `get_problems_list` to `get_problems_count`.
2728

2829
### Removed
2930

static-to-copy/.vscode/tasks.json

+11-8
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
"label": "echo",
88
"type": "shell",
99
"command": "echo",
10-
"args": ["Hello"]
11-
},
10+
"args": [
11+
"Hello"
12+
]
13+
},
1214
{
1315
"label": "gradlew-build",
1416
"type": "shell",
@@ -40,21 +42,22 @@
4042
"windows": {
4143
"command": ".\\gradlew.bat test jacocoJupTestReport"
4244
}
43-
}, {
45+
},
46+
{
4447
"label": "run-xunit-tests",
4548
"type": "shell",
4649
"command": "python ${workspaceFolder}/scripts/run_xunit_tests.py"
47-
},
50+
},
4851
{
49-
"label": "create-problems-list",
52+
"label": "get-problems-count",
5053
"type": "shell",
51-
"command": "python ${workspaceFolder}/scripts/create_problems_list.py"
52-
},
54+
"command": "python ${workspaceFolder}/scripts/get_problems_count.py"
55+
},
5356
{
5457
"label": "run-python-unit-tests",
5558
"type": "shell",
5659
"command": "python ${workspaceFolder}/scripts/run_unit_tests.py"
57-
},
60+
},
5861
{
5962
"label": "run-python-unit-tests-coverage",
6063
"type": "shell",

static-to-copy/Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ pythoncode: pythontestcoverage
5858
# Project tasks
5959
#*****************
6060

61-
createproblemslist:
62-
python ${workspaceFolder}scripts/create_problems_list.py
61+
getproblemscount:
62+
python ${workspaceFolder}scripts/get_problems_count.py
6363

6464
#*****************
6565
# All tasks
6666
#*****************
6767

6868
code: javacode pythoncode csharpcode
6969

70-
all: createproblemslist code
70+
all: getproblemscount code
7171

static-to-copy/scripts/create_problems_list.py

-166
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
"""
2+
Script to get list of all problems by parsing readme.md from all subdirectories under ..\\src\\
3+
pip install -r python-requirements.txt
4+
"""
5+
6+
import os
7+
import json
8+
9+
10+
def find_files():
11+
"""Return the list of files to process."""
12+
result = {}
13+
root_dir = "src"
14+
cwd = os.getcwd()
15+
#print(os.listdir(root_dir))
16+
for root, dirs, files in os.walk(root_dir):
17+
dirs.sort()
18+
for file in files:
19+
if file.endswith("metadata.json"):
20+
metadatafile = os.path.join(cwd, root, file)
21+
contents = open(metadatafile)
22+
metadata = json.load(contents)
23+
languages = ""
24+
if metadata["type"] == "Coding":
25+
languages = dirs
26+
result[root] = (metadatafile, languages)
27+
return result
28+
29+
30+
def get_problems_count(files):
31+
"""Creates the list of problems in markdown and json files."""
32+
count = 0
33+
for item in files.items():
34+
input_file = open(item[1][0], mode="r", encoding="utf-8")
35+
text = input_file.read()
36+
json_parsed = json.loads(text)
37+
38+
if 'skip_for_problems_list' in json_parsed and json_parsed[
39+
'skip_for_problems_list'] == "True":
40+
continue
41+
42+
count = count + 1
43+
print(f"Total problems: {count}")
44+
45+
46+
def main():
47+
"""main method."""
48+
files = find_files()
49+
get_problems_count(files)
50+
51+
52+
if __name__ == '__main__':
53+
main()

0 commit comments

Comments
 (0)