Re: Script to expand toolbar

2024-04-03 Thread Thomas Passin
It's not just a black background that hides it.  There must be a css 
selector for it, mustn't there? 

On Wednesday, April 3, 2024 at 10:56:16 AM UTC-4 Edward K. Ream wrote:

> On Wednesday, April 3, 2024 at 4:54:32 AM UTC-5 Edward K. Ream wrote:
>
> It took me a while to understand what the @button node is doing.
>
> ...
>
> I'm satisfied neither with #407 
>  nor with the 
> script. I would prefer some ways of splitting the icon bar at specific 
> places. I have just created #3851 
> .
>
>
> Alright, I think I understand the bounds of the problem.
>
>
> Googling shows that the QToolbar class has inherent limitations. There is *no 
> way* to split QToolButton widgets into separate rows. Happily, the 
> toolbar shows an *extension icon* on the far right when there are too 
> many buttons. Clicking this icon will show the remaining widgets on 
> separate lines. The newly revealed icons *remain visible* until the user 
> clicks the extension icon again.
>
>
> I never noticed this behavior before. Worse, my dark theme obscured the 
> extension icon! I've corrected that bug by giving the icon a lighter 
> background color.
>
>
> *@button expand-toolbar*
>
>
> This script needs more explanation. The script creates a button that 
> duplicates the purpose of the extension icon. The script (@button node) 
> does nothing if everything in the icon bar is already visible.
>
>
> The script simulates a *single* keypress (and release) on the extension 
> icon. Therefore, the newly revealed icons will *remain visible* until the 
> user presses the button (or the actual extension icon).
>
>
> The test:  if w.objectName() == 'qt_toolbar_ext_button':
>
>
> looks for the name that Qt assigns to the expansion icon. This name *has 
> nothing to do with the headline of the @button node!*
>
>
> *Summary*
>
>
> At long last, I understand the inherent limitations of the QToolbar 
> widget. There seems to be no way to split its contents into separate 
> (always visible) lines.
>
>
> Otoh, the extension icon shows all widgets when clicked and *continues to 
> do so* until clicked again. This behavior is good enough for most 
> purposes.
>
>
> I've corrected my dark theme to show the extension icon. The icon must not 
> have a black background.
>
>
> The given @button script works, but it needs some explanation. I'll amend 
> #3851  accordingly.
>
>
> Edward
>

-- 
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/bf2cc648-946f-4784-bc1d-59366014037fn%40googlegroups.com.


Re: A technique from a chatbot

2024-04-03 Thread Thomas Passin via Python-list

On 4/3/2024 1:27 AM, AVI GROSS via Python-list wrote:

I am a tad confused by a suggestion that any kind of GOTO variant is bad. The 
suggestion runs counter to the reality that underneath it all, compiled 
programs are chock full of GOTO variants even for simple things like IF-ELSE.

Consider the code here:


def first_word_beginning_with_e( list_ ):
  for word in list_:
  if word[ 0 ]== 'e': return word
  something_to_be_done_at_the_end_of_this_function()


If instead the function initialized a variable to nothing useful and in the 
loop if it found a word beginning with e and it still contained nothing useful, 
copied it into the variable and then allowed the code to complete the loop and 
finally returned the variable, that would simply be a much less efficient 
solution to the problem and gain NOTHING. There are many variants you can come 
up with and when the conditions are complex and many points of immediate 
return, fine, then it may be dangerous. But a single return is fine.

The function does have a flaw as it is not clear what it should do if nothing 
is found. Calling a silly long name does not necessarily return anything.

Others, like Thomas, have shown other variants including some longer and more 
complex ways.

A fairly simple one-liner version, not necessarily efficient, would be to just 
use a list comprehension that makes a new list of just the ones matching the 
pattern of starting with an 'e' and then returns the first entry or None. This 
shows the code and test it:

text = ["eastern", "Western", "easter"]

NorEaster = ["North", "West", "orient"]

def first_word_beginning_with_e( list_ ):
   return(result[0] if (result := [word for word in list_ if word[0].lower() == 
'e']) else None)

print(first_word_beginning_with_e( text ))
print(first_word_beginning_with_e( NorEaster ))

Result of running it on a version of python ay least 3.8 so it supports the 
walrus operator:

eastern
None


The OP seems to want to return None if a match is not found.  If a 
Python function ends without a return statement, it automatically 
returns None.  So nothing special needs to be done.  True, that is 
probably a special case, but it suggests that the problem posed to the 
chatbot was not posed well.  A truly useful chatbot could have discussed 
many of the points we've been discussing.  That would have made for a 
good learning experience.  Instead the chatbot produced poorly 
constructed code that caused a bad learning experience.




[snip...]


--
https://mail.python.org/mailman/listinfo/python-list


Re: A technique from a chatbot

2024-04-02 Thread Thomas Passin via Python-list

On 4/2/2024 1:47 PM, Piergiorgio Sartor via Python-list wrote:

On 02/04/2024 19.18, Stefan Ram wrote:

   Some people can't believe it when I say that chatbots improve
   my programming productivity. So, here's a technique I learned
   from a chatbot!
   It is a structured "break". "Break" still is a kind of jump,
   you know?
   So, what's a function to return the first word beginning with
   an "e" in a given list, like for example
[ 'delta', 'epsilon', 'zeta', 'eta', 'theta' ]

   ? Well it's
def first_word_beginning_with_e( list_ ):
 for word in list_:
 if word[ 0 ]== 'e': return word

   . "return" still can be considered a kind of "goto" statement.
   It can lead to errors:

def first_word_beginning_with_e( list_ ):
 for word in list_:
 if word[ 0 ]== 'e': return word
 something_to_be_done_at_the_end_of_this_function()
   The call sometimes will not be executed here!
   So, "return" is similar to "break" in that regard.
   But in Python we can write:
def first_word_beginning_with_e( list_ ):
 return next( ( word for word in list_ if word[ 0 ]== 'e' ), None )


Doesn't look a smart advice.


   . No jumps anymore, yet the loop is aborted on the first hit


It's worse than "not a smart advice". This code constructs an 
unnecessary tuple, then picks out its first element and returns that. 
The something_to_be_done() function may or may not be called.  And it's 
harder to read and understand than necessary.  Compare, for example, 
with this version:


def first_word_beginning_with_e(target, wordlist):
result = ''
for w in wordlist:
if w.startswith(target):
res = w
break
do_something_else()
return result

If do_something_else() is supposed to fire only if the target is not 
found, then this slight modification will do:


def first_word_beginning_with_e(target, wordlist):
result = ''
for w in wordlist:
if w.startswith(target):
res = w
break
else:
do_something_else()
return result

[Using the "target" argument instead of "target[0]" will let you match 
an initial string instead of just a the first character].



First of all, I fail to understand why there
should be no jumps any more.
It depends on how "return" and "if" are handled,
I guess, in different context.
Maybe they're just "masked".
In any case, the "compiler" should have just
done the same.


   (if I guess correctly how its working).


Second, it is difficult to read, which is bad.
The "guess" above is just evidence of that.

My personal opinion about these "chatbots", is
that, while they might deliver clever solutions,
they are not explaining *why* these solutions
should be considered "clever".
Which is the most important thing (the solution
itself is _not_).

bye,



--
https://mail.python.org/mailman/listinfo/python-list


Re: LeoJS Status Report & Video Demo/Tutorial

2024-03-31 Thread Thomas Passin
Felix, I appreciate all the work but I'm not able to work with the intro 
video.  Everything happens too fast and I think you do some things that are 
not visible.  For example, you somehow open a Preview pane that can render 
Markdown.  I'd like to do that. I have to guess that you got to it by a 
right mouse click, but when I right click in the body pane I don't get a 
menu item to open a preview.  The video doesn't give me any guidance about 
how to set that up.

It's similar with the Git integration.  There are just too many things to 
take in during the time that a drag takes place, and then something else 
happens that there also isn't time to take in.

If things were slowed down and there were more titles or explanatory text 
the video would be much more helpful.  I know that making these videos is 
time-consuming and has a large learning curve - that's why I haven't tried 
making my own! Please don't take these comments as criticizing your work - 
I'm just trying to be helpful. 

On Sunday, March 31, 2024 at 4:30:18 PM UTC-4 Félix wrote:

> The sample Leo scripts shown in the video are collected in this github 
> repository: https://github.com/boltex/scripting-samples-leojs
>
> The sample "LeoJS-Plugin" extension shown in the video also has its own 
> github repository at: https://github.com/boltex/extension-sample-leojs
>
> On Sunday, March 31, 2024 at 4:28:00 PM UTC-4 Félix wrote:
>
>> *LeoJS Status Report*
>>
>> After stabilizing the beta version, now reaching its twelfth revision at 
>> 0.2.12, and getting rid of its most obvious bugs and defects, I thought it 
>> would be a good moment to address the questions posed on this forum about 
>> the possible features and capabilities of LeoJS by producing a video 
>> demonstration.
>>
>> This took a bit longer than I would have thought, months instead of 
>> weeks, but nevertheless, here it is!
>>
>> https://www.youtube.com/watch?v=M_mKXSbVGdE
>>
>> *This five-minute video quickly goes over each of the following:*
>>
>>- Using LeoJS on the web
>>- Commits & pull requests from VSCode's UI
>>- Running Leo scripts in LeoJS
>>- Interacting with the UI from scripts (Sample scripts)
>>- Creating a plugin/extension that uses LeoJS (Sample extension)
>>- Invoking commands, using the minibuffer and @buttons
>>- Using a @settings node
>>- UNL link support
>>- Previewing live render of SVG (or markdown, etc.) external files
>>
>> Hoping this will answer most questions the experienced leonistas had 
>> about LeoJS being able to reproduce the original Leo's functionalities from 
>> within VSCode.
>>
>> *Last but not least: I've also remade the classic 'Introduction to Leo' 
>> video with LeoJS! *
>>
>> https://www.youtube.com/watch?v=j0eo7SlnnSY
>>
>> Hope you like those two videos!
>>
>> I'll now focus on the very last few remaining LeoJS issues and features 
>> needed for a proper 1.0 version release of LeoJS. (Hopefully this spring!) 
>>
>> Félix
>>
>

-- 
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/7ccae901-b661-490b-a9d2-be746ae95aden%40googlegroups.com.


Re: I just had successful eye surgury

2024-03-28 Thread Thomas Passin
Sorry to hear this.  Best wishes for a quick and full recovery!

On Thursday, March 28, 2024 at 4:03:52 PM UTC-4 Edward K. Ream wrote:

> A vitrectomy 
> of
>  
> the rt eye. I'll be limited in what I can do for about a week.
>
> Edward
>

-- 
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/9ca2247e-d7ac-44cd-9c6e-d680f05874f1n%40googlegroups.com.


Re: Please test the ekr-2882-qt-only2 branch

2024-03-27 Thread Thomas Passin
I got the same results using the qt-only2 branch.

On Wednesday, March 27, 2024 at 7:49:52 PM UTC-4 Thomas Passin wrote:

> Oops, the last two were tested with devel, not the qt-only-2 branch..  
> I'll have to go back and repeat the test.
>
> On Wednesday, March 27, 2024 at 3:57:11 PM UTC-4 Thomas Passin wrote:
>
>> Some more Linux results:
>> ubuntu
>> nav, console ok.  vr3 image problem
>> XUbuntu
>> nav, console ok.  vr3 image problem
>>
>> OpenSUSE
>> needs libQt6WebEngineCore6, libQt6Quick6
>> After installing them, Leo still couldn't start.  Those libQt6xx
>> libraries were installed by zypper to /usr/lib64 but pyqt6
>> wants version `Qt_6_PRIVATE_API' 
>>
>> Fedora
>> seems ok, vr3 images seem ok
>>
>> On Monday, March 25, 2024 at 12:51:20 PM UTC-4 Edward K. Ream wrote:
>>
>>> On Monday, March 25, 2024 at 6:37:36 AM UTC-5 Edward K. Ream wrote:
>>>
>>> The "ekr-2882-qt-only2" branch is ready for testing. See PR #3828 
>>> <https://github.com/leo-editor/leo-editor/pull/3828>.
>>>
>>>
>>> This PR is a milestone: it removes all vestiges of Qt5 from Leo's 
>>> codebase. As a result, much stronger mypy annotations are possible, but 
>>> improved annotations will be the subject of a follow-on PR.
>>>
>>>
>>> A recent rev makes the QSci module optional for the time being. This rev 
>>> also improves the message that appears if Leo fails to load.
>>>
>>> I'll fix the nits Thomas has reported and merge the PR later today or 
>>> tomorrow.
>>>
>>> Edward
>>>
>>

-- 
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/c72a21af-ef88-4832-85a8-c62efbe80ff4n%40googlegroups.com.


Re: Please test the ekr-2882-qt-only2 branch

2024-03-27 Thread Thomas Passin
Oops, the last two were tested with devel, not the qt-only-2 branch..  I'll 
have to go back and repeat the test.

On Wednesday, March 27, 2024 at 3:57:11 PM UTC-4 Thomas Passin wrote:

> Some more Linux results:
> ubuntu
> nav, console ok.  vr3 image problem
> XUbuntu
> nav, console ok.  vr3 image problem
>
> OpenSUSE
> needs libQt6WebEngineCore6, libQt6Quick6
> After installing them, Leo still couldn't start.  Those libQt6xx
> libraries were installed by zypper to /usr/lib64 but pyqt6
> wants version `Qt_6_PRIVATE_API' 
>
> Fedora
> seems ok, vr3 images seem ok
>
> On Monday, March 25, 2024 at 12:51:20 PM UTC-4 Edward K. Ream wrote:
>
>> On Monday, March 25, 2024 at 6:37:36 AM UTC-5 Edward K. Ream wrote:
>>
>> The "ekr-2882-qt-only2" branch is ready for testing. See PR #3828 
>> <https://github.com/leo-editor/leo-editor/pull/3828>.
>>
>>
>> This PR is a milestone: it removes all vestiges of Qt5 from Leo's 
>> codebase. As a result, much stronger mypy annotations are possible, but 
>> improved annotations will be the subject of a follow-on PR.
>>
>>
>> A recent rev makes the QSci module optional for the time being. This rev 
>> also improves the message that appears if Leo fails to load.
>>
>> I'll fix the nits Thomas has reported and merge the PR later today or 
>> tomorrow.
>>
>> Edward
>>
>

-- 
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/dfdbda83-4082-4f30-ae27-b08c091706fan%40googlegroups.com.


Re: Please test the ekr-2882-qt-only2 branch

2024-03-27 Thread Thomas Passin
Some more Linux results:
ubuntu
nav, console ok.  vr3 image problem
XUbuntu
nav, console ok.  vr3 image problem

