# Path: libraries/file.py
# class File(object):
# 
#     def __init__(self, file_name):
#         self.file_name = file_name
# 
#     def write(self, text):
#         """Write File
# 
#         Writes the content of text in the file set in self.file_name
# 
#         Arguments:
#             text {str} -- text to write
# 
#         Returns:
#             bool -- true if was writed succesuflly
#         """
#         encoding = 'utf-8'
#         with codecs.open(self.file_name, 'w', encoding) as file:
#             file.write(text)
#             return True
# 
#     def read(self):
#         """Read File
# 
#         returns the content of the file set in self.file_name
# 
#         Returns:
#             str -- string from file
#         """
#         encoding = 'utf-8'
#         text = ''
# 
#         try:
#             with codecs.open(self.file_name, 'r', encoding) as file:
#                 text = file.read()
#         except(IOError, UnicodeError):
#             pass
#         return text
# 
#     def read_json(self):
#         """read JSON
#         serialize the content of the file and transform it in
#         a json format type
# 
#         Returns:
#             JSON -- serialized json data
#         """
# 
#         file = self.read()
# 
#         if(file):
#             return json.loads(file)
# 
#         return []
# 
#     def save_json(self, text):
#         """Save JSON
# 
#         Stores JSON data in a file, before do it deserialize
# 
#         Arguments:
#             text {str} -- json data to stored
#         """
#         text = json.dumps(text, sort_keys=True, indent=4)
#         self.write(text)
# 
# Path: libraries/libraries.py
# def get_library_list(example_list=False, platform="all"):
#     """List of Libraries
# 
#     Make a list of the libraries availables. This list is
#     used in the import library and examples.
# 
#     Keyword Arguments:
#         example_list {bool} -- if it's True, returns a list of examples
#                                 inside of the library (default: {False})
# 
#         platform {str} -- results only in the given platform (default: {"all"})
# 
#     Returns:
#         [list/list] -- name of folder and path [[name, path]]
#     """
#     from re import search
# 
#     libraries_folders = get_library_folders(platform)
# 
#     quick_list = []
#     check_list = []
# 
#     for library in libraries_folders:
#         sub_library = glob(library)
# 
#         for content in sub_library:
#             caption = path.basename(content)
#             new_caption = caption.split("_ID")
#             if(new_caption is not None):
#                 caption = new_caption[0]
# 
#             if('__cores__' in content):
#                 cores = path.join(content, '*')
#                 cores = glob(cores)
# 
#                 for sub_core in cores:
#                     libs_core = path.join(sub_core, '*')
#                     libs_core = glob(libs_core)
#                     board = path.basename(sub_core).capitalize()
# 
#                     for lib_core in libs_core:
#                         caption = path.basename(lib_core)
#                         quick_list.append([caption, board, lib_core])
#                         check_list.append([caption])
# 
#             if(caption not in quick_list and '__cores__' not in
#                     caption and caption not in check_list):
# 
#                 store_data = True
#                 if(example_list):
#                     examples_path = path.join(content, 'examples')
#                     store_data = True if path.exists(examples_path) else False
#                     quick_list = sorted(quick_list, key=lambda x: (x[0], x[1]))
# 
#                 if(store_data):
#                     quick_list.append([caption, content])
#                     check_list.append(caption)
# 
#     return quick_list
# 
# Path: libraries/tools.py
# def accepted_extensions():
#     """
#     Files accepted to be processed by deviot
#     """
#     accepted = ['ino', 'pde', 'cpp', 'c', 'S', 'h']
#     return accepted


import sublime_plugin
from os import path
from threading import Thread
from ..api import deviot
from .file import File
from .libraries import get_library_list
from .tools import accepted_extensions
from ..libraries.thread_progress import ThreadProgress
        from sublime import windows
        from ..libraries import keywords
                        ik1 = 0
                    ik1 += 1
                if('KEYWORD2' in word.get_type()):
                    keyword2s += word.get_id() + '|'
                    if(ik2 == 6):
                        keyword2s += '\n'
                        ik2 = 0
                    ik2 += 1
                if('KEYWORD3' in word.get_type()):
                    keyword3s += word.get_id() + '|'
                    if(ik3 == 6):
                        keyword3s += '\n'
                        ik3 = 0
                    ik3 += 1

        template_path = deviot.syntax_path()
        plugin_path = deviot.plugin_path()
        syntax_path = path.join(plugin_path, 'deviot.sublime-syntax')

        # syntax template
        syntax = File(template_path)
        syntax = syntax.read()

        # replace keywords
        syntax = syntax.replace('{LITERAL1}', literal1s)
        syntax = syntax.replace('{KEYWORD1}', keyword1s)
        syntax = syntax.replace('{KEYWORD2}', keyword2s)
        syntax = syntax.replace('{KEYWORD3}', keyword3s)

        # save new file

