Example #1
0
def copyToSrc():
    global dictList
    dictList = list()

    idev.recursiveExec("..", "\.ts$", buildlist)

    for dictFile in dictList:
        p = Path(dictFile)
        name = LANG_FOLDER + '/' + p.name
        if os.path.exists(name):
            shutil.copy(name, dictFile)
Example #2
0
import iricdevtool as idev


def strreplace(path):
    """ Replace string
  """
    with open(path, 'r', encoding='utf-8') as f:
        lines = f.readlines()
        newlines = []
        for line in lines:
            newline = line.replace('containedFiles()',
                                   'containedFiles() const')
            newlines.append(newline)

    if lines == newlines:
        return

    # write result
    with open(path, 'w', encoding='utf-8') as f:
        for line in newlines:
            line = line.replace('\n', '\r\n')
            f.write(line)


print('replacing strings...')

idev.recursiveExec("../libs", "\.cpp$", strreplace)
idev.recursiveExec("../apps", "\.cpp$", strreplace)
Example #3
0
import iricdevtool as idev
import shutil

debugDir = "../libdlls/debug"
releaseDir = "../libdlls/release"


def copydlls(path):
    if ("libdlls" in path):
        return
    if ("\\plugins\\" in path):
        return

    if ("\\debug\\" in path):
        shutil.copy(path, debugDir)
        print('Copied dll: ' + path)

    elif ("\\release\\" in path):
        shutil.copy(path, releaseDir)
        print('Copied dll: ' + path)


print('copying dlls...')
idev.recursiveExec("..", "\.dll$", copydlls)
Example #4
0
            newline = line
            if '= 0' in line:
                pass
            elif 'override' in line:
                pass
            elif 'static ' in line:
                pass
            else:
                m1 = re.search(r".+ ([A-Za-z0-9_]+)\(.*\).*{", line)
                m2 = re.search(r".+ ([A-Za-z0-9_]+)\(.*\).*;$", line)
                if m1:
                    newline = newline.replace(' {', ' override {')
                elif m2:
                    newline = newline.replace(';', ' override;')
            newlines.append(newline)

    if lines == newlines:
        return

    # write result
    with open(path, 'w', encoding='utf-8') as f:
        for line in newlines:
            line = line.replace('\n', '\r\n')
            f.write(line)


print('adding override to functions ...')

idev.recursiveExec("../libs", "\.h$", addoverridelist)
idev.recursiveExec("../apps", "\.h$", addoverridelist)
Example #5
0
            newline = line
            newline = newline.replace("rawData", "geoData")
            newline = newline.replace("rawdata", "geodata")
            newline = newline.replace("Rawdata", "GeoData")
            newline = newline.replace("RAWDATA", "GEODATA")
            newline = newline.replace("RawData", "GeoData")
            newline = newline.replace("rd_", "gd_")
            newline = newline.replace("RD_", "GD_")
            newline = newline.replace("Rd", "Gd")
            newline = newline.replace("WIZAGD", "WIZARD")
            newline = newline.replace("STANDAGD", "STANDARD")
            newline = newline.replace("cg_coogd_", "cg_coord_")
            newline = newline.replace(".readGeoData(", ".readRawData(")
            newline = newline.replace("cg_iRIC_GotoGeoDataTop",
                                      "cg_iRIC_GotoRawDataTop")
            newline = newline.replace("dgeo", "draw")
            newlines.append(newline)

    if lines == newlines:
        return

    # write result
    with open(path, 'w', encoding='utf-8', newline='\r\n') as f:
        for line in newlines:
            f.write(line)


print('adding empty lines before visibility identifier...')
idev.recursiveExec("../libs", "\.(h|cpp|ui|pro)$", renamerawdata)
idev.recursiveExec("../apps", "\.(h|cpp|ui|pro)$", renamerawdata)
    special_lines = [
        'public:', 'protected:', 'private:', 'public slots:',
        'protected slots:', 'private slots:', 'signals:'
    ]

    with open(path, 'r', encoding='shift_jis') as f:
        lines = f.readlines()

    newlines = []
    last_is_empty = False

    for line in lines:
        stripedline = line.strip()
        if stripedline in special_lines and (not last_is_empty):
            newlines.append('\r\n')

        line = line.replace('\n', '\r\n')
        newlines.append(line)

        last_is_empty = (stripedline == '')

    # write result
    with open(path, 'w', encoding='shift_jis') as f:
        for line in newlines:
            f.write(line)


print('adding empty lines before visibility identifier...')
idev.recursiveExec("../libs", "\.h$", addvisiblespace)
idev.recursiveExec("../apps", "\.h$", addvisiblespace)
Example #7
0
import iricdevtool as idev
import shutil
import os;

targetDir = "../apps/iricgui/debug/languages"

