mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-03-31 02:34:28 +00:00
Move all packages to a types directory
This commit is contained in:
39
types/python-shell/index.d.ts
vendored
Normal file
39
types/python-shell/index.d.ts
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
// Type definitions for python-shell 0.4
|
||||
// Project: https://github.com/extrabacon/python-shell
|
||||
// Definitions by: Dolan Miu <https://github.com/dolanmiu>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export class PythonShell {
|
||||
on(message: string, callback: (message: string) => void): void;
|
||||
end(callback: (message: string) => void): void;
|
||||
send(message: any | string): void;
|
||||
|
||||
constructor(scriptName: string, options?: InstanceOptions);
|
||||
defaultOptions: RunOptions;
|
||||
}
|
||||
|
||||
export interface RunOptions {
|
||||
mode?: string;
|
||||
formatter?: string;
|
||||
parser?: string;
|
||||
encoding?: string;
|
||||
pythonPath?: string;
|
||||
pythonOptions?: string[];
|
||||
scriptPath?: string;
|
||||
args?: string[];
|
||||
}
|
||||
|
||||
export interface InstanceOptions {
|
||||
script?: string;
|
||||
command?: string;
|
||||
stdin?: any;
|
||||
stdout?: any;
|
||||
stderr?: any;
|
||||
childProcess?: string;
|
||||
terminated?: any;
|
||||
exitCode?: any;
|
||||
args?: any[];
|
||||
}
|
||||
|
||||
export function run(scriptName: string, RunOptions: RunOptions, callback: (err: Error, results?: any) => void): void;
|
||||
export function run(scriptName: string, callback: (err: Error, results?: any) => void): void;
|
||||
38
types/python-shell/python-shell-tests.ts
Normal file
38
types/python-shell/python-shell-tests.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import * as ps from 'python-shell';
|
||||
|
||||
const PythonShell = ps.PythonShell;
|
||||
|
||||
ps.run('my_script.py', err => {
|
||||
if (err) throw err;
|
||||
console.log('finished');
|
||||
});
|
||||
|
||||
var options = {
|
||||
mode: 'text',
|
||||
pythonPath: 'path/to/python',
|
||||
pythonOptions: ['-u'],
|
||||
scriptPath: 'path/to/my/scripts',
|
||||
args: ['value1', 'value2', 'value3']
|
||||
};
|
||||
|
||||
ps.run('my_script.py', options, (err, results) => {
|
||||
if (err) throw err;
|
||||
// results is an array consisting of messages collected during execution
|
||||
console.log('results: %j', results);
|
||||
});
|
||||
|
||||
var pyshell = new PythonShell('my_script.py');
|
||||
|
||||
// sends a message to the Python script via stdin
|
||||
pyshell.send('hello');
|
||||
|
||||
pyshell.on('message', message => {
|
||||
// received a message sent from the Python script (a simple "print" statement)
|
||||
console.log(message);
|
||||
});
|
||||
|
||||
// end the input stream and allow the process to exit
|
||||
pyshell.end(err => {
|
||||
if (err) throw err;
|
||||
console.log('finished');
|
||||
});
|
||||
23
types/python-shell/tsconfig.json
Normal file
23
types/python-shell/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"python-shell-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/python-shell/tslint.json
Normal file
1
types/python-shell/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "../tslint.json" }
|
||||
Reference in New Issue
Block a user