Ejemplo n.º 1
0
 def _redraw(self):
     figure = self.figure
     axes = figure.axes[0]
     axes.clear()
     if self.data.step_x == True and self.data.step_y == True:
         x = self.data.plot_displ_step[1]
         y = self.data.plot_reaction_step[1]
         axes.plot(x, y, 'b-x', linewidth=2)
         axes.set_title(os_path_split(self.data.out_file)[-1])
         axes.set_xlabel('step', fontsize=16)
         axes.set_ylabel('step', fontsize=16)  # , fontsize = 16
     elif self.data.step_x == True and self.data.step_y == False:
         x = self.data.plot_displ_step[1]
         y = self.data.plot_reaction_step[0]
         axes.plot(x, y, 'b-x', linewidth=2)
         axes.set_title(os_path_split(self.data.out_file)[-1])
         axes.set_xlabel('step', fontsize=16)
         axes.set_ylabel('force', fontsize=16)  # , fontsize = 16
     elif self.data.step_x == False and self.data.step_y == True:
         x = self.data.plot_displ_step[0]
         y = self.data.plot_reaction_step[1]
         axes.plot(x, y, 'b-x', linewidth=2)
         axes.set_title(os_path_split(self.data.out_file)[-1])
         axes.set_xlabel('displ', fontsize=16)
         axes.set_ylabel('step', fontsize=16)  # , fontsize = 16
     else:
         x = self.data.plot_displ_step[0]
         y = self.data.plot_reaction_step[0]
         axes.plot(x, y, 'b-x', linewidth=2)
         axes.set_title(os_path_split(self.data.out_file)[-1])
         axes.set_xlabel('displ', fontsize=16)
         axes.set_ylabel('force', fontsize=16)  # , fontsize = 16
     plt.setp(axes.get_xticklabels(), position=(0, -.01))
     self.data_changed = True
Ejemplo n.º 2
0
 def _update_strokes(self):
     strokes = self._strokes()
     if strokes:
         translations = self._engine.raw_lookup_from_all(strokes)
         if translations:
             # i18n: Widget: “AddTranslationWidget”.
             info = self._format_label(_('{strokes} maps to '), (strokes, ))
             entries = [
                 self._format_label(
                     ('• ' if i else '') +
                     '<bf>{translation}<bf/>\t({filename})', None,
                     translation,
                     os_path_split(resource_filename(dictionary.path))[1])
                 for i, (translation, dictionary) in enumerate(translations)
             ]
             if (len(entries) > 1):
                 # i18n: Widget: “AddTranslationWidget”.
                 entries.insert(1, '<br />' + _('Overwritten entries:'))
             info += '<br />'.join(entries)
         else:
             info = self._format_label(
                 # i18n: Widget: “AddTranslationWidget”.
                 _('{strokes} is not mapped in any dictionary'),
                 (strokes, ))
     else:
         info = ''
     self.strokes_info.setText(info)
Ejemplo n.º 3
0
 def on_strokes_edited(self):
     mapping_is_valid = self.strokes.hasAcceptableInput()
     if mapping_is_valid != self._mapping_is_valid:
         self._mapping_is_valid = mapping_is_valid
         self.mappingValid.emit(mapping_is_valid)
     if not mapping_is_valid:
         return
     strokes = self._strokes()
     if strokes:
         translations = self._engine.raw_lookup_from_all(strokes)
         if translations:
             # i18n: Widget: “AddTranslationWidget”.
             info = self._format_label(_('{strokes} maps to '), (strokes,))
             entries = [
                 self._format_label(
                     ('• ' if i else '') + '<bf>{translation}<bf/>\t({filename})',
                     None,
                     translation,
                     os_path_split(resource_filename(dictionary.path))[1]
                 ) for i, (translation, dictionary) in enumerate(translations)
             ]
             if (len(entries) > 1):
                 # i18n: Widget: “AddTranslationWidget”.
                 entries.insert(1, '<br />' + _('Overwritten entries:'))
             info += '<br />'.join(entries)
         else:
             info = self._format_label(
                 # i18n: Widget: “AddTranslationWidget”.
                 _('{strokes} is not mapped in any dictionary'),
                 (strokes, )
             )
     else:
         info = ''
     self.strokes_info.setText(info)
Ejemplo n.º 4
0
def import_python_file(file_path):
    """Import module from file:
       https://stackoverflow.com/questions/2349991/how-to-import-other-python-files/55892361#55892361"""
    abs_file_path = abspath(file_path)
    pathname, filename = os_path_split(abs_file_path)
    sys.path.append(pathname)
    modname = splitext(filename)[0]
    module = importlib.import_module(modname)
    return module
Ejemplo n.º 5
0
 def save_code(self, obj):
     """saves the code containing the passed in object"""
     if obj is not None:
         module_path, ext = os_path_splitext(getfile(obj))
         code_file_path = module_path + '.py'   # Should get the py file, not the pyc, if compiled.
         code_file_copy_path = self.dir_path+self.divider+os_path_split(module_path)[1]+".pyb"
         if not os_path_exists(code_file_copy_path):
             copyfile(code_file_path, code_file_copy_path)
             log_info("Saved code to: {0}".format(code_file_copy_path))
