How to use the ltk.utils.remove_powershell_formatting function in ltk

To help you get started, we’ve selected a few ltk examples, based on popular ways it is used in public projects.

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

github Lingotek / filesystem-connector / python2 / ltk / commands.py View on Github external
def request(doc_name, path, locales, to_cancel, to_delete, due_date, workflow):
    """ Add targets to document(s) to start translation; defaults to the entire project. If no locales are specified, Filesystem Connector
        will look for target watch locales set in ltk config. Use ltk list -l to see possible locales. """
    try:
        action = request_action.RequestAction(os.getcwd(), doc_name, path, locales, to_cancel, to_delete, due_date, workflow)
        init_logger(action.path)
        if locales and isinstance(locales,str):
            locales = [locales]

        doc_name = remove_powershell_formatting(doc_name)
        path = remove_powershell_formatting(path)

        action.target_action()
    except (UninitializedError, ResourceNotFound, RequestFailedError) as e:
        print_log(e)
        logger.error(e)
        return
github Lingotek / filesystem-connector / python2 / ltk / commands.py View on Github external
def rm(file_names, **kwargs):
    """
    Disassociates local doc(s) from Lingotek Cloud and removes them from the project by cancelling them.  If the remote copy should be deleted, use the -r flag.
    """
    try:
        action = rm_action.RmAction(os.getcwd())
        init_logger(action.path)
        if not file_names and not (('all' in kwargs and kwargs['all']) or ('local' in kwargs and kwargs['local'])):
            logger.info("Usage: ltk rm [OPTIONS] FILE_NAMES...")
            return

        if len(file_names) > 0:
            file_names = remove_powershell_formatting(file_names)

        action.rm_action(file_names, **kwargs)
    except (UninitializedError, ResourceNotFound, RequestFailedError) as e:
        print_log(e)
        logger.error(e)
        return
github Lingotek / filesystem-connector / python2 / ltk / commands.py View on Github external
def add(file_names, **kwargs):
    #""" Add files and folders for upload to Lingotek.  Fileglobs (e.g. *.txt) can be used to add all matching files and/or folders. Added folders will automatically add the new files added or created inside of them. """
    """ Add files and folders for upload to Lingotek.  Fileglobs (e.g. *.txt) can be used to add all matching files and/or folders. Added folders will automatically add the new files added or created inside of them.
    
    Metadata can be added by launching the metadata wizard with the -m flag or by using flags for specific metadata.  The metadata flags are --author_email, --author_name, --business_division, --business_unit, --campaign_id, --campaign_rating, --channel, --contact_email, --contact_name, --content_description, --content_type, --domain, --external_application_id, --external_document_id, --external_style_id, --job_id, --purchase_order, --reference_url, --region, --require_review, --category_id, and --note """
    try:
        action = add_action.AddAction(os.getcwd())
        init_logger(action.path)

        file_names = remove_powershell_formatting(file_names)

        for f in kwargs:
            if kwargs[f]:
                temp = remove_powershell_formatting(kwargs[f])
                kwargs[f] = temp

        action.add_action(file_names, **kwargs)
    except (UninitializedError, RequestFailedError, ResourceNotFound, AlreadyExistsError) as e:
        print_log(e)
        logger.error(e)
        return
github Lingotek / filesystem-connector / python3 / ltk / commands.py View on Github external
"""
    Import documents from Lingotek Cloud, by default downloading to the project's root folder
    """
    # todo import should show all documents
    # add a force option so can import all force -- overwrites all existing documents without prompting
    # check if doc id
    # if exist, prompt for overwrite
    # else automatically re-name
    # possibly have to patch title in Lingotek Cloud?
    try:
        # action = actions.Action(os.getcwd())
        action = import_action.ImportAction(os.getcwd())
        init_logger(action.path)

        if path != None:
            path = remove_powershell_formatting(path)

        action.import_action(import_all, force, path, track, no_cancel)
    except(UninitializedError, RequestFailedError) as e:
        print_log(e)
        logger.error(e)
        return
github Lingotek / filesystem-connector / python2 / ltk / commands.py View on Github external
"""
    Copies the folder structure of added folders or specified folders
    for each target locale as specified in config.
    Folders are added to the locale folder specified if one has been specified,
    or by default a new folder will be created with the name of the locale. If
    only one root folder is being cloned, then the locale folder is used
    (instead of creating a new folder inside of the locale folder).
    """
    try:
        action = clone_action.CloneAction(os.getcwd())
        init_logger(action.path)
        if isinstance(folders,str):
            folders = [folders]

        if len(folders) > 0:
            folders = remove_powershell_formatting(folders)

        action.clone_action(folders, copy_root)
    except (UninitializedError, RequestFailedError) as e:
        print_log(e)
        logger.error(e)
        return
