mirror of
https://github.com/QualityInUse/lab-metrics-maksktl.git
synced 2026-08-05 12:05:27 +03:00
lab metrics
This commit is contained in:
@@ -1,3 +1,38 @@
|
|||||||
name: lab-metrics
|
name: lab-metrics
|
||||||
|
|
||||||
# add your pipline description below
|
# add your pipline description below
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
lint:
|
||||||
|
name: Lint
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: '3.12'
|
||||||
|
- name: Run image
|
||||||
|
uses: abatilo/actions-poetry@v2
|
||||||
|
with:
|
||||||
|
poetry-version: '1.7.1'
|
||||||
|
- name: Install dependencies
|
||||||
|
run: poetry install; poetry add flake8
|
||||||
|
- name: Run flake8
|
||||||
|
run: poetry run flake8
|
||||||
|
complexity-check:
|
||||||
|
name: Complexity
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: '3.12'
|
||||||
|
- name: Run image
|
||||||
|
uses: abatilo/actions-poetry@v2
|
||||||
|
with:
|
||||||
|
poetry-version: '1.7.1'
|
||||||
|
- name: Install dependencies
|
||||||
|
run: poetry install; poetry add flake8
|
||||||
|
- name: Run flake8 complexity
|
||||||
|
run: poetry run flake8 --max-complexity 10
|
||||||
@@ -158,3 +158,4 @@ cython_debug/
|
|||||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||||
#.idea/
|
#.idea/
|
||||||
|
/.idea/
|
||||||
|
|||||||
+42
-28
@@ -4,13 +4,14 @@ import random
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
# Constants
|
# Constants
|
||||||
WORDS = ("python", "jumble", "easy", "difficult", "answer", "xylophone", "hangman",
|
WORDS = ("python", "jumble", "easy", "difficult", "answer", "xylophone",
|
||||||
"computer", "science", "programming", "mathematics", "player", "condition",
|
"hangman", "computer", "science", "programming", "mathematics",
|
||||||
"reverse", "water", "board", "geeks", "keyboard", "laptop", "headphone",
|
"player", "condition", "reverse", "water", "board", "geeks",
|
||||||
"mouse", "printer", "scanner", "software", "hardware", "network", "server")
|
"keyboard", "laptop", "headphone", "mouse", "printer",
|
||||||
|
"scanner", "software", "hardware", "network", "server")
|
||||||
|
|
||||||
HANGMAN_STAGES = (
|
HANGMAN_STAGES = (
|
||||||
"""
|
"""
|
||||||
-------
|
-------
|
||||||
|/ |
|
|/ |
|
||||||
|
|
|
|
||||||
@@ -20,7 +21,7 @@ HANGMAN_STAGES = (
|
|||||||
|
|
|
|
||||||
/|\\
|
/|\\
|
||||||
-----------
|
-----------
|
||||||
""","""
|
""", """
|
||||||
-------
|
-------
|
||||||
|/ |
|
|/ |
|
||||||
| O
|
| O
|
||||||
@@ -30,7 +31,7 @@ HANGMAN_STAGES = (
|
|||||||
|
|
|
|
||||||
/|\\
|
/|\\
|
||||||
-----------
|
-----------
|
||||||
""","""
|
""", """
|
||||||
-------
|
-------
|
||||||
|/ |
|
|/ |
|
||||||
| O
|
| O
|
||||||
@@ -40,7 +41,7 @@ HANGMAN_STAGES = (
|
|||||||
|
|
|
|
||||||
/|\\
|
/|\\
|
||||||
-----------
|
-----------
|
||||||
""","""
|
""", """
|
||||||
-------
|
-------
|
||||||
|/ |
|
|/ |
|
||||||
| O
|
| O
|
||||||
@@ -50,7 +51,7 @@ HANGMAN_STAGES = (
|
|||||||
|
|
|
|
||||||
/|\\
|
/|\\
|
||||||
-----------
|
-----------
|
||||||
""","""
|
""", """
|
||||||
-------
|
-------
|
||||||
|/ |
|
|/ |
|
||||||
| O
|
| O
|
||||||
@@ -60,7 +61,7 @@ HANGMAN_STAGES = (
|
|||||||
|
|
|
|
||||||
/|\\
|
/|\\
|
||||||
-----------
|
-----------
|
||||||
""","""
|
""", """
|
||||||
-------
|
-------
|
||||||
|/ |
|
|/ |
|
||||||
| O
|
| O
|
||||||
@@ -70,7 +71,7 @@ HANGMAN_STAGES = (
|
|||||||
|
|
|
|
||||||
/|\\
|
/|\\
|
||||||
-----------
|
-----------
|
||||||
""","""
|
""", """
|
||||||
-------
|
-------
|
||||||
|/ |
|
|/ |
|
||||||
| O
|
| O
|
||||||
@@ -80,7 +81,7 @@ HANGMAN_STAGES = (
|
|||||||
|
|
|
|
||||||
/|\\
|
/|\\
|
||||||
-----------
|
-----------
|
||||||
""","""
|
""", """
|
||||||
-------
|
-------
|
||||||
|/ |
|
|/ |
|
||||||
| O
|
| O
|
||||||
@@ -92,15 +93,18 @@ HANGMAN_STAGES = (
|
|||||||
-----------
|
-----------
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
|
||||||
# Functions
|
# Functions
|
||||||
def clear_screen():
|
def clear_screen():
|
||||||
"""Clears the screen."""
|
"""Clears the screen."""
|
||||||
os.system("cls" if os.name == "nt" else "clear")
|
os.system("cls" if os.name == "nt" else "clear")
|
||||||
|
|
||||||
|
|
||||||
def get_random_word():
|
def get_random_word():
|
||||||
"""Returns a random word from the WORDS tuple."""
|
"""Returns a random word from the WORDS tuple."""
|
||||||
return random.choice(WORDS)
|
return random.choice(WORDS)
|
||||||
|
|
||||||
|
|
||||||
def splash_screen():
|
def splash_screen():
|
||||||
"""The splash screen."""
|
"""The splash screen."""
|
||||||
print("""
|
print("""
|
||||||
@@ -115,6 +119,28 @@ def splash_screen():
|
|||||||
clear_screen()
|
clear_screen()
|
||||||
|
|
||||||
|
|
||||||
|
def single_letter_check(guessed_letters):
|
||||||
|
while True:
|
||||||
|
guess = input("Guess a letter: ").lower()
|
||||||
|
if len(guess) == 1 and guess.isalpha():
|
||||||
|
# check if letter has already been guessed
|
||||||
|
if guess in guessed_letters:
|
||||||
|
print("You have already guessed that letter.")
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
print("Invalid guess. Please enter a single letter.")
|
||||||
|
return guess
|
||||||
|
|
||||||
|
|
||||||
|
def add_guess_to_word(word, guess, guessed_word):
|
||||||
|
# add guess to guessed word
|
||||||
|
for i in range(len(word)):
|
||||||
|
if word[i] == guess:
|
||||||
|
guessed_word[i] = guess
|
||||||
|
return guessed_word
|
||||||
|
|
||||||
|
|
||||||
def hangman():
|
def hangman():
|
||||||
"""The hangman game."""
|
"""The hangman game."""
|
||||||
try:
|
try:
|
||||||
@@ -132,7 +158,7 @@ def hangman():
|
|||||||
print("Hangman game. Try to guess the word. (CTRL+C to quit)")
|
print("Hangman game. Try to guess the word. (CTRL+C to quit)")
|
||||||
print(HANGMAN_STAGES[wrong_guesses])
|
print(HANGMAN_STAGES[wrong_guesses])
|
||||||
print(" ".join(guessed_word), end=' ')
|
print(" ".join(guessed_word), end=' ')
|
||||||
print("(Guessed letters: " + ", ".join(guessed_letters),")")
|
print("(Guessed letters: " + ", ".join(guessed_letters), ")")
|
||||||
print()
|
print()
|
||||||
|
|
||||||
# check if player has won
|
# check if player has won
|
||||||
@@ -141,31 +167,19 @@ def hangman():
|
|||||||
break
|
break
|
||||||
|
|
||||||
# check if player has lost
|
# check if player has lost
|
||||||
if wrong_guesses == len(HANGMAN_STAGES)-1:
|
if wrong_guesses == len(HANGMAN_STAGES) - 1:
|
||||||
print("You lose!")
|
print("You lose!")
|
||||||
break
|
break
|
||||||
|
|
||||||
# make sure player enters a single letter
|
# make sure player enters a single letter
|
||||||
while True:
|
guess = single_letter_check(guessed_letters)
|
||||||
guess = input("Guess a letter: ").lower()
|
|
||||||
if len(guess) == 1 and guess.isalpha():
|
|
||||||
# check if letter has already been guessed
|
|
||||||
if guess in guessed_letters:
|
|
||||||
print("You have already guessed that letter.")
|
|
||||||
else:
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
print("Invalid guess. Please enter a single letter.")
|
|
||||||
|
|
||||||
# add guess to guessed letters
|
# add guess to guessed letters
|
||||||
guessed_letters.append(guess)
|
guessed_letters.append(guess)
|
||||||
|
|
||||||
# check if guess is in word
|
# check if guess is in word
|
||||||
if guess in word:
|
if guess in word:
|
||||||
# add guess to guessed word
|
guessed_word = add_guess_to_word(word, guess, guessed_word)
|
||||||
for i in range(len(word)):
|
|
||||||
if word[i] == guess:
|
|
||||||
guessed_word[i] = guess
|
|
||||||
else:
|
else:
|
||||||
# increment wrong guesses
|
# increment wrong guesses
|
||||||
wrong_guesses += 1
|
wrong_guesses += 1
|
||||||
|
|||||||
Generated
+51
-3
@@ -1,7 +1,55 @@
|
|||||||
# This file is automatically @generated by Poetry 1.6.1 and should not be changed by hand.
|
# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand.
|
||||||
package = []
|
|
||||||
|
[[package]]
|
||||||
|
name = "flake8"
|
||||||
|
version = "7.0.0"
|
||||||
|
description = "the modular source code checker: pep8 pyflakes and co"
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=3.8.1"
|
||||||
|
files = [
|
||||||
|
{file = "flake8-7.0.0-py2.py3-none-any.whl", hash = "sha256:a6dfbb75e03252917f2473ea9653f7cd799c3064e54d4c8140044c5c065f53c3"},
|
||||||
|
{file = "flake8-7.0.0.tar.gz", hash = "sha256:33f96621059e65eec474169085dc92bf26e7b2d47366b70be2f67ab80dc25132"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[package.dependencies]
|
||||||
|
mccabe = ">=0.7.0,<0.8.0"
|
||||||
|
pycodestyle = ">=2.11.0,<2.12.0"
|
||||||
|
pyflakes = ">=3.2.0,<3.3.0"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "mccabe"
|
||||||
|
version = "0.7.0"
|
||||||
|
description = "McCabe checker, plugin for flake8"
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=3.6"
|
||||||
|
files = [
|
||||||
|
{file = "mccabe-0.7.0-py2.py3-none-any.whl", hash = "sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e"},
|
||||||
|
{file = "mccabe-0.7.0.tar.gz", hash = "sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pycodestyle"
|
||||||
|
version = "2.11.1"
|
||||||
|
description = "Python style guide checker"
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=3.8"
|
||||||
|
files = [
|
||||||
|
{file = "pycodestyle-2.11.1-py2.py3-none-any.whl", hash = "sha256:44fe31000b2d866f2e41841b18528a505fbd7fef9017b04eff4e2648a0fadc67"},
|
||||||
|
{file = "pycodestyle-2.11.1.tar.gz", hash = "sha256:41ba0e7afc9752dfb53ced5489e89f8186be00e599e712660695b7a75ff2663f"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pyflakes"
|
||||||
|
version = "3.2.0"
|
||||||
|
description = "passive checker of Python programs"
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=3.8"
|
||||||
|
files = [
|
||||||
|
{file = "pyflakes-3.2.0-py2.py3-none-any.whl", hash = "sha256:84b5be138a2dfbb40689ca07e2152deb896a65c3a3e24c251c5c62489568074a"},
|
||||||
|
{file = "pyflakes-3.2.0.tar.gz", hash = "sha256:1c61603ff154621fb2a9172037d84dca3500def8c8b630657d1701f026f8af3f"},
|
||||||
|
]
|
||||||
|
|
||||||
[metadata]
|
[metadata]
|
||||||
lock-version = "2.0"
|
lock-version = "2.0"
|
||||||
python-versions = "^3.11"
|
python-versions = "^3.11"
|
||||||
content-hash = "81b2fa642d7f2d1219cf80112ace12d689d053d81be7f7addb98144d56fc0fb2"
|
content-hash = "06818140d2e83f1b984473c86a0c67a23c5623d524feacef40b78bc84fc9d000"
|
||||||
|
|||||||
+2
-1
@@ -2,11 +2,12 @@
|
|||||||
name = "project-hangman-game"
|
name = "project-hangman-game"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
description = ""
|
description = ""
|
||||||
authors = ["Your Name <you@example.com>"]
|
authors = ["maksktl <m.matantsev@innopolis.university>"]
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
|
||||||
[tool.poetry.dependencies]
|
[tool.poetry.dependencies]
|
||||||
python = "^3.11"
|
python = "^3.11"
|
||||||
|
flake8 = "^7.0.0"
|
||||||
|
|
||||||
|
|
||||||
[build-system]
|
[build-system]
|
||||||
|
|||||||
Reference in New Issue
Block a user