Skip to content
Permalink
Browse files

init

  • Loading branch information...
russianidiot
russianidiot committed Oct 18, 2015
0 parents commit 33455e1a42f5c3a0361b4f1e5c6952ed8574f0fe
Showing with 920 additions and 0 deletions.
  1. +9 −0 Examples/osascript(source=None,flags=None,argument=None)/osascript("return \"message\"")
  2. +31 −0 MANIFEST.in
  3. +75 −0 README.md
  4. +35 −0 README.rst
  5. +5 −0 README/usage.md
  6. +5 −0 README/usage.rst
  7. +4 −0 WEBLOC/open .
  8. +8 −0 WEBLOC/osascript(1) Mac OS X Manual Page.webloc
  9. +6 −0 classifiers.txt
  10. +1 −0 description
  11. +1 −0 keywords.txt
  12. +52 −0 py_modules/osascript.py
  13. +7 −0 requirements.txt
  14. +23 −0 setup.py/.author.py
  15. +28 −0 setup.py/.bugtrack_url.py
  16. +38 −0 setup.py/.classifiers.py
  17. +23 −0 setup.py/.dependency_links.py
  18. +17 −0 setup.py/.description.py
  19. +19 −0 setup.py/.entry_points.py
  20. +28 −0 setup.py/.install_requires.py
  21. +18 −0 setup.py/.keywords.py
  22. +19 −0 setup.py/.long_description.py
  23. +27 −0 setup.py/.packages.py
  24. +18 −0 setup.py/.platforms.py
  25. +23 −0 setup.py/.py_modules.py
  26. +23 −0 setup.py/.pypi.command
  27. +25 −0 setup.py/.scripts.py
  28. +21 −0 setup.py/.setup.py develop.command
  29. +21 −0 setup.py/.setup.py install.command
  30. +21 −0 setup.py/.setup.py register.command
  31. +21 −0 setup.py/.setup.py sdist upload.command
  32. +28 −0 setup.py/.url.py
  33. +18 −0 setup.py/.version.py
  34. +3 −0 setup.py/__init__.py
  35. +72 −0 setup.py/__main__.py
  36. +10 −0 tests/.nosetests.command
  37. +15 −0 tests/.shell.command
  38. 0 tests/__init__.py
  39. +24 −0 tests/__main__/test_main.sh
  40. +19 −0 tests/examples/test_examples.sh
  41. +21 −0 tests/import/test_main.sh
  42. +21 −0 tests/osascript(applescript_or_file,flags=None)
  43. +17 −0 tests/sudo(command)
  44. +19 −0 tox.ini
  45. +1 −0 version.txt
@@ -0,0 +1,9 @@
#!/usr/bin/env python
from osascript import *

def main():
returncode,stdout,stderr = osascript("return \"message\"")
print(stdout)

if __name__=="__main__":
main()
@@ -0,0 +1,31 @@
# http://docs.python.org/2/distutils/sourcedist.html#the-manifest-in-template

# LICENSE*, README*, description NOT required
exclude description
exclude LICENSE*
exclude README*

# .entry_points
include .entry_points.txt entry_points.txt

# install_requires
include requirements.txt install_requires.txt

# packages
include .packages.txt packages.txt

# py_modules
include py_modules*/*.py .py_modules.txt py_modules.txt

# scripts
include scripts*/*.py .scripts.txt scripts.txt

# version.txt
include version.txt

