Exemple #1
0
def convert2uft8(filename):
    #print filename
    filename = filename.encode("UTF-8")
    notepad.open(filename)
    notepad.runMenuCommand("Encoding", "Convert to UTF-8")
    notepad.save()
    notepad.close()
    print filename
Exemple #2
0
def convert2uft8(filename):
    #print filename
    filename = filename.encode("UTF-8")
    notepad.open(filename)
    notepad.runMenuCommand("Encoding", "Convert to UTF-8")
    notepad.save()
    notepad.close()
    print filename
Exemple #3
0
def start_regex_tester():
    if REGEX_TESTER_FILE_NAME == '':
        notepad.messageBox('You need to indicate, in the REGEX_TESTER_FILE_NAME variable,\n' +
                           'the fully qualified file name of the TEXT file containing ' +
                           'the REGEX(ES) to test', 'REGEX_TESTER_FILE_NAME is not set')
        return False

    current_document = 0 if notepad.getCurrentView() == 1 else notepad.getCurrentBufferID()

    global REGEX_TESTER_INPUT_TAB
    REGEX_TESTER_INPUT_TAB = regex_tester_doc_already_exists()
    if REGEX_TESTER_INPUT_TAB == 0 :
        notepad.open(REGEX_TESTER_FILE_NAME)
        if notepad.getCurrentFilename().upper() == REGEX_TESTER_FILE_NAME.upper():
            REGEX_TESTER_INPUT_TAB = notepad.getCurrentBufferID()
        else:
            notepad.messageBox('Could not open specified file\n' +
                               '{0}'.format(REGEX_TESTER_FILE_NAME),
                               'Regex Tester Startup Failed', 0)
            return False
    else:
        notepad.activateBufferID(REGEX_TESTER_INPUT_TAB)

    if notepad.getCurrentView() != 1:
        notepad.menuCommand(MENUCOMMAND.VIEW_GOTO_ANOTHER_VIEW)

    STATUS_LINE = 'RegexTester isActive [] flags:sitpr'

    current_status_line = editor2.getLine(0)
    if 'RegexTester' in current_status_line:
        editor2.replace('RegexTester inActive', 'RegexTester isActive')
    else:
        editor2.insertText(0, STATUS_LINE)


    global REGEX_TESTER_IS_RUNNING
    REGEX_TESTER_IS_RUNNING = True

    color_regex_tester_status()

    set_current_buffer_id()

    global PREVIOUS_REGEX
    PREVIOUS_REGEX[CURRENT_BUFFER_ID] = ''

    editor.callbackSync(regex_tester_updateui_callback, [SCINTILLANOTIFICATION.UPDATEUI])

    if current_document != 0:
        notepad.activateBufferID(current_document)

    editor2.setFocus(True)
    editor2.gotoLine(0)
    notepad.save()

    notepad.callback(regex_tester_file_before_close_callback, [NOTIFICATION.FILEBEFORECLOSE])
    notepad.callback(regex_tester_buffer_activated_callback, [NOTIFICATION.BUFFERACTIVATED])

    return True
