omz:forum

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

    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 1
    • Posts 2
    • Best 2
    • Controversial 0
    • Groups 0

    pat31700

    @pat31700

    7
    Reputation
    877
    Profile views
    2
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    pat31700 Unfollow Follow

    Best posts made by pat31700

    • Script to import any file in Pythonista from any app

      To send any file to Pythonista, select sahre and "Run Pythonista Script"

      Then use this script below in Pythonista (you need to add it as an extension) to save any file from "run Pythonista Script" share method ... works with any file type .py .zip etc.

      All imported file are store in a directory "inbox" in Pythonista

      # coding: utf-8
      
      import appex
      import clipboard
      import console
      import shutil
      import os
      
      def getuniquename(filename, ext):
      	root, extension = os.path.splitext(filename)
      	if ext!='':
      		extension = ext
      	filename = root + extension
      	filenum = 1
      	while os.path.isfile(filename):
      		filename = '{} {}{}'.format(root, filenum, extension)
      		filenum += 1
      	return filename
      
      def main():
      	console.clear()
      	dest_path_short = '~/Documents/inbox'
      	dest_path = os.path.expanduser(dest_path_short)
      	if not os.path.isdir(dest_path):
      		print('Create ' + dest_path_short)
      		os.mkdir(dest_path)	
      	if not appex.is_running_extension():
      		print('Using clipboard content...')
      		text = clipboard.get()
      		assert text, 'No text on the clipboard!'
      		resp = console.alert('Alert!', 'Choose File Extension', '.py', '.pyui', hide_cancel_button=False)
      		if resp==1:
      			ext = '.py'
      		elif resp==2:
      			ext = '.pyui'
      		filename=os.path.join(dest_path,'clipboard')
      		filename=getuniquename(filename,ext)
      		while os.path.isfile(filename):
      			filename = '{} {}{}'.format(root, filenum, extension)
      			filenum += 1
      		with open(filename,'w') as f:
      			f.write(text)
      		print('Done!')		
      	else:
      		file = appex.get_file_path()	
      		print('Input path: %s' % file)
      		filename=os.path.join(dest_path, os.path.basename(file))
      		filename=getuniquename(filename,'')
      		shutil.copy(file,filename)
      	print('Saved in %s' % dest_path_short)
      	if not os.path.exists(filename):
      		print(' > Error file %s not found !' % os.path.basename(filename))
      	else:
      		print(' > as %s' % os.path.basename(filename))
      
      if __name__ == '__main__':
      	main()
      
      
      posted in Pythonista
      pat31700
      pat31700
    • RE: How do I transfer code, such as PC to IPad?

      Use "File Transfer" app to transfer file between devices.
      To send a script to "File Transfer" from Pythonista use "Share" and "Open In" to import in File transfer.
      To open a script from "File Transfer" to Pythonista, use "To other app" in "File Transfer" and on the bottom list select "Run Pythonista Script"

      Then use this script in Pythonista to save any file from the previous "run Pythonista Script"

      # coding: utf-8
      
      import appex
      import clipboard
      import console
      import shutil
      import os
      
      def getuniquename(filename, ext):
      	root, extension = os.path.splitext(filename)
      	if ext!='':
      		extension = ext
      	filename = root + extension
      	filenum = 1
      	while os.path.isfile(filename):
      		filename = '{} {}{}'.format(root, filenum, extension)
      		filenum += 1
      	return filename
      
      def main():
      	console.clear()
      	dest_path_short = '~/Documents/inbox'
      	dest_path = os.path.expanduser(dest_path_short)
      	if not os.path.isdir(dest_path):
      		print('Create ' + dest_path_short)
      		os.mkdir(dest_path)	
      	if not appex.is_running_extension():
      		print('Using clipboard content...')
      		text = clipboard.get()
      		assert text, 'No text on the clipboard!'
      		resp = console.alert('Alert!', 'Choose File Extension', '.py', '.pyui', hide_cancel_button=False)
      		if resp==1:
      			ext = '.py'
      		elif resp==2:
      			ext = '.pyui'
      		filename=os.path.join(dest_path,'clipboard')
      		filename=getuniquename(filename,ext)
      		while os.path.isfile(filename):
      			filename = '{} {}{}'.format(root, filenum, extension)
      			filenum += 1
      		with open(filename,'w') as f:
      			f.write(text)
      		print('Done!')		
      	else:
      		file = appex.get_file_path()	
      		print('Input path: %s' % file)
      		filename=os.path.join(dest_path, os.path.basename(file))
      		filename=getuniquename(filename,'')
      		shutil.copy(file,filename)
      	print('Saved in %s' % dest_path_short)
      	if not os.path.exists(filename):
      		print(' > Error file %s not found !' % os.path.basename(filename))
      	else:
      		print(' > as %s' % os.path.basename(filename))
      
      if __name__ == '__main__':
      	main()
      
      
      posted in Pythonista
      pat31700
      pat31700

    Latest posts made by pat31700

    • Script to import any file in Pythonista from any app

      To send any file to Pythonista, select sahre and "Run Pythonista Script"

      Then use this script below in Pythonista (you need to add it as an extension) to save any file from "run Pythonista Script" share method ... works with any file type .py .zip etc.

      All imported file are store in a directory "inbox" in Pythonista

      # coding: utf-8
      
      import appex
      import clipboard
      import console
      import shutil
      import os
      
      def getuniquename(filename, ext):
      	root, extension = os.path.splitext(filename)
      	if ext!='':
      		extension = ext
      	filename = root + extension
      	filenum = 1
      	while os.path.isfile(filename):
      		filename = '{} {}{}'.format(root, filenum, extension)
      		filenum += 1
      	return filename
      
      def main():
      	console.clear()
      	dest_path_short = '~/Documents/inbox'
      	dest_path = os.path.expanduser(dest_path_short)
      	if not os.path.isdir(dest_path):
      		print('Create ' + dest_path_short)
      		os.mkdir(dest_path)	
      	if not appex.is_running_extension():
      		print('Using clipboard content...')
      		text = clipboard.get()
      		assert text, 'No text on the clipboard!'
      		resp = console.alert('Alert!', 'Choose File Extension', '.py', '.pyui', hide_cancel_button=False)
      		if resp==1:
      			ext = '.py'
      		elif resp==2:
      			ext = '.pyui'
      		filename=os.path.join(dest_path,'clipboard')
      		filename=getuniquename(filename,ext)
      		while os.path.isfile(filename):
      			filename = '{} {}{}'.format(root, filenum, extension)
      			filenum += 1
      		with open(filename,'w') as f:
      			f.write(text)
      		print('Done!')		
      	else:
      		file = appex.get_file_path()	
      		print('Input path: %s' % file)
      		filename=os.path.join(dest_path, os.path.basename(file))
      		filename=getuniquename(filename,'')
      		shutil.copy(file,filename)
      	print('Saved in %s' % dest_path_short)
      	if not os.path.exists(filename):
      		print(' > Error file %s not found !' % os.path.basename(filename))
      	else:
      		print(' > as %s' % os.path.basename(filename))
      
      if __name__ == '__main__':
      	main()
      
      
      posted in Pythonista
      pat31700
      pat31700
    • RE: How do I transfer code, such as PC to IPad?

      Use "File Transfer" app to transfer file between devices.
      To send a script to "File Transfer" from Pythonista use "Share" and "Open In" to import in File transfer.
      To open a script from "File Transfer" to Pythonista, use "To other app" in "File Transfer" and on the bottom list select "Run Pythonista Script"

      Then use this script in Pythonista to save any file from the previous "run Pythonista Script"

      # coding: utf-8
      
      import appex
      import clipboard
      import console
      import shutil
      import os
      
      def getuniquename(filename, ext):
      	root, extension = os.path.splitext(filename)
      	if ext!='':
      		extension = ext
      	filename = root + extension
      	filenum = 1
      	while os.path.isfile(filename):
      		filename = '{} {}{}'.format(root, filenum, extension)
      		filenum += 1
      	return filename
      
      def main():
      	console.clear()
      	dest_path_short = '~/Documents/inbox'
      	dest_path = os.path.expanduser(dest_path_short)
      	if not os.path.isdir(dest_path):
      		print('Create ' + dest_path_short)
      		os.mkdir(dest_path)	
      	if not appex.is_running_extension():
      		print('Using clipboard content...')
      		text = clipboard.get()
      		assert text, 'No text on the clipboard!'
      		resp = console.alert('Alert!', 'Choose File Extension', '.py', '.pyui', hide_cancel_button=False)
      		if resp==1:
      			ext = '.py'
      		elif resp==2:
      			ext = '.pyui'
      		filename=os.path.join(dest_path,'clipboard')
      		filename=getuniquename(filename,ext)
      		while os.path.isfile(filename):
      			filename = '{} {}{}'.format(root, filenum, extension)
      			filenum += 1
      		with open(filename,'w') as f:
      			f.write(text)
      		print('Done!')		
      	else:
      		file = appex.get_file_path()	
      		print('Input path: %s' % file)
      		filename=os.path.join(dest_path, os.path.basename(file))
      		filename=getuniquename(filename,'')
      		shutil.copy(file,filename)
      	print('Saved in %s' % dest_path_short)
      	if not os.path.exists(filename):
      		print(' > Error file %s not found !' % os.path.basename(filename))
      	else:
      		print(' > as %s' % os.path.basename(filename))
      
      if __name__ == '__main__':
      	main()
      
      
      posted in Pythonista
      pat31700
      pat31700