def copydics(path):
  if "debug" in path:
    return

  shutil.copy(path, targetDir)
  print('Copied dic: ' + path)

print('copying dics...')
idev.recursiveExec("..", "\.qm$", copydics)
Example #8
0
    print(path)
    p = re.compile(r"\/(.*?)_.+\.ts")
    with open(path, 'r', encoding='utf-8') as f:
        new_lines = list()
        prefix = ""
        for l in f.readlines():
            if '.ts' in l:
                m = p.search(l)
                prefix = m.groups()[0]
            else:
                new_lines.append(l)

    if prefix:
        for i, l in enumerate(langs):
            if i == 0:
                new_lines.append("TRANSLATIONS += languages/" + prefix + "_" +
                                 l + ".ts \\\n")
            elif i == len(langs) - 1:
                new_lines.append("                languages/" + prefix + "_" +
                                 l + ".ts\n")
            else:
                new_lines.append("                languages/" + prefix + "_" +
                                 l + ".ts \\\n")

    with open(path, 'w', encoding='utf-8') as f:
        f.write("".join(new_lines))


print('updating *.pro to add translations...')
idev.recursiveExec("..", r"\.pro$", update_translation)
import iricdevtool as idev
import subprocess
import os


def renamerawdata(path):
    """rename files with "rawdata" to "geodata"
  """

    if 'moc_' in path: return
    if 'qrc_' in path: return

    oldpath = path
    newpath = oldpath.replace('iricRd', 'iricGd')
    newpath = newpath.replace('rawdata', 'geodata')
    newpath = newpath.replace('rd_', 'gd_')

    os.rename(oldpath, newpath)


print('adding empty lines before visibility identifier...')
idev.recursiveExec("../libs", "\.(h|cpp|ui|pro|ts|qm|qrc|png|jpg)$",
                   renamerawdata)
Example #10
0
import iricdevtool as idev
import subprocess
import pathlib
import os


def lrelease(pro_filename):
    cwd = os.getcwd()
    proPath = pathlib.Path(pro_filename)
    parentPath = proPath.parent
    os.chdir(str(parentPath))
    try:
        subprocess.check_output('lrelease ' + proPath.name)
        print('qmake executed for ' + proPath.name)
    except subprocess.CalledProcessError:
        pass
    os.chdir(cwd)


print('executing lrelease ...')
idev.recursiveExec("..", "\.pro$", lrelease)
Example #11
0
def copyFromSrc():
    idev.recursiveExec("..", "\.ts$", copydics)
Example #12
0
def shrinkDictsInSrc():
    idev.recursiveExec("..", "\.ts$", shrinkdics)
Example #13
0
parser.add_argument('name_to', metavar='NAME_TO', type=str, help='The name renamed to which') 
args = parser.parse_args()

name_from = args.name_from
name_to = args.name_to

def renamefunc(path):
  """ Rename function
  """
  with open(path, 'r', encoding = 'utf-8') as f:
    lines = f.readlines()
    newlines = []
    for line in lines:
      newline = line.replace(name_from, name_to)
      newlines.append(newline)

  if lines == newlines:
    return

  # write result
  with open(path, 'w', encoding = 'utf-8') as f:
    for line in newlines:
      line = line.replace('\n', '\r\n')
      f.write(line)

print('renaming function from ' + name_from + ' to ' + name_to + ' ...')

idev.recursiveExec("../libs", "\.(h|cpp)$", renamefunc)
idev.recursiveExec("../apps", "\.(h|cpp)$", renamefunc)

Example #14
0
import iricdevtool as idev


def addconst(path):
    """ Add const keywords to function that should be made constant
  """
    print("Checking: " + path)
    try:
        with open(path, 'r', encoding='utf-8') as f:
            lines = f.readlines()

    except:
        print(path)


print('listing files with non-ascii characters...')

#listnonascii("japanese.txt")

idev.recursiveExec("../libs", "\.h$", addconst)
idev.recursiveExec("../apps", "\.h$", addconst)
Example #15
0
        f.write(line + '\r\n')
      f.write('\r\n')

    if len(iric_incs) > 0:
      for line in iric_incs:
        f.write(line + '\r\n')
      f.write('\r\n')

    if len(qt_incs) > 0:
      for line in qt_incs:
        f.write(line + '\r\n')
      f.write('\r\n')

    if len(vtk_incs) > 0:
      for line in vtk_incs:
        f.write(line + '\r\n')
      f.write('\r\n')

    if len(std_incs) > 0:
      for line in std_incs:
        f.write(line + '\r\n')
      f.write('\r\n')

    for line in lines:
      f.write(line)


print('sorting includes in cpp files...')
idev.recursiveExec("../libs", "\.cpp$", sortincludes)
idev.recursiveExec("../apps", "\.cpp$", sortincludes)