github Lingotek / filesystem-connector / python3 / ltk / commands.py View on Github external
def request(doc_name, path, locales, to_cancel, to_delete, due_date, workflow):
    """ Add targets to document(s) to start translation; defaults to the entire project. If no locales are specified, Filesystem Connector
        will look for target watch locales set in ltk config. Use ltk list -l to see possible locales. """
    try:
        action = request_action.RequestAction(os.getcwd(), doc_name, path, locales, to_cancel, to_delete, due_date, workflow)
        init_logger(action.path)
        if locales and isinstance(locales,str):
            locales = [locales]

        doc_name = remove_powershell_formatting(doc_name)
        path = remove_powershell_formatting(path)

        action.target_action()
    except (UninitializedError, ResourceNotFound, RequestFailedError) as e:
        print_log(e)
        logger.error(e)
        return
github Lingotek / filesystem-connector / python2 / ltk / commands.py View on Github external
def status(**kwargs):
    """ Gets the status of a specific document or all documents """
    try:
        action = status_action.StatusAction(os.getcwd())
        init_logger(action.path)

        for f in kwargs:
            if kwargs[f]:
                temp = remove_powershell_formatting(kwargs[f])
                kwargs[f] = temp

        action.get_status(**kwargs)
    except (UninitializedError, ResourceNotFound) as e:
        print_log(e)
        logger.error(e)
        return
github Lingotek / filesystem-connector / python3 / ltk / commands.py View on Github external
"""
    Copies the folder structure of added folders or specified folders
    for each target locale as specified in config.
    Folders are added to the locale folder specified if one has been specified,
    or by default a new folder will be created with the name of the locale. If
    only one root folder is being cloned, then the locale folder is used
    (instead of creating a new folder inside of the locale folder).
    """
    try:
        action = clone_action.CloneAction(os.getcwd())
        init_logger(action.path)
        if isinstance(folders,str):
            folders = [folders]

        if len(folders) > 0:
            folders = remove_powershell_formatting(folders)

        action.clone_action(folders, copy_root)
    except (UninitializedError, RequestFailedError) as e:
        print_log(e)
        logger.error(e)
        return
github Lingotek / filesystem-connector / python3 / ltk / commands.py View on Github external
def add(file_names, **kwargs):
    #""" Add files and folders for upload to Lingotek.  Fileglobs (e.g. *.txt) can be used to add all matching files and/or folders. Added folders will automatically add the new files added or created inside of them. """
    """ Add files and folders for upload to Lingotek.  Fileglobs (e.g. *.txt) can be used to add all matching files and/or folders. Added folders will automatically add the new files added or created inside of them.
    
    Metadata can be added by launching the metadata wizard with the -m flag or by using flags for specific metadata.  The metadata flags are --author_email, --author_name, --business_division, --business_unit, --campaign_id, --campaign_rating, --channel, --contact_email, --contact_name, --content_description, --content_type, --domain, --external_application_id, --external_document_id, --external_style_id, --job_id, --purchase_order, --reference_url, --region, --require_review, --category_id, and --note """
    try:
        action = add_action.AddAction(os.getcwd())
        init_logger(action.path)

        file_names = remove_powershell_formatting(file_names)

        for f in kwargs:
            if kwargs[f]:
                temp = remove_powershell_formatting(kwargs[f])
                kwargs[f] = temp

        action.add_action(file_names, **kwargs)
    except (UninitializedError, RequestFailedError, ResourceNotFound, AlreadyExistsError) as e:
        print_log(e)
        logger.error(e)
        return
github Lingotek / filesystem-connector / python2 / ltk / commands.py View on Github external
"""
    Import documents from Lingotek Cloud, by default downloading to the project's root folder
    """
    # todo import should show all documents
    # add a force option so can import all force -- overwrites all existing documents without prompting
    # check if doc id
    # if exist, prompt for overwrite
    # else automatically re-name
    # possibly have to patch title in Lingotek Cloud?
    try:
        # action = actions.Action(os.getcwd())
        action = import_action.ImportAction(os.getcwd())
        init_logger(action.path)

        if path != None:
            path = remove_powershell_formatting(path)

        action.import_action(import_all, force, path, track, no_cancel)
    except(UninitializedError, RequestFailedError) as e:
        print_log(e)
        logger.error(e)
        return