예제 #1
0
def main(arguments, out=sys.stdout):
    # Set the path
    PathMapper.set_root_path(os.path.dirname(os.path.abspath(__name__)))

    try:
        parsedArgs = parse_arguments(arguments, output=out)
    except PyCException as e:
        out.write(e.message)
        return 1
예제 #2
0
def import_writers_from_csv_file_path(csvFilePath):
    """
    Imports the writers from a CSV file path
    """
    realPath = PathMapper.get_mapped_path(csvFilePath)
    with open(realPath, 'r') as csvFileDescriptor:
        import_writers_from_csv_descriptor(csvFileDescriptor)
예제 #3
0
 def test_get_config_path(self, mocked_pathmapper_fileops):
     """
     Ensure Pathmapper.get_config_path properly delegates to fileops
     """
     mocked_pathmapper_fileops.join_path.return_value = 'hello'
     self.assertEqual(PathMapper.get_config_path(), 'hello')
     mocked_pathmapper_fileops.join_path.assert_called_with(PathMapper._rootPath, 
             PathMapper.CONFIG_DIR)
예제 #4
0
def load_config_file(path=None):
    """
    Loads the config file into the global config variable

    Keyword Arguments:
    path: str - The path to load the config from (default: conf/packages.json)
    """
    if path is None:
        path = fileops.join_path(PathMapper.get_config_path(), 
                CONFIGURATION_FILE)

    global config
    config = fileops.get_json_dict(path)
예제 #5
0
def add_user_quick(userName: str):
    """
    Adds a user by simply creating their folder and adding their entry to the
    writers.json dict. If the writer exists, an exception is thrown.

    Arguments:
    userName: str - The writer name to create
    """
    if Writers.writer_exists(userName):
        raise PyCException('Error: Writer {} already exists'.format(userName))
    
    mappedWriterPath = PathMapper.get_mapped_path(userName)
    newWriter = Writer(writerPath=mappedWriterPath)
    try:
        newWriter.create()
    except Exception as e:
        raise PyCException('Error: Could not create writer{}'.format(userName))
예제 #6
0
 def test_set_root_path(self):
     """
     Ensure PathMapper.set_root_path correctly sets root path
     """
     PathMapper.set_root_path('rootPath')
     self.assertEqual(PathMapper._rootPath, 'rootPath')
예제 #7
0
 def get_definitions_filepath(cls):
     """
     Gets the filepath of the definitions file based on the path mapper
     """
     return fileops.join_path(PathMapper.get_config_path(), Definitions.DEFINITIONS_FILE)
예제 #8
0
 def get_variables_filepath(cls):
     """
     Gets the filepath of the variables file based on a given path mapper
     """
     return fileops.join_path(PathMapper.get_config_path(), 
             Variables.VARIABLES_FILE)
예제 #9
0
 def get_languages_filepath(cls):
     """
     Gets the filepath of the languages file based on the path mapper
     """
     return fileops.join_path(PathMapper.get_config_path(), Languages.LANGUAGES_FILE)