4 examples of 'ls command in python' in Python

Every line of 'ls command in python' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
250def do_ls(self, line):
251 args = shlex.split(line)
252 if args:
253 for object_name in args:
254 for archive in self.archives:
255 matches = archive.find(object_name)
256 if matches:
257 for object in matches:
258 object.dump(flat=False)
259 else:
260 print('error: no object matches "%s" in "%s"' % (
261 object_name, archive.path))
262 else:
263 for archive in self.archives:
264 archive.dump(flat=True)
265 print('')
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

22def call(self):
23 path = self.protocol.cwd
24 paths = []
25 if len(self.args):
26 for arg in self.args:
27 if not arg.startswith('-'):
28 paths.append(self.protocol.fs.resolve_path(arg,
29 self.protocol.cwd))
30
31 self.show_hidden = False
32 func = self.do_ls_normal
33 for x in self.args:
34 if x.startswith('-') and x.count('l'):
35 func = self.do_ls_l
36 if x.startswith('-') and x.count('a'):
37 self.show_hidden = True
38
39 if not paths:
40 func(path)
41 else:
42 for path in paths:
43 func(path)
38def python(command, env=None, version='2.7'):
39 if env:
40 env = ' '.join(
41 '{}={}'.format(k, v) for k, v in env.items()
42 ) + ' '
43 else:
44 env = ''
45
46 return '{}{}{} {}'.format(env, PYTHON_BIN, version, command)
339def do_py(self, line):
340 # setup local vars (user_ns seems broken)
341 iface = self.iface
342 cli = self
343 p = util.shell(globals())
344 p()

Related snippets