• comfortablynick

    @SmartGoat said:

    1. Is Working Copy able to detect iCloud Drive files changes to commit it in github ?

    Yes, that feature has been added.

    1. if yes, why not putting your Pythonista files directly in the iCloud Drive folder of Pythonista ?

    That is an option, one that I intend to use at some point. I'm using it currently for Scriptable, and it works great. I can edit a Scriptable script on my iPhone, then I open up Working Copy on my iPad (where I set up the sync) and see the change ready to be committed.

    One reason why (2) isn't a complete solution, is that Pythonista doesn't see iCloud in PYTHONPATH. In order to add user-defined modules, I believe they have to go in one of the site-packages directories in the device file system. But for version control of most scripts in Pythonista, the Working Copy sync function should work well with the Pythonista iCloud folder.

    posted in Pythonista read more
  • comfortablynick

    This would be really useful. Now that Working Copy can sync files from iCloud Drive, my dream would be to someday have all of my Pythonista files in Git.

    posted in Pythonista read more
  • comfortablynick

    I would use the Google Sheets Python API. They have a QuickStart example. I haven't done a script for Sheets in Pythonista, but I have done one for Gmail and it worked fine.

    posted in Pythonista read more
  • comfortablynick

    I was wondering the same thing, and I finally got this working. I think the problem was with the attrs package. One of the errors made it look like I needed attr (no 's'), but that is a different unrelated package.

    I installed black with Stash pip, as well as attrs and any other package it needed, until I could run black.py without errors.

    I put together this little script to format a document in the editor. I'm sure there's a better way to do it, but this seems to work beautifully when added to the tools menu in Pythonista.

    #!/usr/bin/env python3
    """Format editor contents/selection in Pythonista with Black formatter."""
    import editor
    import black
    import console
    import time
    
    # Options
    LINE_LEN = 88  # Default: 88
    FAST = False  # True = skip syntax check
    
    # Get text and selection
    text = editor.get_text()
    start, end = editor.get_selection()
    selection = text[start:end]
    
    if len(selection) > 0:
        raw_text = selection
    else:
        raw_text = text
    
    try:
        start_tm = time.time()
        formatted = black.format_file_contents(
            raw_text, line_length=LINE_LEN, fast=int(FAST)
        )
    except black.NothingChanged:
        console.hud_alert(
            f"No formatting needed! ({time.time() - start_tm:.4f}s)", "success"
        )
    except Exception as err:
        console.hud_alert(err, "error")
    else:
        new_text = formatted[:-1]
        if len(selection) > 0:
            editor.replace_text(start, end, new_text)
            editor.set_selection(start, start + len(new_text))
        else:
            editor.replace_text(0, len(text), new_text)
            editor.set_selection(start, end)
        console.hud_alert(
            f"Reformatted! ({time.time() - start_tm:.4f}s)", "success")
    

    posted in Pythonista read more
  • comfortablynick

    Sounds like a cool idea; I would love to participate in any way I can.

    posted in Pythonista read more
  • comfortablynick

    @JonB said:

    The app was never promised regular updates. It works out of the box to do what it promises to do, and offers a lot of customizability to have it do what you want.

    Well, every app needs regular updates. Most devs have to make tweaks at least with each major iOS version. Then there are changes needed due to new hardware, etc. I'm sure some users will hold off on pulling the trigger on a somewhat pricy app if they see it's not being updated regularly.

    I was looking to get Editorial, but it's been even longer since it has seen an update. There's no way I'm going to pay for an app that hasn't even been updated for the iPhone X screen.

    I hope he does open source Pythonista if he's no longer interested in maintaining it. A great app like this needs to stay at the head of the pack. I'm seeing updates of other scripting apps integrating directly with Siri Shortcuts, and it just reminds me of how awesome it would be to do that with Python instead of JavaScript.

    posted in Pythonista read more
  • comfortablynick

    I would also happily pay for a subscription if that helps us get more active development. It would be a shame to have such a wonderful app not be kept up to date. I usually wouldn't even purchase an app that hasn't been updated in 9 months.

    It's nice to see other apps tightly integrating with Shortcuts (Scriptable is a promising app, and Drafts also does well at this). I would much rather automate things with Python than JavaScript. I hope Pythonista eventually gets full x-callback-url support so it can be used more in that regard.

    posted in Pythonista read more
  • comfortablynick

    This issue is really annoying me. Oddly enough, it works 100% of the time on my iPad. On my iPhone, however, functions using appex from Safari only work ~25% of the time. It doesn't matter whether I try to get the URL or web page data directly.

    Is there anything I can do to make this work on the iPhone the way it does on the iPad?

    Here's an example of a general script I use to see what comes through the share sheet:

    import appex
    from bs4 import BeautifulSoup
    
    
    def main():
        if appex.is_running_extension():
            print(f'# APPEX DATA #\n{"=" * 15}\n')
            methods = [
                method for method in dir(appex)
                if callable(getattr(appex, method)) and
                method.startswith('get') and method != 'get_input'
            ]
            for method in methods:
                result = getattr(appex, method)()
                name = method.partition("_")[2]
                if result:
                    print(f'{name}\n{"-"*15}')
                    if name == 'web_page_info':
                        for k, v in result.items():
                            if k == 'html':
                                soup = BeautifulSoup(v, 'html.parser')
                                v = soup.prettify()
                            print(f'{k}: {v}')
                        print('\n')
                    else:
                        print(f'{result}\n\n')
        else:
            raise ReferenceError(
                'Requires appex: (must be run from iOS share sheet!)')
    
    
    if __name__ == '__main__':
        main()

    posted in Pythonista read more
  • comfortablynick

    I love being able to use Working Copy and Pythonista together. Is there any way to execute scripts from Working Copy via appex or callback URL (e.g., from Workflow)?

    It's great that we can open the scripts from Working Copy, but it would be a lot more useful if we could execute them without saving a local copy in Pythonista.

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!