def __init__(self): super(SortBuiltin, self).__init__('sort', input=InputStreamSchema('any'), output='identity', options=[['-r', '--reverse']], argspec=MultiArgSpec('property', min=0))
def __init__(self): super(EditBuiltin, self).__init__('edit', aliases=['ed'], argspec=MultiArgSpec('paths', min=1), nodisplay=True, idempotent=True, threaded=False)
def __init__(self): super(WriteBuiltin, self).__init__('write', input=InputStreamSchema('any', optional=False), argspec=MultiArgSpec('paths', min=1), options=[['-a', '--append'], ['-p', '--pickle'], ['-n', '--newline']])
def __init__(self): super(RmBuiltin, self).__init__('rm', aliases=['delete'], input=InputStreamSchema(File, optional=True), undoable=True, hasstatus=True, argspec=MultiArgSpec('path'), options=[['-u', '--unlink'], ['-r', '--recursive'], ['-f', '--force']])
def __init__(self, name='sys'): super(SysBuiltin, self).__init__( name, input=InputStreamSchema( str, optional=True, opt_formats=['x-unix-pipe-file-object/special']), output=OutputStreamSchema(str, opt_formats=[ 'x-unix-pipe-file-object/special', 'x-filedescriptor/special', 'bytearray/chunked' ]), hasstatus=True, argspec=MultiArgSpec('args'), options_passthrough=True)
def __init__(self): super(KillBuiltin, self).__init__('kill', nodisplay=True, input=InputStreamSchema(Process, optional=True), options_passthrough=True, argspec=MultiArgSpec('pid', min=1))
def __init__(self): super(MkdirBuiltin, self).__init__('mkdir', hasstatus=True, argspec=MultiArgSpec('paths', min=1))
import os, sys, os.path, stat, logging, locale from hotwire.builtin import builtin_hotwire, InputStreamSchema, MultiArgSpec from hotwire.fs import FilePath from hotwire.sysdep.fs import Filesystem, File from hotwire.util import xmap _logger = logging.getLogger("hotwire.builtins.ls") @builtin_hotwire(aliases=['dir'], input=InputStreamSchema(str, optional=True), output=File, idempotent=True, argspec=MultiArgSpec('paths'), options=[['-l', '--long'], ['-a', '--all'], ['-i', '--input']]) def ls(context, *args): _("""List contents of a directory.""") show_all = '-a' in context.options long_fmt = '-l' in context.options process_input = '-i' in context.options fs = Filesystem.getInstance() if process_input and input is not None: args = list(args) args.extend(context.input) if len(args) == 0: for x in fs.ls_dir(context.cwd, show_all):
def __init__(self): super(CpBuiltin, self).__init__('cp', aliases=['copy'], hasstatus=True, argspec=MultiArgSpec('files', min=2))
def __init__(self): super(MvBuiltin, self).__init__('mv', aliases=['move'], hasstatus=True, argspec=MultiArgSpec('paths', min=2))
def __init__(self): super(HotSudoBuiltin, self).__init__('sudo', nodisplay=True, argspec=MultiArgSpec('args'), options_passthrough=True)
def __init__(self): super(TermBuiltin, self).__init__('term', nodisplay=True, argspec=MultiArgSpec('args'), options_passthrough=True, threaded=False)
def __init__(self): super(ViewBuiltin, self).__init__('view', nodisplay=True, argspec=MultiArgSpec('paths', min=1), idempotent=True, threaded=False)
def __init__(self): super(HotSshBuiltin, self).__init__('ssh', nodisplay=True, argspec=MultiArgSpec('args', min=1), options_passthrough=True)
# in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies # of the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE X CONSORTIUM BE # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR # THE USE OR OTHER DEALINGS IN THE SOFTWARE. import hotwire from hotwire.builtin import builtin_hotwire, MultiArgSpec from hotwire.fs import FilePath from hotwire.sysdep.fs import Filesystem @builtin_hotwire(idempotent=True, argspec=MultiArgSpec('paths', min=1), nodisplay=True, threaded=False) def open(context, args): _("""Open a file using default program.""") fs = Filesystem.getInstance() for arg in args: fs.launch_open_file(FilePath(arg, context.cwd), context.cwd)