include examples.py/*, Examples.py/*

include setup.py/*.py

include tests/*, Tests/*, test/*, Test/*

@@ -0,0 +1,75 @@
<p align="center">
<b>osascript(1) (AppleScript) python implementation (OS X)</b>
</p>

<p>
<a href="https://travis-ci.org/russianidiot/osascript.py" class="reference external">
<img src="https://travis-ci.org/russianidiot/osascript.py.svg?branch=master" alt="Build Status">
</a>
<!--
<a href="https://codecov.io/github/russianidiot/osascript.py/">
<img src="https://img.shields.io/codecov/c/github/russianidiot/osascript.py.svg" alt="Codecov">
</a>
-->
</p>
<p>
<a href="http://badge.fury.io/py/osascript" class="reference external">
<img src="https://badge.fury.io/py/osascript.svg" alt="PyPI version">
</a>
<a href="https://pypi.python.org/pypi/osascript">
<img src="https://img.shields.io/pypi/pyversions/osascript.svg" alt="PyPI">
</a>

</p>


Install
-------

[github.com](http://github.com/russianidiot/osascript.py):
`pip install git+git://github.com/russianidiot/osascript.py.git`

[pypi.python.org](https://pypi.python.org): `pip install osascript`

[download](https://github.com/russianidiot/osascript.py/archive/master.zip): `python setup.py install` or `setup.py/.setup.py develop.command`





Usage
=====
```
from osascript import *
returncode,stdout,stderr = osascript('return "message"')
```

---

**Tested**: python 2.6, 2.7, 3+

---

<p align="center">
my Python packages
<a href="http://russianidiot.github.io/python/packages">russianidiot.github.io/python/packages</a> <img src="http://russianidiot.github.io/images/python/16.png" />
</p>
<p align="center">
my Python repos <a href="http://russianidiot.github.io/python/">russianidiot.github.io/python/</a>
<img src="http://russianidiot.github.io/images/python/16.png" />
</p>

<p align="center">
all repos <a href="http://russianidiot.github.io/">russianidiot.github.io</a> <img src="http://russianidiot.github.io/images/star/16.png" />
</p>

<p align="center">
README.md generated with <a href="https://github.com/russianidiot/README.mako.py.automation">README.mako.py.automation</a> + <a href="https://github.com/russianidiot/.README.mako">.README.mako</a>
<img src="http://russianidiot.github.io/images/book/16.png">
</p>

<p align="center">
follow me <a href="http://github.com/russianidiot">github.com/russianidiot</a>
<img src="http://russianidiot.github.io/images/github/16.png" />
</p>
@@ -0,0 +1,35 @@

Install
'''''''

github.com_: :code:`pip install git+git://github.com/russianidiot/osascript.py.git`

pypi.python.org_: :code:`pip install osascript`

download_: :code:`python setup.py install` or :code:`setup.py/.setup.py develop.command`

.. _github.com: http://github.com/russianidiot/osascript.py
.. _pypi.python.org: https://pypi.python.org/pypi/osascript
.. _download: https://github.com/russianidiot/osascript.py/archive/master.zip







Usage
'''''
.. code-block::

from osascript import *

returncode,stdout,stderr = osascript('return "message"')

------------

**Tested**: python 2.6, 2.7, 3+

**Bug Tracker**: `github.com/russianidiot/osascript.py/issues`__

__ https://github.com/russianidiot/osascript.py/issues
@@ -0,0 +1,5 @@
```
from osascript import *
returncode,stdout,stderr = osascript('return "message"')
```
@@ -0,0 +1,5 @@
.. code-block::

from osascript import *

returncode,stdout,stderr = osascript('return "message"')
@@ -0,0 +1,4 @@
#!/bin/sh

open .

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>URL</key>
<string>https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/osascript.1.html</string>
</dict>
</plist>
@@ -0,0 +1,6 @@
Environment :: Console
Environment :: MacOS X

Operating System :: MacOS
Operating System :: MacOS :: MacOS X

@@ -0,0 +1 @@
osascript(1) (AppleScript) python implementation (OS X)
@@ -0,0 +1 @@
osascript applescript osx
@@ -0,0 +1,52 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from os import *
from os.path import *
from subprocess import *
from fullpath import *
from osx_only import *
from public import *
from rm import *
from subopen import *
from temp import *
from tolist import *
from write import *

@osx_only
@public
def osascript(source=None,flags=None,argument=None):
"""osascript applescript code or file
"""
args = ["osascript"]
if source and isinstance(source,list):
source = "\n".join(source)
temp = programfile = None
if source and exists(source) or exists(source):
programfile = source
else:
temp = programfile = tempfile()
write(temp,source)
try:
if flags:
args+=["-s",flags]
if programfile:
args.append(programfile)
if argument:
args+=tolist(argument)
returncode,stdout,stderr = subopen(args)
return (returncode,stdout,stderr)
finally:
rm(temp)


if __name__=="__main__":
# test stdout
returncode,stdout,stderr = osascript('return "message"')
print(stdout)
# test stderr
returncode,stdout,stderr = osascript("log 1") # log 2 stderr
print(stderr)
# test returncode
returncode,stdout,stderr = osascript("ERROR")
print(returncode,stderr)

@@ -0,0 +1,7 @@
public
temp
fullpath
tolist
rm
subopen
osx_only
@@ -0,0 +1,23 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__all__=["author"]
try:
from ConfigParser import * # python2
except:
from configparser import * # python3
from os.path import *

# username
# https://docs.python.org/2/distutils/packageindex.html#pypirc
path = expanduser("~/.pypirc")
if exists(path):
cfg = RawConfigParser()
cfg.read(path)
if cfg.has_option("pypi","username"):
author = cfg.get('pypi', 'username')

if __name__=="__main__":
for k in __all__:
if k in globals():
print("%s: %s" % (k,globals()[k]))

@@ -0,0 +1,28 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__all__=["bugtrack_url"]
import os
from os.path import *
from subprocess import *

dir = dirname(dirname(__file__))
if not dir: dir="."

file = join(dir,"bugtrack_url.txt")
if exists(file) and isfile(file):
bugtrack_url = open(file).read().lstrip().rstrip()
else:
if exists(join(dir,".git")): # .git repo
args = ["git","config","user.name"]
process = Popen(args,stdout=PIPE)
stdout,stderr = process.communicate()
username = stdout.rstrip()

name = basename(dir)
bugtrack_url="https://github.com/%s/%s/issues" % (username,name)

if __name__=="__main__":
for k in __all__:
if k in globals():
print("%s: %s" % (k,globals()[k]))

@@ -0,0 +1,38 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__all__=["classifiers"]
import os
from os.path import *

dir = dirname(dirname(__file__))
if not dir: dir="."

# classifiers.txt
# global default ~/.classifiers.txt +custom ./.classifiers.txt, ./classifiers.txt
classifiers = []
name = "classifiers.txt"
files = [join(os.environ["HOME"],name),".%s" % name,name]

def read(path):
if exists(path) and isfile(path):
lines = open(path).read().splitlines()
lines = list(filter(lambda l:l.lstrip().rstrip(),lines))
lines = list(filter(lambda l:l,lines))
return lines
return []

# ~/.classifiers.txt (default)
default = read(join(os.environ["HOME"],name))
# ./.classifiers.txt, ./classifiers.txt (custom, override default)
custom=read(".classifiers.txt")+read("classifiers.txt")
for l in custom:
if l.find(" :: ")>0:
k = l.split(" :: ")[0]
default = list(filter(lambda l:l.find(k)==0,default))
classifiers=default+custom
classifiers.sort()

if __name__=="__main__":
for k in __all__:
if k in globals():
print("%s: %s" % (k,globals()[k]))
@@ -0,0 +1,23 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__all__=["dependency_links"]
from os.path import *

dir = dirname(dirname(__file__))
if not dir: dir="."

lines=[]
for name in ["dependency_links.txt","dependency.txt"]:
file = join(dir,name)
if exists(file) and isfile(file):
lines = open(file).read().splitlines()
lines = list(filter(lambda l:l.lstrip().rstrip(),lines))
dependency_links+=lines
if lines:
dependency_links = lines

if __name__=="__main__":
for k in __all__:
if k in globals():
print("%s: %s" % (k,globals()[k]))

@@ -0,0 +1,17 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__all__=["description"]
from os.path import *

dir = dirname(dirname(__file__))
if not dir: dir="."

file = join(dir,"description")
if exists(file):
description = open(file).read().lstrip().rstrip()

if __name__=="__main__":
for k in __all__:
if k in globals():
print("%s: %s" % (k,globals()[k]))

0 comments on commit 33455e1

Please sign in to comment.
You can’t perform that action at this time.