# Path: libraries/file.py
# class File(object):
# 
#     def __init__(self, file_name):
#         self.file_name = file_name
# 
#     def write(self, text):
#         """Write File
# 
#         Writes the content of text in the file set in self.file_name
# 
#         Arguments:
#             text {str} -- text to write
# 
#         Returns:
#             bool -- true if was writed succesuflly
#         """
#         encoding = 'utf-8'
#         with codecs.open(self.file_name, 'w', encoding) as file:
#             file.write(text)
#             return True
# 
#     def read(self):
#         """Read File
# 
#         returns the content of the file set in self.file_name
# 
#         Returns:
#             str -- string from file
#         """
#         encoding = 'utf-8'
#         text = ''
# 
#         try:
#             with codecs.open(self.file_name, 'r', encoding) as file:
#                 text = file.read()
#         except(IOError, UnicodeError):
#             pass
#         return text
# 
#     def read_json(self):
#         """read JSON
#         serialize the content of the file and transform it in
#         a json format type
# 
#         Returns:
#             JSON -- serialized json data
#         """
# 
#         file = self.read()
# 
#         if(file):
#             return json.loads(file)
# 
#         return []
# 
#     def save_json(self, text):
#         """Save JSON
# 
#         Stores JSON data in a file, before do it deserialize
# 
#         Arguments:
#             text {str} -- json data to stored
#         """
#         text = json.dumps(text, sort_keys=True, indent=4)
#         self.write(text)
# 
# Path: libraries/libraries.py
# def get_library_list(example_list=False, platform="all"):
#     """List of Libraries
# 
#     Make a list of the libraries availables. This list is
#     used in the import library and examples.
# 
#     Keyword Arguments:
#         example_list {bool} -- if it's True, returns a list of examples
#                                 inside of the library (default: {False})
# 
#         platform {str} -- results only in the given platform (default: {"all"})
# 
#     Returns:
#         [list/list] -- name of folder and path [[name, path]]
#     """
#     from re import search
# 
#     libraries_folders = get_library_folders(platform)
# 
#     quick_list = []
#     check_list = []
# 
#     for library in libraries_folders:
#         sub_library = glob(library)
# 
#         for content in sub_library:
#             caption = path.basename(content)
#             new_caption = caption.split("_ID")
#             if(new_caption is not None):
#                 caption = new_caption[0]
# 
#             if('__cores__' in content):
#                 cores = path.join(content, '*')
#                 cores = glob(cores)
# 
#                 for sub_core in cores:
#                     libs_core = path.join(sub_core, '*')
#                     libs_core = glob(libs_core)
#                     board = path.basename(sub_core).capitalize()
# 
#                     for lib_core in libs_core:
#                         caption = path.basename(lib_core)
#                         quick_list.append([caption, board, lib_core])
#                         check_list.append([caption])
# 
#             if(caption not in quick_list and '__cores__' not in
#                     caption and caption not in check_list):
# 
#                 store_data = True
#                 if(example_list):
#                     examples_path = path.join(content, 'examples')
#                     store_data = True if path.exists(examples_path) else False
#                     quick_list = sorted(quick_list, key=lambda x: (x[0], x[1]))
# 
#                 if(store_data):
#                     quick_list.append([caption, content])
#                     check_list.append(caption)
# 
#     return quick_list
# 
# Path: libraries/tools.py
# def accepted_extensions():
#     """
#     Files accepted to be processed by deviot
#     """
#     accepted = ['ino', 'pde', 'cpp', 'c', 'S', 'h']
#     return accepted


# Path: libraries/syntax.py
import sublime_plugin
from os import path
from threading import Thread
from ..api import deviot
from .file import File
from .libraries import get_library_list
from .tools import accepted_extensions
from ..libraries.thread_progress import ThreadProgress
        from sublime import windows
        from ..libraries import keywords

                        ik1 = 0
                    ik1 += 1
                if('KEYWORD2' in word.get_type()):
                    keyword2s += word.get_id() + '|'
                    if(ik2 == 6):
                        keyword2s += '\n'
                        ik2 = 0
                    ik2 += 1
                if('KEYWORD3' in word.get_type()):
                    keyword3s += word.get_id() + '|'
                    if(ik3 == 6):
                        keyword3s += '\n'
                        ik3 = 0
                    ik3 += 1

        template_path = deviot.syntax_path()
        plugin_path = deviot.plugin_path()
        syntax_path = path.join(plugin_path, 'deviot.sublime-syntax')

        # syntax template
        syntax = File(template_path)
        syntax = syntax.read()

        # replace keywords
        syntax = syntax.replace('{LITERAL1}', literal1s)
        syntax = syntax.replace('{KEYWORD1}', keyword1s)
        syntax = syntax.replace('{KEYWORD2}', keyword2s)
        syntax = syntax.replace('{KEYWORD3}', keyword3s)

        # save new file

        File(syntax_path).write(syntax)