diff --git a/labs/L15/.idea/runConfigurations/globex.xml b/labs/L15/.idea/runConfigurations/globex.xml new file mode 100644 index 0000000..a8f1ac1 --- /dev/null +++ b/labs/L15/.idea/runConfigurations/globex.xml @@ -0,0 +1,24 @@ + + + + + \ No newline at end of file diff --git a/labs/L15/.idea/runConfigurations/pytest.xml b/labs/L15/.idea/runConfigurations/pytest.xml new file mode 100644 index 0000000..42431bf --- /dev/null +++ b/labs/L15/.idea/runConfigurations/pytest.xml @@ -0,0 +1,17 @@ + + + + \ No newline at end of file diff --git a/labs/L15/globex.py b/labs/L15/globex.py new file mode 100644 index 0000000..53e73ee --- /dev/null +++ b/labs/L15/globex.py @@ -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)) diff --git a/labs/L15/list2dict.py b/labs/L15/list2dict.py new file mode 100644 index 0000000..a5db4f4 --- /dev/null +++ b/labs/L15/list2dict.py @@ -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 diff --git a/labs/L15/test_globex.py b/labs/L15/test_globex.py new file mode 100644 index 0000000..a09f870 --- /dev/null +++ b/labs/L15/test_globex.py @@ -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) diff --git a/labs/L15/test_list2dict.py b/labs/L15/test_list2dict.py new file mode 100644 index 0000000..0b1435a --- /dev/null +++ b/labs/L15/test_list2dict.py @@ -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'}