Пример #1
0
	def OnLoadLauncher(self, event=None):
		dia = GetFileOpenDialog(GetMainWindow(), GT(u'Open Launcher'))

		if ShowDialog(dia):
			path = dia.GetPath()

			data = ReadFile(path, split=True, convert=list)

			# Remove unneeded lines
			if data[0] == u'[Desktop Entry]':
				data = data[1:]

			self.Reset()
			# First line needs to be changed to '1'
			data.insert(0, u'1')
			self.Set(u'\n'.join(data))
Пример #2
0
    def OnLoadLauncher(self, event=None):
        dia = GetFileOpenDialog(GetMainWindow(), GT(u'Open Launcher'))

        if ShowDialog(dia):
            path = dia.GetPath()

            data = ReadFile(path, split=True, convert=list)

            # Remove unneeded lines
            if data[0] == u'[Desktop Entry]':
                data = data[1:]

            self.Reset()
            # First line needs to be changed to '1'
            data.insert(0, u'1')
            self.Set(u'\n'.join(data))
Пример #3
0
	def ExportBuild(self, target, installedSize=0):
		self.Export(target, u'control')

		absolute_filename = ConcatPaths((target, u'control'))

		if not os.path.isfile(absolute_filename):
			return GT(u'Control file was not created')

		if installedSize:
			control_data = ReadFile(absolute_filename, split=True, convert=list)

			size_line = u'Installed-Size: {}'.format(installedSize)
			if len(control_data) > 3:
				control_data.insert(3, size_line)

			else:
				control_data.append(size_line)

			# Be sure not to strip trailing newline (dpkg is picky)
			WriteFile(absolute_filename, control_data, noStrip=u'\n')

		return GT(u'Control file created: {}').format(absolute_filename)
Пример #4
0
 def ExportBuild(self, target, installedSize=0):
     self.Export(target, u'control')
     
     absolute_filename = ConcatPaths((target, u'control'))
     
     if not os.path.isfile(absolute_filename):
         return GT(u'Control file was not created')
     
     if installedSize:
         control_data = ReadFile(absolute_filename, split=True, convert=list)
         
         size_line = u'Installed-Size: {}'.format(installedSize)
         if len(control_data) > 3:
             control_data.insert(3, size_line)
         
         else:
             control_data.append(size_line)
         
         # Be sure not to strip trailing newline (dpkg is picky)
         WriteFile(absolute_filename, control_data, noStrip=u'\n')
     
     return GT(u'Control file created: {}').format(absolute_filename)
Пример #5
0
 def OnTemplateFull(self, event=None):
     selected_template = self.sel_templates.GetStringSelection()
     template_file = self.GetLicensePath(selected_template)
     
     if self.DestroyLicenseText():
         if not template_file or not os.path.isfile(template_file):
             ShowErrorDialog(GT(u'Could not locate license file: {}').format(self.GetSelectedName()))
             
             return
         
         Logger.Debug(__name__, u'Copying license {}'.format(template_file))
         
         license_text = ReadFile(template_file, noStrip=u' ')
         
         # Number defines how many empty lines to add after the copyright header
         # Boolean/Integer defines whether copyright header should be centered/offset
         add_header = {
             u'Artistic': (1, True),
             u'BSD': (0, False),
         }
         
         template_name = os.path.basename(template_file)
         if template_name in add_header:
             license_text = license_text.split(u'\n')
             
             empty_lines = add_header[template_name][0]
             for L in range(empty_lines):
                 license_text.insert(0, wx.EmptyString)
             
             header = copyright_header.format(GetYear())
             
             center_header = add_header[template_name][1]
             if center_header:
                 Logger.Debug(__name__, u'Centering header...')
                 
                 offset = 0
                 
                 # Don't use isinstance() here because boolean is an instance of integer
                 if type(center_header) == int:
                     offset = center_header
                 
                 else:
                     # Use the longest line found in the text to center the header
                     longest_line = GetLongestLine(license_text)
                     
                     Logger.Debug(__name__, u'Longest line: {}'.format(longest_line))
                     
                     header_length = len(header)
                     if header_length < longest_line:
                         offset = (longest_line - header_length) / 2
                 
                 if offset:
                     Logger.Debug(__name__, u'Offset: {}'.format(offset))
                     
                     header = u'{}{}'.format(u' ' * offset, header)
             
             # Special changes for BSD license
             if template_name == u'BSD':
                 line_index = 0
                 for LI in license_text:
                     if u'copyright (c)' in LI.lower():
                         license_text[line_index] = header
                         
                         break
                     
                     line_index += 1
             
             else:
                 license_text.insert(0, header)
             
             license_text = u'\n'.join(license_text)
         
         if not license_text:
             ShowErrorDialog(GT(u'License template is empty'))
             
             return
         
         self.dsp_copyright.SetValue(license_text)
         self.dsp_copyright.SetInsertionPoint(0)
     
     self.dsp_copyright.SetFocus()
Пример #6
0
	def OnTemplateFull(self, event=None):
		selected_template = self.sel_templates.GetStringSelection()
		template_file = self.GetLicensePath(selected_template)

		if self.DestroyLicenseText():
			if not template_file or not os.path.isfile(template_file):
				ShowErrorDialog(GT(u'Could not locate license file: {}').format(self.GetSelectedName()))

				return

			Logger.Debug(__name__, u'Copying license {}'.format(template_file))

			license_text = ReadFile(template_file, noStrip=u' ')

			# Number defines how many empty lines to add after the copyright header
			# Boolean/Integer defines whether copyright header should be centered/offset
			add_header = {
				u'Artistic': (1, True),
				u'BSD': (0, False),
			}

			template_name = os.path.basename(template_file)
			if template_name in add_header:
				license_text = license_text.split(u'\n')

				empty_lines = add_header[template_name][0]
				for L in range(empty_lines):
					license_text.insert(0, wx.EmptyString)

				header = copyright_header.format(GetYear())

				center_header = add_header[template_name][1]
				if center_header:
					Logger.Debug(__name__, u'Centering header...')

					offset = 0

					# Don't use isinstance() here because boolean is an instance of integer
					if type(center_header) == int:
						offset = center_header

					else:
						# Use the longest line found in the text to center the header
						longest_line = GetLongestLine(license_text)

						Logger.Debug(__name__, u'Longest line: {}'.format(longest_line))

						header_length = len(header)
						if header_length < longest_line:
							offset = (longest_line - header_length) / 2

					if offset:
						Logger.Debug(__name__, u'Offset: {}'.format(offset))

						header = u'{}{}'.format(u' ' * offset, header)

				# Special changes for BSD license
				if template_name == u'BSD':
					line_index = 0
					for LI in license_text:
						if u'copyright (c)' in LI.lower():
							license_text[line_index] = header

							break

						line_index += 1

				else:
					license_text.insert(0, header)

				license_text = u'\n'.join(license_text)

			if not license_text:
				ShowErrorDialog(GT(u'License template is empty'))

				return

			self.dsp_copyright.SetValue(license_text)
			self.dsp_copyright.SetInsertionPoint(0)

		self.dsp_copyright.SetFocus()