Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix screen linebreaks #737

Merged
merged 27 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
da681cf
First attempt of fixing <screen>s
tomschr Aug 29, 2024
a738a9c
Save as .new
tomschr Aug 29, 2024
689effa
Move to bin, create link
tomschr Aug 29, 2024
c93d417
Fix bug in replace_entities_with_braces, add test
tomschr Aug 29, 2024
89c2e62
Test extract_screen_blocks()
tomschr Aug 29, 2024
188e60f
Introduce xmlparser()
tomschr Aug 29, 2024
de87707
Test is_screen_content_text_only
tomschr Aug 29, 2024
46ecf73
Test and fix modify_screen_with_text_only()
tomschr Aug 29, 2024
c3db63c
Test modify_screen_with_prompt()
tomschr Aug 29, 2024
403c398
Test modify_screen_with_prompt()
tomschr Aug 29, 2024
d36d887
Fix bug in replace_entities_with_braces regex
tomschr Aug 29, 2024
304eda0
Fix test case test_modify_screen_with_prompt_entity
tomschr Aug 29, 2024
a52d083
Fix regex for restore_entities_from_braces
tomschr Aug 29, 2024
8037100
Add --stdout option
tomschr Aug 29, 2024
86f5933
Allow **args for xmlparser()
tomschr Aug 30, 2024
2a1cdc1
Fix modify_screen_with_prompt(screen)
tomschr Aug 30, 2024
e82cb0c
Fix test_modify_screen_with_prompt_entity()
tomschr Aug 30, 2024
1b19ce3
Fix test_replace_screen_blocks()
tomschr Aug 30, 2024
671f12e
Introduce test_replace_screen_blocks_with_prompt_entity
tomschr Aug 30, 2024
20952ad
Check if screen.text is None
tomschr Aug 30, 2024
9241dfb
Add use case prompt + two commands
tomschr Aug 30, 2024
9fd2d8b
Reduce many spaces to one
tomschr Aug 30, 2024
0ad7bde
Fix test_modify_screen_with_text_only
tomschr Aug 30, 2024
1fd6b63
Implement better algorithm for prompts + other inlines
tomschr Aug 30, 2024
384509e
Add setup.py/setup.cfg
tomschr Aug 30, 2024
aaf1ff3
Add tests and .gitignore
tomschr Sep 2, 2024
50b8011
Add README
tomschr Sep 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 129 additions & 0 deletions python-scripts/fix-screen/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/
24 changes: 24 additions & 0 deletions python-scripts/fix-screen/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Fixing `<screen>`

When you have misaligned `<promp>` and `<command>` tags, this script can help
you.

Let's assume, you have this input:

```xml
<screen>
<prompt>&lt; </prompt>
<command>sudo</command>
<command>foo</command>
</screen>
```

The prompt contains linebreak and the command should appear in one line.
Applying this script gives you the following output:

```xml
<screen><prompt>&lt; </prompt> <command>sudo</command> <command>foo</command>
</screen>
```

Other `<screen>`s with other tags are kept as is.
Loading
Loading