Ejemplo n.º 6
0
def get_module(path, module_name=False):
    if not module_name:
        module_name = re.sub(r"[\.][^\.]+$", "", os_path_split(path)[-1])
    
    spec   = import_util.spec_from_file_location(module_name, path)
    module = import_util.module_from_spec(spec)
    sys.modules[spec.name] = module 
    spec.loader.exec_module(module)

    return module
Ejemplo n.º 7
0
 def save_code(self, obj):
     """saves the code containing the passed in object"""
     if obj is not None:
         module_path, ext = os_path_splitext(getfile(obj))
         code_file_path = module_path + '.py'  # Should get the py file, not the pyc, if compiled.
         code_file_copy_path = self.dir_path + self.divider + os_path_split(
             module_path)[1] + ".pyb"
         if not os_path_exists(code_file_copy_path):
             copyfile(code_file_path, code_file_copy_path)
             log_info("Saved code to: {0}".format(code_file_copy_path))
Ejemplo n.º 8
0
    def mergeExcel_Location(self):
        now = time_strftime("%Y-%m-%d-%H-%M-%S", time_localtime())
        self.excelOutputPath, _ = QFileDialog.getSaveFileName(
            self, "选择Excel保存路径", '每日健康打卡位置汇总(%s)' % now,
            "Excel files(*.xlsx , *.xls)")
        self.excelDir, self.excelName = os_path_split(self.excelOutputPath)

        if len(self.excelOutputPath.strip()) != 0:
            self.mergeExcelStart()
            self.mergeExcel()
            self.mergeExcelEnd()
Ejemplo n.º 9
0
 def _redraw(self):
     figure = self.figure
     axes = figure.axes[0]
     axes.clear()
     mask = self.data.reaction_data[:, 0] == self.data.node
     axes.plot(hstack([0, self.data.reaction_data[mask][:, 2]]), "b-x", linewidth=2)
     axes.set_title(os_path_split(self.data.out_file)[-1])
     axes.set_xlabel("step", fontsize=16)
     axes.set_ylabel("force", fontsize=16)  # , fontsize = 16
     plt.setp(axes.get_xticklabels(), position=(0, -0.01))
     self.data_changed = True
Ejemplo n.º 10
0
def checkParentalProtection(directory):
	if hasattr(config.ParentalControl, 'moviepinactive'):
		if config.ParentalControl.moviepinactive.value:
			directory = os_path_split(directory)[0]
			directory = realpath(directory)
			directory = abspath(directory)
			if directory[-1] != "/":
				directory += "/"
			is_protected = config.movielist.moviedirs_config.getConfigValue(directory, "protect")
			if is_protected is not None and is_protected == 1:
				return True
	return False
Ejemplo n.º 11
0
def checkParentalProtection(directory):
	if hasattr(config.ParentalControl, 'moviepinactive'):
		if config.ParentalControl.moviepinactive.value:
			directory = os_path_split(directory)[0]
			directory = realpath(directory)
			directory = abspath(directory)
			if directory[-1] != "/":
				directory += "/"
			is_protected = config.movielist.moviedirs_config.getConfigValue(directory, "protect")
			if is_protected is not None and is_protected == 1:
				return True
	return False
Ejemplo n.º 12
0
def get_current_version() -> str:
    """Gives current version str

    Gives version based on 'config.ini' in application's folder. If data is
    corrupted then "Cannot read 'config.ini' file" str returns
    """
    config: ConfigParser = ConfigParser()

    current_dir: str
    parent_dir: str

    current_dir, _ = os_path_split(__file__)
    parent_dir, _ = os_path_split(current_dir)

    try:
        config.read(os_path_join(parent_dir, 'config.ini'))
    except configparser_ParsingError:
        pass

    if 'VERSION' not in config or 'current_version' not in config['VERSION']:
        return "Cannot read 'config.ini' file"
    else:
        return config['VERSION']['current_version']
Ejemplo n.º 13
0
def scriptInitPaths(base, subdir=True):
    all = []
    paths = []
    
    base = os_path_split(base)[0] # Remove the ending of the paths!
    
    for mod in glob("%s/*.py" % base):
        modm = mod.split(os_seperator)[-1].replace('.py', '')
        if modm == "__init__":
            continue

        all.append(modm)
    
    if subdir:
        for mod in glob("%s/*/__init__.py" % base):
            paths.append(mod.split(os_seperator)[-2])
    return all, paths
Ejemplo n.º 14
0
def scriptInitPaths(base, subdir=True):
    all = []
    paths = []

    base = os_path_split(base)[0]  # Remove the ending of the paths!

    for mod in glob("%s/*.py" % base):
        modm = mod.split(os_seperator)[-1].replace('.py', '')
        if modm == "__init__":
            continue

        all.append(modm)

    if subdir:
        for mod in glob("%s/*/__init__.py" % base):
            paths.append(mod.split(os_seperator)[-2])
    return all, paths
Ejemplo n.º 15
0
from os.path import (split as os_path_split, abspath as os_path_abspath)
from sys import path as sys_path

ui_folder_path, _ = os_path_split(os_path_abspath(__file__))

ogg_vorbis_root, _ = os_path_split(ui_folder_path)

sys_path.append(ogg_vorbis_root)