コード例 #1
0
	def do_cd(self, args):
		"Move to directory"
		if args == '':
			print(common.get_cdir())
		else:
			try:
				common.chdir(args)
				self.prompt = self.get_shortpath() + ' ' + self.prompt_sign

				self.directories = []
				for name in os.listdir(common.get_cdir()):
					if os.path.isdir(os.path.join(common.get_cdir(), name)):
						self.directories.append(name)
			except FileNotFoundError as e:
				print(e)
コード例 #2
0
	def get_shortpath(self):
		path = common.get_cdir()
		separator = ''
		if '\\' in path:
			separator = '\\'
		else:
			separator = '/'
		start = path.find(separator)
		end = path.rfind(separator, 0, len(path)-1)
		if start < end:
			return (path[0:start+1] + '...' + path[end:])
		else:
			return (path)
コード例 #3
0
	def do_pwd(self, args):
		"Print path"
		print(common.get_cdir())
コード例 #4
0
	def do_ls(self, args):
		"List directory"
		for name in os.listdir(common.get_cdir()):
			print(name)