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


Python FileHelper.get_script_type方法代码示例

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


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

示例1: update_check_script

# 需要导入模块: from preupg.utils import FileHelper [as 别名]
# 或者: from preupg.utils.FileHelper import get_script_type [as 别名]
 def update_check_script(self, updates, author=None):
     """
     The function updates check script with license file
     and with API functions like check_rpm_to and check_applies_to
     """
     script_type = FileHelper.get_script_type(self.full_path_name)
     if author is None:
         author = "<empty_line>"
     generated_section, functions = ModuleHelper.generate_common_stuff(settings.license % author,
                                                                       updates,
                                                                       script_type)
     lines = FileHelper.get_file_content(self.full_path_name, "rb", method=True)
     if not [x for x in lines if re.search(r'#END GENERATED SECTION', x)]:
         MessageHelper.print_error_msg("#END GENERATED SECTION is missing in check_script %s" % self.full_path_name)
         raise MissingHeaderCheckScriptError
     for func in functions:
         lines = [x for x in lines if func not in x.strip()]
     output_text = ""
     for line in lines:
         if '#END GENERATED SECTION' in line:
             new_line = '\n'.join(generated_section)
             new_line = new_line.replace('<empty_line>', '').replace('<new_line>', '')
             output_text += new_line+'\n'
             if 'check_applies' in updates:
                 component = updates['check_applies']
             else:
                 component = "distribution"
             if script_type == "sh":
                 output_text += 'COMPONENT="'+component+'"\n'
             else:
                 output_text += 'set_component("'+component+'")\n'
         output_text += line
     FileHelper.write_to_file(self.full_path_name, "wb", output_text)
开发者ID:AloisMahdal,项目名称:preupgrade-assistant,代码行数:35,代码来源:script_utils.py

示例2: update_check_script

# 需要导入模块: from preupg.utils import FileHelper [as 别名]
# 或者: from preupg.utils.FileHelper import get_script_type [as 别名]
 def update_check_script(self, updates, author=None):
     """
     The function updates check script with license file
     and with API functions like check_rpm_to and check_applies_to
     """
     script_type = FileHelper.get_script_type(self.check_script_path)
     if author is None:
         author = "<empty_line>"
     generated_section, functions = ModuleHelper.generate_common_stuff(
         settings.license % author, updates, script_type)
     lines = FileHelper.get_file_content(self.check_script_path, "rb",
                                         method=True)
     if not [x for x in lines if re.search(r'#END GENERATED SECTION', x)]:
         raise MissingHeaderCheckScriptError(self.check_script_path)
     for func in functions:
         lines = [x for x in lines if func not in x.strip()]
     output_text = ""
     for line in lines:
         if '#END GENERATED SECTION' in line:
             new_line = '\n'.join(generated_section)
             new_line = new_line.replace('<empty_line>',
                                         '').replace('<new_line>', '')
             output_text += new_line + '\n'
         output_text += line
     FileHelper.write_to_file(self.check_script_path, "wb", output_text)
开发者ID:upgrades-migrations,项目名称:preupgrade-assistant,代码行数:27,代码来源:script_utils.py

示例3: solution_modification

# 需要导入模块: from preupg.utils import FileHelper [as 别名]
# 或者: from preupg.utils.FileHelper import get_script_type [as 别名]
 def solution_modification(self, key):
     """Function handles a solution text or scripts"""
     fix_tag = []
     for k in key['solution'].split(','):
         self.mh.check_scripts('solution')
         script_type = FileHelper.get_script_type(self.mh.get_full_path_name_solution())
         if script_type == "txt":
             fix_tag.append(xml_tags.FIX_TEXT)
         else:
             fix_tag.append(xml_tags.FIX)
         if 'solution_type' in key:
             solution_type = key['solution_type']
         else:
             solution_type = "text"
         self.update_values_list(fix_tag, "{solution_text}", solution_type)
         self.update_values_list(fix_tag, "{solution}", k.strip())
         self.update_values_list(fix_tag, "{script_type}", script_type)
     self.update_values_list(self.rule, '{fix}', ''.join(fix_tag))
开发者ID:AloisMahdal,项目名称:preupgrade-assistant,代码行数:20,代码来源:xml_utils.py


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