Leo Command To Convert To Title Case

2024-02-03 Thread Thomas Passin
Converting to Title Case means to make the first letter of every word in a 
string capitalized, and all the other letters made lowercase.  It can be 
handy if you copy an all-capital string from somewhere else but you don't 
like all-caps and want to convert it to title case. I couldn't find a 
built-in Leo command to do this.  

Maybe it's there somewhere, but here's a little script to do the job.  It 
uses the title() method of strings. You can put it into myLeoSettings.leo 
as a command, button, or menu item.

"""Convert selection or body to title case."""
w = c.frame.body.wrapper
p = c.p
s = p.b
u = c.undoer

start, end = w.getSelectionRange()
use_entire = start == end  # no selection, convert entire body

undoType = 'title-case-body-selection'
undoData = u.beforeChangeNodeContents(p)

if use_entire:
p.b = s.title()
else:
sel = s[start:end]
head, tail = s[:start], s[end:]
p.b = head + sel.title() + tail

c.setChanged()
p.setDirty()
u.afterChangeNodeContents(p, undoType, undoData)
c.redraw()

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/36d3b601-43a5-4c97-9b5e-994753dd33edn%40googlegroups.com.


Re: PR 3774 completes the 6.7.8 code base

2024-02-03 Thread Thomas Passin
Got some errors on XUbuntu/Python 3.11:

=== FAILURES 
===
 TestTokenBasedOrange.test_blank_lines_after_function_3 


self = 

def test_blank_lines_after_function_3(self):

# From leoAtFile.py.
contents = r"""\
def writeAsisNode(self, p):
print('1')

def put(s):
print('2')

# Trailing comment 1.
# Trailing comment 2.
print('3')
"""
contents, tokens = self.make_data(contents)
expected = contents
results = self.beautify(contents, tokens)
>   self.assertEqual(results, expected)
E   AssertionError: "\\\n[122 chars]omment 1.\n# Trailing 
comment 2.\nprint('3')\n" != "\\\n[122 chars]omment 1.\n# 
Trailing comment 2.\nprint('3')\n"
E \
E def writeAsisNode(self, p):
E print('1')
E 
E def put(s):
E print('2')
E 
E # Trailing comment 1.
E # Trailing comment 2.
E   - print('3')
E   + print('3')
E   ? 

leo/unittests/core/test_leoTokens.py:327: AssertionError
=== warnings summary 
===
leo/plugins/leo_babel/tests/lib_test.py:118
  /home/tom/git/leo-editor/leo/plugins/leo_babel/tests/lib_test.py:118: 
PytestCollectionWarning: cannot collect test class 'TestCmdr' because it 
has a __init__ constructor (from: leo/plugins/leo_babel/tests/lib_test.py)
class TestCmdr:

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=== short test summary info 

FAILED 
leo/unittests/core/test_leoTokens.py::TestTokenBasedOrange::test_blank_lines_after_function_3
 
- AssertionError: "\\\n[122 chars]omment 1.\n# Trailing comment 
2.\n ...
= 1 failed, 904 passed, 26 skipped, 1 warning in 9.32s 


On Saturday, February 3, 2024 at 10:00:57 AM UTC-5 Thomas Passin wrote:

> On Windows 10, Python 3.12 -
>
>  warnings summary 
> leo\plugins\leo_babel\tests\lib_test.py:118
>   C:\Tom\git\leo-editor\leo\plugins\leo_babel\tests\lib_test.py:118: 
> PytestCollectionWarning: cannot collect test class 'TestCmdr' because it 
> has a __init__ constructor (from: leo/plugins/leo_babel/tests/lib_test.py)
> class TestCmdr:
>
> -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
> === 929 passed, 2 skipped, 1 warning in 22.81s ===
>
> Leo 6.7.8-devel, devel branch, build fb38e0c603
> 2024-02-01 17:16:21 -0600
> Python 3.12.0, PyQt version 5.15.2
> Windows 10 AMD64 (build 10.0.19045) SP0
> On Saturday, February 3, 2024 at 6:05:52 AM UTC-5 viktor@gmail.com 
> wrote:
>
>> Hello Edward,
>>
>> Edward K. Ream schrieb am Freitag, 2. Februar 2024 um 11:15:08 UTC+1:
>>
>> PR #3774  is now in 
>> devel. This PR cleans up Leo's unit tests and fixes a crasher in Leo's new 
>> beautifier.
>>
>> The only remaining issue is #3767 
>> : Distribute Leo 
>> only on GitHub. The corresponding PR is a work in progress. I'll say more 
>> about this issue in another post.
>>
>> *Summary*
>>
>> Please test devel and report any problems immediately. 
>>
>> The only remaining changes for 6.7.8 concern distribution.
>>
>> I'll alert you when the new distribution model is ready for testing.
>>
>>
>> I tested the latest version of Leo's devel branch inside a Fedora 38 VM
>>
>> Running the unit tests reveals the following error:
>>
>> ==
>> FAIL: test_blank_lines_after_function_3 
>> (unittests.core.test_leoTokens.TestTokenBasedOrange.test_blank_lines_after_function_3)
>> --
>> Traceback (most recent call last):
>>   File 
>> "/home/user/PyVE/GitHub/Leo/leo-editor/leo/unittests/core/test_leoTokens.py",
>>  
>> line 327, in test_blank_lines_after_function_3
>> self.assertEqual(results, expected)
>> AssertionError: "\\\n[122 chars]omment 1.\n# Trailing comment 
>> 2.\nprint('3')\n" != "\\\n[122 chars]omment 1.\n# Trailing 
>> comment 2.\nprint('3')\n"
>>   \
>>   def writeAsisNode(self, p):
>>   print('1')
>>
>>   def put(s):
>>   print('2')
>>
>>   # Trailing comment 1.
>>   # Trailing comment 2.
>> - print('3')
>> + print('3')
>> ? 
>>
>>
>> --
>> Ran 931 tests in 7.797s
>>
>> FAILED (failures=1, skipped=5)
>> (Leo) [user@fedora-leo-study-vm leo]$ 
>>
>>
>> 

