Add some lab 15 contents

This commit is contained in:
Isaac Shoebottom 2022-11-02 10:02:15 -03:00
parent 0f1e8d5e36
commit 45c5b94e63
6 changed files with 90 additions and 0 deletions

View File

@ -0,0 +1,24 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="globex" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true">
<module name="L15" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="C:\Users\Isaac\Documents\CS2613-Repo\cs2613-ishoebot\labs\L15\globex.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
</component>

View File

@ -0,0 +1,17 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="pytest" type="ShConfigurationType">
<option name="SCRIPT_TEXT" value="pytest --cov --cov-report=term-missing" />
<option name="INDEPENDENT_SCRIPT_PATH" value="true" />
<option name="SCRIPT_PATH" value="" />
<option name="SCRIPT_OPTIONS" value="" />
<option name="INDEPENDENT_SCRIPT_WORKING_DIRECTORY" value="true" />
<option name="SCRIPT_WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="INDEPENDENT_INTERPRETER_PATH" value="true" />
<option name="INTERPRETER_PATH" value="" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="EXECUTE_IN_TERMINAL" value="true" />
<option name="EXECUTE_SCRIPT_FILE" value="false" />
<envs />
<method v="2" />
</configuration>
</component>

23
labs/L15/globex.py Normal file
View File

@ -0,0 +1,23 @@
#!/usr/bin/python3
import glob
import os
# new_dir = os.path.expanduser("~/fcshome/cs2613/labs/test") # For lab machines
new_dir = os.path.abspath("C:\\Users\\Isaac\\Documents\\CS2613-Repo\\cs2613-ishoebot\\labs\\L14") # For local machine
python_files_for = []
for file in glob.glob("*.py"):
python_files_for.append(os.path.join(new_dir, file))
python_files_comp = [os.path.join(new_dir, file) for file in glob.glob("*.py")]
python_files_map = map(lambda file: os.path.join(new_dir, file), glob.glob("*.py"))
if __name__ == '__main__': # pragma: no cover
print(python_files_for)
print()
print(python_files_comp)
print()
print(list(python_files_map))

7
labs/L15/list2dict.py Normal file
View File

@ -0,0 +1,7 @@
def list2dict(lst):
lst_dict = dict()
counter = 1
for i in range(lst):
lst_dict[counter] = i
counter += 1
return lst_dict

9
labs/L15/test_globex.py Normal file
View File

@ -0,0 +1,9 @@
import globex
def test_for():
assert sorted(globex.python_files_for) == sorted(globex.python_files_comp)
def test_map():
assert sorted(globex.python_files_comp) == sorted(globex.python_files_map)

View File

@ -0,0 +1,10 @@
from list2dict import list2dict
def test_empty():
assert list2dict([]) == {}
def test_abc():
dictionary = list2dict(["a", "b", "c"])
assert dictionary == {1: 'a', 2: 'b', 3: 'c'}