OpenSUSE
needs libQt6WebEngineCore6, libQt6Quick6
After installing them, Leo still couldn't start.  Those libQt6xx
libraries were installed by zypper to /usr/lib64 but pyqt6
wants version `Qt_6_PRIVATE_API' 

Fedora
seems ok, vr3 images seem ok

On Monday, March 25, 2024 at 12:51:20 PM UTC-4 Edward K. Ream wrote:

> On Monday, March 25, 2024 at 6:37:36 AM UTC-5 Edward K. Ream wrote:
>
> The "ekr-2882-qt-only2" branch is ready for testing. See PR #3828 
> .
>
>
> This PR is a milestone: it removes all vestiges of Qt5 from Leo's 
> codebase. As a result, much stronger mypy annotations are possible, but 
> improved annotations will be the subject of a follow-on PR.
>
>
> A recent rev makes the QSci module optional for the time being. This rev 
> also improves the message that appears if Leo fails to load.
>
> I'll fix the nits Thomas has reported and merge the PR later today or 
> tomorrow.
>
> Edward
>

-- 
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/f870519a-8f06-4003-bc87-7c0a8ba9d71en%40googlegroups.com.


Re: Please test the ekr-2882-qt-only2 branch

2024-03-25 Thread Thomas Passin
Both Nav and Python Console are present on Linux Manjaro. Also, on Debian 
and Mint, if VR3 tries and fails to display an image, it stops working 
until Leo is restarted.  This hasn't happened as yet on Manjaro.

Lint is derived from Debian.  I wonder if they have something in common 
that's related?

On Monday, March 25, 2024 at 9:49:55 AM UTC-4 Edward K. Ream wrote:

> On Mon, Mar 25, 2024 at 8:45 AM Thomas Passin  wrote:
>
> Nav tab is missing on Debian, Python Console tab is missing on Linux 
>> Mint.  No apparent error messages.
>>
>
> Thanks for your testing!  Now I'll definitely delay the merge.
>
> Edward
>

-- 
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/c097efbe-2dbb-4129-81bc-191f9fc82f18n%40googlegroups.com.


Re: Please test the ekr-2882-qt-only2 branch

2024-03-25 Thread Thomas Passin
Nav tab is missing on Debian, Python Console tab is missing on Linux Mint.  
No apparent error messages.

On Monday, March 25, 2024 at 9:25:25 AM UTC-4 Thomas Passin wrote:

> What is Leo using QScintilla for?
>
> On Monday, March 25, 2024 at 9:21:00 AM UTC-4 Thomas Passin wrote:
>
>> That took care of the problem and the branch of Leo now runs on Ubuntu.  
>> Also, VR3 opens.
>>
>> On Monday, March 25, 2024 at 9:05:18 AM UTC-4 Edward K. Ream wrote:
>>
>>> On Mon, Mar 25, 2024 at 7:47 AM Thomas Passin  wrote:
>>>
>>>> Fails on Ubuntu:
>>>>
>>>> *cannot import name 'Qsci' from 'PyQt6' 
>>>> (/home/tom/.local/lib/python3.10/site-packages/PyQt6/__init__.py)*
>>>>
>>>
>>> Good catch. My apologies for the confusion.
>>>
>>> This is a documentation error or a "transition" problem, depending on 
>>> your point of view.
>>>
>>> It's easy to fix: *pip install PyQt6-QScintilla *
>>>
>>> I say this is a transition problem because requirements.txt now 
>>> includes PyQt6-QScintilla.
>>>
>>> There's no automatic way to avoid the extra dependency. Otoh, Leo 6.7.9 
>>> will provide the dependency automatically.
>>>
>>> *Summary*
>>>
>>> *Everyone *who uses GitHub should run *pip install PyQt6-QScintilla *
>>>
>>> Edward
>>>
>>

-- 
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/b6bd6ecb-f58c-487c-abac-96af26336f5an%40googlegroups.com.


Re: Please test the ekr-2882-qt-only2 branch

2024-03-25 Thread Thomas Passin
What is Leo using QScintilla for?

On Monday, March 25, 2024 at 9:21:00 AM UTC-4 Thomas Passin wrote:

> That took care of the problem and the branch of Leo now runs on Ubuntu.  
> Also, VR3 opens.
>
> On Monday, March 25, 2024 at 9:05:18 AM UTC-4 Edward K. Ream wrote:
>
>> On Mon, Mar 25, 2024 at 7:47 AM Thomas Passin  wrote:
>>
>>> Fails on Ubuntu:
>>>
>>> *cannot import name 'Qsci' from 'PyQt6' 
>>> (/home/tom/.local/lib/python3.10/site-packages/PyQt6/__init__.py)*
>>>
>>
>> Good catch. My apologies for the confusion.
>>
>> This is a documentation error or a "transition" problem, depending on 
>> your point of view.
>>
>> It's easy to fix: *pip install PyQt6-QScintilla *
>>
>> I say this is a transition problem because requirements.txt now includes 
>> PyQt6-QScintilla.
>>
>> There's no automatic way to avoid the extra dependency. Otoh, Leo 6.7.9 
>> will provide the dependency automatically.
>>
>> *Summary*
>>
>> *Everyone *who uses GitHub should run *pip install PyQt6-QScintilla *
>>
>> Edward
>>
>

-- 
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/6e75ccf4-d024-490c-af54-938b014a8c19n%40googlegroups.com.


Re: Please test the ekr-2882-qt-only2 branch

2024-03-25 Thread Thomas Passin
That took care of the problem and the branch of Leo now runs on Ubuntu.  
Also, VR3 opens.

On Monday, March 25, 2024 at 9:05:18 AM UTC-4 Edward K. Ream wrote:

> On Mon, Mar 25, 2024 at 7:47 AM Thomas Passin  wrote:
>
>> Fails on Ubuntu:
>>
>> *cannot import name 'Qsci' from 'PyQt6' 
>> (/home/tom/.local/lib/python3.10/site-packages/PyQt6/__init__.py)*
>>
>
> Good catch. My apologies for the confusion.
>
> This is a documentation error or a "transition" problem, depending on your 
> point of view.
>
> It's easy to fix: *pip install PyQt6-QScintilla *
>
> I say this is a transition problem because requirements.txt now includes 
> PyQt6-QScintilla.
>
> There's no automatic way to avoid the extra dependency. Otoh, Leo 6.7.9 
> will provide the dependency automatically.
>
> *Summary*
>
> *Everyone *who uses GitHub should run *pip install PyQt6-QScintilla *
>
> Edward
>

-- 
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/bb69f912-6aa9-4cb7-9ea3-76681ef9aeean%40googlegroups.com.


Re: Please test the ekr-2882-qt-only2 branch

2024-03-25 Thread Thomas Passin
Fails on Ubuntu:

*cannot import name 'Qsci' from 'PyQt6' 
(/home/tom/.local/lib/python3.10/site-packages/PyQt6/__init__.py)*

*** Leo could not be started ***

Please verify you've installed the required dependencies:



On Monday, March 25, 2024 at 7:37:36 AM UTC-4 Edward K. Ream wrote:

> The "ekr-2882-qt-only2" branch is ready for testing. See PR #3828 
> .
>
>
> This PR is a milestone: it removes all vestiges of Qt5 from Leo's 
> codebase. As a result, much stronger mypy annotations are possible, but 
> improved annotations will be the subject of a follow-on PR.
>
>
> Thomas has raised three minor issues about this PR. I'll resolve these 
> issues before merging the PR. I thank Thomas for his careful review.
>
>
> I'll merge this PR later today or tomorrow. We'll continue our testing 
> after the merge.
>
>
> Edward
>

-- 
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/264dc3e9-8db1-400c-8c79-5e830db2ae90n%40googlegroups.com.


Re: About PR #3828: Require Qt6.6+

2024-03-24 Thread Thomas Passin
Every one of my fleet of Linux VMs has finally got PyQt 6.6, so that's 
favorable. No one can prove that *every* distro will have it - there are 
just too many variations - but so be it.  I don't know about ARM versions 
and don't have a way to check, but I suppose they are still not a likely 
host for Leo.

On Sunday, March 24, 2024 at 8:17:29 AM UTC-4 Edward K. Ream wrote:

> I am now working on PR #3828 
> : require Qt 6.6+. 
> This PR is experimental and possibly controversial.
>
>
> *The good news*
>
>
> - leoQt.py contains no conditional imports. 
>
> - leoQt.py defines all constants unambiguously.
>
> - No Qt-related switches exist*.* Hurray! Removing these switches 
> (especially isQt5 and isQt6) simplifies code throughout Leo.
>
>
> *The controversial news*
>
>
> Four Qt modules no longer exist in Qt6: *phonon*, *QtDeclarative*, 
> *QtWebKit*, and *QtWebKitWidgets*. As a result, I have retired five of 
> Terry Brown's plugins. There is no obvious way to make these plugins work 
> with Qt6. 
>
>
> *Summary*
>
>
> PR #3828  removes all 
> vestiges of Qt5 from Leo's codebase. Now is probably a good time to move to 
> Qt6. Leo 6.7.8 installs only Qt6 without anyone complaining :-)
>
>
> A one-line change to requirements.txt installs all necessary Qt6 modules. 
> There is no need for conditional code in leoQt.py.
>
>
> Five plugins are incompatible with Qt6 and have been retired to the attic: 
> *notebook.py*, *richtext.py*, and three "editpane" plugins: 
> *pandownview.py*, *webengineview.py*, and *webkitview.py*. These plugins 
> are no great loss. They do not work with the typical installation of Leo 
> 6.7.8.
>
>
> Please tell me what you think.
>
>
> Edward
>
>
>

-- 
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/43c0e3d7-615b-42a7-91e0-3153986d9cd7n%40googlegroups.com.


Re: A Script To Insert An Image

2024-03-24 Thread Thomas Passin
It's still a good question, though.  Is there an actual use for a setting 
of type "@path"?Having it included in that documentation section seems 
to imply that there is, though its inclusion may have been meant only as a 
syntax example. Can anyone resolve this?

On Sunday, March 24, 2024 at 8:24:47 AM UTC-4 Edward K. Ream wrote:

> On Sun, Mar 24, 2024 at 7:01 AM Thomas Passin  wrote:
>
>> Settings and headlines are not the same.
>>
>
> At last I understand :-)  As Thomas says, the syntax for settings nodes is 
> different from directives.
>
> In other words, Leo's documentation appears to be correct.
>
> Edward
>

-- 
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/68e70299-1e4a-45eb-b7b2-31aa9bced5can%40googlegroups.com.


Re: A Script To Insert An Image

2024-03-24 Thread Thomas Passin
Settings and headlines are not the same.

On Sunday, March 24, 2024 at 6:39:03 AM UTC-4 jkn wrote:

> Hi Edward
> I put the link (to a different part of the documentation) in an earlier 
> post: 
> https://leo-editor.github.io/leo-editor/customizing.html#simple-settings-nodes
>
> The section you reference is clear, and correct. The link above perhaps 
> references an older syntax?
>
> Regards, J^n
>
>
> On Sunday, March 24, 2024 at 10:27:45 AM UTC Edward K. Ream wrote:
>
>> On Sun, Mar 24, 2024 at 4:20 AM jkn  wrote:
>>
>>>
>>> I am commenting on the fact that the documentation says that an @path 
>>> directive (and all the others in the table below) takes the form
>>>
>>> @path **=** my/path
>>>
>>> whereas in fact no equals sign is necessary (any might well cause an 
>>> error?)
>>>
>>> @path  my/path
>>>
>>
>> I see no equal sign in Leo's directive reference 
>>  page. What 
>> documentation are you talking about?
>>
>> Edward
>>
>

-- 
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/c367b9f6-6c96-4a8d-8e49-173d4f9f5c3an%40googlegroups.com.


Re: A Script To Insert An Image

2024-03-23 Thread Thomas Passin
m 
>>>>>> interested in.
>>>>>>
>>>>>> When run with an image in the (global) clipboard, it saves this to a 
>>>>>> local timestamped file (under ~/tmp), and indicates how a markdown 
>>>>>> reference to that file could be inserted.
>>>>>>
>>>>>> There's plenty more needed but this is the QClipboard part, I think.
>>>>>>
>>>>>> import os
>>>>>> import time
>>>>>> 
>>>>>> def unique_png_fname():
>>>>>> """ return a unique (timestamped) filename to use
>>>>>> """
>>>>>> FORMAT="%Y-%m-%d-%H-%M-%S.png"
>>>>>> return time.strftime(FORMAT)
>>>>>>
>>>>>> def link_string_md(fname):
>>>>>> """ get markdown format to insert a filename
>>>>>> """
>>>>>> return "![[%s]]" % fname
>>>>>>
>>>>>> def main():
>>>>>> # get clipboard contents - default mode is global clipboard
>>>>>> cb = g.app.gui.qtApp.clipboard()
>>>>>> # is it in image format?
>>>>>> img = cb.image()
>>>>>> if not img.isNull():
>>>>>> basefiledir = os.path.expanduser("~/tmp")
>>>>>> fqfilepath = os.path.join(basefiledir, unique_png_fname())
>>>>>> img.save(fqfilepath, "PNG")
>>>>>> g.es("wrote clipboard to:", fqfilepath)
>>>>>> g.es("could insert:", link_string_md(fqfilepath))
>>>>>> else:
>>>>>> g.es("clipboard not in image format")
>>>>>>
>>>>>> main()
>>>>>>
>>>>>>
>>>>>> On Monday, March 11, 2024 at 8:23:42 PM UTC jkn wrote:
>>>>>>
>>>>>>> Doh! should have read the documentation better.
>>>>>>>
>>>>>>> you have to test for a 'null image' using eg. img.isnull()
>>>>>>>
>>>>>>> on with my trivial experiments...
>>>>>>>
>>>>>>>
>>>>>>> On Monday, March 11, 2024 at 8:10:03 PM UTC jkn wrote:
>>>>>>>
>>>>>>>> Has anyone played much with class QClipboard? I did a couple of 
>>>>>>>> trivial experiments but I must be misunderstanding something.
>>>>>>>>
>>>>>>>> for instance, QClipboard.image() returns a non-null value even if 
>>>>>>>> the clipboard does not contain an image.
>>>>>>>>
>>>>>>>> J^n
>>>>>>>>
>>>>>>>>
>>>>>>>> On Monday, March 11, 2024 at 4:33:23 PM UTC tbp1...@gmail.com 
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>> It turns out that to get the relative path conversion w have to 
>>>>>>>>> remove any quotation marks around the path before running 
>>>>>>>>> os.relpath(). So 
>>>>>>>>> the script becomes:
>>>>>>>>>
>>>>>>>>> """Insert RsT code at cursor to display an image.
>>>>>>>>>
>>>>>>>>> The path to the image file will come from a file dialog.
>>>>>>>>> This action is undoable.
>>>>>>>>> """
>>>>>>>>> PATH = g.app.gui.runOpenFileDialog(c,
>>>>>>>>> title="Import File",
>>>>>>>>> filetypes=[("All files", "*"),],
>>>>>>>>> defaultextension=".*",
>>>>>>>>> multiple=False)
>>>>>>>>>
>>>>>>>>> if PATH:
>>>>>>>>> from os.path import relpath
>>>>>>>>> PATH = PATH.replace('"', '').replace("'", '')
>>>>>>>>> PATH = relpath(PATH)
>>>>>>>>> PATH = PATH.replace('\\', '/')
>>>>>

Re: A Script To Insert An Image

2024-03-23 Thread Thomas Passin
 Monday, March 11, 2024 at 8:10:03 PM UTC jkn wrote:
>>>>
>>>>> Has anyone played much with class QClipboard? I did a couple of 
>>>>> trivial experiments but I must be misunderstanding something.
>>>>>
>>>>> for instance, QClipboard.image() returns a non-null value even if the 
>>>>> clipboard does not contain an image.
>>>>>
>>>>> J^n
>>>>>
>>>>>
>>>>> On Monday, March 11, 2024 at 4:33:23 PM UTC tbp1...@gmail.com wrote:
>>>>>
>>>>>> It turns out that to get the relative path conversion w have to 
>>>>>> remove any quotation marks around the path before running os.relpath(). 
>>>>>> So 
>>>>>> the script becomes:
>>>>>>
>>>>>> """Insert RsT code at cursor to display an image.
>>>>>>
>>>>>> The path to the image file will come from a file dialog.
>>>>>> This action is undoable.
>>>>>> """
>>>>>> PATH = g.app.gui.runOpenFileDialog(c,
>>>>>> title="Import File",
>>>>>> filetypes=[("All files", "*"),],
>>>>>> defaultextension=".*",
>>>>>> multiple=False)
>>>>>>
>>>>>> if PATH:
>>>>>> from os.path import relpath
>>>>>> PATH = PATH.replace('"', '').replace("'", '')
>>>>>> PATH = relpath(PATH)
>>>>>> PATH = PATH.replace('\\', '/')
>>>>>>
>>>>>> IMAGE_TEMPLATE = f'''
>>>>>>
>>>>>> .. figure:: {PATH}
>>>>>> :scale: 50%
>>>>>>
>>>>>> '''
>>>>>>
>>>>>> w = c.frame.body.wrapper
>>>>>> p = c.p
>>>>>> s = p.b
>>>>>> u = c.undoer
>>>>>>
>>>>>> start, _ = w.getSelectionRange()
>>>>>>
>>>>>> undoType = 'insert-rst-image-code'
>>>>>> undoData = u.beforeChangeNodeContents(p)
>>>>>>
>>>>>> head, tail = s[:start], s[start:]
>>>>>> p.b = head + IMAGE_TEMPLATE + tail
>>>>>>
>>>>>> c.setChanged()
>>>>>> p.setDirty()
>>>>>> u.afterChangeNodeContents(p, undoType, undoData)
>>>>>> c.redraw()
>>>>>>
>>>>>> On Saturday, March 9, 2024 at 2:04:19 PM UTC-5 Thomas Passin wrote:
>>>>>>
>>>>>>> We can't directly insert an image into a standard Leo node because 
>>>>>>> they are text-only.  I find this very annoying sometimes, especially 
>>>>>>> when I 
>>>>>>> am writing a note and want to include an image.  
>>>>>>>
>>>>>>> But we can do the next best thing - insert an ReStructuredText (RsT) 
>>>>>>> instruction to display an image so that we can view it with the 
>>>>>>> viewrendered3 plugin (VR3). The instruction is short and easy, but it's 
>>>>>>> still annoying to type and I usually forget the exact details. I have a 
>>>>>>> button that toggles VR3 on and off so that it's easy to view an 
>>>>>>> embedded 
>>>>>>> image once the RsT instruction is there. An embedding command would 
>>>>>>> make 
>>>>>>> embedding with Leo as easy as embedding an image in a word processor.  
>>>>>>>  Aha, this is Leo, let's write a script!
>>>>>>>
>>>>>>> Here is a script that pops up a file dialog and inserts a relative 
>>>>>>> path to the chosen file.  There are several small variations which I 
>>>>>>> discuss after the code.
>>>>>>>
>>>>>>> """Insert RsT code at cursor to display an image.
>>>>>>>
>>>>>>> The path to the image file will come from a file dialog.
>>>>>>> This action is undoable.
>>>>>>> """
>>>>>>> PATH = g.app.gui.runOpenFileDialog(c,
>>>>>>> title="Import File",
>>>>>>> filetypes=[("All files", "*"),],
>>>>>>> defaultextension=".*",
>>>>>>> multiple=False)
>>>>>>>
>>>>>>> if PATH:
>>>>>>> from os.path import relpath
>>>>>>> PATH = relpath(PATH)
>>>>>>> PATH = PATH.replace('\\', '/').replace('"', '').replace("'", '')
>>>>>>> IMAGE_TEMPLATE = f'''
>>>>>>>
>>>>>>> .. figure:: {PATH}
>>>>>>> :scale: 50%
>>>>>>>
>>>>>>> '''
>>>>>>> w = c.frame.body.wrapper
>>>>>>> p = c.p
>>>>>>> s = p.b
>>>>>>> u = c.undoer
>>>>>>>
>>>>>>> start, _ = w.getSelectionRange()
>>>>>>>
>>>>>>> undoType = 'insert-rst-image-code'
>>>>>>> undoData = u.beforeChangeNodeContents(p)
>>>>>>>
>>>>>>> head, tail = s[:start], s[start:]
>>>>>>> p.b = head + IMAGE_TEMPLATE + tail
>>>>>>>
>>>>>>> c.setChanged()
>>>>>>> p.setDirty()
>>>>>>> u.afterChangeNodeContents(p, undoType, undoData)
>>>>>>> c.redraw()
>>>>>>>
>>>>>>> Variations:
>>>>>>> 1.  If you want an absolute path instead of a relative path, delete 
>>>>>>> the lines
>>>>>>> from os.path import relpath
>>>>>>> PATH = relpath(PATH)
>>>>>>> with
>>>>>>>
>>>>>>> 2. If you  want to get the path from the clipboard instead of a file 
>>>>>>> dialog, replace the lines
>>>>>>>
>>>>>>> PATH = g.app.gui.runOpenFileDialog(c,
>>>>>>> title="Import File",
>>>>>>> filetypes=[("All files", "*"),],
>>>>>>> defaultextension=".*",
>>>>>>> multiple=False)
>>>>>>>
>>>>>>> with the line 
>>>>>>>
>>>>>>> PATH = g.app.gui.getTextFromClipboard()
>>>>>>>
>>>>>>> 3. If you want the embedded image to be full width instead of 50%, 
>>>>>>> delete the line
>>>>>>>
>>>>>>> :scale: 50%
>>>>>>>
>>>>>>> 4. You can make this work with Markdown or Asciidoc by using their 
>>>>>>> embedding instruction in the TEMPLATE instead of the RsT one.
>>>>>>>
>>>>>>> I have added the command to my own local menu.  VR3 can open in a 
>>>>>>> tab in the log pane; the command for toggling in a tab is 
>>>>>>> *vr3-toggle-tab. * I usually like opening it in the log pane 
>>>>>>> instead of in its own separate pane.
>>>>>>>
>>>>>>> If you would like to create a local menu of your own and don't know 
>>>>>>> how, it's easy.  Just ask and I'll show what to add to 
>>>>>>> myLeoSettings,leo.
>>>>>>>
>>>>>>

-- 
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/22a3e7ff-0914-4615-9c72-03b88eef96d5n%40googlegroups.com.


Re: A Script To Insert An Image

2024-03-23 Thread Thomas Passin
Looks pretty straightforward.  Perhaps you'll want to make it undoable (so 
far as Leo is concerned).  As a matter of Python programming, defining a 
main() function here isn't needed.  If you are only going to use it as a 
script, then you don't need a function at all. Just unindent those lines of 
code (and delete the "main()" line) and they will run when the script 
runs.  No need to call main() at all.   If you want that clipboard part of 
the block to run and if it succeeds then insert the markdown text into a 
node, then the function shouldn't be called "main" but something more 
descriptive.

On Saturday, March 23, 2024 at 4:59:25 PM UTC-4 jkn wrote:

> OK, here is a simple demonstration of part of the feature I am interested 
> in.
>
> When run with an image in the (global) clipboard, it saves this to a local 
> timestamped file (under ~/tmp), and indicates how a markdown reference to 
> that file could be inserted.
>
> There's plenty more needed but this is the QClipboard part, I think.
>
> import os
> import time
> 
> def unique_png_fname():
> """ return a unique (timestamped) filename to use
> """
> FORMAT="%Y-%m-%d-%H-%M-%S.png"
> return time.strftime(FORMAT)
>
> def link_string_md(fname):
> """ get markdown format to insert a filename
> """
> return "![[%s]]" % fname
>
> def main():
> # get clipboard contents - default mode is global clipboard
> cb = g.app.gui.qtApp.clipboard()
> # is it in image format?
> img = cb.image()
> if not img.isNull():
> basefiledir = os.path.expanduser("~/tmp")
> fqfilepath = os.path.join(basefiledir, unique_png_fname())
> img.save(fqfilepath, "PNG")
> g.es("wrote clipboard to:", fqfilepath)
> g.es("could insert:", link_string_md(fqfilepath))
> else:
> g.es("clipboard not in image format")
>
> main()
>
>
> On Monday, March 11, 2024 at 8:23:42 PM UTC jkn wrote:
>
>> Doh! should have read the documentation better.
>>
>> you have to test for a 'null image' using eg. img.isnull()
>>
>> on with my trivial experiments...
>>
>>
>> On Monday, March 11, 2024 at 8:10:03 PM UTC jkn wrote:
>>
>>> Has anyone played much with class QClipboard? I did a couple of trivial 
>>> experiments but I must be misunderstanding something.
>>>
>>> for instance, QClipboard.image() returns a non-null value even if the 
>>> clipboard does not contain an image.
>>>
>>> J^n
>>>
>>>
>>> On Monday, March 11, 2024 at 4:33:23 PM UTC tbp1...@gmail.com wrote:
>>>
>>>> It turns out that to get the relative path conversion w have to remove 
>>>> any quotation marks around the path before running os.relpath(). So the 
>>>> script becomes:
>>>>
>>>> """Insert RsT code at cursor to display an image.
>>>>
>>>> The path to the image file will come from a file dialog.
>>>> This action is undoable.
>>>> """
>>>> PATH = g.app.gui.runOpenFileDialog(c,
>>>> title="Import File",
>>>> filetypes=[("All files", "*"),],
>>>> defaultextension=".*",
>>>> multiple=False)
>>>>
>>>> if PATH:
>>>> from os.path import relpath
>>>>     PATH = PATH.replace('"', '').replace("'", '')
>>>> PATH = relpath(PATH)
>>>> PATH = PATH.replace('\\', '/')
>>>>
>>>> IMAGE_TEMPLATE = f'''
>>>>
>>>> .. figure:: {PATH}
>>>> :scale: 50%
>>>>
>>>> '''
>>>>
>>>> w = c.frame.body.wrapper
>>>> p = c.p
>>>> s = p.b
>>>> u = c.undoer
>>>>
>>>> start, _ = w.getSelectionRange()
>>>>
>>>> undoType = 'insert-rst-image-code'
>>>> undoData = u.beforeChangeNodeContents(p)
>>>>
>>>> head, tail = s[:start], s[start:]
>>>> p.b = head + IMAGE_TEMPLATE + tail
>>>>
>>>> c.setChanged()
>>>> p.setDirty()
>>>> u.afterChangeNodeContents(p, undoType, undoData)
>>>> c.redraw()
>>>>
>>>&

Re: Leo 6.7.8 released to pypi

2024-03-22 Thread Thomas Passin
I've tried out installing post3 on my fleet of Linux VMs.  It succeeded on 
all of them although for some I had to add the pip install option 
*--break-system-packages.  
*After installation, there was a also new "leo" script that launched Leo.  
So it looks like all Edward's hard work has paid off. The install command 
was:

python3 -m pip install --user --upgrade leo

Here is the list of distros I tried:

debian 22.04
fedora
manjaro
mint
opensuse
ubuntu
xubuntu

On Thursday, March 21, 2024 at 4:59:37 PM UTC-4 Edward K. Ream wrote:

>  Leo 6.7.8.post3 is now working as expected in an existing 'venv' w/i a 
>> Fedora 38 VM !
>>
>
> Excellent. Thanks for your testing :-)
>
> Edward
>

-- 
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/b2165288-6be5-47fe-97f8-0c5fd2ac7e6an%40googlegroups.com.


Re: the name ``wheel''

2024-03-21 Thread Thomas Passin via Python-list

On 3/21/2024 4:19 PM, Grant Edwards via Python-list wrote:

On 2024-03-21, MRAB via Python-list  wrote:


As it's recommended to use the Python Launcher py on Windows, I use
that instead:

py -m pip install something

because it gives better support if you have multiple versions of
Python installed.


I adopted that practice years ago on Linux as well after wasting what
seemed like most of a day trying to figure out problems which turned
out to be caused by the fact that "pip" and "python" invoked different
versions of Python.


Although you still need to be aware that there might be a different 
Python installation between e.g. "python3 -m pip" and "python3.11 -m 
pip", etc. depending on what's been installed.


--
https://mail.python.org/mailman/listinfo/python-list


Re: Small puzzle: where is this focus-to-body action coming from?

2024-03-21 Thread Thomas Passin

On Thursday, March 21, 2024 at 2:02:50 PM UTC-4 jkn wrote:

Nevertheless - other @shortcuts I have in myLeoSettings.leo are shown in 
the log output to 'show-commands' - why not this one?


It's in there. My listings for Settings/Show Settings /Show Commands has it:

Alt+d   focus-to-body

It's hard to find things in these listings so I copied it and pasted it 
into a text editor.  A search for the command name located its line. Note 
that either a + or - symbol can be used for bindings, as best I know.

-- 
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/6106f3b1-fb1d-47fc-9208-91955ba90f72n%40googlegroups.com.


Re: Small puzzle: where is this focus-to-body action coming from?

2024-03-21 Thread Thomas Passin
It's in LeoSettings.leo, in the node @shortcuts Gui operations.

On Thursday, March 21, 2024 at 10:33:33 AM UTC-4 jkn wrote:

> I keep meaning to look at 'improving' (for my needs) navigation between 
> Tree and body panes. Whilst taking a look at this again I found a puzzle.
>
> I have what is (I think) the standard bindings for this:
>
> # show-commands
> Alt+d   focus-to-body
>tree:Tab focus-to-body
> focus-to-find
> focus-to-log
> focus-to-minibuffer
> focus-to-spell-tab
> Alt+t   focus-to-tree
>
> However - CTRL+right (ie. main arrow keys on my 107-key KB) seems to do 
> focus-to-body as well as TAB.
>
> Any idea where this binding might be occurring? Is CTRL-right getting 
> turned into TAB somewhere? How can I find out, if show-commands gives the 
> output above?
>
> Thanks, jon N
>
>
>

-- 
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/bcbdf5d8-1934-4a74-b1ba-f15b9cc1a8e3n%40googlegroups.com.


Re: Leo 6.7.8.post1 is ready for testing

2024-03-20 Thread Thomas Passin
Aha! I didn't pick up on that because I always start Leo with python3 -m 
leo.core.runLeo. I do that instead of using a script fromt the Scripts 
directory because I don't let a new install of Python add those directories 
to the path.  And I do *that* because I used to need the Python 2.7 Script 
directories on the path for reasons we don't need to get into. Also I have 
many versions of Python on my machine and the scripts would only work for 
one of them at a time anyway. I can launch Leo with any Python version I 
want in the above incantation and it's become automatic.

On Wednesday, March 20, 2024 at 8:13:56 AM UTC-4 Edward K. Ream wrote:

> On Wednesday, March 20, 2024 at 3:13:41 AM UTC-5 Viktor wrote:
>
>  I installed Leo 6.7.8.post1 into an existing 'venv' on a Fedora 38 VM - 
> but - I could NOT run it using the 'leo' cmd from the shell.
>
> I also tried installing Leo 6.7.8.post1 into a completely new Fedora 38 VM 
> w/o using a 'venv' - Same behaviour ...
>
>
> Thanks for your testing! It looks like a post2 release is called for. 
>
> The old setup.py contained:
>
> entry_points = {
> 'console_scripts': [
> 'leo-c = leo.core.runLeo:run_console',
> 'leo-console = leo.core.runLeo:run_console',
> ],
> 'gui_scripts': ['leo = leo.core.runLeo:run'],
> }
>
> but pyproject.toml does not contain anything similar.
>
> *Leo's signon*
>
> The post2 release revert Leo's signon to 6.7.8, *not* 6.7.8.post2. 
>
> Why? Because "post" releases should *only* fix release-related code, 
> *never* real bugs.
>
> Edward
>

-- 
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/fda22629-2f6d-4587-bed7-cd88d996a98an%40googlegroups.com.


Re: Leo 6.7.8.post1 is ready for testing

2024-03-19 Thread Thomas Passin
On Linux systems that don't allow installing user packages with pip because 
the system python is managed by the system, you can force installation 
using the --break-system packages option, like this:

python3 -m pip install --user --upgrade --break-system-packages 
leo==6.7.8.post1

You will know if this applies to you because you will have seen a message 
that starts like this:

error: externally-managed-environment
This environment is externally managed
╰─> To install Python packages system-wide, try apt install python3-xyz, 
where xyz is the package you are trying to install.

If you wish to install a non-Debian-packaged Python package, create a 
virtual environment using python3 -m venv path/to/venv. Then use 
path/to/venv/bin/python and path/to/venv/bin/pip. Make sure you have 
python3-full installed.

The risk of actually over-riding a system package with the wrong version is 
probably minimal since Leo doesn't seem to use packages in the system 
directories.

If you already are using a venv for Leo, then there should be no problem 
with the install.

On Tuesday, March 19, 2024 at 11:12:32 PM UTC-4 Thomas Passin wrote:

Installed OK on Ubuntu 22.04, Python 3.10.


On Tuesday, March 19, 2024 at 10:31:46 PM UTC-4 Thomas Passin wrote:

python3 -m pip install --user --upgrade leo==6.7.8.post1 succeeded on Linux 
Debian, although I had to install *libxcb-cursor0* afterwards, as we've 
been seeing on some other distros.  After the install:

Leo 6.7.8.post1
Python 3.9.2, PyQt version 6.6.2
linux


On Tuesday, March 19, 2024 at 5:39:27 PM UTC-4 Edward K. Ream wrote:

You can now install Leo *6.7.8.post1* from pypi 
<https://pypi.org/project/leo/>. This "post" release changes only 
distribution-related files. See PR #3835 
<https://github.com/leo-editor/leo-editor/pull/3835/files> for the details.


The "post1" prefix is required to meet the more stringent pypi naming 
conventions.


Please test the installation process immediately and report your experience.


I'll announce Leo 6.7.8 widely when you all give the all-clear :-)


Edward

-- 
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/ffe319a5-dacb-4917-9701-a959f55891dbn%40googlegroups.com.


Re: Leo 6.7.8.post1 is ready for testing

2024-03-19 Thread Thomas Passin
Installed OK on Ubuntu 22.04, Python 3.10.


On Tuesday, March 19, 2024 at 10:31:46 PM UTC-4 Thomas Passin wrote:

> python3 -m pip install --user --upgrade leo==6.7.8.post1 succeeded on 
> Linux Debian, although I had to install *libxcb-cursor0* afterwards, as 
> we've been seeing on some other distros.  After the install:
>
> Leo 6.7.8.post1
> Python 3.9.2, PyQt version 6.6.2
> linux
>
>
> On Tuesday, March 19, 2024 at 5:39:27 PM UTC-4 Edward K. Ream wrote:
>
>> You can now install Leo *6.7.8.post1* from pypi 
>> <https://pypi.org/project/leo/>. This "post" release changes only 
>> distribution-related files. See PR #3835 
>> <https://github.com/leo-editor/leo-editor/pull/3835/files> for the 
>> details.
>>
>>
>> The "post1" prefix is required to meet the more stringent pypi naming 
>> conventions.
>>
>>
>> Please test the installation process immediately and report your 
>> experience.
>>
>>
>> I'll announce Leo 6.7.8 widely when you all give the all-clear :-)
>>
>>
>> Edward
>>
>

-- 
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/31894fea-8438-42f8-a9ac-599503622f5en%40googlegroups.com.


Re: Leo 6.7.8.post1 is ready for testing

2024-03-19 Thread Thomas Passin
python3 -m pip install --user --upgrade leo==6.7.8.post1 succeeded on Linux 
Debian, although I had to install *libxcb-cursor0* afterwards, as we've 
been seeing on some other distros.  After the install:

Leo 6.7.8.post1
Python 3.9.2, PyQt version 6.6.2
linux


On Tuesday, March 19, 2024 at 5:39:27 PM UTC-4 Edward K. Ream wrote:

> You can now install Leo *6.7.8.post1* from pypi 
> . This "post" release changes only 
> distribution-related files. See PR #3835 
>  for the 
> details.
>
>
> The "post1" prefix is required to meet the more stringent pypi naming 
> conventions.
>
>
> Please test the installation process immediately and report your 
> experience.
>
>
> I'll announce Leo 6.7.8 widely when you all give the all-clear :-)
>
>
> Edward
>

-- 
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/ba540e93-4167-4b0c-afd7-9f5d5ce7ad33n%40googlegroups.com.


Re: ENB: Distribution challenges

2024-03-19 Thread Thomas Passin

On Monday, March 18, 2024 at 5:43:22 PM UTC-4 Edward K. Ream wrote:

This Engineering Notebook post briefly summarizes the challenges in 
distributing Leo on pypi.


*I would greatly appreciate help debugging either PR*. My *guess* is that 
pyproject.toml needs only a tweak, but finding that tweak has not been 
easy!!!


If it would  help, once everything is working locally for you on Windows I 
could try it out on several Linux VMs.

-- 
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/46c50b1f-922b-49a4-bddd-8c4e56b78a1fn%40googlegroups.com.


Re: Leo 6.7.8 released, but not to PyPi

2024-03-18 Thread Thomas Passin
Then there's the brute force method - get the zip file from github, unzip 
it, and copy the leo directory into the user's site-packages directory.  To 
be thorough, one should delete the dist-info directory for Leo.  I don't 
know if venv would get this version when setting up a venv, though. 
Although it's not hard,  it isn't a wonderful procedure to ask a 
non-computer-savvy user to do.  It could probably be automated with a 
script, though.

On Monday, March 18, 2024 at 9:01:36 AM UTC-4 viktor@gmail.com wrote:

> Hello Edward,
>
> Edward K. Ream schrieb am Freitag, 15. März 2024 um 11:08:11 UTC+1:
>
> Leo https://leo-editor.github.io/leo-editor/ 6.7.8 is now available on 
> GitHub  but *NOT *on 
> pypi . I have filed this twine issue 
> .
>
> I am enraged by the difficulties of creating a PyPi release. The point of 
> this release was to simplify the installation of Leo, but that goal is on 
> hold until I can update Leo on PyPi.
>
> Any help you can give would be much appreciated.
>
>  
> Until Leo 6.7.7 (including) I was able to install & run Leo *WITHOUT* 
> having to manually create a script on the Linux side. - This is no longer 
> possible as of Leo 6.7.8 !
>
> As I already explained in a separate message to Felix I'm trying to work 
> with separate Python virtual environments (venv's) whenever possible ...
>
> One for GitHub (devel branch), a second one for PyPI (released version) & 
> a separate non-venv based one for LeoInteg. - Reason: see 
> https://github.com/boltex/leointeg/issues/299
>
> Here is initial 'path' & 'version' info about all three environments in a 
> Debian 12 based VM:
>
> ### dedicated ~venv~ for GitHub:
>
> user@debian-leo-study-vm:~$ 
> user@debian-leo-study-vm:~$ cd PyVE/GitHub/Leo/
> user@debian-leo-study-vm:~/PyVE/GitHub/Leo$ 
> user@debian-leo-study-vm:~/PyVE/GitHub/Leo$ source bin/activate
> (Leo) user@debian-leo-study-vm:~/PyVE/GitHub/Leo$ 
> (Leo) user@debian-leo-study-vm:~/PyVE/GitHub/Leo$ which leo
> /home/user/PyVE/GitHub/Leo/bin/leo
> (Leo) user@debian-leo-study-vm:~/PyVE/GitHub/Leo$ 
> (Leo) user@debian-leo-study-vm:~/PyVE/GitHub/Leo$ leo --version
> Leo 6.7.7-devel, devel branch, build 401a78a10e
> 2023-12-31 12:42:43 -0600
> Python 3.11.2
> linux
> (Leo) user@debian-leo-study-vm:~/PyVE/GitHub/Leo$ 
>
> ### dedicated ~venv~ for PyPI:
>
> user@debian-leo-study-vm:~$ 
> user@debian-leo-study-vm:~$ cd PyVE/PyPI/Leo/
> user@debian-leo-study-vm:~/PyVE/PyPI/Leo$ 
> user@debian-leo-study-vm:~/PyVE/PyPI/Leo$ source bin/activate
> (Leo) user@debian-leo-study-vm:~/PyVE/PyPI/Leo$ 
> (Leo) user@debian-leo-study-vm:~/PyVE/PyPI/Leo$ which leo
> /home/user/PyVE/PyPI/Leo/bin/leo
> (Leo) user@debian-leo-study-vm:~/PyVE/PyPI/Leo$ 
> (Leo) user@debian-leo-study-vm:~/PyVE/PyPI/Leo$ leo --version
> Leo 6.7.6
> Python 3.11.2
> linux
> (Leo) user@debian-leo-study-vm:~/PyVE/PyPI/Leo$ 
>
> ### user-specific installation for LeoInteg:
>
> user@debian-leo-study-vm:~$ 
> user@debian-leo-study-vm:~$ which leo
> /home/user/.local/bin/leo
> user@debian-leo-study-vm:~$ 
> user@debian-leo-study-vm:~$ leo --version
> Leo 6.7.7
> Python 3.11.2
> linux
> user@debian-leo-study-vm:~$ 
>
> ###
>
> I believe it is somewhat related to the differences b/w Leo's source tree 
> / directory content when installed from GitHub vs. PyPI.
>
> I hope this provides at least some additional input for your analysis to 
> resolve the issue ...
>
> 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/a63b6043-11b8-4b1f-9535-a53c10ca79e1n%40googlegroups.com.


Re: Discuss: Leo 6.7.8 will install only PyQt6

2024-03-17 Thread Thomas Passin
That's a great tip.  Thanks!

On Sunday, March 17, 2024 at 4:03:24 PM UTC-4 gates...@gmail.com wrote:

> My go-to ‘what package do I need’ tool is pkgs.org.  They’re showing that 
> the package for Fedora 38 is called xcb-until-cursor.  Linux library 
> management leaves much to be desired, in general.
>
> https://pkgs.org/download/libxcb-cursor.so.0()(64bit)
>
> Hope this helps!
> Jake
>
> On Mar 17, 2024, at 3:45 PM, Viktor Ransmayr  wrote:
>
> 
>
> Hello Thomas,
>
> Am So., 17. März 2024 um 15:41 Uhr schrieb Thomas Passin <
> tbp1...@gmail.com>:
>
>> Try the other suggested library in the error message:  xcb-cursor0 . I 
>> went through the same thing about a week ago on a different distro, and 
>> using the alternate suggestion solved it.  If that doesn't work either, run 
>> an internet search for "fedora qt.qpa.plugin: From 6.5.0, xcb-cursor0 or 
>> libxcb-cursor0 is needed to load the Qt xcb platform plugin." This may 
>> surface another library name that your distro has.
>>
>
> I tried both libraries ! - See my log ...
>  
>
>> On Sunday, March 17, 2024 at 3:20:17 PM UTC-4 viktor@gmail.com wrote:
>>
>>> Hello Edward, hello Thomas,
>>>
>>> tbp1...@gmail.com schrieb am Freitag, 1. März 2024 um 07:32:23 UTC-5:
>>>
>>> On Friday, March 1, 2024 at 5:33:34 AM UTC-5 Edward K. Ream wrote:
>>>
>>> My question wasn't clear. I meant to ask whether potential errors 
>>> concerning the missing xcb-cursor0 or libxcb-cursor0 libraries are a 
>>> show stopper.
>>>
>>> Imo, most linux users will know to run sudo apt install, so the missing 
>>> library isn't a significant barrier to requiring PyQt6. A new FAQ entry 
>>> might be all that is needed. Do you agree?
>>>
>>>
>>> A year ago I might have said it was a show-stopper.  But now the error 
>>> message from Ubuntu was clear enough that running its suggested command 
>>> fixed the issue.  In years past I had to go to the internet and wade 
>>> through a lot of useless posts to find the right command (I've saved it in 
>>> my workbook to make it easier to find).  I do know that some non-technical 
>>> people will read the error message and yet not know what to do, so I agree 
>>> with a FAQ entry.
>>>
>>> BTW, Ubuntu/XUbuntu is the only distro where I've encountered this issue 
>>> so far.
>>>
>>>
>>> I have encountered this problem as well, when I tried to install Leo 
>>> from the devel-branch into a newly created Fedora 38 VM.
>>>
>>> When I try to install the mentioned libraries I receive the following 
>>> error msg:
>>>
>>> ###
>>>
>>> [user@Test-VM1 ~]$ 
>>> [user@Test-VM1 ~]$ ./leo &
>>> [1] 1513
>>> [user@Test-VM1 ~]$ setting leoID from os.getenv('USER'): 'user'
>>>
>>> qt.qpa.plugin: From 6.5.0, xcb-cursor0 or libxcb-cursor0 is needed 
>>> to load the Qt xcb platform plugin.
>>> qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" 
>>> even though it was found.
>>> This application failed to start because no Qt platform plugin could 
>>> be initialized. Reinstalling the application may fix this problem.
>>>
>>> Available platform plugins are: linuxfb, vnc, minimal, wayland-egl, 
>>> eglfs, vkkhrdisplay, offscreen, wayland, xcb, minimalegl.
>>>
>>> ./leo: line 2:  1517 Aborted (core dumped) python 
>>> ~/leo-editor/launchLeo.py $1
>>>
>>> [1]+  Exit 134./leo
>>> [user@Test-VM1 ~]$ 
>>> [user@fedora-38-minimal-vr ~]$ sudo dnf install libxcb-cursor0
>>> Last metadata expiration check: 2:19:22 ago on Sun Mar 17 12:29:58 
>>> 2024.
>>> No match for argument: libxcb-cursor0
>>> Error: Unable to find a match: libxcb-cursor0
>>> [user@fedora-38-minimal-vr ~]$ 
>>> [user@fedora-38-minimal-vr ~]$ sudo dnf install xcb-cursor0
>>> Last metadata expiration check: 2:19:56 ago on Sun Mar 17 12:29:58 
>>> 2024.
>>> No match for argument: xcb-cursor0
>>> Error: Unable to find a match: xcb-cursor0
>>> [user@fedora-38-minimal-vr ~]$ 
>>>
>>> ###
>>>
>>> What am I missing ?
>>>
>>> With kind regards,
>>>
>>> Viktor
>>>  
>>>
>> -- 
>> 

Re: Discuss: Leo 6.7.8 will install only PyQt6

2024-03-17 Thread Thomas Passin
Try the other suggested library in the error message:  xcb-cursor0 . I went 
through the same thing about a week ago on a different distro, and using 
the alternate suggestion solved it.  If that doesn't work either, run an 
internet search for "fedora qt.qpa.plugin: From 6.5.0, xcb-cursor0 or 
libxcb-cursor0 is needed to load the Qt xcb platform plugin." This may 
surface another library name that your distro has.
On Sunday, March 17, 2024 at 3:20:17 PM UTC-4 viktor@gmail.com wrote:

> Hello Edward, hello Thomas,
>
> tbp1...@gmail.com schrieb am Freitag, 1. März 2024 um 07:32:23 UTC-5:
>
> On Friday, March 1, 2024 at 5:33:34 AM UTC-5 Edward K. Ream wrote:
>
> My question wasn't clear. I meant to ask whether potential errors 
> concerning the missing xcb-cursor0 or libxcb-cursor0 libraries are a show 
> stopper.
>
> Imo, most linux users will know to run sudo apt install, so the missing 
> library isn't a significant barrier to requiring PyQt6. A new FAQ entry 
> might be all that is needed. Do you agree?
>
>
> A year ago I might have said it was a show-stopper.  But now the error 
> message from Ubuntu was clear enough that running its suggested command 
> fixed the issue.  In years past I had to go to the internet and wade 
> through a lot of useless posts to find the right command (I've saved it in 
> my workbook to make it easier to find).  I do know that some non-technical 
> people will read the error message and yet not know what to do, so I agree 
> with a FAQ entry.
>
> BTW, Ubuntu/XUbuntu is the only distro where I've encountered this issue 
> so far.
>
>
> I have encountered this problem as well, when I tried to install Leo from 
> the devel-branch into a newly created Fedora 38 VM.
>
> When I try to install the mentioned libraries I receive the following 
> error msg:
>
> ###
>
> [user@Test-VM1 ~]$ 
> [user@Test-VM1 ~]$ ./leo &
> [1] 1513
> [user@Test-VM1 ~]$ setting leoID from os.getenv('USER'): 'user'
>
> qt.qpa.plugin: From 6.5.0, xcb-cursor0 or libxcb-cursor0 is needed to 
> load the Qt xcb platform plugin.
> qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even 
> though it was found.
> This application failed to start because no Qt platform plugin could 
> be initialized. Reinstalling the application may fix this problem.
>
> Available platform plugins are: linuxfb, vnc, minimal, wayland-egl, 
> eglfs, vkkhrdisplay, offscreen, wayland, xcb, minimalegl.
>
> ./leo: line 2:  1517 Aborted (core dumped) python 
> ~/leo-editor/launchLeo.py $1
>
> [1]+  Exit 134./leo
> [user@Test-VM1 ~]$ 
> [user@fedora-38-minimal-vr ~]$ sudo dnf install libxcb-cursor0
> Last metadata expiration check: 2:19:22 ago on Sun Mar 17 12:29:58 
> 2024.
> No match for argument: libxcb-cursor0
> Error: Unable to find a match: libxcb-cursor0
> [user@fedora-38-minimal-vr ~]$ 
> [user@fedora-38-minimal-vr ~]$ sudo dnf install xcb-cursor0
> Last metadata expiration check: 2:19:56 ago on Sun Mar 17 12:29:58 
> 2024.
> No match for argument: xcb-cursor0
> Error: Unable to find a match: xcb-cursor0
> [user@fedora-38-minimal-vr ~]$ 
>
> ###
>
> What am I missing ?
>
> 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/a257a7e3-343e-4f9e-bfde-f3c58b9f9b72n%40googlegroups.com.


Re: Configuring an object via a dictionary

2024-03-16 Thread Thomas Passin via Python-list

On 3/16/2024 8:12 AM, Roel Schroeven via Python-list wrote:

Barry via Python-list schreef op 16/03/2024 om 9:15:


> On 15 Mar 2024, at 19:51, Thomas Passin via Python-list 
  wrote:
> > I've always like writing using the "or" form and have never gotten 
bit


I, on the other hand, had to fix a production problem that using “or” 
introducted.

I avoid this idiom because it fails on falsy values.

Me too. It's just too fragile. When writing code you're going to need an 
alternative for cases where "config.get('source_name') or default_value" 
doesn't work correctly; much better to use that alternative for all cases.


Trying to remember when I've used it, that was probably on personal code 
where I had a good idea what the values could be. Otherwise, I'm in 
agreement.


--
https://mail.python.org/mailman/listinfo/python-list


Re: Configuring an object via a dictionary

2024-03-15 Thread Thomas Passin via Python-list

On 3/15/2024 5:33 PM, Dan Sommers via Python-list wrote:

On 2024-03-15 at 15:48:17 -0400,
Thomas Passin via Python-list  wrote:


[...] And I suppose there is always the possibility that sometime in
the future an "or" clause like that will be changed to return a
Boolean, which one would expect anyway.


Not only is the current value is way more useful, but changing it would
be a compatibility and maintenance nightmare.


I'm with you here!


If I want Java, I know where to find it.  :-)


--
https://mail.python.org/mailman/listinfo/python-list


Re: Configuring an object via a dictionary

2024-03-15 Thread Thomas Passin via Python-list

On 3/15/2024 3:09 PM, Grant Edwards via Python-list wrote:

On 2024-03-15, Thomas Passin via Python-list  wrote:

On 3/15/2024 5:30 AM, Loris Bennett via Python-list wrote:

Hi,

I am initialising an object via the following:

  def __init__(self, config):

  self.connection = None

  self.source_name = config['source_name']
  self.server_host = config['server_host']
  self.server_port = config['server_port']
  self.user_base = config['user_base']
  self.user_identifier = config['user_identifier']
  self.group_base = config['group_base']
  self.group_identifier = config['group_identifier']
  self.owner_base = config['owner_base']

However, some entries in the configuration might be missing.  What is
the best way of dealing with this?

I could of course simply test each element of the dictionary before
trying to use.  I could also just write

 self.config = config

but then addressing the elements will add more clutter to the code.

However, with a view to asking forgiveness rather than
permission, is there some simple way just to assign the dictionary
elements which do in fact exist to self-variables?

Or should I be doing this completely differently?


  self.source_name = config.get('source_name', default_value)

Or, if you like this kind of expression better,

  self.source_name = config.get('source_name') or default_value


Won't the latter version misbehave if the value of config['source_name'] has a
"false" boolean value (e.g. "", 0, 0.0, None, [], (), {}, ...)


config = {}
config['source_name'] = ""
config.get('source_name') or 'default'

'default'


Oh, well, picky, picky!  I've always like writing using the "or" form 
and have never gotten bit - especially for configuration-type values 
where you really do expect a non-falsey value, it's probably low risk - 
but of course, you're right. In newer code I have been putting a default 
into get().  And I suppose there is always the possibility that sometime 
in the future an "or" clause like that will be changed to return a 
Boolean, which one would expect anyway.


--
https://mail.python.org/mailman/listinfo/python-list


Re: Configuring an object via a dictionary

2024-03-15 Thread Thomas Passin via Python-list

On 3/15/2024 5:30 AM, Loris Bennett via Python-list wrote:

Hi,

I am initialising an object via the following:

 def __init__(self, config):

 self.connection = None

 self.source_name = config['source_name']
 self.server_host = config['server_host']
 self.server_port = config['server_port']
 self.user_base = config['user_base']
 self.user_identifier = config['user_identifier']
 self.group_base = config['group_base']
 self.group_identifier = config['group_identifier']
 self.owner_base = config['owner_base']

However, some entries in the configuration might be missing.  What is
the best way of dealing with this?

I could of course simply test each element of the dictionary before
trying to use.  I could also just write

self.config = config

but then addressing the elements will add more clutter to the code.

However, with a view to asking forgiveness rather than
permission, is there some simple way just to assign the dictionary
elements which do in fact exist to self-variables?

Or should I be doing this completely differently?


self.source_name = config.get('source_name', default_value)

Or, if you like this kind of expression better,

self.source_name = config.get('source_name') or default_value

.get() will return None if the key doesn't exist, or the default value 
if you specify one.

--
https://mail.python.org/mailman/listinfo/python-list


Re: A Script To Insert An Image

2024-03-11 Thread Thomas Passin
It turns out that to get the relative path conversion w have to remove any 
quotation marks around the path before running os.relpath(). So the script 
becomes:

"""Insert RsT code at cursor to display an image.

The path to the image file will come from a file dialog.
This action is undoable.
"""
PATH = g.app.gui.runOpenFileDialog(c,
title="Import File",
filetypes=[("All files", "*"),],
defaultextension=".*",
multiple=False)

if PATH:
from os.path import relpath
PATH = PATH.replace('"', '').replace("'", '')
PATH = relpath(PATH)
PATH = PATH.replace('\\', '/')
IMAGE_TEMPLATE = f'''

.. figure:: {PATH}
:scale: 50%

'''

w = c.frame.body.wrapper
p = c.p
s = p.b
u = c.undoer

start, _ = w.getSelectionRange()

undoType = 'insert-rst-image-code'
undoData = u.beforeChangeNodeContents(p)

head, tail = s[:start], s[start:]
p.b = head + IMAGE_TEMPLATE + tail

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

On Saturday, March 9, 2024 at 2:04:19 PM UTC-5 Thomas Passin wrote:

> We can't directly insert an image into a standard Leo node because they 
> are text-only.  I find this very annoying sometimes, especially when I am 
> writing a note and want to include an image.  
>
> But we can do the next best thing - insert an ReStructuredText (RsT) 
> instruction to display an image so that we can view it with the 
> viewrendered3 plugin (VR3). The instruction is short and easy, but it's 
> still annoying to type and I usually forget the exact details. I have a 
> button that toggles VR3 on and off so that it's easy to view an embedded 
> image once the RsT instruction is there. An embedding command would make 
> embedding with Leo as easy as embedding an image in a word processor.  
>  Aha, this is Leo, let's write a script!
>
> Here is a script that pops up a file dialog and inserts a relative path to 
> the chosen file.  There are several small variations which I discuss after 
> the code.
>
> """Insert RsT code at cursor to display an image.
>
> The path to the image file will come from a file dialog.
> This action is undoable.
> """
> PATH = g.app.gui.runOpenFileDialog(c,
> title="Import File",
> filetypes=[("All files", "*"),],
> defaultextension=".*",
> multiple=False)
>
> if PATH:
> from os.path import relpath
> PATH = relpath(PATH)
> PATH = PATH.replace('\\', '/').replace('"', '').replace("'", '')
> IMAGE_TEMPLATE = f'''
>
> .. figure:: {PATH}
> :scale: 50%
>
> '''
> w = c.frame.body.wrapper
> p = c.p
> s = p.b
> u = c.undoer
>
> start, _ = w.getSelectionRange()
>
> undoType = 'insert-rst-image-code'
> undoData = u.beforeChangeNodeContents(p)
>
> head, tail = s[:start], s[start:]
> p.b = head + IMAGE_TEMPLATE + tail
>
> c.setChanged()
> p.setDirty()
> u.afterChangeNodeContents(p, undoType, undoData)
> c.redraw()
>
> Variations:
> 1.  If you want an absolute path instead of a relative path, delete the 
> lines
> from os.path import relpath
> PATH = relpath(PATH)
> with
>
> 2. If you  want to get the path from the clipboard instead of a file 
> dialog, replace the lines
>
> PATH = g.app.gui.runOpenFileDialog(c,
> title="Import File",
> filetypes=[("All files", "*"),],
> defaultextension=".*",
> multiple=False)
>
> with the line 
>
> PATH = g.app.gui.getTextFromClipboard()
>
> 3. If you want the embedded image to be full width instead of 50%, delete 
> the line
>
> :scale: 50%
>
> 4. You can make this work with Markdown or Asciidoc by using their 
> embedding instruction in the TEMPLATE instead of the RsT one.
>
> I have added the command to my own local menu.  VR3 can open in a tab in 
> the log pane; the command for toggling in a tab is *vr3-toggle-tab. * I 
> usually like opening it in the log pane instead of in its own separate pane.
>
> If you would like to create a local menu of your own and don't know how, 
> it's easy.  Just ask and I'll show what to add to myLeoSettings,leo.
>

-- 
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/8cfecaea-4d99-4435-8ce8-fe6da3af427cn%40googlegroups.com.


Re: pathlib.Path.is_file vs os.path.isfile difference

2024-03-10 Thread Thomas Passin via Python-list

On 3/10/2024 9:33 AM, Albert-Jan Roskam wrote:



On Mar 10, 2024 12:59, Thomas Passin via Python-list 
 wrote:


On 3/10/2024 6:17 AM, Barry wrote:
 >
 >
 >> On 8 Mar 2024, at 23:19, Thomas Passin via Python-list
 wrote:
 >>
 >> We just learned a few posts back that it might be specific to
Linux; I ran it on Windows.
 >
 > Depending on the exact win32 api used there is a 257 limit on
windows.
 > The 257 includes 2 for the device, C:, and 255 for the path part
that will use 1 for the leading \. Getting an error for a name that
is 255 is not surprising.
 >
 > Other api allow for 65535 limit, not sure on its additional limits.

I seem to remember there is a setting to allow longer paths, but I
forget any details.



=

You mean the "\\?\" prefix?

https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=registry


That and there's a registry setting:

https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation



--
https://mail.python.org/mailman/listinfo/python-list


Re: pathlib.Path.is_file vs os.path.isfile difference

2024-03-10 Thread Thomas Passin via Python-list

On 3/10/2024 6:17 AM, Barry wrote:




On 8 Mar 2024, at 23:19, Thomas Passin via Python-list  
wrote:

We just learned a few posts back that it might be specific to Linux; I ran it 
on Windows.


Depending on the exact win32 api used there is a 257 limit on windows.
The 257 includes 2 for the device, C:, and 255 for the path part that will use 
1 for the leading \. Getting an error for a name that is 255 is not surprising.

Other api allow for 65535 limit, not sure on its additional limits.


I seem to remember there is a setting to allow longer paths, but I 
forget any details.


--
https://mail.python.org/mailman/listinfo/python-list


Re: LeoJS - How To Write To File System And Run External Programs

2024-03-09 Thread Thomas Passin
I don't know if you got around to thinking about it yet (you've got so much 
else going on!), but the command I wrote to run external files is in 
LeoPyRef and it's called *execute-external-file*.  It has some trickiness 
because it has to run on Linux as well as Windows, and the terminal 
commands to launch programs differ among the distros. The code has to try 
some empirical hacks to figure it all out. But it ought to port to TS 
pretty easily, I would think.

On Saturday, March 9, 2024 at 9:46:57 PM UTC-5 Félix wrote:

> I'm still working on this! Thanks for your patience :) 
>   
> (The latest LeoJS 0.2.12 release is the result of trying to capture many 
> features for that video tutorial, and realizing that they needed a bit of 
> polishing!)
>
> Félix
>
> On Wednesday, January 3, 2024 at 7:18:33 PM UTC-5 tbp1...@gmail.com wrote:
>
>> Yay!
>>
>> On Wednesday, January 3, 2024 at 7:12:26 PM UTC-5 Félix wrote:
>>
>>> I'm going to take a coding break by doing a tutorial exactly about that!
>>>
>>> On Wednesday, January 3, 2024 at 4:56:12 PM UTC-5 tbp1...@gmail.com 
>>> wrote:
>>>
 Now That leoJS is getting into pretty good shape - and Felix must need 
 a month's vacation! - I am thinking about plugins and scripts that can do 
 things that are easy to do from within Leo. Specifically, scripts that can 
 read and write files from the file system, and files that do the 
 equivalent 
 of subprocess.run() or subprocess.Popen().  In addition (or maybe it's in 
 the same group), scripts that launch a web browser on a specified file.

 Is there somewhere we can read up on these things, that is, how a leoJS 
 script can do them in javascript/typescript?

>>>

-- 
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/1d5176ef-3bc9-4175-97e5-7bc8f5606da2n%40googlegroups.com.


Re: ✨LeoJS beta 0.2.12 Released!

2024-03-09 Thread Thomas Passin
A great achievement, Felix!  So much work, too!

I see this update isn't in the marketplace for vscodium yet.  Coming soon, 
I imagine?  It updated successfully in VScode.

On Saturday, March 9, 2024 at 9:40:56 PM UTC-5 Félix wrote:

> 📣Introducing LeoJS Beta 0.2.12
> Félix here, ecstatic to unveil the latest milestone in our coding 
> odyssey—LeoJS 
> Beta 0.2.12 
> !
> [image: leojs-alien2.png]
> 🌟What's New in 0.2.12?
>
>- *Enhanced Help Commands:* I've revamped the help commands, 
>transitioning from markdown preview panes to more interactive HTML 
>webviews, ensuring you get the guidance you need, right when you need it.
>- *VSCode Api access for scripts: *A pivotal update (note: it's a 
>breaking change) - the VSCode instance is now accessible via g.vscode 
>instead of the previous g.app.vscode, simplifying your interaction with 
> the 
>editor.
>- *More scripting helpers: *Dive deeper with more external libraries 
>like SQL, pako, showdown, and JSZip now at your fingertips through the 
>global 'g' object. Plus, essential OS path-related constants such as 
>extensionContext, extensionUri, and workspaceUri are also readily 
>accessible to help you read & write to files easily.
>- *Feature-Rich Commands & Fixes:* Discover the new 
>'show-recent-files' command, along with the improved Find-Panel, and 
>explore fixes and additions across the board, including 'open-aside' 
>command enhancements and a new, intuitive UNL status bar button.
>- *Polished Experience:* I've removed the 'font-size & zoom' related 
>settings in favor of VSCode's new zoom settings API, added XML language 
>colorization support, and introduced UNL relative path support for a more 
>refined experience.
>- *Improved UI behavior and fixes: *@buttons panel now refreshes 
>properly after a 'revert-to-saved'command, the 'Goto' panel's navigation 
>stability issues are resolved, the startup process properly ask for a 
> LeoID 
>if none exist, among many other bugfixes.
>
> 🔧Your Feedback Fuels Improvement!
>
> Your input is invaluable. Don't hesitate to share your thoughts, report 
> issues, or to suggest enhancements on the 'issues' section 
>  of the repository.
>
> 🚀Join the Journey!
>
> Ready to try out LeoJS Beta 0.2.12 
> ? Dive 
> in now and discover how this latest version can transform your programming 
> workflow. (also available on open-vsx.org 
> )
>
> Or to try online in VSCode for the web, simply visit* a GitHub repository 
> that you own*, press '.' (period) to switch to the web editor 
> ,
>  
> install LeoJS from the extension panel, and you're set! 
>
> Here's to many more code adventures together!
>
> Happy coding, 
> Félix
> [image: explorer-futurist.jpg]
>
>

-- 
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/b2c4cef6-8ff9-490b-96b3-550802527084n%40googlegroups.com.


Re: A Script To Insert An Image

2024-03-09 Thread Thomas Passin
Yup, Terry Brown has already done most of it for us in the screen_capture 
plugin.  Here's the docstring:

"""
screen_capture.py
=

Capture screen shots - single frames are useful.  The
`Recorder` class can also capture frames continuously but that's not
really useful, it doesn't handle audio or video encoding, and can't maintain
a 30 fps frame rate.  The code for doing so is not hooked up in this plugin.

Screen captures are saved in ``~/.leo/screen_captures`` with
timestamps in the filenames.

Commands


``screen-capture-5sec``
  Wait five seconds, then take a screen shot.
``screen-capture-now``
  Take a screen shot.

Settings


``@string screen-capture-save-path``
  Save screen shots here instead of ~/.leo/screen_captures

Terry Brown, terry_n_br...@yahoo.com, Fri Apr 19 16:33:45 2013
"""

The code may need to be updated for Qt6, since it was originally written 
for Qt4 in 2013. Or just the key capture part of the code could be used, 
since the entire plugin is more complicated than necessary.  Also it 
doesn't capture a part of the screen as best as I can see, only the whole.
On Saturday, March 9, 2024 at 3:27:30 PM UTC-5 jkn wrote:

> I would expect that to be somewhat os-dependant (I mostly use Linux), but 
> perhaps it is there. I will try to take a look for clipboard-paste 
> functions.
>
>
>
> On Saturday, March 9, 2024 at 8:22:44 PM UTC tbp1...@gmail.com wrote:
>
>> I seem to remember that somewhere in the code base, Leo code to capture 
>> the screen has already been worked out.  If that's the case we're in clover.
>>
>> On Saturday, March 9, 2024 at 3:09:24 PM UTC-5 jkn wrote:
>>
>>> The way I have been using the Obsidian feature is to paste image bytes 
>>> (eg. from a screen region capture). So Obsidian saves a file:
>>>
>>> /path/to/attachments/ 
>>>
>>> Pasted image 20240228230106.png
>>>
>>>
>>> Where /path/to/attachments is an Obsidian setting, and the name of the 
>>> file is clearly a timestamp.
>>>
>>>
>>> Obsidian only uses markdown, so it inserts 
>>>
>>>
>>> ![[Pasted image 20240228230106.png]]
>>>
>>>
>>> into the 'node being edited'
>>>
>>>
>>> I think you can also drag and drop files into a 'node'.
>>>
>>>
>>> There would clearly have to be some work to make this generally useful 
>>> in a Leo context...
>>>
>>>
>>>
>>> On Saturday, March 9, 2024 at 7:35:15 PM UTC tbp1...@gmail.com wrote:
>>>
 Shouldn't be hard.  What would be on the clipboard?  Image bytes?  Or 
 an image filename?  I often select an image in a file manager window, copy 
 it to an "images" subdirectory of the current outline, then write the 
 embedding code into and "images" child node.  That would be easy to write 
 a 
 script for.

 On Saturday, March 9, 2024 at 2:14:41 PM UTC-5 jkn wrote:

> This looks interesting and useful, thanks Thomas. I confess I 
> rarely/never use Leo with images, I really should experiment a little.
>
> Recently I have been using Obsidian as a note-taking app (Joplin is 
> similar). Neither are as capable as Leo, in many ways, but they have 
> their 
> niceties.
> One that is handy when note-taking is the ability to paste *from the 
> clipboard*. You can setup an area (directory0 in an Obsidian 'vault' - 
> then 
> 'paste from clipboard' will
> (a) create a unique filename within the image directory, and put the 
> clipboard contents in there as eg. a .png file
> (b) add a (markdown) reference to the new image in the 'note' that you 
> are in.
>
> It'd be nice to have something similar in Leo... ;-)
>
> Regards, Jon N
>
> On Saturday, March 9, 2024 at 7:04:19 PM UTC tbp1...@gmail.com wrote:
>
>> We can't directly insert an image into a standard Leo node because 
>> they are text-only.  I find this very annoying sometimes, especially 
>> when I 
>> am writing a note and want to include an image.  
>>
>> But we can do the next best thing - insert an ReStructuredText (RsT) 
>> instruction to display an image so that we can view it with the 
>> viewrendered3 plugin (VR3). The instruction is short and easy, but it's 
>> still annoying to type and I usually forget the exact details. I have a 
>> button that toggles VR3 on and off so that it's easy to view an embedded 
>> image once the RsT instruction is there. An embedding command would make 
>> embedding with Leo as easy as embedding an image in a word processor.  
>>  Aha, this is Leo, let's write a script!
>>
>> Here is a script that pops up a file dialog and inserts a relative 
>> path to the chosen file.  There are several small variations which I 
>> discuss after the code.
>>
>> """Insert RsT code at cursor to display an image.
>>
>> The path to the image file will come from a file dialog.
>> This action is undoable.
>> """
>> PATH = g.app.gui.runOpenFileDialog(c,
>> title="Im

Re: A Script To Insert An Image

2024-03-09 Thread Thomas Passin
I seem to remember that somewhere in the code base, Leo code to capture the 
screen has already been worked out.  If that's the case we're in clover.

On Saturday, March 9, 2024 at 3:09:24 PM UTC-5 jkn wrote:

> The way I have been using the Obsidian feature is to paste image bytes 
> (eg. from a screen region capture). So Obsidian saves a file:
>
> /path/to/attachments/ 
>
> Pasted image 20240228230106.png
>
>
> Where /path/to/attachments is an Obsidian setting, and the name of the 
> file is clearly a timestamp.
>
>
> Obsidian only uses markdown, so it inserts 
>
>
> ![[Pasted image 20240228230106.png]]
>
>
> into the 'node being edited'
>
>
> I think you can also drag and drop files into a 'node'.
>
>
> There would clearly have to be some work to make this generally useful in 
> a Leo context...
>
>
>
> On Saturday, March 9, 2024 at 7:35:15 PM UTC tbp1...@gmail.com wrote:
>
>> Shouldn't be hard.  What would be on the clipboard?  Image bytes?  Or an 
>> image filename?  I often select an image in a file manager window, copy it 
>> to an "images" subdirectory of the current outline, then write the 
>> embedding code into and "images" child node.  That would be easy to write a 
>> script for.
>>
>> On Saturday, March 9, 2024 at 2:14:41 PM UTC-5 jkn wrote:
>>
>>> This looks interesting and useful, thanks Thomas. I confess I 
>>> rarely/never use Leo with images, I really should experiment a little.
>>>
>>> Recently I have been using Obsidian as a note-taking app (Joplin is 
>>> similar). Neither are as capable as Leo, in many ways, but they have their 
>>> niceties.
>>> One that is handy when note-taking is the ability to paste *from the 
>>> clipboard*. You can setup an area (directory0 in an Obsidian 'vault' - then 
>>> 'paste from clipboard' will
>>> (a) create a unique filename within the image directory, and put the 
>>> clipboard contents in there as eg. a .png file
>>> (b) add a (markdown) reference to the new image in the 'note' that you 
>>> are in.
>>>
>>> It'd be nice to have something similar in Leo... ;-)
>>>
>>> Regards, Jon N
>>>
>>> On Saturday, March 9, 2024 at 7:04:19 PM UTC tbp1...@gmail.com wrote:
>>>
 We can't directly insert an image into a standard Leo node because they 
 are text-only.  I find this very annoying sometimes, especially when I am 
 writing a note and want to include an image.  

 But we can do the next best thing - insert an ReStructuredText (RsT) 
 instruction to display an image so that we can view it with the 
 viewrendered3 plugin (VR3). The instruction is short and easy, but it's 
 still annoying to type and I usually forget the exact details. I have a 
 button that toggles VR3 on and off so that it's easy to view an embedded 
 image once the RsT instruction is there. An embedding command would make 
 embedding with Leo as easy as embedding an image in a word processor.  
  Aha, this is Leo, let's write a script!

 Here is a script that pops up a file dialog and inserts a relative path 
 to the chosen file.  There are several small variations which I discuss 
 after the code.

 """Insert RsT code at cursor to display an image.

 The path to the image file will come from a file dialog.
 This action is undoable.
 """
 PATH = g.app.gui.runOpenFileDialog(c,
 title="Import File",
 filetypes=[("All files", "*"),],
 defaultextension=".*",
 multiple=False)

 if PATH:
 from os.path import relpath
 PATH = relpath(PATH)
 PATH = PATH.replace('\\', '/').replace('"', '').replace("'", '')
 IMAGE_TEMPLATE = f'''

 .. figure:: {PATH}
 :scale: 50%

 '''
 w = c.frame.body.wrapper
 p = c.p
 s = p.b
 u = c.undoer

 start, _ = w.getSelectionRange()

 undoType = 'insert-rst-image-code'
 undoData = u.beforeChangeNodeContents(p)

 head, tail = s[:start], s[start:]
 p.b = head + IMAGE_TEMPLATE + tail

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

 Variations:
 1.  If you want an absolute path instead of a relative path, delete the 
 lines
 from os.path import relpath
 PATH = relpath(PATH)
 with

 2. If you  want to get the path from the clipboard instead of a file 
 dialog, replace the lines

 PATH = g.app.gui.runOpenFileDialog(c,
 title="Import File",
 filetypes=[("All files", "*"),],
 defaultextension=".*",
 multiple=False)

 with the line 

 PATH = g.app.gui.getTextFromClipboard()

 3. If you want the embedded image to be full width instead of 50%, 
 delete the line

 :scale: 50%

 4. You can make this work with Markdown or Asciidoc by using their 
 embedding instruction in the TEMPLATE instead of 

Re: A Script To Insert An Image

2024-03-09 Thread Thomas Passin
Shouldn't be hard.  What would be on the clipboard?  Image bytes?  Or an 
image filename?  I often select an image in a file manager window, copy it 
to an "images" subdirectory of the current outline, then write the 
embedding code into and "images" child node.  That would be easy to write a 
script for.

On Saturday, March 9, 2024 at 2:14:41 PM UTC-5 jkn wrote:

> This looks interesting and useful, thanks Thomas. I confess I rarely/never 
> use Leo with images, I really should experiment a little.
>
> Recently I have been using Obsidian as a note-taking app (Joplin is 
> similar). Neither are as capable as Leo, in many ways, but they have their 
> niceties.
> One that is handy when note-taking is the ability to paste *from the 
> clipboard*. You can setup an area (directory0 in an Obsidian 'vault' - then 
> 'paste from clipboard' will
> (a) create a unique filename within the image directory, and put the 
> clipboard contents in there as eg. a .png file
> (b) add a (markdown) reference to the new image in the 'note' that you are 
> in.
>
> It'd be nice to have something similar in Leo... ;-)
>
> Regards, Jon N
>
> On Saturday, March 9, 2024 at 7:04:19 PM UTC tbp1...@gmail.com wrote:
>
>> We can't directly insert an image into a standard Leo node because they 
>> are text-only.  I find this very annoying sometimes, especially when I am 
>> writing a note and want to include an image.  
>>
>> But we can do the next best thing - insert an ReStructuredText (RsT) 
>> instruction to display an image so that we can view it with the 
>> viewrendered3 plugin (VR3). The instruction is short and easy, but it's 
>> still annoying to type and I usually forget the exact details. I have a 
>> button that toggles VR3 on and off so that it's easy to view an embedded 
>> image once the RsT instruction is there. An embedding command would make 
>> embedding with Leo as easy as embedding an image in a word processor.  
>>  Aha, this is Leo, let's write a script!
>>
>> Here is a script that pops up a file dialog and inserts a relative path 
>> to the chosen file.  There are several small variations which I discuss 
>> after the code.
>>
>> """Insert RsT code at cursor to display an image.
>>
>> The path to the image file will come from a file dialog.
>> This action is undoable.
>> """
>> PATH = g.app.gui.runOpenFileDialog(c,
>> title="Import File",
>> filetypes=[("All files", "*"),],
>> defaultextension=".*",
>> multiple=False)
>>
>> if PATH:
>> from os.path import relpath
>> PATH = relpath(PATH)
>> PATH = PATH.replace('\\', '/').replace('"', '').replace("'", '')
>> IMAGE_TEMPLATE = f'''
>>
>> .. figure:: {PATH}
>> :scale: 50%
>>
>> '''
>> w = c.frame.body.wrapper
>> p = c.p
>> s = p.b
>> u = c.undoer
>>
>> start, _ = w.getSelectionRange()
>>
>> undoType = 'insert-rst-image-code'
>> undoData = u.beforeChangeNodeContents(p)
>>
>> head, tail = s[:start], s[start:]
>> p.b = head + IMAGE_TEMPLATE + tail
>>
>> c.setChanged()
>> p.setDirty()
>> u.afterChangeNodeContents(p, undoType, undoData)
>> c.redraw()
>>
>> Variations:
>> 1.  If you want an absolute path instead of a relative path, delete the 
>> lines
>> from os.path import relpath
>> PATH = relpath(PATH)
>> with
>>
>> 2. If you  want to get the path from the clipboard instead of a file 
>> dialog, replace the lines
>>
>> PATH = g.app.gui.runOpenFileDialog(c,
>> title="Import File",
>> filetypes=[("All files", "*"),],
>> defaultextension=".*",
>> multiple=False)
>>
>> with the line 
>>
>> PATH = g.app.gui.getTextFromClipboard()
>>
>> 3. If you want the embedded image to be full width instead of 50%, delete 
>> the line
>>
>> :scale: 50%
>>
>> 4. You can make this work with Markdown or Asciidoc by using their 
>> embedding instruction in the TEMPLATE instead of the RsT one.
>>
>> I have added the command to my own local menu.  VR3 can open in a tab in 
>> the log pane; the command for toggling in a tab is *vr3-toggle-tab. * I 
>> usually like opening it in the log pane instead of in its own separate pane.
>>
>> If you would like to create a local menu of your own and don't know how, 
>> it's easy.  Just ask and I'll show what to add to myLeoSettings,leo.
>>
>

-- 
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/0aecddc9-6a24-44f7-8a75-1520ed20436bn%40googlegroups.com.


A Script To Insert An Image

2024-03-09 Thread Thomas Passin
We can't directly insert an image into a standard Leo node because they are 
text-only.  I find this very annoying sometimes, especially when I am 
writing a note and want to include an image.  

But we can do the next best thing - insert an ReStructuredText (RsT) 
instruction to display an image so that we can view it with the 
viewrendered3 plugin (VR3). The instruction is short and easy, but it's 
still annoying to type and I usually forget the exact details. I have a 
button that toggles VR3 on and off so that it's easy to view an embedded 
image once the RsT instruction is there. An embedding command would make 
embedding with Leo as easy as embedding an image in a word processor.  
 Aha, this is Leo, let's write a script!

Here is a script that pops up a file dialog and inserts a relative path to 
the chosen file.  There are several small variations which I discuss after 
the code.

"""Insert RsT code at cursor to display an image.

The path to the image file will come from a file dialog.
This action is undoable.
"""
PATH = g.app.gui.runOpenFileDialog(c,
title="Import File",
filetypes=[("All files", "*"),],
defaultextension=".*",
multiple=False)

if PATH:
from os.path import relpath
PATH = relpath(PATH)
PATH = PATH.replace('\\', '/').replace('"', '').replace("'", '')
IMAGE_TEMPLATE = f'''

.. figure:: {PATH}
:scale: 50%

'''
w = c.frame.body.wrapper
p = c.p
s = p.b
u = c.undoer

start, _ = w.getSelectionRange()

undoType = 'insert-rst-image-code'
undoData = u.beforeChangeNodeContents(p)

head, tail = s[:start], s[start:]
p.b = head + IMAGE_TEMPLATE + tail

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

Variations:
1.  If you want an absolute path instead of a relative path, delete the 
lines
from os.path import relpath
PATH = relpath(PATH)
with

2. If you  want to get the path from the clipboard instead of a file 
dialog, replace the lines

PATH = g.app.gui.runOpenFileDialog(c,
title="Import File",
filetypes=[("All files", "*"),],
defaultextension=".*",
multiple=False)

with the line 

PATH = g.app.gui.getTextFromClipboard()

3. If you want the embedded image to be full width instead of 50%, delete 
the line

:scale: 50%

4. You can make this work with Markdown or Asciidoc by using their 
embedding instruction in the TEMPLATE instead of the RsT one.

I have added the command to my own local menu.  VR3 can open in a tab in 
the log pane; the command for toggling in a tab is *vr3-toggle-tab. * I 
usually like opening it in the log pane instead of in its own separate pane.

If you would like to create a local menu of your own and don't know how, 
it's easy.  Just ask and I'll show what to add to myLeoSettings,leo.

-- 
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/e5055411-b63b-4c0e-b36b-82859c935488n%40googlegroups.com.


Re: pathlib.Path.is_file vs os.path.isfile difference

2024-03-08 Thread Thomas Passin via Python-list

On 3/8/2024 5:14 PM, Albert-Jan Roskam wrote:



On Mar 8, 2024 19:35, Thomas Passin via Python-list 
 wrote:


On 3/8/2024 1:03 PM, Albert-Jan Roskam via Python-list wrote:
 > Hi,
 > I was replacing some os.path stuff with Pathlib and I
discovered this:
 > Path(256 * "x").is_file()  # OSError
 > os.path.isfile(256 * "x")  # bool
 > Is this intended? Does pathlib try to resemble os.path as
closely as
 > possible?

You must have an very old version of Python.  I'm running 3.12.2 and it
returns False.  Either that or that path name exists and throws some
kind of unexpected exception.





Hi, I tested this with Python 3.8. Good to know that this was fixed!


We just learned a few posts back that it might be specific to Linux; I 
ran it on Windows.


--
https://mail.python.org/mailman/listinfo/python-list


Re: pathlib.Path.is_file vs os.path.isfile difference

2024-03-08 Thread Thomas Passin via Python-list

On 3/8/2024 2:21 PM, Grant Edwards via Python-list wrote:

On 2024-03-08, Thomas Passin via Python-list  wrote:

On 3/8/2024 1:03 PM, Albert-Jan Roskam via Python-list wrote:

 Hi,
 I was replacing some os.path stuff with Pathlib and I discovered this:
 Path(256 * "x").is_file()  # OSError
 os.path.isfile(256 * "x")  # bool
 Is this intended? Does pathlib try to resemble os.path as closely as
 possible?


You must have an very old version of Python.  I'm running 3.12.2 and it
returns False.


It throws OSError with Python 3.11.8 on Linux.


Sorry, I should have said on Windows.



$ python
Python 3.11.8 (main, Feb 23 2024, 16:11:29) [GCC 13.2.1 20240113] on linux
Type "help", "copyright", "credits" or "license" for more information.

import pathlib
pathlib.Path(256 * "x").is_file()

Traceback (most recent call last):
   File "", line 1, in 
   File "/usr/lib/python3.11/pathlib.py", line 1267, in is_file
 return S_ISREG(self.stat().st_mode)
^^^
   File "/usr/lib/python3.11/pathlib.py", line 1013, in stat
 return os.stat(self, follow_symlinks=follow_symlinks)
^^
OSError: [Errno 36] File name too long: 
''


import os
os.path.isfile(256 * "x")

False



--
https://mail.python.org/mailman/listinfo/python-list


Re: pathlib.Path.is_file vs os.path.isfile difference

2024-03-08 Thread Thomas Passin via Python-list

On 3/8/2024 1:03 PM, Albert-Jan Roskam via Python-list wrote:

Hi,
I was replacing some os.path stuff with Pathlib and I discovered this:
Path(256 * "x").is_file()  # OSError
os.path.isfile(256 * "x")  # bool
Is this intended? Does pathlib try to resemble os.path as closely as
possible?


You must have an very old version of Python.  I'm running 3.12.2 and it 
returns False.  Either that or that path name exists and throws some 
kind of unexpected exception.


The Python docs say

"Return True if the path points to a regular file (or a symbolic link 
pointing to a regular file), False if it points to another kind of file.


False is also returned if the path doesn’t exist or is a broken symlink; 
other errors (such as permission errors) are propagated"

--
https://mail.python.org/mailman/listinfo/python-list


Re: Variable scope inside and outside functions - global statement being overridden by assignation unless preceded by reference

2024-03-06 Thread Thomas Passin via Python-list

On 3/6/2024 7:55 AM, Jacob Kruger via Python-list wrote:
Ok, simpler version - all the code in a simpler test file, and working 
with two separate variables to explain exactly what am talking about:


# start code

from datetime import datetime, timezone, timedelta

from copy import copy


# initialise original values

dt_expiry = datetime.strptime("1970-01-01 00:00", "%Y-%m-%d 
%H:%M").replace(tzinfo=timezone.utc)


l_test = [1, 2, 3]


def do_it():
     global dt_expiry, l_test # asked python to refer to global 
variables for both


     # assign new value immediately

     dt_expiry = datetime.now()+timedelta(minutes=5)
     print(dt_expiry.strftime("%Y-%m-%d %H:%M")) # just to show new 
value has been assigned

     # grab copy of list for re-use of items
     l_temp = copy(l_test)
     # following line means l_test will later on retain value in global 
scope because it was manipulated inside function instead of just 
assigned new value

     l_test.clear()
     # replace original set of values
     for i in l_temp: l_test.append(i)
     # add new item
     l_test.append(99)
# end of do_it function

# end code


If you import the contents of that file into the python interpreter, 
dt_expiry will start off as "1970-01-01 00:00", and, if you execute 
do_it function, it will print out the new value assigned to the 
dt_expiry variable inside that function, but if you then again check the 
value of the dt_expiry variable afterwards, it's reverted to the 1970... 
value?


Not when I run your code. With a little annotation added to the print 
statements I get (I added the import statements to make it run, and I 
used the same date-time formatting for all three print statements):


List before: [1, 2, 3]
start: 1970-01-01 00:00
inside after reassignment: 2024-03-06 08:57
outside after: 2024-03-06 08:57
List after: [1, 2, 3, 99]

As an aside, you have gone to some trouble to copy, clear, and 
reconstruct l_test.  It would be simpler like this (and you wouldn't 
have to import the "copy" library):


l_temp = l_test[:]
l_test = []

Instead of those lines and then this:

for i in l_temp: l_test.append(i)

you could achieve the same thing with this single statement:

l_test = l_test[:]


If I take out the line that removes values from l_test # l_test.clear() 
# before appending new value to it, then it will also not retain it's 
new/additional child items after the function exits, and will just 
revert back to [1, 2, 3] each and every time.



In other words, with some of the variable/object types, if you use a 
function that manipulates the contents of a variable, before then 
re-assigning it a new value, it seems like it might then actually 
update/manipulate the global variable, but, either just calling purely 
content retrieval functions against said objects, or assigning them new 
values from scratch seems to then ignore the global scope specified in 
the first line inside the function?



Hope this makes more sense


Jacob Kruger
+2782 413 4791
"Resistance is futile!...Acceptance is versatile..."


On 2024/03/05 20:23, dn via Python-list wrote:

Jacob,

Please reduce the problem to a small code-set which reproduces the 
problem. If we can reproduce same, then that tells us something. At 
the very least, we can experiment without having to expend amounts of 
time in a (likely faulty) bid to reproduce the same environment.


Also, code is the ultimate description!


Perhaps start with a small experiment:

- after l_servers is created, print its id()
- after the global statement, print its id()
- after the clear/reassignment, print its id()

Is Python always working with the same list?
Please advise...


On 6/03/24 07:13, Jacob Kruger via Python-list wrote:

Hi there


Working with python 3.11, and, issue that confused me for a little 
while, trying to figure out what was occurring - unless am completely 
confused, or missing something - was that, for example, when having 
pre-defined a variable, and then included it in the global statement 
inside a function, that function was still referring to a completely 
local instance, without manipulating outside variable object at all 
unless I first executed a form of referral to it, before then 
possibly assigning a new value to it.



Now, this does not seem to occur consistently if, for example, I just 
run bare-bones test code inside the python interpreter, but 
consistently occurs inside my actual testing script.



Basically, in a file with python code in that am using for a form of
testing at the moment, at the top of the file, under all the import
statements, I initiate the existence of a list variable to make use of

later:


# code snippet

l_servers = []

# end of first code snippet


Then, lower down, inside a couple of different functions, the first line
inside the functions includes the following:
# code snippet
 global l_servers
# end code snippet

That should, in theory, mean that if I assign a value to that variable
inside one of t

Re: Variable scope inside and outside functions - global statement being overridden by assignation unless preceded by reference

2024-03-06 Thread Thomas Passin via Python-list

On 3/6/2024 5:59 AM, Alan Gauld via Python-list wrote:

On 05/03/2024 22:46, Grant Edwards via Python-list wrote:

Unfortunately (presumably thanks to SEO) the enshittification of
Google has reached the point where searching for info on things like
Python name scope, the first page of links are to worthless sites like
geeksforgeeks.

And not just Google, I just tried bing, yahoo and duckduckgo
and they are all the same. Not a one listed anything from
python.org on the first page... In fact it didn't even appear
in the first 100 listings, although wikipedia did manage an
entry, eventually.


I don't know ... I just searched for "python local vs global variables" 
and a python.org page on it was the second hit. I usually use StartPage 
- who knows where they aggregate from - but the same search on Google 
and Bing also popped up the python.org link as the second hit.  As usual 
Bing was a nasty experience, though.


Still, if your search phrase isn't as well focused as that or you are 
less lucky, for sure you'll get all sorts of junk.


--
https://mail.python.org/mailman/listinfo/python-list


Re: FYI: Simplified installation instructions

2024-03-03 Thread Thomas Passin
I hit the publish button too soon, sorry!  Here's my directory structure 
again:

gf4-docs.leo
docs
sphinx
images

My source rst files live in the *sphinx* directory and they can reference 
graphics in the *images* directory.  The generated HTML files are in the 
*docs* directory.

The node with the script that runs the above code is also in the same 
outline, at the same level and above the entire document tree.  It's 
headline reads @button Build HTML .  You could have another similar script 
to create a pdf file - if rst2pdf is working right these days, anyway - and 
you can have one button for each script.

I've developed this way of generating Sphinx documentation over many years 
and iterations and it's the one I like best so far.  Give it  try and see 
it it works for you!
On Sunday, March 3, 2024 at 4:23:36 PM UTC-5 Thomas Passin wrote:

> I don't know about a "gentle" introduction, but VR3 has an extensive 
> docstring you can read by means of the Plugins menu.
>
> I use Sphinx a lot, and normally I don't even create a Sphinx 
> configuration file.  I find I can do enough configuration for my needs with 
> command-line parameters, which I supply with a little script that I can 
> attach to a button.  The script would be specialized for a particular 
> outline so the button won't show up for all outlines.
>
> Here is one of the scripts I use.  It seems more complicated than it is, 
> but it lets you start from any node in the outline so you don't have to 
> remember to navigate to the top of the @rst tree.
>
> @language python
> from sys import executable
> import subprocess
> import os
>
> target = None
> HEAD = "GF4 User's Guide"
> p0 = c.p
> for p in c.all_unique_positions():
> if p.h.startswith(HEAD):
> target = p
> c.selectPosition(target)
> break
> if target:
> c.k.simulateCommand('rst3')
>
> # Thw rst3 command writes to correct (@path sphinx) directory
> # but Sphinx will look in current directory, which may
> # not be the same.  So -
> # if we start from a selected node outside the
> # @path sphinx tree, temporarily cd to the docs directory.
> cwd = os.getcwd()
> if not cwd.endswith('sphinx'):
> temp_cwd = os.path.join(cwd, 'sphinx')
> os.chdir(temp_cwd)
>
> # Other likely themes: 
> #'-D', 'html_theme=sphinx_book_theme',
> #'-D', 'html_theme=bizstyle',
>
> cmd = [executable, '-m', 'sphinx', '-C',
> '-b', 'html',
> '-D', "master_doc=GF4_Users_Guide",
> '-D', 'source_suffix=.rst',
> '-D', 'html_theme=pyramid',
> '-D', 'project=GF4',
> '-D', 'extensions=sphinx.ext.autosectionlabel',
> '-D', 'copyright=Thomas B. Passin 2022',
> '-D', "html_theme_options.sidebarwidth=20em",
>
> # sourcedir, outputdir:
> r'.', r'..\docs']
>
> subprocess.call(cmd)
> else:
> g.es('Cannot find the @rst tree to process', color = 'red')
>
> The key here is providing Sphinx's command line arguments.  That happens 
> in the block that starts
>
> cmd = [executable, '-m', 'sphinx', '-C',
>
> There are command line parameters for many of the things that would be in 
> a config file.  The trickiest part is getting the source and build 
> directories right.  They will be relative to the outline's directory if you 
> use relative paths.
>
> For this Sphinx document, the entire rst document is a child of a node 
> name @path sphinx. This points to a subdirectory *sphinx* just below the 
> outline's directory. The directory structure looks like this:
>
> gf4-docs.leo
> docs
> sphinx
> images
>
>
>
> On Sunday, March 3, 2024 at 2:37:33 PM UTC-5 Geoff Evans wrote:
>
> Obvious question: if I use both Anaconda *and* MacOS (Ventura), which 
> part of the Installation instructions supersedes the other?  Is Homebrew 
> necessary?
> I've still not succeeded with pyqt6.
>
> Unrelated question:
> The traffic on this site is, quite understandably, dominated by the latest 
> exciting innovations.  So that I'm not sure where to find beginnings any 
> more.  
> Where do I go to find a gentle introduction to, say, ViewRendered or 
> LeoJS: the bit that tells me what might be the payoff if I jump into the 
> details of them?
> [Though I probably won't jump in: a nice editor-outliner with clones and a 
> literate approach will let me organize my science nicely, alongside jupyter 
> notebooks that do the details.
> Maybe the main thing I need to learn, for sharing with colleagues, is 
> make-sphinx?]
>
>

-- 
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/f18e5244-c4f4-440d-9f76-5877df6bee73n%40googlegroups.com.


Re: FYI: Simplified installation instructions

2024-03-03 Thread Thomas Passin
I don't know about a "gentle" introduction, but VR3 has an extensive 
docstring you can read by means of the Plugins menu.

I use Sphinx a lot, and normally I don't even create a Sphinx configuration 
file.  I find I can do enough configuration for my needs with command-line 
parameters, which I supply with a little script that I can attach to a 
button.  The script would be specialized for a particular outline so the 
button won't show up for all outlines.

Here is one of the scripts I use.  It seems more complicated than it is, 
but it lets you start from any node in the outline so you don't have to 
remember to navigate to the top of the @rst tree.

@language python
from sys import executable
import subprocess
import os

target = None
HEAD = "GF4 User's Guide"
p0 = c.p
for p in c.all_unique_positions():
if p.h.startswith(HEAD):
target = p
c.selectPosition(target)
break
if target:
c.k.simulateCommand('rst3')

# Thw rst3 command writes to correct (@path sphinx) directory
# but Sphinx will look in current directory, which may
# not be the same.  So -
# if we start from a selected node outside the
# @path sphinx tree, temporarily cd to the docs directory.
cwd = os.getcwd()
if not cwd.endswith('sphinx'):
temp_cwd = os.path.join(cwd, 'sphinx')
os.chdir(temp_cwd)

# Other likely themes: 
#'-D', 'html_theme=sphinx_book_theme',
#'-D', 'html_theme=bizstyle',

cmd = [executable, '-m', 'sphinx', '-C',
'-b', 'html',
'-D', "master_doc=GF4_Users_Guide",
'-D', 'source_suffix=.rst',
'-D', 'html_theme=pyramid',
'-D', 'project=GF4',
'-D', 'extensions=sphinx.ext.autosectionlabel',
'-D', 'copyright=Thomas B. Passin 2022',
'-D', "html_theme_options.sidebarwidth=20em",

# sourcedir, outputdir:
r'.', r'..\docs']

subprocess.call(cmd)
else:
g.es('Cannot find the @rst tree to process', color = 'red')

The key here is providing Sphinx's command line arguments.  That happens in 
the block that starts

cmd = [executable, '-m', 'sphinx', '-C',

There are command line parameters for many of the things that would be in a 
config file.  The trickiest part is getting the source and build 
directories right.  They will be relative to the outline's directory if you 
use relative paths.

For this Sphinx document, the entire rst document is a child of a node name 
@path 
sphinx. This points to a subdirectory *sphinx* just below the outline's 
directory. The directory structure looks like this:

gf4-docs.leo
docs
sphinx
images



On Sunday, March 3, 2024 at 2:37:33 PM UTC-5 Geoff Evans wrote:

Obvious question: if I use both Anaconda *and* MacOS (Ventura), which part 
of the Installation instructions supersedes the other?  Is Homebrew 
necessary?
I've still not succeeded with pyqt6.

Unrelated question:
The traffic on this site is, quite understandably, dominated by the latest 
exciting innovations.  So that I'm not sure where to find beginnings any 
more.  
Where do I go to find a gentle introduction to, say, ViewRendered or LeoJS: 
the bit that tells me what might be the payoff if I jump into the details 
of them?
[Though I probably won't jump in: a nice editor-outliner with clones and a 
literate approach will let me organize my science nicely, alongside jupyter 
notebooks that do the details.
Maybe the main thing I need to learn, for sharing with colleagues, is 
make-sphinx?]

-- 
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/d7a323c7-65e4-40b5-99d9-02fbd0da4ce8n%40googlegroups.com.


Re: .csv Importer Is Specialized For MindManager Export Files

2024-03-02 Thread Thomas Passin
Thanks for the code.  Can't get much simpler than that!  I have a more 
general interest, though - getting the import-file command and file 
drag-and-drop to work right.  The csv matter would be part of that.  It 
seems to me that Leo ought to have separate import commands for MindManager 
and ordinary tabular .csv  files, which will be easy enough to arrange.  If 
the MindManager import command were simply removed, it might bite someone 
who still uses it.

I think the drag-and-drop code and the import-file code should share as 
much code as possible.  After all, they do the same job except for how Leo 
gets the path of the file to be imported (and possibly the location to 
create the imported file - that could be debated).  Right now they are very 
different (and the drag-and-drop code is very complex compared with the 
import-file code).

On Saturday, March 2, 2024 at 6:51:54 AM UTC-5 Edward K. Ream wrote:

> On Fri, Mar 1, 2024 at 8:33 PM Thomas Passin  wrote:
>
>> The process for importing any file delegates .csv files to files exported 
>> the MindJet's MindManager program. Using it to import ordinary tabular .csv 
>> data produces unusable results on the samples I tried today.
>>
>
> Thanks for this report.
>
> This is a confusing topic. Some notes:
>
> - There is no separate importer for .csv files.
> - The import-file command delegates .csv files to the ic.importFreeMind 
> method, which in turn uses the MindMapImporter command.
>
> I would like to have Leo be able to import standard .csv files so I would 
>> like to start a discussion about the subject.
>>
>
> I agree this would be a good idea. It will probably be easy to do.
>
> It's too late to do this for Leo 6.7.8. In the meantime, you can write a 
> script that imports directly to text. Here is tested code:
>
> import os
> fn = 'README.md'
> path = g.os_path_finalize_join(g.app.loadDir, '..', '..', fn)
> contents = g.readFileIntoUnicodeString(path)
> last = c.lastTopLevel()
> p = last.insertAfter()
> p.h = fn
> c.importCommands.createOutline(p, ext='.txt', s=contents)
> c.redraw(p)
>
> HTH.
>
> Edward
>

-- 
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/87c9743b-0c6d-4bb7-b6a6-ba0dc73b8acen%40googlegroups.com.


.csv Importer Is Specialized For MindManager Export Files

2024-03-01 Thread Thomas Passin
The process for importing any file delegates .csv files to files exported 
the MindJet's MindManager program. Using it to import ordinary tabular .csv 
data produces unusable results on the samples I tried today.  I

Most .csv files contain tabular data and, in my view, should be imported as 
text files. If there is some internal identifying signature in 
MindManager's files, that could be used to distinguish them from ordinary 
.csv files.

I don't know if anyone is still importing MindManager files, or if Leo's 
import code still works for current versions of its export format.

I would like to have Leo be able to import standard .csv files so I would 
like to start a discussion about the subject.

-- 
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/0778fb9d-3cb3-4d21-baec-caab46967815n%40googlegroups.com.


Re: Discuss: Leo 6.7.8 will install only PyQt6

2024-03-01 Thread Thomas Passin

On Friday, March 1, 2024 at 5:33:34 AM UTC-5 Edward K. Ream wrote:

My question wasn't clear. I meant to ask whether potential errors 
concerning the missing xcb-cursor0 or libxcb-cursor0 libraries are a show 
stopper.

Imo, most linux users will know to run sudo apt install, so the missing 
library isn't a significant barrier to requiring PyQt6. A new FAQ entry 
might be all that is needed. Do you agree?


A year ago I might have said it was a show-stopper.  But now the error 
message from Ubuntu was clear enough that running its suggested command 
fixed the issue.  In years past I had to go to the internet and wade 
through a lot of useless posts to find the right command (I've saved it in 
my workbook to make it easier to find).  I do know that some non-technical 
people will read the error message and yet not know what to do, so I agree 
with a FAQ entry.

BTW, Ubuntu/XUbuntu is the only distro where I've encountered this issue so 
far.

-- 
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/3bde9179-e516-4f22-8c24-f7f6e8d92b34n%40googlegroups.com.


Re: Discuss: Leo 6.7.8 will install only PyQt6

2024-02-29 Thread Thomas Passin
It's looking better than say a year ago. I currently don't have any more 
distros to try.  Manjaro, which I listed above, is based on Arch-Linux, so 
probably any distro derived from Arch will have Qt6 too.  The big one I 
don't have and won't have is Red Hat.  It used to be that Fedora was 
basically Red Hat, but I don't think that's quite true any more.

Maybe someone else reading this will know more?

On Thursday, February 29, 2024 at 10:55:55 AM UTC-5 Edward K. Ream wrote:

> On Thu, Feb 29, 2024 at 9:46 AM Thomas Passin  wrote:
>
>> So far all the distros I have checked do now support pyqt6:
>>
>> Ubuntu/XUbuntu
>> Debian
>> OpenSuSE
>> Fedora
>> Manjaro
>> Mint
>>
>> These are all the distros I've got VMs for.
>>
>
> Thanks for the report. Do you think requirements.txt can specify only 
> PyQt6?
>
> Edward
>

-- 
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/431517b5-3493-4fb9-b433-70930a8c7a59n%40googlegroups.com.


Re: Discuss: Leo 6.7.8 will install only PyQt6

2024-02-29 Thread Thomas Passin
So far all the distros I have checked do now support pyqt6:

Ubuntu/XUbuntu
Debian
OpenSuSE
Fedora
Manjaro
Mint

These are all the distros I've got VMs for.



On Thursday, February 29, 2024 at 10:32:12 AM UTC-5 Edward K. Ream wrote:

> On Thu, Feb 29, 2024 at 9:25 AM Edward K. Ream  wrote:
>
> > It looks like requirements.txt must specify Qt5 on Linux.
>
> I've just changed the requirements as follows:
>
> # Use PyQt5 by default.
> "PyQt5>= 5.15; os_name != 'nt'",
> "PyQtWebEngine; ; os_name != 'nt'",
>
> # Use PyQt6 on Windows.
> "PyQt6>= 6.6; os_name == 'nt'",
> "PyQt6-WebEngine; os_name == 'nt'",
>
> So it looks like the dream of using only PyQt6 is still on hold.
>
> Please keep testing on all platforms.  Thanks.
>
> Edward
>

-- 
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/4a63ab03-4742-4663-b6b2-a48486a5f3fan%40googlegroups.com.


Heads Up - Malicious Git Forks

2024-02-29 Thread Thomas Passin
See This Slashdot story - GitHub Besieged By Millions of Malicious 
Repositories In Ongoing Attack 


-- 
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/7ce16a8d-4ab4-4031-933c-85d13dd6fb3bn%40googlegroups.com.


Re: Discuss: Leo 6.7.8 will install only PyQt6

2024-02-29 Thread Thomas Passin
I think that whether we can require pyqt6 should depend on whether it can 
be installed on a particular flavor of Linux.  That didn't used to be the 
case, but it may be now.  It is available on Ubuntu/XUbuntu, and probably 
on most Ubuntu-derived distros.

*However,* Leo won't run after installing on Ubuntu until you install 
something else.  The error message will be:

qt.qpa.plugin: From 6.5.0, xcb-cursor0 or libxcb-cursor0 is needed to load 
the Qt xcb platform plugin.
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even 
though it was found.

Here's the command needed to fix the issue:

sudo apt install libxcb-cursor0

I have some non-Ubuntu Linux VMs, and I'll check them for Qt6.
On Thursday, February 29, 2024 at 8:33:39 AM UTC-5 Edward K. Ream wrote:

> On Thu, Feb 29, 2024 at 7:20 AM Edward K. Ream  wrote:
>
>> Recent revs to the 6.7.8 and "devel" branches install only PyQt6 when 
>> installing either from PyPi or GitHub. That is, both of the following will 
>> install PyQt6:
>>
>>
>> pip install leo # From PyPi
>>
>> pip install -r requirements.txt # after git clone leo
>>
>
> I would prefer to migrate away from PyQt5, but this post 
> 
>  
> discusses alternative dependencies. For example, pyproject.toml could 
> contain.
>
> [project.optional-dependencies]gui = ["PyQt5"]
>
> In that case the user could install PyQt5 with:
>
> pip install leo[pyqt5]
>
> I would rather avoid this complication, but we'll see.
>
> Edward
>
>

-- 
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/ce58853c-dcc5-400d-aa79-35d5f8057bf5n%40googlegroups.com.


Re: Problem resizing a window and button placement

2024-02-26 Thread Thomas Passin via Python-list

On 2/26/2024 6:02 AM, Steve GS via Python-list wrote:

Although your code produces the value of Ww outside the function, I do not see 
how I can use the value of Ww unless I close the program.


The configuration event hasn't fired at the time you include the print 
statement in the handler's def block, and therefore the print function 
inside your handler hasn't invoked.  It won't be invoked until you 
resize the window.


There is no point to saving the width and height outside your 
on_configure() function, because outside that function you can't know if 
they have been changed.  There could even have been a race condition 
where you use one but the other changes before you get around to using 
it.  It's better just to ask tk for the values whenever you need them, 
as you do inside your handler.



import tkinter as tk

Ww = None  # What does this do? Why not Integer?
WwZ = None

# These could be integers, like 0, but that would not be the correct
# window sizes at that point. The window is either not constructed or it
# has some definite size that is not zero.


def on_configure(*args):
 global Ww
 global WwZ
 Ww = root.winfo_width()
 print("9  Ww Inside =<"+str(Ww)+">")  # works
 WwZ = Ww * 2
 print("11  WwZ Inside =<"+str(WwZ)+">")  # works
 return(Ww)  #Can I use this?
 
root = tk.Tk()

root.bind('',on_configure)
print("15  Ww Inside1 = <"+str(Ww)+">")
#Ww2 = int(Ww) * 2  # fails
print("17  WwZ Inside2 = <"+str(WwZ)+">")

root.mainloop()

Ww2 = int(Ww) * 2  #Works but only after the program stops
print("21  Ww Outside2 = <"+str(WwZ)+">")
# Can I have concentric loops?


SGA

-Original Message-
From: Alan Gauld 
Sent: Monday, February 26, 2024 4:04 AM
To: Steve GS ; python-list@python.org
Subject: Re: RE: Problem resizing a window and button placement

On 26/02/2024 07:56, Steve GS via Python-list wrote:


Then there is that discovery
element: Why is my original
idea not working? I still
cannot pass the value back
from the function.  What is
different about this function
that others would have given
me the value?


There is nothing different, see the code below.
print() is a function like any other.
In this case it is called after you close the window, ie after mainloop() exits.
But any other function called inside
mainloop - eg any other event handler can also access it.

For example, if you added a button:

def printW(): print("Button Ww = ", Ww)

bw = tk.Button(root, text="Print Width", command=printW)
bw.pack()

You would be able to print the value on demand.


import tkinter as tk

Ww = None

def on_configure(*args):
 global Ww
 Ww = root.winfo_width()
 print("Ww Inside =<"+str(Ww)+">")

root = tk.Tk()
root.bind('',on_configure)
root.mainloop()

print("Ww Outside = <"+str(Ww)+">")


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




--
https://mail.python.org/mailman/listinfo/python-list


Re: Problem resizing a window and button placement

2024-02-25 Thread Thomas Passin via Python-list

On 2/25/2024 4:19 PM, Steve GS via Python-list wrote:

SOLUTION FOUND!

The fix was to write the code that uses the width value and to place it into 
the function itself.
Kluge? Maybe but it works.


Right, just what I wrote earlier:

"have the function that responds to the resize event perform the action 
that you want"



Mischief Managed.


As for the most recent suggestion, it fails for me:

Traceback (most recent call last):
   File "F:/___zInsulin Code A 08-02-23/WinPic/IOWw.pyw", line 14, in 
 print("Ww Outside = <" + str(Ww) > + ">")
TypeError: bad operand type for unary +: 'str'

With the need to close the window, it adds an extra step and intervention to 
the program to use. I am not sure how this help[s.

As a curio, it would be interesting to see how to use the value of a variable, 
created in the function used here, and make it available to the code outside 
the function.



SGA

-Original Message-
From: Alan Gauld 
Sent: Sunday, February 25, 2024 12:44 PM
To: Steve GS ; python-list@python.org
Subject: Re: RE: Problem resizing a window and button placement

On 25/02/2024 03:58, Steve GS via Python-list wrote:
import tkinter as tk

Ww = None

def on_configure(*args):
global Ww
Ww = root.winfo_width()
print("Ww Inside = <" + str(Ww) + ">")

root = tk.Tk()
root.bind('', on_configure)
root.mainloop()

print("Ww Outside = <" + str(Ww) > + ">")

Produces:
Ww Inside = <200>
Ww Inside = <200>
Ww Inside = <205>
Ww Inside = <205>
Ww Inside = <206>
Ww Inside = <206>
Ww Outside = <206>

HTH



--
https://mail.python.org/mailman/listinfo/python-list


Re: Problem resizing a window and button placement

2024-02-24 Thread Thomas Passin via Python-list

On 2/24/2024 9:51 PM, Steve GS via Python-list wrote:
First of all, please make sure that the formatting is readable and 
especially the indentation.  This is Python, after all.


Do not use tabs; use 3 or 4 spaces instead of each tab.

import tkinter as tk

#global Ww  Neither global
helps
def on_configure(*args):
# print(args)
  #global Ww  Neither
global helps
  Ww = root.winfo_width()
  print("WwInside = <" +
str(Ww) + ">")

root = tk.Tk()
root.bind('',
on_configure)
print("WwOutside = <" +
str(Ww) + ">")
#NameError: name 'Ww' is not
defined


The function that declares Ww hasn't run yet. As I wrote earlier, the 
function bound to the callback should do all the work for the callback, 
or it should call other functions that do.  That's if you don't let a 
layout do it all for you, as others have written.



root.mainloop()

SGA

-Original Message-
From: Python-list
 On
Behalf Of MRAB via Python-list
Sent: Saturday, February 24,
2024 7:49 PM
To: python-list@python.org
Subject: Re: Problem resizing
a window and button placement

On 2024-02-25 00:33, Steve GS
via Python-list wrote:

"Well, yes, in Python a
variable created inside a
function or method is local

to

that function unless you
declare it global."

Yes, I knew that. I tried to
global it both before the
function call and within it.
Same for when I created the
variable. If I try to use it
in the rest of the code, it
keeps coming up as not
declared.  In other

functions,

I can 'return' the variable
but that apparently would

not

work for this function.

Is this type of function any
different that that which I
have been using?


Please post a short example
that shows the problem.



--
https://mail.python.org/mailman/listinfo/python-list


Re: Problem resizing a window and button placement

2024-02-24 Thread Thomas Passin via Python-list

On 2/24/2024 3:20 AM, Steve GS via Python-list wrote:

Yes, I ran that elegantly
simple code. The print
statement reports the X, Y,
Height and Width values.
However, I do not see how to
capture the width value.

  I experimented with the code
Vwidth = rootV.winfo_width()
and it also reports the width
as I resize the window.

However, I cannot seem to use
the variable Vwidth outside
the sub routine. It is acting
as if Vwidth is not global but
I added that.  It is reported
that Vwidth is not defined
when I try to use it in my
code.


Well, yes, in Python a variable created inside a function or method is 
local to that function unless you declare it global. That characteristic 
is called its "scope". But if you think you need it to be a global 
variable you should rethink your design. For one thing, before the next 
time you use your global variable the window size may have changed again.


Instead, it would be better to have the function that responds to the 
resize event perform the action that you want, or call another function 
that does, passing the new width to it.


Note that in most programming languages, variables have a scope.  The 
rules about those scopes vary between languages.




So close..
SGA

-Original Message-
From: Barry

Sent: Saturday, February 24,
2024 3:04 AM
To: Steve GS

Cc: MRAB
;
python-list@python.org
Subject: Re: Problem resizing
a window and button placement




On 24 Feb 2024, at 04:36,

Steve GS via Python-list

wrote:


How do I extract the values
from args?


You can look up the args in
documentation.
You can run the example code
MRAB provided and see what is
printed to learn what is in
the args.

Barry




--
https://mail.python.org/mailman/listinfo/python-list


Re: Testing (sorry)

2024-02-19 Thread Thomas Passin via Python-list

On 2/19/2024 11:55 AM, Skip Montanaro wrote:

Here is a typical bounce message that I get:

mailto:python-list@python.org>>: host
mail.python.org [188.166.95.178] said:
450-4.3.2
      Service currently unavailable 450 4.3.2

Some time after I get one of these messages I re-send the post. 
Usually

it gets through then.


Looks kinda like greylisting to me. I'm pretty sure that's one of the 
tool in the mail.python.org  chain.


I don't see it as greylisting.  A repeat post will succeed, before there 
would be time for my email provider (Dreamhost) to do anything about it.


--
https://mail.python.org/mailman/listinfo/python-list


Re: Testing (sorry)

2024-02-19 Thread Thomas Passin via Python-list

On 2/19/2024 9:17 AM, Grant Edwards via Python-list wrote:

On 2024-02-19, Thomas Passin  wrote:


About 24 hours later, all of my posts (and the confirmation e-mails)
all showed up in a burst at the same time on two different unrelated
e-mail accounts.

I still have no clue what was going on...


Sometimes a post of mine will not show up for hours or even half a day.
They are all addressed directly to the list.  Sometimes my email
provider sends me a notice that the message bounced.  Those notices say
that the address wasn't available when the transmission was tried.


Here is a typical bounce message that I get:

: host mail.python.org[188.166.95.178] said: 
450-4.3.2

Service currently unavailable 450 4.3.2

Some time after I get one of these messages I re-send the post.  Usually 
it gets through then.



I guess that in future I'll wait a couple days before I assume
something is broken.

--
Grant



--
https://mail.python.org/mailman/listinfo/python-list


Re: Testing (sorry)

2024-02-18 Thread Thomas Passin via Python-list

On 2/18/2024 6:09 PM, Grant Edwards via Python-list wrote:

On 2024-02-18, Peter J. Holzer via Python-list  wrote:

[Replying to the list *and* Grant]

On 2024-02-17 19:38:04 -0500, Grant Edwards via Python-list wrote:

Today I noticed that nothing I've posted to python-list in past 3
weeks has shown up on the list.


January 29th, AFAICS. And end of december before that.


I don't know how to troubleshoot this other than sending test
messages.  Obviously, if this shows up on the list, then I've gotten
it to work...


This did show up and 3 other test messages with very similar text
as well.

Also there was a whole flurry of almost but not quite identical messages
from you in the "nan" thread.


Sorry about that.

All of those were posted at various times throughout the day yesterday
using two different accounts, two different mail servers, and three
different methods for submitting the e-mails.  I finally gave up and
switched to using comp.lang.python via Usenet.

Then, about 24 hours later, all those messages finally showed up.

At one point about half way through that process yesterday, I
unsusbscribed and then re-subscribed both e-mail addresses.  I got
confirmation and welcome messages on both accounts.  Sending "help"
requests to the list server produced the expected results. I enabled
the sending of confirmation messages from the list server.

But posts to the list still seemed to vanish into the ether while
emails from both accounts reached other destinations without delay,

During this process a number of posts from other users did appear in
the list archive and at at _one_ of the two e-mail addresses which I
had subscribed.

But no sign of any of my posts.

About 24 hours later, all of my posts (and the confirmation e-mails)
all showed up in a burst at the same time on two different unrelated
e-mail accounts.

I still have no clue what was going on...


Sometimes a post of mine will not show up for hours or even half a day. 
They are all addressed directly to the list.  Sometimes my email 
provider sends me a notice that the message bounced.  Those notices say 
that the address wasn't available when the transmission was tried.


--
https://mail.python.org/mailman/listinfo/python-list


Re: Leo's PyPi page will remain

2024-02-16 Thread Thomas Passin
On WIndows, installing pyqtx does not require a separate installation of Qt 
- apparently all the binaries needed are packaged with pyqyx.  From your 
error message, on the Mac it seems that you need to install Qt itself, 
apart from any Python installation.  If Qt has already been installed, 
maybe the cocoa plugin for it has to get installed separately.

On Linux the package manager usually takes care of the Qt aspects, I 
think.  At least, I haven't had problems when I pip-install pyqtx.

On Friday, February 16, 2024 at 3:06:48 PM UTC-5 Geoff Evans wrote:

> Thanks Thomas for the pyqt6 reminder (I remembered doing something like 
> that years ago, but not precisely what ;-)
> Now I get 
> "qt.qpa.plugin: Could not find the Qt platform plugin "cocoa" in ""
> This application failed to start because no Qt platform plugin could be 
> initialized. Reinstalling the application may fix this problem. "
>
> re-installing didn't make any difference.
>
> geoff
>

-- 
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/dcaa-5d02-4e52-a15f-82b0c2c77a28n%40googlegroups.com.


Interesting Post On Retiring An API

2024-02-16 Thread Thomas Passin
>From The Old New Thing -

If you’re just going to sit there doing nothing, at least do nothing 
correctly 

-- 
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/56d531ac-20ce-4269-a973-20fcc059d2d6n%40googlegroups.com.


Re: Leo's PyPi page will remain

2024-02-11 Thread Thomas Passin
I don't know for sure about the Mac (why it would be different, I mean),  
but you want to install "pyqt6", not "qt".  You should also install 
"PyQt6-WebEngine", for the ViewRendered3 plugin to work completely.  I 
don't know if that has finally gotten into the requirements list or not.

On Windows and Linux, installing Leo also installs pyqt6 (or pyqt5, which 
will also work; correspondingly you also should install PyQtWebEngine).  I 
don't know if it needs to be compiled  during installation on a Mac or not, 
but the compilation might not have worked for some reason.

On Sunday, February 11, 2024 at 2:34:20 PM UTC-5 Geoff Evans wrote:

> (Sorry; forgot to say this is in MacOS)
>
> On Sunday 11 February 2024 at 16:03:48 UTC-3:30 Geoff Evans wrote:
>
>> Thanks Edward, I tried that and got further than I did 2 weeks ago.  "pip 
>> install leo" apparently works but when I then type  "leo" I get
>> Can not load the requested gui: qt
>> Then when I try "pip install qt" I get "ERROR: No matching distribution 
>> found for qt".  What am I missing?
>>
>> Cheersgeoff
>>
>> On Sunday 11 February 2024 at 08:27:39 UTC-3:30 Edward K. Ream wrote:
>>
>>> I have deleted the ill-fated 6.7.7.1 release from Leo's PyPi page 
>>> .
>>>
>>> pip install leo should work again as before.
>>>
>>> Issue #3767  now 
>>> suggests supporting pip install -r requirements.txt
>>> as an easy way to install requirements *from within a cloned GitHub 
>>> repo*.
>>>
>>> All comments and questions are welcome.
>>>
>>> Edward
>>>
>>

-- 
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/67488c9a-b5b2-494c-ae2e-8292c4f89408n%40googlegroups.com.


Re: PR 3774 completes the 6.7.8 code base

2024-02-05 Thread Thomas Passin
On my Manjaro VM only three were skipped - one importer, one speller, one 
in leoAst.

928 passed, 3 skipped in 11.53s

I wonder if something isn't installed on the XUBuntu VM, like a language or 
something else outside of Leo itself.
On Monday, February 5, 2024 at 1:09:34 PM UTC-5 Thomas Passin wrote:

> OK, doing it that way on XUbuntu gave no errors but many more skipped 
> tests than on Windows (Windows skipped two importer tests):
>
> 905 passed, 26 skipped in 8.59s
>
> On Sunday, February 4, 2024 at 6:21:18 PM UTC-5 Edward K. Ream wrote:
>
>> On Saturday, February 3, 2024 at 9:00:57 AM UTC-6 Thomas 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' ...
>>
>>
>> leo\plugins\leo_babel\tests\lib_test.py appears to be a bespoke unit 
>> testing framework.
>>
>> I have no intention of diving into those weeds, so I'm going to close 
>> #3778 <https://github.com/leo-editor/leo-editor/issues/3778>. 
>>
>> To run Leo's unit tests with pytest do pytest leo\unittests, *not* pytest 
>> leo.
>>
>> Edward
>>
>

-- 
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/b8cb8767-d421-48a0-a79f-4bd296006a54n%40googlegroups.com.


Re: PR 3774 completes the 6.7.8 code base

2024-02-05 Thread Thomas Passin
OK, doing it that way on XUbuntu gave no errors but many more skipped tests 
than on Windows (Windows skipped two importer tests):

905 passed, 26 skipped in 8.59s

On Sunday, February 4, 2024 at 6:21:18 PM UTC-5 Edward K. Ream wrote:

> On Saturday, February 3, 2024 at 9:00:57 AM UTC-6 Thomas 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' ...
>
>
> leo\plugins\leo_babel\tests\lib_test.py appears to be a bespoke unit 
> testing framework.
>
> I have no intention of diving into those weeds, so I'm going to close 
> #3778 . 
>
> To run Leo's unit tests with pytest do pytest leo\unittests, *not* pytest 
> leo.
>
> Edward
>

-- 
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/3d4fe0c3-d07c-4925-820c-f2b9cdb165abn%40googlegroups.com.


Re: PR 3774 completes the 6.7.8 code base

2024-02-04 Thread Thomas Passin
On Linux/Manjaro there is the same warning, but it only skipped 3 tests 
instead of 26.  It too a few seconds longer than on XUbuntu.

On Sunday, February 4, 2024 at 2:41:44 PM UTC-5 Thomas Passin wrote:

> For the recent merge in devel, 08fcbac60bc296b2e636c3467daf29022b03231b, 
> there is still a warning from XUbuntu:
>
> === 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
> == 905 passed, 26 skipped, 1 warning in 8.84s 
> ==
>
> There is a similar warning on Windows 10:
>
>  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 21.87s ===
>
> Interesting how much faster the tests run in Linux than Windows.
> On Sunday, February 4, 2024 at 3:38:37 AM UTC-5 Edward K. Ream wrote:
>
>> On Sat, Feb 3, 2024 at 9:01 AM Thomas Passin wrote:
>>
>>> On Windows 10, Python 3.12 -
>>
>> 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)
>>>
>> ...
>>
>> Thanks for this report. See #3778 
>> <https://github.com/leo-editor/leo-editor/issues/3778>.
>>
>> Edward
>>
>

-- 
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/fc0c62ea-58d1-4cc3-aa4e-df8620daaf3cn%40googlegroups.com.


Re: PR 3774 completes the 6.7.8 code base

2024-02-04 Thread Thomas Passin
For the recent merge in devel, 08fcbac60bc296b2e636c3467daf29022b03231b, 
there is still a warning from XUbuntu:

=== 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
== 905 passed, 26 skipped, 1 warning in 8.84s 
==

There is a similar warning on Windows 10:

 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 21.87s ===

Interesting how much faster the tests run in Linux than Windows.
On Sunday, February 4, 2024 at 3:38:37 AM UTC-5 Edward K. Ream wrote:

> On Sat, Feb 3, 2024 at 9:01 AM Thomas Passin wrote:
>
>> On Windows 10, Python 3.12 -
>
> 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)
>>
> ...
>
> Thanks for this report. See #3778 
> <https://github.com/leo-editor/leo-editor/issues/3778>.
>
> Edward
>

-- 
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/0eddc1c6-ab48-4f3d-8e32-af93f9a9158cn%40googlegroups.com.


Re: Extract lines from file, add to new files

2024-02-03 Thread Thomas Passin via Python-list

On 2/3/2024 5:02 PM, dn via Python-list wrote:
Every trainer, in any field, has to deal with these problems - all the 
time, and over-and-over.



On 4/02/24 06:58, Thomas Passin via Python-list wrote:
In my view this whole thread became murky and complicated because the 
OP did not write down the requirements for the program.  Requirements 
are needed to communicate with other people.  An individual may not 
need to actually write down the requirements - depending on their 
complexity - but they always exist even if only vaguely in a person's 
mind.  The requirements may include what tools or languages the person 
wants to use and why.


If you are asking for help, you need to communicate the requirements 
to the people you are asking for help from.


The OP may have thought the original post(s) contained enough of the 
requirements but as we know by now, they didn't.


There is another possible interpretation in such situations (not 
necessarily this one): that the person is fixated on a particular 
solution (and unable/unwilling to adjust his/her thinking to consider 
more widely).


Thus, the question is not: 'here's an entire problem, how can it be 
solved', but more: 'I have a solution, and want help to implement it 
(and only it) just-so'.



The latter is an interesting psychology:

1
an experienced person who is trying to translate from one tool to 
another (Python), but discovers that a word-for-word solution is 
difficult because of the artificial-constraints they've placed on the 
situation.


2
a beginner who doesn't know what (s)he doesn't know and comes-up with an 
idea, but fails to appreciate that there is likely more than one path to 
the goal.



The person asking for help may not realize they don't know enough to 
write down all the requirements; an effort to do so may bring that 
lack to visibility.


In the case of 'Beginners' this should probably be taken-as-read!

Which is why we will always find ourselves asking questions or 'please 
give more information'...



However, there are other reasons, eg corporate concerns or personality; 
why people don't want to give more information. The former is reasonable 
(have suffered from same myself). The latter may reveal that the person 
is 'difficult to deal with'...



Mailing lists like these have a drawback that it's hard to impossible 
for someone not involved in a thread to learn anything general from 
it. We can write over and over again to please state clearly what you 
want to do and where the sticking points are, but newcomers post new 
questions without ever reading these pleas.  Then good-hearted people 
who want to be helpful end up spending a lot of time trying to guess 
what is actually being asked for, and maybe never find out with enough 
clarity.  Others take a guess and then spend time working up a 
solution that may or may not be on target.


So please! before posting a request for help, write down the 
requirements as best you can figure them out, and then make sure that 
they are expressed such that the readers can understand.


Unfortunately, if the person doesn't understand the problem (leave-aside 
any ideas of solution), then (s)he will not be able to clearly 
communicate same to us, in any way, shape, or form...


Which brings one to the question: if a person cannot express the problem 
clearly and completely, is (s)he suited to development work? If the 
problem is not understood, could 'the solution' ever be more than an 
exercise in hope?

(prototyping and experimentation aside)


Pairs programming can be fun and productive, if you are lucky to have 
the right person to work with.  I've had one person like that over the 
years.


Yes, it is frustrating to invest time and effort in helping someone, 
only for same to disappear 'into a black hole'. The lack of response 
seems to indicate a lack of respect or appreciation. Is this perhaps 
part of today's "consumer" life-style, where so few are contributors or 
creators?



On the other side of that coin: do the people who make assumptions and 
(kindly) blaze-ahead with 'a solution', actually help the conversation? 
If the assumptions are correct, yes! What if they are not?



...and don't get me started on folk who want us to do their 
training-assignments or build some application, for them!



As a slight aside: on one training-course DiscussionList/BulletinBoard 
set-up, if a trainee asked a question without a descriptive 
title/SubjectLine, eg "Python not working" or "Urgent: please help"; I 
asked them to re-post with a title that would help others in a similar 
situation find the topic - and closed the original thread.


Some found it "brutal" - probably skewing towards those who felt 
"Urgent" because they'd left things too close to deadline. Others joi

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: Extract lines from file, add to new files

2024-02-03 Thread Thomas Passin via Python-list
In my view this whole thread became murky and complicated because the OP 
did not write down the requirements for the program.  Requirements are 
needed to communicate with other people.  An individual may not need to 
actually write down the requirements - depending on their complexity - 
but they always exist even if only vaguely in a person's mind.  The 
requirements may include what tools or languages the person wants to use 
and why.


If you are asking for help, you need to communicate the requirements to 
the people you are asking for help from.


The OP may have thought the original post(s) contained enough of the 
requirements but as we know by now, they didn't.


The person asking for help may not realize they don't know enough to 
write down all the requirements; an effort to do so may bring that lack 
to visibility.


Mailing lists like these have a drawback that it's hard to impossible 
for someone not involved in a thread to learn anything general from it. 
We can write over and over again to please state clearly what you want 
to do and where the sticking points are, but newcomers post new 
questions without ever reading these pleas.  Then good-hearted people 
who want to be helpful end up spending a lot of time trying to guess 
what is actually being asked for, and maybe never find out with enough 
clarity.  Others take a guess and then spend time working up a solution 
that may or may not be on target.


So please! before posting a request for help, write down the 
requirements as best you can figure them out, and then make sure that 
they are expressed such that the readers can understand.


On 2/3/2024 11:33 AM, avi.e.gr...@gmail.com wrote:

Thomas,

I have been thinking about the concept of being stingy with information as
this is a fairly common occurrence when people ask for help. They often ask
for what they think they want while people like us keep asking why they want
that and perhaps offer guidance on how to get closer to what they NEED or a
better way.

In retrospect, Rich did give all the info he thought he needed. It boiled
down to saying that he wants to distribute data into two files in such a way
that finding an item in file A then lets him find the corresponding item in
file B. He was not worried about how to make the files or what to do with
the info afterward. He had those covered and was missing what he considered
a central piece. And, it seems he programs in multiple languages and
environments as needed and is not exactly a newbie. He just wanted a way to
implement his overall design.

We threw many solutions and ideas at him but some of us (like me) also got
frustrated as some ideas were not received due to one objection or another
that had not been mentioned earlier when it was not seen as important.

I particularly notice a disconnect some of us had. Was this supposed to be a
search that read only as much as needed to find something and stopped
reading, or a sort of filter that returned zero or more matches and went to
the end, or perhaps something that read entire files and swallowed them into
data structures in memory and then searched and found corresponding entries,
or maybe something else?

All the above approaches could work but some designs not so much. For
example, some files are too large. We, as programmers, often consciously or
unconsciously look at many factors to try to zoom in on what approaches me
might use. To be given minimal amounts of info can be frustrating. We worry
about making a silly design. But the OP may want something minimal and not
worry as long as it is fairly easy to program and works.

We could have suggested something very simple like:

Open both files A and B
In a loop get a line from each. If the line from A is a match, do something
with the current line from B.
If you are getting only one, exit the loop.

Or, if willing, we could have suggested any other file format, such as a
CSV, in which the algorithm is similar but different as in:

Open file A
Read a line in a loop
Split it in parts
If the party of the first part matches something, use the party of the
second part

Or, of course, suggest they read the entire file, into a list of lines or a
data.frame and use some tools that search all of it and produce results.

I find I personally now often lean toward the latter approach but ages ago
when memory and CPU were considerations and maybe garbage collection was not
automatic, ...


-Original Message-
From: Python-list  On
Behalf Of Thomas Passin via Python-list
Sent: Wednesday, January 31, 2024 7:25 AM
To: python-list@python.org
Subject: Re: Extract lines from file, add to new files

On 1/30/2024 11:25 PM, avi.e.gr...@gmail.com wrote:

Thomas, on some points we may see it differently.


I'm mostly going by what the OP originally asked for back on Jan 11.
He's been too stingy with information since then to be worth spending
much time on, IMHO.


Some formats can be done simply but are maybe be

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 <https://github.com/leo-editor/leo-editor/pull/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 
>> <https://github.com/leo-editor/leo-editor/issues/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 
&

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: Extract lines from file, add to new files

2024-01-31 Thread Thomas Passin via Python-list

On 1/31/2024 9:05 AM, Rich Shepard via Python-list wrote:

On Tue, 30 Jan 2024, Thomas Passin via Python-list wrote:


If I had a script that's been working for 30 years, I'd probably just use
Python to do the personalizing and let the rest of the bash script do the
rest, like it always has. The Python program would pipe or send the
personalized messages to the rest of the bash program. Something in that
ballpark, anyway.


Thomas,

A bash shell script looks easier for me and more promising. Using a while
loop (one for the name file the other for the address file), and sed for
putting the name at the head of the message replacing a generic placeholder
should work with the existing for loop script.


Sounds good.  I'd still be a bit worried about the two files getting out 
of sync, as others have mentioned.


--
https://mail.python.org/mailman/listinfo/python-list


Re: Extract lines from file, add to new files

2024-01-31 Thread Thomas Passin via Python-list

On 1/30/2024 11:25 PM, avi.e.gr...@gmail.com wrote:

Thomas, on some points we may see it differently.


I'm mostly going by what the OP originally asked for back on Jan 11. 
He's been too stingy with information since then to be worth spending 
much time on, IMHO.



Some formats can be done simply but are maybe better done in somewhat
standard ways.

Some of what the OP has is already tables in a database and that can
trivially be exported into a CSV file or other formats like your TSV file
and more. They can also import from there. As I mentioned, many spreadsheets
and all kinds of statistical programs tend to support some formats making it
quite flexible.

Python has all kinds of functionality, such as in the pandas module, to read
in a CSV or write it out. And once you have the data structure in memory, al
kinds of queries and changes can be made fairly straightforwardly. As one
example, Rich has mentioned wanting finer control in selecting who gets some
version of the email based on concepts like market segmentation. He already
may have info like the STATE (as in Arizona) in his database. He might at
some point enlarge his schema so each entry is placed in one or more
categories and thus his CSV, once imported, can do the usual tasks of
selecting various rows and columns or doing joins or whatever.

Mind you, another architecture could place quite a bit of work completely on
the back end and he could send SQL queries to the database from python and
get back his results into python which would then make the email messages
and pass them on to other functionality to deliver. This would remove any
need for files and just rely on the DB.

There as as usual, too many choices and not necessarily one best answer. Of
course if this was a major product that would be heavily used, sure, you
could tweak and optimize. As it is, Rich is getting a chance to improve his
python skills no matter which way he goes.



-Original Message-
From: Python-list  On
Behalf Of Thomas Passin via Python-list
Sent: Tuesday, January 30, 2024 10:37 PM
To: python-list@python.org
Subject: Re: Extract lines from file, add to new files

On 1/30/2024 12:21 PM, Rich Shepard via Python-list wrote:

On Tue, 30 Jan 2024, Thomas Passin via Python-list wrote:


Fine, my toy example will still be applicable. But, you know, you haven't
told us enough to give you help. Do you want to replace text from values
in a file? That's been covered. Do you want to send the messages using
those libraries? You haven't said what you don't know how to do.
Something
else? What is it that you want to do that you don't know how?


Thomas,

For 30 years I've used a bash script using mailx to send messages to a

list

of recipients. They have no salutation to personalize each one. Since I
want
to add that personalized salutation I decided to write a python script to
replace the bash script.

I have collected 11 docs explaining the smtplib and email modules and
providing example scripts to apply them to send multiple individual
messages
with salutations and attachments.


If I had a script that's been working for 30 years, I'd probably just
use Python to do the personalizing and let the rest of the bash script
do the rest, like it always has.  The Python program would pipe or send
the personalized messages to the rest of the bash program. Something in
that ballpark, anyway.


Today I'm going to be reading these. They each recommend using .csv input
files for names and addresses. My first search is learning whether I can
write a single .csv file such as:
"name1","address1"
"mane2","address2"
which I believe will work; and by inserting at the top of the message

block

Hi, {yourname}
the name in the .csv file will replace the bracketed place holder

If the file contents are going to be people's names and email addresses,
I would just tab separate them and split each line on the tab.  Names
aren't going to include tabs so that would be safe.  Email addresses
might theoretically include a tab inside a quoted name but that would be
extremely obscure and unlikely.  No need for CSV, it would just add
complexity.

data = f.readlines()
for d in data:
  name, addr = line.split('\t') if line.strip() else ('', '')


Still much to learn and the batch of downloaded PDF files should educate
me.

Regards,

Rich




--
https://mail.python.org/mailman/listinfo/python-list


Re: Extract lines from file, add to new files

2024-01-30 Thread Thomas Passin via Python-list

On 1/30/2024 12:21 PM, Rich Shepard via Python-list wrote:

On Tue, 30 Jan 2024, Thomas Passin via Python-list wrote:


Fine, my toy example will still be applicable. But, you know, you haven't
told us enough to give you help. Do you want to replace text from values
in a file? That's been covered. Do you want to send the messages using
those libraries? You haven't said what you don't know how to do. 
Something

else? What is it that you want to do that you don't know how?


Thomas,

For 30 years I've used a bash script using mailx to send messages to a list
of recipients. They have no salutation to personalize each one. Since I 
want

to add that personalized salutation I decided to write a python script to
replace the bash script.

I have collected 11 docs explaining the smtplib and email modules and
providing example scripts to apply them to send multiple individual 
messages

with salutations and attachments.


If I had a script that's been working for 30 years, I'd probably just 
use Python to do the personalizing and let the rest of the bash script 
do the rest, like it always has.  The Python program would pipe or send 
the personalized messages to the rest of the bash program. Something in 
that ballpark, anyway.



Today I'm going to be reading these. They each recommend using .csv input
files for names and addresses. My first search is learning whether I can
write a single .csv file such as:
"name1","address1"
"mane2","address2"
which I believe will work; and by inserting at the top of the message block
Hi, {yourname}
the name in the .csv file will replace the bracketed place holder
If the file contents are going to be people's names and email addresses, 
I would just tab separate them and split each line on the tab.  Names 
aren't going to include tabs so that would be safe.  Email addresses 
might theoretically include a tab inside a quoted name but that would be 
extremely obscure and unlikely.  No need for CSV, it would just add 
complexity.


data = f.readlines()
for d in data:
name, addr = line.split('\t') if line.strip() else ('', '')

Still much to learn and the batch of downloaded PDF files should educate 
me.


Regards,

Rich


--
https://mail.python.org/mailman/listinfo/python-list


Re: Extract lines from file, add to new files

2024-01-30 Thread Thomas Passin via Python-list

On 1/30/2024 8:37 AM, Rich Shepard via Python-list wrote:

On Mon, 29 Jan 2024, Thomas Passin via Python-list wrote:


If you aren't going to use one or another existing template system,
perhaps the easiest is to use unique strings in the message file. For
example:

Dear __##so-and-so##__:
  Please don't write this message off as mere spam.
  Respectfully, Rich

Then you just do a replace of the unique string by the salutation. Don't
change the original (i.e., template), make the changes to a copy that you
will output.


My script is not a web application, but an emailer that allows me to 
contact

clients and prospective clients. From the command line on a linux host.
Using the python smtplib and mail modules.

Rich


Fine, my toy example will still be applicable.  But, you know, you 
haven't told us enough to give you help.  Do you want to replace text 
from values in a file?  That's been covered. Do you want to send the 
messages using those libraries?  You haven't said what you don't know 
how to do.  Something else? What is it that you want to do that you 
don't know how?


--
https://mail.python.org/mailman/listinfo/python-list


Re: Extract lines from file, add to new files

2024-01-29 Thread Thomas Passin via Python-list

On 1/29/2024 11:15 AM, Rich Shepard via Python-list wrote:

For my use 1) the salutation and email address (always with an '@') are
sequential and 2) I'm developing the script to extract both from the same
file.


I've looked at my Python books "Python Crash Course," "Effective Python,"
and "Python Tricks The Book" as well as web pages in my searches without
finding the answer to what may be a simple question: how to specify a
variable in one file that has its values in another file.

Specifically, how to I designate the salutation holder in the message file
and pass it the name value from the name/email address file?

If this explanation is not sufficiently clear I'll re-write it. :-)

TIA,

Rich


I'm assuming this is a continuation of a previous thread about working 
with alternate lines with salutation and address, and I assume you've 
got that worked out.


If you aren't going to use one or another existing template system, 
perhaps the easiest is to use unique strings in the message file.  For 
example:


Dear __##so-and-so##__:
   Please don't write this message off as mere spam.
   Respectfully, Rich

Then you just do a replace of the unique string by the salutation. Don't 
change the original (i.e., template), make the changes to a copy that 
you will output.


--
https://mail.python.org/mailman/listinfo/python-list


Re: 🚀 LeoInteg 1.0.19 Released

2024-01-22 Thread Thomas Passin
After updating, and installing websockets, the new version opened OK in 
vsc.  One thing I noticed is that LeoInteg uses the name "Leo" in the bar 
displaying its name, and LeoJS uses "LeoJS".  This makes it a little 
unclear whether the "Leo" panel is another instance of LeoJS, or whether 
it's LeoInteg.  When it's convenient, I suggest changing the display name 
to "LeoInteg".

On Monday, January 22, 2024 at 10:51:47 PM UTC-5 Félix wrote:

> [image: banner1.0.19.png]
> *Announcing LeoInteg 1.0.19! *🥳
>
> Big news! Following the unannounced 1.0.18 small patch, the 1.0.19 version 
> is here!
>
> *Here's what Leonistas can expect:*
>
>- *UNL support: *Requires Leo 6.7.7.
>- *Word Wrap support: *honors @wrap and @nowrap directives and 
>settings.
>- *@button panel: *entries now have a proper 'play' button to trigger.
>- *Fixed 'goto-script' command: *Will even find external scripts from 
>@settings notes  
>
> And many other UI improvements  and bug fixes.
>
> *Available via automatic update, or on the vscode marketplace 
>  and 
> the open-vsx marketplace ! *
>
> Please report any problems or suggestions on the project's issues page at 
> https://github.com/boltex/leointeg/issues. 
>
> Thanks for trying out LeoInteg! 🦁
>
> Félix
>

-- 
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/ed4904f4-0894-4cfa-a86e-95e344e17b1bn%40googlegroups.com.


Re: LeoInteg using Leo's Null GUI ?

2024-01-22 Thread Thomas Passin

On Monday, January 22, 2024 at 5:09:27 PM UTC-5 Edward K. Ream wrote:

On Mon, Jan 22, 2024 at 3:10 PM Thomas Passin  wrote:
 

Didn't we decide not to support Jupyter notebooks any more? If so, nbformat 
can probably be omitted in the future.


Good catch. Hehe, VR3 still has some references to nbformat!


I've realized that for some time and I didn't want to put such a minor PR 
in while all those heavy-duty ones were in the mix.   After my current ones 
get merged, I'll fix up the nbformat import for VR3.

-- 
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/c200ee02-b307-47e4-90af-5ac7137f2afdn%40googlegroups.com.


Re: LeoInteg using Leo's Null GUI ?

2024-01-22 Thread Thomas Passin

On Monday, January 22, 2024 at 3:49:42 PM UTC-5 Edward K. Ream wrote:


setup.py specifies requirements in the section called << define 
install_requires >>.

This section lists the following dependencies:


install_requires = [

 # Other entries omitted 

  'nbformat', # for Jupyter notebook integration

]

 
Didn't we decide not to support Jupyter notebooks any more? If so, nbformat 
can probably be omitted in the future.

-- 
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/9df145ca-799c-4833-a8ce-b50d251f9ef2n%40googlegroups.com.


Re: How to replace a cell value with each of its contour cells and yield the corresponding datasets seperately in a list according to a Pandas-way?

2024-01-21 Thread Thomas Passin via Python-list

On 1/21/2024 1:25 PM, marc nicole wrote:
It is part of a larger project aiming at processing data according to a 
given algorithm

Do you have any comments or any enhancing recommendations on the code?


I'm not knowledgeable enough about either pandas or numpy, I'm afraid, 
just very basic usage.  Someone else will probably pitch in.



Thanks.

Le dim. 21 janv. 2024 à 18:28, Thomas Passin via Python-list 
mailto:python-list@python.org>> a écrit :


On 1/21/2024 11:54 AM, marc nicole wrote:
 > Thanks for the reply,
 >
 > I think using a Pandas (or a Numpy) approach would optimize the
 > execution of the program.
 >
 > Target cells could be up to 10% the size of the dataset, a good
example
 > to start with would have from 10 to 100 values.

Thanks for the reformatted code.  It's much easier to read and think
about.

For say 100 points, it doesn't seem that "optimization" would be
much of
an issue.  On my laptop machine and Python 3.12, your example takes
around 5 seconds to run and print().  OTOH if you think you will go to
much larger datasets, certainly execution time could become a factor.

I would think that NumPy arrays and/or matrices would have good
potential.

Is this some kind of a cellular automaton, or an image filtering
process?

 > Let me know your thoughts, here's a reproducible example which I
formatted:
 >
 >
 >
 > from numpy import random
 > import pandas as pd
 > import numpy as np
 > import operator
 > import math
 > from collections import deque
 > from queue import *
 > from queue import Queue
 > from itertools import product
 >
 >
 > def select_target_values(dataframe, number_of_target_values):
 >      target_cells = []
 >      for _ in range(number_of_target_values):
 >          row_x = random.randint(0, len(dataframe.columns) - 1)
 >          col_y = random.randint(0, len(dataframe) - 1)
 >          target_cells.append((row_x, col_y))
 >      return target_cells
 >
 >
 > def select_contours(target_cells):
 >      contour_coordinates = [(0, 1), (1, 0), (0, -1), (-1, 0)]
 >      contour_cells = []
 >      for target_cell in target_cells:
 >          # random contour count for each cell
 >          contour_cells_count = random.randint(1, 4)
 >          try:
 >              contour_cells.append(
 >                  [
 >                      tuple(
 >                          map(
 >                              lambda i, j: i + j,
 >                              (target_cell[0], target_cell[1]),
 >                              contour_coordinates[iteration_],
 >                          )
 >                      )
 >                      for iteration_ in range(contour_cells_count)
 >                  ]
 >              )
 >          except IndexError:
 >              continue
 >      return contour_cells
 >
 >
 > def create_zipf_distribution():
 >      zipf_dist = random.zipf(2, size=(50, 5)).reshape((50, 5))
 >
 >      zipf_distribution_dataset = pd.DataFrame(zipf_dist).round(3)
 >
 >      return zipf_distribution_dataset
 >
 >
 > def apply_contours(target_cells, contour_cells):
 >      target_cells_with_contour = []
 >      # create one single list of cells
 >      for idx, target_cell in enumerate(target_cells):
 >          target_cell_with_contour = [target_cell]
 >          target_cell_with_contour.extend(contour_cells[idx])
 >          target_cells_with_contour.append(target_cell_with_contour)
 >      return target_cells_with_contour
 >
 >
 > def create_possible_datasets(dataframe, target_cells_with_contour):
 >      all_datasets_final = []
 >      dataframe_original = dataframe.copy()
 >
 >      list_tuples_idx_cells_all_datasets = list(
 >          filter(
 >              lambda x: x,
 >              [list(tuples) for tuples in
 > list(product(*target_cells_with_contour))],
 >          )
 >      )
 >      target_original_cells_coordinates = list(
 >          map(
 >              lambda x: x[0],
 >              [
 >                  target_and_contour_cell
 >                  for target_and_contour_cell in
target_cells_with_contour
 >              ],
 >          )
 >      )
 >      for dataset_index_values in list_tuples_idx_cells_all_datasets:
 >          all_datasets = []
 >          for 

Re: How to replace a cell value with each of its contour cells and yield the corresponding datasets seperately in a list according to a Pandas-way?

2024-01-21 Thread Thomas Passin via Python-list

On 1/21/2024 11:54 AM, marc nicole wrote:

Thanks for the reply,

I think using a Pandas (or a Numpy) approach would optimize the 
execution of the program.


Target cells could be up to 10% the size of the dataset, a good example 
to start with would have from 10 to 100 values.


Thanks for the reformatted code.  It's much easier to read and think about.

For say 100 points, it doesn't seem that "optimization" would be much of 
an issue.  On my laptop machine and Python 3.12, your example takes 
around 5 seconds to run and print().  OTOH if you think you will go to 
much larger datasets, certainly execution time could become a factor.


I would think that NumPy arrays and/or matrices would have good potential.

Is this some kind of a cellular automaton, or an image filtering process?


Let me know your thoughts, here's a reproducible example which I formatted:



from numpy import random
import pandas as pd
import numpy as np
import operator
import math
from collections import deque
from queue import *
from queue import Queue
from itertools import product


def select_target_values(dataframe, number_of_target_values):
     target_cells = []
     for _ in range(number_of_target_values):
         row_x = random.randint(0, len(dataframe.columns) - 1)
         col_y = random.randint(0, len(dataframe) - 1)
         target_cells.append((row_x, col_y))
     return target_cells


def select_contours(target_cells):
     contour_coordinates = [(0, 1), (1, 0), (0, -1), (-1, 0)]
     contour_cells = []
     for target_cell in target_cells:
         # random contour count for each cell
         contour_cells_count = random.randint(1, 4)
         try:
             contour_cells.append(
                 [
                     tuple(
                         map(
                             lambda i, j: i + j,
                             (target_cell[0], target_cell[1]),
                             contour_coordinates[iteration_],
                         )
                     )
                     for iteration_ in range(contour_cells_count)
                 ]
             )
         except IndexError:
             continue
     return contour_cells


def create_zipf_distribution():
     zipf_dist = random.zipf(2, size=(50, 5)).reshape((50, 5))

     zipf_distribution_dataset = pd.DataFrame(zipf_dist).round(3)

     return zipf_distribution_dataset


def apply_contours(target_cells, contour_cells):
     target_cells_with_contour = []
     # create one single list of cells
     for idx, target_cell in enumerate(target_cells):
         target_cell_with_contour = [target_cell]
         target_cell_with_contour.extend(contour_cells[idx])
         target_cells_with_contour.append(target_cell_with_contour)
     return target_cells_with_contour


def create_possible_datasets(dataframe, target_cells_with_contour):
     all_datasets_final = []
     dataframe_original = dataframe.copy()

     list_tuples_idx_cells_all_datasets = list(
         filter(
             lambda x: x,
             [list(tuples) for tuples in 
list(product(*target_cells_with_contour))],

         )
     )
     target_original_cells_coordinates = list(
         map(
             lambda x: x[0],
             [
                 target_and_contour_cell
                 for target_and_contour_cell in target_cells_with_contour
             ],
         )
     )
     for dataset_index_values in list_tuples_idx_cells_all_datasets:
         all_datasets = []
         for idx_cell in range(len(dataset_index_values)):
             dataframe_cpy = dataframe.copy()
             dataframe_cpy.iat[
                 target_original_cells_coordinates[idx_cell][1],
                 target_original_cells_coordinates[idx_cell][0],
             ] = dataframe_original.iloc[
                 dataset_index_values[idx_cell][1], 
dataset_index_values[idx_cell][0]

             ]
             all_datasets.append(dataframe_cpy)
         all_datasets_final.append(all_datasets)
     return all_datasets_final


def main():
     zipf_dataset = create_zipf_distribution()

     target_cells = select_target_values(zipf_dataset, 5)
     print(target_cells)
     contour_cells = select_contours(target_cells)
     print(contour_cells)
     target_cells_with_contour = apply_contours(target_cells, contour_cells)
     datasets = create_possible_datasets(zipf_dataset, 
target_cells_with_contour)

     print(datasets)


main()

Le dim. 21 janv. 2024 à 16:33, Thomas Passin via Python-list 
mailto:python-list@python.org>> a écrit :


On 1/21/2024 7:37 AM, marc nicole via Python-list wrote:
 > Hello,
 >
 > I have an initial dataframe with a random list of target cells
(each cell
 > being identified with a couple (x,y)).
 > I want to yield four different dataframes each containing the
value of one
 > of the contour (surrounding) cells of each specified target cell.
 >
 > the surrounding cells 

Re: How to replace a cell value with each of its contour cells and yield the corresponding datasets seperately in a list according to a Pandas-way?

2024-01-21 Thread Thomas Passin via Python-list

On 1/21/2024 7:37 AM, marc nicole via Python-list wrote:

Hello,

I have an initial dataframe with a random list of target cells (each cell
being identified with a couple (x,y)).
I want to yield four different dataframes each containing the value of one
of the contour (surrounding) cells of each specified target cell.

the surrounding cells to consider for a specific target cell are : (x-1,y),
(x,y-1),(x+1,y);(x,y+1), specifically I randomly choose 1 to 4 cells from
these and consider for replacement to the target cell.

I want to do that through a pandas-specific approach without having to
define the contour cells separately and then apply the changes on the
dataframe 


1. Why do you want a Pandas-specific approach?  Many people would rather 
keep code independent of special libraries if possible;


2. How big can these collections of target cells be, roughly speaking? 
The size could make a big difference in picking a design;


3. You really should work on formatting code for this list.  Your code 
below is very complex and would take a lot of work to reformat to the 
point where it is readable, especially with the nearly impenetrable 
arguments in some places.  Probably all that is needed is to replace all 
tabs by (say) three spaces, and to make sure you intentionally break 
lines well before they might get word-wrapped.  Here is one example I 
have reformatted (I hope I got this right):


list_tuples_idx_cells_all_datasets = list(filter(
   lambda x: utils_tuple_list_not_contain_nan(x),
   [list(tuples) for tuples in list(
 itertools.product(*target_cells_with_contour))
   ]))

4. As an aside, it doesn't look like you need to convert all those 
sequences and iterators to lists all over the place;




(but rather using an all in one approach):
for now I have written this example which I think is not Pandas specific:

[snip]

--
https://mail.python.org/mailman/listinfo/python-list


Re: Discuss: Release Leo only via GitHub?

2024-01-20 Thread Thomas Passin
Yes, running pip on requiremenst.txt is the standard way.  I also know that 
currently requirements.txt does not contain the actual dependencies (which 
can be changed, of course). I was just thinking about whether a new user 
would have a problem with using pip this way, having already manually 
downloaded and unpacked the Leo distro.

On Saturday, January 20, 2024 at 5:14:11 PM UTC-5 Edward K. Ream wrote:

> On Sat, Jan 20, 2024 at 3:23 PM Thomas Passin  wrote:
>
>> I think that would be all right, although sometimes I have trouble 
>> finding the release files when I want to get an app from GitHub.  My main 
>> concern would be how to make it painless for a new user to get the 
>> dependencies installed.
>>
>
> There is an easy answer. See #3767 
> <https://github.com/leo-editor/leo-editor/issues/3767>: 
> (requirements.txt).
>
> Leo already has a requirements.txt file, but it delegates everything to 
> setup.py.
>
> The remaining question is whether Leo needs setup.py at all.
>
> Edward
>

-- 
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/c5d866d3-83d3-45c6-9c8e-4c5f185a463fn%40googlegroups.com.


Re: Discuss: Release Leo only via GitHub?

2024-01-20 Thread Thomas Passin
I think that would be all right, although sometimes I have trouble finding 
the release files when I want to get an app from GitHub.  My main concern 
would be how to make it painless for a new user to get the dependencies 
installed.

On Saturday, January 20, 2024 at 2:14:18 PM UTC-5 Edward K. Ream wrote:

> I am at the end of my patience with PyPI :
>
>
> - The process is error-prone, as we have just seen.
>
> - PyPI is thwarting the upgrade of leo-6.7.7.tar.gz.
>
>   I don't know why. The error message seems wrong.
>
> - Even with help, 2-factor authentication is too complicated.
>
> - PyPI is designed for packages, not apps.
>
>
> Instead, I propose the following:
>
>
> - Release all new versions of Leo using GitHub releases 
> .
>
> - Release new versions at least once a year and more often as needed to 
> support LeoJS or LeoInteg.
>
>
> Your thoughts?
>
>
> Edward
>

-- 
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/01ce4f5e-02eb-466e-a073-59cc615730can%40googlegroups.com.


Re: Leo 6.7.7 released

2024-01-20 Thread Thomas Passin
All right, now the pip distro reports Leo 6.7.7.

BTW, pip won't upgrade an existing package to one of the same release.  
There's probably some better way, but I handled it by deleting 6.7.7 and 
its install directory from Python's site-packages directory (the one in the 
user's location if installed with --user).  After that, pip doesn't know 
that Leo 6.7.7 had ever been installed.

On Saturday, January 20, 2024 at 5:41:49 AM UTC-5 Edward K. Ream wrote:

> On Thursday, January 18, 2024 at 1:12:51 PM UTC-6 Edward K. Ream wrote:
>
> Leo https://leo-editor.github.io/leo-editor/ 6.7.7 is now available on 
> GitHub  and pypi 
> .
>
>
> The latest GitHub release 
>  corrects some 
> problems with the original release. The release is still called 6.7.7, but 
> it is now based on a different rev.
>
> Leo's PyPI page  now contains an 
> updated Python wheel, but I have not been able to update the .tar file. So 
> if you are building Leo from sources, you may want to change the reported 
> version from 6.7.8 to 6.7.7 :-)
>
> I plan no further work on 6.7.7. I'm hoping the 6.7.8 release process goes 
> a bit more smoothly.
>
> Please report any further release-related problems.
>
> Edward
>

-- 
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/49615cbf-b42d-48f9-8093-f3160e854094n%40googlegroups.com.


Re: Leo 6.7.7 released

2024-01-18 Thread Thomas Passin
After upgrading from PyPi, my copy claims it is Leo 6.7.8. Otherwise it 
seems normal but I've only had it open a few minutes.

On Thursday, January 18, 2024 at 2:12:51 PM UTC-5 Edward K. Ream wrote:

> Leo https://leo-editor.github.io/leo-editor/ 6.7.7 is now available on 
> GitHub  and pypi 
> .
>
>
> *The highlights of Leo 6.7.7*
>
>
> - PR #3761 : Improve 
> leoserver.py to support LeoInteg. Many thanks to Félix for this work.
>
>
> *Installation note*
>
>
> For this release, setup.py includes neither asttokens nor black in the 
> list of dependencies.
>
>
> This last-minute change was a hasty attempt to remove a Rust-related 
> folder from the distro. The proper fix was to remove the folder Doh!
>
>
> Happily, this panic should not affect LeoInteg.
>
>
> Edward
>

-- 
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/f2fd8f8a-4a09-44c8-86e9-ada4d986098dn%40googlegroups.com.


Re: Question about garbage collection

2024-01-16 Thread Thomas Passin via Python-list

On 1/16/2024 4:17 AM, Barry wrote:




On 16 Jan 2024, at 03:49, Thomas Passin via Python-list 
 wrote:

This kind of thing can happen with PyQt, also.  There are ways to minimize it 
but I don't know if you can ever be sure all Qt C++ objects will get deleted. 
It depends on the type of object and the circumstances.


When this has been seen in the past it has been promptly fixed by the 
maintainer.


The usual advice is to call deleteLater() on objects derived from PyQt 
classes.  I don't know enough about PyQt to know if this takes care of 
all dangling reference problems, though.


--
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3.12.1, Windows 11: shebang line #!/usr/bin/env python3 doesn't work any more

2024-01-15 Thread Thomas Passin via Python-list

On 1/15/2024 7:24 PM, Thomas Passin wrote:

On 1/15/2024 6:27 PM, Greg Ewing via Python-list wrote:

On 16/01/24 11:55 am, Mats Wichmann wrote:
Windows natively has something called python.exe and python3.exe 
which is interfering here


I'm wondering whether py.exe should be taught to recognise these stubs
and ignore them. This sounds like something that could trip a lot of
people up.


There are registry entries that say where all the python.org install 
locations are.  I suppose, but don't know, that py.exe checks them.  The 
registry entries are 
in Computer\HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore


For python.org installs that are installed for all users, the entries are in

Computer\HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore

--
https://mail.python.org/mailman/listinfo/python-list


Re: Question about garbage collection

2024-01-15 Thread Thomas Passin via Python-list

On 1/15/2024 9:47 PM, Akkana Peck via Python-list wrote:

I wrote:

Also be warned that some modules (particularly if they're based on libraries 
not written in Python) might not garbage collect, so you may need to use other 
methods of cleaning up after those objects.


Chris Angelico writes:

Got any examples of that?


The big one for me was gdk-pixbuf, part of GTK. When you do something like 
gtk.gdk.pixbuf_new_from_file(), there's a Python object that gets created, but 
there's also the underlying C code that allocates memory for the pixbuf. When 
the object went out of scope, the Python object was automatically garbage 
collected, but the pixbuf data leaked.


This kind of thing can happen with PyQt, also.  There are ways to 
minimize it but I don't know if you can ever be sure all Qt C++ objects 
will get deleted. It depends on the type of object and the circumstances.



Calling gc.collect() caused the pixbuf data to be garbage collected too.

There used to be a post explaining this on the pygtk mailing list: the link was
http://www.daa.com.au/pipermail/pygtk/2003-December/006499.html
but that page is gone now and I can't seem to find any other archives of that 
list (it's not on archive.org either). And this was from GTK2; I never checked 
whether the extra gc.collect() is still necessary in GTK3, but I figure leaving 
it in doesn't hurt anything. I use pixbufs in a tiled map application, so there 
are a lot of small pixbufs being repeatedly read and then deallocated.

 ...Akkana


--
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3.12.1, Windows 11: shebang line #!/usr/bin/env python3 doesn't work any more

2024-01-15 Thread Thomas Passin via Python-list

On 1/15/2024 6:27 PM, Greg Ewing via Python-list wrote:

On 16/01/24 11:55 am, Mats Wichmann wrote:
Windows natively has something called python.exe and python3.exe which 
is interfering here


I'm wondering whether py.exe should be taught to recognise these stubs
and ignore them. This sounds like something that could trip a lot of
people up.


There are registry entries that say where all the python.org install 
locations are.  I suppose, but don't know, that py.exe checks them.  The 
registry entries are inComputer\HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore


--
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3.12.1, Windows 11: shebang line #!/usr/bin/env python3 doesn't work any more

2024-01-15 Thread Thomas Passin via Python-list

On 1/15/2024 1:26 PM, Mats Wichmann via Python-list wrote:

On 1/15/24 09:44, Sibylle Koczian via Python-list wrote:


First and foremost I want to understand why I'm seeing this:

- Python scripts with "/usr/bin/env python3" as shebang line work as 
expected on a computer with Windows 10 and Python 3.11.5. They have 
worked for years on this machine, using either the latest Python or 
one version before (depending on availability of some packages). There 
is a virtual machine with ArchLinux on the same machine and some of 
the scripts are copies from that.


- I've got a second computer with Windows 11 and I installed Python 
3.12.1 on it. After copying some scripts from my first computer I 
found that I couldn't start them: not by entering the script name in a 
console, not using py.exe, not double clicking in the explorer. 
Entering \python  probably worked 
- I think I tried that too, but I'm not really sure, because that's 
really not practical.


In the Python documentation for versions 3.11 and 3.12 I found no 
differences regarding py.exe and shebang lines.


Then I removed the "/env" from the shebang lines and could start the 
scripts from the second computer. That certainly is a solution, but 
why???


It's because of Windows itself.  The default nowadays is that irritating 
little stub that prompts you to go install Python from the WIndows 
store.  When you use the "env" form, it looks for python (or python3 in 
your case) in the PATH *first* and you'll get a hit.   Mine looks like:


C:\Users\mats\AppData\Local\Microsoft\WindwsApps\python.exe and python3.exe

you can check what it's doing for you by using the "where" command in a 
windows shell.


On your older Windows 10 machine you either never had that stub - I 
don't know when it was added, maybe someone from Microsoft listening 
here knows - or it's been superseded by changes to the PATH, or 
something.  On my fairly new Win 11 box the base of that path is early 
in the user portion of PATH, so that must be a default.


py.exe without the "/usr/bin/env" magic doesn't put PATH searching 
first, according to that snip from the docs that's been posted here 
several times., so you shouldn't fall down that particular rathole.


Python from the App Store is not the same as Python from python.org:

"The Microsoft Store package is a simple installation of Python that is 
suitable for running scripts and packages, and using IDLE or other 
development environments. It requires Windows 10 and above, but can be 
safely installed without corrupting other programs. It also provides 
many convenient commands for launching Python and its tools."


- https://docs.python.org/3/using/windows.html

Also:

"The Windows Store distribution of Python is a sandboxed application ... 
The internal components of Windows Store apps are protected from being 
accessed from other applications, and so the PyXLL add-in cannot use the 
Python DLLs and packages that are installed as part of the Windows Store 
Python app."


From the PyXLL support site -

https://support.pyxll.com/hc/en-gb/articles/4417634326675-Python-installed-via-the-Windows-Store-cannot-be-used-with-PyXLL

The "py" launcher is installed by the installer from python.org.




--
https://mail.python.org/mailman/listinfo/python-list


Re: LLMs as Collaborators

2024-01-14 Thread Thomas Passin
Thanks, I didn't know about polars!

On Sunday, January 14, 2024 at 11:37:13 PM UTC-5 iamap...@gmail.com wrote:

> Jon Udell continues to learn how to make use of LLMs -
>> 7 Guiding Principles for Working with LLMs 
>> 
>>
> These tips are very useful.
>
> As I continue to use it, I find that LLMs can easily help me learn the 
> contents of the library. For example, yesterday I wanted to learn about 
> https://github.com/pola-rs/polars and let it help me list the 
> characteristics and examples of this library. , and compare the differences 
> between its operations and pandas. Although I can't write it out quickly, I 
> think I basically understand it.
>

-- 
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/fa49982f-ee2c-4fc6-99c7-bdf9121df554n%40googlegroups.com.


Re: LLMs as Collaborators

2024-01-14 Thread Thomas Passin
Jon Udell continues to learn how to make use of LLMs -
7 Guiding Principles for Working with LLMs 
<https://thenewstack.io/7-guiding-principles-for-working-with-llms/>
It's starting to look useful ...

On Tuesday, November 7, 2023 at 12:15:31 AM UTC-5 Thomas Passin wrote:

> Here's another installment of Jon Udell's LLM chat experiments -
> Let’s Talk: Conversational Software Development 
> <https://thenewstack.io/lets-talk-conversational-software-development/>
>
> On Friday, September 8, 2023 at 9:46:36 PM UTC-4 iamap...@gmail.com wrote:
>
>> Learning While Coding: How LLMs Teach You Implicitly 
>> <https://thenewstack.io/learning-while-coding-how-llms-teach-you-implicitly/>
>>
>> Very interesting, I like it. thanks for sharing!
>>
>> Here is the list of posts for someone who want read more :D
>>
>> https://blog.jonudell.net/2023/09/07/how-llms-teach-you-things-you-didnt-know-you-didnt-know/
>>  
>>
>

-- 
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/63023754-146c-4881-b303-1efbad6e5e9fn%40googlegroups.com.


Re: Python 3.12.1, Windows 11: shebang line #!/usr/bin/env python3 doesn't work any more

2024-01-14 Thread Thomas Passin via Python-list

On 1/14/2024 8:54 AM, Thomas Passin via Python-list wrote:

On 1/14/2024 7:48 AM, Sibylle Koczian via Python-list wrote:

Am 09.01.2024 um 12:36 schrieb Barry Scott via Python-list:



On 7 Jan 2024, at 15:09, Sibylle Koczian via Python-list 
 wrote:


Oh, and the two Windows and Python versions are on two different 
computers.


Will remove the "/env" from my shebang lines, even if I don't 
understand what's happening.


Thanks for the details.

Only thing I can think of is that "python" may be defaulting to mean 
python 2.

If you use "#!/usr/bin/env python3" it may work on both.


No, it doesn't. That's the form I started with. When it didn't work I 
thought "python3" might be too old, because Python 2 is dead for so long.


Did you creates a py.ini file to configure py.exe?

See if you have %userappdata%\py.ini on either windows 10 or windows 11.
If so what is its contents?


No to both.


I've tried with and without a py.ini and cannot duplicate what you see.



It really seems strange. Only thing I can think of - and I don't 
really believe in that idea: as far as I know in Windows 11 the 
handling of PATH has changed. My Python isn't on the path, perhaps 
that is it. A shebang line without "/env" doesn't check the path, right?


 From what I've read recently, if you have a Python program that starts 
with a shebang line with any of four standard unix-like paths, then 
Python (not Windows) will look for a version of Python in standard 
locations - *NOT* in the shebang line locations:


I meant to write "the Python launcher", that is, the "py" program. 
Normal Python installs on Windows install the launcher and Windows will 
run it on ".py" files if no other program has been specified on the 
command line.


"To allow shebang lines in Python scripts to be portable between Unix 
and Windows, this launcher supports a number of ‘virtual’ commands to 
specify which interpreter to use. The supported virtual commands are:


/usr/bin/env
/usr/bin/python
/usr/local/bin/python
python
"

Also -
"The /usr/bin/env form of shebang line has one further special property. 
Before looking for installed Python interpreters, this form will search 
the executable PATH for a Python executable matching the name provided 
as the first argument. This corresponds to the behaviour of the Unix env 
program, which performs a PATH search. If an executable matching the 
first argument after the env command cannot be found, but the argument 
starts with python, it will be handled as described for the other 
virtual commands.

"

There are some other complications, too, depending on whether you 
specify bare "python" or some specific version. The form with 
"/usr/bin/env" is the closest to the unix behavior, in that it searches 
the PATH.  And you write that your intended version of Python is not on 
the path.


IOW, these shebang lines don't work the way you seem to think that they do.

See https://docs.python.org/3/using/windows.html for a more complete 
rundown.


--
https://mail.python.org/mailman/listinfo/python-list


<    1   2   3   4   5   6   7   8   9   10   >