Re: PR 3774 completes the 6.7.8 code base

2024-02-03 Thread Thomas Passin
On Windows 10, Python 3.12 -

 warnings summary 
leo\plugins\leo_babel\tests\lib_test.py:118
  C:\Tom\git\leo-editor\leo\plugins\leo_babel\tests\lib_test.py:118: 
PytestCollectionWarning: cannot collect test class 'TestCmdr' because it 
has a __init__ constructor (from: leo/plugins/leo_babel/tests/lib_test.py)
class TestCmdr:

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=== 929 passed, 2 skipped, 1 warning in 22.81s ===

Leo 6.7.8-devel, devel branch, build fb38e0c603
2024-02-01 17:16:21 -0600
Python 3.12.0, PyQt version 5.15.2
Windows 10 AMD64 (build 10.0.19045) SP0
On Saturday, February 3, 2024 at 6:05:52 AM UTC-5 viktor@gmail.com 
wrote:

> Hello Edward,
>
> Edward K. Ream schrieb am Freitag, 2. Februar 2024 um 11:15:08 UTC+1:
>
> PR #3774  is now in 
> devel. This PR cleans up Leo's unit tests and fixes a crasher in Leo's new 
> beautifier.
>
> The only remaining issue is #3767 
> : Distribute Leo 
> only on GitHub. The corresponding PR is a work in progress. I'll say more 
> about this issue in another post.
>
> *Summary*
>
> Please test devel and report any problems immediately. 
>
> The only remaining changes for 6.7.8 concern distribution.
>
> I'll alert you when the new distribution model is ready for testing.
>
>
> I tested the latest version of Leo's devel branch inside a Fedora 38 VM
>
> Running the unit tests reveals the following error:
>
> ==
> FAIL: test_blank_lines_after_function_3 
> (unittests.core.test_leoTokens.TestTokenBasedOrange.test_blank_lines_after_function_3)
> --
> Traceback (most recent call last):
>   File 
> "/home/user/PyVE/GitHub/Leo/leo-editor/leo/unittests/core/test_leoTokens.py", 
> line 327, in test_blank_lines_after_function_3
> self.assertEqual(results, expected)
> AssertionError: "\\\n[122 chars]omment 1.\n# Trailing comment 
> 2.\nprint('3')\n" != "\\\n[122 chars]omment 1.\n# Trailing 
> comment 2.\nprint('3')\n"
>   \
>   def writeAsisNode(self, p):
>   print('1')
>
>   def put(s):
>   print('2')
>
>   # Trailing comment 1.
>   # Trailing comment 2.
> - print('3')
> + print('3')
> ? 
>
>
> --
> Ran 931 tests in 7.797s
>
> FAILED (failures=1, skipped=5)
> (Leo) [user@fedora-leo-study-vm leo]$ 
>
>
> With kind regards,
>
> Viktor
>  
>

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/8dbe9e40-fd62-4305-a6da-d145b84b6549n%40googlegroups.com.


Re: PR 3774 completes the 6.7.8 code base

2024-02-03 Thread Viktor Ransmayr
Hello Edward,

Edward K. Ream schrieb am Freitag, 2. Februar 2024 um 11:15:08 UTC+1:

PR #3774  is now in 
devel. This PR cleans up Leo's unit tests and fixes a crasher in Leo's new 
beautifier.

The only remaining issue is #3767 
: Distribute Leo only 
on GitHub. The corresponding PR is a work in progress. I'll say more about 
this issue in another post.

*Summary*

Please test devel and report any problems immediately. 

The only remaining changes for 6.7.8 concern distribution.

I'll alert you when the new distribution model is ready for testing.


I tested the latest version of Leo's devel branch inside a Fedora 38 VM

Running the unit tests reveals the following error:

==
FAIL: test_blank_lines_after_function_3 
(unittests.core.test_leoTokens.TestTokenBasedOrange.test_blank_lines_after_function_3)
--
Traceback (most recent call last):
  File 
"/home/user/PyVE/GitHub/Leo/leo-editor/leo/unittests/core/test_leoTokens.py", 
line 327, in test_blank_lines_after_function_3
self.assertEqual(results, expected)
AssertionError: "\\\n[122 chars]omment 1.\n# Trailing comment 
2.\nprint('3')\n" != "\\\n[122 chars]omment 1.\n# Trailing 
comment 2.\nprint('3')\n"
  \
  def writeAsisNode(self, p):
  print('1')

  def put(s):
  print('2')

  # Trailing comment 1.
  # Trailing comment 2.
- print('3')
+ print('3')
? 


--
Ran 931 tests in 7.797s

FAILED (failures=1, skipped=5)
(Leo) [user@fedora-leo-study-vm leo]$ 


With kind regards,

Viktor
 

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/70cea672-3905-495f-9390-b46dba0b04ffn%40googlegroups.com.