omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular
    1. Home
    2. tguillemin

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    • Profile
    • Following 0
    • Followers 0
    • Topics 14
    • Posts 36
    • Best 2
    • Controversial 0
    • Groups 0

    tguillemin

    @tguillemin

    2
    Reputation
    1392
    Profile views
    36
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    tguillemin Unfollow Follow

    Best posts made by tguillemin

    • About placeholder labels' position

      I encounter 2 different placeholder labels' position :

      • in lieu of the folded lines, i.e. under the "folding" header
      • at the end of the "folding" header

      This second type seems to have 2 advantages : it is more compact, and it allows to move up/down the block (header and folded lines) in one step.

      Is it possible to choose between those 2 configurations ?

      Thanks

      posted in Editorial
      tguillemin
      tguillemin
    • Workflow to fold all & unfold specific headers (with their contents) ?

      I want to build a workflow to fold/unfold not lines, but specific headers and their contents, and I do not know how to proceed.(I suppose iwhat action ? what Regex ?). Of course I know how to do that manually…

      I have a text, e.g. :

      #Chapter one (@tag1, @tag2)
      
      some text
      some other text
      
      #Chapter two (@tag2, @tag3)
      
      foo
      ber
      baz
      
      #Chapter three (@tag1, @tag3)
      
      London
      Paris
      Berlin
      
      #Chapter four (@tag2, @tag4)
      
      something
      anything
      

      I want to select the, e.g. @tag1 headers and unfold these and these only, so as to have :

      #Chapter one (@tag1, @tag2)
      
      some text
      some other text
      
      [number of hidden words]
      
      #Chapter three (@tag1, @tag3)
      
      London
      Paris
      Berlin
      
      [number of hidden words]
      

      How should I proceed ?

      Thanks in advance

      posted in Editorial
      tguillemin
      tguillemin

    Latest posts made by tguillemin

    • RE: Problem with Find/Replace regex : \n (newline) and \b (boundary) ignored

      First of all, thank you very much for your answer.

      Three remarks

      1. I am a Python newbie… How do I insert this in a workflow ? Through "RunPython script", I suppose (coming after an "Extend Selection" to the whole document ?), but how ?

      2. How come a sequence \b\n\b in Find and a space in Replace does not work, although it works perfectly well in Regex101 ?
        Could it be a bug ? I doubt it. I most certainly make a mistake, but where ?

      3. I do not (entirely) share your condemnation of Regexes, but, as you know, nobody is perfect…

      Thanks again

      posted in Editorial
      tguillemin
      tguillemin
    • Problem with Find/Replace regex : \n (newline) and \b (boundary) ignored

      I have the following text :

      Paragraph1
      
      Paragraph2
      Paragraph2
      Paragraph2
      Paragraph2
      
      Paragraph3
      Paragraph3
      
      Paragraph4```
      

      I want to merge the lines of each paragraph, in order to get :

      Paragraph1
      
      Paragraph2 Paragraph2 Paragraph2 Paragraph2
      
      Paragraph3 Paragraph3
      
      Paragraph4 
      

      Thanks to Stackoverflow, I found a solution which passes the Regex101 test

      But I cannot make it work in Editorial's Find/Replace (and I did not forget to choose Regular Expression…)

      What do I get wrong ?

      posted in Editorial
      tguillemin
      tguillemin
    • RE: Problem with a Python script to count number of lines containing a word

      Thank you very much for your answer and, may I add, thank you very much for this indispensable app (together with Pythonista, of course…)

      posted in Editorial
      tguillemin
      tguillemin
    • Problem with a Python script to count number of lines containing a word

      I have the following text :

      Paris Rome
      London Berlin
      London Rome
      Paris Berlin Berlin
      Rome London
      Berlin Madrid
      paris Madrid

      I wish to count the number of lines containing London (3 lines)

      I run the following workflow

      [http://www.editorial-workflows.com/workflow/5858062694875136/Sy1_sF8-Vbs](link url)

      which gives me the answer "The word London occurs in 0 lines" (but the highlighting on the contrary is correct)

      The explanation is most certainly evident, but I cannot find it…

      Where did I go wrong ?

      Thanks in advance

      posted in Editorial
      tguillemin
      tguillemin
    • RE: From a Pythonista sqlite script, how to open somefile.db in Dropbox ?

      @cvp : I finally went for the iCloud solution, and, after copying the database in the Pythonista3 folder, inserted in my script :

      conn = sqlite3.connect('/private/var/mobile/Library/Mobile Documents/iCloud~com~omz-software~Pythonista3/Hist.db')
      

      and it worked, albeit with a few preliminary quirks ("No such table", and later "No such column"…)

      Thank you very much for your help

      posted in Pythonista
      tguillemin
      tguillemin
    • RE: From a Pythonista sqlite script, how to open somefile.db in Dropbox ?

      @cvp : Thanks again

      I finally succeeded. Sort of…

      I proceeded as indicated, was taken to my script, ran it and got the data I was looking for.
      But :

      a) this occurred in a light mode version of my script, although I have adopted the night mode in Pythonista

      b) when I tried to run the script by opening Pythonista as usual, I got an error ("argument 1 must be str, not None")

      c) I then tried something else : I imported the db file in my Pythonista SQLite folder. But when I tried to retrieve data in it, came an error "there is no such table as data", although this table had been acknowledged in the attempt a)

      It seems I do not grok the process. Furthermore I do not understand why it is impossible to establish a permanent link between a Pythonista script and a file in Dropbox.
      Would it be different in iCloud Drive ?

      posted in Pythonista
      tguillemin
      tguillemin
    • RE: From a Pythonista sqlite script, how to open somefile.db in Dropbox ?

      @cvp : First of all, thank you for your answer. But I seem to be doing it all wrong…

      1. in my Pythonista script "SQLiteHist.py" (it is a simple tool for a chronology database), I added : import appex. I understand I shall have to insert a appex.get_file_path() line in my script

      2. Then I went to my Files app/Dropbox (btw I am on iPhone 7 plus) :

      • I selected the Hist.db (the aforementioned chronology database)

      • I pressed until appeared the menu (Copy…Duplicate…etc…Share)

      • I then selected Share, which brought me to the Share Menu…

      • …where I selected Run Pythonista script

      • I did not have the possibility to choose my SQLiteHist.py script : the process started downloading the file (endlessy), and I canceled it

      • To sum it up I could not select my script, thus it did not receive any link to my db file

      Sorry to be so awkwardly precise.

      Where did I go wrong ?

      posted in Pythonista
      tguillemin
      tguillemin
    • From a Pythonista sqlite script, how to open somefile.db in Dropbox ?

      I have created a sqlite script in Pythonista, and I wish to insert/update/append/delete/retrieve data stocked in an existing .db file which is in my Dropbox account.

      If I try to use the EXTERNAL FILES/Open…, I can see my file, but I am unable to open it.

      So, for the time being, I am obliged to re-create that file inside Pythonista…

      How should I proceed ?
      And if it is possible what path should I indicate ? I tried :

      conn = sqlite3.connect('Dropbox/somefile.db')
      

      and, of course, it did not work ("unable to open database file").

      Thanks in advance```

      posted in Pythonista
      tguillemin
      tguillemin
    • Help needed to improve a small RSS reader script

      In order to have a river-style (Dave Winer) feed about book reviews in some great newspapers (NYT, The Economist, Le Monde, Japan Times), I created a RSSMix feed of the 4 and "borrowed" a script from : [http://www.idiotinside.com/2017/06/08/parse-rss-feed-with-python/](Parse RSS feed with Python)

      Here is the script :

      # coding: utf-8
      
      import os
      import sys
      import feedparser
      import console
      
      #source : http://www.idiotinside.com/2017/06/08/parse-rss-feed-with-python/
      
      feedparser._HTMLSanitizer.acceptable_elements.update(['iframe'])
      
      feed = feedparser.parse("http://www.rssmix.com/u/8265752/rss.xml")
      # RSSmix of Books reviews from : NYT, TE, LM, JT
      
      feed_title = feed['feed']['title']
      feed_entries = feed.entries
      
      for entry in feed.entries:
      	article_title = entry.title
      	article_link = entry.link
      	article_published_at = entry.published # Unicode string
      	article_published_at_parsed = entry.published_parsed # Time object
      	article_description = entry.description
      	article_summary = entry.summary
      	#article_tags = entry.tags.label    <--------- PB
      	
      	console.set_color(0,1,0)
      	print ("{}".format(article_title))
      	console.set_color(1,1,1)
      	print ("{}".format(article_published_at))
      	console.set_color(0,0.75,1)
      	print ("{}".format(article_link))
      	console.set_color(1,1,1)
      	print ("{}".format(article_summary))
      	#print ("{}".format(article_tags))   <--------- PB
      	print (" ")
      	print ("....................")
      	print (" ")
      	
      file_name = os.path.basename(sys.argv[0])
      print(file_name)
      

      All in all, it works.
      I nevertheless encounter a few problems :

      • I would like to position the page at the most recent feed (top of the output), whereas the script positions it at the bottom
      • I cannot figure out how to grab the entries' tags which would allow me to "filter" some entries
      • It seems that the output keeps on growing… How do I eliminate entries e.g. older than 30 days ?

      Thanks in advance for your help.

      posted in Pythonista
      tguillemin
      tguillemin
    • RE: How to capture the line before a regex match ?

      @dgelessus : Thank you for your answer. which is what I had (approximately) figured.

      How is it possible to make to @olemoritz the suggestion/request/wish to "unleash" the power of regex in that specific action (and elsewhere, of course, if needed) ?

      This would make the irreplaceable Editorial even better.

      Thanks again

      posted in Editorial
      tguillemin
      tguillemin