-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(python_snippets#Change the logging level of a library): Change t…
…he logging level of a library ```python sh_logger = logging.getLogger("sh") sh_logger.setLevel(logging.WARN) ``` feat(python_snippets#Get all subdirectories of a directory): Get all subdirectories of a directory ```python [x[0] for x in os.walk(directory)] ``` feat(python_snippets#Move a file): Move a file ```python import os os.rename("path/to/current/file.foo", "path/to/new/destination/for/file.foo") ``` feat(python_snippets#Copy a file): Copy a file ```python import shutil shutil.copyfile(src_file, dest_file) ``` feat(sh#testing): Test programs that use `sh` `sh` can be patched in your tests the typical way, with `unittest.mock.patch()`: ```python from unittest.mock import patch import sh def get_something(): return sh.pwd() @patch("sh.pwd", create=True) def test_something(pwd): pwd.return_value = "/" assert get_something() == "/" ``` feat(questionary#Conditionally skip questions): Conditionally skip questions Sometimes it is helpful to be able to skip a question based on a condition. To avoid the need for an if around the question, you can pass the condition when you create the question: ```python import questionary DISABLED = True response = questionary.confirm("Are you amazed?").skip_if(DISABLED, default=True).ask() ``` feat(questionary#Don't highlight the selected option by default): Don't highlight the selected option by default If you don't want to highlight the default choice in the `select` question use the next style: ```python from questionary import Style choice = select( "Question title: ", choices=['a', 'b', 'c'], default='a', style=Style([("selected", "noreverse")]), ).ask() ``` feat(sqlite#Get the columns of a database): Get the columns of a database ```sqlite PRAGMA table_info(table_name); ``` ci: fix material theme to 8.1.2 until nav issue is solved oprypin/mkdocs-section-index#10
- Loading branch information
Showing
10 changed files
with
158 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters