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))
def _create_writer_from_list(datalist: list): # TODO: Change CSV implementation to use dict reader for better handling of # missing information """ Private function. Creates a single writer from a list following the format: ["folder","name","email","language1,language2"] Arguments: datalist: list - The list of data to load into the writer """ # First, verify that the data list is OK if datalist is None or not len(datalist) == 4: raise PyCException('Cannot create writer from datalist {}. Malformed' .format(str(datalist))) newWriter = Writer(writerPath=datalist[0],writerName=datalist[1], writerEmail=datalist[2]) newWriter.create() splitLanguageList = [languageName.strip() for languageName in datalist[3].split(',')] newWriter.add_known_language_from_list(splitLanguageList)