├── app └── main.py ├── .gitignore ├── requirements.txt ├── .flake8 ├── .github └── workflows │ └── test.yml ├── checklist.md └── README.md /app/main.py: -------------------------------------------------------------------------------- 1 | # write your code here 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .vscode/ 3 | *.iml 4 | .env 5 | .DS_Store 6 | venv/ 7 | .pytest_cache/ 8 | **__pycache__/ 9 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | flake8==5.0.4 2 | flake8-annotations==2.9.1 3 | flake8-quotes==3.3.1 4 | flake8-variables-names==0.0.5 5 | pep8-naming==0.13.2 6 | pytest==7.1.3 7 | -------------------------------------------------------------------------------- /.flake8: -------------------------------------------------------------------------------- 1 | [flake8] 2 | inline-quotes = " 3 | ignore = E203, E266, W503, ANN002, ANN003, ANN101, ANN102, ANN401, N807, N818 4 | max-line-length = 79 5 | max-complexity = 18 6 | select = B,C,E,F,W,T4,B9,ANN,Q0,N8,VNE 7 | exclude = venv, tests 8 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Test 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - "master" 7 | 8 | jobs: 9 | test: 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | - name: Checkout repo 14 | uses: actions/checkout@v2 15 | 16 | - name: Set Up Python 3.10 17 | uses: actions/setup-python@v2 18 | with: 19 | python-version: "3.10" 20 | 21 | - name: Install pytest and flake8 22 | run: | 23 | python -m pip install --upgrade pip 24 | pip install -r requirements.txt 25 | 26 | - name: Run flake8 27 | run: flake8 app/ 28 | 29 | -------------------------------------------------------------------------------- /checklist.md: -------------------------------------------------------------------------------- 1 | # Сheck Your Code Against the Following Points 2 | 3 | ## Code Efficiency 4 | 5 | Make sure you check that the `cp` input command is correct. 6 | 7 | ## Code Style 8 | 9 | 1. Use one style of quotes in your code. Double quotes are preferable. 10 | 2. Use descriptive and correct variable names. 11 | 12 | Good example: 13 | 14 | ```python 15 | with open("list_of_workers.txt", "r") as source: 16 | pass 17 | ``` 18 | 19 | Bad example: 20 | 21 | ```python 22 | with open("list_of_workers.txt", "r") as f: 23 | pass 24 | ``` 25 | 26 | ## Clean Code 27 | 28 | Add comments, prints, and functions to check your solution when you write your code. 29 | Don't forget to delete them when you are ready to commit and push your code. 30 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Copy file 2 | 3 | - Read [the guideline](https://github.com/mate-academy/py-task-guideline/blob/main/README.md) before starting. 4 | 5 | Write a function `copy_file` that will copy a file in current directory 6 | like Linux cp command: `cp file.txt file-copy.txt`. Function take only one 7 | argument `command`, that is string with command `cp`, file name to copy and new file 8 | name, separated by spaces. 9 | 10 | - It must do nothing in case the user is trying to copy file to file with the same 11 | name. 12 | - Function must copy the whole content to new file. 13 | Example: 14 | ```python 15 | copy_file("cp file.txt file.txt") # Does nothing 16 | 17 | copy_file("cp file.txt new_file.txt") 18 | open("file.txt").read() == open("new_file.txt").read() # True 19 | ``` 20 | **Note**: You can use two contexts managers simultaneously by separating them by a comma: 21 | ```python 22 | with open(..., "r") as file_in, open(..., "w") as file_out: 23 | ... 24 | ``` 25 | 26 | ### Note: Check your code using this [checklist](checklist.md) before pushing your solution. 27 | --------------------------------------------------------------------------------