当前位置: 首页>>代码示例>>Python>>正文


Python Movie.generate_new_name方法代码示例

本文整理汇总了Python中movie.Movie.generate_new_name方法的典型用法代码示例。如果您正苦于以下问题:Python Movie.generate_new_name方法的具体用法?Python Movie.generate_new_name怎么用?Python Movie.generate_new_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在movie.Movie的用法示例。


在下文中一共展示了Movie.generate_new_name方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: load_movies_run

# 需要导入模块: from movie import Movie [as 别名]
# 或者: from movie.Movie import generate_new_name [as 别名]
 def load_movies_run(self, filepaths):
     renaming_rule = utils.preferences.value("renaming_rule").toString()
     # loop on file paths
     for filepath in filepaths:
         # set loading label text, show current file name
         self.ui.label_loading.setText(QApplication.translate('GUI', "Getting information from ")\
                                        + os.path.split(filepath)[1])
         # create a new movie object
         movie = Movie(filepath)
         # generate new movie name based on renaming rule
         movie.generate_new_name(renaming_rule)
         # add movie to list
         self.movies.append(movie)
         # insert a new row in movie table
         self.ui.table_movies.insertRow(self.ui.table_movies.rowCount())
         # create a table item with original movie file name
         item_original_name = QTableWidgetItem(movie.original_file_name())
         item_original_name.setForeground(QBrush(Qt.black))
         self.ui.table_movies.setItem(self.ui.table_movies.rowCount() - 1, 0, item_original_name)
         # create a table item with new movie file name
         item_new_name = QTableWidgetItem(movie.new_file_name())
         item_new_name.setForeground(QBrush(Qt.black))
         self.ui.table_movies.setItem(self.ui.table_movies.rowCount() - 1, 1, item_new_name)
     self.load_movies_finished.emit()
开发者ID:meloi,项目名称:almoviesrenamer,代码行数:26,代码来源:gui.py

示例2: RenamingRuleDialog

# 需要导入模块: from movie import Movie [as 别名]
# 或者: from movie.Movie import generate_new_name [as 别名]

#.........这里部分代码省略.........
        """
        populate renaming rule by rule read from settings
        """

        renaming_rule = utils.preferences.value("renaming_rule").toString()
        # split rule
        rules = renaming_rule.split('.')
        # if rule is empty, reset it to 'title'
        if rules[0] == '':
            rules[0] = Movie.TITLE
            renaming_rule = Movie.TITLE
            utils.preferences.setValue("renaming_rule", renaming_rule)
        visual_rule = []
        # loop on rules
        for rule in rules:
            visual_rule.append(self.RENAMING_TO_VISUAL_RULE[rule])
        self.ui.list_visual_rule.addItems(visual_rule)

    def update_representations(self):
        duration_index = utils.preferences.value("duration_representation").toInt()[0]
        duration_representation = PreferencesDialog.DURATION_REPRESENTATIONS[duration_index]
        self.ui.label_duration_representation.setText(duration_representation)

        language_index = utils.preferences.value("language_representation").toInt()[0]
        language_representation = PreferencesDialog.LANGUAGE_REPRESENTATIONS[language_index]
        self.ui.label_language_representation.setText(language_representation)

        separator_index = utils.preferences.value("words_separator").toInt()[0]
        separator_representation = PreferencesDialog.WORDS_SEPARATORS_REPRESENTATIONS[separator_index]
        self.ui.label_separator_representation.setText(separator_representation)

    def update_example_movie(self, renaming_rule):
        # generate new name for example movie
        example_movie_new_name = self.example_movie.generate_new_name(renaming_rule)
        # show it on label
        self.ui.label_example_movie_name.setText(example_movie_new_name)

    def rule_changed(self, parent = None, start = None, end = None):
        """
        called when renaming rule changes
        
        creates and saves new renaming rule, and generate the movie example's new name
        """

        rule = []
        for index in range(self.ui.list_visual_rule.count()):
            text = self.ui.list_visual_rule.item(index).text()
            # when an item is moved inside the list_visual_rule, firstly 
            # a new empty item is inserted into the destination location, then 
            # the item from source location is deleted. that function is called 
            # for both events (insertion and deletion), and when is called for
            # the insertion event after a list items move, the list contains an empty item,
            # which is a kind of error. 
            if text != '':
                rule.append(self.VISUAL_TO_RENAMING_RULE[text])
        # creates renaming rule
        renaming_rule = '.'.join(rule)
        #save renaming rule on settings
        utils.preferences.setValue("renaming_rule", renaming_rule)
        #update example movie
        self.update_example_movie(renaming_rule)

    def remove_rule(self):
        """
        removes selected rule
        """
开发者ID:meloi,项目名称:almoviesrenamer,代码行数:70,代码来源:gui.py


注:本文中的movie.Movie.generate_new_name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。