Project/Project.py

changeset 5533
3c908e3b6e5c
parent 5462
52b2f19226e7
child 5555
5ece4e830780
equal deleted inserted replaced
5532:3a7c5deab9b7 5533:3c908e3b6e5c
4871 lst.append(entry) 4871 lst.append(entry)
4872 lst.sort() 4872 lst.sort()
4873 if "PKGLIST" in lst: 4873 if "PKGLIST" in lst:
4874 lst.remove("PKGLIST") 4874 lst.remove("PKGLIST")
4875 4875
4876 # build the header to indicate a freshly generated list
4877 header = [
4878 ";",
4879 "; initial_list (REMOVE THIS LINE WHEN DONE)",
4880 ";",
4881 " ",
4882 ]
4883
4876 # write the file 4884 # write the file
4877 try: 4885 try:
4878 if self.pdata["EOL"] == 0: 4886 if self.pdata["EOL"] == 0:
4879 newline = None 4887 newline = None
4880 else: 4888 else:
4881 newline = self.getEolString() 4889 newline = self.getEolString()
4882 pkglistFile = open(pkglist, "w", encoding="utf-8", newline=newline) 4890 pkglistFile = open(pkglist, "w", encoding="utf-8", newline=newline)
4891 pkglistFile.write("\n".join(header) + "\n")
4883 pkglistFile.write( 4892 pkglistFile.write(
4884 "\n".join([Utilities.fromNativeSeparators(f) for f in lst])) 4893 "\n".join([Utilities.fromNativeSeparators(f) for f in lst]))
4885 pkglistFile.write("\n") # ensure the file ends with an empty line 4894 pkglistFile.write("\n") # ensure the file ends with an empty line
4886 pkglistFile.close() 4895 pkglistFile.close()
4887 except IOError as why: 4896 except IOError as why:
4965 4974
4966 lines = names.splitlines() 4975 lines = names.splitlines()
4967 archiveName = "" 4976 archiveName = ""
4968 archiveVersion = "" 4977 archiveVersion = ""
4969 names = [] 4978 names = []
4979 listOK = True
4970 for line in lines: 4980 for line in lines:
4971 if line.startswith(";"): 4981 if line.startswith(";"):
4972 line = line[1:].strip() 4982 line = line[1:].strip()
4973 # it's a comment possibly containing a directive 4983 # it's a comment possibly containing a directive
4974 # supported directives are: 4984 # supported directives are:
4976 # - archive_version= defines the version of the archive 4986 # - archive_version= defines the version of the archive
4977 if line.startswith("archive_name="): 4987 if line.startswith("archive_name="):
4978 archiveName = line.split("=")[1] 4988 archiveName = line.split("=")[1]
4979 elif line.startswith("archive_version="): 4989 elif line.startswith("archive_version="):
4980 archiveVersion = line.split("=")[1] 4990 archiveVersion = line.split("=")[1]
4981 else: 4991 elif line.startswith("initial_list "):
4982 names.append(line) 4992 E5MessageBox.critical(
4993 self.ui,
4994 self.tr("Create Plugin Archive"),
4995 self.tr(
4996 """<p>The file <b>{0}</b> is not ready yet."""
4997 """</p><p>Please rework it and delete the"""
4998 """'; initial_list' line of the header."""
4999 """</p>""").format(os.path.basename(pkglist)))
5000 errors += 1
5001 count += 1
5002 listOK = False
5003 break
5004 elif line.strip():
5005 names.append(line.strip())
5006
5007 if not listOK:
5008 continue
5009
4983 names = sorted(names) 5010 names = sorted(names)
4984 if archiveName: 5011 if archiveName:
4985 archive = os.path.join(self.ppath, archiveName) 5012 archive = os.path.join(self.ppath, archiveName)
4986 else: 5013 else:
4987 archive = os.path.join( 5014 archive = os.path.join(

eric ide

mercurial