Go to the documentation of this file.00001
00002
00003
00004
00005 '''rtshell
00006
00007 Copyright (C) 2009-2014
00008 Geoffrey Biggs
00009 RT-Synthesis Research Group
00010 Intelligent Systems Research Institute,
00011 National Institute of Advanced Industrial Science and Technology (AIST),
00012 Japan
00013 All rights reserved.
00014 Licensed under the Eclipse Public License -v 1.0 (EPL)
00015 http://www.opensource.org/licenses/eclipse-1.0.txt
00016
00017 Functions for dealing with input paths.
00018
00019 '''
00020
00021
00022 import os
00023
00024
00025 ENV_VAR='RTCSH_CWD'
00026
00027
00028 def cmd_path_to_full_path(cmd_path):
00029 '''Given a path from the user, returns a suitable full path based on the
00030 value of the environment variable specified in ENV_VAR.
00031
00032 '''
00033 if cmd_path.startswith('/'):
00034 return cmd_path
00035 if ENV_VAR in os.environ and os.environ[ENV_VAR]:
00036 if os.environ[ENV_VAR].endswith('/') or cmd_path.startswith('/'):
00037 return os.environ[ENV_VAR] + cmd_path
00038 else:
00039 return os.environ[ENV_VAR] + '/' + cmd_path
00040
00041 return '/' + cmd_path
00042
00043
00044
00045