def start_regex_tester():
    if REGEX_TESTER_FILE_NAME == '':
        notepad.messageBox('You need to indicate, in the REGEX_TESTER_FILE_NAME variable,\n' +
                           'the fully qualified file name of the TEXT file containing ' +
                           'the REGEX(ES) to test', 'REGEX_TESTER_FILE_NAME is not set')
        return False

    current_document = 0 if notepad.getCurrentView() == 1 else notepad.getCurrentBufferID()

    global REGEX_TESTER_INPUT_TAB
    REGEX_TESTER_INPUT_TAB = regex_tester_doc_already_exists()
    if REGEX_TESTER_INPUT_TAB == 0 :
        notepad.open(REGEX_TESTER_FILE_NAME)
        if notepad.getCurrentFilename().upper() == REGEX_TESTER_FILE_NAME.upper():
            REGEX_TESTER_INPUT_TAB = notepad.getCurrentBufferID()
        else:
            notepad.messageBox('Could not open specified file\n' +
                               '{0}'.format(REGEX_TESTER_FILE_NAME),
                               'Regex Tester Startup Failed', 0)
            return False
    else:
        notepad.activateBufferID(REGEX_TESTER_INPUT_TAB)

    if notepad.getCurrentView() != 1:
        notepad.menuCommand(MENUCOMMAND.VIEW_GOTO_ANOTHER_VIEW)

    STATUS_LINE = 'RegexTester isActive [] flags:sitpr'

    current_status_line = editor2.getLine(0)
    if 'RegexTester' in current_status_line:
        editor2.replace('RegexTester inActive', 'RegexTester isActive')
    else:
        editor2.insertText(0, STATUS_LINE)


    global REGEX_TESTER_IS_RUNNING
    REGEX_TESTER_IS_RUNNING = True

    color_regex_tester_status()

    set_current_buffer_id()

    global PREVIOUS_REGEX
    PREVIOUS_REGEX[CURRENT_BUFFER_ID] = ''

    editor.callbackSync(regex_tester_updateui_callback, [SCINTILLANOTIFICATION.UPDATEUI])

    if current_document != 0:
        notepad.activateBufferID(current_document)

    editor2.setFocus(True)
    editor2.gotoLine(0)
    notepad.save()

    notepad.callback(regex_tester_file_before_close_callback, [NOTIFICATION.FILEBEFORECLOSE])
    notepad.callback(regex_tester_buffer_activated_callback, [NOTIFICATION.BUFFERACTIVATED])

    return True
Exemple #5
0
 def rename_response_handler(self, decoded_message):
     log(decoded_message)
     # 'result': {'documentChanges': [{'edits': [{'newText': u"...",
     # 'range': {'end': {'character': 0, 'line': 417},
     # 'start': {'character': 0, 'line': 0}}}],
     # 'textDocument': {'uri': 'file:///d:/...', 'version': None}}]}}
     if decoded_message['result']:
         editor.beginUndoAction()
         for changes in decoded_message['result']['documentChanges']:
             for change in changes['edits']:
                 _file = url2pathname(
                     changes['textDocument']['uri'].replace('file:', ''))
                 notepad.open(_file)
                 start_line = change['range']['start']['line']
                 end_line = change['range']['end']['line']
                 start_position = editor.positionFromLine(
                     start_line) + change['range']['start']['character']
                 end_position = editor.positionFromLine(
                     end_line) + change['range']['end']['character']
                 editor.setTargetRange(start_position, end_position)
                 editor.replaceTarget(change['newText'])
         editor.endUndoAction()
Exemple #6
0
import os
import sys
from Npp import notepad

filePathSrc=r"D:\Documents\PRM\selected-tiantian\mlf"
for dir,dirs,files in os.walk(filePathSrc):
for fn in files:
if fn.endswith(".mlf"):
notepad.open(os.path.join(dir,fn))
notepad.runMenuCommand("Encoding","Convert to UTF-8 without BOM")
Exemple #7
0
import os
import sys
from Npp import notepad

filePathSrc = "C:\\server\\encode"

for root, dirs, files in os.walk(filePathSrc):
    for fn in files:
        if fn[-4:] == '.yml':
            notepad.open(root + "\\" + fn)
            notepad.runMenuCommand("Encoding", "Convert to ANSI")
            notepad.save()
            notepad.close()
Exemple #8
0
import os
import sys

from Npp import notepad
filePathSrc = "D:/training/twg_copy/Contract Detail 5/"
#print "ashu"
for root, dirs, files in os.walk(filePathSrc):
                for fn in files:
                                if (fn[-4:] == '.csv'):
                                                notepad.open (root + "/" + fn)
                                                notepad.runMenuCommand("Macro", "convert")
                                                #notepad.save()
                                                notepad.runMenuCommand("Encoding", "Convert to UTF-8")
                                                notepad.save()
                                                #notepad.messageBox("{}{}".format(root+"\\"+fn[:-4],'_trans.csv'),0,"Done")
                                                notepad.messageBox("File: %s " % (fn))
                                                notepad.close()
                                                #notepad.saveAs("{}{}".format(root+"\\"+fn[:-4],'_trans.csv')) 
                #notepad.close()